diff --git a/examples/main.c b/examples/main.c index aee457723c5457f107dffe6794ded8c5a4399b19..b9f1426a75824e9dbd443748c2b2a942f04cfdc1 100644 --- a/examples/main.c +++ b/examples/main.c @@ -601,7 +601,10 @@ int main(int argc, char *argv[]) { /* Initialise the cosmology */ struct cosmology cosmo; - if (with_cosmology) cosmology_init(params, &us, &prog_const, &cosmo); + if (with_cosmology) + cosmology_init(params, &us, &prog_const, &cosmo); + else + cosmology_init_no_cosmo(params, &us, &prog_const, &cosmo); if (with_cosmology) cosmology_print(&cosmo); /* Initialise the hydro properties */ diff --git a/src/cosmology.c b/src/cosmology.c index 8ee3fe82f2017df8035d9d156144ff30add57599..3a65ffc0f9159a85cb3c7667765c85a00cd2a9eb 100644 --- a/src/cosmology.c +++ b/src/cosmology.c @@ -421,6 +421,51 @@ void cosmology_init(const struct swift_params *params, cosmology_init_tables(c); } +/** + * @brief Initialise the #cosmology for non-cosmological time-integration + * + * Essentially sets all constants to 1. + * + * @param params The parsed values. + * @param us The current internal system of units. + * @param phys_const The physical constants in the current system of units. + * @param c The #cosmology to initialise. + */ +void cosmology_init_no_cosmo(const struct swift_params *params, + const struct unit_system *us, + const struct phys_const *phys_const, + struct cosmology *c) { + + c->Omega_m = 0.; + c->Omega_r = 0.; + c->Omega_k = 0.; + c->Omega_lambda = 0.; + c->Omega_b = 0.; + c->w_0 = 0.; + c->w_a = 0.; + c->h = 0.; + c->w = 0.; + + c->a_begin = 1.; + c->a_end = 1.; + c->log_a_begin = 0.; + c->log_a_end = 0.; + + c->H = 1.; + c->a = 1.; + c->a_inv = 1.; + c->a_dot = 0.; + c->time = 0.; + c->universe_age_at_present_day = 0.; + + /* Initialise the interpolation tables */ + c->drift_fac_interp_table = NULL; + c->grav_kick_fac_interp_table = NULL; + c->hydro_kick_fac_interp_table = NULL; + c->time_interp_table = NULL; + c->time_interp_table_offset = 0.; +} + /** * @brief Computes the cosmology factor that enters the drift operator. * diff --git a/src/cosmology.h b/src/cosmology.h index 2611a1ea96038e9ac313190eaeecf3e88c438b45..62f57275f393b610f274914b2417e25b1b1c6f57 100644 --- a/src/cosmology.h +++ b/src/cosmology.h @@ -146,6 +146,11 @@ void cosmology_init(const struct swift_params *params, const struct unit_system *us, const struct phys_const *phys_const, struct cosmology *c); +void cosmology_init_no_cosmo(const struct swift_params *params, + const struct unit_system *us, + const struct phys_const *phys_const, + struct cosmology *c); + void cosmology_print(const struct cosmology *c); void cosmology_clean(struct cosmology *c);