Example #1
0
 def create_equations(self):
     equations = [
         Group(equations=[
             TaitEOS(dest='fluid', sources=None, rho0=self.ro, c0=self.co,
                     gamma=7.0),
             TaitEOS(dest='tank', sources=None, rho0=self.ro, c0=self.co,
                     gamma=7.0),
         ], real=False),
         Group(equations=[
             ContinuityEquation(
                 dest='fluid',
                 sources=['fluid', 'tank', 'cube'],),
             ContinuityEquation(
                 dest='tank',
                 sources=['fluid', 'tank', 'cube'], ),
             MomentumEquation(dest='fluid', sources=['fluid', 'tank'],
                              alpha=self.alpha, beta=0.0, c0=self.co,
                              gy=-9.81),
             SolidForceOnFluid(dest='fluid', sources=['cube']),
             XSPHCorrection(dest='fluid', sources=['fluid', 'tank']),
         ]),
         Group(equations=[
             BodyForce(dest='cube', sources=None, gy=-9.81),
             FluidForceOnSolid(dest='cube', sources=['fluid']),
             # RigidBodyCollision(
             #     dest='cube',
             #     sources=['tank'],
             #     kn=1e5,
             #     en=0.5, )
         ]),
         Group(equations=[RigidBodyMoments(dest='cube', sources=None)]),
         Group(equations=[RigidBodyMotion(dest='cube', sources=None)]),
     ]
     return equations
Example #2
0
 def create_equations(self):
     equations = [
         Group(equations=[
             TaitEOS(dest='fluid',
                     sources=None,
                     rho0=1000,
                     c0=self.co,
                     gamma=7.0),
             TaitEOS(dest='wall',
                     sources=None,
                     rho0=1000,
                     c0=self.co,
                     gamma=7.0),
         ],
               real=False),
         Group(equations=[
             ContinuityEquation(dest='fluid', sources=['fluid', 'wall']),
             ContinuityEquation(dest='wall', sources=['fluid', 'wall']),
             MomentumEquation(dest='fluid',
                              sources=['fluid', 'wall'],
                              alpha=self.alpha,
                              beta=0.0,
                              c0=self.co,
                              gy=-9.81),
             XSPHCorrection(dest='fluid', sources=['fluid']),
         ]),
     ]
     return equations
 def create_equations(self):
     equations = [
         Group(equations=[
             TaitEOS(dest='fluid', sources=None, rho0=self.ro, c0=self.co,
                     gamma=7.0),
             TaitEOS(dest='tank', sources=None, rho0=self.ro, c0=self.co,
                     gamma=7.0),
         ], real=False),
         Group(equations=[
             SummationDensityShepardFilter(
                 dest='fluid',
                 sources=['fluid', 'tank'], ),
             # SummationDensityShepardFilter(
             #     dest='tank',
             #     sources=['fluid', 'tank'], ),
             SummationDensity(
                 dest='tank',
                 sources=['fluid', 'tank'], ),
             MomentumEquation(dest='fluid', sources=['fluid', 'tank'],
                              alpha=self.alpha, beta=0.0, c0=self.co,
                              gy=-9.81),
             XSPHCorrection(dest='fluid', sources=['fluid', 'tank']),
         ]),
     ]
     return equations
Example #4
0
 def create_equations(self):
     equations = [
         Group(equations=[
             BodyForce(dest='ball', sources=None, gy=gz),
         ]),
         Group(equations=[
             TaitEOS(dest='fluid',
                     sources=None,
                     rho0=self.ro,
                     c0=self.co,
                     gamma=7.0),
             TaitEOS(dest='wall',
                     sources=None,
                     rho0=self.ro,
                     c0=self.co,
                     gamma=7.0),
             TaitEOS(dest='temp_wall',
                     sources=None,
                     rho0=self.ro,
                     c0=self.co,
                     gamma=7.0),
         ],
               real=False),
         Group(equations=[
             ContinuityEquation(
                 dest='fluid',
                 sources=['fluid', 'temp_wall', 'wall'],
             ),
             ContinuityEquation(
                 dest='temp_wall',
                 sources=['fluid', 'temp_wall', 'wall'],
             ),
             ContinuityEquation(
                 dest='wall',
                 sources=['fluid', 'temp_wall', 'wall'],
             ),
             MomentumEquation(dest='fluid',
                              sources=['fluid', 'wall', 'temp_wall'],
                              alpha=self.alpha,
                              beta=0.0,
                              c0=self.co,
                              gy=-9.81),
             SolidFluidForce(
                 dest='fluid',
                 sources=['ball'],
             ),
             XSPHCorrection(dest='fluid',
                            sources=['fluid', 'temp_wall', 'wall']),
         ]),
         Group(equations=[
             RigidBodyCollision(
                 dest='ball', sources=['ball', 'wall', 'temp_wall'], kn=1e5)
         ]),
         Group(equations=[RigidBodyMoments(dest='ball', sources=None)]),
         Group(equations=[RigidBodyMotion(dest='ball', sources=None)]),
     ]
     return equations
Example #5
0
    def create_equations(self):
        adami_equations = [
            Group(equations=[
                SummationDensity(dest='liquid',
                                 sources=['liquid', 'wall', 'gas']),
                SummationDensity(dest='gas', sources=['liquid', 'wall', 'gas'
                                                      ]),
                SummationDensity(dest='wall',
                                 sources=['liquid', 'wall', 'gas'])
            ]),
            Group(equations=[
                TaitEOS(dest='liquid',
                        sources=None,
                        rho0=rho1,
                        c0=c0,
                        gamma=1,
                        p0=p1),
                TaitEOS(
                    dest='gas', sources=None, rho0=rho2, c0=c0, gamma=1,
                    p0=p1),
                SolidWallPressureBCnoDensity(dest='wall',
                                             sources=['liquid', 'gas']),
            ]),
            Group(equations=[
                ColorGradientAdami(dest='liquid',
                                   sources=['liquid', 'wall', 'gas']),
                ColorGradientAdami(dest='gas',
                                   sources=['liquid', 'wall', 'gas']),
            ]),
            Group(equations=[
                ConstructStressMatrix(
                    dest='liquid', sources=None, sigma=sigma, d=2),
                ConstructStressMatrix(
                    dest='gas', sources=None, sigma=sigma, d=2)
            ]),
            Group(equations=[
                MomentumEquationPressureGradientAdami(
                    dest='liquid', sources=['liquid', 'wall', 'gas']),
                MomentumEquationPressureGradientAdami(
                    dest='gas', sources=['liquid', 'wall', 'gas']),
                MomentumEquationViscosityAdami(dest='liquid',
                                               sources=['liquid', 'gas']),
                MomentumEquationViscosityAdami(dest='gas',
                                               sources=['liquid', 'gas']),
                SurfaceForceAdami(dest='liquid',
                                  sources=['liquid', 'wall', 'gas']),
                SurfaceForceAdami(dest='gas',
                                  sources=['liquid', 'wall', 'gas']),
                SolidWallNoSlipBC(dest='liquid', sources=['wall'], nu=nu1),
                SolidWallNoSlipBC(dest='gas', sources=['wall'], nu=nu2),
            ]),
        ]

        return adami_equations
Example #6
0
 def create_equations(self):
     equations = [
         Group(
             equations=[
                 BodyForce(dest='cube', sources=None, gy=-9.81),
                 # NumberDensity(dest='cube', sources=['cube']),
             ],
             real=False),
         Group(equations=[
             TaitEOS(dest='fluid',
                     sources=None,
                     rho0=self.ro,
                     c0=self.co,
                     gamma=7.0),
             TaitEOS(dest='tank',
                     sources=None,
                     rho0=self.ro,
                     c0=self.co,
                     gamma=7.0),
         ],
               real=False),
         Group(equations=[
             ContinuityEquation(
                 dest='fluid',
                 sources=['fluid', 'tank', 'cube'],
             ),
             ContinuityEquation(
                 dest='tank',
                 sources=['fluid', 'tank', 'cube'],
             ),
             MomentumEquation(dest='fluid',
                              sources=['fluid', 'tank'],
                              alpha=self.alpha,
                              beta=0.0,
                              c0=self.co,
                              gy=-9.81),
             SolidFluidForce(
                 dest='fluid',
                 sources=['cube'],
             ),
             # PressureRigidBody(dest='fluid', sources=['cube'],
             #                   rho0=1500),
             XSPHCorrection(dest='fluid', sources=['fluid', 'tank']),
         ]),
         Group(equations=[
             RigidBodyCollision(dest='cube', sources=['tank'], kn=1e5)
         ]),
         Group(equations=[RigidBodyMoments(dest='cube', sources=None)]),
         Group(equations=[RigidBodyMotion(dest='cube', sources=None)]),
     ]
     return equations
Example #7
0
    def get_equations(self):
        from pysph.sph.basic_equations import XSPHCorrection
        from pysph.sph.wc.basic import TaitEOS
        from pysph.sph.wc.viscosity import LaminarViscosity
        all = self.fluids

        equations = []

        eq0 = []
        for fluid in self.fluids:
            eq0.append(CRKSPHPreStep(dest=fluid, sources=all, dim=2))
        equations.append(Group(equations=eq0, real=False))

        eq1 = []
        for fluid in self.fluids:
            eq1.append(NumberDensity(dest=fluid, sources=all))
        equations.append(Group(equations=eq1, real=False))

        eq2 = []
        for fluid in self.fluids:
            eq2.extend([
                CRKSPH(dest=fluid, sources=all, dim=self.dim, tol=self.tol),
                SummationDensityCRKSPH(dest=fluid, sources=all)
            ])
        equations.append(Group(equations=eq2, real=False))

        eq3 = []
        for fluid in self.fluids:
            eq3.append(
                TaitEOS(dest=fluid, sources=None, rho0=self.rho0, c0=self.c0,
                        p0=self.p0, gamma=self.gamma))
        equations.append(Group(equations=eq3, real=False))

        eq4 = []
        for fluid in self.fluids:
            eq4.extend([
                CRKSPH(dest=fluid, sources=all, dim=self.dim, tol=self.tol),
                VelocityGradient(dest=fluid, sources=all, dim=self.dim)
            ])
        equations.append(Group(equations=eq4))

        eq5 = []
        for fluid in self.fluids:
            eq5.extend([
                CRKSPHSymmetric(dest=fluid, sources=all, dim=self.dim,
                                tol=self.tol),
                MomentumEquation(
                    dest=fluid, sources=all, dim=self.dim, gx=self.gx,
                    gy=self.gy, gz=self.gz, cl=self.cl, cq=self.cq,
                    eta_crit=self.eta_crit, eta_fold=self.eta_fold
                ),
                XSPHCorrection(dest=fluid, sources=all)
            ])

            if abs(self.nu) > 1e-14:
                eq5.append(LaminarViscosity(
                    dest=fluid, sources=self.fluids, nu=self.nu
                ))
        equations.append(Group(equations=eq5))
        return equations
