Exemplo n.º 1
0
    def create_equations(self):
        '''
        Set-up governing equations
        '''

        equations = [
            Group(equations=[
                IsothermalEOS(dest='fluid',
                              sources=['fluid'],
                              rho0=self.rho0,
                              c0=self.c0,
                              p0=0.0),
                GradientCorrectionPreStep(dest='fluid',
                                          sources=['fluid'],
                                          dim=2),
            ],
                  real=False),
            Group(
                equations=[
                    GradientCorrection(dest='fluid',
                                       sources=['fluid'],
                                       dim=2,
                                       tol=0.1),
                    ContinuityEquationDeltaSPHPreStep(dest='fluid',
                                                      sources=['fluid']),
                    #PST_PreStep_1(dest='fluid', sources=['fluid'], dim=2, boundedFlow=self.PST_boundedFlow),
                    #PST_PreStep_2(dest='fluid', sources=['fluid'], dim=2, H=self.h0, boundedFlow=self.PST_boundedFlow),
                ],
                real=False),
            Group(
                equations=[
                    PST(dest='fluid',
                        sources=['fluid'],
                        H=self.h0,
                        dt=self.dt,
                        dx=self.dx,
                        Uc0=self.PST_Uc0,
                        Rh=self.PSR_Rh,
                        boundedFlow=self.PST_boundedFlow),
                    ContinuityEquation(dest='fluid', sources=['fluid']),
                    ContinuityEquationDeltaSPH(dest='fluid',
                                               sources=['fluid'],
                                               c0=self.c0,
                                               delta=0.1),
                    LaminarViscosityDeltaSPHPreStep(dest='fluid',
                                                    sources=['fluid']),
                    #LaminarViscosity(dest='fluid', sources=['fluid'], nu=self.nu),
                    LaminarViscosityDeltaSPH(dest='fluid',
                                             sources=['fluid'],
                                             dim=2,
                                             rho0=self.rho0,
                                             nu=self.nu),
                    Spatial_Acceleration(dest='fluid', sources=['fluid']),
                ],
                real=True),
        ]

        return equations
Exemplo n.º 2
0
    def get_equations(self):
        all = self.fluids + self.solids
        
        stage0 = []
        eq1 = []
        if self.solids:
            for solid in self.solids:
                eq1.append(EvaluateNumberDensity(dest=solid, sources=self.fluids))

        for fluid in self.fluids:
            eq1.append(GradientCorrectionPreStep(dest=fluid, sources=all, dim=self.dim))
            eq1.append(GradientCorrection(dest=fluid, sources=all, dim=self.dim))
            eq1.append(ContinuityEquationDeltaSPHPreStep(dest=fluid, sources=all))
        stage0.append(Group(equations=eq1, real=False))

        eq2 = []    
        for fluid in self.fluids:
            eq2.append(ContinuityEquation(dest=fluid, sources=all))
            eq2.append(ContinuityEquationDeltaSPH(dest=fluid, sources=all, c0=self.c0))
        stage0.append(Group(equations=eq2, real=False))

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

        if self.solids:
            eq4 = []
            for solid in self.solids:
                eq4.append(SetWallVelocity(dest=solid, sources=self.fluids))
                eq4.append(SetPressureSolid(dest=solid, sources=self.fluids, rho0=self.rho0, p0=self.p0))
            stage0.append(Group(equations=eq4, real=False))

        eq5 = []
        for fluid in self.fluids:
            eq5.append(LaminarViscosityDeltaSPHPreStep(dest=fluid, sources=self.fluids))
            eq5.append(LaminarViscosityDeltaSPH(dest=fluid, sources=self.fluids, dim=self.dim, rho0=self.rho0, nu=self.nu))
            if self.solids:
                eq5.append(SolidWallNoSlipBC(dest=fluid, sources=self.solids, nu=self.nu))
            eq5.append(Spatial_Acceleration(dest=fluid, sources=self.fluids))
        stage0.append(Group(equations=eq5, real=True))

        stage1 = []
        eq6 = []
        for fluid in self.fluids:
            eq6.append(GradientCorrectionPreStep(dest=fluid, sources=all, dim=self.dim))
            eq6.append(GradientCorrection(dest=fluid, sources=all, dim=self.dim))
            eq6.append(PST_PreStep_1(dest=fluid, sources=all, dim=self.dim, boundedFlow=self.boundedFlow))
            eq6.append(PST_PreStep_2(dest=fluid, sources=all, boundedFlow=self.boundedFlow))
        stage1.append(Group(equations=eq6, real=False))

        eq7 = []
        for fluid in self.fluids:
            eq7.append(PST(dest=fluid, sources=all, h=self.h0, dt=self.dt, dx=self.dx, c0=self.c0, boundedFlow=self.boundedFlow, gamma=self.gamma))
        stage1.append(Group(equations=eq7, real=False))

        return MultiStageEquations([stage0,stage1])
