Example #1
0
    def create_solver(self):
        kernel = WendlandQuintic(dim=2)
        self.wdeltap = kernel.kernel(rij=dx, h=hdx * dx)

        integrator = PECIntegrator(bar=SolidMechStep())

        solver = Solver(kernel=kernel, dim=2, integrator=integrator)
        dt = 1e-9
        tf = 2.5e-5
        solver.set_time_step(dt)
        solver.set_final_time(tf)
        return solver
Example #2
0
 def create_scheme(self):
     s = WCSPHScheme(['fluid'], ['top_wall', 'bottom_wall'],
                     dim=3,
                     rho0=rho0,
                     c0=co,
                     h0=dx * hdx,
                     hdx=hdx,
                     gamma=7.0,
                     alpha=0.5,
                     beta=0.0,
                     nu=mu / rho0,
                     tensile_correction=True)
     kernel = WendlandQuintic(dim=3)
     dt_cfl = 0.25 * (hdx * dx) / co
     dt_viscous = 0.125 * (hdx * dx)**2 * rho0 / mu
     print("CFL based time step: %.3E" % dt_cfl)
     print("Viscous time step:   %.3E" % dt_viscous)
     dt = min(dt_cfl, dt_viscous)
     s.configure_solver(kernel=kernel,
                        integrator_cls=EPECIntegrator,
                        tf=tf,
                        dt=dt,
                        adaptive_timestep=True,
                        n_damp=50,
                        pfreq=200)
     return s
Example #3
0
    def configure_scheme(self):
        tf = 2.5
        kw = dict(tf=tf, output_at_times=[0.4, 0.6, 0.8, 1.0])
        if self.options.scheme == 'wcsph':
            self.scheme.configure(h0=self.h, hdx=self.hdx)
            kernel = WendlandQuintic(dim=2)
            from pysph.sph.integrator import EPECIntegrator
            kw.update(
                dict(integrator_cls=EPECIntegrator,
                     kernel=kernel,
                     adaptive_timestep=True,
                     n_damp=50,
                     fixed_h=False))
        elif self.options.scheme == 'aha':
            self.scheme.configure(h0=self.h)
            kernel = QuinticSpline(dim=2)
            dt = 0.125 * self.h / co
            kw.update(dict(kernel=kernel, dt=dt))
            print("dt = %f" % dt)
        elif self.options.scheme == 'edac':
            self.scheme.configure(h=self.h)
            kernel = QuinticSpline(dim=2)
            dt = 0.125 * self.h / co
            kw.update(dict(kernel=kernel, dt=dt))
            print("dt = %f" % dt)

        self.scheme.configure_solver(**kw)
Example #4
0
 def create_solver(self):
     kernel = WendlandQuintic(dim=2)
     integrator = PECIntegrator(fluid=TransportVelocityStep())
     solver = Solver(
         kernel=kernel, dim=dim, integrator=integrator,
         dt=dt, tf=tf, adaptive_timestep=False)
     return solver
Example #5
0
class TestWendlandQuintic2D(TestCubicSpline2D):
    kernel_factory = staticmethod(lambda: WendlandQuintic(dim=2))

    def test_simple(self):
        self.check_kernel_at_origin(7.0 / (4.0 * np.pi))

    def test_zeroth_kernel_moments(self):
        r = self.check_kernel_moment_2d(0, 0)
        self.assertAlmostEqual(r, 1.0, 6)
Example #6
0
    def create_solver(self):
        kernel = WendlandQuintic(dim=dim)

        integrator = EPECIntegrator(fluid=WCSPHStep(),
                                    obstacle=RK2StepRigidBody(),
                                    boundary=WCSPHStep())
        solver = Solver(kernel=kernel, dim=dim, integrator=integrator,
                        tf=tf, dt=dt, adaptive_timestep=True, n_damp=0)
        return solver
Example #7
0
 def create_solver(self):
     kernel = WendlandQuintic(dim=2)
     integrator = PECIntegrator(fluid=VerletSymplecticWCSPHStep())
     solver = Solver(kernel=kernel,
                     dim=dim,
                     integrator=integrator,
                     dt=dt,
                     tf=tf,
                     adaptive_timestep=False)
     return solver
