How to Draw Phase Planes

A stage portrait of a dynamical system is a geometric representation that depicts the system'due south trajectories in the phase airplane. In this tutorial, we volition acquire how to depict the stage portrait of Van-Der-Political leader oscillatorinLaTeXusingTikZandPgfplots.

Phase portrait of Van der Pol Oscillator in TikZ

Let'southward start by the Limit Cycle

TheVan der Pol oscillator can be represented by the following differential equations:

Van der Pol equation TikZ

where μ is a scalar parameter indicating the damping strength. For μ, the nonlinear system has a stable limit wheel. Nonetheless, it doesn't accept an analytic solution that we can plot it directly in LaTeX using PGFplots parcel 😔.

💡 To remedy this issue, nosotros tin follow these steps:

1. Solve the differential equations of the Van der Political leader oscillator numerically (due east.g. Matlab, python).

2. Export the solution every bit a table of x and y.

3. Plot it in LaTeX using PGFplots packet .

1. Plot data using Pgfplots

In my case, I used Matlab/Simulink to simulate Van der Politician equations for μ=0.8. Then, I exported the solution (10 and y) to the workspace of Matlab and extracted steady country data that corresponds to the limit cycle trajectory.

The next LaTeX lawmaking plots the limit wheel from an external file, named data.txt, using the \addplot command.

              \documentclass[border=0.2cm]{standalone}  \usepackage{pgfplots} \pgfplotsset{compat = newest}  \begin{document} \begin{tikzpicture} \begin{axis}[ 	filigree=both, 	grid way={dashed,carmine!twenty}, 	xmin = -4, xmax = 4, 	ymin = -4, ymax = four, 	width = \textwidth, 	height = 0.7\textwidth, 	xlabel = {$10$}, 	ylabel = {$y$}, 	championship={Phase Portrait of Van Der Pol Oscillator} ]  % Plot the Limit Cycle  \addplot[ultra thick, red] file {data.txt};  \end{axis} \finish{tikzpicture}   \end{document}            

Limit Cycle of Van der Pol Oscillator in Pgfplots

Information technology should be noted that we plotted the country y in office of the state x but we need to highlight the evolution direction using pocket-size arrows.

2. Draw an arrow along a path

In the previous tutorial, "How to describe an arrow in the center of a line in TikZ?", we have presented dissimilar methods that tin can exist used in order to add an arrowhead along a path. We volition use method 2 based on decorations.markings library(repeated arrows case). Inspired by this mail service, A slight modification is considered.

            \documentclass[edge=0.2cm]{standalone}  \usepackage{pgfplots} \pgfplotsset{compat = newest}  % Ascertain arrow's style \usetikzlibrary{decorations.markings}  \tikzset{decorated arrows/.fashion={ 	postaction={ 		decorate, 		decoration={ 			markings, 			marking=betwixt positions 0 and i stride 15mm with {\arrow[black]{stealth};} 			} 		}, 	} }  \begin{certificate} \brainstorm{tikzpicture}  \brainstorm{axis}[ 	grid=both, 	grid mode={dashed,cherry-red!twenty}, 	xmin = -4, xmax = 4, 	ymin = -4, ymax = 4, 	width = \textwidth, 	tiptop = 0.7\textwidth, 	xlabel = {$ten$}, 	ylabel = {$y$}, 	title={Limit Cycle of Van Der Pol Oscillator} ]  % Plot the Limit Bike        \addplot[ultra thick, red, decorated arrows] file {data.txt};  \stop{centrality} \end{tikzpicture}  \end{document}          

Comments:

  • A TikZ style, nameddecorated arrows, is created using \tikzset command.
  • It creates repetitive arrows between 0 (start of the path) and 1 (finish of the path). A 15mm altitude between successive arrows.
  • Arrowhead fashion is chosen stealth with blackness color.
  • The created style (busy arrows) is add equally an option to \addplot which draws the path in question.

Van Der Pol Limit Cycle Arrows in LaTeX

iii. Plot trajectories (transient and steady states)