Example #8
0
    def create_equations(self):
        adami_equations = [
            Group(equations=[
                SummationDensity(dest='fluid', sources=['fluid', 'wall']),
                SummationDensity(dest='wall', sources=['fluid', 'wall']),
                # Density_correction(dest='wall', sources=['fluid', 'wall']),
            ]),
            Group(equations=[
                TaitEOS(dest='fluid',
                        sources=None,
                        rho0=rho1,
                        c0=c0,
                        gamma=7,
                        p0=p1),
                SolidWallPressureBCnoDensity(dest='wall', sources=['fluid']),
            ]),
            Group(equations=[
                ColorGradientAdami(dest='fluid', sources=['fluid', 'wall']),
            ]),
            Group(equations=[
                ConstructStressMatrix(
                    dest='fluid', sources=None, sigma=sigma, d=2)
            ]),
            Group(equations=[
                MomentumEquationPressureGradientAdami(
                    dest='fluid', sources=['fluid', 'wall']),
                # MomentumEquation(dest='fluid', sources=['fluid', 'wall'], c0=c0, alpha=0.0, beta=0.0, tensile_correction=True),
                MomentumEquationViscosityAdami(dest='fluid', sources=['fluid']
                                               ),
                SurfaceForceAdami(dest='fluid', sources=['fluid', 'wall']),
                SolidWallNoSlipBC(dest='fluid', sources=['wall'], nu=nu0)
            ]),
        ]

        return adami_equations
Example #9
0
 def setUp(self):
     from pysph.sph.basic_equations import SummationDensity
     from pysph.sph.wc.basic import TaitEOS
     self.group = CythonGroup(
         [SummationDensity('f', ['f']),
          TaitEOS('f', None, rho0=1.0, c0=1.0, gamma=1.4, p0=1.0)]
     )
    def create_equations(self):
        equations = [
            Group(equations=[
                LiuFluidForce(
                    dest='fluid',
                    sources=None,
                ),
                XSPHCorrection(dest='fluid', sources=[
                    'fluid',
                ]),
                TaitEOS(dest='fluid',
                        sources=None,
                        rho0=1000,
                        c0=1498,
                        gamma=7.0),
            ],
                  real=False),
            Group(equations=[
                ContinuityEquation(dest='fluid', sources=[
                    'fluid',
                ]),
                MomentumEquation(dest='fluid',
                                 sources=['fluid'],
                                 alpha=0.1,
                                 beta=0.0,
                                 c0=1498,
                                 gy=-9.81),
                XSPHCorrection(dest='fluid', sources=['fluid']),
            ]),
        ]

        return equations
Example #11
0
    def create_equations(self):
        """Set up equations.

        Body force is necessary to reset fx,fy,fz, although
        not body force is applied.
        """
        equations = [
            Group(equations=[
                BodyForce(dest='ellipsoid', sources=None),
                NumberDensity(dest='ellipsoid', sources=['ellipsoid']),
                NumberDensity(dest='walls', sources=['walls'])
            ]),

            # Tait equation of state
            Group(equations=[
                TaitEOS(dest='fluid',
                        sources=None,
                        rho0=self.rho,
                        c0=self.co,
                        gamma=7.0),
                TaitEOSHGCorrection(dest='ellipsoid',
                                    sources=None,
                                    rho0=self.rho,
                                    c0=self.co,
                                    gamma=7.0),
                TaitEOSHGCorrection(dest='walls',
                                    sources=None,
                                    rho0=self.rho,
                                    c0=self.co,
                                    gamma=7.0),
            ],
                  real=False),
            Group(equations=[
                ContinuityEquation(dest='fluid',
                                   sources=['fluid', 'walls', 'ellipsoid']),
                ContinuityEquation(dest='ellipsoid', sources=['fluid']),
                ContinuityEquation(dest='walls', sources=['fluid']),
                LaminarViscosity(
                    dest='fluid', sources=['fluid', 'walls'], nu=self.nu),
                MomentumEquation(dest='fluid',
                                 sources=['fluid', 'walls'],
                                 alpha=self.alpha,
                                 beta=0.0,
                                 c0=self.co),
                ViscosityRigidBody(dest='fluid',
                                   sources=['ellipsoid'],
                                   nu=self.nu,
                                   rho0=self.rho),
                PressureRigidBody(dest='fluid',
                                  sources=['ellipsoid'],
                                  rho0=self.rho),
                XSPHCorrection(dest='fluid', sources=['fluid']),
            ]),
            Group(
                equations=[RigidBodyMoments(dest='ellipsoid', sources=None)]),
            Group(equations=[RigidBodyMotion(dest='ellipsoid', sources=None)]),
        ]
        return equations
Example #12
0
    def create_equations(self):
        morris_equations = [
            Group(equations=[
                SummationDensitySourceMass(dest='fluid',
                                           sources=['fluid', 'wall']),
                SummationDensitySourceMass(dest='wall',
                                           sources=['fluid', 'wall']),
            ]),
            Group(equations=[
                TaitEOS(dest='fluid',
                        sources=None,
                        rho0=rho1,
                        c0=c0,
                        gamma=1,
                        p0=p1),
                SolidWallPressureBCnoDensity(
                    dest='wall', sources=['fluid'], rho0=rho1, p0=p1),
                SmoothedColor(dest='fluid', sources=['fluid', 'wall']),
                SmoothedColor(dest='wall', sources=['fluid', 'wall']),
            ]),
            Group(equations=[
                MorrisColorGradient(
                    dest='fluid', sources=['fluid', 'wall'], epsilon=epsilon),
            ]),
            Group(equations=[
                FindMaxddelta(dest='fluid', sources=None),
            ]),
            Group(equations=[
                MomentumEquationPressureGradientMorris(
                    dest='fluid', sources=['fluid', 'wall']),
                MomentumEquationViscosityMorris(dest='fluid',
                                                sources=['fluid']),
                CSFSurfaceTensionForce(
                    dest='fluid', sources=['fluid', 'wall'], sigma=sigma),
                SolidWallNoSlipBC(dest='fluid', sources=['wall'], nu=nu0)
            ]),
        ]

        return morris_equations