Example #8
0
    def create_particles(self):
        bar = get_bar_particles()
        plate = get_plate_particles()

        # add requisite properties

        # velocity gradient for the bar
        for name in ('v00', 'v01', 'v02', 'v10', 'v11', 'v12', 'v20', 'v21',
                     'v22'):
            bar.add_property(name)

        # deviatoric stress components
        for name in ('s00', 's01', 's02', 's11', 's12', 's22'):
            bar.add_property(name)

        # deviatoric stress accelerations
        for name in ('as00', 'as01', 'as02', 'as11', 'as12', 'as22'):
            bar.add_property(name)

        # deviatoric stress initial values
        for name in ('s000', 's010', 's020', 's110', 's120', 's220'):
            bar.add_property(name)

        bar.add_property('e0')

        # artificial stress properties
        for name in ('r00', 'r01', 'r02', 'r11', 'r12', 'r22'):
            bar.add_property(name)

        # standard acceleration variables and initial values.
        for name in ('arho', 'au', 'av', 'aw', 'ax', 'ay', 'az', 'ae', 'rho0',
                     'u0', 'v0', 'w0', 'x0', 'y0', 'z0', 'e0'):
            bar.add_property(name)

        bar.add_constant('G', G)
        bar.add_constant('n', 4)

        kernel = WendlandQuintic(dim=2)
        wdeltap = kernel.kernel(rij=dx, h=hdx * dx)
        bar.add_constant('wdeltap', wdeltap)

        return [bar, plate]
Example #9
0
 def configure_scheme(self):
     self.scheme.configure(h0=self.h, hdx=self.hdx)
     kernel = WendlandQuintic(dim=2)
     tf = 2.5
     from pysph.sph.integrator import EPECIntegrator
     self.scheme.configure_solver(kernel=kernel,
                                  integrator_cls=EPECIntegrator,
                                  tf=tf,
                                  adaptive_timestep=True,
                                  n_damp=50,
                                  fixed_h=False,
                                  output_at_times=[0.4, 0.6, 0.8, 1.0])
Example #10
0
 def create_scheme(self):
     s = WCSPHScheme(
         ['fluid'], ['boundary'], dim=dim, rho0=ro, c0=self.co,
         h0=h0, hdx=hdx, gz=-9.81, alpha=alpha, beta=beta, gamma=gamma,
         hg_correction=True, tensile_correction=True
     )
     kernel = WendlandQuintic(dim=dim)
     s.configure_solver(
         kernel=kernel, integrator_cls=EPECIntegrator, tf=tf, dt=dt,
         adaptive_timestep=True, n_damp=50
     )
     return s
Example #11
0
    def create_solver(self):
        kernel = WendlandQuintic(dim=2)

        integrator = EPECIntegrator(fluid=WCSPHStep(),
                                    block=RK2StepRigidBody())
        solver = Solver(kernel=kernel,
                        dim=2,
                        integrator=integrator,
                        tf=tf,
                        dt=dt,
                        adaptive_timestep=False)
        return solver
Example #12
0
    def create_solver(self):
        '''
        Define solver
        '''
        kernel = WendlandQuintic(dim=2)
        
        integrator = EulerIntegrator_DPSPH(fluid = EulerStep_DPSPH())

        solver = Solver(
            kernel=kernel, dim=2, integrator=integrator, dt=self.dt, tf=self.tf, 
            pfreq=100
        )

        return solver
Example #13
0
 def configure_scheme(self):
     s = self.scheme
     hdx = self.hdx
     kernel = WendlandQuintic(dim=dim)
     h0 = self.dx * hdx
     s.configure(h0=h0, hdx=hdx)
     dt = 0.25 * h0 / (1.1 * self.co)
     s.configure_solver(kernel=kernel,
                        integrator_cls=EPECIntegrator,
                        tf=tf,
                        dt=dt,
                        adaptive_timestep=True,
                        n_damp=50,
                        output_at_times=[0.4, 0.6, 1.0])
Example #14
0
    def create_solver(self):
        '''
        Define solver
        '''
        kernel = WendlandQuintic(dim=2)

        #integrator = PECIntegrator(fluid = DPSPHStep())
        integrator = RK4Integrator(fluid=RK4Step())

        solver = Solver(kernel=kernel,
                        dim=2,
                        integrator=integrator,
                        dt=self.dt,
                        tf=self.tf,
                        pfreq=50)

        return solver
