Skip to content
Snippets Groups Projects
Commit bddc5d10 authored by Tom Theuns's avatar Tom Theuns
Browse files

added timestep multiplier as extra parameter

parent 961a5ca3
No related branches found
No related tags found
1 merge request!205Isothermal potential
...@@ -63,11 +63,12 @@ PointMass: ...@@ -63,11 +63,12 @@ PointMass:
position_y: 50. position_y: 50.
position_z: 50. position_z: 50.
mass: 1e10 # mass of external point mass in internal units mass: 1e10 # mass of external point mass in internal units
timestep_mult: 0.03 # controls time step
IsothermalPotential: IsothermalPotential:
position_x: 100. # location of external point mass in internal units position_x: 100. # location of centre of isothermal potential in internal units
position_y: 100. position_y: 100.
position_z: 100. position_z: 100.
vrot: 200. # rotation speed of isothermal potential in internal units vrot: 200. # rotation speed of isothermal potential in internal units
timestep_mult: 0.03 # controls time step
...@@ -46,6 +46,8 @@ void potential_init(const struct swift_params* parameter_file, ...@@ -46,6 +46,8 @@ void potential_init(const struct swift_params* parameter_file,
parser_get_param_double(parameter_file, "PointMass:position_z"); parser_get_param_double(parameter_file, "PointMass:position_z");
potential->point_mass.mass = potential->point_mass.mass =
parser_get_param_double(parameter_file, "PointMass:mass"); parser_get_param_double(parameter_file, "PointMass:mass");
potential->point_mass.timestep_mult =
parser_get_param_double(parameter_file, "PointMass:timestep_mult");
#endif /* EXTERNAL_POTENTIAL_POINTMASS */ #endif /* EXTERNAL_POTENTIAL_POINTMASS */
#ifdef EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL #ifdef EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL
...@@ -57,6 +59,8 @@ void potential_init(const struct swift_params* parameter_file, ...@@ -57,6 +59,8 @@ void potential_init(const struct swift_params* parameter_file,
parser_get_param_double(parameter_file, "IsothermalPotential:position_z"); parser_get_param_double(parameter_file, "IsothermalPotential:position_z");
potential -> isothermal_potential.vrot = potential -> isothermal_potential.vrot =
parser_get_param_double(parameter_file, "IsothermalPotential:vrot"); parser_get_param_double(parameter_file, "IsothermalPotential:vrot");
potential -> isothermal_potential.timestep_mult =
parser_get_param_double(parameter_file, "IsothermalPotential:timestep_mult");
#endif /* EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL */ #endif /* EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL */
} }
...@@ -68,13 +72,15 @@ void potential_init(const struct swift_params* parameter_file, ...@@ -68,13 +72,15 @@ void potential_init(const struct swift_params* parameter_file,
void potential_print(const struct external_potential* potential) { void potential_print(const struct external_potential* potential) {
#ifdef EXTERNAL_POTENTIAL_POINTMASS #ifdef EXTERNAL_POTENTIAL_POINTMASS
message("Point mass properties are (x,y,z) = (%e, %e, %e), M = %e", message("Point mass properties are (x,y,z) = (%e, %e, %e), M = %e timestep multiplier = %e",
potential->point_mass.x, potential->point_mass.y, potential->point_mass.x, potential->point_mass.y,
potential->point_mass.z, potential->point_mass.mass); potential->point_mass.z, potential->point_mass.mass,
potential->point_mass.timestep_mult);
#endif /* EXTERNAL_POTENTIAL_POINTMASS */ #endif /* EXTERNAL_POTENTIAL_POINTMASS */
#ifdef EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL #ifdef EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL
message("Isothermal potential properties are (x,y,z) = (%e, %e, %e), vrot = %e", message("Isothermal potential properties are (x,y,z) = (%e, %e, %e), vrot = %e timestep multiplier= %e",
potential->isothermal_potential.x, potential->isothermal_potential.y, potential->isothermal_potential.x, potential->isothermal_potential.y,
potential->isothermal_potential.z, potential->isothermal_potential.vrot); potential->isothermal_potential.z, potential->isothermal_potential.vrot,
potential->isothermal_potential.timestep_mult);
#endif /* EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL */ #endif /* EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL */
} }
...@@ -42,12 +42,14 @@ struct external_potential { ...@@ -42,12 +42,14 @@ struct external_potential {
struct { struct {
double x, y, z; double x, y, z;
double mass; double mass;
double timestep_mult;
} point_mass; } point_mass;
#endif #endif
#ifdef EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL #ifdef EXTERNAL_POTENTIAL_ISOTHERMALPOTENTIAL
struct { struct {
double x, y, z; double x, y, z;
double vrot; double vrot;
double timestep_mult;
} isothermal_potential; } isothermal_potential;
#endif #endif
}; };
...@@ -83,7 +85,8 @@ __attribute__((always_inline)) ...@@ -83,7 +85,8 @@ __attribute__((always_inline))
// error(" dx= %e dvx= %e rinv2= %e a2= %e dota_2= %e dt= %e", dx, g->v_full[1], rinv2, a_2, dota_2, 0.03f * sqrtf(a_2 / dota_2)); // error(" dx= %e dvx= %e rinv2= %e a2= %e dota_2= %e dt= %e", dx, g->v_full[1], rinv2, a_2, dota_2, 0.03f * sqrtf(a_2 / dota_2));
return EXTERNAL_GRAVITY_TIMESTEP_PREFACTOR * sqrtf(a_2 / dota_2); //return EXTERNAL_GRAVITY_TIMESTEP_PREFACTOR * sqrtf(a_2 / dota_2);
return potential->isothermal_potential.timestep_mult * sqrtf(a_2 / dota_2);
} }
/** /**
* @brief Computes the gravitational acceleration of a particle due to a point * @brief Computes the gravitational acceleration of a particle due to a point
...@@ -142,7 +145,8 @@ external_gravity_pointmass_timestep(const struct external_potential* potential, ...@@ -142,7 +145,8 @@ external_gravity_pointmass_timestep(const struct external_potential* potential,
const float a_2 = g->a_grav[0] * g->a_grav[0] + g->a_grav[1] * g->a_grav[1] + const float a_2 = g->a_grav[0] * g->a_grav[0] + g->a_grav[1] * g->a_grav[1] +
g->a_grav[2] * g->a_grav[2]; g->a_grav[2] * g->a_grav[2];
return EXTERNAL_GRAVITY_TIMESTEP_PREFACTOR * sqrtf(a_2 / dota_2); /* return EXTERNAL_GRAVITY_TIMESTEP_PREFACTOR * sqrtf(a_2 / dota_2); */
return potential->point_mass.timestep_mult * sqrtf(a_2 / dota_2);
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment