Module scheme

Abstract class to define the API for an SPH scheme. The idea is that one can define a scheme and thereafter one simply instantiates a suitable scheme, gives it a bunch of particles and runs the application.

class pysph.sph.scheme.ADKEScheme(fluids, solids, dim, gamma=1.4, alpha=1.0, beta=2.0, k=1.0, eps=0.0, g1=0, g2=0, has_ghosts=False)[source]

Bases: pysph.sph.scheme.Scheme

Parameters:
  • fluids (list) – a list with names of fluid particle arrays
  • solids (list) – a list with names of solid (or boundary) particle arrays
  • dim (int) – dimensionality of the problem
  • gamma (double) – Gamma for equation of state
  • alpha (double) – artificial viscosity parameter
  • beta (double) – artificial viscosity parameter
  • k (double) – kernel scaling parameter
  • eps (double) – kernel scaling parameter
  • g1 (double) – artificial heat conduction parameter
  • g2 (double) – artificial heat conduction parameter
  • has_ghosts (bool) – if problem uses ghost particles (periodic or mirror)
configure_solver(kernel=None, integrator_cls=None, extra_steppers=None, **kw)[source]

Configure the solver to be generated.

Parameters:
  • kernel (Kernel instance.) – Kernel to use, if none is passed a default one is used.
  • integrator_cls (pysph.sph.integrator.Integrator) – Integrator class to use, use sensible default if none is passed.
  • extra_steppers (dict) – Additional integration stepper instances as a dict.
  • **kw (extra arguments) – Any additional keyword args are passed to the solver instance.
get_equations()[source]
setup_properties(particles, clean=True)[source]

Setup the particle arrays so they have the right set of properties for this scheme.

Parameters:
  • particles (list) – List of particle arrays.
  • clean (bool) – If True, removes any unnecessary properties.
class pysph.sph.scheme.AdamiHuAdamsScheme(fluids, solids, dim, rho0, c0, nu, h0, gx=0.0, gy=0.0, gz=0.0, p0=0.0, gamma=7.0, tdamp=0.0, alpha=0.0)[source]

Bases: pysph.sph.scheme.TVFScheme

This is a scheme similiar to that in the paper:

Adami, S., Hu, X., Adams, N. A generalized wall boundary condition for smoothed particle hydrodynamics. Journal of Computational Physics 2012;231(21):7057-7075.

The major difference is in how the equations are integrated. The paper has a different scheme that does not quite fit in with how things are done in PySPH readily so we simply use the WCSPHStep which works well.

add_user_options(group)[source]
attributes_changed()[source]

Overload this to compute any properties that depend on others.

This is automatically called when configure is called.

configure_solver(kernel=None, integrator_cls=None, extra_steppers=None, **kw)[source]

Configure the solver to be generated.

Parameters:
  • kernel (Kernel instance.) – Kernel to use, if none is passed a default one is used.
  • integrator_cls (pysph.sph.integrator.Integrator) – Integrator class to use, use sensible default if none is passed.
  • extra_steppers (dict) – Additional integration stepper instances as a dict.
  • **kw (extra arguments) – Any additional keyword args are passed to the solver instance.
consume_user_options(options)[source]
get_equations()[source]
setup_properties(particles, clean=True)[source]

Setup the particle arrays so they have the right set of properties for this scheme.

Parameters:
  • particles (list) – List of particle arrays.
  • clean (bool) – If True, removes any unnecessary properties.
class pysph.sph.scheme.GSPHScheme(fluids, solids, dim, gamma, kernel_factor, g1=0.0, g2=0.0, rsolver=2, interpolation=1, monotonicity=1, interface_zero=True, hybrid=False, blend_alpha=5.0, tf=1.0, niter=20, tol=1e-06, has_ghosts=False)[source]

Bases: pysph.sph.scheme.Scheme

Parameters:
  • fluids (list) – List of names of fluid particle arrays.
  • solids (list) – List of names of solid particle arrays (or boundaries), currently not supported
  • dim (int) – Dimensionality of the problem.
  • gamma (float) – Gamma for Equation of state.
  • kernel_factor (float) – Kernel scaling factor.
  • g2 (g1,) – ADKE style thermal conduction parameters
  • rsolver (int) – Riemann solver to use. See pysph.sph.gas_dynamics.gsph for valid options.
  • interpolation (int) – Kind of interpolation for the specific volume integrals.
  • monotonicity (int) – Type of monotonicity algorithm to use: 0 : First order GSPH 1 : I02 algorithm # https://doi.org/10.1006/jcph.2002.7053 2 : IwIn algorithm # https://doi.org/10.1111/j.1365-2966.2011.19588.x # noqa: E501
  • interface_zero (bool) – Set Interface position s^*_{ij} = 0 for the Riemann problem.
  • blend_alpha (hybrid,) – Hybrid scheme and blending alpha value
  • tf (double) – Final time used for blending.
  • niter (int) – Max number of iterations for iterative Riemann solvers.
  • tol (double) – Tolerance for iterative Riemann solvers.
  • has_ghosts (bool) – if ghost particles (either mirror or periodic) is used