Example #15
0
    def configure_solver(self,
                         kernel=None,
                         integrator_cls=None,
                         extra_steppers=None,
                         **kw):
        """Configure the solver to be generated.

        Parameters
        ----------

        kernel : Kernel instance.
            Kernel to use, if none is passed a default one is used.
        integrator_cls : pysph.sph.integrator.Integrator
            Integrator class to use, use sensible default if none is
            passed.
        extra_steppers : dict
            Additional integration stepper instances as a dict.
        **kw : extra arguments
            Any additional keyword args are passed to the solver instance.
        """
        from pysph.base.kernels import WendlandQuintic
        if kernel is None:
            kernel = WendlandQuintic(dim=self.dim)
        steppers = {}
        if extra_steppers is not None:
            steppers.update(extra_steppers)

        step_cls = GTVFStep
        for fluid in self.fluids:
            if fluid not in steppers:
                steppers[fluid] = step_cls()

        if integrator_cls is not None:
            cls = integrator_cls
            print("Warning: GTVF Integrator is not being used.")
        else:
            cls = GTVFIntegrator
        integrator = cls(**steppers)

        from pysph.solver.solver import Solver
        self.solver = Solver(dim=self.dim,
                             integrator=integrator,
                             kernel=kernel,
                             **kw)
Example #16
0
    def create_solver(self):
        '''
        Define solver
        '''
        kernel = WendlandQuintic(dim=2)

        if self.INT == 'eul':
            integrator = EulerIntegrator(fluid=EulerStep())
        elif self.INT == 'rk4':
            integrator = RK4Integrator(fluid=RK4Step())
        else:
            raise Exception('Invalid integrator argument')

        solver = Solver(kernel=kernel,
                        dim=2,
                        integrator=integrator,
                        dt=self.dt,
                        tf=self.tf,
                        pfreq=self.pfreq)

        return solver
Example #17
0
    def configure_solver(self, kernel=None, integrator_cls=None,
                         extra_steppers=None, **kw):
        from pysph.base.kernels import WendlandQuintic
        from pysph.solver.solver import Solver

        if kernel is None:
            kernel = WendlandQuintic(dim=self.dim)
        steppers = {}
        if extra_steppers is not None:
            steppers.update(extra_steppers)

        step_cls = RK4Step
        for fluid in self.fluids:
            if fluid not in steppers:
                steppers[fluid] = step_cls()

        cls = integrator_cls if integrator_cls is not None else RK4Integrator
        integrator = cls(**steppers)

        if 'dt' not in kw:
            kw['dt'] = self.get_timestep()
        self.solver = Solver(
            dim=self.dim, integrator=integrator, kernel=kernel, **kw
        )
Example #18
0
    # artificial stress properties
    for name in ('r00', 'r01', 'r11'):
        bar.add_property(name)

    # standard acceleration variables and initial values.
    for name in ('arho', 'au', 'av', 'aw', 'ax', 'ay', 'az', 'ae',
                 'rho0', 'u0', 'v0', 'w0', 'x0', 'y0', 'z0', 'e0'):
        bar.add_property(name)

    return [bar, plate]

# create the Application
app = Application()

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

# integrator
integrator = PECIntegrator(bar=SolidMechStep())

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

# default parameters
dt = 1e-9
tf = 2.5e-5
solver.set_time_step(dt)
solver.set_final_time(tf)

# add the equations
Example #19
0
class TestWendlandQuintic3D(TestGaussian3D):
    kernel_factory = staticmethod(lambda: WendlandQuintic(dim=3))

    def test_simple(self):
        self.check_kernel_at_origin(21.0 / (16.0 * np.pi))
Example #20
0
    def configure_scheme(self):
        tf = 2.5
        kw = dict(
            tf=tf, output_at_times=[0.4, 0.6, 0.8, 1.0]
        )
        if self.options.scheme == 'wcsph':
            dt = 0.125 * self.h / co
            self.scheme.configure(h0=self.h, hdx=self.hdx)
            kernel = WendlandQuintic(dim=2)
            from pysph.sph.integrator import PECIntegrator
            kw.update(
                dict(
                    integrator_cls=PECIntegrator,
                    kernel=kernel, adaptive_timestep=True, n_damp=50,
                    fixed_h=False, dt=dt
                )
            )
        elif self.options.scheme == 'aha':
            self.scheme.configure(h0=self.h)
            kernel = QuinticSpline(dim=2)
            dt = 0.125 * self.h / co
            kw.update(
                dict(
                    kernel=kernel, dt=dt
                )
            )
            print("dt = %f" % dt)
        elif self.options.scheme == 'edac':
            self.scheme.configure(h=self.h)
            kernel = QuinticSpline(dim=2)
            dt = 0.125 * self.h / co
            kw.update(
                dict(
                    kernel=kernel, dt=dt
                )
            )
            print("dt = %f" % dt)
        elif self.options.scheme == 'iisph':
            kernel = QuinticSpline(dim=2)
            dt = 0.125 * 10 * self.h / co
            kw.update(
                dict(
                    kernel=kernel, dt=dt, adaptive_timestep=True
                )
            )
            print("dt = %f" % dt)
        elif self.options.scheme == 'gtvf':
            scheme = self.scheme
            kernel = QuinticSpline(dim=2)
            dt = 0.125 * self.h / co
            kw.update(dict(kernel=kernel, dt=dt))
            scheme.configure(pref=B*gamma, h0=self.h)
            print("dt = %f" % dt)
        elif self.options.scheme == 'sisph':
            dt = 0.125*self.h/vref
            kernel = QuinticSpline(dim=2)
            print("SISPH dt = %f" % dt)
            kw.update(dict(kernel=kernel))
            self.scheme.configure_solver(
                dt=dt, tf=tf, adaptive_timestep=False, pfreq=10,
            )

        self.scheme.configure_solver(**kw)
