diff options
author | Karl Berry <karl@freefriends.org> | 2012-09-14 22:15:11 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-09-14 22:15:11 +0000 |
commit | 655440ffbc259c110c3f77959344260e641a5fb0 (patch) | |
tree | cadbec13ee02de5cfbbf1a31e7835b21f9f7552f /Master | |
parent | a4799313350c8a85179bc99161cc49c0af3e1558 (diff) |
pst-ode (14sep12)
git-svn-id: svn://tug.org/texlive/trunk@27669 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/generic/pst-ode/ChangeLog | 4 | ||||
-rw-r--r-- | Master/texmf-dist/doc/generic/pst-ode/lorenz.tex | 46 | ||||
-rw-r--r-- | Master/texmf-dist/doc/generic/pst-ode/ode.tex | 18 | ||||
-rw-r--r-- | Master/texmf-dist/doc/generic/pst-ode/particle.tex | 55 | ||||
-rw-r--r-- | Master/texmf-dist/doc/generic/pst-ode/pst-ode-doc.pdf | bin | 121611 -> 123984 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/generic/pst-ode/pst-ode-doc.tex | 11 | ||||
-rw-r--r-- | Master/texmf-dist/dvips/pst-ode/pst-ode.pro | 26 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/pst-ode/pst-ode.tex | 57 |
8 files changed, 60 insertions, 157 deletions
diff --git a/Master/texmf-dist/doc/generic/pst-ode/ChangeLog b/Master/texmf-dist/doc/generic/pst-ode/ChangeLog index a56317fdb42..41562516d90 100644 --- a/Master/texmf-dist/doc/generic/pst-ode/ChangeLog +++ b/Master/texmf-dist/doc/generic/pst-ode/ChangeLog @@ -1,2 +1,6 @@ +2012-09-14 + * version 0.2 + * new: command option `algebraicOutputFormat' added + 2012-08-16 * initial release (v0.1) to CTAN diff --git a/Master/texmf-dist/doc/generic/pst-ode/lorenz.tex b/Master/texmf-dist/doc/generic/pst-ode/lorenz.tex deleted file mode 100644 index 3150ec923bb..00000000000 --- a/Master/texmf-dist/doc/generic/pst-ode/lorenz.tex +++ /dev/null @@ -1,46 +0,0 @@ -\documentclass{article} -\usepackage{pst-ode,pst-3dplot} -\usepackage[T1]{fontenc} -\usepackage[latin1]{inputenc}% - -\begin{document} -\begin{center} -\pstVerb{ - /alpha 10 def - /beta 28 def - /gamma 8 3 div def -}% -\pstODEsolve[algebraic]{lorenzXYZ}{0 1 2}{0}{25}{2501}{10 10 30}{ - alpha*(x[1]-x[0]) | - x[0]*(beta-x[2]) - x[1] | - x[0]*x[1] - gamma*x[2] -} -\begin{pspicture}(-6,-2)(6,10) -\psset{unit=0.17cm,Alpha=160,Beta=15} -\listplotThreeD{lorenzXYZ} -\psset{unit=0.425cm,linestyle=dashed} -\pstThreeDNode(0,0,0){O} -\pstThreeDNode(0,0,5){Z} -\pstThreeDNode(5,0,0){X} -\pstThreeDNode(0,5,0){Y} -\pstThreeDNode(-10,-10,0){A} -\pstThreeDNode(-10,-10,20){B} -\pstThreeDNode(-10,10,20){C} -\pstThreeDNode(-10,10,0){D} -\pstThreeDNode(10,-10,0){E} -\pstThreeDNode(10,-10,20){F} -\pstThreeDNode(10,10,20){G} -\pstThreeDNode(10,10,0){H} -\pspolygon(A)(B)(C)(D) -\pspolygon(E)(F)(G)(H) -\psline(A)(E) -\psline(B)(F) -\psline(D)(H) -\psline(C)(G) -\psset{linestyle=solid,linecolor=red} -\psline{->}(O)(X) -\psline{->}(O)(Y) -\psline{->}(O)(Z) -\end{pspicture} -\end{center} -\end{document} diff --git a/Master/texmf-dist/doc/generic/pst-ode/ode.tex b/Master/texmf-dist/doc/generic/pst-ode/ode.tex deleted file mode 100644 index 59d529f3bce..00000000000 --- a/Master/texmf-dist/doc/generic/pst-ode/ode.tex +++ /dev/null @@ -1,18 +0,0 @@ -\documentclass{article} -\usepackage{pst-ode,pst-plot} -\usepackage[T1]{fontenc} -\usepackage[latin1]{inputenc}% - -\begin{document} -\begin{center} -\psset{unit=3cm} -\begin{pspicture}(-0.3,-0.4)(.2,1) - \psset{xAxisLabelPos={c,-5ex},yAxisLabelPos={-3ex,c}} - \begin{psgraph}[axesstyle=frame,Ox=-1,](0,0)(0,0)(4,1){10cm}{2.5cm} - \rput(1,0){\psplot[algebraic]{-1}{3}{Euler^(-x^2)}} - \pstODEsolve[algebraicIC,algebraic]{TY}{(t) 0}{-1}{3}{5}{1/Euler}{-2*t*y[0]} - \rput(1,0){\listplot[plotstyle=dots,dotsize=0.05,linecolor=red]{TY}} - \end{psgraph} -\end{pspicture} -\end{center} -\end{document} diff --git a/Master/texmf-dist/doc/generic/pst-ode/particle.tex b/Master/texmf-dist/doc/generic/pst-ode/particle.tex deleted file mode 100644 index b1010b08c32..00000000000 --- a/Master/texmf-dist/doc/generic/pst-ode/particle.tex +++ /dev/null @@ -1,55 +0,0 @@ -\documentclass{article} -\usepackage{pst-ode,pst-3dplot} -\usepackage[T1]{fontenc} -\usepackage[latin1]{inputenc}% - -\begin{document} -\begin{center} -\psset{unit=0.74cm,Alpha=40,Beta=20} -\begin{pspicture}(-10,-2)(6,13) -\newpsstyle{vecteurA}{arrowinset=0.1,arrowsize=0.15,linecolor={[rgb]{0 0.5 1}}} -\pstVerb{ - /wc 5 def - /tau 5 def - /vx 20 def - /vz 2 def -} -\pstODEsolve[algebraic]{particleXYZ}{0 1 2}{0}{25}{1000}{0 0 0 vx 0 vz}{ - y[3] | y[4] | y[5] | wc*y[4] - y[3]/tau | -wc*y[3] - y[4]/tau | -y[5]/tau -} -\listplotThreeD{particleXYZ} -\pstThreeDNode(0,0,0){O} -\pstThreeDNode(0,0,1){Z} -\pstThreeDNode(1,0,0){X} -\pstThreeDNode(0,1,0){Y} -\pstThreeDNode(-5,-9,0){A} -\pstThreeDNode(-5,-9,10){B} -\pstThreeDNode(-5,2,10){C} -\pstThreeDNode(-5,2,0){D} -\pstThreeDNode(5,-9,0){E} -\pstThreeDNode(5,-9,10){F} -\pstThreeDNode(5,2,10){G} -\pstThreeDNode(5,2,0){H} -\pstThreeDNode(0,0,0){M0} -\pstThreeDNode(vx 5 div,0,vz 5 div){V} -\pstThreeDNode(vx 5 div,0,0){Vx} -{\psset{linestyle=dashed} -\pspolygon(A)(B)(C)(D) -\pspolygon(E)(F)(G)(H) -\psline(A)(E) -\psline(B)(F) -\psline(D)(H) -\psline(C)(G)}% -\psline[linecolor=red]{->}(M0)(V) -\psline[linecolor=cyan]{->}(M0)(Vx) -\uput{0.1}[l](V){\red$\overrightarrow{v}_0$} -{\psset{linestyle=solid,linecolor=red} -\psline[style=vecteurA]{->}(O)(X) -\psline[style=vecteurA]{->}(O)(Y) -\psline[style=vecteurA]{->}(O)(Z)}% -\uput[u](Z){$z$} -\uput[dl](X){$x$} -\uput[r](Y){$y$} -\end{pspicture} -\end{center} -\end{document} diff --git a/Master/texmf-dist/doc/generic/pst-ode/pst-ode-doc.pdf b/Master/texmf-dist/doc/generic/pst-ode/pst-ode-doc.pdf Binary files differindex 6e51efc0675..54bf10563ae 100644 --- a/Master/texmf-dist/doc/generic/pst-ode/pst-ode-doc.pdf +++ b/Master/texmf-dist/doc/generic/pst-ode/pst-ode-doc.pdf diff --git a/Master/texmf-dist/doc/generic/pst-ode/pst-ode-doc.tex b/Master/texmf-dist/doc/generic/pst-ode/pst-ode-doc.tex index 0139f79811f..28d7547257c 100644 --- a/Master/texmf-dist/doc/generic/pst-ode/pst-ode-doc.tex +++ b/Master/texmf-dist/doc/generic/pst-ode/pst-ode-doc.tex @@ -115,24 +115,27 @@ is the main user command for solving initial value problems. The first mandatory argument \Larg{result} is a simple identifier composed of letters and possibly numbers. It is used to create a \PS{} object of the same name, which takes the computed state vectors $\mathbf{x}_i$, formatted according to the second argument \Larg{output format}, as a long list of values. \Larg{result} can be directly used as the \Larg{data} argument of \Lcs{listplot}\Largb{data} (package \LPack{pst-plot}) or \Lcs{listplotThreeD}\Largb{data} (package \LPack{pst-3dplot}). When put on the \PS{} operand stack, \Larg{result} is immediately executed, that is, the list of values contained in \Larg{result} is pushed onto the operand stack. The scope of \Larg{result} is global and thus its content survives page breaks. -The second argument \Larg{output format} determines which of the components of the state vectors $\mathbf{x}_i$ and possibly the independent variable $t$ are stored into \Larg{result}. The keyword \Lkeyword{(t)} (parentheses required) inserts the integration parameter value $t_i$ into the result list; numbers (\Lkeyword{0}, \Lkeyword{1}, \Lkeyword{2}, \dots, $n-1$) in arbitrary order specify the components of vector $\mathbf{x}_i$ to be inserted, as well as their order of insertion. The elements of \Larg{output format} are to be separated by spaces. +The second argument \Larg{output format} determines which of the components of the state vectors $\mathbf{x}_i$ and possibly the independent variable $t$ are stored into \Larg{result}. \Larg{output format} can be specified in two different formats, depending on the setting of the command option \Lkeyword{algebraicOutputFormat}. +If \Lkeyword{algebraicOutputFormat} is set, calculations can be made on the components of the computed state vectors before writing them to \Larg{result}. Without option \Lkeyword{algebraicOutputFormat} the following applies: The keyword \Lkeyword{(t)} (parentheses required) inserts the integration parameter value $t_i$ into the result list; numbers (\Lkeyword{0}, \Lkeyword{1}, \Lkeyword{2}, \dots, $n-1$) in arbitrary order specify the components of vector $\mathbf{x}_i$ to be inserted, as well as their order of insertion. The elements of \Larg{output format} are to be separated by spaces. If option \Lkeyword{algebraicOutputFormat} is set, \Larg{output format} is a \Lkeyword{|}-separated list of algebraic expressions according to which the components of the output vector are to be calculated. In these algebraic expressions, the $n$ current state vector components can be referred to as \Lkeyword{x[0]}, \Lkeyword{x[1]}, \dots, \Lkeyword{x[}$n-1$\Lkeyword{]} or \Lkeyword{y[0]}, \Lkeyword{y[1]}, \dots, \Lkeyword{y[}$n-1$\Lkeyword{]}, and the current independent variable value as `\Lkeyword{t}'. In either case, there is no upper limit of the output vector length. It must have at least one element though. Arguments $t_0$ and $t_\mathrm{e}$ define the interval of integration $I=[t_0, t_\mathrm{e}]$. $N$ is the number of \emph{equally} spaced output points, including $t_0$ and $t_\mathrm{e}$; it must be $\ge 2$. In order to divide the interval of integration into $K$ output steps, $N$ must be set to $K+1$. Note that the precision of the solution does \emph{not} depend on $N$; internal integration steps are automatically inserted and resized according to the changes in the solution. -$\mathbf{x}_0$ is a list of $n$ space separated initial values, one for each differential equation. Alternatively, $\mathbf{x}_0$ can be given as a \PS{} procedure pushing the initial values on the stack, or as an algebraic expression where the elements are separated by `\Lkeyword{|}'. Algebraic notation requires option \Lkeyword{algebraicIC}. This argument can be left empty. In that case, the last computed state vector of the preceding \Lcs{pstODEsaveState} call is used as initial condition. Of course, the number of equations $n$ must be the same as in the preceding calculation. +$\mathbf{x}_0$ is a list of $n$ space separated initial values, one for each differential equation. Alternatively, $\mathbf{x}_0$ can be given as a \PS{} procedure pushing the initial values on the stack, or as an algebraic expression where the elements are separated by `\Lkeyword{|}'. Algebraic notation requires option \Lkeyword{algebraicIC}. This argument can be left empty. In that case, the last computed state vector of a preceding \Lcs{pstODEsolve} call or a state vector that was set using the \Lcs{pstODEsetOrRestoreState} macro is used as initial condition. Of course, the number of equations $n$ must be the same as in the preceding calculation. $\mathbf{f}(t,\mathbf{x})$ is the right-hand side of the differential equations. Equations can be entered in either algebraic or \PS{} notation. Algebraic notation requires option \Lkeyword{algebraic}, and equations have to be separated by `\Lkeyword{|}'. The $n$ current state vector components can be referred to as \Lkeyword{x[0]}, \Lkeyword{x[1]}, \dots, \Lkeyword{x[}$n-1$\Lkeyword{]} or \Lkeyword{y[0]}, \Lkeyword{y[1]}, \dots, \Lkeyword{y[}$n-1$\Lkeyword{]}, and the current independent variable value as `\Lkeyword{t}'. If given in \PS{} notation, the provided procedure must first pop the current state vector components in reverse order(!) from the operand stack and then push the first derivatives in regular order back to it. Again, the independent variable value can be accessed using `\Lkeyword{t}'.\\[1ex] -\Lcs{pstODEsolve} accepts a few \OptArgs: \Lkeyword{append}, \Lkeyword{saveData}, \Lkeyword{algebraicIC}, \Lkeyword{algebraic}, \Lkeyword{silent} and \Lkeyword{varsteptol}. +\Lcs{pstODEsolve} accepts a few \OptArgs: \Lkeyword{append}, \Lkeyword{saveData}, \Lkeyword{algebraicOutputFormat}, \Lkeyword{algebraicIC}, \Lkeyword{algebraic}, \Lkeyword{silent} and \Lkeyword{varsteptol}. With \Lkeyword{append}, the computed result is appended to \Larg{result} which must already exist, e.\, g. from a previous use of \Lcs{pstODEsolve}. Usually, the initial condition vector argument is left empty in order to continue integration from the last computed or from a restored state (see \Lcs{pstODEsetOrRestoreState}). If option \Lkeyword{saveData} is set, the formatted state vectors are written as a table to a textfile named `\Larg{result}\Lkeyword{.dat}'. Note that \Lkeyword{ps2pdf} must be called with option \Lkeyword{-dNOSAFER} to enable writing of external files. +With \Lkeyword{algebraicOutputFormat}, the command argument \Larg{output format} is a \Lkeyword{|}-separated list of algebraic expressions, according to which the output vector components are to be assembled before storing them into \Larg{result}. Default is not to use algebraic expressions. For details, see the description of \Larg{output format} above. + With \Lkeyword{algebraicIC}, the initial condition vector $\mathbf{x}_0$ can be given in algebraic notation. Vector components have to be separated by `\Lkeyword{|}'. Default is \PS{} notation. -With \Lkeyword{algebraic}, the right-hand side of differential equations $\mathbf{f}(t,\mathbf{x})$ can be given in algebraic notation. Equations are to be separated by `\Lkeyword{|}'. Default is \PS{} notation. +With \Lkeyword{algebraic}, the right-hand side of differential equations $\mathbf{f}(t,\mathbf{x})$ can be given in algebraic notation. Algebraic expressions are to be separated by `\Lkeyword{|}'. Default is \PS{} notation. Option \Lkeyword{silent} suppresses the terminal output of stepping information. diff --git a/Master/texmf-dist/dvips/pst-ode/pst-ode.pro b/Master/texmf-dist/dvips/pst-ode/pst-ode.pro index 22b347cd546..cc9f66cb427 100644 --- a/Master/texmf-dist/dvips/pst-ode/pst-ode.pro +++ b/Master/texmf-dist/dvips/pst-ode/pst-ode.pro @@ -1,7 +1,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % PostScript prologue for pst-ode.tex. -% Version 0.1, 2012/07/20 +% Version 0.2, 2012/09/14 % % Alexander Grahn (C) 2012 % @@ -113,24 +113,20 @@ tx@odeDict begin } ifelse }ifelse } bind def -/writeresult { %assembles state vector for output into file + writes it - outvect { - dup (t) eq { - pop tcur 20 string cvs statefile exch writestring - }{ - ode@laststate exch get 20 string cvs statefile exch writestring - } ifelse - statefile ( ) writestring +/writeresult { %write output vector to file + { + 20 string cvs statefile exch writestring + statefile ( ) writestring } forall statefile (\n) writestring } bind def /assembleresult { %assembles state vector for building table of results - outvect { - dup (t) eq { - pop tcur - }{ - ode@laststate exch get - } ifelse + { + dup (t) eq { + pop tcur + }{ + ode@laststate exch get + } ifelse } forall } bind def end diff --git a/Master/texmf-dist/tex/generic/pst-ode/pst-ode.tex b/Master/texmf-dist/tex/generic/pst-ode/pst-ode.tex index fe391d0a71f..44c7eaeffc7 100644 --- a/Master/texmf-dist/tex/generic/pst-ode/pst-ode.tex +++ b/Master/texmf-dist/tex/generic/pst-ode/pst-ode.tex @@ -11,8 +11,8 @@ %% ODEs using the Runge-Kutta-Fehlberg (RKF45) method with automatic %% step size adjustment %% -\def\fileversion{0.1} -\def\filedate{2012/08/16} +\def\fileversion{0.2} +\def\filedate{2012/09/14} \csname PSTODELoaded\endcsname \let\PSTODELoaded\endinput @@ -43,18 +43,19 @@ % Usage: % % \pstODEsolve[Options] -% {result}{output vector}{ta}{tb}{number of output points} +% {result}{output vector format}{ta}{tb}{number of output points} % {initial cond.}{function} % % options: -% * append result appended to <result> which must already exist (e. g. -% from previous use of \pstODEsolve); usually the initial -% condition vector argument is left empty in order to continue -% integration from the last state -% * saveData result is written to file <result>.dat -% * algebraic (system of) ODE given in infix notation -% * silent suppress output of stepping information -% * varsteptol relative tolerance for step size adjustment +% * append result appended to <result> which must already exist (e. g. +% from previous use of \pstODEsolve); usually the initial +% condition vector argument is left empty in order to continue +% integration from the last state +% * saveData result is written to file <result>.dat +% * algebraic (system of) ODE given in infix notation +% * algebraicIC initial condition vector given in infix notation +% * silent suppress output of stepping information +% * varsteptol relative tolerance for step size adjustment % % arguments: % @@ -81,6 +82,7 @@ \define@boolkey[psset]{pst-ode}[Pst@]{algebraicIC}[true]{}% \define@boolkey[psset]{pst-ode}[Pst@]{algebraic}[true]{}% \define@boolkey[psset]{pst-ode}[Pst@]{silent}[true]{}% +\define@boolkey[psset]{pst-ode}[Pst@]{algebraicOutputFormat}[true]{}% \define@key[psset]{pst-ode}{varsteptol}{\def\ode@varsteptol{#1}}% \def\pstODEsolve{\def\pst@par{}\pst@object{pstODEsolve}}% \def\pstODEsolve@i#1#2#3#4#5#6#7{% @@ -92,6 +94,7 @@ \edef\ode@init{#6{}}% \edef\ode@init{\expandafter\ode@zapspace\ode@init\@nil}% \edef\ode@arg{#7{}}% + \ifPst@algebraicOutputFormat\edef\ode@fmt{#2{}}\fi% \pstVerb{ tx@odeDict begin \ifPst@silent @@ -102,7 +105,6 @@ /ode@tol \ode@varsteptol\space def % rel. tolerance for step size adjustment %process arguments \ifPst@saveData /statefile (#1.dat) (\filemode) file def \fi - /outvect [#2] def /tStart #3 def /tEnd #4 def /dt tEnd tStart sub #5\space 1 sub div def % output step size @@ -121,7 +123,7 @@ /xlength ode@laststate length def % number of equations /xlength1 xlength 1 add def % number of equations plus 1 \ifPst@algebraic - /ode@rpn (\expandafter\ode@zapspace\ode@arg\@nil) AlgParser cvx def + /ode@rpn (\expandafter\ode@zapspace\ode@arg\@nil) AlgParser cvx bind def /ODESET {%system of ODEs tx@Dict begin /x exch def /y x def ode@rpn end xlength array astore } bind def @@ -130,8 +132,16 @@ aload pop tx@Dict begin 0 begin #7 end end xlength array astore } bind def %ensure local scope of user defined variables in #7 - /ODESET load 5 1 dict put + /ODESET load 4 1 dict put \fi + \ifPst@algebraicOutputFormat + /ode@fmtrpn (\expandafter\ode@zapspace\ode@fmt\@nil) AlgParser cvx bind def + /formatoutput {% + tx@Dict begin + ode@laststate /x exch def /y x def /t tcur def ode@fmtrpn + end + } bind def + \else /formatoutput {[#2] assembleresult} def \fi% %perform ode integration (\string\n pstODEsolve RKF45 method; '-' failed step, '+' successful step, % 'o' output step : \string\n) odeprint @@ -139,8 +149,12 @@ /tout tStart dt add def % next output t /ddt dt def % initial integration step size \ifPst@append\else - \ifPst@saveData writeresult \fi - [ assembleresult true setglobal ] + [ + [formatoutput] + \ifPst@saveData dup writeresult \fi + aload pop + true setglobal + ] globaldict exch /#1 exch cvx put false setglobal (o) odeprint @@ -148,8 +162,12 @@ #5\space 1 sub { ode@laststate ODEINT [ exch aload pop true setglobal ] globaldict exch /ode@laststate exch put false setglobal - \ifPst@saveData writeresult \fi - [ #1 assembleresult true setglobal ] + [ + #1 [formatoutput] + \ifPst@saveData dup writeresult \fi + aload pop + true setglobal + ] globaldict exch /#1 exch cvx put false setglobal } repeat @@ -185,7 +203,8 @@ } \psset[pst-ode]{append=false,saveData=false,algebraicIC=false, - algebraic=false,silent=false,varsteptol=1e-6} + algebraic=false,silent=false,varsteptol=1e-6,algebraicOutputFormat=false, +} \catcode`\@=\PstAtCode\relax %% END: pst-ode.tex |