46template <concepts::formula Formula>
82 problem.evaluate_on(initial_time, initial_variable,
86 const auto [step_size_from_diff, initial_diff_norm] =
88 initial_variable, initial_diff, tolerances);
92 initial_variable, initial_diff, step_size_from_diff,
93 initial_diff_norm, tolerances);
96 std::min(1e+2 * step_size_from_diff, step_size_from_second_diff);
98 "Selection of step size without limits: {}",
99 step_size_without_limit);
102 limits.apply(step_size_without_limit);
104 "Final selection of step size: {}", step_size_without_limit);
106 return final_step_size;
123 -> std::tuple<scalar_type, scalar_type> {
126 tolerances.calc_norm(initial_variable, initial_variable);
128 this->
logger(),
"Norm of variable: {}", initial_variable_norm);
132 tolerances.calc_norm(initial_variable, initial_diff);
134 this->
logger(),
"Norm of first derivative: {}", initial_diff_norm);
138 (initial_variable_norm >=
static_cast<scalar_type>(1e-5) &&
139 initial_diff_norm >=
static_cast<scalar_type>(1e-5))
140 ?
static_cast<scalar_type>(1e-2) * initial_variable_norm /
144 "First estimate of step size using differential coefficient: {}",
145 step_size_from_diff);
147 return {step_size_from_diff, initial_diff_norm};
173 initial_variable + step_size_from_diff * initial_diff;
175 problem.evaluate_on(initial_time + step_size_from_diff,
177 const variable_type& euler_updated_diff = problem.diff_coeff();
181 tolerances.calc_norm(
182 initial_variable, euler_updated_diff - initial_diff) /
185 this->
logger(),
"Norm of second derivative: {}", second_diff_norm);
188 std::max(initial_diff_norm, second_diff_norm);
195 ? std::pow(
static_cast<scalar_type>(1e-2) / larger_norm,
198 static_cast<scalar_type>(1e-3) * step_size_from_diff);
200 "Second estimate of step size using second derivative: {}",
201 step_size_from_second_diff);
203 return step_size_from_second_diff;
Class of tags of logs without memory management.
Class to incorporate logging in algorithms.
logging_mixin(log_tag_view tag)
Constructor.
auto logger() const noexcept -> const num_collect::logging::logger &
Access to the logger.
Class of error tolerances hairer1993.
Class to calculate initial step sizes hairer1993.
auto calculate_step_size_from_diff(const variable_type &initial_variable, const variable_type &initial_diff, const error_tolerances< variable_type > &tolerances) const -> std::tuple< scalar_type, scalar_type >
Calculate a step size from differential coefficients at the initial time.
typename formula_type::problem_type problem_type
Type of problem.
auto calculate_step_size_from_second_diff(problem_type &problem, const scalar_type &initial_time, const variable_type &initial_variable, const variable_type &initial_diff, const scalar_type &step_size_from_diff, const scalar_type &initial_diff_norm, const error_tolerances< variable_type > &tolerances) const
Calculate a step size using a estimate of the second derivative.
typename problem_type::scalar_type scalar_type
Type of scalars.
auto calculate(problem_type &problem, const scalar_type &initial_time, const variable_type &initial_variable, const step_size_limits< scalar_type > &limits, const error_tolerances< variable_type > &tolerances) const -> scalar_type
Calculate the initial step size.
Formula formula_type
Type of formula.
initial_step_size_calculator()
Constructor.
typename problem_type::variable_type variable_type
Type of variables.
Class of limits of step sizes.
Definition of error_tolerances class.
Definition of evaluation_type enumeration.
Definition of get_least_known_order function.
Definition of log_tag_view class.
Definition of macros for logging.
#define NUM_COLLECT_LOG_TRACE(LOGGER,...)
Write a trace log.
Definition of logging_mixin class.
constexpr auto get_least_known_order() -> index_type
Get the least known order of a formula.
Namespace of solvers of ordinary differential equations (ODE).
constexpr auto initial_step_size_calculator_log_tag
Log tag.
Definition of step_size_limits class.
Struct to specify types of evaluations.