def create_solver(self): kernel = CubicSpline(dim=2) self.wdeltap = kernel.kernel(rij=dx, h=hdx * dx) integrator = PECIntegrator(solid=SolidMechStep()) solver = Solver(kernel=kernel, dim=2, integrator=integrator) dt = 1e-8 tf = 5e-5 solver.set_time_step(dt) solver.set_final_time(tf) solver.set_print_freq(500) return solver
def create_solver(self): dim = 3 kernel = CubicSpline(dim=dim) # kernel = WendlandQuintic(dim=dim) self.wdeltap = kernel.kernel(rij=dx, h=hdx * dx) integrator = EPECIntegrator(fluid=WCSPHStep()) solver = Solver(kernel=kernel, dim=dim, 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
def create_particles(self): spacing = self.spacing # spacing = 2*5cm x, y = numpy.mgrid[-self.ro:self.ro:self.dx, -self.ro:self.ro:self.dx] x = x.ravel() y = y.ravel() d = (x * x + y * y) ro = self.ro ri = self.ri keep = numpy.flatnonzero((ri * ri <= d) * (d < ro * ro)) x = x[keep] y = y[keep] x = numpy.concatenate([x - spacing, x + spacing]) y = numpy.concatenate([y, y]) dx = self.dx hdx = self.hdx m = numpy.ones_like(x) * dx * dx h = numpy.ones_like(x) * hdx * dx rho = numpy.ones_like(x) # create the particle array kernel = CubicSpline(dim=2) self.wdeltap = kernel.kernel(rij=dx, h=self.h) pa = get_particle_array_elastic_dynamics( name="solid", x=x + spacing, y=y, m=m, rho=rho, h=h, constants=dict( wdeltap=self.wdeltap, n=4, rho_ref=self.rho0, E=self.E, nu=self.nu)) print('Ellastic Collision with %d particles' % (x.size)) print("Shear modulus G = %g, Young's modulus = %g, Poisson's ratio =%g" % (pa.G, pa.E, pa.nu)) u_f = 0.059 pa.u = pa.cs * u_f * (2 * (x < 0) - 1) return [pa]
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) solver.set_final_time(tf) solver.set_print_freq(500) # add the equations
def create_particles(self): xp, yp = self.create_plate() m = self.plate_rho0 * self.dx_plate**2. # get the index of the particle which will be used to compute the # amplitude xp_max = max(xp) fltr = np.argwhere(xp == xp_max) fltr_idx = int(len(fltr) / 2.) amplitude_idx = fltr[fltr_idx][0] kernel = CubicSpline(dim=2) self.wdeltap = kernel.kernel(rij=self.dx_plate, h=self.h) plate = get_particle_array_elastic_dynamics( x=xp, y=yp, m=m, h=self.h, rho=self.plate_rho0, name="plate", constants=dict(wdeltap=self.wdeltap, n=4, rho_ref=self.plate_rho0, E=self.plate_E, nu=self.plate_nu, amplitude_idx=amplitude_idx)) ################################## # vertical velocity of the plate # ################################## # initialize with zero at the beginning v = np.zeros_like(xp) v = v.ravel() # set the vertical velocity for particles which are only # out of the wall K = self.K # L = self.L KL = self.KL M = sin(KL) + sinh(KL) N = cos(KL) + cosh(KL) Q = 2 * (cos(KL) * sinh(KL) - sin(KL) * cosh(KL)) # import pudb; pudb.set_trace() fltr = xp > 0 tmp1 = (cos(K * xp[fltr]) - cosh(K * xp[fltr])) tmp2 = (sin(K * xp[fltr]) - sinh(K * xp[fltr])) v[fltr] = self.Vf * plate.cs[0] * (M * tmp1 - N * tmp2) / Q # set vertical velocity plate.v = v # ######################################### # #### Create the wall particle array ##### # ######################################### # create the particle array xw, yw = self.create_wall() wall = get_particle_array_elastic_dynamics(x=xw, y=yw, m=m, h=self.h, rho=self.plate_rho0, name="wall", constants=dict( E=self.plate_E, nu=self.plate_nu)) return [plate, wall]