Exemple #1
0
 def create_equations(self):
     morris_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']),
         ], )
     ]
     return morris_equations
Exemple #2
0
    def _get_internal_flow_equations(self):
        from pysph.sph.wc.transport_velocity import (
            VolumeSummation, SolidWallNoSlipBC, SummationDensity,
            MomentumEquationArtificialStress,
            MomentumEquationArtificialViscosity, MomentumEquationViscosity)
        edac_nu = self._get_edac_nu()

        iom = self.inlet_outlet_manager
        fluids_with_io = self.fluids
        all_solids = self.solids + self.inviscid_solids
        if iom is not None:
            fluids_with_io = self.fluids + iom.get_io_names()
        all = fluids_with_io + all_solids

        equations = []
        # inlet-outlet
        if iom is not None:
            io_eqns = iom.get_equations(self)
            for grp in io_eqns:
                equations.append(grp)

        group1 = []
        avg_p_group = []
        has_solids = len(all_solids) > 0
        for fluid in fluids_with_io:
            group1.append(SummationDensity(dest=fluid, sources=all))
            if self.bql:
                eq = ComputeAveragePressure(dest=fluid, sources=all)
                if has_solids:
                    avg_p_group.append(eq)
                else:
                    group1.append(eq)

        for solid in self.solids:
            group1.extend([
                SourceNumberDensity(dest=solid, sources=fluids_with_io),
                VolumeSummation(dest=solid, sources=all),
                SolidWallPressureBC(dest=solid,
                                    sources=fluids_with_io,
                                    gx=self.gx,
                                    gy=self.gy,
                                    gz=self.gz),
                SetWallVelocity(dest=solid, sources=fluids_with_io),
            ])
        for solid in self.inviscid_solids:
            group1.extend([
                SourceNumberDensity(dest=solid, sources=fluids_with_io),
                NoSlipVelocityExtrapolation(dest=solid,
                                            sources=fluids_with_io),
                NoSlipAdvVelocityExtrapolation(dest=solid,
                                               sources=fluids_with_io),
                VolumeSummation(dest=solid, sources=all),
                SolidWallPressureBC(dest=solid,
                                    sources=fluids_with_io,
                                    gx=self.gx,
                                    gy=self.gy,
                                    gz=self.gz)
            ])

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

        # Compute average pressure *after* the wall pressure is setup.
        if self.bql and has_solids:
            equations.append(Group(equations=avg_p_group, real=True))

        group2 = []
        for fluid in self.fluids:
            group2.append(
                MomentumEquationPressureGradient(dest=fluid,
                                                 sources=all,
                                                 pb=self.pb,
                                                 gx=self.gx,
                                                 gy=self.gy,
                                                 gz=self.gz,
                                                 tdamp=self.tdamp))
            if self.alpha > 0.0:
                sources = fluids_with_io + self.solids
                group2.append(
                    MomentumEquationArtificialViscosity(dest=fluid,
                                                        sources=sources,
                                                        alpha=self.alpha,
                                                        c0=self.c0))
            if self.nu > 0.0:
                group2.append(
                    MomentumEquationViscosity(dest=fluid,
                                              sources=fluids_with_io,
                                              nu=self.nu))
            if len(self.solids) > 0 and self.nu > 0.0:
                group2.append(
                    SolidWallNoSlipBC(dest=fluid,
                                      sources=self.solids,
                                      nu=self.nu))
            group2.extend([
                MomentumEquationArtificialStress(dest=fluid,
                                                 sources=fluids_with_io),
                EDACEquation(dest=fluid,
                             sources=all,
                             nu=edac_nu,
                             cs=self.c0,
                             rho0=self.rho0),
            ])
        equations.append(Group(equations=group2))

        print(equations)
        return equations