add_user_options(group)[source]
configure_solver(kernel=None, integrator_cls=None, extra_steppers=None, **kw)[source]

Configure the solver to be generated.

Parameters:
  • kernel (Kernel instance.) – Kernel to use, if none is passed a default one is used.
  • integrator_cls (pysph.sph.integrator.Integrator) – Integrator class to use, use sensible default if none is passed.
  • extra_steppers (dict) – Additional integration stepper instances as a dict.
  • **kw (extra arguments) – Any additional keyword args are passed to the solver instance.
consume_user_options(options)[source]
get_equations()[source]
setup_properties(particles, clean=True)[source]

Setup the particle arrays so they have the right set of properties for this scheme.

Parameters:
  • particles (list) – List of particle arrays.
  • clean (bool) – If True, removes any unnecessary properties.
class pysph.sph.scheme.GasDScheme(fluids, solids, dim, gamma, kernel_factor, alpha1=1.0, alpha2=0.1, beta=2.0, adaptive_h_scheme='mpm', update_alpha1=False, update_alpha2=False, max_density_iterations=250, density_iteration_tolerance=0.001, has_ghosts=False)[source]

Bases: pysph.sph.scheme.Scheme

Parameters:
  • fluids (list) – List of names of fluid particle arrays.
  • solids (list) – List of names of solid particle arrays (or boundaries), currently not supported
  • dim (int) – Dimensionality of the problem.
  • gamma (float) – Gamma for Equation of state.
  • kernel_factor (float) – Kernel scaling factor.
  • alpha1 (float) – Artificial viscosity parameter.
  • alpha2 (float) – Artificial viscosity parameter.
  • beta (float) – Artificial viscosity parameter.
  • adaptive_h_scheme (str) – Adaptive h scheme to use. One of [‘mpm’, ‘gsph’]
  • update_alpha1 (bool) – Update the alpha1 parameter dynamically.
  • update_alpha2 (bool) – Update the alpha2 parameter dynamically.
  • max_density_iterations (int) – Maximum number of iterations to run for one density step
  • density_iteration_tolerance (float) – Maximum difference allowed in two successive density iterations
  • has_ghosts (bool) – if ghost particles (either mirror or periodic) is used
add_user_options(group)[source]
configure_solver(kernel=None, integrator_cls=None, extra_steppers=None, **kw)[source]

Configure the solver to be generated.

Parameters:
  • kernel (Kernel instance.) – Kernel to use, if none is passed a default one is used.
  • integrator_cls (pysph.sph.integrator.Integrator) – Integrator class to use, use sensible default if none is passed.
  • extra_steppers (dict) – Additional integration stepper instances as a dict.
  • **kw (extra arguments) – Any additional keyword args are passed to the solver instance.
consume_user_options(options)[source]
get_equations()[source]
setup_properties(particles, clean=True)[source]

Setup the particle arrays so they have the right set of properties for this scheme.

Parameters:
  • particles (list) – List of particle arrays.
  • clean (bool) – If True, removes any unnecessary properties.
class pysph.sph.scheme.Scheme(fluids, solids, dim)[source]

Bases: object

An API for an SPH scheme.

Parameters:
  • fluids (list) – List of names of fluid particle arrays.
  • solids (list) – List of names of solid particle arrays (or boundaries).
  • dim (int) – Dimensionality of the problem.
add_user_options(group)[source]
attributes_changed()[source]

Overload this to compute any properties that depend on others.

This is automatically called when configure is called.

configure(**kw)[source]

Configure the scheme with given parameters.

Overload this to do any scheme specific stuff.

configure_solver(kernel=None, integrator_cls=None, extra_steppers=None, **kw)[source]

Configure the solver to be generated.

Parameters:
  • kernel (Kernel instance.) – Kernel to use, if none is passed a default one is used.
  • integrator_cls (pysph.sph.integrator.Integrator) – Integrator class to use, use sensible default if none is passed.
  • extra_steppers (dict) – Additional integration stepper instances as a dict.
  • **kw (extra arguments) – Any additional keyword args are passed to the solver instance.
