Пример #1
0
# 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()
Пример #2
0
    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()
Пример #3
0
    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()