Beispiel #1
0
    def setUp(self):
        """ A Dummy fluid solver is created with the following operations

        (i)  -- Equation of State
        (ii) -- Density Rate
        (iii)-- Momentum Equation Pressure Gradient
        (iv) -- Momentum Equation Viscosity 
        
        """
        self.kernel = kernel = base.CubicSplineKernel(dim=2)

        self.solver = s = solver.Solver(dim=2,
                                        integrator_type=solver.EulerIntegrator)

        s.default_kernel = kernel

        self.particles = base.Particles(arrays=[base.get_particle_array()])

        # Create some replacement operations

        self.visc = solver.SPHIntegration(sph.MorrisViscosity,
                                          on_types=[Fluids],
                                          from_types=[Fluids, Solids],
                                          updates=['u', 'v'],
                                          id='visc')

        self.summation_density = solver.SPHOperation(sph.SPHRho,
                                                     on_types=[Fluids, Solids],
                                                     updates=['rho'],
                                                     id='sd')
Beispiel #2
0
    def setUp(self):

        parrays = []

        for i in range(np):
            x = numpy.array([x0[i]])
            y = numpy.array([y0[i]])
            z = numpy.array([z0[i]])
            h = numpy.array([h0[i]])

            mi = numpy.array([m[i]])

            name = 'array' + str(i)
            pa = base.get_particle_array(name=name, x=x, y=y, z=z, h=h, m=mi)

            parrays.append(pa)

        self.parrays = parrays

        self.particles = base.Particles(arrays=parrays)

        kernel = base.CubicSplineKernel(dim=3)

        self.solver = s = solver.Solver(dim=3,
                                        integrator_type=solver.EulerIntegrator)

        # NBodyForce operation

        s.add_operation(
            solver.SPHIntegration(sph.NBodyForce.withargs(eps=eps),
                                  on_types=[Fluids],
                                  from_types=[Fluids],
                                  updates=['u', 'v', 'w'],
                                  id='nbody_force'))

        # position stepping

        s.add_operation_step([Fluids])

        # time step and final time

        s.set_final_time(tf)
        s.set_time_step(dt)

        # setup the integrator

        s.setup_integrator(self.particles)
Beispiel #3
0
#generate the boundary
l = base.Line(base.Point(-.5), 1.0, 0)
g = base.Geometry('line', [l], False)
g.mesh_geometry(dx)
boundary = g.get_particle_array(re_orient=True)

boundary.m[:] = 1.0

particles = base.Particles(arrays=[fluid, boundary])
app.particles = particles


kernel = base.HarmonicKernel(dim=2, n=3)

s = solver.Solver(dim=2, integrator_type=solver.PredictorCorrectorIntegrator)

# set the kernel as the default for the solver

s.default_kernel = kernel

#Tait equation
s.add_operation(solver.SPHOperation(
        
        sph.TaitEquation.withargs(co=25.0, ro=1.0), 
        on_types=[Fluid], 
        updates=['p','cs'],
        id='eos', kernel=kernel)

                )
Beispiel #4
0
                                rho=rhof,
                                v=vf,
                                cf=cf)

boundary = base.get_particle_array(name="boundary",
                                   type=1,
                                   x=xb,
                                   y=yb,
                                   h=hb,
                                   m=mb,
                                   rho=rhob)

particles = base.Particles(arrays=[boundary, fluid])
app.particles = particles

s = solver.Solver(dim=2, integrator_type=solver.EulerIntegrator)

#Equation of state
s.add_operation(
    solver.SPHOperation(sph.TaitEquation.withargs(co=25.0, ro=1.0),
                        on_types=[Fluid, Solid],
                        updates=['p', 'cs'],
                        id='eos'))

#Continuity equation
s.add_operation(
    solver.SPHIntegration(sph.SPHDensityRate.withargs(),
                          from_types=[Fluid, Solid],
                          on_types=[Fluid, Solid],
                          updates=['rho'],
                          id='density'))
Beispiel #5
0
    fluid1 = get_fluid_particles(name="fluid1")

    fluid2 = get_fluid_particles(name="fluid2")
    fluid2.x = width - fluid2.x

    return [fluid1, fluid2, boundary]


app = solver.Application()
app.process_command_line()

particles = app.create_particles(variable_h=False, callable=get_particles)

kernel = base.HarmonicKernel(dim=2, n=3)
s = solver.Solver(dim=2, integrator_type=solver.RK2Integrator)

s.default_kernel = kernel

#Equation of state
s.add_operation(
    solver.SPHOperation(sph.TaitEquation.withargs(co=co, ro=ro),
                        on_types=[Fluid, Solid],
                        updates=['p', 'cs'],
                        id='eos'))

#Continuity equation
s.add_operation(
    solver.SPHIntegration(sph.SPHDensityRate.withargs(),
                          on_types=[Fluid, Solid],
                          from_types=[Fluid, Solid],
Beispiel #6
0
    def setUp(self):
        """ A simple simulation in 2D with boundary particles spaced with a
        distance dp. The fluid particles are in a row just above as shown
        in the fgure. 

                   dx
                  o   o   o   o   o
            x x x x x x x x x x x x x x x  

        Y
        |  Z
        | /
        |/___ X
            

        Expected Behavior:
        -------------------
        The Monaghan Boundary force is defned such that a particle moving 
        parallel to the wall experiences a constant force.
        Each fluid particle can be thought of successive instances of a 
        moving particle and hence each of them should experience the same
        force.

        """

        #fluid particle spacing
        self.dx = dx = 0.1

        #solid particle spacing
        self.dp = dp = 0.05

        #the fluid properties
        xf = numpy.array([-.2, -.1, 0.0, 0.1, 0.2])
        yf = numpy.array([dp, dp, dp, dp, dp])
        hf = numpy.ones_like(xf) * 2 * dx
        mf = numpy.ones_like(xf) * dx
        cs = numpy.ones_like(xf)
        rhof = numpy.ones_like(xf)

        self.fluid = base.get_particle_array(x=xf,
                                             y=yf,
                                             h=hf,
                                             m=mf,
                                             rho=rhof,
                                             cs=cs,
                                             ax=mf,
                                             ay=mf,
                                             az=mf,
                                             name='fluid',
                                             type=Fluid)

        l = base.Line(base.Point(-0.35), 0.70, 0.0)
        g = base.Geometry('line', lines=[l], is_closed=False)
        g.mesh_geometry(dp)
        self.solid = g.get_particle_array(re_orient=True)

        self.particles = particles = base.Particles(
            arrays=[self.fluid, self.solid])

        self.kernel = kernel = base.CubicSplineKernel(dim=2)

        self.solver = solver.Solver(kernel.dim, solver.EulerIntegrator)

        self.solver.add_operation(
            solver.SPHIntegration(sph.MonaghanBoundaryForce.withargs(delp=dp),
                                  from_types=[Solid],
                                  on_types=[Fluid],
                                  updates=['u', 'v', 'w'],
                                  id='boundary'))

        self.solver.setup_integrator(particles)

        self.integrator = self.solver.integrator