示例#1
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
 def create_equations(self):
     equations = [
         Group(equations=[
             BodyForce(dest='cube', sources=None, gy=-9.81),
             SummationDensity(dest='cube', sources=['fluid', 'cube'])
         ],
               real=False),
         Group(equations=[
             TaitEOSHGCorrection(dest='cube',
                                 sources=None,
                                 rho0=self.solid_rho,
                                 c0=self.co,
                                 gamma=7.0),
             TaitEOSHGCorrection(dest='fluid',
                                 sources=None,
                                 rho0=self.ro,
                                 c0=self.co,
                                 gamma=7.0),
             TaitEOSHGCorrection(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', 'cube'],
                              alpha=self.alpha,
                              beta=0.0,
                              c0=self.co,
                              gy=-9.81),
             LiuFluidForce(
                 dest='fluid',
                 sources=['cube'],
             ),
             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
示例#3
0
    def create_equations(self):
        equations = [
            Group(equations=[
                BodyForce(dest='cube', sources=None, gy=-9.81),
            ],
                  real=False),
            Group(equations=[
                ContinuityEquation(dest='fluid',
                                   sources=['fluid', 'tank', 'cube']),
                ContinuityEquation(dest='tank',
                                   sources=['tank', 'fluid', 'cube'])
            ]),

            # Tait equation of state
            Group(equations=[
                TaitEOSHGCorrection(dest='fluid',
                                    sources=None,
                                    rho0=self.ro,
                                    c0=self.co,
                                    gamma=7.0),
                TaitEOSHGCorrection(dest='tank',
                                    sources=None,
                                    rho0=self.ro,
                                    c0=self.co,
                                    gamma=7.0),
            ],
                  real=False),
            Group(equations=[
                MomentumEquation(dest='fluid',
                                 sources=['fluid', 'tank'],
                                 alpha=self.alpha,
                                 beta=0.0,
                                 c0=self.co,
                                 gy=-9.81),
                AkinciRigidFluidCoupling(dest='fluid', sources=['cube']),
                XSPHCorrection(dest='fluid', sources=['fluid', 'tank']),
            ]),
            Group(equations=[
                RigidBodyCollision(
                    dest='cube', sources=['tank', 'cube'], kn=1e5)
            ]),
            Group(equations=[RigidBodyMoments(dest='cube', sources=None)]),
            Group(equations=[RigidBodyMotion(dest='cube', sources=None)]),
        ]
        return equations
示例#4
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
示例#5
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
    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
示例#7
0
 def create_equations(self):
     equations = [
         Group(
             equations=[
                 BodyForce(dest='cube', sources=None, gy=-9.81),
                 BodyForce(dest='wood', sources=None, gy=-9.81),
                 BodyForce(dest='small_tank', sources=None, gy=-9.81),
                 BodyForce(dest='outside', sources=None, gy=-9.81),
                 SummationDensity(dest='cube', sources=['fluid', 'cube']),
                 SummationDensity(dest='wood', sources=['fluid', 'wood']),
                 SummationDensity(dest='small_tank',
                                  sources=['fluid', 'small_tank']),
                 SummationDensity(dest='outside',
                                  sources=['fluid', 'outside'])
                 # NumberDensity(dest='cube', sources=['cube']),
             ],
             real=False),
         Group(equations=[
             TaitEOSHGCorrection(dest='wood',
                                 sources=None,
                                 rho0=self.wood_rho,
                                 c0=self.co,
                                 gamma=7.0),
             TaitEOSHGCorrection(dest='cube',
                                 sources=None,
                                 rho0=self.solid_rho,
                                 c0=self.co,
                                 gamma=7.0),
             TaitEOSHGCorrection(dest='fluid',
                                 sources=None,
                                 rho0=self.ro,
                                 c0=self.co,
                                 gamma=7.0),
             TaitEOSHGCorrection(dest='big_tank',
                                 sources=None,
                                 rho0=self.ro,
                                 c0=self.co,
                                 gamma=7.0),
             TaitEOSHGCorrection(dest='small_tank',
                                 sources=None,
                                 rho0=self.wood_rho,
                                 c0=self.co,
                                 gamma=7.0),
             TaitEOSHGCorrection(dest='outside',
                                 sources=None,
                                 rho0=self.ro,
                                 c0=self.co,
                                 gamma=7.0),
         ],
               real=False),
         Group(equations=[
             ContinuityEquation(
                 dest='fluid',
                 sources=[
                     'fluid', 'small_tank', 'cube', 'wood', 'big_tank',
                     'outside'
                 ],
             ),
             ContinuityEquation(
                 dest='big_tank',
                 sources=[
                     'fluid', 'big_tank', 'cube', 'wood', 'small_tank',
                     'outside'
                 ],
             ),
             MomentumEquation(dest='fluid',
                              sources=['fluid', 'big_tank'],
                              alpha=self.alpha,
                              beta=0.0,
                              c0=self.co,
                              gy=-9.81),
             LiuFluidForce(
                 dest='fluid',
                 sources=['cube'],
             ),
             LiuFluidForce(
                 dest='fluid',
                 sources=['wood'],
             ),
             LiuFluidForce(
                 dest='fluid',
                 sources=['small_tank'],
             ),
             LiuFluidForce(
                 dest='fluid',
                 sources=['outside'],
             ),
             # PressureRigidBody(dest='fluid', sources=['cube'],
             #                   rho0=1500),
             XSPHCorrection(dest='fluid', sources=['fluid', 'big_tank']),
         ]),
         Group(equations=[
             RigidBodyCollision(
                 dest='cube',
                 sources=['big_tank', 'wood', 'small_tank', 'outside'],
                 kn=1e6)
         ]),
         Group(equations=[RigidBodyMoments(dest='cube', sources=None)]),
         Group(equations=[RigidBodyMotion(dest='cube', sources=None)]),
         Group(equations=[
             RigidBodyCollision(
                 dest='wood',
                 sources=['big_tank', 'cube', 'small_tank', 'outside'],
                 kn=1e6)
         ]),
         Group(equations=[RigidBodyMoments(dest='wood', sources=None)]),
         Group(equations=[RigidBodyMotion(dest='wood', sources=None)]),
         Group(equations=[
             RigidBodyCollision(
                 dest='small_tank',
                 sources=['big_tank', 'cube', 'wood', 'outside'],
                 kn=1e6)
         ]),
         Group(
             equations=[RigidBodyMoments(dest='small_tank', sources=None)]),
         Group(
             equations=[RigidBodyMotion(dest='small_tank', sources=None)]),
         Group(equations=[
             RigidBodyCollision(
                 dest='outside',
                 sources=['big_tank', 'cube', 'small_tank', 'wood'],
                 kn=1e6)
         ]),
         Group(equations=[RigidBodyMoments(dest='outside', sources=None)]),
         Group(equations=[RigidBodyMotion(dest='outside', sources=None)]),
     ]
     return equations
示例#8
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
                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']),

        # Momentum equation
        MomentumEquation(dest='fluid',
                         sources=['fluid', 'boundary'],
示例#10
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