Exemplo n.º 3
0
    def create_equations(self):
        # Formulation for REF1
        # (using only first set of equations for simplicity)
        equations = [


            # 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=[
                TaitEOSHGCorrectionVariableRho(dest='fluid', sources=None,  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
Exemplo n.º 4
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
Exemplo n.º 5
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
    def create_equations(self):
        '''
        Set-up governing equations
        '''
        if self.PST == False:
            equations = [
                Group(equations=[
                    IsothermalEOS(dest='fluid', sources=['fluid'], rho0=self.rho0, c0=self.c0, p0=0.0),
                    GradientCorrectionPreStep(dest='fluid', sources=['fluid'], dim=2),
                ],real=False
                ),

                Group(equations=[
                    GradientCorrection(dest='fluid', sources=['fluid'], dim=2, tol=0.1), 
                    ContinuityEquationDeltaSPHPreStep(dest='fluid', sources=['fluid']),
                ],real=True
                ),

                Group(equations=[
                    ContinuityEquation(dest='fluid', sources=['fluid']),                 
                    ContinuityEquationDeltaSPH(dest='fluid', sources=['fluid'], c0=self.c0, delta=0.1), 
                    MomentumEquation(dest='fluid', sources=['fluid'], c0=self.c0, alpha=0.0, beta=0.0, gx=0.0, gy=0.0, gz=0.0, tensile_correction=False), 
                    #MomentumEquationDeltaSPH(dest='fluid', sources=['fluid'], rho0=self.rho0, c0=self.c0, alpha=0.0), 
                    #LaminarViscosityDeltaSPHPreStep(dest='fluid', sources=['fluid']),
                    LaminarViscosityDeltaSPH(dest='fluid', sources=['fluid'], dim=2, rho0=self.rho0, nu=self.nu), 
                    Spatial_Acceleration(dest='fluid', sources=['fluid']),                
                    #XSPHCorrection(dest='fluid', sources=['fluid'], eps=0.5),            
                ],real=True
                ),
            ]
    
        elif self.PST == True:
            equations = [
                Group(equations=[                
                    IsothermalEOS(dest='fluid', sources=['fluid'], rho0=self.rho0, c0=self.c0, p0=0.0),
                    GradientCorrectionPreStep(dest='fluid', sources=['fluid'], dim=2),
                    PST_PreStep_1(dest='fluid', sources=['fluid'], dim=2),
                    ######AverageSpacing(dest='fluid', sources=['fluid'], dim=2),            
                ],real=False
                ),

                Group(equations=[
                    GradientCorrection(dest='fluid', sources=['fluid'], dim=2, tol=0.1), 
                    ContinuityEquationDeltaSPHPreStep(dest='fluid', sources=['fluid']),
                    PST_PreStep_2(dest='fluid', sources=['fluid'], dim=2, H=self.h0),
                    PST(dest='fluid', sources=['fluid'], dim=2, H=self.h0, dt=self.dt, dx=self.dx, Uc0=self.PST_Uc0, Rh=self.PSR_Rh, saveAllDRh=True, R_coeff=self.PST_R_coeff, n_exp=self.PST_n_exp),            
                ],real=True
                ),

                Group(equations=[
                    ContinuityEquation(dest='fluid', sources=['fluid']),                 
                    ContinuityEquationDeltaSPH(dest='fluid', sources=['fluid'], c0=self.c0, delta=0.1), 
                    MomentumEquation(dest='fluid', sources=['fluid'], c0=self.c0, alpha=0.0, beta=0.0, gx=0.0, gy=0.0, gz=0.0, tensile_correction=False), 
                    #MomentumEquationDeltaSPH(dest='fluid', sources=['fluid'], rho0=self.rho0, c0=self.c0, alpha=0.0), 
                    #LaminarViscosityDeltaSPHPreStep(dest='fluid', sources=['fluid']),
                    LaminarViscosityDeltaSPH(dest='fluid', sources=['fluid'], dim=2, rho0=self.rho0, nu=self.nu), 
                    Spatial_Acceleration(dest='fluid', sources=['fluid']),                
                    #XSPHCorrection(dest='fluid', sources=['fluid'], eps=0.5),            
                ],real=True
                ),
            ]

        return equations