Exemplo n.º 1
0
 def configure_scheme(self):
     scheme = self.scheme
     kernel = Gaussian(dim=2)
     tf = 0.0076
     dt = self.options.cfl * self.hdx * self.dx / (141 + self.co)
     if self.options.scheme == 'wcsph':
         scheme.configure(h0=self.hdx * self.dx)
         scheme.configure_solver(kernel=kernel,
                                 integrator_cls=EPECIntegrator,
                                 dt=dt,
                                 tf=tf,
                                 adaptive_timestep=True,
                                 cfl=0.3,
                                 n_damp=50,
                                 output_at_times=[0.0008, 0.0038])
     elif self.options.scheme == 'iisph':
         scheme.configure_solver(kernel=kernel,
                                 dt=dt,
                                 tf=tf,
                                 adaptive_timestep=True,
                                 output_at_times=[0.0008, 0.0038])
     elif self.options.scheme == 'dpsph':
         scheme.configure(hdx=self.hdx, dx=self.dx, h0=self.h0, dt=dt)
         scheme.configure_solver(tf=tf,
                                 dt=dt,
                                 output_at_times=[0.0008, 0.0038])
Exemplo n.º 2
0
    def setUp(self):
        self.l = l = 1.0
        n = 20
        dx = l / n
        hdx = 1.5

        x, y, z = G.get_3d_block(dx, l, l, l)
        h = np.ones_like(x) * hdx * dx
        m = np.ones_like(x) * dx * dx * dx
        V = np.zeros_like(x)
        fluid = get_particle_array(name='fluid', x=x, y=y, z=z, h=h, m=m, V=V)

        x, y = G.get_2d_block(dx, l, l)
        z = np.ones_like(x) * (l + 5 * dx) / 2.0
        z = np.concatenate([z, -z])
        x = np.tile(x, 2)
        y = np.tile(y, 2)
        m = np.ones_like(x) * dx * dx * dx
        h = np.ones_like(x) * hdx * dx
        V = np.zeros_like(x)
        channel = get_particle_array(name='channel',
                                     x=x,
                                     y=y,
                                     z=z,
                                     h=h,
                                     m=m,
                                     V=V)

        self.particles = [fluid, channel]
        self.kernel = get_compiled_kernel(Gaussian(dim=3))
Exemplo n.º 3
0
    def __init__(self,
                 arrays,
                 equations,
                 dim,
                 kernel=None,
                 domain_manager=None):
        """Constructor.

        Parameters
        ----------
        arrays: list(ParticleArray)
        equations: list
        dim: int
        kernel: kernel instance.
        domain_manager: DomainManager
        """
        self.arrays = arrays
        self.equations = equations
        self.domain_manager = domain_manager
        self.dim = dim
        if kernel is None:
            self.kernel = Gaussian(dim=dim)
        else:
            self.kernel = kernel

        self.func_eval = AccelerationEval(arrays, equations, self.kernel)
        compiler = SPHCompiler(self.func_eval, None)
        compiler.compile()
        self._create_nnps(arrays)
Exemplo n.º 4
0
    def configure_solver(self,
                         kernel=None,
                         integrator_cls=None,
                         extra_steppers=None,
                         **kw):

        from pysph.base.kernels import Gaussian
        if kernel is None:
            kernel = Gaussian(dim=self.dim)

        if hasattr(kernel, 'fkern'):
            self.fkern = kernel.fkern
        else:
            self.fkern = 1.0

        steppers = {}
        if extra_steppers is not None:
            steppers.update(extra_steppers)

        from pysph.sph.integrator import PECIntegrator

        cls = integrator_cls if integrator_cls is not None else PECIntegrator
        step_cls = PECStep
        for name in self.fluids:
            if name not in steppers:
                steppers[name] = step_cls()

        integrator = cls(**steppers)

        from pysph.solver.solver import Solver
        self.solver = Solver(dim=self.dim,
                             integrator=integrator,
                             kernel=kernel,
                             **kw)
