Exemplo n.º 1
0
def main():
    # Create the application.
    app = Application()

    dim = 1
    # Create the kernel
    kernel = CubicSpline(dim=dim)

    # Create the integrator.
    integrator = EulerIntegrator(fluid=DummyStepper())

    solver = Solver(kernel=kernel, dim=dim, integrator=integrator)
    solver.set_time_step(0.1)
    solver.set_final_time(0.1)

    equations = [TotalMass(dest='fluid', sources=['fluid'])]
    app.setup(
        solver=solver, equations=equations, particle_factory=create_particles)
    # There is no need to write any output as the test below
    # computes the total mass.
    solver.set_disable_output(True)
    app.run()

    fluid = solver.particles[0]
    err = fluid.total_mass[0] - 10.0
    assert abs(err) < 1e-16, "Error: %s" % err
Exemplo n.º 2
0
class TotalMass(Equation):
    def reduce(self, dst):
        m = serial_reduce_array(dst.m, op='sum')
        dst.total_mass[0] = parallel_reduce_array(m, op='sum')


class DummyStepper(IntegratorStep):
    def initialize(self):
        pass

    def stage1(self):
        pass


# Create the application.
app = Application()

dim = 1
# Create the kernel
kernel = CubicSpline(dim=dim)

# Create the integrator.
integrator = EulerIntegrator(fluid=DummyStepper())

solver = Solver(kernel=kernel, dim=dim, integrator=integrator)
solver.set_time_step(0.1)
solver.set_final_time(0.1)

equations = [TotalMass(dest='fluid', sources=['fluid'])]
app.setup(solver=solver,
          equations=equations,
Exemplo n.º 3
0
    # deviatoric stress initial values
    add_properties(pa, 's000', 's010', 's020', 's110', 's120', 's220')

    # standard acceleration variables
    add_properties(pa, 'arho', 'au', 'av', 'aw', 'ax', 'ay', 'az', 'ae')

    # initial values
    add_properties(pa, 'rho0', 'u0', 'v0', 'w0', 'x0', 'y0', 'z0', 'e0')

    # load balancing properties
    pa.set_lb_props( pa.properties.keys() )

    return [pa,]

# create the Application
app = Application()

# kernel
kernel = CubicSpline(dim=2)
wdeltap = kernel.kernel(rij=dx, h=hdx*dx)

# integrator
integrator = PECIntegrator(solid=SolidMechStep())

# Create a solver
solver = Solver(kernel=kernel, dim=2, integrator=integrator)

# default parameters
dt = 1e-8
tf = 5e-5
solver.set_time_step(dt)
Exemplo n.º 4
0
    fluid.V[:] = 1./volume
    solid.V[:] = 1./volume

    # smoothing lengths
    fluid.h[:] = hdx * dx
    solid.h[:] = hdx * dx

    # return the particle list
    return [fluid, solid]

# domain for periodicity
domain = DomainManager(
    xmin=0, xmax=L, ymin=0, ymax=H, periodic_in_x=True,periodic_in_y=True)

# Create the application.
app = Application(domain=domain)

# Create the kernel
kernel = Gaussian(dim=2)

integrator = PECIntegrator(fluid=TransportVelocityStep())

# Create a solver.
solver = Solver(kernel=kernel, dim=2, integrator=integrator,
                dt=dt, tf=tf)

equations = [

    # 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
Exemplo n.º 5
0
ro = 1000.0

# the geometry generator
geom = DamBreak3DGeometry(
    dx=dx, nboundary_layers=nboundary_layers, hdx=hdx, rho0=ro)

h0 = dx * hdx
co = 10.0 * geom.get_max_speed(g=9.81)

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

# Create the application.
app = Application()

# Create the kernel
kernel = WendlandQuintic(dim=dim)

# Setup the integrator.
integrator = EPECIntegrator(fluid=WCSPHStep(),
                            boundary=WCSPHStep(),
                            obstacle=WCSPHStep())

# Create a solver.
solver = Solver(kernel=kernel, dim=dim, integrator=integrator, tf=tf, dt=dt,
                adaptive_timestep=True, tdamp=tf/1000.0)

# create the equations
equations = [
Exemplo n.º 6
0
    container_width=container_width, container_height=container_height,
    fluid_column_height=fluid_column_height,
    fluid_column_width=fluid_column_width, dx=dx, dy=dy,
    nboundary_layers=1, ro=ro, co=1.0,
    with_obstacle=False,
    beta=1.0, nfluid_offset=1, hdx=hdx, iisph=True)


def create_particles(**kw):
    fluid, boundary = geom.create_particles(**kw)
    boundary.x -= 0.1
    boundary.y -= 0.1
    return [fluid, boundary]

# Create the application.
app = Application()

# Create the kernel
kernel = CubicSpline(dim=2)


# Create the Integrator. Currently, PySPH supports multi-stage,
# predictor corrector and a TVD-RK3 integrators.

integrator = EulerIntegrator(fluid=IISPHStep())

# Create a solver.
solver = Solver(kernel=kernel, dim=dim, integrator=integrator,
                dt=dt, tf=tf, adaptive_timestep=True,
                fixed_h=False)
solver.set_print_freq(10)
Exemplo n.º 7
0
    # remove particles outside the circle
    indices = []
    for i in range(len(x)):
        if sqrt(x[i]*x[i] + y[i]*y[i]) - 1 > 1e-10:
            indices.append(i)

    pa = get_particle_array_iisph(x=x, y=y, m=m, rho=rho, h=h, p=p, u=u, v=v,
                                  name=name)
    pa.remove_particles(indices)

    print("Elliptical drop :: %d particles"%(pa.get_number_of_particles()))

    return [pa,]

# Create the application.
app = Application()

# Set the SPH kernel. The spline based kernels are much more efficient
#(but less accurate) than the Gaussian
kernel = CubicSpline(dim=2)

# Create the Integrator.
integrator = EulerIntegrator(fluid=IISPHStep())

# Construct the solver. Use the output_at_times list to specify instants of
# time at which the output solution is  required.
dt = 2e-4;
tf = 0.0075
solver = Solver(kernel=kernel, dim=2, integrator=integrator,
                dt=dt, tf=tf, adaptive_timestep=False,
                cfl=0.05,