dx = 0.01; dxb2 = 0.5 * dx
h0 = 1.3*dx

# Uniform lattice distribution of particles
#x, y, dx, dy, xmin, xmax, ymin, ymax = uniform_distribution_cubic2D(
#    dx, xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0)

# Uniform hexagonal close packing arrangement of particles
x, y, dx, dy, xmin, xmax, ymin, ymax = uniform_distribution_hcp2D(
    dx, xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0, adjust=True)

# SPH kernel
#k = CubicSpline(dim=2)
#k = Gaussian(dim=2)
#k = QuinticSpline(dim=2)
k = WendlandQuintic(dim=2)

# for the hexagonal particle spacing, dx*dy is only an approximate
# expression for the particle volume. As far as the summation density
# test is concerned, the value will be uniform but not equal to 1. To
# reproduce a density profile of 1, we need to estimate the kernel sum
# or number density of the distribution based on the kernel
wij_sum_estimate = get_number_density_hcp(dx, dy, k, h0)
volume = 1./wij_sum_estimate
print 'Volume estimates :: dx^2 = %g, Number density = %g'%(dx*dy, volume)

x = x.ravel(); y = y.ravel()
h = numpy.ones_like(x) * h0
m = numpy.ones_like(x) * volume
wij = numpy.zeros_like(x)
                          fluid_column_width=fluid_column_width,
                          dx=dx,
                          dy=dy,
                          nboundary_layers=1,
                          ro=ro,
                          co=co,
                          with_obstacle=False,
                          beta=2.0,
                          nfluid_offset=1,
                          hdx=hdx)

# Create the application.
app = Application()

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

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

integrator = EPECIntegrator(fluid=WCSPHStep(), boundary=WCSPHStep())

# Create a solver.  The damping is performed for the first 50 iterations.
solver = Solver(kernel=kernel,
                dim=dim,
                integrator=integrator,
                dt=dt,
                tf=tf,
                adaptive_timestep=True,
                n_damp=50,
                fixed_h=False)
Example #23
0
#x, y, dx, dy, xmin, xmax, ymin, ymax = uniform_distribution_cubic2D(
#    dx, xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0)

# Uniform hexagonal close packing arrangement of particles
x, y, dx, dy, xmin, xmax, ymin, ymax = uniform_distribution_hcp2D(dx,
                                                                  xmin=0.0,
                                                                  xmax=1.0,
                                                                  ymin=0.0,
                                                                  ymax=1.0,
                                                                  adjust=True)

# SPH kernel
#k = CubicSpline(dim=2)
#k = Gaussian(dim=2)
#k = QuinticSpline(dim=2)
k = WendlandQuintic(dim=2)

# for the hexagonal particle spacing, dx*dy is only an approximate
# expression for the particle volume. As far as the summation density
# test is concerned, the value will be uniform but not equal to 1. To
# reproduce a density profile of 1, we need to estimate the kernel sum
# or number density of the distribution based on the kernel
wij_sum_estimate = get_number_density_hcp(dx, dy, k, h0)
volume = 1. / wij_sum_estimate
print('Volume estimates :: dx^2 = %g, Number density = %g' % (dx * dy, volume))

x = x.ravel()
y = y.ravel()
h = numpy.ones_like(x) * h0
m = numpy.ones_like(x) * volume
wij = numpy.zeros_like(x)