Exemplo n.º 5
0
    def common_setup(self):
        # create the particle arrays
        L = 1.0
        n = 10
        dx = L / n
        hdx = 1.5
        self.L = L
        _x = np.arange(dx / 2, L, dx)
        self.vol = vol = dx * dx

        # fluid particles
        xx, yy = np.meshgrid(_x, _x)

        x = xx.ravel()
        y = yy.ravel()  # particle positions
        p = self._get_pressure(x, y, 0.0)
        h = np.ones_like(x) * hdx * dx   # smoothing lengths
        m = np.ones_like(x) * vol      # mass
        V = np.zeros_like(x)           # volumes

        fluid = get_particle_array(name='fluid', x=x, y=y, h=h, m=m, V=V, p=p)

        # particles and domain
        self.fluid = fluid
        self.domain = DomainManager(xmin=0, xmax=L, ymin=0, ymax=L,
                                    periodic_in_x=True, periodic_in_y=True,
                                    backend=self.backend
                                    )
        self.kernel = get_compiled_kernel(Gaussian(dim=2))
Exemplo n.º 6
0
    def create_solver(self):
        kernel = Gaussian(dim=2)
        #kernel = WendlandQuintic(dim=2)

        self.wdeltap = kernel.kernel(rij=dx, h=hdx * dx)

        integrator = EPECIntegrator(projectile=SolidMechStep(),
                                    plate=SolidMechStep())
        solver = Solver(kernel=kernel, dim=2, integrator=integrator)

        dt = 1e-9
        tf = 8e-6
        solver.set_time_step(dt)
        solver.set_final_time(tf)
        solver.set_print_freq(100)
        return solver
Exemplo n.º 7
0
    def __init__(self,
                 particle_arrays,
                 num_points=125000,
                 kernel=None,
                 x=None,
                 y=None,
                 z=None,
                 domain_manager=None,
                 equations=None,
                 use_shepard=True):
        """
        The x, y, z coordinates need not be specified, and if they are not,
        the bounds of the interpolated domain is automatically computed and
        `num_points` number of points are used in this domain uniformly placed.

        Parameters
        ----------

        particle_arrays: list
            A list of particle arrays.
        num_points: int
            the number of points to interpolate on to.
        kernel: Kernel
            the kernel to use for interpolation.
        x: ndarray
            the x-coordinate of points on which to interpolate.
        y: ndarray
            the y-coordinate of points on which to interpolate.
        z: ndarray
            the z-coordinate of points on which to interpolate.
        domain_manager: DomainManager
            An optional Domain manager for periodic domains.
        equations: sequence
            A sequence of equations or groups.  Defaults to None.  This is
            used only if the default interpolation equations are inadequate.
        use_shepard: bool
            Use Shepard interpolation for the interpolation when no equations
            are specified. If False, a simple SPH interpolation is performed.
        """
        self._set_particle_arrays(particle_arrays)
        bounds = get_bounding_box(self.particle_arrays)
        shape = get_nx_ny_nz(num_points, bounds)
        self.dim = 3 - list(shape).count(1)

        if kernel is None:
            self.kernel = Gaussian(dim=self.dim)
        else:
            self.kernel = kernel

        self.pa = None
        self.nnps = None
        self.equations = equations
        self.func_eval = None
        self.domain_manager = domain_manager
        self.use_shepard = use_shepard
        if x is None and y is None and z is None:
            self.set_domain(bounds, shape)
        else:
            self.set_interpolation_points(x=x, y=y, z=z)
Exemplo n.º 8
0
    def create_solver(self):
        dim = 3
        kernel = Gaussian(dim=dim)
        # kernel = WendlandQuintic(dim=dim)

        self.wdeltap = kernel.kernel(rij=dx, h=hdx * dx)

        integrator = EPECIntegrator(projectile=SolidMechStep(),
                                    plate=SolidMechStep())

        dt = 5e-10
        tf = 40e-7
        solver = Solver(kernel=kernel,
                        dim=dim,
                        integrator=integrator,
                        dt=dt,
                        tf=tf,
                        output_at_times=numpy.mgrid[0:40e-7:1e-7])

        return solver
Exemplo n.º 9
0
    def __init__(self, dim, dst, src, kernel=None):
        self.dst = dst
        self.src = src
        if kernel is None:
            self.kernel = get_compiled_kernel(Gaussian(dim))

        # create the neighbor locator object
        self.nnps = nnps = NNPS(dim=dim,
                                particles=[dst, src],
                                radius_scale=self.kernel.radius_scale)
        nnps.update()
 def create_scheme(self):
     s = WCSPHScheme(
         ['fluid'], [], dim=2, rho0=self.ro, c0=self.co,
         h0=self.dx*self.hdx, hdx=self.hdx, gamma=7.0, alpha=0.1, beta=0.0
     )
     kernel = Gaussian(dim=2)
     dt = 5e-6; tf = 0.0076
     s.configure_solver(
         kernel=kernel, integrator_cls=EPECIntegrator, dt=dt, tf=tf,
         adaptive_timestep=True, cfl=0.3, n_damp=50,
         output_at_times=[0.0008, 0.0038]
     )
     return s