Exemple #3
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
Exemple #4
0
    def create_equations(self):
        tvf_equations = [

            # We first compute the mass and number density of the fluid
            # phase. This is used in all force computations henceforth. The
            # number density (1/volume) is explicitly set for the solid phase
            # and this isn't modified for the simulation.
            Group(equations=[
                SummationDensity(dest='fluid', sources=['fluid', 'wall'])
            ]),

            # Given the updated number density for the fluid, we can update
            # the fluid pressure. Additionally, we can extrapolate the fluid
            # velocity to the wall for the no-slip boundary
            # condition. Also compute the smoothed color based on the color
            # index for a particle.
            Group(equations=[
                StateEquation(
                    dest='fluid', sources=None, rho0=rho0, p0=p0, b=1.0),
                SetWallVelocity(dest='wall', sources=['fluid']),
                SmoothedColor(dest='fluid', sources=['fluid']),
            ]),

            #################################################################
            # Begin Surface tension formulation
            #################################################################
            # Scale the smoothing lengths to determine the interface
            # quantities. The NNPS need not be updated since the smoothing
            # length is decreased.
            Group(equations=[
                ScaleSmoothingLength(dest='fluid', sources=None, factor=0.8)
            ],
                  update_nnps=False),

            # Compute the gradient of the color function with respect to the
            # new smoothing length. At the end of this Group, we will have the
            # interface normals and the discretized dirac delta function for
            # the fluid-fluid interface.
            Group(equations=[
                ColorGradientUsingNumberDensity(dest='fluid',
                                                sources=['fluid', 'wall'],
                                                epsilon=0.01 / h0),
            ], ),

            # Compute the interface curvature using the modified smoothing
            # length and interface normals computed in the previous Group.
            Group(equations=[
                InterfaceCurvatureFromNumberDensity(
                    dest='fluid',
                    sources=['fluid'],
                    with_morris_correction=True),
            ], ),

            # Now rescale the smoothing length to the original value for the
            # rest of the computations.
            Group(
                equations=[
                    ScaleSmoothingLength(dest='fluid',
                                         sources=None,
                                         factor=1.25)
                ],
                update_nnps=False,
            ),
            #################################################################
            # End Surface tension formulation
            #################################################################

            # Once the pressure for the fluid phase has been updated via the
            # state-equation, we can extrapolate the pressure to the wall
            # ghost particles. After this group, the density and pressure of
            # the boundary particles has been updated and can be used in the
            # integration equations.
            Group(equations=[
                SolidWallPressureBC(dest='wall',
                                    sources=['fluid'],
                                    p0=p0,
                                    rho0=rho0,
                                    gy=gy),
            ], ),

            # The main acceleration block
            Group(
                equations=[

                    # Gradient of pressure for the fluid phase using the
                    # number density formulation. No penetration boundary
                    # condition using Adami et al's generalized wall boundary
                    # condition. The extrapolated pressure and density on the
                    # wall particles is used in the gradient of pressure to
                    # simulate a repulsive force.
                    MomentumEquationPressureGradient(dest='fluid',
                                                     sources=['fluid', 'wall'],
                                                     pb=p0,
                                                     gy=gy),

                    # Artificial viscosity for the fluid phase.
                    MomentumEquationViscosity(dest='fluid',
                                              sources=['fluid'],
                                              nu=nu),

                    # No-slip boundary condition using Adami et al's
                    # generalized wall boundary condition. This equation
                    # basically computes the viscous contribution on the fluid
                    # from the wall particles.
                    SolidWallNoSlipBC(dest='fluid', sources=['wall'], nu=nu),

                    # Surface tension force for the SY11 formulation
                    ShadlooYildizSurfaceTensionForce(dest='fluid',
                                                     sources=None,
                                                     sigma=sigma),

                    # Artificial stress for the fluid phase
                    MomentumEquationArtificialStress(dest='fluid',
                                                     sources=['fluid']),
                ], )
        ]
        return tvf_equations
    def get_equations(self):
        from pysph.sph.equation import Group
        from pysph.sph.wc.transport_velocity import (
            SummationDensity, StateEquation, MomentumEquationPressureGradient,
            MomentumEquationArtificialViscosity, MomentumEquationViscosity,
            MomentumEquationArtificialStress, SolidWallPressureBC,
            SolidWallNoSlipBC, SetWallVelocity)
        equations = []
        all = self.fluids + self.solids
        g1 = []
        for fluid in self.fluids:
            g1.append(SummationDensity(dest=fluid, sources=all))

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

        g2 = []
        for fluid in self.fluids:
            g2.append(
                StateEquation(dest=fluid,
                              sources=None,
                              p0=self.p0,
                              rho0=self.rho0,
                              b=1.0))
        for solid in self.solids:
            g2.append(SetWallVelocity(dest=solid, sources=self.fluids))

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

        g3 = []
        for solid in self.solids:
            g3.append(
                SolidWallPressureBC(dest=solid,
                                    sources=self.fluids,
                                    b=1.0,
                                    rho0=self.rho0,
                                    p0=self.p0,
                                    gx=self.gx,
                                    gy=self.gy,
                                    gz=self.gz))

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

        g4 = []
        for fluid in self.fluids:
            g4.append(
                MomentumEquationPressureGradient(dest=fluid,
                                                 sources=all,
                                                 pb=self.pb,
                                                 gx=self.gx,
                                                 gy=self.gy,
                                                 gz=self.gz,
                                                 tdamp=self.tdamp))
            if self.alpha > 0.0:
                g4.append(
                    MomentumEquationArtificialViscosity(dest=fluid,
                                                        sources=all,
                                                        c0=self.c0,
                                                        alpha=self.alpha))
            if self.nu > 0.0:
                g4.append(
                    MomentumEquationViscosity(dest=fluid,
                                              sources=self.fluids,
                                              nu=self.nu))
                if len(self.solids) > 0:
                    g4.append(
                        SolidWallNoSlipBC(dest=fluid,
                                          sources=self.solids,
                                          nu=self.nu))

            g4.append(
                MomentumEquationArtificialStress(dest=fluid,
                                                 sources=self.fluids))

        equations.append(Group(equations=g4))
        return equations
