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
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]
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 equations = [
# get list of neighbors nps.get_nearest_particles(0, 0, i, nbrs) neighbors = nbrs.get_npy_array() max_ngb = max( neighbors.size, max_ngb ) # iterate over the neighbor set rho_sum = 0.0; wij_sum = 0.0 for j in neighbors: xij = xi - x[j] yij = yi - y[j] rij = numpy.sqrt( xij**2 + yij**2 ) hij = 0.5 * (h[i] + h[j]) _wij = k.kernel( [xij, yij, 0.0], rij, hij) # contribution from this neibhor wij_sum += _wij rho_sum += m[j] * _wij # total contribution to the density and number density pa.rho[i] = rho_sum pa.wij[i] = wij_sum t2 = time()-t1 avg_density = numpy.sum(pa.rho)/pa.num_real_particles print '2D Summation density: %d particles %g seconds, Max %d neighbors'%(pa.num_real_particles, t2, max_ngb) print """Average density = %g, Relative error = %g"""%(avg_density, (1-avg_density)*100), '%'
nps.get_nearest_particles(0, 0, i, nbrs) neighbors = nbrs.get_npy_array() max_ngb = max(neighbors.size, max_ngb) # iterate over the neighbor set rho_sum = 0.0 wij_sum = 0.0 for j in neighbors: xij = xi - x[j] yij = yi - y[j] rij = numpy.sqrt(xij**2 + yij**2) hij = 0.5 * (h[i] + h[j]) _wij = k.kernel([xij, yij, 0.0], rij, hij) # contribution from this neibhor wij_sum += _wij rho_sum += m[j] * _wij # total contribution to the density and number density pa.rho[i] = rho_sum pa.wij[i] = wij_sum t2 = time() - t1 avg_density = numpy.sum(pa.rho) / pa.num_real_particles print('2D Summation density: %d particles %g seconds, Max %d neighbors' % (pa.num_real_particles, t2, max_ngb)) print(