consume_user_options(options)[source]
get_equations()[source]
get_solver()[source]
setup_properties(particles, clean=True)[source]

Setup the particle arrays so they have the right set of properties for this scheme.

Parameters:
  • particles (list) – List of particle arrays.
  • clean (bool) – If True, removes any unnecessary properties.
class pysph.sph.scheme.SchemeChooser(default, **schemes)[source]

Bases: pysph.sph.scheme.Scheme

Parameters:
  • default (str) – Name of the default scheme to use.
  • **schemes (kwargs) – The schemes to choose between.
add_user_options(group)[source]
attributes_changed()[source]

Overload this to compute any properties that depend on others.

This is automatically called when configure is called.

configure(**kw)[source]

Configure the scheme with given parameters.

Overload this to do any scheme specific stuff.

configure_solver(kernel=None, integrator_cls=None, extra_steppers=None, **kw)[source]

Configure the solver to be generated.

Parameters:
  • kernel (Kernel instance.) – Kernel to use, if none is passed a default one is used.
  • integrator_cls (pysph.sph.integrator.Integrator) – Integrator class to use, use sensible default if none is passed.
  • extra_steppers (dict) – Additional integration stepper instances as a dict.
  • **kw (extra arguments) – Any additional keyword args are passed to the solver instance.
consume_user_options(options)[source]
get_equations()[source]
get_solver()[source]
setup_properties(particles, clean=True)[source]

Setup the particle arrays so they have the right set of properties for this scheme.

Parameters:
  • particles (list) – List of particle arrays.
  • clean (bool) – If True, removes any unnecessary properties.
class pysph.sph.scheme.TVFScheme(fluids, solids, dim, rho0, c0, nu, p0, pb, h0, gx=0.0, gy=0.0, gz=0.0, alpha=0.0, tdamp=0.0)[source]

Bases: pysph.sph.scheme.Scheme

add_user_options(group)[source]
configure_solver(kernel=None, integrator_cls=None, extra_steppers=None, **kw)[source]

Configure the solver to be generated.

Parameters:
  • kernel (Kernel instance.) – Kernel to use, if none is passed a default one is used.
  • integrator_cls (pysph.sph.integrator.Integrator) – Integrator class to use, use sensible default if none is passed.
  • extra_steppers (dict) – Additional integration stepper instances as a dict.
  • **kw (extra arguments) – Any additional keyword args are passed to the solver instance.
consume_user_options(options)[source]
get_equations()[source]
get_timestep(cfl=0.25)[source]
setup_properties(particles, clean=True)[source]

Setup the particle arrays so they have the right set of properties for this scheme.

Parameters:
  • particles (list) – List of particle arrays.
  • clean (bool) – If True, removes any unnecessary properties.
class pysph.sph.scheme.WCSPHScheme(fluids, solids, dim, rho0, c0, h0, hdx, gamma=7.0, gx=0.0, gy=0.0, gz=0.0, alpha=0.1, beta=0.0, delta=0.1, nu=0.0, tensile_correction=False, hg_correction=False, update_h=False, delta_sph=False, summation_density=False)[source]

Bases: pysph.sph.scheme.Scheme

Parameters:
  • fluids (list) – List of names of fluid particle arrays.
  • solids (list) – List of names of solid particle arrays (or boundaries).
  • dim (int) – Dimensionality of the problem.
  • rho0 (float) – Reference density.
  • c0 (float) – Reference speed of sound.
  • gamma (float) – Gamma for the equation of state.
  • h0 (float) – Reference smoothing length.
  • hdx (float) – Ratio of h/dx.
  • gy, gz (gx,) – Body force acceleration components.
  • alpha (float) – Coefficient for artificial viscosity.
  • beta (float) – Coefficient for artificial viscosity.
  • delta (float) – Coefficient used to control the intensity of diffusion of density
  • nu (float) – Real viscosity of the fluid, defaults to no viscosity.
  • tensile_correction (bool) – Use tensile correction.
  • hg_correction (bool) – Use the Hughes-Graham correction.
  • update_h (bool) – Update the smoothing length as per Ferrari et al.
  • delta_sph (bool) – Use the delta-SPH correction terms.
  • summation_density (bool) – Use summation density instead of continuity.

References