Example #13
0
 def create_equations(self):
     print("Create our own equations.")
     equations = [
         Group(equations=[
             TaitEOS(dest='fluid',
                     sources=None,
                     rho0=self.ro,
                     c0=self.co,
                     gamma=7.0),
         ],
               real=False),
         Group(equations=[
             ContinuityEquation(dest='fluid', sources=['fluid']),
             MomentumEquation(dest='fluid',
                              sources=['fluid'],
                              alpha=self.alpha,
                              beta=0.0,
                              c0=self.co),
             XSPHCorrection(dest='fluid', sources=['fluid']),
         ]),
     ]
     return equations
Example #14
0
 def create_equations(self):
     morris_equations = [
         Group(equations=[
             SummationDensitySourceMass(
                 dest='fluid', sources=[
                     'fluid', 'wall']),
             SummationDensitySourceMass(
                 dest='wall', sources=[
                     'fluid', 'wall']),
         ]),
         Group(equations=[
             TaitEOS(dest='fluid', sources=None, rho0=rho0, c0=c0, gamma=1, p0=0.0),
             SolidWallPressureBCnoDensity(dest='wall', sources=['fluid']),
             SmoothedColor(
                 dest='fluid', sources=[
                     'fluid', 'wall']),
             SmoothedColor(
                 dest='wall', sources=[
                     'fluid', 'wall']),
         ]),
         Group(equations=[
             MorrisColorGradient(dest='fluid', sources=['fluid', 'wall'],
                                 epsilon=epsilon),
         ]),
         Group(equations=[
             InterfaceCurvatureFromDensity(dest='fluid', sources=['fluid', 'wall'],
                                                 with_morris_correction=True),
         ]),
         Group(
             equations=[
                 # MomentumEquation(dest='fluid', sources=['fluid', 'wall'], c0=c0, tensile_correction=False, alpha=0.0, beta=0.0),
                 MomentumEquationPressureGradientMorris(dest='fluid', sources=['fluid', 'wall']),
                 MomentumEquationViscosityMorris(dest='fluid', sources=['fluid']),
                 CSFSurfaceTensionForce(
                     dest='fluid', sources=None, sigma=sigma),
                 SolidWallNoSlipBC(dest='fluid', sources=['wall'], nu=nu0)
             ]),
             ]
     return morris_equations
Example #15
0
    def create_equations(self):
        equations = [

            # Equation of state
            Group(equations=[
                TaitEOS(dest='fluid',
                        sources=None,
                        rho0=rho0,
                        c0=c0,
                        gamma=gamma),
                TaitEOSHGCorrection(dest='boundary',
                                    sources=None,
                                    rho0=rho0,
                                    c0=c0,
                                    gamma=gamma),
            ],
                  real=False),

            # Continuity Momentum and XSPH equations
            Group(equations=[
                ContinuityEquation(dest='fluid', sources=['fluid', 'boundary'
                                                          ]),
                ContinuityEquation(dest='boundary', sources=['fluid']),
                MomentumEquation(dest='fluid',
                                 sources=['fluid', 'boundary'],
                                 c0=c0,
                                 alpha=alpha,
                                 beta=beta,
                                 gz=-9.81,
                                 tensile_correction=True),

                # Position step with XSPH
                XSPHCorrection(dest='fluid', sources=['fluid'], eps=eps)
            ])
        ]
        return equations
    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.equation import Group
        from pysph.sph.wc.basic import (MomentumEquation, TaitEOS,
                                        TaitEOSHGCorrection,
                                        UpdateSmoothingLengthFerrari)
        from pysph.sph.wc.basic import (ContinuityEquationDeltaSPH,
                                        MomentumEquationDeltaSPH)
        from pysph.sph.basic_equations import \
            (ContinuityEquation, SummationDensity, XSPHCorrection)
        from pysph.sph.wc.viscosity import LaminarViscosity

        equations = []
        g1 = []
        all = self.fluids + self.solids

        if self.summation_density:
            g0 = []
            for name in self.fluids:
                g0.append(SummationDensity(dest=name, sources=all))
            equations.append(Group(equations=g0, real=False))

        for name in self.fluids:
            g1.append(
                TaitEOS(dest=name,
                        sources=None,
                        rho0=self.rho0,
                        c0=self.c0,
                        gamma=self.gamma))

        if self.hg_correction:
            # This correction applies only to solids.
            for name in self.solids:
                g1.append(
                    TaitEOSHGCorrection(dest=name,
                                        sources=None,
                                        rho0=self.rho0,
                                        c0=self.c0,
                                        gamma=self.gamma))

        equations.append(Group(equations=g1, real=False))

        g2 = []
        for name in self.solids:
            g2.append(ContinuityEquation(dest=name, sources=self.fluids))

        for name in self.fluids:
            if self.delta_sph:
                other = all[:]
                other.remove(name)
                g2.append(
                    ContinuityEquationDeltaSPH(dest=name,
                                               sources=[name],
                                               c0=self.c0,
                                               delta=self.delta))
                if len(other) > 0:
                    g2.append(ContinuityEquation(dest=name, sources=other))
                g2.append(
                    MomentumEquationDeltaSPH(
                        dest=name,
                        sources=[name],
                        rho0=self.rho0,
                        c0=self.c0,
                        alpha=self.alpha,
                        gx=self.gx,
                        gy=self.gy,
                        gz=self.gz,
                    ))
                if len(other) > 0:
                    g2.append(
                        MomentumEquation(
                            dest=name,
                            sources=other,
                            c0=self.c0,
                            alpha=self.alpha,
                            beta=self.beta,
                            gx=self.gx,
                            gy=self.gy,
                            gz=self.gz,
                            tensile_correction=self.tensile_correction))

                g2.append(XSPHCorrection(dest=name, sources=[name]))
            else:
                if not self.summation_density:
                    g2.append(ContinuityEquation(dest=name, sources=all))
                g2.extend([
                    MomentumEquation(
                        dest=name,
                        sources=all,
                        alpha=self.alpha,
                        beta=self.beta,
                        gx=self.gx,
                        gy=self.gy,
                        gz=self.gz,
                        c0=self.c0,
                        tensile_correction=self.tensile_correction),
                    XSPHCorrection(dest=name, sources=[name])
                ])

            if abs(self.nu) > 1e-14:
                eq = LaminarViscosity(dest=name,
                                      sources=self.fluids,
                                      nu=self.nu)
                g2.insert(-1, eq)
        equations.append(Group(equations=g2))

        if self.update_h:
            g3 = [
                UpdateSmoothingLengthFerrari(dest=x,
                                             sources=None,
                                             dim=self.dim,
                                             hdx=self.hdx) for x in self.fluids
            ]
            equations.append(Group(equations=g3, real=False))

        return equations
