diff --git a/src/engine.c b/src/engine.c index f49550b702e762470c24314f9652726d04ec8aed..83d2c3cbb0df4fed49621e38cc9dda59f675e44b 100644 --- a/src/engine.c +++ b/src/engine.c @@ -1820,13 +1820,14 @@ void engine_run_rt_sub_cycles(struct engine *e) { /* Get some time variables for printouts. Don't update the ones in the * engine like in the regular step, or the outputs in the regular steps * will be wrong. */ - /* think cosmology one day: needs adapting here */ - /* Also needs adapting further below - we print out current values of a - * and z. They need to be updated in the engine. */ - if (e->policy & engine_policy_cosmology) - error("Can't run RT subcycling with cosmology yet"); - const double dt_subcycle = rt_step_size * e->time_base; - double time = e->ti_current_subcycle * e->time_base + e->time_begin; + double dt_subcycle; + if (e->policy & engine_policy_cosmology) { + dt_subcycle = + cosmology_get_delta_time(e->cosmology, e->ti_current, e->ti_rt_end_min); + } else { + dt_subcycle = rt_step_size * e->time_base; + } + double time = e->time; /* Keep track and accumulate the deadtime over all sub-cycles. */ /* We need to manually put this back in the engine struct when @@ -1886,10 +1887,17 @@ void engine_run_rt_sub_cycles(struct engine *e) { e->max_active_bin_subcycle = get_max_active_bin(e->ti_current_subcycle); e->min_active_bin_subcycle = get_min_active_bin(e->ti_current_subcycle, ti_subcycle_old); - /* think cosmology one day: needs adapting here */ - if (e->policy & engine_policy_cosmology) - error("Can't run RT subcycling with cosmology yet"); - time = e->ti_current_subcycle * e->time_base + e->time_begin; + /* TODO: add rt_props_update() for cosmological thermochemistry*/ + if (e->policy & engine_policy_cosmology) { + double time_old = time; + cosmology_update( + e->cosmology, e->physical_constants, + e->ti_current_subcycle); // Update cosmological parameters + time = e->cosmology->time; // Grab new cosmology time + dt_subcycle = time - time_old; + } else { + time = e->ti_current_subcycle * e->time_base + e->time_begin; + } /* Do the actual work now. */ engine_unskip_rt_sub_cycle(e);