Exemple #6
0
    def _get_internal_flow_equations(self):
        from pysph.sph.wc.transport_velocity import (
            VolumeSummation, SolidWallNoSlipBC, SummationDensity,
            MomentumEquationArtificialStress,
            MomentumEquationArtificialViscosity, MomentumEquationViscosity)
        edac_nu = self._get_edac_nu()
        all = self.fluids + self.solids
        equations = []
        group1 = []
        avg_p_group = []
        has_solids = len(self.solids) > 0
        for fluid in self.fluids:
            group1.append(SummationDensity(dest=fluid, sources=all))
            if self.bql:
                eq = ComputeAveragePressure(dest=fluid, sources=all)
                if has_solids:
                    avg_p_group.append(eq)
                else:
                    group1.append(eq)

        for solid in self.solids:
            group1.extend([
                VolumeSummation(dest=solid, sources=all),
                SolidWallPressureBC(dest=solid,
                                    sources=self.fluids,
                                    gx=self.gx,
                                    gy=self.gy,
                                    gz=self.gz),
                SetWallVelocity(dest=solid, sources=self.fluids),
            ])

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

        # Compute average pressure *after* the wall pressure is setup.
        if self.bql and has_solids:
            equations.append(Group(equations=avg_p_group, real=True))

        group2 = []
        for fluid in self.fluids:
            group2.append(
                MomentumEquationPressureGradient(dest=fluid,
                                                 sources=all,
                                                 pb=self.pb,
                                                 gx=self.gx,
                                                 gy=self.gy,
                                                 gz=self.gz,
                                                 tdamp=self.tdamp))
            if self.alpha > 0.0:
                group2.append(
                    MomentumEquationArtificialViscosity(dest=fluid,
                                                        sources=all,
                                                        alpha=self.alpha,
                                                        c0=self.c0))
            if self.nu > 0.0:
                group2.append(
                    MomentumEquationViscosity(dest=fluid,
                                              sources=self.fluids,
                                              nu=self.nu))
            if len(self.solids) > 0 and self.nu > 0.0:
                group2.append(
                    SolidWallNoSlipBC(dest=fluid,
                                      sources=self.solids,
                                      nu=self.nu))
            group2.extend([
                MomentumEquationArtificialStress(dest=fluid,
                                                 sources=self.fluids),
                EDACEquation(dest=fluid,
                             sources=all,
                             nu=edac_nu,
                             cs=self.c0,
                             rho0=self.rho0),
            ])
        equations.append(Group(equations=group2))

        return equations
