Commit e0bd04bf authored by Volker Springel's avatar Volker Springel
Browse files

small fix for cosmological big sphere set-up and clean ups

parent dc4c95d0
...@@ -192,7 +192,7 @@ void coolsfr::sfr_create_star_particles(simparticles *Sp) ...@@ -192,7 +192,7 @@ void coolsfr::sfr_create_star_particles(simparticles *Sp)
else else
rate = 0; rate = 0;
/* compute the cumulative mass of stars (->>> CHECK ME!!!) */ /* compute the cumulative mass of stars */
cum_mass_stars += total_sum_mass_stars; cum_mass_stars += total_sum_mass_stars;
/* convert to solar masses per yr */ /* convert to solar masses per yr */
......
...@@ -78,7 +78,9 @@ void sim::compute_grav_accelerations(int timebin) ...@@ -78,7 +78,9 @@ void sim::compute_grav_accelerations(int timebin)
else else
{ {
GravTree.DoPM = 0; GravTree.DoPM = 0;
#if defined(PERIODIC)
GravTree.DoEwald = 1; GravTree.DoEwald = 1;
#endif
} }
#else /* here no PM acceleration is used */ #else /* here no PM acceleration is used */
...@@ -272,25 +274,34 @@ void sim::gravity_set_oldacc(int timebin) ...@@ -272,25 +274,34 @@ void sim::gravity_set_oldacc(int timebin)
} }
} }
/* CHECK: shoukd this function still contain the communication of the forces in in Tree.ResultsActiveImported? */
void sim::gravity_comoving_factors(int timebin) void sim::gravity_comoving_factors(int timebin)
{ {
particle_data *P = Sp.P; particle_data *P = Sp.P;
#ifndef PERIODIC #ifndef PERIODIC
#ifndef PMGRID
if(All.ComovingIntegrationOn) if(All.ComovingIntegrationOn)
{ {
/* here we carry out an integration in comoving coordinates but in a non-periodic space (i.e. the 'big sphere setup') */
double fac = 0.5 * All.Hubble * All.Hubble * All.Omega0 / All.G; double fac = 0.5 * All.Hubble * All.Hubble * All.Omega0 / All.G;
for(int i = 0; i < Sp.TimeBinsGravity.NActiveParticles; i++) for(int i = 0; i < Sp.TimeBinsGravity.NActiveParticles; i++)
{ {
int target = Sp.TimeBinsGravity.ActiveParticleList[i]; int target = Sp.TimeBinsGravity.ActiveParticleList[i];
double pos[3];
Sp.intpos_to_pos(P[target].IntPos, pos); /* converts the integer distance to floating point */
for(int j = 0; j < 3; j++) for(int j = 0; j < 3; j++)
P[target].GravAccel[j] += fac * P[target].IntPos[j]; P[target].GravAccel[j] += fac * pos[j];
#ifdef EVALPOTENTIAL
double r2 = 0;
for(int k = 0; k < 3; k++)
r2 += pos[k] * pos[k];
P[target].Potential -= fac * r2;
#endif
} }
} }
#endif
#endif #endif
/* muliply by G */ /* muliply by G */
...@@ -341,46 +352,30 @@ void sim::gravity_comoving_factors(int timebin) ...@@ -341,46 +352,30 @@ void sim::gravity_comoving_factors(int timebin)
#endif #endif
#endif #endif
if(All.ComovingIntegrationOn) if(All.ComovingIntegrationOn == 0 && All.OmegaLambda != 0)
{ {
#ifndef PERIODIC #ifdef PERIODIC
#ifdef EVALPOTENTIAL Terminate(
double fac = -0.5 * All.Omega0 * All.Hubble * All.Hubble; "You specified a periodic simulation in physical coordinates but with a non-zero cosmological constant - this can't be "
"run");
#endif
/* Finally, the following factor allows a computation of a cosmological simulation
with vacuum energy in physical coordinates */
double pos[3]; double pos[3];
Sp.intpos_to_pos(P[target].IntPos, pos); /* converts the integer distance to floating point */ Sp.intpos_to_pos(P[target].IntPos, pos); /* converts the integer distance to floating point */
double r2 = 0; double fac = All.OmegaLambda * All.Hubble * All.Hubble;
for(int k = 0; k < 3; k++)
r2 += pos[k] * pos[k];
P[target].Potential += fac * r2;
#endif
#endif
}
else
{
if(All.OmegaLambda != 0)
{
#ifndef PERIODIC
/* Finally, the following factor allows a computation of a cosmological simulation
with vacuum energy in physical coordinates */
double pos[3]; for(int j = 0; j < 3; j++)
Sp.intpos_to_pos(P[target].IntPos, pos); /* converts the integer distance to floating point */ Sp.P[target].GravAccel[j] += fac * pos[j];
double fac = All.OmegaLambda * All.Hubble * All.Hubble;
for(int j = 0; j < 3; j++)
Sp.P[target].GravAccel[j] += fac * pos[j];
#ifdef EVALPOTENTIAL #ifdef EVALPOTENTIAL
double r2 = 0; double r2 = 0;
for(int k = 0; k < 3; k++) for(int k = 0; k < 3; k++)
r2 += pos[k] * pos[k]; r2 += pos[k] * pos[k];
P[target].Potential -= 0.5 * fac * r2; P[target].Potential -= 0.5 * fac * r2;
#endif
#endif #endif
}
} }
} }
} }
......
...@@ -231,7 +231,6 @@ int tree<node, partset, point_data, foreign_point_data>::treebuild_construct(voi ...@@ -231,7 +231,6 @@ int tree<node, partset, point_data, foreign_point_data>::treebuild_construct(voi
nfreep->level = 0; nfreep->level = 0;
nfreep->sibling_shmrank = TreeSharedMem_ThisTask; nfreep->sibling_shmrank = TreeSharedMem_ThisTask;
nfreep->nextnode_shmrank = TreeSharedMem_ThisTask; nfreep->nextnode_shmrank = TreeSharedMem_ThisTask;
nfreep->father_shmrank = TreeSharedMem_ThisTask;
for(int j = 0; j < 3; j++) for(int j = 0; j < 3; j++)
nfreep->center[j] = ((MyIntPosType)1) << (BITS_FOR_POSITIONS - 1); nfreep->center[j] = ((MyIntPosType)1) << (BITS_FOR_POSITIONS - 1);
...@@ -579,7 +578,6 @@ int tree<node, partset, point_data, foreign_point_data>::treebuild_insert_group_ ...@@ -579,7 +578,6 @@ int tree<node, partset, point_data, foreign_point_data>::treebuild_insert_group_
nfreep->center[1] = ((subintpos[i][1] & centermask) | mask); nfreep->center[1] = ((subintpos[i][1] & centermask) | mask);
nfreep->center[2] = ((subintpos[i][2] & centermask) | mask); nfreep->center[2] = ((subintpos[i][2] & centermask) | mask);
nfreep->father_shmrank = TreeSharedMem_ThisTask;
nfreep->nextnode_shmrank = TreeSharedMem_ThisTask; nfreep->nextnode_shmrank = TreeSharedMem_ThisTask;
nfreep->sibling_shmrank = TreeSharedMem_ThisTask; nfreep->sibling_shmrank = TreeSharedMem_ThisTask;
...@@ -746,7 +744,6 @@ int tree<node, partset, point_data, foreign_point_data>::create_empty_nodes( ...@@ -746,7 +744,6 @@ int tree<node, partset, point_data, foreign_point_data>::create_empty_nodes(
TopNodes[no].sibling_shmrank = TreeSharedMem_ThisTask; TopNodes[no].sibling_shmrank = TreeSharedMem_ThisTask;
TopNodes[no].nextnode_shmrank = TreeSharedMem_ThisTask; TopNodes[no].nextnode_shmrank = TreeSharedMem_ThisTask;
TopNodes[no].father_shmrank = TreeSharedMem_ThisTask;
} }
/* loop over daughter nodes */ /* loop over daughter nodes */
......
...@@ -64,7 +64,6 @@ struct basenode ...@@ -64,7 +64,6 @@ struct basenode
unsigned char level; /**< hold the tree level, used to store the side length of node in space efficient way */ unsigned char level; /**< hold the tree level, used to store the side length of node in space efficient way */
unsigned char sibling_shmrank; unsigned char sibling_shmrank;
unsigned char nextnode_shmrank; unsigned char nextnode_shmrank;
unsigned char father_shmrank; // CHECK: can be deleted
std::atomic_flag access; std::atomic_flag access;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment