SPH equations
- class pysph.sph.equation.Equation(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
Basic SPH Equations
References
J. Monaghan, Smoothed Particle Hydrodynamics, “Annual Review of Astronomy and Astrophysics”, 30 (1992), pp. 543-574.
J. Monaghan, “Smoothed particle hydrodynamics”, Reports on Progress in Physics, 68 (2005), pp. 1703-1759.
- class pysph.sph.basic_equations.BodyForce(dest, sources, fx=0.0, fy=0.0, fz=0.0)[source]
Add a body force to the particles:
\(\boldsymbol{f} = f_x, f_y, f_z\)
- Parameters:
fx (float) – Body force per unit mass along the x-axis
fy (float) – Body force per unit mass along the y-axis
fz (float) – Body force per unit mass along the z-axis
- class pysph.sph.basic_equations.ContinuityEquation(dest, sources)[source]
Density rate:
\(\frac{d\rho_a}{dt} = \sum_b m_b \boldsymbol{v}_{ab}\cdot \nabla_a W_{ab}\)
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.basic_equations.IsothermalEOS(dest, sources, rho0, c0, p0)[source]
Compute the pressure using the Isothermal equation of state:
\(p = p_0 + c_0^2(\rho_0 - \rho)\)
- Parameters:
rho0 (float) – Reference density of the fluid (\(\rho_0\))
c0 (float) – Maximum speed of sound expected in the system (\(c0\))
p0 (float) – Reference pressure in the system (\(p0\))
- class pysph.sph.basic_equations.MonaghanArtificialViscosity(dest, sources, alpha=1.0, beta=1.0)[source]
Classical Monaghan style artificial viscosity [Monaghan2005]
\[\frac{d\mathbf{v}_{a}}{dt}&=&-\sum_{b}m_{b}\Pi_{ab}\nabla_{a}W_{ab}\]where
\[\begin{split}\Pi_{ab}=\begin{cases}\frac{-\alpha_{\pi}\bar{c}_{ab}\phi_{ab}+ \beta_{\pi}\phi_{ab}^{2}}{\bar{\rho}_{ab}}, & \mathbf{v}_{ab}\cdot \mathbf{r}_{ab}<0\\0, & \mathbf{v}_{ab}\cdot\mathbf{r}_{ab}\geq0 \end{cases}\end{split}\]with
\[ \begin{align}\begin{aligned}\begin{split}\phi_{ab}=\frac{h\mathbf{v}_{ab}\cdot\mathbf{r}_{ab}} {|\mathbf{r}_{ab}|^{2}+\epsilon^{2}}\\\end{split}\\\begin{split}\bar{c}_{ab}&=&\frac{c_{a}+c_{b}}{2}\\\end{split}\\\bar{\rho}_{ab}&=&\frac{\rho_{a}+\rho_{b}}{2}\end{aligned}\end{align} \]- Parameters:
alpha (float) – produces a shear and bulk viscosity
beta (float) – used to handle high Mach number shocks
- class pysph.sph.basic_equations.SummationDensity(dest, sources)[source]
Good old Summation density:
\(\rho_a = \sum_b m_b W_{ab}\)
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.basic_equations.VelocityGradient2D(dest, sources)[source]
Compute the SPH evaluation for the velocity gradient tensor in 2D.
The expression for the velocity gradient is:
\(\frac{\partial v^i}{\partial x^j} = \sum_{b}\frac{m_b}{\rho_b}(v_b - v_a)\frac{\partial W_{ab}}{\partial x_a^j}\)
Notes
The tensor properties are stored in the variables v_ij where ‘i’ refers to the velocity component and ‘j’ refers to the spatial component. Thus v_10 is \(\frac{\partial v}{\partial x}\)
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.basic_equations.VelocityGradient3D(dest, sources)[source]
Compute the SPH evaluation for the velocity gradient tensor in 2D.
The expression for the velocity gradient is:
\(\frac{\partial v^i}{\partial x^j} = \sum_{b}\frac{m_b}{\rho_b}(v_b - v_a)\frac{\partial W_{ab}}{\partial x_a^j}\)
Notes
The tensor properties are stored in the variables v_ij where ‘i’ refers to the velocity component and ‘j’ refers to the spatial component. Thus v_21 is \(\frac{\partial v}{\partial x}\)
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.basic_equations.XSPHCorrection(dest, sources, eps=0.5)[source]
Position stepping with XSPH correction [Monaghan1992]
\[\frac{d\mathbf{r}_{a}}{dt}=\mathbf{\hat{v}}_{a}=\mathbf{v}_{a}- \epsilon\sum_{b}m_{b}\frac{\mathbf{v}_{ab}}{\bar{\rho}_{ab}}W_{ab}\]- Parameters:
eps (float) – \(\epsilon\) as in the above equation
Notes
This equation must be used to advect the particles. XSPH can be turned off by setting the parameter
eps = 0.
- class pysph.sph.basic_equations.XSPHCorrectionForLeapFrog(dest, sources, eps=0.5)[source]
The XSPH correction [Monaghan1992] alone. This is meant to be used with a leap-frog integrator which already considers the velocity of the particles. It simply computes the correction term and adds that to
ax, ay, az.\[\frac{d\mathbf{r}_{a}}{dt}=\mathbf{\hat{v}}_{a}= - \epsilon\sum_{b}m_{b}\frac{\mathbf{v}_{ab}}{\bar{\rho}_{ab}}W_{ab}\]- Parameters:
eps (float) – \(\epsilon\) as in the above equation
Notes
This equation must be used to advect the particles. XSPH can be turned off by setting the parameter
eps = 0.
Basic WCSPH Equations
- class pysph.sph.wc.basic.ContinuityEquationDeltaSPH(dest, sources, c0, delta=0.1)[source]
Continuity equation with dissipative terms
\(\frac{d\rho_a}{dt} = \sum_b \rho_a \frac{m_b}{\rho_b} \left( \boldsymbol{v}_{ab}\cdot \nabla_a W_{ab} + \delta \eta_{ab} \cdot \nabla_{a} W_{ab} (h_{ab}\frac{c_{ab}}{\rho_a}(\rho_b - \rho_a)) \right)\)
References
[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.
- Parameters:
c0 (float) – reference speed of sound
delta (float) – coefficient used to control the intensity of diffusion of density
- class pysph.sph.wc.basic.ContinuityEquationDeltaSPHPreStep(dest, sources)[source]
Continuity equation with dissipative terms See
pysph.sph.wc.basic.ContinuityEquationDeltaSPHThe matrix \(L_a\) is multiplied to \(\nabla W_{ij}\) in thepysph.sph.scheme.WCSPHSchemeclass by usingpysph.sph.wc.kernel_correction.GradientCorrectionPreStepandpysph.sph.wc.kernel_correction.GradientCorrection.- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.basic.MomentumEquation(dest, sources, c0, alpha=1.0, beta=1.0, gx=0.0, gy=0.0, gz=0.0, tensile_correction=False)[source]
Classic Monaghan Style Momentum Equation with Artificial Viscosity
\[\frac{d\mathbf{v}_{a}}{dt}=-\sum_{b}m_{b}\left(\frac{p_{b}} {\rho_{b}^{2}}+\frac{p_{a}}{\rho_{a}^{2}}+\Pi_{ab}\right) \nabla_{a}W_{ab}\]where
\[\begin{split}\Pi_{ab}=\begin{cases} \frac{-\alpha\bar{c}_{ab}\mu_{ab}+\beta\mu_{ab}^{2}}{\bar{\rho}_{ab}} & \mathbf{v}_{ab}\cdot\mathbf{r}_{ab}<0;\\ 0 & \mathbf{v}_{ab}\cdot\mathbf{r}_{ab}\geq0; \end{cases}\end{split}\]with
\[ \begin{align}\begin{aligned}\begin{split}\mu_{ab}=\frac{h\mathbf{v}_{ab}\cdot\mathbf{r}_{ab}} {\mathbf{r}_{ab}^{2}+\eta^{2}}\\\end{split}\\\begin{split}\bar{c}_{ab} = \frac{c_a + c_b}{2}\\\end{split}\\\bar{\rho}_{ab} = \frac{\rho_a + \rho_b}{2}\end{aligned}\end{align} \]References
[Monaghan1992]J. Monaghan, Smoothed Particle Hydrodynamics, “Annual Review of Astronomy and Astrophysics”, 30 (1992), pp. 543-574.
- Parameters:
c0 (float) – reference speed of sound
alpha (float) – produces a shear and bulk viscosity
beta (float) – used to handle high Mach number shocks
gx (float) – body force per unit mass along the x-axis
gy (float) – body force per unit mass along the y-axis
gz (float) – body force per unit mass along the z-axis
tensilte_correction (bool) – switch for tensile instability correction (Default: False)
- class pysph.sph.wc.basic.MomentumEquationDeltaSPH(dest, sources, rho0, c0, alpha=1.0)[source]
Momentum equation defined in JOSEPHINE and the delta-SPH model
\[\frac{du_{i}}{dt}=-\frac{1}{\rho_{i}}\sum_{j}\left(p_{j}+p_{i}\right) \nabla_{i}W_{ij}V_{j}+\mathbf{g}_{i}+\alpha hc_{0}\rho_{0}\sum_{j} \pi_{ij}\nabla_{i}W_{ij}V_{j}\]where
\[\pi_{ij}=\frac{\mathbf{u}_{ij}\cdot\mathbf{r}_{ij}} {|\mathbf{r}_{ij}|^{2}}\]References
[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.
- Parameters:
rho0 (float) – reference density
c0 (float) – reference speed of sound
alpha (float) – coefficient used to control the intensity of the diffusion of velocity
Notes
Artificial viscosity is used in this momentum equation and is controlled by the parameter \(\alpha\). This form of the artificial viscosity is similar but not identical to the Monaghan-style artificial viscosity.
- class pysph.sph.wc.basic.PressureGradientUsingNumberDensity(dest, sources)[source]
Pressure gradient discretized using number density:
\[\frac{d \boldsymbol{v}_a}{dt} = -\frac{1}{m_a}\sum_b (\frac{p_a}{V_a^2} + \frac{p_b}{V_b^2})\nabla_a W_{ab}\]- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.basic.TaitEOS(dest, sources, rho0, c0, gamma, p0=0.0)[source]
Tait equation of state for water-like fluids
\(p_a = \frac{c_{0}^2\rho_0}{\gamma}\left( \left(\frac{\rho_a}{\rho_0}\right)^{\gamma} -1\right)\)
References
[Cole1948]H. R. Cole, “Underwater Explosions”, Princeton University Press, 1948.
[Batchelor2002]G. Batchelor, “An Introduction to Fluid Dynamics”, Cambridge University Press, 2002.
[Monaghan2005]J. Monaghan, “Smoothed particle hydrodynamics”, Reports on Progress in Physics, 68 (2005), pp. 1703-1759.
- Parameters:
rho0 (float) – reference density of fluid particles
c0 (float) – maximum speed of sound expected in the system
gamma (float) – constant
p0 (float) – reference pressure in the system (defaults to zero).
Notes
The reference speed of sound, c0, is to be taken approximately as 10 times the maximum expected velocity in the system. The particle sound speed is given by the usual expression:
\(c_a = \sqrt{\frac{\partial p}{\partial \rho}}\)
- class pysph.sph.wc.basic.TaitEOSHGCorrection(dest, sources, rho0, c0, gamma)[source]
Tait Equation of State with Hughes and Graham Correction
\[p_a = \frac{c_{0}^2\rho_0}{\gamma}\left( \left(\frac{\rho_a}{\rho_0}\right)^{\gamma} -1\right)\]where
\[\begin{split}\rho_{a}=\begin{cases}\rho_{a} & \rho_{a}\geq\rho_{0}\\ \rho_{0} & \rho_{a}<\rho_{0}\end{cases}`\end{split}\]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.
- Parameters:
rho0 (float) – reference density
c0 (float) – reference speed of sound
gamma (float) – constant
Notes
The correction is to be applied on boundary particles and imposes a minimum value of the density (rho0) which is set upon instantiation. This correction avoids particle sticking behaviour at walls.
- class pysph.sph.wc.basic.UpdateSmoothingLengthFerrari(dest, sources, dim, hdx)[source]
Update the particle smoothing lengths
\(h_a = hdx \left(\frac{m_a}{\rho_a}\right)^{\frac{1}{d}}\)
References
[Ferrari2009]A. Ferrari et al., “A new 3D parallel SPH scheme for free surface flows”, Computers and Fluids, 38 (2009), pp. 1203–1217.
- Parameters:
dim (float) – number of dimensions
hdx (float) – scaling factor
Notes
Ideally, the kernel scaling factor should be determined from the kernel used based on a linear stability analysis. The default value of (hdx=1) reduces to the formulation suggested by Ferrari et al. who used a Cubic Spline kernel.
Typically, a change in the smoothing length should mean the neighbors are re-computed which in PySPH means the NNPS must be updated. This equation should therefore be placed as the last equation so that after the final corrector stage, the smoothing lengths are updated and the new NNPS data structure is computed.
Note however that since this is to be used with incompressible flow equations, the density variations are small and hence the smoothing lengths should also not vary too much.
Viscosity functions
- class pysph.sph.wc.viscosity.ClearyArtificialViscosity(dest, sources, dim, alpha=1.0)[source]
Artificial viscosity proposed By P. Cleary:
\[\mathcal{Pi}_{ab} = -\frac{16}{\mu_a \mu_b}{\rho_a \rho_b (\mu_a + \mu_b)}\left( \frac{\boldsymbol{v}_{ab} \cdot \boldsymbol{r}_{ab}}{\boldsymbol{r}_{ab}^2 + \epsilon} \right),\]where the viscosity is determined from the parameter \(\alpha\) as
\[\mu_a = \frac{1}{8}\alpha h_a c_a \rho_a\]This equation is described in the 2005 review paper by Monaghan
J. J. Monaghan, “Smoothed Particle Hydrodynamics”, Reports on Progress in Physics, 2005, 68, pp 1703–1759 [JM05]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.viscosity.LaminarViscosity(dest, sources, nu, eta=0.01)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.viscosity.LaminarViscosityDeltaSPH(dest, sources, dim, rho0, nu)[source]
See section 2 of the below reference [Sun2017]
References
[Sun2017]P. Sun, A. Colagrossi, S. Marrone, A. Zhang “The $delta$ plus-SPH model: simple procedures for a further improvement of the SPH scheme”, Computer Methods in Applied Mechanics and Engineering 315 (2017), pp. 25-49.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.viscosity.MonaghanSignalViscosityFluids(dest, sources, alpha, h)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
Transport Velocity Formulation
References
S. Adami et. al “A generalized wall boundary condition for smoothed particle hydrodynamics”, Journal of Computational Physics (2012), pp. 7057–7075.
S. Adami et. al “A transport-velocity formulation for smoothed particle hydrodynamics”, Journal of Computational Physics (2013), pp. 292–307.
- class pysph.sph.wc.transport_velocity.ContinuityEquation(dest, sources)[source]
Conservation of mass equation
Eq (6) in [Adami2012]:
\[\frac{d\rho_a}{dt} = \rho_a \sum_b \frac{m_b}{\rho_b} \boldsymbol{v}_{ab} \cdot \nabla_a W_{ab}\]- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.transport_velocity.ContinuitySolid(dest, sources)[source]
Continuity equation for the solid’s ghost particles.
The key difference is that we use the ghost velocity ug, and not the particle velocity u.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.transport_velocity.MomentumEquationArtificialStress(dest, sources)[source]
Artificial stress contribution to the Momentum Equation
\[\frac{d\boldsymbol{v}_a}{dt} = \frac{1}{m_a}\sum_b (V_a^2 + V_b^2)\left[ \frac{1}{2}(\boldsymbol{A}_a + \boldsymbol{A}_b) : \nabla_a W_{ab}\right]\]where the artificial stress terms are given by:
\[ \boldsymbol{A} = \rho \boldsymbol{v} (\tilde{\boldsymbol{v}} - \boldsymbol{v})\]- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.transport_velocity.MomentumEquationArtificialViscosity(dest, sources, c0, alpha=0.1)[source]
Artificial viscosity for the momentum equation
Eq. (11) in [Adami2012]:
\[\frac{d \boldsymbol{v}_a}{dt} = -\sum_b m_b \alpha h_{ab} c_{ab} \frac{\boldsymbol{v}_{ab}\cdot \boldsymbol{r}_{ab}}{\rho_{ab}\left(|r_{ab}|^2 + \epsilon \right)}\nabla_a W_{ab}\]where
\[ \begin{align}\begin{aligned}\begin{split}\rho_{ab} = \frac{\rho_a + \rho_b}{2}\\\end{split}\\\begin{split}c_{ab} = \frac{c_a + c_b}{2}\\\end{split}\\h_{ab} = \frac{h_a + h_b}{2}\end{aligned}\end{align} \]- Parameters:
alpha (float) – constant
c0 (float) – speed of sound
- class pysph.sph.wc.transport_velocity.MomentumEquationPressureGradient(dest, sources, pb, gx=0.0, gy=0.0, gz=0.0, tdamp=0.0)[source]
Momentum equation for the Transport Velocity Formulation: Pressure
Eq. (8) in [Adami2013]:
\[\frac{d \boldsymbol{v}_a}{dt} = \frac{1}{m_a}\sum_b (V_a^2 + V_b^2)\left[-\bar{p}_{ab}\nabla_a W_{ab} \right]\]where
\[\bar{p}_{ab} = \frac{\rho_b p_a + \rho_a p_b}{\rho_a + \rho_b}\]- Parameters:
pb (float) – background pressure
gx (float) – Body force per unit mass along the x-axis
gy (float) – Body force per unit mass along the y-axis
gz (float) – Body force per unit mass along the z-axis
tdamp (float) – damping time
Notes
This equation should have the destination as fluid and sources as fluid and boundary particles.
This function also computes the contribution to the background pressure and accelerations due to a body force or gravity.
The body forces are damped according to Eq. (13) in [Adami2012] to avoid instantaneous accelerations. By default, damping is neglected.
- class pysph.sph.wc.transport_velocity.MomentumEquationViscosity(dest, sources, nu)[source]
Momentum equation for the Transport Velocity Formulation: Viscosity
Eq. (8) in [Adami2013]:
\[\frac{d \boldsymbol{v}_a}{dt} = \frac{1}{m_a}\sum_b (V_a^2 + V_b^2)\left[ \bar{\eta}_{ab}\hat{r}_{ab}\cdot \nabla_a W_{ab} \frac{\boldsymbol{v}_{ab}}{|\boldsymbol{r}_{ab}|}\right]\]where
\[\bar{\eta}_{ab} = \frac{2\eta_a \eta_b}{\eta_a + \eta_b}\]- Parameters:
nu (float) – kinematic viscosity
- class pysph.sph.wc.transport_velocity.SetWallVelocity(dest, sources)[source]
Extrapolating the fluid velocity on to the wall
Eq. (22) in [Adami2012]:
\[\tilde{\boldsymbol{v}}_a = \frac{\sum_b\boldsymbol{v}_b W_{ab}} {\sum_b W_{ab}}\]Notes
The destination particle array for this equation should define the filtered velocity variables \(uf, vf, wf\).
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.transport_velocity.SolidWallNoSlipBC(dest, sources, nu)[source]
Solid wall boundary condition [Adami2012]
This boundary condition is to be used with fixed ghost particles in SPH simulations and is formulated for the general case of moving boundaries.
The velocity and pressure of the fluid particles is extrapolated to the ghost particles and these values are used in the equations of motion.
No-penetration:
Ghost particles participate in the continuity and state equations with fluid particles. This means as fluid particles approach the wall, the pressure of the ghost particles increases to generate a repulsion force that prevents particle penetration.
No-slip:
Extrapolation is used to set the dummy velocity of the ghost particles for viscous interaction. First, the smoothed velocity field of the fluid phase is extrapolated to the wall particles:
\[\tilde{v}_a = \frac{\sum_b v_b W_{ab}}{\sum_b W_{ab}}\]In the second step, for the viscous interaction in Eqs. (10) in [Adami2012] and Eq. (8) in [Adami2013], the velocity of the ghost particles is assigned as:
\[v_b = 2v_w -\tilde{v}_a,\]where \(v_w\) is the prescribed wall velocity and \(v_b\) is the ghost particle in the interaction.
- Parameters:
nu (float) – kinematic viscosity
Notes
For this equation the destination particle array should be the fluid and the source should be ghost or boundary particles. The boundary particles must define a prescribed velocity \(u_0, v_0, w_0\)
- class pysph.sph.wc.transport_velocity.SolidWallPressureBC(dest, sources, rho0, p0, b=1.0, gx=0.0, gy=0.0, gz=0.0)[source]
Solid wall pressure boundary condition [Adami2012]
This boundary condition is to be used with fixed ghost particles in SPH simulations and is formulated for the general case of moving boundaries.
The velocity and pressure of the fluid particles is extrapolated to the ghost particles and these values are used in the equations of motion.
Pressure boundary condition:
The pressure of the ghost particle is also calculated from the fluid particle by interpolation using:
\[p_g = \frac{\sum_f p_f W_{gf} + \boldsymbol{g - a_g} \cdot \sum_f \rho_f \boldsymbol{r}_{gf}W_{gf}}{\sum_f W_{gf}},\]where the subscripts g and f relate to the ghost and fluid particles respectively.
Density of the wall particle is then set using this pressure
\[\rho_w=\rho_0\left(\frac{p_w - \mathcal{X}}{p_0} + 1\right)^{\frac{1}{\gamma}}\]- Parameters:
rho0 (float) – reference density
p0 (float) – reference pressure
b (float) – constant (default 1.0)
gx (float) – Body force per unit mass along the x-axis
gy (float) – Body force per unit mass along the y-axis
gz (float) – Body force per unit mass along the z-axis
Notes
For a two fluid system (boundary, fluid), this equation must be instantiated with boundary as the destination and fluid as the source.
The boundary particle array must additionally define a property \(wij\) for the denominator in Eq. (27) from [Adami2012]. This array sums the kernel terms from the ghost particle to the fluid particle.
- class pysph.sph.wc.transport_velocity.StateEquation(dest, sources, p0, rho0, b=1.0)[source]
Generalized Weakly Compressible Equation of State
\[p_a = p_0\left[ \left(\frac{\rho}{\rho_0}\right)^\gamma - b \right] + \mathcal{X}\]Notes
This is the generalized Tait’s equation of state and the suggested values in [Adami2013] are \(\mathcal{X} = 0\), \(\gamma=1\) and \(b = 1\).
The reference pressure \(p_0\) is calculated from the artificial sound speed and reference density:
\[p_0 = \frac{c^2\rho_0}{\gamma}\]- Parameters:
p0 (float) – reference pressure
rho0 (float) – reference density
b (float) – constant (default 1.0).
- class pysph.sph.wc.transport_velocity.SummationDensity(dest, sources)[source]
Summation density with volume summation
In addition to the standard summation density, the number density for the particle is also computed. The number density is important for multi-phase flows to define a local particle volume independent of the material density.
\[ \begin{align}\begin{aligned}\begin{split}\rho_a = \sum_b m_b W_{ab}\\\end{split}\\\mathcal{V}_a = \frac{1}{\sum_b W_{ab}}\end{aligned}\end{align} \]Notes
Note that in the pysph implementation, V is the inverse volume of a particle, i.e. the equation computes V as follows:
\[\mathcal{V}_a = \sum_b W_{ab}\]For this equation, the destination particle array must define the variable V for particle volume.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.transport_velocity.VolumeFromMassDensity(dest, sources)[source]
Set the inverse volume using mass density
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.transport_velocity.VolumeSummation(dest, sources)[source]
Number density for volume computation
See SummationDensity
Note that the quantity V is really \(\sigma\) of the original paper, i.e. inverse of the particle volume.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
Generalized Transport Velocity Formulation
Some notes on the paper,
In the viscosity term of equation (17) a factor of ‘2’ is missing.
A negative sign is missing from equation (22) i.e, either put a negative sign in equation (22) or at the integrator step equation(25).
The Solid Mechanics Equations are not tested.
References
Chi Zhang, Xiangyu Y. Hu, Nikolaus A. Adams “A generalized transport-velocity formulation for smoothed particle hydrodynamics”, Journal of Computational Physics 237 (2017), pp. 216–232.
- class pysph.sph.wc.gtvf.ContinuityEquationGTVF(dest, sources)[source]
Evolution of density
From [ZhangHuAdams2017], equation (12),
\[\frac{\tilde{d} \rho_i}{dt} = \rho_i \sum_j \frac{m_j}{\rho_j} \nabla W_{ij} \cdot \tilde{\boldsymbol{v}}_{ij}\]- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.gtvf.CorrectDensity(dest, sources)[source]
Density correction
From [ZhangHuAdams2017], equation (13),
\[\rho_i = \frac{\sum_j m_j W_{ij}} {\min(1, \sum_j \frac{m_j}{\rho_j^{*}} W_{ij})}\]where,
\[\rho_j^{*} = \text{density before this correction is applied.}\]- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.gtvf.DeviatoricStressRate(dest, sources, dim, G)[source]
Stress rate for solids
From [ZhangHuAdams2017], equation (5),
\[\frac{d \boldsymbol{\sigma}'}{dt} = 2 G (\boldsymbol{\epsilon} - \frac{1}{3} \text{Tr}(\boldsymbol{\epsilon})\textbf{I}) + \boldsymbol{\sigma}' \cdot \boldsymbol{\Omega}^{T} + \boldsymbol{\Omega} \cdot \boldsymbol{\sigma}'\]where,
\[\boldsymbol{\Omega_{i/j}} = \frac{1}{2} \left(\nabla \otimes \boldsymbol{v}_{i/j} - (\nabla \otimes \boldsymbol{v}_{i/j})^{T}\right)\]\[\boldsymbol{\epsilon_{i/j}} = \frac{1}{2} \left(\nabla \otimes \boldsymbol{v}_{i/j} + (\nabla \otimes \boldsymbol{v}_{i/j})^{T}\right)\]see the class VelocityGradient for \(\nabla \otimes \boldsymbol{v}_i\)
- Parameters:
dim (int) – Dimensionality of the problem.
G (float) – value of shear modulus
- class pysph.sph.wc.gtvf.GTVFIntegrator(**kw)[source]
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.
- 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(index=0, update_nnps=True)
self.do_post_stage(stage_dt, stage_count_from_1)
self.update_domain()
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.
- class pysph.sph.wc.gtvf.GTVFScheme(fluids, solids, dim, rho0, c0, nu, h0, pref, gx=0.0, gy=0.0, gz=0.0, b=1.0, alpha=0.0)[source]
- Parameters:
fluids (list) – List of names of fluid particle arrays.
solids (list) – List of names of solid particle arrays.
dim (int) – Dimensionality of the problem.
rho0 (float) – Reference density.
c0 (float) – Reference speed of sound.
nu (float) – Real viscosity of the fluid.
h0 (float) – Reference smoothing length.
pref (float) – reference pressure for rate of change of transport velocity.
gx (float) – Body force acceleration components in x direction.
gy (float) – Body force acceleration components in y direction.
gz (float) – Body force acceleration components in z direction.
b (float) – constant for the equation of state.
- 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.
- class pysph.sph.wc.gtvf.GTVFStep[source]
- class pysph.sph.wc.gtvf.MomentumEquationArtificialStress(dest, sources, dim)[source]
Momentum equation Artificial stress for solids
See the class MomentumEquationPressureGradient for details.
- Parameters:
dim (int) – Dimensionality of the problem.
- class pysph.sph.wc.gtvf.MomentumEquationArtificialStressSolid(dest, sources, dim)[source]
Momentum equation Artificial stress for solids
See the class MomentumEquationPressureGradient for details.
- Parameters:
dim (int) – Dimensionality of the problem.
- class pysph.sph.wc.gtvf.MomentumEquationPressureGradient(dest, sources, pref, gx=0.0, gy=0.0, gz=0.0)[source]
Momentum Equation
From [ZhangHuAdams2017], equation (17),
\[\frac{\tilde{d} \boldsymbol{v}_i}{dt} = - \sum_j m_j \nabla W_{ij} \cdot \left[\left(\frac{p_i}{\rho_i^2} + \frac{p_j}{\rho_j^2} \right)\textbf{I} - \left(\frac{\boldsymbol{A_i}}{\rho_i^2} + \frac{\boldsymbol{A_j}}{\rho_j^2} \right)\right] + \sum_j \frac{\eta_{ij}\boldsymbol{v}_{ij}}{\rho_i \rho_j r_{ij}} \nabla W_{ij} \cdot \boldsymbol{x}_{ij}\]where,
\[\boldsymbol{A_{i/j}} = \rho_{i/j} \boldsymbol{v}_{i/j} \otimes (\tilde{\boldsymbol{v}}_{i/j} - \boldsymbol{v}_{i/j})\]\[\eta_{ij} = \frac{2\eta_i \eta_j}{\eta_i + \eta_j}\]\[\eta_{i/j} = \rho_{i/j} \nu\]for solids, replace \(\boldsymbol{A}_{i/j}\) with \(\boldsymbol{\sigma}'_{i/j}\).
The rate of change of transport velocity is given by,
\[(\frac{d\boldsymbol{v}_i}{dt})_c = -p_i^0 \sum_j \frac{m_j} {\rho_i^2} \nabla \tilde{W}_{ij}\]where,
\[\tilde{W}_{ij} = W(\boldsymbol{x}_ij, \tilde{0.5 h_{ij}})\]\[p_i^0 = \min(10|p_i|, p_{ref})\]Notes:
A negative sign in \((\frac{d\boldsymbol{v}_i}{dt})_c\) is missing in the paper [ZhangHuAdams2017].
- Parameters:
pref (float) – reference pressure
gx (float) – body force per unit mass along the x-axis
gy (float) – body force per unit mass along the y-axis
gz (float) – body force per unit mass along the z-axis
- class pysph.sph.wc.gtvf.MomentumEquationViscosity(dest, sources, nu)[source]
Momentum equation Artificial stress for solids
See the class MomentumEquationPressureGradient for details.
Notes:
A factor of ‘2’ is missing in the viscosity equation given by [ZhangHuAdams2017].
- Parameters:
nu (float) – viscosity of the fluid.
- class pysph.sph.wc.gtvf.VelocityGradient(dest, sources, dim)[source]
Gradient of velocity vector
\[(\nabla \otimes \tilde{\boldsymbol{v}})_i = \sum_j \frac{m_j} {\rho_j} \tilde{\boldsymbol{v}}_{ij} \otimes \nabla W_{ij}\]- Parameters:
dim (int) – Dimensionality of the problem.
- class pysph.sph.wc.density_correction.MLSFirstOrder2D(dest, sources)[source]
Moving Least Squares density reinitialization This is a first order density reinitialization
\[W_{ab}^{MLS} = \beta\left(\mathbf{r_{a}}\right)\cdot\left( \mathbf{r}_a - \mathbf{r}_b\right)W_{ab}\]\[\beta\left(\mathbf{r_{a}}\right) = A^{-1} \left[1 0 0\right]^{T}\]where
\[A = \sum_{b}W_{ab}\tilde{A}\frac{m_{b}}{\rho_{b}}\]\[\tilde{A} = pp^{T}\]where
\[p = \left[1 x_{a}-x_{b} y_{a}-y_{b}\right]^{T}\]\[\rho_{a} = \sum_{b} \m_{b}W_{ab}^{MLS}\]References
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.density_correction.MLSFirstOrder3D(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.density_correction.ShepardFilter(dest, sources)[source]
Shepard Filter density reinitialization This is a zeroth order density reinitialization
\[\tilde{W_{ab}} = \frac{W_{ab}}{\sum_{b} W_{ab}\frac{m_{b}} {\rho_{b}}}\]\[\rho_{a} = \sum_{b} \m_{b}\tilde{W_{ab}}\]References
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
Kernel Corrections
These are the equations for the kernel corrections that are mentioned in the paper by Bonet and Lok [BonetLok1999].
References
Bonet, J. and Lok T.-S.L. (1999) Variational and Momentum Preservation Aspects of Smoothed Particle Hydrodynamic Formulations.
- class pysph.sph.wc.kernel_correction.GradientCorrection(dest, sources, dim=2, tol=0.1)[source]
Kernel Gradient Correction
From [BonetLok1999], equations (42) and (45)
\[\nabla \tilde{W}_{ab} = L_{a}\nabla W_{ab}\]\[L_{a} = \left(\sum \frac{m_{b}}{\rho_{b}} \nabla W_{ab} \mathbf{\otimes}x_{ba} \right)^{-1}\]- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.kernel_correction.GradientCorrectionPreStep(dest, sources, dim=2)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.kernel_correction.KernelCorrection(dest, sources)[source]
Kernel Correction
From [BonetLok1999], equation (53):
\[\mathbf{f}_{a} = \frac{\sum_{b}\frac{m_{b}}{\rho_{b}} \mathbf{f}_{b}W_{ab}}{\sum_{b}\frac{m_{b}}{\rho_{b}}W_{ab}}\]- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.kernel_correction.MixedGradientCorrection(dest, sources, dim=2, tol=0.1)[source]
Mixed Kernel Gradient Correction
This is as per [BonetLok1999]. See the MixedKernelCorrectionPreStep for the equations.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.kernel_correction.MixedKernelCorrectionPreStep(dest, sources, dim=2)[source]
Mixed Kernel Correction
From [BonetLok1999], equations (54), (57) and (58)
\[\tilde{W}_{ab} = \frac{W_{ab}}{\sum_{b} V_{b}W_{ab}}\]\[\nabla \tilde{W}_{ab} = L_{a}\nabla \bar{W}_{ab}\]where,
\[L_{a} = \left(\sum_{b} V_{b} \nabla \bar{W}_{ab} \mathbf{\otimes}x_{ba} \right)^{-1}\]\[\nabla \bar{W}_{ab} = \frac{\nabla W_{ab} - \gamma} {\sum_{b} V_{b}W_{ab}}\]\[\gamma = \frac{\sum_{b} V_{b}\nabla W_{ab}} {\sum_{b} V_{b}W_{ab}}\]- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
CRKSPH corrections
These are equations for the basic kernel corrections in [CRKSPH2017].
References
Nicholas Frontiere, Cody D. Raskin, J. Michael Owen “CRKSPH - A Conservative Reproducing Kernel Smoothed Particle Hydrodynamics Scheme”, Journal of Computational Physics 332 (2017), pp. 160–209.
- class pysph.sph.wc.crksph.CRKSPH(dest, sources, dim=2, tol=0.5)[source]
Conservative Reproducing Kernel SPH
Equations from the paper [CRKSPH2017].
\[W_{ij}^{R} = A_{i}\left(1+B_{i}^{\alpha}x_{ij}^{\alpha} \right)W_{ij}\]\[\partial_{\gamma}W_{ij}^{R} = A_{i}\left(1+B_{i}^{\alpha} x_{ij}^{\alpha}\right)\partial_{\gamma}W_{ij} + \partial_{\gamma}A_{i}\left(1+B_{i}^{\alpha}x_{ij}^{\alpha} \right)W_{ij} + A_{i}\left(\partial_{\gamma}B_{i}^{\alpha} x_{ij}^{\alpha} + B_{i}^{\gamma}\right)W_{ij}\]\[\nabla\tilde{W}_{ij} = 0.5 * \left(\nabla W_{ij}^{R}-\nabla W_{ji}^{R} \right)\]where,
\[A_{i} = \left[m_{0} - \left(m_{2}^{-1}\right)^{\alpha \beta} m_1^{\beta}m_1^{\alpha}\right]^{-1}\]\[B_{i}^{\alpha} = -\left(m_{2}^{-1}\right)^{\alpha \beta} m_{1}^{\beta}\]\[\partial_{\gamma}A_{i} = -A_{i}^{2}\left(\partial_{\gamma} m_{0}-\left(m_{2}^{-1}\right)^{\alpha \beta}\left( m_{1}^{\beta}\partial_{\gamma}m_{1}^{\alpha} + \partial_{\gamma}m_{1}^{\beta}m_{1}^{\alpha}\right) + \left(m_{2}^{-1}\right)^{\alpha \phi}\partial_{\gamma} m_{2}^{\phi \psi}\left(m_{2}^{-1}\right)^{\psi \beta} m_{1}^{\beta}m_{1}^{\alpha} \right)\]\[\partial_{\gamma}B_{i}^{\alpha} = -\left(m_{2}^{-1}\right)^ {\alpha \beta}\partial_{\gamma}m_{1}^{\beta} + \left(m_{2}^{-1}\right)^ {\alpha \phi}\partial_{\gamma}m_{2}^{\phi \psi}\left(m_{2}^ {-1}\right)^{\psi \beta}m_{1}^{\beta}\]\[m_{0} = \sum_{j}V_{j}W_{ij}\]\[m_{1}^{\alpha} = \sum_{j}V_{j}x_{ij}^{\alpha}W_{ij}\]\[m_{2}^{\alpha \beta} = \sum_{j}V_{j}x_{ij}^{\alpha} x_{ij}^{\beta}W_{ij}\]\[\partial_{\gamma}m_{0} = \sum_{j}V_{j}\partial_{\gamma} W_{ij}\]\[\partial_{\gamma}m_{1}^{\alpha} = \sum_{j}V_{j}\left[ x_{ij}^{\alpha}\partial_{\gamma}W_{ij}+\delta^ {\alpha \gamma}W_{ij} \right]\]\[\partial_{\gamma}m_{2}^{\alpha \beta} = \sum_{j}V_{j}\left[ x_{ij}^{\alpha}x_{ij}^{\beta}\partial_{\gamma}W_{ij} + \left(x_{ij}^{\alpha}\delta^{\beta \gamma} + x_{ij}^{\beta} \delta^{\alpha \gamma} \right)W_{ij} \right]\]- Parameters:
dim (int) – Dimensionality of the problem.
tol (float) – Tolerence value to decide std or corrected kernel
- class pysph.sph.wc.crksph.CRKSPHIntegrator(**kw)[source]
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.
- 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(index=0, update_nnps=True)
self.do_post_stage(stage_dt, stage_count_from_1)
self.update_domain()
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.
- class pysph.sph.wc.crksph.CRKSPHPreStep(dest, sources, dim=2)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.crksph.CRKSPHScheme(fluids, dim, rho0, c0, nu, h0, p0, gx=0.0, gy=0.0, gz=0.0, cl=2, cq=1, gamma=7.0, eta_crit=0.3, eta_fold=0.2, tol=0.5, has_ghosts=False)[source]
- Parameters:
fluids (list) – a list with names of fluid particle arrays
solids (list) – a list with names of solid (or boundary) particle arrays
- 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.
- class pysph.sph.wc.crksph.CRKSPHSymmetric(dest, sources, dim=2, tol=0.5)[source]
Conservative Reproducing Kernel SPH
This is symmetric and will only work for particles of the same array.
Equations from the paper [CRKSPH2017].
\[W_{ij}^{R} = A_{i}\left(1+B_{i}^{\alpha}x_{ij}^{\alpha} \right)W_{ij}\]\[\partial_{\gamma}W_{ij}^{R} = A_{i}\left(1+B_{i}^{\alpha} x_{ij}^{\alpha}\right)\partial_{\gamma}W_{ij} + \partial_{\gamma}A_{i}\left(1+B_{i}^{\alpha}x_{ij}^{\alpha} \right)W_{ij} + A_{i}\left(\partial_{\gamma}B_{i}^{\alpha} x_{ij}^{\alpha} + B_{i}^{\gamma}\right)W_{ij}\]\[\nabla\tilde{W}_{ij} = 0.5 * \left(\nabla W_{ij}^{R}-\nabla W_{ji}^{R} \right)\]where,
\[A_{i} = \left[m_{0} - \left(m_{2}^{-1}\right)^{\alpha \beta} m1_{\beta}m1_{\alpha}\right]^{-1}\]\[B_{i}^{\alpha} = -\left(m_{2}^{-1}\right)^{\alpha \beta} m_{1}^{\beta}\]\[\partial_{\gamma}A_{i} = -A_{i}^{2}\left(\partial_{\gamma} m_{0}-\left[m_{2}^{-1}\right]^{\alpha \beta}\left[ m_{1}^{\beta}\partial_{\gamma}m_{1}^{\beta}m_{1}^{\alpha} + \partial_{\gamma}m_{1}^{\alpha}m_{1}^{\beta}\right] + \left[m_{2}^{-1}\right]^{\alpha \phi}\partial_{\gamma} m_{2}^{\phi \psi}\left[m_{2}^{-1}\right]^{\psi \beta} m_{1}^{\beta}m_{1}^{\alpha} \right)\]\[\partial_{\gamma}B_{i}^{\alpha} = -\left(m_{2}^{-1}\right)^ {\alpha \beta}\partial_{\gamma}m_{1}^{\beta} + \left(m_{2}^{-1}\right)^ {\alpha \phi}\partial_{\gamma}m_{2}^{\phi \psi}\left(m_{2}^ {-1}\right)^{\psi \beta}m_{1}^{\beta}\]\[m_{0} = \sum_{j}V_{j}W_{ij}\]\[m_{1}^{\alpha} = \sum_{j}V_{j}x_{ij}^{\alpha}W_{ij}\]\[m_{2}^{\alpha \beta} = \sum_{j}V_{j}x_{ij}^{\alpha} x_{ij}^{\beta}W_{ij}\]\[\partial_{\gamma}m_{0} = \sum_{j}V_{j}\partial_{\gamma} W_{ij}\]\[\partial_{\gamma}m_{1}^{\alpha} = \sum_{j}V_{j}\left[ x_{ij}^{\alpha}\partial_{\gamma}W_{ij}+\delta^ {\alpha \gamma}W_{ij} \right]\]\[\partial_{\gamma}m_{2}^{\alpha \beta} = \sum_{j}V_{j}\left[ x_{ij}^{\alpha}x_{ij}^{\beta}\partial_{\gamma}W_{ij} + \left(x_{ij}^{\alpha}\delta^{\beta \gamma} + x_{ij}^{\beta} \delta^{\alpha \gamma} \right)W_{ij} \right]\]- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.crksph.CRKSPHUpdateGhostProps(dest, sources=None, dim=2)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.crksph.EnergyEquation(dest, sources, dim, gamma, gx=0.0, gy=0.0, gz=0.0, cl=2, cq=1, eta_crit=0.5, eta_fold=0.2, tol=0.5)[source]
Energy Equation
From [CRKSPH2017], equation (66):
\[\Delta u_{ij} = \frac{f_{ij}}{2}\left(v_j^{\alpha}(t) + v_j^{\alpha}(t + \Delta t) - v_i^{\alpha}(t) - v_i^{\alpha}(t + \Delta t)\right) \frac{Dv_{ij}^{\alpha}}{Dt}\]\[\begin{split}f_{ij} = \begin{cases} 1/2 &|s_i - s_j| = 0,\\ s_{\min} / (s_{\min} + s_{\max}) &\Delta u_{ij}\times(s_i - s_j) > 0\\ s_{\max} / (s_{\min} + s_{\max}) &\Delta u_{ij}\times(s_i - s_j) < 0\\ \end{cases}\end{split}\]\[s_{\min} = \min(|s_i|, |s_j|)\]\[s_{\max} = \max(|s_i|, |s_j|)\]\[s_{i/j} = \frac{p_{i/j}}{\rho_{i/j}^\gamma}\]see MomentumEquation for \(\frac{Dv_{ij}^{\alpha}}{Dt}\)
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.crksph.MomentumEquation(dest, sources, dim, gx=0.0, gy=0.0, gz=0.0, cl=2, cq=1, eta_crit=0.3, eta_fold=0.2, tol=0.5)[source]
Momentum Equation
From [CRKSPH2017], equation (64):
\[\frac{Dv_{i}^{\alpha}}{Dt} = -\frac{1}{2 m_i}\sum_{j} V_i V_j (P_i + P_j + Q_i + Q_j) (\partial_{\alpha}W_{ij}^R - \partial_{\alpha} W_{ji}^R)\]where,
\[V_{i/j} = \text{dest/source particle number density}\]\[P_{i/j} = \text{dest/source particle pressure}\]\[Q_i = \rho_{i} (-C_{l} c_{i} \mu_{i} + C_{q} \mu_{i}^{2})\]\[\mu_i = \min \left(0, \frac{\hat{v}_{ij} \eta_{i}^{\alpha}}{\eta_{i}^{\alpha}\eta_{i}^{\alpha} + \epsilon^{2}}\right)\]\[\hat{v}_{ij}^{\alpha} = v_{i}^{\alpha} - v_{j}^{\alpha} - \frac{\phi_{ij}}{2}\left(\partial_{\beta} v_i^{\alpha} + \partial_{\beta}v_j^{\alpha}\right) x_{ij}^{\beta}\]\[\begin{split}\phi_{ij} = \max \left[0, \min \left[1, \frac{4r_{ij}}{(1 + r_{ij})^2}\right]\right] \times \begin{cases} \exp{\left[-\left((\eta_{ij} - \eta_{crit})/\eta_{fold}\right)^2\right]}, &\eta_{ij} < \eta_{crit} \\ 1, & \eta_{ij} >= \eta_{crit} \end{cases}\end{split}\]\[\eta_{ij} = \min(\eta_i, \eta_j)\]\[\eta_{i/j} = (x_{ij}^{\alpha} x_{ij}^{\alpha})^{1/2} / h_{i/j}\]\[r_{ij} = \frac{\partial_{\beta} v_i^{\alpha} x_{ij}^{\alpha} x_{ij}^{\beta}}{\partial_{\beta} v_j^{\alpha}x_{ij}^{\alpha} x_{ij}^{\beta}}\]\[\partial_{\beta} v_i^{\alpha} = -\sum_j V_j v_{ij}^{\alpha} \partial_{\beta} W_{ij}^R\]- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.crksph.NumberDensity(dest, sources)[source]
Number Density
From [CRKSPH2017], equation (75):
\[V_{i}^{-1} = \sum_{j} W_{i}\]Note that the quantity V is the inverse of particle volume, so when using in the equation use \(\frac{1}{V}\).
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.crksph.SpeedOfSound(dest, sources=None, gamma=7.0)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.crksph.StateEquation(dest, sources, gamma)[source]
State Equation
State equation for ideal gas, from [CRKSPH2017] equation (77):
\[p_i = (\gamma - 1)\rho_{i} u_i\]where, \(u_i\) is the specific thermal energy.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.crksph.SummationDensityCRKSPH(dest, sources)[source]
Summation Density CRKSPH
From [CRKSPH2017], equation (76):
\[\rho_{i} = \frac{\sum_j m_{ij} V_j W_{ij}^R} {\sum_{j} V_{j}^{2} W_{ij}^R}\]where,
\[\begin{split}mij = \begin{cases} m_j, &i \text{ and } j \text{ are same material} \\ m_i, &i \text{ and } j \text{ are different material} \end{cases}\end{split}\]Note that in this equation we are just using \(m_{ij}\) to be \(m_i\) as the mass remains constant through out the simulation.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.crksph.VelocityGradient(dest, sources, dim)[source]
Velocity Gradient
From [CRKSPH2017], equation (74)
\[\partial_{\beta} v_i^{\alpha} = -\sum_j V_j v_{ij}^{\alpha} \partial_{\beta} W_{ij}^R\]- Parameters:
dim (int) – Dimensionality of the Problem.
Predictive-Corrective Incompressible SPH (PCISPH)
References
B. Solenthaler, R. Pajarola “Predictive-Corrective Incompressible SPH”, ACM Trans. Graph 28 (2009), pp. 1–6.
- class pysph.sph.wc.pcisph.ComputePressure(dest, sources, rho0)[source]
Compute Pressure
Compute pressure iteratively maintaining density within a given tolerance.
\[p_i += \delta \rho^{*}_{{err}_i}\]where,
\[\rho_{err_i} = \rho_i^{*} - \rho_0\]\[\delta = \frac{-1}{\beta (-\sum_j \nabla W_{ij} \cdot \sum_j \nabla W_{ij} - \sum_j \nabla W_{ij} \nabla W_{ij})}\]- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.pcisph.MomentumEquationPressureGradient(dest, sources, rho0, tolerance, debug)[source]
Momentum Equation pressure gradient
Standard WCSPH pressure gradient,
\[\frac{d\mathbf{v}}{dt} = - \sum_j m_j \left(\frac{p_i}{\rho_i^2} + \frac{p_i}{\rho_i^2}\right) \nabla W(x_{ij}, h)\]- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.pcisph.MomentumEquationViscosity(dest, sources, nu=0.0, gx=0.0, gy=0.0, gz=0.0)[source]
Momentum Equation Viscosity
See “pysph.sph.wc.viscosity.LaminarViscocity”
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.wc.pcisph.PCISPHIntegrator(**kw)[source]
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.
- initial_acceleration(t, dt)[source]
Compute the initial accelerations if needed before the iterations start.
The default implementation only does this for the first acceleration evaluator. So if you have multiple evaluators, you must override this method in a subclass.
- 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(index=0, update_nnps=True)
self.do_post_stage(stage_dt, stage_count_from_1)
self.update_domain()
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.
- class pysph.sph.wc.pcisph.PCISPHScheme(fluids, dim, rho0, nu, gx=0.0, gy=0.0, gz=0.0, tolerance=0.1, debug=False, show_itercount=False)[source]
- 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.
- 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.
- class pysph.sph.wc.pcisph.PCISPHStep(show_itercount=False)[source]
- class pysph.sph.wc.pcisph.Predict(dest, sources)[source]
Predict velocity and position
\[\mathbf{v}^{*}(t+1) = \mathbf{v}(t) + dt \left(\frac{d \mathbf{v}_{visc, g}(t)}{dt} + \frac{d \mathbf{v}_{p} (t)}{dt} \right)\]\[\mathbf{x}^{*}(t+1) = \mathbf{x}(t) + dt * \mathbf{v}(t+1)\]- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
SPH Boundary Equations
- class pysph.sph.boundary_equations.MonaghanBoundaryForce(dest, sources, deltap)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.boundary_equations.MonaghanKajtarBoundaryForce(dest, sources, K=None, beta=None, h=None)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
Basic Equations for Solid Mechanics
References
J. P. Gray et al., “SPH elastic dynamics”, Computer Methods in Applied Mechanics and Engineering, 190 (2001), pp 6641 - 6662.
- class pysph.sph.solid_mech.basic.ElasticSolidsScheme(elastic_solids, solids, dim, artificial_stress_eps=0.3, xsph_eps=0.5, alpha=1.0, beta=1.0)[source]
- 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.
- 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.
- class pysph.sph.solid_mech.basic.EnergyEquationWithStress(dest, sources, alpha=1.0, beta=1.0, eta=0.01)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.solid_mech.basic.HookesDeviatoricStressRate(dest, sources)[source]
Rate of change of stress
\[\frac{dS^{ij}}{dt} = 2\mu\left(\epsilon^{ij} - \frac{1}{3}\delta^{ij} \epsilon^{ij}\right) + S^{ik}\Omega^{jk} + \Omega^{ik}S^{kj}\]where
\[ \begin{align}\begin{aligned}\begin{split}\epsilon^{ij} = \frac{1}{2}\left(\frac{\partial v^i}{\partial x^j} + \frac{\partial v^j}{\partial x^i}\right)\\\end{split}\\\Omega^{ij} = \frac{1}{2}\left(\frac{\partial v^i}{\partial x^j} - \frac{\partial v^j}{\partial x^i} \right)\end{aligned}\end{align} \]- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.solid_mech.basic.IsothermalEOS(dest, sources)[source]
Compute the pressure using the Isothermal equation of state:
\(p = p_0 + c_0^2(\rho_0 - \rho)\)
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.solid_mech.basic.MomentumEquationWithStress(dest, sources)[source]
Momentum Equation with Artificial Stress
\[\frac{D\vec{v_a}^i}{Dt} = \sum_b m_b\left(\frac{\sigma_a^{ij}}{\rho_a^2} +\frac{\sigma_b^{ij}}{\rho_b^2} + R_{ab}^{ij}f^n \right)\nabla_a W_{ab}\]where
\[ \begin{align}\begin{aligned}\begin{split}f_{ab} = \frac{W(r_{ab})}{W(\Delta p)}\\\end{split}\\R_{ab}^{ij} = R_{a}^{ij} + R_{b}^{ij}\end{aligned}\end{align} \]- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.solid_mech.basic.MonaghanArtificialStress(dest, sources, eps=0.3)[source]
Artificial stress to remove tensile instability
The dispersion relations in [Gray2001] are used to determine the different components of \(R\).
Angle of rotation for particle \(a\)
\[\tan{2 \theta_a} = \frac{2\sigma_a^{xy}}{\sigma_a^{xx} - \sigma_a^{yy}}\]In rotated frame, the new components of the stress tensor are
\[ \begin{align}\begin{aligned}\begin{split}\bar{\sigma}_a^{xx} = \cos^2{\theta_a} \sigma_a^{xx} + 2\sin{\theta_a} \cos{\theta_a}\sigma_a^{xy} + \sin^2{\theta_a}\sigma_a^{yy}\\\end{split}\\\bar{\sigma}_a^{yy} = \sin^2{\theta_a} \sigma_a^{xx} + 2\sin{\theta_a} \cos{\theta_a}\sigma_a^{xy} + \cos^2{\theta_a}\sigma_a^{yy}\end{aligned}\end{align} \]Components of \(R\) in rotated frame:
\[ \begin{align}\begin{aligned}\begin{split}\bar{R}_{a}^{xx}=\begin{cases}-\epsilon\frac{\bar{\sigma}_{a}^{xx}} {\rho^{2}} & \bar{\sigma}_{a}^{xx}>0\\0 & \bar{\sigma}_{a}^{xx}\leq0 \end{cases}\\\end{split}\\\begin{split}\bar{R}_{a}^{yy}=\begin{cases}-\epsilon\frac{\bar{\sigma}_{a}^{yy}} {\rho^{2}} & \bar{\sigma}_{a}^{yy}>0\\0 & \bar{\sigma}_{a}^{yy}\leq0 \end{cases}\end{split}\end{aligned}\end{align} \]Components of \(R\) in original frame:
\[ \begin{align}\begin{aligned}\begin{split}R_a^{xx} = \cos^2{\theta_a} \bar{R}_a^{xx} + \sin^2{\theta_a} \bar{R}_a^{yy}\\\end{split}\\\begin{split}R_a^{yy} = \sin^2{\theta_a} \bar{R}_a^{xx} + \cos^2{\theta_a} \bar{R}_a^{yy}\\\end{split}\\R_a^{xy} = \sin{\theta_a} \cos{\theta_a}\left(\bar{R}_a^{xx} - \bar{R}_a^{yy}\right)\end{aligned}\end{align} \]- Parameters:
eps (float) – constant
- pysph.sph.solid_mech.basic.get_bulk_mod(G, nu)[source]
Get the bulk modulus from shear modulus and Poisson ratio
- pysph.sph.solid_mech.basic.get_particle_array_elastic_dynamics(constants=None, **props)[source]
Return a particle array for the Standard SPH formulation of solids.
- Parameters:
constants (dict) – Dictionary of constants
props (dict) – Additional keywords passed are set as the property arrays.
See also
get_particle_array
Equations for the High Velocity Impact Problems
- class pysph.sph.solid_mech.hvi.MieGruneisenEOS(dest, sources, gamma, r0, c0, S)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.solid_mech.hvi.StiffenedGasEOS(dest, sources, gamma, r0, c0)[source]
Stiffened-gas EOS from “A Free Lagrange Augmented Godunov Method for the Simulation of Elastic-Plastic Solids”, B. P. Howell and G. J. Ball, JCP (2002). http://dx.doi.org/10.1006/jcph.2001.6931
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.solid_mech.hvi.VonMisesPlasticity2D(dest, sources, flow_stress)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
Gas Dynamics
Basic equations for Gas-dynamics
- class pysph.sph.gas_dynamics.basic.ADKEAccelerations(dest, sources, alpha, beta, g1, g2, k, eps)[source]
ADKE as discussed in the reference [KP14].
References
[KP14] (1,2,3)A comparison of SPH schemes for the compressible Euler equations, 2014, Journal of Computational Physics, 256, pp 308 – 333 (http://dx.doi.org/10.1016/j.jcp.2013.08.060)
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.basic.ADKEUpdateGhostProps(dest, sources=None, dim=2)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.basic.IdealGasEOS(dest, sources, gamma)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.basic.MPMAccelerations(dest, sources, beta=2.0, update_alpha1=False, update_alpha2=False, alpha1_min=0.1, alpha2_min=0.1, sigma=0.1)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.basic.MPMUpdateGhostProps(dest, sources=None, dim=2)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.basic.Monaghan92Accelerations(dest, sources, alpha=1.0, beta=2.0)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.basic.ScaleSmoothingLength(dest, sources, factor=2.0)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.basic.SummationDensity(dest, sources, dim, density_iterations=False, iterate_only_once=False, k=1.2, htol=1e-06)[source]
Summation density with iterative solution of the smoothing lengths.
Parameters:
- density_iterationsbint
Flag to indicate density iterations are required.
- iterate_only_oncebint
Flag to indicate if only one iteration is required
- kdouble
Kernel scaling factor
- htoldouble
Iteration tolerance
- class pysph.sph.gas_dynamics.basic.SummationDensityADKE(dest, sources, k=1.0, eps=0.0)[source]
References
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.basic.UpdateSmoothingLengthFromVolume(dest, sources, dim, k=1.2)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
Boundary equations for Gas-dynamics
- class pysph.sph.gas_dynamics.boundary_equations.WallBoundary(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- initialize(d_idx, d_p, d_rho, d_e, d_m, d_cs, d_div, d_h, d_htmp, d_h0, d_u, d_v, d_w, d_wij)[source]
Surface tension
Implementation of the equations used for surface tension modelling, for example in KHI simulations. The references are [SY11], [JM00], [A10], [XA06].
References
M. Shadloo, M. Yildiz, “Numerical modelling of Kelvin-Helmholtz instability using smoothed particle hydrodynamics”, IJNME, 2011, 87, pp 988–1006
Joseph P. Morris “Simulating surface tension with smoothed particle hydrodynamics”, JCP, 2000, 33, pp 333–353
Adami et al. “A new surface-tension formulation for multi-phase SPH using a reproducing divergence approximation”, JCP 2010, 229, pp 5011–5021
X.Y.Hu, N.A. Adams. “A multi-phase SPH method for macroscopic and mesoscopic flows”, JCP 2006, 213, pp 844-861 [XA06]
- class pysph.sph.surface_tension.AdamiColorGradient(dest, sources)[source]
Gradient of color Eq. (14) in [A10]
\[\nabla c_a = \frac{1}{V_a}\sum_b \left[V_a^2 + V_b^2 \right]\tilde{c}_{ab}\nabla_a W_{ab}\,,\]where, the average \(\tilde{c}_{ab}\) is defined as
\[\tilde{c}_{ab} = \frac{\rho_b}{\rho_a + \rho_b}c_a + \frac{\rho_a}{\rho_a + \rho_b}c_b\]- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.AdamiReproducingDivergence(dest, sources, dim)[source]
Reproducing divergence approximation Eq. (20) in [A10] to compute the curvature
\[\nabla \cdot \boldsymbol{\phi}_a = d\frac{\sum_b \boldsymbol{\phi}_{ab}\cdot \nabla_a W_{ab}V_b}{\sum_b\boldsymbol{x}_{ab}\cdot \nabla_a W_{ab} V_b}\]- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.CSFSurfaceTensionForce(dest, sources, sigma=0.1)[source]
Acceleration due to surface tension force Eq. (25) in [JM00]:
Note that as per Eq. (17) in [JM00], the un-normalized normal is basically the gradient of the color function. The acceleration term therefore depends on the gradient of the color field.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.CSFSurfaceTensionForceAdami(dest, sources, sigma)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.ColorGradientAdami(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.ColorGradientUsingNumberDensity(dest, sources, epsilon=1e-06)[source]
Gradient of the color function using Eq. (13) of [SY11]:
\[\nabla C_a = \sum_b \frac{2 C_b - C_a}{\psi_a + \psi_a} \nabla_{a} W_{ab}\]Using the gradient of the color function, the normal and discretized dirac delta is calculated in the post loop.
Singularities are avoided as per the recommendation by [JM00] (see eqs 20 & 21) using the parameter \(\epsilon\)
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.ConstructStressMatrix(dest, sources, sigma, d=2)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.InterfaceCurvatureFromDensity(dest, sources, with_morris_correction=True)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.InterfaceCurvatureFromNumberDensity(dest, sources, with_morris_correction=True)[source]
Interface curvature using number density. Eq. (15) in [SY11]:
\[\kappa_a = \sum_b \frac{2.0}{\psi_a + \psi_b} \left(\boldsymbol{n_a} - \boldsymbol{n_b}\right) \cdot \nabla_a W_{ab}\]- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.MomentumEquationPressureGradientAdami(dest, sources, gx=0.0, gy=0.0, gz=0.0)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.MomentumEquationPressureGradientHuAdams(dest, sources, gx=0.0, gy=0.0, gz=0.0)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.MomentumEquationPressureGradientMorris(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.MomentumEquationViscosityAdami(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.MomentumEquationViscosityMorris(dest, sources, eta=0.01)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.MorrisColorGradient(dest, sources, epsilon=1e-06)[source]
Gradient of the color function using Eq. (17) of [JM00]:
\[\nabla c_a = \sum_b \frac{m_b}{\rho_b}(c_b - c_a) \nabla_{a} W_{ab}\,,\]where a smoothed representation of the color is used in the equation. Using the gradient of the color function, the normal and discretized dirac delta is calculated in the post loop.
Singularities are avoided as per the recommendation by [JM00] (see eqs 20 & 21) using the parameter \(\epsilon\)
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.SY11ColorGradient(dest, sources, epsilon=1e-06)[source]
Gradient of the color function using Eq. (13) of [SY11]:
\[\nabla C_a = \sum_b \frac{2 C_b - C_a}{\psi_a + \psi_a} \nabla_{a} W_{ab}\]Using the gradient of the color function, the normal and discretized dirac delta is calculated in the post loop.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.SY11DiracDelta(dest, sources, epsilon=1e-06)[source]
Discretized dirac-delta for the SY11 formulation Eq. (14) in [SY11]
This is essentially the same as computing the color gradient, the only difference being that this might be called with a reduced smoothing length.
Note that the normals should be computed using the SY11ColorGradient equation. This function will effectively overwrite the color gradient.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.ShadlooViscosity(dest, sources, alpha)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.ShadlooYildizSurfaceTensionForce(dest, sources, sigma=0.1)[source]
Acceleration due to surface tension force Eq. (7,9) in [SY11]:
where, \(\delta^s\) is the discretized dirac delta function, \(\boldsymbol{n}\) is the interface normal, \(\kappa\) is the discretized interface curvature and \(\sigma\) is the surface tension force constant.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.SmoothedColor(dest, sources)[source]
Smoothed color function. Eq. (17) in [JM00]
\[c_a = \sum_b \frac{m_b}{\rho_b} c_b^i \nabla_a W_{ab}\,,\]where, \(c_b^i\) is the color index associated with a particle.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.SolidWallPressureBCnoDensity(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.SummationDensitySourceMass(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.surface_tension.SurfaceForceAdami(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- pysph.sph.surface_tension.get_surface_tension_equations(fluids, solids, scheme, rho0, p0, c0, b, factor1, factor2, nu, sigma, d, epsilon, gamma, real=False)[source]
This function returns the required equations for the multiphase formulation taking inputs of the fluid particles array, solid particles array, the scheme to be used and other physical parameters
- Parameters:
fluids (list) – List of names of fluid particle arrays
solids (list) – List of names of solid particle arrays
scheme (string) –
The scheme with which the equations are to be setup. Supported Schemes:
TVF scheme with Morris’ surface tension. String to be used: “tvf”
Adami’s surface tension implementation which doesn’t involve calculation of curvature. String to be used: “adami_stress”
Adami’s surface tension implementation which involves calculation of curvature. String to be used: “adami”
Shadloo Yildiz surface tension formulation. String to be used: “shadloo”
Morris’ surface tension formulation. This is the default scheme which will be used if none of the above strings are input as scheme.
rho0 (float) – The reference density of the medium (Currently multiple reference densities for different particles is not supported)
p0 (float) – The background pressure of the medium(Currently multiple background pressures for different particles is not supported)
c0 (float) – The speed of sound of the medium(Currently multiple speeds of sounds for different particles is not supported)
b (float) – The b parameter of the generalized Tait Equation of State. Refer to the Tait Equation’s documentation for reference
factor1 (float) – The factor for scaling of smoothing length for calculation of interface curvature number for shadloo’s scheme
factor2 (float) – The factor for scaling back of smoothing length for calculation of forces after calculating the interface curvature number in shadloo’s scheme
nu (float) – The kinematic viscosity of the medium
sigma (float) – The surface tension of the system
d (int) – The number of dimensions of the problem in the cartesian space
epsilon (float) – Put this option false if the equations are supposed to be evaluated for the ghost particles, else keep it True
Implicit Incompressible SPH
The basic equations for the IISPH formulation of
M. Ihmsen, J. Cornelis, B. Solenthaler, C. Horvath, M. Teschner, “Implicit Incompressible SPH,” IEEE Transactions on Visualization and Computer Graphics, vol. 20, no. 3, pp. 426-435, March 2014. http://dx.doi.org/10.1109/TVCG.2013.105
- class pysph.sph.iisph.AdvectionAcceleration(dest, sources, gx=0.0, gy=0.0, gz=0.0)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.iisph.ComputeAII(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.iisph.ComputeAIIBoundary(dest, sources, rho0)[source]
This is important and not really discussed in the original IISPH paper.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.iisph.ComputeDII(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.iisph.ComputeDIIBoundary(dest, sources, rho0)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.iisph.ComputeDIJPJ(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.iisph.ComputeRhoAdvection(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.iisph.ComputeRhoBoundary(dest, sources, rho0)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.iisph.IISPHScheme(fluids, solids, dim, rho0, nu=0.0, gx=0.0, gy=0.0, gz=0.0, omega=0.5, tolerance=0.01, debug=False, has_ghosts=False)[source]
The IISPH scheme
- Parameters:
fluids (list(str)) – List of names of fluid particle arrays.
solids (list(str)) – List of names of solid particle arrays.
dim (int) – Dimensionality of the problem.
rho0 (float) – Density of fluid.
nu (float) – Kinematic viscosity.
gx (float) – Componenents of body acceleration (gravity, external forcing etc.)
gy (float) – Componenents of body acceleration (gravity, external forcing etc.)
gz (float) – Componenents of body acceleration (gravity, external forcing etc.)
omega (float) – Relaxation parameter for relaxed-Jacobi iterations.
tolerance (float) – Tolerance for the convergence of pressure iterations as a fraction.
debug (bool) – Produce some debugging output on iterations.
has_ghosts (bool) – The problem has ghost particles so add equations for those.
- configure_solver(kernel=None, integrator_cls=None, extra_steppers=None, **kw)[source]
Configure the solver to be generated.
This is to be called before get_solver is called.
- Parameters:
dim (int) – Number of dimensions.
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.
- class pysph.sph.iisph.IISPHStep[source]
A straightforward and simple integrator to be used for IISPH.
- class pysph.sph.iisph.NormalizedSummationDensity(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.iisph.NumberDensity(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.iisph.PressureForce(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.iisph.PressureForceBoundary(dest, sources, rho0)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.iisph.PressureSolve(dest, sources, rho0, omega=0.5, tolerance=0.01, debug=False)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.iisph.PressureSolveBoundary(dest, sources, rho0)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.iisph.SummationDensity(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.iisph.SummationDensityBoundary(dest, sources, rho0)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.iisph.UpdateGhostPressure(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.iisph.UpdateGhostProps(dest, sources=None)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.iisph.ViscosityAcceleration(dest, sources, nu)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
Hopkins’ ‘Traditional’ SPH (TSPH)
References
Hopkins, Philip F. “A General Class of Lagrangian Smoothed Particle Hydrodynamics Methods and Implications for Fluid Mixing Problems.” Monthly Notices of the Royal Astronomical Society 428, no. 4 (February 1, 2013): 2840–56. https://doi.org/10.1093/mnras/sts210.
- class pysph.sph.gas_dynamics.tsph.TSPHScheme(fluids, solids, dim, gamma, hfact, beta=2.0, fkern=1.0, max_density_iterations=250, alphamax=1.0, density_iteration_tolerance=0.001, has_ghosts=False)[source]
Density-energy formulation [Hopkins2013] including Balsara’s artificial viscocity switch with modifications, as presented in Appendix F1 of [Hopkins2015] .
Notes
- Is this exactly in accordance with what is proposed in [Hopkins2015] ?
Not quite.
- What is different then?
Adapting smoothing length using MPM [KP14] procedure from
SummationDensity. In this, calculation of grad-h terms are changed to that specified for this scheme.Using the PEC integrator step. No individual adaptive time-stepping.
Using
Gaussian Kernelby default instead of Cubic Spline with radius scale 1.
Tip: Reduce the number of points if particle penetration is encountered. This has to be done while running
gas_dynamics.wc_blastwaveandgas_dynamics.robert.- 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 gas dynamics schemes.
beta (float, optional) – \(\beta\) for artificial viscosity, by default 2.0
fkern (float, optional) – \(f_{kern}\), Factor to scale smoothing length for equivalence with classic kernel when using kernel with altered radius_scale is being used, by default 1.
max_density_iterations (int, optional) – Maximum number of iterations to run for one density step, by default 250.
density_iteration_tolerance (float, optional) – Maximum difference allowed in two successive density iterations, by default 1e-3
has_ghosts (bool, optional) – if ghost particles (either mirror or periodic) is used, by default False
alphamax (float, optional) – \(\alpha_{av}\) for artificial viscosity switch, by default 1.0
- 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.
- class pysph.sph.gas_dynamics.tsph.SummationDensity(dest, sources, dim, density_iterations=False, iterate_only_once=False, hfact=1.2, htol=1e-06)[source]
SummationDensitymodified to use number density for calculation of grad-h terms.Ref. Appendix F1 [Hopkins2015]
- initialize(d_idx, d_rho, d_arho, d_drhosumdh, d_n, d_dndh, d_prevn, d_prevdndh, d_prevdrhosumdh, d_an)[source]
- class pysph.sph.gas_dynamics.tsph.IdealGasEOS(dest, sources, gamma)[source]
IdealGasEOSmodified to avoid repeated calculations usingloop(). Doing the same usingpost_loop().
- class pysph.sph.gas_dynamics.tsph.VelocityGradDivC1(dest, sources, dim)[source]
First Order consistent velocity gradient and divergence
- class pysph.sph.gas_dynamics.tsph.BalsaraSwitch(dest, sources, alphaav, fkern)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.tsph.MomentumAndEnergy(dest, sources, dim, fkern, beta=2.0)[source]
TSPH Momentum and Energy Equations with artificial viscosity.
Possible typo in that has been taken care of:
Instead of Equation F3 [Hopkins2015] for evolution of total energy sans artificial viscosity and artificial conductivity,
\[\frac{\mathrm{d} E_{i}}{\mathrm{~d} t}=\boldsymbol{v}_{i} \cdot \frac{\mathrm{d} \boldsymbol{P}_{i}}{\mathrm{~d} t}- \sum_{j} m_{i} m_{j}\left(\boldsymbol{v}_{i}- \boldsymbol{v}_{j}\right) \cdot\left[\frac{P_{i}} {\bar{\rho}_{i}^{2}} f_{i, j} \nabla_{i} W_{i j}\left(h_{i}\right)\right],\]it should have been,
\[\frac{\mathrm{d} E_{i}}{\mathrm{~d} t}=\boldsymbol{v}_{i} \cdot \frac{\mathrm{d} \boldsymbol{P}_{i}}{\mathrm{~d} t}+ \sum_{j} m_{i} m_{j}\left(\boldsymbol{v}_{i}- \boldsymbol{v}_{j}\right) \cdot\left[\frac{P_{i}} {\bar{\rho}_{i}^{2}} f_{i, j} \nabla_{i} W_{i j}\left(h_{i}\right)\right].\]Specific thermal energy, \(u\), would therefore be evolved using,
\[\frac{\mathrm{d} u_{i}}{\mathrm{~d} t}= \sum_{j} m_{j}\left(\boldsymbol{v}_{i}- \boldsymbol{v}_{j}\right) \cdot\left[\frac{P_{i}} {\bar{\rho}_{i}^{2}} f_{i, j} \nabla_{i} W_{i j}\left(h_{i}\right)\right]\]
- class pysph.sph.gas_dynamics.tsph.WallBoundary(dest, sources)[source]
WallBoundarymodified for TSPH.Most importantly, mass of the boundary particle should never be zero since it appears in denominator of fij. This has been addressed.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- initialize(d_idx, d_p, d_rho, d_e, d_m, d_cs, d_h, d_htmp, d_h0, d_u, d_v, d_w, d_wij, d_n, d_dndh, d_drhosumdh, d_divv, d_m0)[source]
- class pysph.sph.gas_dynamics.tsph.UpdateGhostProps(dest, sources=None, dim=2)[source]
MPMUpdateGhostPropsmodified for TSPH
Hopkins’ ‘Modern’ SPH (PSPH)
References
Cullen, Lee, and Walter Dehnen. “Inviscid Smoothed Particle Hydrodynamics: Inviscid Smoothed Particle Hydrodynamics.” Monthly Notices of the Royal Astronomical Society 408, no. 2 (October 21, 2010): 669–83. https://doi.org/10.1111/j.1365-2966.2010.17158.x.
Read, J. I., and T. Hayfield. “SPHS: Smoothed Particle Hydrodynamics with a Higher Order Dissipation Switch: SPH with a Higher Order Dissipation Switch.” Monthly Notices of the Royal Astronomical Society 422, no. 4 (June 1, 2012): 3037–55. https://doi.org/10.1111/j.1365-2966.2012.20819.x.
- class pysph.sph.gas_dynamics.psph.PSPHScheme(fluids, solids, dim, gamma, hfact, betab=2.0, fkern=1.0, max_density_iterations=250, alphac=0.25, density_iteration_tolerance=0.001, has_ghosts=False, alphamin=0.02, alphamax=2.0, betac=0.7, betad=0.05, betaxi=1.0)[source]
Pressure-energy formulation [Hopkins2013] including Cullen-Dehnen artificial viscocity switch [CullenDehnen2010] with modifications, as presented in Appendix F2 of [Hopkins2015] .
Notes
- Is this exactly in accordance with what is proposed in [Hopkins2015] ?
Not quite.
- What is different then?
Adapting smoothing length using MPM [KP14] procedure from
SummationDensity. In this, calculation of grad-h terms are changed to that specified for this scheme.Using the PEC integrator step. No individual adaptive time-stepping.
Using
Gaussian Kernelby default instead of Cubic Spline with radius scale 1.
Tip: Reduce the number of points if particle penetration is encountered. This has to be done while running
gas_dynamics.wc_blastwaveandgas_dynamics.robert.- 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 gas dynamics schemes.
betab (float, optional) – \(\beta_b\) for artificial viscosity, by default 2.0
fkern (float, optional) – \(f_{kern}\), Factor to scale smoothing length for equivalence with classic kernel when using kernel with altered radius_scale is being used, by default 1.
max_density_iterations (int, optional) – Maximum number of iterations to run for one density step, by default 250.
alphac (float, optional) – \(\alpha_c\) for artificial conductivity, by default 0.25
density_iteration_tolerance (float, optional) – Maximum difference allowed in two successive density iterations, by default 1e-3
has_ghosts (bool, optional) – if ghost particles (either mirror or periodic) is used, by default False
alphamin (float, optional) – \(\alpha_{min}\) for artificial viscosity switch, by default 0.02
alphamax (float, optional) – \(\alpha_{max}\) for artificial viscosity switch, by default 2.0
betac (float, optional) – \(\beta_c\) for artificial viscosity switch, by default 0.7
betad (float, optional) – \(\beta_d\) for artificial viscosity switch, by default 0.05
betaxi (float, optional) – \(\beta_{\xi}\) for artificial viscosity switch, by default 1.0
- 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.
- class pysph.sph.gas_dynamics.psph.PSPHSummationDensityAndPressure(dest, sources, dim, gamma, density_iterations=False, iterate_only_once=False, hfact=1.2, htol=1e-06)[source]
SummationDensitymodified to use number density for calculation of grad-h terms and to calculate pressure and speed of sound as well.Ref. Appendix F2 [Hopkins2015]
- Parameters:
density_iterations (bint, optional) – Flag to indicate density iterations are required, by default False
iterate_only_once (bint, optional) –
- Flag to indicate if only one iteration is required,
by default False
hfact (float, optional) – \(h_{fact}\), by default 1.2
htol (double, optional) – Iteration tolerance, by default 1e-6
- initialize(d_idx, d_rho, d_arho, d_n, d_dndh, d_prevn, d_prevdndh, d_p, d_dpsumdh, d_dprevpsumdh, d_an)[source]
- class pysph.sph.gas_dynamics.psph.GradientKinsfolkC1(dest, sources, dim)[source]
First order consistent,
Velocity gradient, grad(v)
Acceleration gradient, grad(a)
Velocity divergence, div(v)
Velocity divergence rate, d (div(v)) / dt
Traceless symmetric strain rate, S
trace(dot(S,transpose(S)))
Ref. Appendix B [CullenDehnen2010]
- class pysph.sph.gas_dynamics.psph.LimiterAndAlphas(dest, sources, alphamin=0.02, alphamax=2.0, betac=0.7, betad=0.05, betaxi=1.0, fkern=1.0)[source]
Cullen Dehnen’s limiter for artificial viscosity modified by Hopkins.
Ref. Appendix F2 [Hopkins2015]
- class pysph.sph.gas_dynamics.psph.MomentumAndEnergy(dest, sources, dim, fkern, gamma, betab=2.0, alphac=0.25)[source]
PSPH Momentum and Energy Equations with artificial viscosity and artificial conductivity.
Possible typos in that have been taken care of,
Instead of Equation F15 [Hopkins2015] for evolution of total energy sans artificial viscosity and artificial conductivity,
\[\frac{\mathrm{d} E_{i}}{\mathrm{~d} t}= \boldsymbol{v}_{i} \cdot \frac{\mathrm{d} \boldsymbol{P}_{i}}{\mathrm{~d} t}- \sum_{j=1}^{N}(\gamma-1)^{2} m_{i} m_{j} u_{i} u_{j} \frac{f_{i j}}{\bar{P}_{i}}\left(\boldsymbol{v}_{i}- \boldsymbol{v}_{j}\right) \cdot \nabla_{i} W_{i j} \left(h_{i}\right),\]it should have been,
\[\frac{\mathrm{d} E_{i}}{\mathrm{~d} t}= \boldsymbol{v}_{i} \cdot \frac{\mathrm{d} \boldsymbol{P}_{i}}{\mathrm{~d} t}+ \sum_{j=1}^{N}(\gamma-1)^{2} m_{i} m_{j} u_{i} u_{j} \frac{f_{i j}}{\bar{P}_{i}}\left(\boldsymbol{v}_{i}- \boldsymbol{v}_{j}\right) \cdot \nabla_{i} W_{i j} \left(h_{i}\right).\]Specific thermal energy, \(u\), would therefore be evolved using,
\[\frac{\mathrm{d} u_{i}}{\mathrm{~d} t}= \sum_{j=1}^{N}(\gamma-1)^{2} m_{j} u_{i} u_{j} \frac{f_{i j}}{\bar{P}_{i}}\left(\boldsymbol{v}_{i}- \boldsymbol{v}_{j}\right) \cdot \nabla_{i} W_{i j} \left(h_{i}\right).\]Equation F18 [Hopkins2015] for contribution of artificial viscosity to the evolution of total energy is,
\[\frac{\mathrm{d} E_{i}}{\mathrm{~d} t}= \alpha_{\mathrm{C}} \sum_{j} m_{i} m_{j} \alpha_{i j} \tilde{v}_{s}\left(u_{i}- u_{j}\right) \times \frac{\left|P_{i}-P_{j}\right|}{P_{i}+ P_{j}} \frac{\nabla_{i} W_{i j}\left(h_{i}\right)+ \nabla_{i} W_{i j}\left(h_{j}\right)}{\bar{\rho}_{i}+ \bar{\rho}_{j}} .\]Carefully comparing with [ReadHayfield2012] and [KP14], specific thermal energy, \(u\), should be evolved using,
\[\begin{split}\frac{\mathrm{d} u_{i}}{\mathrm{~d} t}= \alpha_{\mathrm{C}} \sum_{j} & m_{j} \alpha_{i j} \tilde{v}_{s}\left(u_{i}- u_{j}\right) \frac{\left|P_{i}-P_{j}\right|}{P_{i}+ P_{j}} \\ & \frac{\nabla_{i} W_{i j}\left(h_{i}\right)+ \nabla_{i} W_{i j}\left(h_{j}\right)}{\bar{\rho}_{i}+ \bar{\rho}_{j}} \cdot \frac{\left(\boldsymbol{x}_{i}- \boldsymbol{x}_{j}\right)}{\left|\boldsymbol{x}_{i}- \boldsymbol{x}_{j}\right|}\end{split}\]
- class pysph.sph.gas_dynamics.psph.WallBoundary(dest, sources)[source]
WallBoundarymodified for PSPH- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- initialize(d_idx, d_p, d_rho, d_e, d_m, d_cs, d_h, d_htmp, d_h0, d_u, d_v, d_w, d_wij, d_n, d_dndh, d_dpsumdh, d_m0)[source]
- class pysph.sph.gas_dynamics.psph.UpdateGhostProps(dest, sources=None, dim=2)[source]
MPMUpdateGhostPropsmodified for PSPH
MAGMA2
References
Rosswog, Stephan. “Astrophysical smooth particle hydrodynamics.” New Astronomy Reviews 53, no. 4-6 (2009): 78-104. https://doi.org/10.1016/j.newar.2009.08.007
Rosswog, Stephan. “Boosting the accuracy of SPH techniques: Newtonian and special-relativistic tests.” Monthly Notices of the Royal Astronomical Society 448, no. 4 (2015): 3628-3664. https://doi.org/10.1093/mnras/stv225.
Rosswog, Stephan. “A simple, entropy-based dissipation trigger for SPH.” The Astrophysical Journal 898, no. 1 (2020): 60. https://doi.org/10.3847/1538-4357/ab9a2e.
Rosswog, Stephan. “The Lagrangian hydrodynamics code MAGMA2.” Monthly Notices of the Royal Astronomical Society 498, no. 3 (2020): 4230-4255. https://doi.org/10.1093/mnras/staa2591.
- class pysph.sph.gas_dynamics.magma2.IncreaseSmoothingLength(dest, sources)[source]
Increase smoothing length by 10%.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.magma2.UpdateSmoothingLength(dest, sources, ndes)[source]
Sorts neighbours based on distance and uses the distance of nearest \((n_{des} + 1)^{th}\) particle to set the smoothing length. Here, \(n_{des}\) is the desired number of neighbours to be in the kernel support of each particle.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.magma2.SummationDensityMPMStyle(dest, sources, dim, density_iterations=False, iterate_only_once=False, hfact=1.2, htol=1e-06)[source]
SummationDensitymodified to use number density and without grad-h terms.- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.magma2.IdealGasEOS(dest, sources, gamma)[source]
IdealGasEOSmodified to avoid repeated calculations usingloop(). Doing the same usingpost_loop().- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.magma2.AuxiliaryGradient(dest, sources, dim)[source]
Auxiliary first gradient calculated using analytical gradient of kernel and without using density.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.magma2.CorrectionMatrix(dest, sources, dim)[source]
Correction matrix, C, that accounts for the local particle distribution and used in calculation of gradients without using analytical derivatives of kernel.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.magma2.FirstGradient(dest, sources, dim)[source]
First gradient and divergence calculated using matrix inversion formulation without analytical derivative of the kernel.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.magma2.SecondGradient(dest, sources, dim)[source]
Second gradient calculated from auxiliary gradient using matrix inversion formulation without analytical derivative of the kernel.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.magma2.EntropyBasedDissipationTrigger(dest, sources, alphamax, alphamin, fkern, l0, l1, gamma)[source]
Simple, entropy-based dissipation trigger from [Rosswog2020a]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.magma2.WallBoundary(dest, sources, dim)[source]
WallBoundarymodified for MAGMA2.- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- initialize(d_idx, d_p, d_rho, d_e, d_m, d_cs, d_h, d_htmp, d_h0, d_u, d_v, d_w, d_wij, d_n, d_dndh, d_divv, d_alpha, d_ddv, d_dv, d_de, d_cm, d_dde, d_rho0)[source]
- class pysph.sph.gas_dynamics.magma2.MomentumAndEnergyStdGrad(dest, sources, dim, fkern, eta_crit=0.3, eta_fold=0.2, beta=2.0, alphac=0.05, eps=0.01)[source]
Standard Gradient formulation (stdGrad) momentum and energy equations with artificial viscosity and artificial conductivity from [Rosswog2020b]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.magma2.MomentumAndEnergyMI1(dest, sources, dim, fkern, eta_crit=0.3, eta_fold=0.2, beta=2.0, alphac=0.05, eps=0.01)[source]
Matrix inversion formulation 1 (MI1) momentum and energy equations with artificial viscosity and artificial conductivity from [Rosswog2020b]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.magma2.MomentumAndEnergyMI2(dest, sources, dim, fkern, eta_crit=0.3, eta_fold=0.2, beta=2.0, alphac=0.05, eps=0.01)[source]
Matrix inversion formulation 2 (MI2) momentum and energy equations with artificial viscosity and artificial conductivity from [Rosswog2020b]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.magma2.EvaluateTildeMu(dest, sources, dim)[source]
Find \(\tilde{\mu}\) to calculate time step.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.gas_dynamics.magma2.SettleByArtificialPressure(dest, sources, xi=0.5, fkern=1.0)[source]
Equation 40 of [Rosswog2020b] . Combined with an equation to update density (and smoothing length, if preferred), this equation can be evaluated through
SPHEvaluatorto settle the particles and obtain an initial distribution.- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
Rigid body motion
Rigid body related equations.
- class pysph.sph.rigid_body.AkinciRigidFluidCoupling(dest, sources, fluid_rho=1000)[source]
Force between a solid sphere and a SPH fluid particle. This is implemented using Akinci’s[1] force and additional force from solid bodies pressure which is implemented by Liu[2]
[1]’Versatile Rigid-Fluid Coupling for Incompressible SPH’
URL: https://graphics.ethz.ch/~sobarbar/papers/Sol12/Sol12.pdf
[2]A 3D Simulation of a Moving Solid in Viscous Free-Surface Flows by Coupling SPH and DEM
https://doi.org/10.1155/2017/3174904
- Note: Here forces for both the phases are added at once.
Please make sure that this force is applied only once for both the particle properties.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.rigid_body.BodyForce(dest, sources, gx=0.0, gy=0.0, gz=0.0)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.rigid_body.EulerStepRigidBody[source]
Fast but inaccurate integrator. Use this for testing
- class pysph.sph.rigid_body.LiuFluidForce(dest, sources)[source]
Force between a solid sphere and a SPH fluid particle. This is implemented using Akinci’s[1] force and additional force from solid bodies pressure which is implemented by Liu[2]
[1]’Versatile Rigid-Fluid Coupling for Incompressible SPH’
URL: https://graphics.ethz.ch/~sobarbar/papers/Sol12/Sol12.pdf
[2]A 3D Simulation of a Moving Solid in Viscous Free-Surface Flows by Coupling SPH and DEM
https://doi.org/10.1155/2017/3174904
- Note: Here forces for both the phases are added at once.
Please make sure that this force is applied only once for both the particle properties.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.rigid_body.NumberDensity(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.rigid_body.PressureRigidBody(dest, sources, rho0)[source]
The pressure acceleration on the fluid/solid due to a boundary. Implemented from Akinci et al. http://dx.doi.org/10.1145/2185520.2185558
Use this with the fluid as a destination and body as source.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.rigid_body.RK2StepRigidBody[source]
- initialize(d_idx, d_x, d_y, d_z, d_x0, d_y0, d_z0, d_omega, d_omega0, d_vc, d_vc0, d_num_body)[source]
- class pysph.sph.rigid_body.RigidBodyCollision(dest, sources, kn=1000.0, mu=0.5, en=0.8)[source]
Force between two spheres is implemented using DEM contact force law.
Refer https://doi.org/10.1016/j.powtec.2011.09.019 for more information.
Open-source MFIX-DEM software for gas–solids flows: Part I—Verification studies .
Initialise the required coefficients for force calculation.
Keyword arguments: kn – Normal spring stiffness (default 1e3) mu – friction coefficient (default 0.5) en – coefficient of restitution (0.8)
Given these coefficients, tangential spring stiffness, normal and tangential damping coefficient are calculated by default.
- class pysph.sph.rigid_body.RigidBodyForceGPUGems(dest, sources, k=1.0, d=1.0, eta=1.0, kt=1.0)[source]
This is inspired from http://http.developer.nvidia.com/GPUGems3/gpugems3_ch29.html and BK Mishra’s article on DEM http://dx.doi.org/10.1016/S0301-7516(03)00032-2 A review of computer simulation of tumbling mills by the discrete element method: Part I - contact mechanics
Note that d is a factor multiplied with the “h” of the particle.
- class pysph.sph.rigid_body.RigidBodyMoments(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.rigid_body.RigidBodyMotion(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.rigid_body.RigidBodyWallCollision(dest, sources, kn=1000.0, mu=0.5, en=0.8)[source]
Force between sphere and a wall is implemented using DEM contact force law.
Refer https://doi.org/10.1016/j.powtec.2011.09.019 for more information.
Open-source MFIX-DEM software for gas–solids flows: Part I—Verification studies .
Initialise the required coefficients for force calculation.
Keyword arguments: kn – Normal spring stiffness (default 1e3) mu – friction coefficient (default 0.5) en – coefficient of restitution (0.8)
Given these coefficients, tangential spring stiffness, normal and tangential damping coefficient are calculated by default.
- class pysph.sph.rigid_body.SummationDensityBoundary(dest, sources, fluid_rho=1000.0)[source]
Equation to find the density of the fluid particle due to any boundary or a rigid body
\(\rho_a = \sum_b {\rho}_fluid V_b W_{ab}\)
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.rigid_body.SummationDensityRigidBody(dest, sources, rho0)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.rigid_body.ViscosityRigidBody(dest, sources, rho0, nu)[source]
The viscous acceleration on the fluid/solid due to a boundary. Implemented from Akinci et al. http://dx.doi.org/10.1145/2185520.2185558
Use this with the fluid as a destination and body as source.
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- pysph.sph.rigid_body.get_alpha_dot()[source]
Use sympy to perform most of the math and use the resulting formulae to calculate:
inv(I) ( au - w x (I w))
Miscellaneous
Functions for advection
- class pysph.sph.misc.advection.Advect(dest, sources)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
- class pysph.sph.misc.advection.MixingVelocityUpdate(dest, sources, T)[source]
- Parameters:
dest (str) – name of the destination particle array
sources (list of str or None) – names of the source particle arrays
Functions to reduce array data in serial or parallel.
- pysph.base.reduce_array.dummy_reduce_array(array, op='sum')[source]
Simply returns the array for the serial case.
- pysph.base.reduce_array.mpi_reduce_array(array, op='sum')[source]
Reduce an array given an array and a suitable reduction operation.
Currently, only ‘sum’, ‘max’, ‘min’ and ‘prod’ are supported.
Parameters
array: numpy.ndarray: Any numpy array (1D).
op: str: reduction operation, one of (‘sum’, ‘prod’, ‘min’, ‘max’)
- pysph.base.reduce_array.parallel_reduce_array(array, op='sum')
Reduce an array given an array and a suitable reduction operation.
Currently, only ‘sum’, ‘max’, ‘min’ and ‘prod’ are supported.
Parameters
array: numpy.ndarray: Any numpy array (1D).
op: str: reduction operation, one of (‘sum’, ‘prod’, ‘min’, ‘max’)
- pysph.base.reduce_array.serial_reduce_array(array, op='sum')[source]
Reduce an array given an array and a suitable reduction operation.
Currently, only ‘sum’, ‘max’, ‘min’ and ‘prod’ are supported.
Parameters
array: numpy.ndarray: Any numpy array (1D).
op: str: reduction operation, one of (‘sum’, ‘prod’, ‘min’, ‘max’)
Group of equations
- class pysph.sph.equation.Group(equations, real=True, update_nnps=False, iterate=False, max_iterations=1, min_iterations=0, pre=None, post=None, condition=None, start_idx=0, stop_idx=None, name=None)[source]
A group of equations.
This class provides some support for the code generation for the collection of equations.
Constructor.
- Parameters:
equations (list) – a list of equation objects.
real (bool) – specifies if only non-remote/non-ghost particles should be operated on.
update_nnps (bool) – specifies if the neighbors should be re-computed locally after this group
iterate (bool) – specifies if the group should continue iterating until each equation’s “converged()” methods returns with a positive value.
max_iterations (int) – specifies the maximum number of times this group should be iterated.
min_iterations (int) – specifies the minimum number of times this group should be iterated.
pre (callable) – A callable which is passed no arguments that is called before anything in the group is executed.
post (callable) – A callable which is passed no arguments that is called after the group is completed.
condition (callable) – A callable that is passed (t, dt). If this callable returns True, the group is executed, otherwise it is not. If condition is None, the group is always executed. Note that this should work even if the group has many destination arrays.
start_idx (int or str) – Start looping from this destination index. Starts from the given number if an integer is passed. If a string is look for a property/constant and use its first value as the loop count.
stop_idx (int or str) – Loop up to this destination index instead of over all possible values. Defaults to all particles. Ends at the given number if an integer is passed. If a string is passed, look for a property/constant and use its first value as the loop count. Note that this works like a range stop parameter so the last value is not included.
name (str) – The passed string is used to name the Group in the profiling info csv file to make it easy to read. If a string is not passed it defaults to the name ‘Group’.
Notes
When running simulations in parallel, one should typically run the summation density over all particles (both local and remote) in each processor. This is because we must update the pressure/density of the remote neighbors in the current processor. Otherwise the results can be incorrect with the remote particles having an older density. This is also the case for the TaitEOS. In these cases the group that computes the equation should set real to False.
- class pysph.sph.equation.MultiStageEquations(groups)[source]
A class that allows a user to specify different equations for different stages.
The object doesn’t do much, except contain the different collections of equations.
- Parameters:
groups (list/tuple) – A list/tuple of list of groups/equations, one for each stage.