Exemple #7
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
Exemple #8
0
    def create_equations(self):
        equations = [

            # We first compute the mass and number density of the fluid
            # phase. This is used in all force computations henceforth. The
            # number density (1/volume) is explicitly set for the solid phase
            # and this isn't modified for the simulation.
            Group(equations=[
                SummationDensity(dest='fluid', sources=['fluid']),
            ]),

            # Given the updated number density for the fluid, we can update
            # the fluid pressure. Also compute the smoothed color based on the
            # color index for a particle.
            Group(equations=[
                StateEquation(
                    dest='fluid', sources=None, rho0=rho0, p0=p0, b=1.0),
                SmoothedColor(dest='fluid', sources=['fluid']),
            ]),

            #################################################################
            # Begin Surface tension formulation
            #################################################################
            # Scale the smoothing lengths to determine the interface
            # quantities.
            Group(equations=[
                ScaleSmoothingLength(dest='fluid',
                                     sources=None,
                                     factor=factor1)
            ],
                  update_nnps=False),

            # Compute the gradient of the color function with respect to the
            # new smoothing length. At the end of this Group, we will have the
            # interface normals and the discretized dirac delta function for
            # the fluid-fluid interface.
            Group(
                equations=[
                    MorrisColorGradient(dest='fluid',
                                        sources=['fluid'],
                                        epsilon=0.01 / h0),
                    # ColorGradientUsingNumberDensity(dest='fluid',sources=['fluid'],
                    #                                epsilon=epsilon),
                    # AdamiColorGradient(dest='fluid', sources=['fluid']),
                ], ),

            # Compute the interface curvature using the modified smoothing
            # length and interface normals computed in the previous Group.
            Group(
                equations=[
                    InterfaceCurvatureFromNumberDensity(
                        dest='fluid',
                        sources=['fluid'],
                        with_morris_correction=True),
                    # AdamiReproducingDivergence(dest='fluid',sources=['fluid'],
                    #                           dim=2),
                ], ),

            # Now rescale the smoothing length to the original value for the
            # rest of the computations.
            Group(
                equations=[
                    ScaleSmoothingLength(dest='fluid',
                                         sources=None,
                                         factor=factor2)
                ],
                update_nnps=False,
            ),
            #################################################################
            # End Surface tension formulation
            #################################################################

            # The main acceleration block
            Group(
                equations=[

                    # Gradient of pressure for the fluid phase using the
                    # number density formulation.
                    MomentumEquationPressureGradient(dest='fluid',
                                                     sources=['fluid'],
                                                     pb=p0),

                    # Artificial viscosity for the fluid phase.
                    MomentumEquationViscosity(dest='fluid',
                                              sources=['fluid'],
                                              nu=nu),

                    # Surface tension force for the SY11 formulation
                    ShadlooYildizSurfaceTensionForce(dest='fluid',
                                                     sources=None,
                                                     sigma=sigma),

                    # Artificial stress for the fluid phase
                    MomentumEquationArtificialStress(dest='fluid',
                                                     sources=['fluid']),
                ], )
        ]
        return equations
