This commit is contained in:
Guilhem Lavaux 2015-01-22 19:16:46 +01:00
parent 7a27dae025
commit f12c9a0c1a
5 changed files with 128 additions and 33 deletions

View file

@ -4,10 +4,11 @@ import cosmolopy as cpy
from cosmogrowth import *
import borgadaptor as ba
def gen_posgrid(N, L):
@ct.timeit
def gen_posgrid(N, L, delta=1, dtype=np.float32):
""" Generate an ordered lagrangian grid"""
ix = (np.arange(N)*L/N).astype(np.float32)
ix = (np.arange(N)*(L/N*delta)).astype(dtype)
x = ix[:,None,None].repeat(N, axis=1).repeat(N, axis=2)
y = ix[None,:,None].repeat(N, axis=0).repeat(N, axis=2)
@ -147,6 +148,8 @@ def run_generation(input_borg, a_borg, a_ic, cosmo, supersample=1, supergenerate
D2 = -3./7 * D1_0**2
if do_lpt2:
psi2 = lpt.lpt2('all')
for j in xrange(3):
# Generate psi_j (displacement along j)
print("LPT1 axis=%d" % j)
@ -154,8 +157,7 @@ def run_generation(input_borg, a_borg, a_ic, cosmo, supersample=1, supergenerate
psi = psi.reshape((psi.size,))
if do_lpt2:
print("LPT2 axis=%d" % j)
psi2 = lpt.lpt2(j)
psi += D2 * psi2.reshape((psi2.size,))
psi += D2 * psi2[j].reshape((psi2[j].size,))
# Generate posx
posx.append(((posq[j] + psi)%L).astype(np.float32))
# Generate vel