[Hughes2010]J. P. Hughes and D. I. Graham, “Comparison of incompressible and weakly-compressible SPH models for free-surface water flows”, Journal of Hydraulic Research, 48 (2010), pp. 105-117.
[Marrone2011]S. Marrone et al., “delta-SPH model for simulating violent impact flows”, Computer Methods in Applied Mechanics and Engineering, 200 (2011), pp 1526–1542.
[Cherfils2012]J. M. Cherfils et al., “JOSEPHINE: A parallel SPH code for free-surface flows”, Computer Physics Communications, 183 (2012), pp 1468–1480.
add_user_options(group)[source]
configure_solver(kernel=None, integrator_cls=None, extra_steppers=None, **kw)[source]

Configure the solver to be generated.

Parameters:
  • kernel (Kernel instance.) – Kernel to use, if none is passed a default one is used.
  • integrator_cls (pysph.sph.integrator.Integrator) – Integrator class to use, use sensible default if none is passed.
  • extra_steppers (dict) – Additional integration stepper instances as a dict.
  • **kw (extra arguments) – Any additional keyword args are passed to the solver instance.
consume_user_options(options)[source]
get_equations()[source]
get_timestep(cfl=0.5)[source]
setup_properties(particles, clean=True)[source]

Setup the particle arrays so they have the right set of properties for this scheme.

Parameters:
  • particles (list) – List of particle arrays.
  • clean (bool) – If True, removes any unnecessary properties.
pysph.sph.scheme.add_bool_argument(group, arg, dest, help, default)[source]
class pysph.sph.gas_dynamics.magma2.MAGMA2Scheme(fluids, solids, dim, gamma, hfact=None, fkern=1.0, adaptive_h_scheme='magma2', max_density_iterations=250, density_iteration_tolerance=0.001, alphamax=1.0, alphamin=0.1, alphac=0.05, beta=2.0, eps=0.01, eta_crit=0.3, eta_fold=0.2, ndes=None, reconstruction_order=2, formulation='mi1', recycle_accelerations=True, has_ghosts=False, l0=-9.210340371976182, l1=-2.995732273553991)[source]

Bases: pysph.sph.scheme.Scheme

MAGMA2 formulations.

Set of Equations: [Rosswog2020b]

Dissipation Limiter: [Rosswog2020a]

Parameters:
  • fluids (list) – List of names of fluid particle arrays.
  • solids (list) – List of names of solid particle arrays (or boundaries), currently not supported
  • dim (int) – Dimensionality of the problem.
  • gamma (float) – \(\gamma\) for Equation of state.
  • hfact (float) – \(h_{fact}\) for smoothing length adaptivity, also referred to as kernel_factor in other schemes like AKDE, MPM, GSPH.
  • formulation (str, optional) – Set of governing equations for momentum and energy. Should be one of {‘stdgrad’, ‘mi1’, ‘mi2’}, by default ‘mi1’.
  • adaptive_h_scheme (str, optional) – Procedure to adapt smoothing lengths. Should be one of {‘gadget2’, ‘mpm’}, by default ‘gadget2’.
  • max_density_iterations (int, optional) – Maximum number of iterations to run for one density step if using MPM procedure to adapt smoothing lengths, by default 2.0
  • density_iteration_tolerance (float, optional) – Maximum difference allowed in two successive density iterations if using MPM procedure to adapt smoothing lengths, by default 1e-3.
  • alphamax (float, optional) – \(\alpha_{max}\) for artificial viscosity switch, by default 1.0
  • alphamin (float, optional) – \(\alpha_{0}\) for artificial viscosity switch, by default 0.1
  • alphac (float, optional) – \(\alpha_{u}\) for artificial conductivity, by default 0.05
  • beta (float, optional) – \(\beta\) for artificial viscosity, by default 2.0
  • eps (float, optional) – Numerical parameter often used in denominator to avoid division by zero, by default 0.01
  • eta_crit (float, optional) – \(\eta_{crit}\) for slope limiter, by default None
  • eta_fold (float, optional) – \(\eta_{fold}\) for slope limiter, by default 0.2
  • fkern (float, optional) – \(f_{kern}\), Factor to scale smoothing length for equivalence when using kernel with altered radius_scale, by default 1.0.
  • ndes (int, optional) – \(n_{des}\), Desired number of neighbours to be in the kernel support of each particle, by default 300 for 3D.
  • reconstruction_order (int, optional) – Order of reconstruction, by default 2.
  • recycle_accelerations (bool, optional) – Weather to recycle accelerations, i.e., weather the accelerations used in the correction step can be reused in the successive prediction step, by default True.
  • has_ghosts (bool, optional) – If ghost particles (either mirror or periodic) is used, by default False.
  • l0 (float, optional) – Low entropy threshold parameter for dissipation trigger, by default log(1e-4).
  • l1 (float, optional) – High entropy threshold parameter for dissipation trigger, by default log(5e-2).