Exemple #9
0
    def create_equations(self):
        equations = [

            # set the acceleration for the obstacle using the special function
            # mimicking the accelerations provided in the test.
            Group(equations=[
                SPHERICBenchmarkAcceleration(dest='obstacle', sources=None),
            ],
                  real=False),

            # Summation density along with volume summation for the fluid
            # phase. This is done for all local and remote particles. At the
            # end of this group, the fluid phase has the correct density
            # taking into consideration the fluid and solid
            # particles.
            Group(equations=[
                SummationDensity(dest='fluid',
                                 sources=['fluid', 'solid', 'obstacle']),
            ],
                  real=False),

            # Once the fluid density is computed, we can use the EOS to set
            # the fluid pressure. Additionally, the dummy velocity for the
            # channel is set, which is later used in the no-slip wall BC.
            Group(equations=[
                StateEquation(dest='fluid',
                              sources=None,
                              p0=p0,
                              rho0=rho0,
                              b=1.0),
                SetWallVelocity(dest='solid', sources=['fluid']),
                SetWallVelocity(dest='obstacle', sources=['fluid']),
            ],
                  real=False),

            # Once the pressure for the fluid phase has been updated, we can
            # extrapolate the pressure to the ghost particles. After this
            # group, the fluid density, pressure and the boundary pressure has
            # been updated and can be used in the integration equations.
            Group(equations=[
                SolidWallPressureBC(dest='obstacle',
                                    sources=['fluid'],
                                    b=1.0,
                                    rho0=rho0,
                                    p0=p0),
                SolidWallPressureBC(dest='solid',
                                    sources=['fluid'],
                                    b=1.0,
                                    rho0=rho0,
                                    p0=p0),
            ],
                  real=False),

            # The main accelerations block. The acceleration arrays for the
            # fluid phase are upadted in this stage for all local particles.
            Group(
                equations=[
                    # Pressure gradient terms
                    MomentumEquationPressureGradient(
                        dest='fluid',
                        sources=['fluid', 'solid', 'obstacle'],
                        pb=p0),

                    # fluid viscosity
                    MomentumEquationViscosity(dest='fluid',
                                              sources=['fluid'],
                                              nu=nu),

                    # No-slip boundary condition. This is effectively a
                    # viscous interaction of the fluid with the ghost
                    # particles.
                    SolidWallNoSlipBC(dest='fluid',
                                      sources=['solid', 'obstacle'],
                                      nu=nu),

                    # Artificial stress for the fluid phase
                    MomentumEquationArtificialStress(dest='fluid',
                                                     sources=['fluid']),
                ],
                real=True),
        ]
        return equations
