summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pst-ode
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-09-14 22:15:11 +0000
committerKarl Berry <karl@freefriends.org>2012-09-14 22:15:11 +0000
commit655440ffbc259c110c3f77959344260e641a5fb0 (patch)
treecadbec13ee02de5cfbbf1a31e7835b21f9f7552f /Master/texmf-dist/tex/generic/pst-ode
parenta4799313350c8a85179bc99161cc49c0af3e1558 (diff)
pst-ode (14sep12)
git-svn-id: svn://tug.org/texlive/trunk@27669 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pst-ode')
-rw-r--r--Master/texmf-dist/tex/generic/pst-ode/pst-ode.tex57
1 files changed, 38 insertions, 19 deletions
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