Example #18
0
def get_surface_tension_equations(fluids, solids, scheme, rho0, p0, c0, b,
                                  factor1, factor2, nu, sigma, d, epsilon,
                                  gamma, real=False):
    """
    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:
            1. TVF scheme with Morris' surface tension.
            String to be used: "tvf"
            2. Adami's surface tension implementation which doesn't involve
            calculation of curvature. String to be used: "adami_stress"
            3. Adami's surface tension implementation which involves
            calculation of curvature. String to be used: "adami"
            4. Shadloo Yildiz surface tension formulation.
            String to be used: "shadloo"
            5. 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
    """
    if scheme == 'tvf':
        result = []
        equations = []
        for i in fluids+solids:
            equations.append(SummationDensity(dest=i, sources=fluids+solids))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(StateEquation(dest=i, sources=None, rho0=rho0,
                                           p0=p0))
            equations.append(SmoothedColor(dest=i, sources=fluids+solids))
        for i in solids:
            equations.append(SolidWallPressureBCnoDensity(dest=i,
                                                          sources=fluids))
            equations.append(SmoothedColor(dest=i, sources=fluids+solids))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(MorrisColorGradient(dest=i, sources=fluids+solids,
                                                 epsilon=epsilon))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(InterfaceCurvatureFromNumberDensity(
                dest=i, sources=fluids+solids, with_morris_correction=True))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(MomentumEquationPressureGradient(dest=i,
                             sources=fluids+solids, pb=p0))
            equations.append(MomentumEquationViscosity(dest=i, sources=fluids,
                             nu=nu))
            equations.append(CSFSurfaceTensionForce(dest=i, sources=None,
                             sigma=sigma))
            equations.append(MomentumEquationArtificialStress(dest=i,
                                                              sources=fluids))
            if len(solids) != 0:
                equations.append(SolidWallNoSlipBC(dest=i, sources=solids,
                                 nu=nu))
        result.append(Group(equations))
    elif scheme == 'adami_stress':
        result = []
        equations = []
        for i in fluids+solids:
            equations.append(SummationDensity(dest=i, sources=fluids+solids))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(TaitEOS(dest=i, sources=None, rho0=rho0, c0=c0,
                             gamma=gamma, p0=p0))
        for i in solids:
            equations.append(SolidWallPressureBCnoDensity(dest=i,
                             sources=fluids))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(ColorGradientAdami(dest=i, sources=fluids+solids))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(ConstructStressMatrix(dest=i, sources=None,
                                                   sigma=sigma, d=d))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(MomentumEquationPressureGradientAdami(dest=i,
                             sources=fluids+solids))
            equations.append(MomentumEquationViscosityAdami(dest=i,
                                                            sources=fluids))
            equations.append(SurfaceForceAdami(dest=i, sources=fluids+solids))
            if len(solids) != 0:
                equations.append(SolidWallNoSlipBC(dest=i, sources=solids,
                                                   nu=nu))
        result.append(Group(equations))
    elif scheme == 'adami':
        result = []
        equations = []
        for i in fluids+solids:
            equations.append(SummationDensity(dest=i, sources=fluids+solids))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(StateEquation(dest=i, sources=None, rho0=rho0,
                                           p0=p0, b=b))
        for i in solids:
            equations.append(SolidWallPressureBCnoDensity(dest=i,
                                                          sources=fluids))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(AdamiColorGradient(dest=i, sources=fluids+solids))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(AdamiReproducingDivergence(dest=i,
                                                        sources=fluids+solids,
                                                        dim=d))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(MomentumEquationPressureGradient(
                dest=i, sources=fluids+solids, pb=0.0))
            equations.append(MomentumEquationViscosityAdami(dest=i,
                                                            sources=fluids))
            equations.append(CSFSurfaceTensionForceAdami(dest=i, sources=None))
            if len(solids) != 0:
                equations.append(SolidWallNoSlipBC(dest=i, sources=solids,
                                 nu=nu))
        result.append(Group(equations))
    elif scheme == 'shadloo':
        result = []
        equations = []
        for i in fluids+solids:
            equations.append(SummationDensity(dest=i, sources=fluids+solids))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(StateEquation(dest=i, sources=None, rho0=rho0,
                                           p0=p0, b=b))
            equations.append(SY11ColorGradient(dest=i, sources=fluids+solids))
        for i in solids:
            equations.append(SolidWallPressureBCnoDensity(dest=i,
                                                          sources=fluids))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(ScaleSmoothingLength(dest=i, sources=None,
                                                  factor=factor1))
        result.append(Group(equations, real=real, update_nnps=True))
        equations = []
        for i in fluids:
            equations.append(SY11DiracDelta(dest=i, sources=fluids+solids))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(InterfaceCurvatureFromNumberDensity(
                dest=i, sources=fluids+solids, with_morris_correction=True))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(ScaleSmoothingLength(dest=i, sources=None,
                                                  factor=factor2))
        result.append(Group(equations, real=real, update_nnps=True))
        equations = []
        for i in fluids:
            equations.append(MomentumEquationPressureGradient(
                dest=i, sources=fluids+solids, pb=0.0))
            equations.append(MomentumEquationViscosity(dest=i, sources=fluids,
                                                       nu=nu))
            equations.append(ShadlooYildizSurfaceTensionForce(dest=i,
                                                              sources=None,
                                                              sigma=sigma))
            if len(solids) != 0:
                equations.append(SolidWallNoSlipBC(dest=i, sources=solids,
                                                   nu=nu))
        result.append(Group(equations))
    else:
        result = []
        equations = []
        for i in fluids+solids:
            equations.append(SummationDensitySourceMass(dest=i,
                                                        sources=fluids+solids))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(TaitEOS(dest=i, sources=None, rho0=rho0, c0=c0,
                                     gamma=gamma, p0=0.0))
            equations.append(SmoothedColor(dest=i, sources=fluids+solids))
        for i in solids:
            equations.append(SolidWallPressureBCnoDensity(dest=i,
                                                          sources=fluids))
            equations.append(SmoothedColor(dest=i, sources=fluids+solids))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(MorrisColorGradient(dest=i, sources=fluids+solids,
                                                 epsilon=epsilon))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(InterfaceCurvatureFromDensity(
                dest=i, sources=fluids+solids, with_morris_correction=True))
        result.append(Group(equations, real=real))
        equations = []
        for i in fluids:
            equations.append(MomentumEquationPressureGradientMorris(dest=i,
                             sources=fluids+solids))
            equations.append(MomentumEquationViscosityMorris(dest=i,
                                                             sources=fluids))
            equations.append(CSFSurfaceTensionForce(dest=i, sources=None,
                                                    sigma=sigma))
            if len(solids) != 0:
                equations.append(SolidWallNoSlipBC(dest=i, sources=solids,
                                                   nu=nu))
        result.append(Group(equations))
    return result
