summaryrefslogtreecommitdiff
path: root/graphics/pstricks/contrib/pst-ode/pst-ode.tex
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pstricks/contrib/pst-ode/pst-ode.tex')
-rw-r--r--graphics/pstricks/contrib/pst-ode/pst-ode.tex24
1 files changed, 18 insertions, 6 deletions
diff --git a/graphics/pstricks/contrib/pst-ode/pst-ode.tex b/graphics/pstricks/contrib/pst-ode/pst-ode.tex
index 7cb0e89573..3ab38399c3 100644
--- a/graphics/pstricks/contrib/pst-ode/pst-ode.tex
+++ b/graphics/pstricks/contrib/pst-ode/pst-ode.tex
@@ -12,8 +12,8 @@
%% ODEs using the Runge-Kutta-Fehlberg (RKF45) method with automatic
%% step size adjustment
%%
-\def\fileversion{0.17}
-\def\filedate{2022/05/14}
+\def\fileversion{0.18}
+\def\filedate{2022/11/24}
\csname PSTODELoaded\endcsname
\let\PSTODELoaded\endinput
@@ -64,6 +64,8 @@
% * varsteptol relative tolerance for step size adjustment
% * dt0 first tentative integration step size, overrides output step
% size (#4-#3)/(#5-1) used as default value
+% * rk4 instead of RKF45, use 4th-order classical Runge-Kutta between
+% output points (without adaptive step size)
%
% arguments:
%
@@ -87,6 +89,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\define@boolkey[psset]{pst-ode}[PstODE@]{append}[true]{}%
\define@boolkey[psset]{pst-ode}[PstODE@]{saveData}[true]{}%
+\define@boolkey[psset]{pst-ode}[PstODE@]{rk4}[true]{}%
\define@boolkey[psset]{pst-ode}[PstODE@]{algebraicT}[true]{}%
\define@boolkey[psset]{pst-ode}[PstODE@]{algebraicN}[true]{}%
\define@boolkey[psset]{pst-ode}[PstODE@]{algebraicIC}[true]{}%
@@ -126,6 +129,9 @@
\fi
/ode@tol \ode@varsteptol\space def % rel. tolerance for step size adjustment
%process arguments
+ /rk4
+ \expandafter\csname ifPstODE@rk4\endcsname true\else false\fi\space
+ def
\ifPstODE@saveData /statefile (#1.dat) (\filemode) file def \fi
\ifPstODE@algebraicT
tx@Dict begin (\expandafter\ode@zapspace\ode@ta\@nil)
@@ -175,10 +181,14 @@
ode@dict ode@laststate /x exch def /y x def /t tcur def end
tx@Dict begin ode@dict ode@fmtrpn end end
} bind def
- \else /formatoutput {[#2] assembleresult} def \fi%
+ \else /formatoutput {[#2] assembleresult} def \fi
%perform ode integration
- (\string\n pstODEsolve (RKF45),\string\n) odeprint
- (-/+ failed/successful step, "o" output step, "!" step size underflow (stop):\string\n) odeprint
+ rk4 {
+ (\string\n pstODEsolve (RK4),) odeprint ( "o" output step:\string\n) odeprint
+ }{
+ (\string\n pstODEsolve (RKF45),\string\n) odeprint
+ (-/+ failed/successful step, "o" output step, "!" step size underflow (stop):\string\n) odeprint
+ } ifelse
ode@dict
/tcur tStart def % current parameter t value
/outStepCnt 1 def % output step counter
@@ -193,6 +203,8 @@
\ode@dtInit\space 0 eq
{/ddt dt def}{/ddt \ode@dtInit\space def} ifelse
\fi
+ % for RK4, use output step size
+ rk4 {/ddt dt def} if
end
\ifPstODE@append\else
[
@@ -261,7 +273,7 @@
\psset[pst-ode]{append=false,saveData=false,algebraicIC=false,algebraicT=false,
algebraicN=false,silent=false,varsteptol=1e-6,algebraicOutputFormat=false,
- algebraicAll=false,dt0=0
+ algebraicAll=false,dt0=0,rk4=false
}
\psset{algebraic=false}
\catcode`\@=\PstAtCode\relax