In the previous subsection, nosotros plotted the limit wheel of Van der Political leader oscillator, which is obtained by removing the transient part of the system's trajectory (this works equally we are dealing with a stable limit cycle). To add trajectories starting from dissimilar initial atmospheric condition, nosotros will follow the aforementioned steps as above.  Here is an example of two trajectories starting from dissimilar initial conditions exterior the limit cycle:

            \documentclass[edge=0.2cm]{standalone}  \usepackage{pgfplots} \pgfplotsset{compat = newest}  % Define arrow'southward manner \usetikzlibrary{decorations.markings}  % Pointer way ane \tikzset{busy arrows/.style={ 	postaction={ 		decorate, 		decoration={ 			markings, 			mark=between positions 0 and 1 step 15mm with {\arrow[black]{stealth};} 			} 		}, 	} }  % Arrow style ii \tikzset{busy arrows2/.way={ 	postaction={ 		decorate, 		decoration={ 			markings, 			mark=at position 15mm with {\arrow[black]{stealth};} 			} 		}, 	} }   \begin{document} \begin{tikzpicture}  \brainstorm{axis}[ 	grid=both, 	grid style={dashed}, 	xmin = -4, xmax = 4, 	ymin = -4, ymax = 4, 	width = \textwidth, 	tiptop = 0.7\textwidth, 	xlabel = {$x$}, 	ylabel = {$y$}, 	championship={Phase Portrait of Van Der Politico Oscillator} ]  % Trajectories \addplot[very thick, busy arrows2] file {data1.txt}; \addplot[very thick, decorated arrows2] file {data2.txt};   % Plot the Limit Cycle        \addplot[ultra thick, red, decorated arrows] file {data.txt};  \end{axis} \end{tikzpicture}  \finish{certificate}          

Comments:

  • As trajectories converge to the limit bike and to avoid likewise much arrows on the limit bike'due south path, we decorated trajectories with only one arrow head, positioned at 15mm from the starting the point.

4. Plot Vector Field

A vector field is an consignment of a minor vector (with a givenmagnitudeandmanagement) to each point in the stage plane. The direction and magnitude depends on the system dynamics.

Avector field tin can be fatigued in LaTeX usignPgfplotswithquiverselection. The commencement thing that we need is aset of points that fill the aeroplane.Then we add small arrows, tangent to the organisation'southward trajectories, at each signal.

Yous may wonder how ane can create a set of points that fills the phase plane using Pgfplots?This can be accomplished as follows:

1. Move to a 3D plot by using the command \addplot3;

two. Ascertain x and y domains (-4 to four in this instance)

iii. Choose your function z=0, this will provides a set up of points that fills the xy-aeroplane with z=0

four. Change the view from 3D to a 2D version (xy plane)

Here is the corresponding code:

            \documentclass[border=0.2cm]{standalone}  \usepackage{pgfplots} \pgfplotsset{compat = newest}  % Define pointer'south mode \usetikzlibrary{decorations.markings}  % Arrow way \tikzset{decorated arrows/.way={ 	postaction={ 		decorate, 		decoration={ 			markings, 			marker=between positions 0 and one footstep 15mm with {\arrow[black]{stealth};} 			} 		}, 	} }   \begin{certificate} \brainstorm{tikzpicture}  \brainstorm{axis}[ 	grid=both, 	grid manner={dashed,red!20}, 	xmin = -4, xmax = 4, 	ymin = -iv, ymax = iv, 	width = \textwidth, 	peak = 0.vii\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*(i-10^ii)*y-x)^two)}, 		five = {(0.viii*(i-x^two)*y-x)/sqrt(y^2+(0.8*(1-x^ii)*y-x)^two)}, 		scale arrows = 0.25, 	}, 	-stealth, 	domain = -4:4, 	domain y = -4:iv, 	lightgray]  {0};  % Plot the Limit Cycle        \addplot[ultra thick, red, busy arrows] file {information.txt};  \end{axis} \end{tikzpicture}  \stop{document}          

Comments:

  • The option view{0}{ninety} projects the plot into xy-plane.
  • quiver is used as an option to \addplot3 . We provide a normalized version of dx/dt and dy/dt to quiver .
  • Normalized equations yields clean results with normalized vectors. Magnitude information is lost in this example just we tin add together a color mapping.
  • Arrowhead style is chosen stealth .

We have reached the end of this tutorial, I hope you detect it useful 🥰.

If you have anyremarksorsuggestions, exercise not hesitate tocontact me, I will be happy to hear from you!

Thanks!

chowarorinced1959.blogspot.com

Source: https://latexdraw.com/phase-portrait-of-van-der-pol-oscillator/

0 Response to "How to Draw Phase Planes"

Postar um comentário

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel