Some fixups

This commit is contained in:
Guilhem Lavaux 2019-11-11 10:32:40 +01:00
parent 1bd685e9c5
commit 71691956cc
6 changed files with 24 additions and 10 deletions

View File

@ -171,6 +171,7 @@ void CosmoTool_compute_bispectrum(
size_t *Ntriangles, size_t *Ntriangles,
double* B, double delta_k, size_t Nk ) double* B, double delta_k, size_t Nk )
{ {
#if 0
// First remap to multi_array for easy access // First remap to multi_array for easy access
size_t kNz = Nz/2+1; size_t kNz = Nz/2+1;
#ifdef _OPENMP #ifdef _OPENMP
@ -246,6 +247,7 @@ void CosmoTool_compute_bispectrum(
#else #else
#warning Serial version not implemented #warning Serial version not implemented
#endif #endif
#endif
} }
@ -255,6 +257,7 @@ void CosmoTool_compute_powerspectrum(
size_t *Ncounts, size_t *Ncounts,
double* P, double delta_k, size_t Nk ) double* P, double delta_k, size_t Nk )
{ {
#if 0
// First remap to multi_array for easy access // First remap to multi_array for easy access
size_t kNz = Nz/2+1; size_t kNz = Nz/2+1;
boost::multi_array_ref<std::complex<double>, 3> a_delta(reinterpret_cast<std::complex<double>*>(delta_hat), boost::extents[Nx][Ny][kNz]); boost::multi_array_ref<std::complex<double>, 3> a_delta(reinterpret_cast<std::complex<double>*>(delta_hat), boost::extents[Nx][Ny][kNz]);
@ -275,4 +278,5 @@ void CosmoTool_compute_powerspectrum(
a_Nc[q1] ++; a_Nc[q1] ++;
a_P[q1] += std::norm(v1); a_P[q1] += std::norm(v1);
} }
#endif
} }

View File

@ -65,18 +65,30 @@ cdef class CosmologyPower:
cdef CosmoPower power cdef CosmoPower power
def __init__(self,**cosmo): def __init__(self,**cosmo):
"""Constructor
Keyword arguments:
* omega_B_0
* omega_M_0
* h
* ns
* T27
"""
self.power = CosmoPower() self.power = CosmoPower()
self.power.OMEGA_B = cosmo['omega_B_0'] self.power.OMEGA_B = cosmo['omega_B_0']
self.power.OMEGA_C = cosmo['omega_M_0']-cosmo['omega_B_0'] self.power.OMEGA_C = cosmo['omega_M_0']-cosmo['omega_B_0']
self.power.h = cosmo['h'] self.power.h = cosmo['h']
if 'ns' in cosmo: if 'ns' in cosmo:
self.power.n = cosmo['ns'] self.power.n = cosmo['ns']
if 'T27' in cosmo:
self.power.THETA_27 = cosmo['T27']
assert self.power.OMEGA_C > 0 assert self.power.OMEGA_C > 0
self.power.updateCosmology() self.power.updateCosmology()
def setNormalization(self,A): def setNormalization(self,A):
"""Set manual normalization for A_S"""
self.power.setNormalization(A) self.power.setNormalization(A)
def normalize(self,s8,k_min=-1,k_max=-1): def normalize(self,s8,k_min=-1,k_max=-1):

View File

@ -509,19 +509,17 @@ cdef void INTERNAL_project_cic_with_mass_periodic(DTYPE_t[:,:,:] g,
cdef int b1[3] cdef int b1[3]
for i in range(x.shape[0]): for i in range(x.shape[0]):
for j in range(3): for j in range(3):
a[j] = (x[i,j]+shifter)*delta_Box a[j] = (x[i,j]+shifter)*delta_Box
b[j] = int(floor(a[j])) b[j] = int(floor(a[j]))
b1[j] = b[j]+1 b1[j] = (b[j]+1) % Ngrid
while b1[j] < 0:
b1[j] += Ngrid
while b1[j] >= Ngrid:
b1[j] -= Ngrid
a[j] -= b[j] a[j] -= b[j]
c[j] = 1-a[j] c[j] = 1-a[j]
b[j] %= Ngrid
m0 = mass[i] m0 = mass[i]
g[b[0],b[1],b[2]] += c[0]*c[1]*c[2]*m0 g[b[0],b[1],b[2]] += c[0]*c[1]*c[2]*m0
g[b1[0],b[1],b[2]] += a[0]*c[1]*c[2]*m0 g[b1[0],b[1],b[2]] += a[0]*c[1]*c[2]*m0

View File

@ -146,7 +146,7 @@ int main(int argc, char **argv)
if (rx < 0 || rx >= Nres || ry < 0 || ry >= Nres || rz < 0 || rz >= Nres) if (rx < 0 || rx >= Nres || ry < 0 || ry >= Nres || rz < 0 || rz >= Nres)
continue; continue;
#pragma omp atomic update //#pragma omp atomic update
bins[rx][ry][rz]++; bins[rx][ry][rz]++;
} }
v1_data.resize(boost::extents[1][1]); v1_data.resize(boost::extents[1][1]);

View File

@ -218,7 +218,7 @@ class BuildCMakeExt(build_ext):
CosmoTool_extension = CMakeExtension(name="cosmotool") CosmoTool_extension = CMakeExtension(name="cosmotool")
setup(name='cosmotool', setup(name='cosmotool',
version='1.0.0a0', version='1.0.0a2',
packages=["cosmotool"], packages=["cosmotool"],
package_dir={'cosmotool': 'python/cosmotool'}, package_dir={'cosmotool': 'python/cosmotool'},
setup_requires=['cython','cffi','numexpr'], setup_requires=['cython','cffi','numexpr'],

View File

@ -277,7 +277,7 @@ namespace CosmoTool {
coords tmpBound; coords tmpBound;
NodeIntType nodeId; NodeIntType nodeId;
#pragma omp atomic capture //#pragma omp atomic capture
nodeId = (this->lastNode)++; nodeId = (this->lastNode)++;
node = &nodes[nodeId]; node = &nodes[nodeId];
@ -293,7 +293,7 @@ namespace CosmoTool {
tmpBound[axis] = node->value->coord[axis]; tmpBound[axis] = node->value->coord[axis];
depth++; depth++;
#pragma omp task private(tmpBound) //#pragma omp task private(tmpBound)
{ {
node->children[0] = buildTree(cell0, mid, depth, minBound, tmpBound); node->children[0] = buildTree(cell0, mid, depth, minBound, tmpBound);
} }