Example #19
0
    def create_equations(self):
        morris_equations = [
            Group(equations=[
                SummationDensity(dest='fluid', sources=['fluid']),
            ],
                  real=False,
                  update_nnps=False),
            Group(
                equations=[
                    # IsothermalEOS(
                    #     dest='fluid',
                    #     sources=None,
                    #     rho0=rho1,
                    #     p0=0.0,
                    #     c0=c0),
                    TaitEOS(dest='fluid',
                            sources=None,
                            rho0=rho1,
                            c0=c0,
                            gamma=1.0,
                            p0=p1),
                    SmoothedColor(dest='fluid', sources=[
                        'fluid',
                    ]),
                    # ScaleSmoothingLength(dest='fluid', sources=None, factor=2.0/3.0),
                ],
                real=True,
                update_nnps=True),
            Group(
                equations=[
                    MorrisColorGradient(dest='fluid',
                                        sources=[
                                            'fluid',
                                        ],
                                        epsilon=epsilon),
                    # ScaleSmoothingLength(dest='fluid', sources=None, factor=1.5),
                ],
                real=False,
                update_nnps=False),
            # Group(equations=[
            #     InterfaceCurvatureFromNumberDensity(dest='fluid', sources=['fluid'],
            #                                         with_morris_correction=True),
            # ], real=False, update_nnps=False),
            Group(equations=[
                FindMaxddelta(dest='fluid', sources=None),
            ]),
            Group(equations=[
                MomentumEquationPressureGradient(dest='fluid',
                                                 sources=['fluid']),
                MomentumEquationViscosity(dest='fluid', sources=['fluid']),
            ],
                  real=False,
                  update_nnps=False),
            Group(equations=[
                CSFSurfaceTensionForce(dest='fluid', sources=['fluid']),
            ],
                  real=False,
                  update_nnps=False)
        ]

        return morris_equations
Example #20
0
    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
Example #21
0
    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
Example #22
0
    def create_equations(self):
        equations = [
            Group(equations=[
                BodyForce(dest='block', sources=None, gy=gy),
                NumberDensity(dest='block', sources=['block']),
                NumberDensity(dest='solid', sources=['solid']),
            ], ),

            # 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),
                TaitEOSHGCorrection(dest='solid',
                                    sources=None,
                                    rho0=rho0,
                                    c0=c0,
                                    gamma=gamma),
                TaitEOSHGCorrection(dest='block',
                                    sources=None,
                                    rho0=rho0,
                                    c0=c0,
                                    gamma=gamma),
            ], ),

            # Main acceleration block
            Group(equations=[

                # Continuity equation with dissipative corrections for fluid on fluid
                ContinuityEquationDeltaSPH(
                    dest='fluid', sources=['fluid'], c0=c0, delta=0.1),
                ContinuityEquation(dest='fluid', sources=['solid', 'block']),
                ContinuityEquation(dest='solid', sources=['fluid']),
                ContinuityEquation(dest='block', sources=['fluid']),

                # Momentum equation
                MomentumEquation(dest='fluid',
                                 sources=['fluid', 'solid', 'block'],
                                 alpha=alpha,
                                 beta=beta,
                                 gy=-9.81,
                                 c0=c0,
                                 tensile_correction=True),
                PressureRigidBody(dest='fluid',
                                  sources=['block', 'solid'],
                                  rho0=rho0),
                ViscosityRigidBody(
                    dest='fluid', sources=['block', 'solid'
                                           ], rho0=rho0, nu=nu),

                # Position step with XSPH
                XSPHCorrection(dest='fluid', sources=['fluid']),
                RigidBodyCollision(dest='block',
                                   sources=['solid'],
                                   k=1.0,
                                   d=2.0,
                                   eta=0.1,
                                   kt=0.1),
            ]),
            Group(equations=[RigidBodyMoments(dest='block', sources=None)]),
            Group(equations=[RigidBodyMotion(dest='block', sources=None)]),
        ]
        return equations
# Create a solver.  The damping is performed for the first 50 iterations.
solver = Solver(kernel=kernel,
                dim=dim,
                integrator=integrator,
                dt=dt,
                tf=tf,
                adaptive_timestep=True,
                n_damp=50,
                fixed_h=False)