Exemplo n.º 11
0
    def create_solver(self):
        dim = 3
        kernel = Gaussian(dim=dim)
        # kernel = WendlandQuintic(dim=dim)

        integrator = EPECIntegrator(projectile=SolidMechStep(),
                                    plate=SolidMechStep())
        solver = Solver(kernel=kernel, dim=dim, integrator=integrator)

        dt = 1e-9
        tf = 8e-5
        solver.set_time_step(dt)
        solver.set_final_time(tf)
        solver.set_print_freq(100)
        return solver
Exemplo n.º 12
0
    def setUp(self):
        # create the particle arrays
        L = 1.0
        n = 100
        dx = L / n
        hdx = 1.5
        _x = np.arange(dx / 2, L, dx)
        self.vol = vol = dx * dx

        # fluid particles
        xx, yy = np.meshgrid(_x, _x)

        x = xx.ravel()
        y = yy.ravel()  # particle positions
        h = np.ones_like(x) * hdx * dx  # smoothing lengths
        m = np.ones_like(x) * vol  # mass
        V = np.zeros_like(x)  # volumes

        fluid = get_particle_array(name='fluid', x=x, y=y, h=h, m=m, V=V)

        # channel particles
        _y = np.arange(L + dx / 2, L + dx / 2 + 10 * dx, dx)
        xx, yy = np.meshgrid(_x, _y)

        xtop = xx.ravel()
        ytop = yy.ravel()

        _y = np.arange(-dx / 2, -dx / 2 - 10 * dx, -dx)
        xx, yy = np.meshgrid(_x, _y)

        xbot = xx.ravel()
        ybot = yy.ravel()

        x = np.concatenate((xtop, xbot))
        y = np.concatenate((ytop, ybot))

        h = np.ones_like(x) * hdx * dx
        m = np.ones_like(x) * vol
        V = np.zeros_like(x)

        channel = get_particle_array(name='channel', x=x, y=y, h=h, m=m, V=V)

        # particles and domain
        self.particles = particles = [fluid, channel]
        self.domain = domain = DomainManager(xmin=0,
                                             xmax=L,
                                             periodic_in_x=True)
        self.kernel = get_compiled_kernel(Gaussian(dim=2))
Exemplo n.º 13
0
    def setUp(self):
        # create the particle arrays
        L = 1.0
        n = 5
        dx = L / n
        hdx = 1.5
        self.L = L
        self.vol = vol = dx * dx * dx

        # fluid particles
        xx, yy, zz = np.mgrid[dx / 2:L:dx, dx / 2:L:dx, dx / 2:L:dx]

        x = xx.ravel()
        y = yy.ravel()
        z = zz.ravel()  # particle positions
        p = self._get_pressure(x, y, z)
        h = np.ones_like(x) * hdx * dx  # smoothing lengths
        m = np.ones_like(x) * vol  # mass
        V = np.zeros_like(x)  # volumes

        fluid = get_particle_array(name='fluid',
                                   x=x,
                                   y=y,
                                   z=z,
                                   h=h,
                                   m=m,
                                   V=V,
                                   p=p)

        # particles and domain
        self.fluid = fluid
        self.domain = DomainManager(xmin=0,
                                    xmax=L,
                                    ymin=0,
                                    ymax=L,
                                    zmin=0,
                                    zmax=L,
                                    periodic_in_x=True,
                                    periodic_in_y=True,
                                    periodic_in_z=True)
        self.kernel = get_compiled_kernel(Gaussian(dim=3))

        self.orig_n = self.fluid.get_number_of_particles()
        self.nnps = LinkedListNNPS(dim=3,
                                   particles=[self.fluid],
                                   domain=self.domain,
                                   radius_scale=self.kernel.radius_scale)
    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 Gaussian
        if kernel is None:
            kernel = Gaussian(dim=self.dim)

        steppers = {}
        if extra_steppers is not None:
            steppers.update(extra_steppers)

        from pysph.sph.integrator import PECIntegrator
        from pysph.sph.integrator_step import ADKEStep

        cls = integrator_cls if integrator_cls is not None else PECIntegrator
        step_cls = ADKEStep
        for name in self.fluids:
            if name not in steppers:
                steppers[name] = step_cls()

        integrator = cls(**steppers)

        from pysph.solver.solver import Solver
        self.solver = Solver(dim=self.dim,
                             integrator=integrator,
                             kernel=kernel,
                             **kw)
