apply_chemistry_timestep_control Subroutine

subroutine apply_chemistry_timestep_control(flow, params, max_dT, max_dY, max_rel_drho, min_alpha)

Cut the next dynamic timestep when chemistry produced a large state jump. This does not reject the current step; it prevents the next operator-split chemistry/projection update from repeating an overly large heat-release jump.

Arguments

Type IntentOptional Attributes Name
type(flow_mpi_t), intent(in) :: flow
type(case_params_t), intent(inout) :: params
real(kind=rk), intent(in) :: max_dT
real(kind=rk), intent(in) :: max_dY
real(kind=rk), intent(in) :: max_rel_drho
real(kind=rk), intent(in) :: min_alpha

Source Code

   subroutine apply_chemistry_timestep_control(flow, params, max_dT, max_dY, max_rel_drho, min_alpha)
      type(flow_mpi_t), intent(in) :: flow
      type(case_params_t), intent(inout) :: params
      real(rk), intent(in) :: max_dT, max_dY, max_rel_drho, min_alpha

      real(rk) :: factor, old_dt, threshold

      if (.not. params%use_dynamic_dt) return
      factor = one

      threshold = params%chemistry_max_dT_per_step
      if (threshold > zero .and. max_dT > threshold) then
         factor = min(factor, params%chemistry_dt_safety * threshold / max(max_dT, tiny(1.0_rk)))
      end if

      threshold = params%chemistry_max_dY_per_step
      if (threshold > zero .and. max_dY > threshold) then
         factor = min(factor, params%chemistry_dt_safety * threshold / max(max_dY, tiny(1.0_rk)))
      end if

      threshold = params%chemistry_max_rel_rho_change_per_step
      if (threshold > zero .and. max_rel_drho > threshold) then
         factor = min(factor, params%chemistry_dt_safety * threshold / max(max_rel_drho, tiny(1.0_rk)))
      end if

      factor = max(params%chemistry_dt_min_factor, min(one, factor))
      if (factor < one) then
         old_dt = params%dt
         params%dt = max(params%min_dt, min(params%max_dt, params%dt * factor))
         if (flow%rank == 0) then
            write(output_unit,'(a,es11.4,a,es11.4,a,es11.4,a,es11.4,a,es11.4,a,es11.4,a,es11.4)') &
               'chemistry dt control: dt ', old_dt, ' -> ', params%dt, &
               ' max_dT=', max_dT, ' max_dY=', max_dY, &
               ' max_rel_drho=', max_rel_drho, ' min_alpha=', min_alpha
         end if
      end if
   end subroutine apply_chemistry_timestep_control