Integrator module¶
Basic code for the templated integrators.
Currently we only support two-step integrators.
These classes are used to generate the code for the actual integrators from the sph_eval module.
-
class
pysph.sph.integrator.
EPECIntegrator
(**kw)[source]¶ Bases:
pysph.sph.integrator.Integrator
Predictor corrector integrators can have two modes of operation.
In the Evaluate-Predict-Evaluate-Correct (EPEC) mode, the system is advanced using:
\[\begin{split}F(y^n) --> Evaluate\end{split}\]\[\begin{split}y^{n+\frac{1}{2}} = y^n + F(y^n) --> Predict\end{split}\]\[\begin{split}F(y^{n+\frac{1}{2}}) --> Evaluate\end{split}\]\[\begin{split}y^{n+1} = y^n + \Delta t F(y^{n+\frac{1}{2}}) --> Correct\end{split}\]Notes:
The Evaluate stage of the integrator forces a function evaluation. Therefore, the PEC mode is much faster but relies on old accelertions for the Prediction stage.
In the EPEC mode, the final corrector can be modified to:
\(y^{n+1} = y^n + \frac{\Delta t}{2}\left( F(y^n) + F(y^{n+\frac{1}{2}}) \right)\)
This would require additional storage for the accelerations.
Pass fluid names and suitable IntegratorStep instances.
For example:
>>> integrator = Integrator(fluid=WCSPHStep(), solid=WCSPHStep())
where “fluid” and “solid” are the names of the particle arrays.
-
class
pysph.sph.integrator.
EulerIntegrator
(**kw)[source]¶ Bases:
pysph.sph.integrator.Integrator
Pass fluid names and suitable IntegratorStep instances.
For example:
>>> integrator = Integrator(fluid=WCSPHStep(), solid=WCSPHStep())
where “fluid” and “solid” are the names of the particle arrays.
-
class
pysph.sph.integrator.
Integrator
(**kw)[source]¶ Bases:
object
Generic class for multi-step integrators in PySPH for a system of ODES of the form \(\frac{dy}{dt} = F(y)\).
Pass fluid names and suitable IntegratorStep instances.
For example:
>>> integrator = Integrator(fluid=WCSPHStep(), solid=WCSPHStep())
where “fluid” and “solid” are the names of the particle arrays.
-
compute_time_step
(dt, cfl)[source]¶ If there are any adaptive timestep constraints, the appropriate timestep is returned, else None is returned.
-
one_timestep
(t, dt)[source]¶ User written function that actually does one timestep.
This function is used in the high-performance Cython implementation. The assumptions one may make are the following:
t and dt are passed.
the following methods are available:
- self.initialize()
- self.stage1(), self.stage2() etc. depending on the number of stages available.
- self.compute_accelerations(t, dt)
- self.do_post_stage(stage_dt, stage_count_from_1)
Please see any of the concrete implementations of the Integrator class to study. By default the Integrator implements a predict-evaluate-correct method, the same as PECIntegrator.
-
set_compiled_object
(c_integrator)[source]¶ Set the high-performance compiled object to call internally.
-
set_post_stage_callback
(callback)[source]¶ This callback is called when the particles are moved, i.e one stage of the integration is done.
This callback is passed the current time value, the timestep and the stage.
The current time value is t + stage_dt, for example this would be 0.5*dt for a two stage predictor corrector integrator.
-
-
class
pysph.sph.integrator.
LeapFrogIntegrator
(**kw)[source]¶ Bases:
pysph.sph.integrator.PECIntegrator
A leap-frog integrator.
Pass fluid names and suitable IntegratorStep instances.
For example:
>>> integrator = Integrator(fluid=WCSPHStep(), solid=WCSPHStep())
where “fluid” and “solid” are the names of the particle arrays.
-
class
pysph.sph.integrator.
PECIntegrator
(**kw)[source]¶ Bases:
pysph.sph.integrator.Integrator
In the Predict-Evaluate-Correct (PEC) mode, the system is advanced using:
\[\begin{split}y^{n+\frac{1}{2}} = y^n + \frac{\Delta t}{2}F(y^{n-\frac{1}{2}}) --> Predict\end{split}\]\[\begin{split}F(y^{n+\frac{1}{2}}) --> Evaluate\end{split}\]\[y^{n + 1} = y^n + \Delta t F(y^{n+\frac{1}{2}})\]Pass fluid names and suitable IntegratorStep instances.
For example:
>>> integrator = Integrator(fluid=WCSPHStep(), solid=WCSPHStep())
where “fluid” and “solid” are the names of the particle arrays.
-
class
pysph.sph.integrator.
PEFRLIntegrator
(**kw)[source]¶ Bases:
pysph.sph.integrator.Integrator
A Position-Extended Forest-Ruth-Like integrator [Omeylan2002]
References
[Omeylan2002] I.M. Omelyan, I.M. Mryglod and R. Folk, “Optimized Forest-Ruth- and Suzuki-like algorithms for integration of motion in many-body systems”, Computer Physics Communications 146, 188 (2002) http://arxiv.org/abs/cond-mat/0110585 Pass fluid names and suitable IntegratorStep instances.
For example:
>>> integrator = Integrator(fluid=WCSPHStep(), solid=WCSPHStep())
where “fluid” and “solid” are the names of the particle arrays.
-
class
pysph.sph.integrator.
TVDRK3Integrator
(**kw)[source]¶ Bases:
pysph.sph.integrator.Integrator
In the TVD-RK3 integrator, the system is advanced using:
\[y^{n + \frac{1}{3}} = y^n + \Delta t F( y^n )\]\[y^{n + \frac{2}{3}} = \frac{3}{4}y^n + \frac{1}{4}(y^{n + \frac{1}{3}} + \Delta t F(y^{n + \frac{1}{3}}))\]\[y^{n + 1} = \frac{1}{3}y^n + \frac{2}{3}(y^{n + \frac{2}{3}} + \Delta t F(y^{n + \frac{2}{3}}))\]Pass fluid names and suitable IntegratorStep instances.
For example:
>>> integrator = Integrator(fluid=WCSPHStep(), solid=WCSPHStep())
where “fluid” and “solid” are the names of the particle arrays.