Added OpenCL CIC code

This commit is contained in:
Guilhem Lavaux 2014-09-23 11:54:44 +02:00
parent 1e733f2318
commit f6ad248f75
8 changed files with 297 additions and 78 deletions

View file

@ -74,6 +74,7 @@ def run_generation(input_borg, a_borg, a_ic, cosmo, supersample=1, do_lpt2=True,
# Compute LPT scaling coefficient
D1 = cgrowth.D(a_ic)
D1_0 = D1/cgrowth.D(a_borg)
print "D1_0=%lg" % D1_0
velmul = cgrowth.compute_velmul(a_ic) if not psi_instead else 1
D2 = -3./7 * D1_0**2
@ -169,13 +170,12 @@ def whitify(density, L, cosmo, supergenerate=1, zero_fill=False, func='HU_WIGGLE
def write_icfiles(*generated_ic, **kwargs):
"""Write the initial conditions from the tuple returned by run_generation"""
supergenerate=1
supergenerate=kwargs.get('supergenerate', 1)
zero_fill=kwargs.get('zero_fill', False)
posx,vel,density,N,L,a_ic,cosmo = generated_ic
ct.simpleWriteGadget("Data/borg.gad", posx, velocities=vel, boxsize=L, Hubble=cosmo['h'], Omega_M=cosmo['omega_M_0'], time=a_ic)
for i,c in enumerate(["x","y","z"]):
for i,c in enumerate(["z","y","x"]):
ct.writeGrafic("Data/ic_velc%s" % c, vel[i].reshape((N,N,N)), L, a_ic, **cosmo)
ct.writeGrafic("Data/ic_deltab", density, L, a_ic, **cosmo)

View file

@ -1,6 +1,11 @@
import pyfftw
import numpy as np
import cosmotool as ct
import borgicgen as bic
import pickle
with file("wisdom") as f:
pyfftw.import_wisdom(pickle.load(f))
cosmo={'omega_M_0':0.3175, 'h':0.6711}
cosmo['omega_lambda_0']=1-cosmo['omega_M_0']
@ -9,11 +14,11 @@ cosmo['omega_B_0']=0.049
cosmo['SIGMA8']=0.8344
cosmo['ns']=0.9624
supergen=2
supergen=8
zstart=50
astart=1/69.#1/(1.+zstart)
astart=1/(1.+zstart)
halfPixelShift=False
zero_fill=True
zero_fill=False
if __name__=="__main__":
bic.write_icfiles(*bic.run_generation("initial_density_1380.dat", 0.001, astart, cosmo, supersample=1, shiftPixel=halfPixelShift, do_lpt2=False), supergenerate=supergen, zero_fill=zero_fill)
bic.write_icfiles(*bic.run_generation("initial_density_1872.dat", 0.001, astart, cosmo, supersample=1, shiftPixel=halfPixelShift, do_lpt2=False), supergenerate=supergen, zero_fill=zero_fill)

View file

@ -8,6 +8,7 @@ s = ct.loadRamsesAll(sys.argv[1], int(sys.argv[2]), doublePrecision=True, loadVe
q = [p for p in s.getPositions()]
q += [p for p in s.getVelocities()]
q += [np.ones(q[0].size,dtype=q[0].dtype)]
q = np.array(q)
with h5.File("particles.h5", mode="w") as f: