Page MenuHomec4science

test_LoadParticlesQ.py
No OneTemporary

File Metadata

Created
Sat, Nov 9, 13:56

test_LoadParticlesQ.py

#!/usr/bin/env python
from mpi4py import MPI
from pNbody import ic
from numpy import *
from PyGadget import gadget
import Ptools as pt
import sys
import time
ThisTask = MPI.COMM_WORLD.Get_rank()
random.seed(ThisTask) # 2 for two points
n = 10000
rc = 2
rmax = 100
nb = ic.plummer(n,1,1,1,eps=rc,rmax=rmax,ftype='gadget')
nb.rename('plummer.dat')
nb.write()
gadget.InitMPI() # init MPI
gadget.InitDefaultParameters() # init default parameters
gadget.Info()
params = {}
params['ErrTolTheta'] = 0.7
params['DesNumNgb'] = 50
params['MaxNumNgbDeviation'] = 1
params['UnitLength_in_cm'] = 3.085e+21
params['UnitMass_in_g'] = 4.435693e+44
params['UnitVelocity_in_cm_per_s'] = 97824708.2699
params['SofteningGas'] = rc/100.
params['SofteningHalo'] = rc/100.
params['SofteningDisk'] = rc/100.
params['SofteningBulge'] = rc/100.
params['SofteningStars'] = rc/100.
params['SofteningBndry'] = rc/100.
params['SofteningGasMaxPhys'] = rc/100.
params['SofteningHaloMaxPhys'] = rc/100.
params['SofteningDiskMaxPhys'] = rc/100.
params['SofteningBulgeMaxPhys'] = rc/100.
params['SofteningStarsMaxPhys'] = rc/100.
params['SofteningBndryMaxPhys'] = rc/100.
gadget.SetParameters(params)
params = gadget.GetParameters()
gadget.LoadParticlesQ(array(nb.npart),nb.pos,nb.vel,nb.mass,nb.num,nb.tpe)
nb.pos = gadget.GetAllPositionsQ()
nb.vel = gadget.GetAllVelocitiesQ()
nb.mass = gadget.GetAllMassesQ()
nb.num = gadget.GetAllIDQ()
nb.tpe = gadget.GetAllTypesQ()
nb.init()
nb.set_pio('yes')
nb.rename("snap.dat")
nb.write()
print nb.p_name

Event Timeline