Exemplo n.º 15
0
    def create_solver(self):
        print("Create our own solver.")
        kernel = Gaussian(dim=2)

        integrator = EPECIntegrator(fluid=WCSPHStep())

        dt = 5e-6
        tf = 0.0076
        solver = Solver(kernel=kernel,
                        dim=2,
                        integrator=integrator,
                        dt=dt,
                        tf=tf,
                        adaptive_timestep=True,
                        cfl=0.3,
                        n_damp=50,
                        output_at_times=[0.0008, 0.0038])

        return solver
Exemplo n.º 16
0
class TestGaussian2D(TestCubicSpline2D):
    kernel_factory = staticmethod(lambda: Gaussian(dim=2))

    def test_simple(self):
        self.check_kernel_at_origin(1.0 / np.pi)

    def test_zeroth_kernel_moments(self):
        r = self.check_kernel_moment_2d(0, 0)
        self.assertAlmostEqual(r, 1.0, 3)

    def test_first_grad_moment(self):
        r = self.check_gradient_moment_2d(1, 0)
        self.assertAlmostEqual(r[0], -1.0, 2)
        self.assertAlmostEqual(r[1], 0.0, 8)
        r = self.check_gradient_moment_2d(0, 1)
        self.assertAlmostEqual(r[0], 0.0, 8)
        self.assertAlmostEqual(r[1], -1.0, 2)
        r = self.check_gradient_moment_2d(1, 1)
        self.assertAlmostEqual(r[0], 0.0, 8)
        self.assertAlmostEqual(r[1], 0.0, 8)
Exemplo n.º 17
0
 def configure_scheme(self):
     scheme = self.scheme
     kernel = Gaussian(dim=2)
     dt = 5e-6
     tf = 0.0076
     if self.options.scheme == 'wcsph':
         scheme.configure_solver(kernel=kernel,
                                 integrator_cls=EPECIntegrator,
                                 dt=dt,
                                 tf=tf,
                                 adaptive_timestep=True,
                                 cfl=0.3,
                                 n_damp=50,
                                 output_at_times=[0.0008, 0.0038])
     elif self.options.scheme == 'iisph':
         scheme.configure_solver(kernel=kernel,
                                 dt=dt,
                                 tf=tf,
                                 adaptive_timestep=True,
                                 output_at_times=[0.0008, 0.0038])
Exemplo n.º 18
0
class TestGaussian1D(TestCubicSpline1D):
    kernel_factory = staticmethod(lambda: Gaussian(dim=1))

    def test_simple(self):
        self.check_kernel_at_origin(1.0 / np.sqrt(np.pi))

    def test_first_grad_moment(self):
        kh = self.wrapper.radius_scale
        r = self.check_grad_moment_1d(0.0, 2 * kh, 1.0, 1, xj=kh)
        self.assertAlmostEqual(r, -1.0, 3)

    def test_zeroth_kernel_moments(self):
        kh = self.wrapper.radius_scale
        # zero'th moment
        r = self.check_kernel_moment_1d(-kh, kh, 1.0, 0, xj=0)
        self.assertAlmostEqual(r, 1.0, 4)
        # Use a non-unit h.
        r = self.check_kernel_moment_1d(-kh, kh, 0.5, 0, xj=0)
        self.assertAlmostEqual(r, 1.0, 4)
        r = self.check_kernel_moment_1d(0.0, 2 * kh, 1.0, 0, xj=kh)
        self.assertAlmostEqual(r, 1.0, 4)
Exemplo n.º 19
0
    def __init__(self,
                 arrays,
                 equations,
                 dim,
                 kernel=None,
                 domain_manager=None,
                 backend=None,
                 nnps_factory=NNPS):
        """Constructor.

        Parameters
        ----------
        arrays: list(ParticleArray)
        equations: list
        dim: int
        kernel: kernel instance.
        domain_manager: DomainManager
        backend: str: indicates the backend to use.
            one of ('opencl', 'cython', '', None)
        nnps_factory: A factory that creates an NNPSBase instance.
        """
        self.arrays = arrays
        self.equations = equations
        self.domain_manager = domain_manager
        self.dim = dim
        if kernel is None:
            self.kernel = Gaussian(dim=dim)
        else:
            self.kernel = kernel

        self.nnps_factory = nnps_factory
        self.backend = backend

        self.func_eval = AccelerationEval(arrays,
                                          equations,
                                          self.kernel,
                                          backend=backend)
        compiler = SPHCompiler(self.func_eval, None)
        compiler.compile()
        self._create_nnps(arrays)
Exemplo n.º 20
0
def get_plate_particles():
    gmsh.initialize()
    gmsh.open('t.msh')
    # Launch the GUI to see the results:
    # if '-nopopup' not in sys.argv:
    #     gmsh.fltk.run()

    nodeTags, nodesCoord, parametricCoord = gmsh.model.mesh.getNodes()
    liquid_x = nodesCoord[1::3]
    liquid_y = nodesCoord[2::3]
    liquid_z = nodesCoord[0::3]
    liquid_y = liquid_y + abs(min(liquid_y))
    liquid_x = liquid_x + abs(min(liquid_x))

    liquid_x = liquid_x[0::5] * 1e-3 - 0.002
    liquid_y = liquid_y[0::5] * 1e-3 - 0.1
    liquid_z = liquid_z[0::5] * 1e-3 - 0.005

    print('%d Target particles' % len(liquid_x))

    hf = numpy.ones_like(liquid_x) * h
    mf = numpy.ones_like(liquid_x) * dx * dy * dz * ro1
    rhof = numpy.ones_like(liquid_x) * ro1
    csf = numpy.ones_like(liquid_x) * cs1
    pa = plate = get_particle_array(name="plate",
                                    x=liquid_x,
                                    y=liquid_y,
                                    z=liquid_z,
                                    h=hf,
                                    m=mf,
                                    rho=rhof,
                                    cs=csf)

    # add requisite properties
    # sound speed etc.
    add_properties(pa, 'e')

    # velocity gradient properties
    add_properties(pa, 'v00', 'v01', 'v02', 'v10', 'v11', 'v12', 'v20', 'v21',
                   'v22')

    # artificial stress properties
    add_properties(pa, 'r00', 'r01', 'r02', 'r11', 'r12', 'r22')

    # deviatoric stress components
    add_properties(pa, 's00', 's01', 's02', 's11', 's12', 's22')

    # deviatoric stress accelerations
    add_properties(pa, 'as00', 'as01', 'as02', 'as11', 'as12', 'as22')

    # 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')

    pa.add_constant('G', G1)
    pa.add_constant('n', 4)

    kernel = Gaussian(dim=3)
    wdeltap = kernel.kernel(rij=dx, h=hdx * dx)
    pa.add_constant('wdeltap', wdeltap)
    # load balancing properties
    pa.set_lb_props(list(pa.properties.keys()))

    # removed S_00 and similar components
    plate.v[:] = 0.0
    return plate
Exemplo n.º 21
0
    def __init__(self,
                 particle_arrays,
                 num_points=125000,
                 kernel=None,
                 x=None,
                 y=None,
                 z=None,
                 domain_manager=None,
                 equations=None,
                 method='shepard'):
        """
        The x, y, z coordinates need not be specified, and if they are not,
        the bounds of the interpolated domain is automatically computed and
        `num_points` number of points are used in this domain uniformly placed.

        Parameters
        ----------

        particle_arrays: list
            A list of particle arrays.
        num_points: int
            the number of points to interpolate on to.
        kernel: Kernel
            the kernel to use for interpolation.
        x: ndarray
            the x-coordinate of points on which to interpolate.
        y: ndarray
            the y-coordinate of points on which to interpolate.
        z: ndarray
            the z-coordinate of points on which to interpolate.
        domain_manager: DomainManager
            An optional Domain manager for periodic domains.
        equations: sequence
            A sequence of equations or groups.  Defaults to None.  This is
            used only if the default interpolation equations are inadequate.
        method : str
            String with the following allowed methods: 'shepard', 'sph',
            'order1'
        """
        self._set_particle_arrays(particle_arrays)
        bounds = get_bounding_box(self.particle_arrays)
        shape = get_nx_ny_nz(num_points, bounds)
        self.dim = 3 - list(shape).count(1)

        if kernel is None:
            self.kernel = Gaussian(dim=self.dim)
        else:
            self.kernel = kernel

        self.pa = None
        self.nnps = None
        self.equations = equations
        self.func_eval = None
        self.domain_manager = domain_manager
        self.method = method
        if method not in ['sph', 'shepard', 'order1']:
            raise RuntimeError('%s method is not implemented' % (method))
        if x is None and y is None and z is None:
            self.set_domain(bounds, shape)
        else:
            self.set_interpolation_points(x=x, y=y, z=z)
