def get_equations(self): from pysph.sph.equation import Group from pysph.sph.wc.basic import TaitEOS from pysph.sph.basic_equations import XSPHCorrection from pysph.sph.wc.transport_velocity import ( ContinuityEquation, MomentumEquationPressureGradient, MomentumEquationViscosity, MomentumEquationArtificialViscosity, SolidWallPressureBC, SolidWallNoSlipBC, SetWallVelocity, VolumeSummation) equations = [] all = self.fluids + self.solids g2 = [] for fluid in self.fluids: g2.append(VolumeSummation(dest=fluid, sources=all)) g2.append( TaitEOS(dest=fluid, sources=None, rho0=self.rho0, c0=self.c0, gamma=self.gamma, p0=self.p0)) for solid in self.solids: g2.append(VolumeSummation(dest=solid, sources=all)) g2.append(SetWallVelocity(dest=solid, sources=self.fluids)) equations.append(Group(equations=g2, real=False)) g3 = [] for solid in self.solids: g3.append( SolidWallPressureBC(dest=solid, sources=self.fluids, b=1.0, rho0=self.rho0, p0=self.B, gx=self.gx, gy=self.gy, gz=self.gz)) equations.append(Group(equations=g3, real=False)) g4 = [] for fluid in self.fluids: g4.append(ContinuityEquation(dest=fluid, sources=all)) g4.append( MomentumEquationPressureGradient(dest=fluid, sources=all, pb=0.0, gx=self.gx, gy=self.gy, gz=self.gz, tdamp=self.tdamp)) if self.alpha > 0.0: g4.append( MomentumEquationArtificialViscosity(dest=fluid, sources=all, c0=self.c0, alpha=self.alpha)) if self.nu > 0.0: g4.append( MomentumEquationViscosity(dest=fluid, sources=self.fluids, nu=self.nu)) if len(self.solids) > 0: g4.append( SolidWallNoSlipBC(dest=fluid, sources=self.solids, nu=self.nu)) g4.append(XSPHCorrection(dest=fluid, sources=[fluid])) equations.append(Group(equations=g4)) return equations
def get_equations(self): from pysph.sph.wc.transport_velocity import ( StateEquation, SetWallVelocity, SolidWallPressureBC, VolumeSummation, SolidWallNoSlipBC, MomentumEquationArtificialViscosity, ContinuitySolid) all = self.fluids + self.solids stage1 = [] if self.solids: eq0 = [] for solid in self.solids: eq0.append(SetWallVelocity(dest=solid, sources=self.fluids)) stage1.append(Group(equations=eq0, real=False)) eq1 = [] for fluid in self.fluids: eq1.append(ContinuityEquationGTVF(dest=fluid, sources=self.fluids)) if self.solids: eq1.append(ContinuitySolid(dest=fluid, sources=self.solids)) stage1.append(Group(equations=eq1, real=False)) eq2, stage2 = [], [] for fluid in self.fluids: eq2.append(CorrectDensity(dest=fluid, sources=all)) stage2.append(Group(equations=eq2, real=False)) eq3 = [] for fluid in self.fluids: eq3.append( StateEquation(dest=fluid, sources=None, p0=self.pref, rho0=self.rho0, b=1.0)) stage2.append(Group(equations=eq3, real=False)) g2_s = [] for solid in self.solids: g2_s.append(VolumeSummation(dest=solid, sources=all)) g2_s.append( SolidWallPressureBC(dest=solid, sources=self.fluids, b=1.0, rho0=self.rho0, p0=self.pref, gx=self.gx, gy=self.gy, gz=self.gz)) if g2_s: stage2.append(Group(equations=g2_s, real=False)) eq4 = [] for fluid in self.fluids: eq4.append( MomentumEquationPressureGradient(dest=fluid, sources=all, pref=self.pref, gx=self.gx, gy=self.gy, gz=self.gz)) if self.alpha > 0.0: eq4.append( MomentumEquationArtificialViscosity(dest=fluid, sources=all, c0=self.c0, alpha=self.alpha)) if self.nu > 0.0: eq4.append( MomentumEquationViscosity(dest=fluid, sources=all, nu=self.nu)) if self.solids: eq4.append( SolidWallNoSlipBC(dest=fluid, sources=self.solids, nu=self.nu)) eq4.append( MomentumEquationArtificialStress(dest=fluid, sources=self.fluids, dim=self.dim)) stage2.append(Group(equations=eq4, real=True)) return MultiStageEquations([stage1, stage2])
def get_equations(self): from pysph.sph.equation import Group from pysph.sph.wc.transport_velocity import ( SummationDensity, StateEquation, MomentumEquationPressureGradient, MomentumEquationArtificialViscosity, MomentumEquationViscosity, MomentumEquationArtificialStress, SolidWallPressureBC, SolidWallNoSlipBC, SetWallVelocity) equations = [] all = self.fluids + self.solids g1 = [] for fluid in self.fluids: g1.append(SummationDensity(dest=fluid, sources=all)) equations.append(Group(equations=g1, real=False)) g2 = [] for fluid in self.fluids: g2.append( StateEquation(dest=fluid, sources=None, p0=self.p0, rho0=self.rho0, b=1.0)) for solid in self.solids: g2.append(SetWallVelocity(dest=solid, sources=self.fluids)) equations.append(Group(equations=g2, real=False)) g3 = [] for solid in self.solids: g3.append( SolidWallPressureBC(dest=solid, sources=self.fluids, b=1.0, rho0=self.rho0, p0=self.p0, gx=self.gx, gy=self.gy, gz=self.gz)) equations.append(Group(equations=g3, real=False)) g4 = [] for fluid in self.fluids: g4.append( MomentumEquationPressureGradient(dest=fluid, sources=all, pb=self.pb, gx=self.gx, gy=self.gy, gz=self.gz, tdamp=self.tdamp)) if self.alpha > 0.0: g4.append( MomentumEquationArtificialViscosity(dest=fluid, sources=all, c0=self.c0, alpha=self.alpha)) if self.nu > 0.0: g4.append( MomentumEquationViscosity(dest=fluid, sources=self.fluids, nu=self.nu)) if len(self.solids) > 0: g4.append( SolidWallNoSlipBC(dest=fluid, sources=self.solids, nu=self.nu)) g4.append( MomentumEquationArtificialStress(dest=fluid, sources=self.fluids)) equations.append(Group(equations=g4)) return equations
def create_equations(self): # Formulation for REF1 # (using only first set of equations for simplicity) equations = [ Group(equations=[ DiffuseMaterial(dest='fluid', sources=['fluid'], diffusion_speed=0.1) ], ), # For the multi-phase formulation, we require an estimate of the # particle volume. This can be either defined from the particle # number density or simply as the ratio of mass to density Group( equations=[VolumeFromMassDensity(dest='fluid', sources=None)], ), # Equation of state is typically the Tait EOS with a suitable # exponent gamma Group(equations=[ TaitEOS(dest='fluid', sources=None, rho0=rho0, c0=c0, gamma=gamma), ], ), # The boundary conditions are imposed by extrapolating the fluid # pressure, taking into consideration the boundary acceleration Group(equations=[ SolidWallPressureBC(dest='solid', sources=['fluid'], b=1.0, gy=gravity_y, rho0=rho0, p0=p0) ], ), # Main acceleration block Group(equations=[ # Continuity equation ContinuityEquation(dest='fluid', sources=['fluid', 'solid']), # Pressure gradient with acceleration damping MomentumEquationPressureGradient(dest='fluid', sources=['fluid', 'solid'], pb=0.0, gy=gravity_y, tdamp=tdamp), # artificial viscosity for stability MomentumEquationArtificialViscosity(dest='fluid', sources=['fluid', 'solid'], alpha=0.24, c0=c0), # Position step with XSPH XSPHCorrection(dest='fluid', sources=['fluid'], eps=0.0) ]), ] return equations
def _get_external_flow_equations(self): from pysph.sph.basic_equations import XSPHCorrection from pysph.sph.wc.transport_velocity import ( VolumeSummation, SolidWallNoSlipBC, SummationDensity, MomentumEquationArtificialViscosity, MomentumEquationViscosity) all = self.fluids + self.solids edac_nu = self._get_edac_nu() equations = [] group1 = [] for fluid in self.fluids: group1.append(SummationDensity(dest=fluid, sources=all)) for solid in self.solids: group1.extend([ VolumeSummation(dest=solid, sources=all), SolidWallPressureBC(dest=solid, sources=self.fluids, gx=self.gx, gy=self.gy, gz=self.gz), SetWallVelocity(dest=solid, sources=self.fluids), ]) if self.clamp_p: group1.append(ClampWallPressure(dest=solid, sources=None)) equations.append(Group(equations=group1, real=False)) group2 = [] for fluid in self.fluids: group2.append( MomentumEquation(dest=fluid, sources=all, gx=self.gx, gy=self.gy, gz=self.gz, c0=self.c0, tdamp=self.tdamp)) if self.alpha > 0.0: group2.append( MomentumEquationArtificialViscosity(dest=fluid, sources=all, alpha=self.alpha, c0=self.c0)) if self.nu > 0.0: group2.append( MomentumEquationViscosity(dest=fluid, sources=self.fluids, nu=self.nu)) if len(self.solids) > 0 and self.nu > 0.0: group2.append( SolidWallNoSlipBC(dest=fluid, sources=self.solids, nu=self.nu)) group2.extend([ EDACEquation(dest=fluid, sources=all, nu=edac_nu, cs=self.c0, rho0=self.rho0), XSPHCorrection(dest=fluid, sources=[fluid], eps=self.eps) ]) equations.append(Group(equations=group2)) return equations
def _get_internal_flow_equations(self): from pysph.sph.wc.transport_velocity import ( VolumeSummation, SolidWallNoSlipBC, SummationDensity, MomentumEquationArtificialStress, MomentumEquationArtificialViscosity, MomentumEquationViscosity) edac_nu = self._get_edac_nu() all = self.fluids + self.solids equations = [] group1 = [] avg_p_group = [] has_solids = len(self.solids) > 0 for fluid in self.fluids: group1.append(SummationDensity(dest=fluid, sources=all)) if self.bql: eq = ComputeAveragePressure(dest=fluid, sources=all) if has_solids: avg_p_group.append(eq) else: group1.append(eq) for solid in self.solids: group1.extend([ VolumeSummation(dest=solid, sources=all), SolidWallPressureBC(dest=solid, sources=self.fluids, gx=self.gx, gy=self.gy, gz=self.gz), SetWallVelocity(dest=solid, sources=self.fluids), ]) equations.append(Group(equations=group1, real=False)) # Compute average pressure *after* the wall pressure is setup. if self.bql and has_solids: equations.append(Group(equations=avg_p_group, real=True)) group2 = [] for fluid in self.fluids: group2.append( MomentumEquationPressureGradient(dest=fluid, sources=all, pb=self.pb, gx=self.gx, gy=self.gy, gz=self.gz, tdamp=self.tdamp)) if self.alpha > 0.0: group2.append( MomentumEquationArtificialViscosity(dest=fluid, sources=all, alpha=self.alpha, c0=self.c0)) if self.nu > 0.0: group2.append( MomentumEquationViscosity(dest=fluid, sources=self.fluids, nu=self.nu)) if len(self.solids) > 0 and self.nu > 0.0: group2.append( SolidWallNoSlipBC(dest=fluid, sources=self.solids, nu=self.nu)) group2.extend([ MomentumEquationArtificialStress(dest=fluid, sources=self.fluids), EDACEquation(dest=fluid, sources=all, nu=edac_nu, cs=self.c0, rho0=self.rho0), ]) equations.append(Group(equations=group2)) return equations
def create_equations(self): # Formulation for REF1 equations1 = [ # For the multi-phase formulation, we require an estimate of the # particle volume. This can be either defined from the particle # number density or simply as the ratio of mass to density. Group(equations=[ VolumeFromMassDensity(dest='fluid', sources=None) ], ), # Equation of state is typically the Tait EOS with a suitable # exponent gamma Group(equations=[ TaitEOS(dest='fluid', sources=None, rho0=rho0, c0=c0, gamma=gamma), ], ), # The boundary conditions are imposed by extrapolating the fluid # pressure, taking into considering the bounday acceleration Group(equations=[ SolidWallPressureBC(dest='solid', sources=['fluid'], b=1.0, gy=gy, rho0=rho0, p0=p0), ], ), # Main acceleration block Group(equations=[ # Continuity equation ContinuityEquation(dest='fluid', sources=['fluid','solid']), # Pressure gradient with acceleration damping. MomentumEquationPressureGradient( dest='fluid', sources=['fluid', 'solid'], pb=0.0, gy=gy, tdamp=tdamp), # artificial viscosity for stability MomentumEquationArtificialViscosity( dest='fluid', sources=['fluid', 'solid'], alpha=0.24, c0=c0), # Position step with XSPH XSPHCorrection(dest='fluid', sources=['fluid'], eps=0.0) ]), ] # Formulation for REF2. Note that for this formulation to work, the # boundary particles need to have a spacing different from the fluid # particles (usually determined by a factor beta). In the current # implementation, the value is taken as 1.0 which will mostly be # ineffective. equations2 = [ # For the multi-phase formulation, we require an estimate of the # particle volume. This can be either defined from the particle # number density or simply as the ratio of mass to density. Group(equations=[ VolumeFromMassDensity(dest='fluid', sources=None) ], ), # Equation of state is typically the Tait EOS with a suitable # exponent gamma Group(equations=[ TaitEOS(dest='fluid', sources=None, rho0=rho0, c0=c0, gamma=gamma), ], ), # Main acceleration block Group(equations=[ # The boundary conditions are imposed as a force or # accelerations on the fluid particles. Note that the # no-penetration condition is to be satisfied with this # equation. The subsequent equations therefore do not have # solid as the source. Note the difference between the # ghost-fluid formulations. K should be 0.01*co**2 # according to REF2. We take it much smaller here on # account of the multiple layers of boundary particles MonaghanKajtarBoundaryForce(dest='fluid', sources=['solid'], K=0.02, beta=1.0, h=hdx*dx), # Continuity equation ContinuityEquation(dest='fluid', sources=['fluid',]), # Pressure gradient with acceleration damping. MomentumEquationPressureGradient( dest='fluid', sources=['fluid'], pb=0.0, gy=gy, tdamp=tdamp), # artificial viscosity for stability MomentumEquationArtificialViscosity( dest='fluid', sources=['fluid'], alpha=0.25, c0=c0), # Position step with XSPH XSPHCorrection(dest='fluid', sources=['fluid'], eps=0.0) ]), ] # Formulation for REF3 equations3 = [ # For the multi-phase formulation, we require an estimate of the # particle volume. This can be either defined from the particle # number density or simply as the ratio of mass to density. Group(equations=[ VolumeFromMassDensity(dest='fluid', sources=None) ], ), # Equation of state is typically the Tait EOS with a suitable # exponent gamma. The solid phase is treated just as a fluid and # the pressure and density operations is updated for this as well. Group(equations=[ TaitEOS(dest='fluid', sources=None, rho0=rho0, c0=c0, gamma=gamma), TaitEOS(dest='solid', sources=None, rho0=rho0, c0=c0, gamma=gamma), ], ), # Main acceleration block. The boundary conditions are imposed by # peforming the continuity equation and gradient of pressure # calculation on the solid phase, taking contributions from the # fluid phase Group(equations=[ # Continuity equation ContinuityEquation(dest='fluid', sources=['fluid','solid']), ContinuityEquation(dest='solid', sources=['fluid']), # Pressure gradient with acceleration damping. MomentumEquationPressureGradient( dest='fluid', sources=['fluid', 'solid'], pb=0.0, gy=gy, tdamp=tdamp), # artificial viscosity for stability MomentumEquationArtificialViscosity( dest='fluid', sources=['fluid', 'solid'], alpha=0.25, c0=c0), # Position step with XSPH XSPHCorrection(dest='fluid', sources=['fluid'], eps=0.5) ]), ] if self.options.bc_type == 1: return equations1 elif self.options.bc_type == 2: return equations2 elif self.options.bc_type == 3: return equations3
def create_equations(self): # Formulation for REF1 equations1 = [ Group(equations=[ HarmonicOscilllator(dest='spoon', sources=None, A=3, omega=0.5), # Translate acceleration to positions XSPHCorrection(dest='spoon', sources=['spoon'], eps=0.0) ], real=False), # Water Faucet Equations Group(equations=[ H2OFaucet(dest='tahini', sources=None, x=0.5, y=tahiniH, z=1, r=0.1, fill_rate=8), DiffuseH2O(dest='tahini', sources=['tahini'], diffusion_speed=0.025), ]), # For the multi-phase formulation, we require an estimate of the # particle volume. This can be either defined from the particle # number density or simply as the ratio of mass to density. Group(equations=[ VolumeFromMassDensity(dest='tahini', sources=None) ], ), # Equation of state is typically the Tait EOS with a suitable # exponent gamma Group(equations=[ TaitEOSHGCorrection( dest='tahini', sources=None, rho0=rho0, c0=c0, gamma=gamma), ], ), # The boundary conditions are imposed by extrapolating the tahini # pressure, taking into considering the bounday acceleration Group(equations=[ SolidWallPressureBC(dest='bowl', sources=['tahini'], b=1.0, gy=gy, rho0=rho0, p0=p0), SolidWallPressureBC(dest='spoon', sources=['tahini'], b=1.0, gy=gy, rho0=rho0, p0=p0), ], ), # Main acceleration block Group(equations=[ TahiniEquation(dest='tahini', sources=['tahini'], sigma=dx / 1.122), # Continuity equation ContinuityEquation( dest='tahini', sources=[ 'tahini', 'bowl', 'spoon']), # Pressure gradient with acceleration damping. MomentumEquationPressureGradient( dest='tahini', sources=['tahini', 'bowl', 'spoon'], pb=0.0, gy=gy, tdamp=tdamp), # artificial viscosity for stability MomentumEquationArtificialViscosity( dest='tahini', sources=['tahini', 'bowl', 'spoon'], alpha=1, c0=c0), # Position step with XSPH XSPHCorrection(dest='tahini', sources=['tahini'], eps=0.0) ]), ] # Formulation for REF3 equations3 = [ # Spoon Equations Group(equations=[ HarmonicOscilllator(dest='spoon', sources=None, A=3, omega=0.333), # Translate acceleration to positions XSPHCorrection(dest='spoon', sources=['spoon'], eps=0.0) ], real=False), # Water Faucet Equations Group(equations=[ H2OFaucet(dest='tahini', sources=None, x=0.5, y=tahiniH, z=1, r=0.1, fill_rate=25), DiffuseH2O(dest='tahini', sources=['tahini'], diffusion_speed=0.025), ]), # For the multi-phase formulation, we require an estimate of the # particle volume. This can be either defined from the particle # number density or simply as the ratio of mass to density. Group(equations=[ VolumeFromMassDensity(dest='tahini', sources=None) ], ), # Equation of state is typically the Tait EOS with a suitable # exponent gamma. The solid phase is treated just as a fluid and # the pressure and density operations is updated for this as well. Group(equations=[ TaitEOS( dest='tahini', sources=None, rho0=rho0, c0=c0, gamma=gamma), TaitEOS( dest='bowl', sources=None, rho0=rho0, c0=c0, gamma=gamma), TaitEOS( dest='spoon', sources=None, rho0=rho0, c0=c0, gamma=gamma), ], ), # Main acceleration block. The boundary conditions are imposed by # peforming the continuity equation and gradient of pressure # calculation on the bowl phase, taking contributions from the # tahini phase Group(equations=[ TahiniEquation(dest='tahini', sources=['tahini'], sigma=dx / 1.122), # Continuity equation ContinuityEquation( dest='tahini', sources=[ 'tahini', 'bowl', 'spoon']), ContinuityEquation(dest='bowl', sources=['tahini']), ContinuityEquation(dest='spoon', sources=['tahini']), # Pressure gradient with acceleration damping. MomentumEquationPressureGradient( dest='tahini', sources=['tahini', 'bowl', 'spoon'], pb=0.0, gy=gy, tdamp=tdamp), # artificial viscosity for stability MomentumEquationArtificialViscosity( dest='tahini', sources=['tahini', 'bowl', 'spoon'], alpha=1, c0=c0), # Position step with XSPH XSPHCorrection(dest='tahini', sources=['tahini'], eps=0.5) ]), ] if self.options.bc_type == 1: return equations1 elif self.options.bc_type == 3: return equations3