# create the equations
equations = [

    # Equation of state
    Group(equations=[
        TaitEOS(dest='fluid', sources=None, rho0=ro, c0=co, gamma=gamma),
        TaitEOSHGCorrection(dest='boundary',
                            sources=None,
                            rho0=ro,
                            c0=co,
                            gamma=gamma),
    ],
          real=False),
    Group(equations=[

        # Continuity equation with dissipative corrections for fluid on fluid
        ContinuityEquationDeltaSPH(
            dest='fluid', sources=['fluid'], c0=co, delta=0.1),
        ContinuityEquation(dest='fluid', sources=['boundary']),
        ContinuityEquation(dest='boundary', sources=['fluid']),
Example #24
0
    def create_equations(self):
        sy11_equations = [
            Group(
                equations=[SummationDensity(dest='fluid', sources=['fluid'])],
                real=False),
            Group(equations=[
                StateEquation(dest='fluid', sources=None, rho0=rho0, p0=p0),
                SY11ColorGradient(dest='fluid', sources=['fluid'])
            ],
                  real=False),
            Group(equations=[
                ScaleSmoothingLength(dest='fluid',
                                     sources=None,
                                     factor=factor1)
            ],
                  real=False,
                  update_nnps=True),
            Group(equations=[SY11DiracDelta(dest='fluid', sources=['fluid'])],
                  real=False),
            Group(equations=[
                InterfaceCurvatureFromNumberDensity(
                    dest='fluid',
                    sources=['fluid'],
                    with_morris_correction=True),
            ],
                  real=False),
            Group(
                equations=[
                    ScaleSmoothingLength(dest='fluid',
                                         sources=None,
                                         factor=factor2)
                ],
                real=False,
                update_nnps=True,
            ),
            Group(equations=[
                MomentumEquationPressureGradient(dest='fluid',
                                                 sources=['fluid'],
                                                 pb=0.0),
                MomentumEquationViscosity(dest='fluid',
                                          sources=['fluid'],
                                          nu=nu),
                ShadlooYildizSurfaceTensionForce(dest='fluid',
                                                 sources=None,
                                                 sigma=sigma),
            ], )
        ]

        adami_equations = [
            Group(
                equations=[SummationDensity(dest='fluid', sources=['fluid'])],
                real=False),
            Group(equations=[
                StateEquation(dest='fluid', sources=None, rho0=rho0, p0=p0),
            ],
                  real=False),
            Group(equations=[
                AdamiColorGradient(dest='fluid', sources=['fluid']),
            ],
                  real=False),
            Group(equations=[
                AdamiReproducingDivergence(dest='fluid',
                                           sources=['fluid'],
                                           dim=2),
            ],
                  real=False),
            Group(equations=[
                MomentumEquationPressureGradient(dest='fluid',
                                                 sources=['fluid'],
                                                 pb=p0),
                MomentumEquationViscosityAdami(dest='fluid',
                                               sources=['fluid']),
                CSFSurfaceTensionForceAdami(
                    dest='fluid',
                    sources=None,
                )
            ], )
        ]

        adami_stress_equations = [
            Group(equations=[
                SummationDensity(dest='fluid', sources=['fluid']),
            ],
                  real=False),
            Group(equations=[
                TaitEOS(dest='fluid',
                        sources=None,
                        rho0=rho0,
                        c0=c0,
                        gamma=7,
                        p0=p0),
            ],
                  real=False),
            Group(equations=[
                ColorGradientAdami(dest='fluid', sources=['fluid']),
            ],
                  real=False),
            Group(equations=[
                ConstructStressMatrix(dest='fluid',
                                      sources=None,
                                      sigma=sigma,
                                      d=2)
            ],
                  real=False),
            Group(equations=[
                MomentumEquationPressureGradientAdami(dest='fluid',
                                                      sources=['fluid']),
                MomentumEquationViscosityAdami(dest='fluid', sources=['fluid'
                                                                      ]),
                SurfaceForceAdami(dest='fluid', sources=['fluid']),
            ]),
        ]

        tvf_equations = [
            Group(
                equations=[SummationDensity(dest='fluid', sources=['fluid'])],
                real=False),
            Group(equations=[
                StateEquation(dest='fluid', sources=None, rho0=rho0, p0=p0),
                SmoothedColor(dest='fluid', sources=['fluid']),
            ],
                  real=False),
            Group(equations=[
                MorrisColorGradient(dest='fluid',
                                    sources=['fluid'],
                                    epsilon=epsilon),
            ],
                  real=False),
            Group(equations=[
                InterfaceCurvatureFromNumberDensity(
                    dest='fluid',
                    sources=['fluid'],
                    with_morris_correction=True),
            ],
                  real=False),
            Group(equations=[
                MomentumEquationPressureGradient(dest='fluid',
                                                 sources=['fluid'],
                                                 pb=p0),
                MomentumEquationViscosity(dest='fluid',
                                          sources=['fluid'],
                                          nu=nu),
                CSFSurfaceTensionForce(dest='fluid', sources=None,
                                       sigma=sigma),
                MomentumEquationArtificialStress(dest='fluid',
                                                 sources=['fluid']),
            ], )
        ]

        morris_equations = [
            Group(equations=[
                SummationDensitySourceMass(dest='fluid', sources=['fluid']),
            ],
                  real=False,
                  update_nnps=False),
            Group(equations=[
                TaitEOS(dest='fluid',
                        sources=None,
                        rho0=rho0,
                        c0=c0,
                        gamma=1.0),
                SmoothedColor(dest='fluid', sources=[
                    'fluid',
                ]),
                ScaleSmoothingLength(dest='fluid',
                                     sources=None,
                                     factor=2.0 / 3.0),
            ],
                  real=False,
                  update_nnps=False),
            Group(equations=[
                MorrisColorGradient(dest='fluid',
                                    sources=[
                                        'fluid',
                                    ],
                                    epsilon=epsilon),
            ],
                  real=False,
                  update_nnps=False),
            Group(equations=[
                InterfaceCurvatureFromDensity(dest='fluid',
                                              sources=['fluid'],
                                              with_morris_correction=True),
                ScaleSmoothingLength(dest='fluid', sources=None, factor=1.5),
            ],
                  real=False,
                  update_nnps=False),
            Group(equations=[
                MomentumEquationPressureGradientMorris(dest='fluid',
                                                       sources=['fluid']),
                MomentumEquationViscosityMorris(dest='fluid',
                                                sources=['fluid']),
                CSFSurfaceTensionForce(dest='fluid', sources=None,
                                       sigma=sigma),
            ],
                  update_nnps=False)
        ]

        if self.options.scheme == 'tvf':
            return tvf_equations
        elif self.options.scheme == 'adami_stress':
            return adami_stress_equations
        elif self.options.scheme == 'adami':
            return adami_equations
        elif self.options.scheme == 'shadloo':
            return sy11_equations
        else:
            return morris_equations
Example #25
0
    def create_equations(self):
        h0 = dx * hdx
        co = 10.0 * self.geom.get_max_speed(g=9.81)

        gamma = 7.0
        alpha = 0.5
        beta = 0.0
        B = co * co * rho0 / gamma

        equations = [
            Group(equations=[
                BodyForce(dest='obstacle', sources=None, gz=-9.81),
                NumberDensity(dest='obstacle', sources=['obstacle']),
                NumberDensity(dest='boundary', sources=['boundary']),
            ], ),

            # Equation of state
            Group(equations=[
                TaitEOS(dest='fluid',
                        sources=None,
                        rho0=rho0,
                        c0=co,
                        gamma=gamma),
                TaitEOSHGCorrection(dest='boundary',
                                    sources=None,
                                    rho0=rho0,
                                    c0=co,
                                    gamma=gamma),
                TaitEOSHGCorrection(dest='obstacle',
                                    sources=None,
                                    rho0=rho0,
                                    c0=co,
                                    gamma=gamma),
            ],
                  real=False),

            # Continuity, momentum and xsph equations
            Group(equations=[
                ContinuityEquation(dest='fluid',
                                   sources=['fluid', 'boundary', 'obstacle']),
                ContinuityEquation(dest='boundary', sources=['fluid']),
                ContinuityEquation(dest='obstacle', sources=['fluid']),
                MomentumEquation(dest='fluid',
                                 sources=['fluid', 'boundary'],
                                 alpha=alpha,
                                 beta=beta,
                                 gz=-9.81,
                                 c0=co,
                                 tensile_correction=True),
                PressureRigidBody(dest='fluid',
                                  sources=['obstacle'],
                                  rho0=rho0),
                XSPHCorrection(dest='fluid', sources=['fluid']),
                RigidBodyCollision(dest='obstacle',
                                   sources=['boundary'],
                                   k=1.0,
                                   d=2.0,
                                   eta=0.1,
                                   kt=0.1),
            ]),
            Group(equations=[RigidBodyMoments(dest='obstacle', sources=None)]),
            Group(equations=[RigidBodyMotion(dest='obstacle', sources=None)]),
        ]
        return equations
Example #26
0
    def create_equations(self):
        # Formulation for REF1
        equations1 = [
            # Spoon Equations
            Group(
                equations=[
                    HarmonicOscilllator(dest='spoon',
                                        sources=None,
                                        A=0.5,
                                        omega=0.2),

                    # 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=1.25,
                          y=tahiniH,
                          r=0.15,
                          fill_rate=7),
                DiffuseH2O(
                    dest='tahini', sources=['tahini'], 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='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=0.5,
                                        omega=0.2),

                    # 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=Cx,
                          y=tahiniH,
                          r=0.15,
                          fill_rate=5),
                DiffuseH2O(
                    dest='tahini', sources=['tahini'], 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='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