Upgraded gadget load to support variable masses. Adjusted simple3DFilter for that too.
This commit is contained in:
parent
7df2cdbe7c
commit
8809d6c255
@ -156,7 +156,7 @@ def whitify(density, L, cosmo, supergenerate=1, func='HU_WIGGLES'):
|
|||||||
|
|
||||||
print np.where(np.isnan(density_hat_super))[0].size
|
print np.where(np.isnan(density_hat_super))[0].size
|
||||||
|
|
||||||
cube = CubeFT(Ns, L)
|
cube = CubeFT(L, Ns)
|
||||||
cube.dhat = density_hat_super
|
cube.dhat = density_hat_super
|
||||||
return np.fft.irfftn(density_hat_super)*Ns**1.5
|
return np.fft.irfftn(density_hat_super)*Ns**1.5
|
||||||
|
|
||||||
|
@ -9,10 +9,10 @@ cosmo['omega_B_0']=0.049
|
|||||||
cosmo['SIGMA8']=0.8344
|
cosmo['SIGMA8']=0.8344
|
||||||
cosmo['ns']=0.9624
|
cosmo['ns']=0.9624
|
||||||
|
|
||||||
supergen=2
|
supergen=1
|
||||||
zstart=50
|
zstart=50
|
||||||
astart=1/(1.+zstart)
|
astart=1/(1.+zstart)
|
||||||
halfPixelShift=False
|
halfPixelShift=False
|
||||||
|
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
bic.write_icfiles(*bic.run_generation("initial_condition_borg.dat", 0.001, astart, cosmo, supersample=2, shiftPixel=halfPixelShift, do_lpt2=False), supergenerate=supergen)
|
bic.write_icfiles(*bic.run_generation("initial_density_988.dat", 0.001, astart, cosmo, supersample=1, shiftPixel=halfPixelShift, do_lpt2=False), supergenerate=supergen)
|
||||||
|
@ -50,9 +50,11 @@ int main(int argc, char **argv)
|
|||||||
uint32_t res;
|
uint32_t res;
|
||||||
char *fname;
|
char *fname;
|
||||||
int id;
|
int id;
|
||||||
|
double MPC;
|
||||||
|
|
||||||
MiniArgDesc desc[] = {
|
MiniArgDesc desc[] = {
|
||||||
{ "SNAPSHOT", &fname, MINIARG_STRING },
|
{ "SNAPSHOT", &fname, MINIARG_STRING },
|
||||||
|
{ "MPC", &MPC, MINIARG_DOUBLE },
|
||||||
{ 0, 0, MINIARG_NULL }
|
{ 0, 0, MINIARG_NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -63,7 +65,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
|
|
||||||
SimuData *p = loadGadgetMulti(fname, 0, 0);
|
SimuData *p = loadGadgetMulti(fname, 0, 0);
|
||||||
double L0 = p->BoxSize/1000;
|
double L0 = p->BoxSize/MPC;
|
||||||
array_type parts(boost::extents[p->TotalNumPart][7]);
|
array_type parts(boost::extents[p->TotalNumPart][7]);
|
||||||
uint64_t q = 0;
|
uint64_t q = 0;
|
||||||
|
|
||||||
@ -72,13 +74,12 @@ int main(int argc, char **argv)
|
|||||||
p = loadGadgetMulti(fname, cpuid, NEED_POSITION|NEED_VELOCITY|NEED_MASS);
|
p = loadGadgetMulti(fname, cpuid, NEED_POSITION|NEED_VELOCITY|NEED_MASS);
|
||||||
for (uint32_t i = 0; i < p->NumPart; i++)
|
for (uint32_t i = 0; i < p->NumPart; i++)
|
||||||
{
|
{
|
||||||
parts[q][0] = p->Pos[0][i]/1000;
|
|
||||||
parts[q][1] = p->Pos[1][i]/1000;
|
|
||||||
parts[q][2] = p->Pos[2][i]/1000;
|
|
||||||
for (int j = 0; j < 3; j++)
|
for (int j = 0; j < 3; j++)
|
||||||
{
|
{
|
||||||
|
parts[q][j] = p->Pos[j][i]/MPC;
|
||||||
while (parts[q][j] < 0) parts[q][j] += L0;
|
while (parts[q][j] < 0) parts[q][j] += L0;
|
||||||
while (parts[q][j] >= L0) parts[q][j] -= L0;
|
while (parts[q][j] >= L0) parts[q][j] -= L0;
|
||||||
|
parts[q][j] -= L0/2;
|
||||||
}
|
}
|
||||||
parts[q][3] = p->Vel[0][i];
|
parts[q][3] = p->Vel[0][i];
|
||||||
parts[q][4] = p->Vel[1][i];
|
parts[q][4] = p->Vel[1][i];
|
||||||
|
@ -114,7 +114,7 @@ int main(int argc, char **argv)
|
|||||||
rLimit2 = rLimit*rLimit;
|
rLimit2 = rLimit*rLimit;
|
||||||
|
|
||||||
hdf5_read_array(in_f, "particles", v1_data);
|
hdf5_read_array(in_f, "particles", v1_data);
|
||||||
assert(v1_data.shape()[1] == 6);
|
assert(v1_data.shape()[1] == 7);
|
||||||
|
|
||||||
N1_points = v1_data.shape()[0];
|
N1_points = v1_data.shape()[0];
|
||||||
|
|
||||||
@ -132,6 +132,7 @@ int main(int argc, char **argv)
|
|||||||
allCells_1[i].coord[j] = v1_data[i][j];
|
allCells_1[i].coord[j] = v1_data[i][j];
|
||||||
for (int k = 0; k < 3; k++)
|
for (int k = 0; k < 3; k++)
|
||||||
allCells_1[i].val.pValue.v[k] = v1_data[i][3+k];
|
allCells_1[i].val.pValue.v[k] = v1_data[i][3+k];
|
||||||
|
allCells_1[i].val.pValue.mass = v1_data[i][6];
|
||||||
allCells_1[i].active = true;
|
allCells_1[i].active = true;
|
||||||
allCells_1[i].val.weight = 0.0;
|
allCells_1[i].val.weight = 0.0;
|
||||||
|
|
||||||
|
@ -262,10 +262,18 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (loadflags & NEED_MASS) {
|
if (loadflags & NEED_MASS) {
|
||||||
|
bool do_load = false;
|
||||||
|
|
||||||
|
for (int k = 0; k < 6; k++)
|
||||||
|
{
|
||||||
|
do_load = do_load || ((h.mass[k] == 0)&&(h.npart[k]>0));
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
long l = 0;
|
long l = 0;
|
||||||
f->beginCheckpoint();
|
if (do_load)
|
||||||
|
f->beginCheckpoint();
|
||||||
data->Mass = new float[NumPart];
|
data->Mass = new float[NumPart];
|
||||||
for (int k = 0; k < 6; k++)
|
for (int k = 0; k < 6; k++)
|
||||||
{
|
{
|
||||||
@ -281,7 +289,8 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f->endCheckpoint();
|
if (do_load)
|
||||||
|
f->endCheckpoint();
|
||||||
}
|
}
|
||||||
catch (const InvalidUnformattedAccess& e)
|
catch (const InvalidUnformattedAccess& e)
|
||||||
{
|
{
|
||||||
@ -290,6 +299,11 @@ SimuData *CosmoTool::loadGadgetMulti(const char *fname, int id,
|
|||||||
delete data;
|
delete data;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
catch (const EndOfFileException& e)
|
||||||
|
{
|
||||||
|
for (int k = 0; k < 6; k++)
|
||||||
|
cerr << "mass[" << k << "] = " << h.mass[k] << endl;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
f->skip(2*4);
|
f->skip(2*4);
|
||||||
for (int k = 0; k < 6; k++)
|
for (int k = 0; k < 6; k++)
|
||||||
|
Loading…
Reference in New Issue
Block a user