1 \documentclass{article
}
2 \usepackage[a4paper,margin=
2cm
]{geometry
}
3 \usepackage[T1]{fontenc}
4 \usepackage[latin1]{inputenc}%
5 \usepackage[garamond
]{mathdesign
}
6 \renewcommand{\ttdefault}{lmtt
}
7 \usepackage{pst-node,pst-eqdf
}
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 % Essai de Manuel Luque 19 février 2003
12 % transformé par Denis Girou le 25 février 2003
13 % révision le 14 septembre 2011
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16 \pst@addfams
{pst-plothsb
}
18 \define@key
[psset
]{pst-plothsb
}{HueBegin
}{% Between 0 and 1
19 \edef\PstParametricplotHSB@HueBegin
{#1}}
21 \define@key
[psset
]{pst-plothsb
}{HueEnd
}{% Between 0 and 1
22 \edef\PstParametricplotHSB@HueEnd
{#1}}
25 \define@key
[psset
]{pst-plothsb
}{HSB
}[true
]{\@nameuse
{Pst@HSB
#1}}
28 \psset{HueBegin=
0,HueEnd=
1,HSB=true
}
30 \def\parametricplotHSB{\pst@object
{parametricplotHSB
}}
31 \def\parametricplotHSB@i
{\@ifnextchar
[{\parametricplotHSB@do
}{\parametricplotHSB@do
[]}}
32 \def\parametricplotHSB@do
[#1]#2#3#4{{%
37 /dt
#3 t sub
\psk@plotpoints
\space div def
42 /Counter Counter
1 add def
43 /F@pstplot
\ifPst@algebraic (
#4)
44 tx@AlgToPs begin AlgToPs end cvx
52 \pst@number
\psyunit mul exch
53 \pst@number
\psxunit mul exch
55 {moveto
} % First point
56 {\ifPst@HSB
% Other points than the first one
59 Counter
\psk@plotpoints
\space div
60 \PstParametricplotHSB@HueEnd
\space
61 \PstParametricplotHSB@HueBegin
\space sub mul
62 \PstParametricplotHSB@HueBegin
\space add
70 } repeat
}% fin du code ps
71 \end@ClosedObj
}} % fin de la commande PSTricks
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 % adaptation de \parametricplotHSB
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 \def\listplotHSB{\pst@object
{listplotHSB
}}
82 \def\listplotHSB@i
#1{%
89 \pst@number
\psyunit mul exch
90 \pst@number
\psxunit mul exch
93 2 2 L
2 sub
{/i exch def
94 /x1 XY i get
\pst@number
\psxunit mul def
95 /y1 XY i
1 add get
\pst@number
\psyunit mul def
99 \PstParametricplotHSB@HueEnd
\space
100 \PstParametricplotHSB@HueBegin
\space sub mul
101 \PstParametricplotHSB@HueBegin
\space add
103 /Counter Counter
1 add def
113 /xObservateur abscisse Sin1 mul neg ordonnee Cos1 mul add def
114 /yObservateur abscisse Cos1Sin2 mul neg ordonnee Sin1Sin2 mul sub cote Cos2 mul add def
115 /zObservateur abscisse neg Cos1Cos2 mul ordonnee Sin1Cos2 mul sub cote Sin2 mul sub Dobs add def
116 /xScreen DScreen xObservateur mul zObservateur div def
117 /yScreen DScreen yObservateur mul zObservateur div def
121 \pst@addfams
{pst-pnodeTroisD
}
123 \define@key
[psset
]{pst-pnodeTroisD
}{THETA
}{\edef\psk@TroisD@Theta
{#1 }}
124 \define@key
[psset
]{pst-pnodeTroisD
}{PHI
}{\edef\psk@TroisD@Phi
{#1 }}
125 \define@key
[psset
]{pst-pnodeTroisD
}{Dobs
}{\edef\psk@TroisD@Dobs
{#1 }}
126 \define@key
[psset
]{pst-pnodeTroisD
}{Decran
}{\edef\psk@TroisD@Ecran
{#1 }}
127 \psset{THETA=
300,PHI=
20,Dobs=
200,Decran=
25}
128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
129 \def\pnodeTroisD{\@ifnextchar
[{\pst@pnodeTroisD
}{\pst@pnodeTroisD
[]}}
131 \def\pst@pnodeTroisD
[#1](
#2,
#3,
#4)
#5{{%
135 /THETA
\psk@TroisD@Theta
\space def
136 /PHI
\psk@TroisD@Phi
\space def
137 /Dobs
\psk@TroisD@Dobs
\space def
138 /DScreen
\psk@TroisD@Ecran
\space def
143 /Cos1Sin2 Cos1 Sin2 mul def
144 /Sin1Sin2 Sin1 Sin2 mul def
145 /Cos1Cos2 Cos1 Cos2 mul def
146 /Sin1Cos2 Sin1 Cos2 mul def
147 /xObservateur
#2 Sin1 mul neg
#3 Cos1 mul add def
148 /yObservateur
#2 Cos1Sin2 mul neg
#3 Sin1Sin2 mul sub
#4 Cos2 mul add def
149 /zObservateur
#2 neg Cos1Cos2 mul
#3 Sin1Cos2 mul sub
#4 Sin2 mul sub Dobs add def
150 /xScreen DScreen xObservateur mul zObservateur div def
151 /yScreen DScreen yObservateur mul zObservateur div def
152 xScreen yScreen)
{#5}}}
154 \title{L'attracteur de Lorenz avec PSTricks
}
158 \section{Présentation
}
159 Ceci n'est pas un cours sur l'attracteur de Lorenz, il existe sur internet un grand nombre de sites qui lui sont consacrés très complets et d'une grande qualité pédagogique. Il s'agit, plus simplement, de montrer que l'utilisation de PSTricks permet d'illustrer ce modèle très convenablement.
161 Pour résoudre numériquement le système de Lorenz :
165 \dfrac{\mathrm{d
}x
}{\mathrm{d
}t
}&=&
\sigma(x-y)\\
166 \dfrac{\mathrm{d
}y
}{\mathrm{d
}t
}&=&rx-y-z\\
167 \dfrac{\mathrm{d
}z
}{\mathrm{d
}t
}&=&xy-
\beta z
171 j'utilise une version très simplifiée de la macro
\verb+
\psplotDiffEqn+ de Dominique Rodriguez qui est incluse dans le package
\verb+pstricks-add+, mais qui était, à l'origine, un package `
\verb+pst-eqdf+' à elle seule. Dominique m'a donné la permission de modifier sa macro afin de pouvoir sauvegarder dans un tableau
\verb+postscript+, et/ou dans un fichier, toutes les valeurs nécessaires au dessin des figures et en particulier à la représentation en
3D du
\textit{papillon
}de Lorenz. Cette macro simplifiée, qui utilise la méthode Runge-Kutta~
4 est incluse dans un tout petit package dont j'ai gardé le même nom
\verb+pst-eqdf+, mais la macro a changé de nom
\verb+
\psequadiff+ car elle ne trace plus les fonctions directement.
173 Pour les couleurs, j'utilise une macro
\verb+
\listplotHSB+ qui est un complément à celle-ci :
\verb+
\parametricplotHSB+
\footnote{\url{http://melusine.eu.org/syracuse/G/pstricks/courbes-arc-en-ciel/
}}, que nous avions mise au point avec Denis Girou.
175 \section{Les étapes de la construction des figures
}
176 \subsection{Équations, paramètres et conditions initiales
}
177 Il faut d'abord définir les équations en notation algébrique pour la macro
\verb+
\psequadiff+ :
183 Rh*y
[0]-y
[1]-y
[0]*y
[2]|
%
187 ainsi que les paramètres :
195 puis les conditions initiales :
198 \def\conditionsInitiales{10 10 30}
200 Ce sont ces deux dernières définitions qu'il faudra modifier si on veut changer les conditions initiales et les paramètres.
201 \subsection{L'utilisation de la commande
\textbackslash{}psequadiff
}
203 \pstVerb{\parametres}%
207 whichabs=
0,whichord=
1,
208 saveData,filename=LorenzXY.dat,
209 plotpoints=
2501,algebraic
]{0}{25}{\conditionsInitiales}{\Lorenz}
211 Dans cet exemple, l'intervalle de temps choisi est de
0 à
25 s. Les grandeurs prises sur la pile sont $(x,y)$. Le nombre de points calculés vaut
2501.
212 Les valeurs, sur cet intervalle de temps, sont stockées dans le tableau
\verb+postscript+ :
\textsf{[\textbf{tabname
}=tabXY
]} avec
\textsf{tabXY
} qui est le nom que l'on choisit soi-même.
214 Pour ne pas refaire le calcul, on peut choisir d'enregistrer la liste de valeurs du couple $(x,y)$, en positionnant le booléen
\textsf{[saveData
]} à true, on choisit un nom pour le fichier avec :
\textsf{[\textbf{filename
}=LorenzXY.dat
]}. Par défaut, aucun fichier n'est enregistré.
216 saveData,filename=LorenzXY.dat,
218 Pour utiliser ce fichier, il suffit de faire :
220 \pstVerb{/XY
{(LorenzXY.dat) run
} def
}%
223 Vous pouvez utiliser la commande
\textbf{\textsf{lisplot
}} du package
\textsf{pst-plot
} qui offre davantage d'options que
\textsf{\textbf{listplotHSB
}}.
224 \subsection{Le tracé de la courbe
}
226 \listplotHSB[unit=
0.25]{tabXY aload pop
}%
228 \verb+
\listplotHSB+ permet de faire varier la couleur tout au long du tracé. Par défaut le paramètre
\textsf{hue
} de la définition d'une couleur dans le système
\textsf{hsb
} varie de
0 à
1. On peut fixer la plage de valeurs avec les
2 options suivantes :
230 \item \textsf{\textbf{HueBegin
}} avec une valeur comprise entre
0 et
1.
231 \item \textsf{\textbf{HueEnd
}} avec une valeur comprise entre
0 et
1.
233 Pour avoir une couleur uniforme tout au long du tracé, il faut désactiver l'option
\textsf{[\textbf{HSB
}=false
]} ainsi le tracé prendra la couleur que vous avez choisie avec l'option habituelle
\textsf{linecolor
}.
234 \section{Le tracé des courbes
}
235 \subsection{Le tracé de XY
}
240 Rh*y
[0]-y
[1]-y
[0]*y
[2]|
%
243 \def\conditionsInitiales{10 10 30}
250 \begin{pspicture
}(-
8,-
6)(
8,
8)
251 \psgrid[subgriddiv=
0,gridcolor=lightgray,griddots=
10,gridlabels=
0pt
]%
252 \pstVerb{\parametres}%
256 whichabs=
0,whichord=
1,
257 saveData,filename=LorenzXY.dat,
258 plotpoints=
2501,algebraic
]{0}{25}{\conditionsInitiales}{\Lorenz}
259 \listplotHSB[unit=
0.25]{tabXY aload pop
}%
265 \begin{pspicture
}(-
8,-
6)(
8,
8)
266 \psgrid[subgriddiv=
0,gridcolor=lightgray,griddots=
10,gridlabels=
0pt
]%
267 \pstVerb{\parametres}%
271 whichabs=
0,whichord=
1,
272 saveData,filename=LorenzXY.dat,
273 plotpoints=
2501,algebraic
]{0}{25}{\conditionsInitiales}{\Lorenz}
274 \listplotHSB[unit=
0.25]{tabXY aload pop
}%
279 \subsection{Le tracé de X(t)
}
281 \begin{pspicture
}(
0,-
5)(
13,
5.5)
282 \psgrid[subgriddiv=
0,gridcolor=lightgray,griddots=
10,gridlabels=
0pt
](
0,-
5)(
13,
5)
%
283 \pstVerb{\parametres}%
288 saveData,filename=LorenztX.dat,
289 plotpoints=
2501,algebraic
]{0}{25}{\conditionsInitiales}{\Lorenz}
290 \listplotHSB[yunit=
0.2,xunit=
0.5,HSB=false
]{tabtX aload pop
}%
293 \psline{<->
}(
13,
0)(
0,
0)(
0,
5)
297 \begin{pspicture
}(
0,-
5)(
13,
5)
298 \psgrid[subgriddiv=
0,gridcolor=lightgray,griddots=
10,gridlabels=
0pt
]%
299 \pstVerb{\parametres}%
304 saveData,filename=LorenztX.dat,
305 plotpoints=
2501,algebraic
]{0}{25}{\conditionsInitiales}{\Lorenz}
306 \listplotHSB[yunit=
0.2,xunit=
0.5,HSB=false
]{tabtX aload pop
}%
307 \uput[r
](
12.5,
0)
{$t$
}
311 \subsection{Le tracé de XZ
}
313 \begin{pspicture
}(-
8,
0)(
8,
12)
314 \psgrid[subgriddiv=
0,gridcolor=lightgray,griddots=
10,gridlabels=
0pt
]%
315 \pstVerb{\parametres}%
321 saveData,filename=LorenzXZ.dat,
322 plotpoints=
2501,algebraic
]{0}{25}{\conditionsInitiales}{\Lorenz}
323 \listplotHSB[linecolor=green,unit=
0.25,HueBegin=
.25,HueEnd=
0.65]{tabXZ aload pop
}%
329 \begin{pspicture
}(-
8,
0)(
8,
12)
330 \psgrid[subgriddiv=
0,gridcolor=lightgray,griddots=
10,gridlabels=
0pt
]%
331 \pstVerb{\parametres}%
337 saveData,filename=LorenzXZ.dat,
338 plotpoints=
2501,algebraic
]{0}{25}{\conditionsInitiales}{\Lorenz}
339 \listplotHSB[linecolor=green,unit=
0.25,HueBegin=
.25,HueEnd=
0.65]{tabXZ aload pop
}%
344 \subsection{Le tracé de YZ
}
346 \begin{pspicture
}(-
8,
0)(
8,
12)
347 \psgrid[subgriddiv=
0,gridcolor=lightgray,griddots=
10,gridlabels=
0pt
]%
348 \pstVerb{\parametres}%
354 saveData,filename=LorenzYZ.dat,
355 plotpoints=
2501,algebraic
]{0}{25}{\conditionsInitiales}{\Lorenz}
356 \listplotHSB[linecolor=magenta,unit=
0.25,HueBegin=
0.65,HueEnd=
1]{tabYZ aload pop
}%
362 \begin{pspicture
}(-
8,
0)(
8,
12)
363 \psgrid[subgriddiv=
0,gridcolor=lightgray,griddots=
10,gridlabels=
0pt
]%
364 \pstVerb{\parametres}%
370 saveData,filename=LorenzYZ.dat,
371 plotpoints=
2501,algebraic
]{0}{25}{\conditionsInitiales}{\Lorenz}
372 \listplotHSB[linecolor=magenta,unit=
0.25,HueBegin=
0.65,HueEnd=
1]{tabYZ aload pop
}%
377 \subsection{Le tracé du papillon de Lorenz en
3D
}
378 Le tracé en
3D est l'étape la plus délicate, puisqu'il faut réunir les fichiers $(x,y)$, $(x,z)$ et $(y,z)$ en un seul fichier $(x,y,z)$. Ce qu'on réalise ainsi :
380 \pstVerb{/XY
[(LorenzXY.dat) run
] def
381 /XZ
[(LorenzXZ.dat) run
] def
382 /YZ
[(LorenzYZ.dat) run
] def
384 0 2 XY length
2 sub
{/i exch def
391 /fichierpoints (XYZLorenz.dat) (w) file def
392 0 1 tabXYZ length
1 sub
{/i exch def
393 tabXYZ i get aload pop
397 fichierpoints xi
15 string cvs writestring
398 fichierpoints
32 write
%% espace
399 fichierpoints yi
15 string cvs writestring
400 fichierpoints
32 write
%% espace
401 fichierpoints zi
15 string cvs writestring
402 fichierpoints
10 write
%% CR
404 fichierpoints closefile
406 Les dernières lignes permettent d'enregistrer, si on le souhaite, le fichier de points.
408 \begin{pspicture
}(-
6,-
4)(
6,
12)
409 \psset{THETA=-
70,PHI=
20,Dobs=
2000,Decran=
400}
410 \pstVerb{/XY
[(LorenzXY.dat) run
] def
411 /XZ
[(LorenzXZ.dat) run
] def
412 /YZ
[(LorenzYZ.dat) run
] def
414 0 2 XY length
2 sub
{/i exch def
421 /fichierpoints (XYZLorenz.dat) (w) file def
422 0 1 tabXYZ length
1 sub
{/i exch def
423 tabXYZ i get aload pop
427 fichierpoints xi
15 string cvs writestring
428 fichierpoints
32 write
%% espace
429 fichierpoints yi
15 string cvs writestring
430 fichierpoints
32 write
%% espace
431 fichierpoints zi
15 string cvs writestring
432 fichierpoints
10 write
%% CR
434 fichierpoints closefile
438 /THETA
\psk@TroisD@Theta def
439 /PHI
\psk@TroisD@Phi def
440 /Dobs
\psk@TroisD@Dobs def
441 /DScreen
\psk@TroisD@Ecran def
446 /Cos1Sin2 Cos1 Sin2 mul def
447 /Sin1Sin2 Sin1 Sin2 mul def
448 /Cos1Cos2 Cos1 Cos2 mul def
449 /Sin1Cos2 Sin1 Cos2 mul def
451 0 1 tabXYZ length
1 sub
{/i exch def
452 /TAB tabXYZ i get def
453 /abscisse TAB
0 get def
454 /ordonnee TAB
1 get def
460 \listplotHSB[unit=
1]{IIID
}
461 \psset{unit=
2.5,linestyle=dashed
}
462 \pnodeTroisD(
0,
0,
0)
{O
}
463 \pnodeTroisD(
0,
0,
5)
{Z
}
464 \pnodeTroisD(
5,
0,
0)
{X
}
465 \pnodeTroisD(
0,
5,
0)
{Y
}
466 \pnodeTroisD(-
10,-
10,
0)
{A
}
467 \pnodeTroisD(-
10,-
10,
20)
{B
}
468 \pnodeTroisD(-
10,
10,
20)
{C
}
469 \pnodeTroisD(-
10,
10,
0)
{D
}
470 \pnodeTroisD(
10,-
10,
0)
{E
}
471 \pnodeTroisD(
10,-
10,
20)
{F
}
472 \pnodeTroisD(
10,
10,
20)
{G
}
473 \pnodeTroisD(
10,
10,
0)
{H
}
474 \pspolygon(A)(B)(C)(D)
475 \pspolygon(E)(F)(G)(H)
480 \psset{linestyle=solid,linecolor=red
}
487 Le tracé s'effectue grâce à la commande
\verb+
\pnodeTroisD+ et ses diverses options.
491 /THETA
\psk@TroisD@Theta def
492 /PHI
\psk@TroisD@Phi def
493 /Dobs
\psk@TroisD@Dobs def
494 /DScreen
\psk@TroisD@Ecran def
499 /Cos1Sin2 Cos1 Sin2 mul def
500 /Sin1Sin2 Sin1 Sin2 mul def
501 /Cos1Cos2 Cos1 Cos2 mul def
502 /Sin1Cos2 Sin1 Cos2 mul def
504 0 1 tabXYZ length
1 sub
{/i exch def
505 /TAB tabXYZ i get def
506 /abscisse TAB
0 get def
507 /ordonnee TAB
1 get def
513 \listplotHSB[unit=
1]{IIID
}
514 \psset{unit=
2.5,linestyle=dashed
}
515 \pnodeTroisD(
0,
0,
0)
{O
}
516 \pnodeTroisD(
0,
0,
5)
{Z
}
517 \pnodeTroisD(
5,
0,
0)
{X
}
518 \pnodeTroisD(
0,
5,
0)
{Y
}
519 \pnodeTroisD(-
10,-
10,
0)
{A
}
520 \pnodeTroisD(-
10,-
10,
20)
{B
}
521 \pnodeTroisD(-
10,
10,
20)
{C
}
522 \pnodeTroisD(-
10,
10,
0)
{D
}
523 \pnodeTroisD(
10,-
10,
0)
{E
}
524 \pnodeTroisD(
10,-
10,
20)
{F
}
525 \pnodeTroisD(
10,
10,
20)
{G
}
526 \pnodeTroisD(
10,
10,
0)
{H
}
527 \pspolygon(A)(B)(C)(D)
528 \pspolygon(E)(F)(G)(H)
533 \psset{linestyle=solid,linecolor=red
}
538 \section{Animations avec le package animate
}