dim = 3; gamma = 1.4 particles = phd.distribute_initial_particles( create_particles, dim=dim, gamma=gamma) # computation related to boundaries domain_manager = phd.DomainManager( xmin=[0., 0., 0.], xmax=[1., 1., 1.], initial_radius=0.1) # create voronoi mesh mesh = phd.Mesh(relax_iterations=10) # computation integrator = phd.MovingMeshMUSCLHancock() integrator.set_mesh(mesh) integrator.set_riemann(phd.HLLC()) integrator.set_particles(particles) integrator.set_domain_manager(domain_manager) integrator.set_boundary_condition(phd.Reflective()) integrator.set_reconstruction(phd.PieceWiseLinear()) integrator.set_equation_state(phd.IdealGas(gamma=gamma)) sim_name = "sod" if phd._in_parallel: integrator.set_load_balance(phd.LoadBalance()) sim_name = "mpi_sod" # add finish criteria simulation_time_manager = phd.SimulationTimeManager() simulation_time_manager.add_finish(phd.Time(time_max=0.15))
pc['velocity-x'][:] = 0.0 pc['velocity-y'][:] = 0.0 pc['tag'][:] = phd.ParticleTAGS.Real pc['type'][:] = phd.ParticleTAGS.Undefined return pc # simulation driver sim = phd.Simulation(cfl=0.5, tf=2.5, pfreq=25, relax_num_iterations=0, output_relax=False, fname='implosion') sim.add_component( create_particles(1.4)) # create inital state of the simulation sim.add_component(phd.DomainLimits(dim=2, xmin=0., xmax=1.)) # spatial size of problem sim.add_component(phd.Boundary(boundary_type=phd.BoundaryType.Reflective) ) # reflective boundary condition sim.add_component(phd.Mesh()) # tesselation algorithm sim.add_component(phd.PieceWiseLinear()) # Linear reconstruction #sim.add_component(phd.PieceWiseConstant()) # Linear reconstruction sim.add_component(phd.HLLC(gamma=1.4)) # riemann solver sim.add_component(phd.MovingMesh(regularize=1)) # Integrator # run the simulation sim.solve()
# tell each processor how many particles it will hold send = comm.scatter(send, root=0) # allocate local particle container pc = phd.ParticleContainer(send) # import particles from root fields = ['position-x', 'position-y', 'density', 'pressure', 'ids'] for field in fields: comm.Scatterv([pc_root[field], (lengths, disp)], pc[field]) pc['process'][:] = rank pc['tag'][:] = phd.ParticleTAGS.Real pc['type'][:] = phd.ParticleTAGS.Undefined domain = phd.DomainLimits(dim=2, xmin=0., xmax=1.) # spatial size of problem load_bal = phd.LoadBalance(domain, comm, order=21) # tree load balance scheme boundary = phd.BoundaryParallel(domain, # periodic boundary condition boundary_type=phd.BoundaryType.Periodic, load_bal, comm) mesh = phd.Mesh(boundary) # tesselation algorithm reconstruction = phd.PieceWiseConstant() # constant reconstruction riemann = phd.HLLC(reconstruction, gamma=1.4, cfl=0.5) # riemann solver integrator = phd.MovingMesh(pc, mesh, riemann, regularize=1) # integrator solver = phd.SolverParallel(integrator, # simulation driver cfl=0.5, tf=2.5, pfreq=25, relax_num_iterations=0, output_relax=False, fname='kh_2d_cartesian') solver.solve()
particles["tag"][:] = phd.ParticleTAGS.Real particles["type"][:] = phd.ParticleTAGS.Undefined # computation related to boundaries domain_manager = phd.DomainManager( xmin=[0., 0.], xmax=[3., 3.], initial_radius=0.1, search_radius_factor=2) # create voronoi mesh mesh = phd.Mesh(regularize=True, relax_iterations=0) # computation integrator = phd.MovingMeshMUSCLHancock() #integrator = phd.StaticMeshMUSCLHancock() integrator.set_mesh(mesh) integrator.set_riemann(phd.HLLC(boost=True)) integrator.set_particles(particles) integrator.set_equation_state(phd.IdealGas()) integrator.set_domain_manager(domain_manager) integrator.set_load_balance(phd.LoadBalance()) integrator.set_boundary_condition(phd.Reflective()) integrator.set_reconstruction(phd.PieceWiseLinear(limiter="arepo", gizmo_limiter=True)) # source term integrator.add_source_term(phd.ConstantGravity()) # add finish criteria simulation_time_manager = phd.SimulationTimeManager() simulation_time_manager.add_finish(phd.Time(time_max=2.0)) # output last step
r = 0.1 cells = ((pc['position-x']-.5)**2 + (pc['position-y']-.5)**2) <= r**2 pc['pressure'][cells] = 1.0/(np.pi*r**2)*(gamma-1) # zero out the velocities and set particle type pc['velocity-x'][:] = 0.0 pc['velocity-y'][:] = 0.0 pc['tag'][:] = phd.ParticleTAGS.Real pc['type'][:] = phd.ParticleTAGS.Undefined return pc # simulation driver sim = phd.Simulation( cfl=0.5, tf=0.1, pfreq=1, relax_num_iterations=10, output_relax=False, fname='sedov_2d_uniform') sim.add_particles(create_particles(1.4)) # create inital state of the simulation sim.add_domain(phd.DomainLimits(dim=2, xmin=0., xmax=1.)) # spatial size of problem sim.add_boundary(phd.Boundary(boundary_type=phd.BoundaryType.Reflective)) # reflective boundary condition sim.add_mesh(phd.Mesh()) # tesselation algorithm sim.add_reconstruction(phd.PieceWiseLinear(limiter=1)) # Linear reconstruction #sim.add_reconstruction(phd.PieceWiseConstant(limiter=1)) # Linear reconstruction sim.add_riemann(phd.HLLC(gamma=1.4, boost=0)) # riemann solver sim.add_integrator(phd.MovingMesh(regularize=1)) # Integrator # run the simulation sim.solve()
part += 1 pc['pressure'][:] = 2.5 pc['velocity-y'][:] = 0.0 pc['tag'][:] = phd.ParticleTAGS.Real pc['type'][:] = phd.ParticleTAGS.Undefined return pc # create inital state of the simulation pc = create_particles(1.4) domain = phd.DomainLimits(dim=2, xmin=0., xmax=1.) # spatial size of problem boundary = phd.Boundary( domain, # periodic boundary condition boundary_type=phd.BoundaryType.Periodic) mesh = phd.Mesh(boundary) # tesselation algorithm reconstruction = phd.PieceWiseConstant() # constant reconstruction riemann = phd.HLLC(reconstruction, gamma=1.4) # riemann solver integrator = phd.MovingMesh(pc, mesh, riemann, regularize=1) # integrator solver = phd.Solver( integrator, # simulation driver cfl=0.5, tf=2.5, pfreq=25, relax_num_iterations=0, output_relax=False, fname='kh_cartesian') solver.solve()