Multiply the power spectrum by the volume to have proper units

This commit is contained in:
Guilhem Lavaux 2012-11-30 17:16:45 -05:00
parent 01f36b9be7
commit a3ef55c318

View File

@ -69,17 +69,22 @@ namespace CosmoTool
std::complex<T> *d = rand_map.data();
long idx;
const DimArray& dims = rand_map.getDims();
const std::vector<double>& delta_k = rand_map.get_delta_k();
long plane_size;
bool alleven = rand_map.allDimensionsEven();
double V = 1;
for (int p = 0; p < delta_k.size(); p++)
V *= (2*M_PI/delta_k[p]);
for (long p = 1; p < rand_map.size(); p++)
{
double A_k = std::sqrt(0.5*f(rand_map.get_K(p)));
double A_k = std::sqrt(0.5*V*f(rand_map.get_K(p)));
d[p] = std::complex<T>(gsl_ran_gaussian(rng, A_k),
gsl_ran_gaussian(rng, A_k));
}
// Generate the mean value
d[0] = std::complex<T>(gsl_ran_gaussian(rng, std::sqrt(f(0))), 0);
d[0] = std::complex<T>(gsl_ran_gaussian(rng, std::sqrt(V*f(0))), 0);
if (!rand_map.firstDimensionEven())
return;