def setup_solver(self): s = self.solver # Add the default operations s.add_operation( solver.SPHOperation(sph.TaitEquation.withargs(1, 1), on_types=[Fluids, Solids], updates=['p', 'cs'], id='eos')) s.add_operation( solver.SPHIntegration(sph.SPHDensityRate, on_types=[Fluids, Solids], from_types=[Fluids, Solids], updates=['rho'], id='density_rate')) s.add_operation( solver.SPHIntegration(sph.SPHPressureGradient.withargs(dim=2), on_types=[Fluids], from_types=[Fluids, Solids], updates=['u', 'v'], id='pgrad')) s.add_operation( solver.SPHIntegration(sph.MonaghanArtificialVsicosity, on_types=[Fluids], from_types=[Fluids, Solids], updates=['u', 'v', 'w'], id='avisc'))
def setUp(self): """ A Dummy fluid solver is created with the following operations (i) -- Equation of State (ii) -- Density Rate (iii)-- Momentum Equation Pressure Gradient (iv) -- Momentum Equation Viscosity """ self.kernel = kernel = base.CubicSplineKernel(dim=2) self.solver = s = solver.Solver(dim=2, integrator_type=solver.EulerIntegrator) s.default_kernel = kernel self.particles = base.Particles(arrays=[base.get_particle_array()]) # Create some replacement operations self.visc = solver.SPHIntegration(sph.MorrisViscosity, on_types=[Fluids], from_types=[Fluids, Solids], updates=['u', 'v'], id='visc') self.summation_density = solver.SPHOperation(sph.SPHRho, on_types=[Fluids, Solids], updates=['rho'], id='sd')
def test_from_solid_on_fluid(self): """ Test for construction of the SPHOperation """ function = sph.SPHRho operation = solver.SPHOperation(function, on_types=[Fluid], updates=['rho'], id='sd', from_types=[Fluid, Solid]) #test for the construction self.assertEqual(type(operation.function), type(function)) self.assertEqual(operation.from_types, [Fluid, Solid]) self.assertEqual(operation.on_types, [Fluid]) self.assertEqual(operation.updates, ['rho']) self.assertEqual(operation.id, 'sd') calc_data = operation.get_calc_data(self.particles) # test the calc data # one destination for type Fluid ndsts = len(calc_data) self.assertEqual(ndsts, 1) # the destination number should be 0 ( the first array is Fluid ) dest_data = calc_data[0] self.assertEqual(dest_data['dnum'], 0) # the calc should have two sources sources = dest_data['sources'] self.assertEqual(len(sources), 2) # the calc should have two funcs ( one for each src-dst pair ) funcs = dest_data['funcs'] self.assertEqual(len(funcs), 2) # test the first function func = funcs[0] self.assertEqual(func.dest, self.fluid) self.assertEqual(func.source, self.fluid) #test the second function func = funcs[1] self.assertEqual(func.dest, self.fluid) self.assertEqual(func.source, self.solid)
particles = base.Particles(arrays=[fluid, boundary]) app.particles = particles kernel = base.HarmonicKernel(dim=2, n=3) s = solver.Solver(dim=2, integrator_type=solver.PredictorCorrectorIntegrator) # set the kernel as the default for the solver s.default_kernel = kernel #Tait equation s.add_operation(solver.SPHOperation( sph.TaitEquation.withargs(co=25.0, ro=1.0), on_types=[Fluid], updates=['p','cs'], id='eos', kernel=kernel) ) #continuity equation s.add_operation(solver.SPHIntegration( sph.SPHDensityRate.withargs(), from_types=[Fluid], on_types=[Fluid], updates=['rho'], id='density', kernel=kernel) ) #momentum equation
type=1, x=xb, y=yb, h=hb, m=mb, rho=rhob) particles = base.Particles(arrays=[boundary, fluid]) app.particles = particles s = solver.Solver(dim=2, integrator_type=solver.EulerIntegrator) #Equation of state s.add_operation( solver.SPHOperation(sph.TaitEquation.withargs(co=25.0, ro=1.0), on_types=[Fluid, Solid], updates=['p', 'cs'], id='eos')) #Continuity equation s.add_operation( solver.SPHIntegration(sph.SPHDensityRate.withargs(), from_types=[Fluid, Solid], on_types=[Fluid, Solid], updates=['rho'], id='density')) #momentum equation, no viscosity s.add_operation( solver.SPHIntegration(sph.MomentumEquation.withargs(alpha=0.0, beta=0.0), on_types=[Fluid], from_types=[Fluid, Solid],
pa = particles.get_named_particle_array('fluid') pa.add_property({'name': 'rhop'}) pa.add_property({'name': 'div'}) # ensure that the array 'q' is available pa.add_property({'name': 'q', 'type': 'double'}) s = solver.ShockTubeSolver(dim=1, integrator_type=solver.EulerIntegrator) # add the smoothing length update function as the first operation s.add_operation(solver.SPHOperation(sph.ADKEPilotRho.withargs(h0=h0), on_types=[Fluid], from_types=[Fluid], updates=['rhop'], id='adke_rho'), before=True, id="density") s.add_operation(solver.SPHOperation(sph.ADKESmoothingUpdate.withargs(h0=h0, k=k, eps=eps), on_types=[Fluid], updates=['h'], id='adke'), before=True, id="density") # add the update conduction coefficient after the density calculation
app = solver.Application() app.process_command_line() particles = app.create_particles(variable_h=False, callable=get_particles, min_cell_size=4 * h) print "Number of cells: ", len(particles.cell_manager.cells_dict) s = solver.Solver(dim=2, integrator_type=solver.PredictorCorrectorIntegrator) #Equation of state s.add_operation( solver.SPHOperation(sph.TaitEquation.withargs(hks=False, co=co, ro=ro), on_types=[Fluid, Solid], updates=['p', 'cs'], id='eos'), ) #Continuity equation s.add_operation( solver.SPHIntegration(sph.SPHDensityRate.withargs(hks=False), on_types=[Fluid, Solid], from_types=[Fluid, Solid], updates=['rho'], id='density')) #momentum equation s.add_operation( solver.SPHIntegration(sph.MomentumEquation.withargs(alpha=alpha, beta=0.0, hks=False),
return [wall, square, fluid, dummy_fluid] app = solver.Application() app.process_command_line() particles = app.create_particles(False, get_particles) s = solver.Solver(dim=2, integrator_type=solver.PredictorCorrectorIntegrator) # Equation of state s.add_operation( solver.SPHOperation(sph.TaitEquation(co=co, ro=ro), on_types=[Fluid], updates=['p', 'cs'], id='eos')) # Continuity equation s.add_operation( solver.SPHIntegration(sph.SPHDensityRate(), on_types=[Fluid], from_types=[Fluid, DummyFluid], updates=['rho'], id='density')) # momentum equation s.add_operation( solver.SPHIntegration(sph.MomentumEquation(alpha=alpha, beta=0.0),