Exemplo n.º 22
0
def get_projectile_particles():
    x, y, z = numpy.mgrid[-r:r + 1e-6:dx, -r:r + 1e-6:dx, -r:r + 1e-6:dx]
    x = x.ravel()
    y = y.ravel()
    z = z.ravel()

    d = (x * x + y * y + z * z)
    keep = numpy.flatnonzero(d <= r * r)
    x = x[keep]
    y = y[keep]
    z = z[keep]

    x = x - (r + 2 * dx)
    print('%d Projectile particles' % len(x))

    hf = numpy.ones_like(x) * h
    mf = numpy.ones_like(x) * dx * dy * dz * ro2
    rhof = numpy.ones_like(x) * ro2
    csf = numpy.ones_like(x) * cs2
    u = numpy.ones_like(z) * v_s

    pa = projectile = get_particle_array(name="projectile",
                                         x=x,
                                         y=y,
                                         z=z,
                                         h=hf,
                                         m=mf,
                                         rho=rhof,
                                         cs=csf,
                                         u=u)

    # add requisite properties
    # sound speed etc.
    add_properties(pa, 'e')

    # velocity gradient properties
    add_properties(pa, 'v00', 'v01', 'v02', 'v10', 'v11', 'v12', 'v20', 'v21',
                   'v22')

    # artificial stress properties
    add_properties(pa, 'r00', 'r01', 'r02', 'r11', 'r12', 'r22')

    # deviatoric stress components
    add_properties(pa, 's00', 's01', 's02', 's11', 's12', 's22')

    # deviatoric stress accelerations
    add_properties(pa, 'as00', 'as01', 'as02', 'as11', 'as12', 'as22')

    # 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')

    pa.add_constant('G', G2)
    pa.add_constant('n', 4)

    kernel = Gaussian(dim=3)
    wdeltap = kernel.kernel(rij=dx, h=hdx * dx)
    pa.add_constant('wdeltap', wdeltap)

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

    return projectile
Exemplo n.º 23
0
def get_plate_particles():
    xarr = numpy.arange(0, 0.002 + dx, dx)
    yarr = numpy.arange(-0.020, 0.02 + dx, dx)
    zarr = numpy.arange(-0.02, 0.02 + dx, dx)

    x, y, z = numpy.mgrid[0:0.002 + dx:dx, -0.02:0.02 + dx:dx,
                          -0.02:0.02 + dx:dx]
    x = x.ravel()
    y = y.ravel()
    z = z.ravel()

    print('%d Target particles' % len(x))

    hf = numpy.ones_like(x) * h
    mf = numpy.ones_like(x) * dx * dy * dz * ro1
    rhof = numpy.ones_like(x) * ro1
    csf = numpy.ones_like(x) * cs1
    pa = plate = get_particle_array(name="plate",
                                    x=x,
                                    y=y,
                                    z=z,
                                    h=hf,
                                    m=mf,
                                    rho=rhof,
                                    cs=csf)

    # add requisite properties
    # sound speed etc.
    add_properties(pa, 'e')

    # velocity gradient properties
    add_properties(pa, 'v00', 'v01', 'v02', 'v10', 'v11', 'v12', 'v20', 'v21',
                   'v22')

    # artificial stress properties
    add_properties(pa, 'r00', 'r01', 'r02', 'r11', 'r12', 'r22')

    # deviatoric stress components
    add_properties(pa, 's00', 's01', 's02', 's11', 's12', 's22')

    # deviatoric stress accelerations
    add_properties(pa, 'as00', 'as01', 'as02', 'as11', 'as12', 'as22')

    # 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')

    pa.add_constant('G', G1)
    pa.add_constant('n', 4)

    kernel = Gaussian(dim=3)
    wdeltap = kernel.kernel(rij=dx, h=hdx * dx)
    pa.add_constant('wdeltap', wdeltap)
    # load balancing properties
    pa.set_lb_props(list(pa.properties.keys()))

    # removed S_00 and similar components
    plate.v[:] = 0.0
    return plate