Exemple #10
0
    def create_equations(self):
        sy11_equations = [
            # We first compute the mass and number density of the fluid
            # phase. This is used in all force computations henceforth. The
            # number density (1/volume) is explicitly set for the solid phase
            # and this isn't modified for the simulation.
            Group(
                equations=[SummationDensity(dest='fluid', sources=['fluid'])]),

            # Given the updated number density for the fluid, we can update
            # the fluid pressure. Additionally, we can compute the Shepard
            # Filtered velocity required for the no-penetration boundary
            # condition. Also compute the gradient of the color function to
            # compute the normal at the interface.
            Group(equations=[
                StateEquation(dest='fluid', sources=None, rho0=rho0, p0=p0),
                SY11ColorGradient(dest='fluid', sources=['fluid'])
            ]),

            #################################################################
            # Begin Surface tension formulation
            #################################################################
            # Scale the smoothing lengths to determine the interface
            # quantities.
            Group(equations=[
                ScaleSmoothingLength(dest='fluid',
                                     sources=None,
                                     factor=factor1)
            ],
                  update_nnps=False),

            # Compute the discretized dirac delta with respect to the new
            # smoothing length.
            Group(equations=[SY11DiracDelta(dest='fluid',
                                            sources=['fluid'])], ),

            # Compute the interface curvature using the modified smoothing
            # length and interface normals computed in the previous Group.
            Group(equations=[
                InterfaceCurvatureFromNumberDensity(
                    dest='fluid',
                    sources=['fluid'],
                    with_morris_correction=True),
            ], ),

            # Now rescale the smoothing length to the original value for the
            # rest of the computations.
            Group(
                equations=[
                    ScaleSmoothingLength(dest='fluid',
                                         sources=None,
                                         factor=factor2)
                ],
                update_nnps=False,
            ),
            #################################################################
            # End Surface tension formulation
            #################################################################

            # The main acceleration block
            Group(
                equations=[

                    # Gradient of pressure for the fluid phase using the
                    # number density formulation. No penetration boundary
                    # condition using Adami et al's generalized wall boundary
                    # condition. The extrapolated pressure and density on the
                    # wall particles is used in the gradient of pressure to
                    # simulate a repulsive force.
                    MomentumEquationPressureGradient(dest='fluid',
                                                     sources=['fluid'],
                                                     pb=p0),

                    # Artificial viscosity for the fluid phase.
                    MomentumEquationViscosity(dest='fluid',
                                              sources=['fluid'],
                                              nu=nu),

                    # Surface tension force for the SY11 formulation
                    ShadlooYildizSurfaceTensionForce(dest='fluid',
                                                     sources=None,
                                                     sigma=sigma),

                    # Artificial stress for the fluid phase
                    MomentumEquationArtificialStress(dest='fluid',
                                                     sources=['fluid']),
                ], )
        ]

        morris_equations = [

            # We first compute the mass and number density of the fluid
            # phase. This is used in all force computations henceforth. The
            # number density (1/volume) is explicitly set for the solid phase
            # and this isn't modified for the simulation.
            Group(
                equations=[SummationDensity(dest='fluid', sources=['fluid'])]),

            # Given the updated number density for the fluid, we can update
            # the fluid pressure. Additionally, we can compute the Shepard
            # Filtered velocity required for the no-penetration boundary
            # condition. Also compute the smoothed color based on the color
            # index for a particle.
            Group(equations=[
                StateEquation(dest='fluid', sources=None, rho0=rho0, p0=p0),
                SmoothedColor(dest='fluid', sources=['fluid'], smooth=True),
            ]),

            #################################################################
            # Begin Surface tension formulation
            #################################################################
            # Compute the gradient of the smoothed color field. At the end of
            # this Group, we will have the interface normals and the
            # discretized dirac delta function for the fluid-fluid interface.
            Group(equations=[
                MorrisColorGradient(dest='fluid',
                                    sources=['fluid'],
                                    epsilon=epsilon),
            ], ),

            # Compute the interface curvature computed in the previous Group.
            Group(equations=[
                InterfaceCurvatureFromNumberDensity(
                    dest='fluid',
                    sources=['fluid'],
                    with_morris_correction=True),
            ], ),
            #################################################################
            # End Surface tension formulation
            #################################################################

            # The main acceleration block
            Group(
                equations=[

                    # Gradient of pressure for the fluid phase
                    MomentumEquationPressureGradient(dest='fluid',
                                                     sources=['fluid'],
                                                     pb=p0),

                    # Artificial viscosity for the fluid phase.
                    MomentumEquationViscosity(dest='fluid',
                                              sources=['fluid'],
                                              nu=nu),

                    # Surface tension force for the Morris formulation
                    CSFSurfaceTensionForce(dest='fluid',
                                           sources=None,
                                           sigma=sigma),

                    # Artificial stress for the fluid phase
                    MomentumEquationArtificialStress(dest='fluid',
                                                     sources=['fluid']),
                ], )
        ]

        adami_equations = [

            # We first compute the mass and number density of the fluid
            # phase. This is used in all force computations henceforth. The
            # number density (1/volume) is explicitly set for the solid phase
            # and this isn't modified for the simulation.
            Group(
                equations=[SummationDensity(dest='fluid', sources=['fluid'])]),

            # Given the updated number density for the fluid, we can update
            # the fluid pressure. Additionally, we can compute the Shepard
            # Filtered velocity required for the no-penetration boundary
            # condition.
            Group(equations=[
                StateEquation(dest='fluid', sources=None, rho0=rho0, p0=p0),
            ]),

            #################################################################
            # Begin Surface tension formulation
            #################################################################
            # Compute the gradient of the color field.
            Group(equations=[
                AdamiColorGradient(dest='fluid', sources=['fluid']),
            ], ),

            # Compute the interface curvature using the color gradients
            # computed in the previous Group.
            Group(equations=[
                AdamiReproducingDivergence(dest='fluid',
                                           sources=['fluid'],
                                           dim=2),
            ], ),
            #################################################################
            # End Surface tension formulation
            #################################################################

            # The main acceleration block
            Group(
                equations=[

                    # Gradient of pressure for the fluid phase
                    MomentumEquationPressureGradient(dest='fluid',
                                                     sources=['fluid'],
                                                     pb=p0),

                    # Artificial viscosity for the fluid phase.
                    MomentumEquationViscosity(dest='fluid',
                                              sources=['fluid'],
                                              nu=nu),

                    # Surface tension force for the CSF formulation
                    CSFSurfaceTensionForce(dest='fluid',
                                           sources=None,
                                           sigma=sigma),

                    # Artificial stress for the fluid phase
                    MomentumEquationArtificialStress(dest='fluid',
                                                     sources=['fluid']),
                ], )
        ]

        if self.options.scheme == 'morris':
            return morris_equations
        elif self.options.scheme == 'adami':
            return adami_equations
        else:
            return sy11_equations