|
LaTeXDraw.com
Phase portrait of Van-Der-Pol oscillator in TikZ
December 12, 2020
TeXLive.net
- \documentclass[border=0.2cm]{standalone}
-
- \usepackage{pgfplots}
- \pgfplotsset{compat = newest}
-
- % Define arrow's style
- \usetikzlibrary{decorations.markings}
-
- % Arrow style
- \tikzset{decorated arrows/.style={
- postaction={
- decorate,
- decoration={
- markings,
- mark=between positions 0 and 1 step 15mm with {\arrow[black]{stealth};}
- }
- },
- }
- }
-
-
- \begin{document}
- \begin{filecontents}{data.txt}
- -1.4524 -2.0041
- -1.5484 -1.8329
- -1.6354 -1.6464
- -1.7128 -1.4509
- -1.7804 -1.2526
- -1.8381 -1.0571
- -1.8863 -0.86899
- -1.9252 -0.69163
- -1.9556 -0.52729
- -1.9782 -0.37716
- -1.9936 -0.24155
- -2.0026 -0.12011
- -2.0058 -0.012026
- -2.004 0.083793
- -1.9976 0.16859
- -1.9873 0.24366
- -1.9734 0.31025
- -1.9564 0.36955
- -1.9366 0.42265
- -1.9142 0.47053
- -1.8896 0.51406
- -1.8629 0.55402
- -1.8342 0.59108
- -1.8038 0.62583
- -1.7717 0.65879
- -1.738 0.69041
- -1.7027 0.72111
- -1.6659 0.75124
- -1.6275 0.78112
- -1.5877 0.81105
- -1.5464 0.8413
- -1.5036 0.87212
- -1.4592 0.90377
- -1.4132 0.93647
- -1.3655 0.97046
- -1.3161 1.006
- -1.2649 1.0432
- -1.2118 1.0825
- -1.1566 1.1239
- -1.0994 1.1678
- -1.0398 1.2144
- -0.97786 1.264
- -0.91335 1.3167
- -0.84613 1.3729
- -0.77601 1.4326
- -0.7028 1.4961
- -0.62633 1.5635
- -0.54639 1.6348
- -0.46279 1.7098
- -0.37535 1.7884
- -0.2839 1.8701
- -0.18831 1.954
- -0.088478 2.0392
- 0.015613 2.1242
- 0.1239 2.2068
- 0.23622 2.2847
- 0.35224 2.3547
- 0.4715 2.4132
- 0.59331 2.4563
- 0.7168 2.4798
- 0.8409 2.4798
- 0.96433 2.4528
- 1.0857 2.3965
- 1.2035 2.3099
- 1.3162 2.1938
- 1.4224 2.0509
- 1.5209 1.8853
- 1.6106 1.7027
- 1.691 1.5093
- 1.7615 1.3112
- 1.8221 1.1144
- 1.873 0.92364
- 1.9146 0.7428
- 1.9475 0.57444
- 1.9723 0.42004
- 1.9897 0.28015
- 2.0005 0.15459
- 2.0054 0.042661
- 2.005 -0.05666
- 2 -0.14459
- 1.9907 -0.2224
- 1.9779 -0.29137
- 1.9617 -0.35271
- 1.9427 -0.40753
- 1.9211 -0.45686
- 1.8971 -0.50159
- 1.871 -0.54253
- 1.8429 -0.58038
- 1.813 -0.61576
- 1.7814 -0.6492
- 1.7481 -0.68117
- 1.7133 -0.71211
- 1.6769 -0.74237
- 1.639 -0.77229
- 1.5997 -0.80218
- 1.5588 -0.8323
- 1.5164 -0.86293
- 1.4725 -0.89431
- 1.427 -0.92668
- 1.3798 -0.96026
- 1.3309 -0.9953
- 1.2803 -1.032
- 1.2277 -1.0706
- 1.1732 -1.1114
- 1.1165 -1.1546
- 1.0577 -1.2004
- 0.99643 -1.249
- 0.9327 -1.3008
- 0.8663 -1.3559
- 0.79705 -1.4146
- 0.72478 -1.4769
- 0.64929 -1.5432
- 0.5704 -1.6133
- 0.4879 -1.6872
- 0.40162 -1.7648
- 0.31137 -1.8456
- 0.21701 -1.929
- 0.11844 -2.014
- 0.015605 -2.0992
- -0.091456 -2.1828
- -0.20261 -2.2623
- -0.31758 -2.335
- -0.43594 -2.3973
- -0.55707 -2.4454
- -0.68017 -2.4751
- -0.80422 -2.4825
- -0.92799 -2.4637
- -1.0501 -2.4163
- -1.1691 -2.3386
- -1.2835 -2.2311
- -1.3917 -2.0957
- -1.4926 -1.9363
- \end{filecontents}
- \begin{tikzpicture}
-
- \begin{axis}[
- grid=both,
- grid style={dashed,red!20},
- xmin = -4, xmax = 4,
- ymin = -4, ymax = 4,
- width = \textwidth,
- height = 0.7\textwidth,
- xlabel = {$x$},
- ylabel = {$y$},
- title={Phase Portrait of Van Der Pol Oscillator},
- view = {0}{90},
- ]
-
- % Vector Field
- \addplot3[
- quiver = {
- u = {y/sqrt(y^2+(0.8*(1-x^2)*y-x)^2)},
- v = {(0.8*(1-x^2)*y-x)/sqrt(y^2+(0.8*(1-x^2)*y-x)^2)},
- scale arrows = 0.25,
- },
- -stealth,
- domain = -4:4,
- domain y = -4:4,
- lightgray]
- {0};
-
- % Plot the Limit Cycle
- \addplot[ultra thick, red, decorated arrows] file {data.txt};
-
- \end{axis}
- \end{tikzpicture}
- \end{document}
复制代码 |
|