SDDSlib
|
Bulirsch-Stoer method implementation for solving ordinary differential equations using polynomial extrapolation. More...
#include "mdb.h"
Go to the source code of this file.
Macros | |
#define | DEBUG 0 |
#define | IMAX 11 |
#define | NUSE 7 |
#define | TINY 1.0e-30 |
#define | MAX_N_STEP_UPS 10 |
#define | MAX_N_STEP_UPS 10 |
#define | MAX_N_STEP_UPS 10 |
#define | TINY 1.0e-30 |
#define | MAX_N_STEP_UPS 10 |
#define | MAX_N_STEP_UPS 10 |
Functions | |
void | new_scale_factors_dp (double *yscale, double *y0, double *dydx0, double h_start, double *tiny, long *accmode, double *accuracy, long n_eq) |
void | initial_scale_factors_dp (double *yscale, double *y0, double *dydx0, double h_start, double *tiny, long *accmode, double *accuracy, double *accur, double x0, double xf, long n_eq) |
void | bs_qctune (double newStepIncreaseFactor, double newStepDecreaseFactor) |
long | bs_step (double *yFinal, double *x, double *yInitial, double *dydxInitial, double step, double *stepUsed, double *stepRecommended, double *yScale, long equations, void(*derivs)(double *dydx, double *y, double x), long *misses) |
long | bs_odeint (double *y0, void(*derivs)(double *dydx, double *y, double x), long n_eq, double *accuracy, long *accmode, double *tiny, long *misses, double *x0, double xf, double x_accuracy, double h_start, double h_max, double *h_rec, double(*exit_func)(double *dydx, double *y, double x), double exit_accuracy, long n_to_skip, void(*store_data)(double *dydx, double *y, double x, double exf)) |
Integrates a system of ordinary differential equations using the Bulirsch-Stoer method. | |
long | bs_odeint1 (double *y0, void(*derivs)(), long n_eq, double *accuracy, long *accmode, double *tiny, long *misses, double *x0, double xf, double x_accuracy, double h_start, double h_max, double *h_rec) |
Integrates a system of ordinary differential equations to a specified upper limit without exit condition checks or intermediate data storage. | |
long | bs_odeint2 (double *y0, void(*derivs)(double *dydx, double *y, double x), long n_eq, double *accuracy, long *accmode, double *tiny, long *misses, double *x0, double xf, double x_accuracy, double h_start, double h_max, double *h_rec, double exit_value, long i_exit_value, double exit_accuracy, long n_to_skip) |
Integrates a system of ordinary differential equations until a specified component reaches a target value or the upper limit is met. | |
long | bs_odeint3 (double *yif, void(*derivs)(double *dydx, double *y, double x), long n_eq, double *accuracy, long *accmode, double *tiny, long *misses, double *x0, double xf, double x_accuracy, double h_start, double h_max, double *h_rec, double(*exit_func)(double *dydx, double *y, double x), double exit_accuracy) |
Integrates a system of ordinary differential equations using the Bulirsch-Stoer method with optimized internal state management. | |
long | bs_odeint4 (double *y0, void(*derivs)(double *dydx, double *y, double x), long n_eq, double *accuracy, long *accmode, double *tiny, long *misses, double *x0, double xf, double x_accuracy, double h_start, double h_max, double *h_rec, double exit_value, long i_exit_value, double exit_accuracy, long n_to_skip, void(*store_data)(double *dydx, double *y, double x, double exf)) |
Integrates a system of ordinary differential equations until a specified component reaches a target value or the upper limit is met, with intermediate data storage. | |
Variables | |
static double | stepIncreaseFactor = 0.50 |
static double | stepDecreaseFactor = 0.95 |
Bulirsch-Stoer method implementation for solving ordinary differential equations using polynomial extrapolation.
This file contains the implementation of the Bulirsch-Stoer method for integrating ordinary differential equations (ODEs). It includes functions for performing integration steps, handling scale factors, and managing accuracy controls.
Definition in file bsODEp.c.
long bs_odeint | ( | double * | y0, |
void(* | derivs )(double *dydx, double *y, double x), | ||
long | n_eq, | ||
double * | accuracy, | ||
long * | accmode, | ||
double * | tiny, | ||
long * | misses, | ||
double * | x0, | ||
double | xf, | ||
double | x_accuracy, | ||
double | h_start, | ||
double | h_max, | ||
double * | h_rec, | ||
double(* | exit_func )(double *dydx, double *y, double x), | ||
double | exit_accuracy, | ||
long | n_to_skip, | ||
void(* | store_data )(double *dydx, double *y, double x, double exf) ) |
Integrates a system of ordinary differential equations using the Bulirsch-Stoer method.
This function integrates a set of ODEs from an initial value until the upper limit of the independent variable is reached or a user-supplied exit condition function evaluates to zero.
y0 | Pointer to the array of initial values of the dependent variables. Upon successful completion, it contains the final values. |
derivs | Function pointer to compute the derivatives. It calculates dy/dx given the current state. |
n_eq | Number of equations or dependent variables in the system. |
accuracy | Pointer to the array specifying the desired accuracy for each dependent variable. |
accmode | Pointer to the array specifying the accuracy control mode for each dependent variable. Modes:
|
tiny | Pointer to the array of small values representing the lower limits of significance for each dependent variable. |
misses | Pointer to the array that counts the number of times each variable caused a step size reset due to exceeding error tolerance. |
x0 | Pointer to the initial value of the independent variable. It is updated to the final value after integration. |
xf | Upper limit of the independent variable to integrate up to. |
x_accuracy | Desired accuracy for the final value of the independent variable. |
h_start | Suggested starting step size for the integration. |
h_max | Maximum allowed step size for the integration. |
h_rec | Pointer to the variable where the recommended step size for continuation will be stored. |
exit_func | Function pointer to the exit condition function. It returns a value that, when zero, signals the integration to stop. |
exit_accuracy | Desired accuracy for the exit condition function to evaluate to zero. |
n_to_skip | Number of zeros of the exit function to skip before returning. |
store_data | Function pointer to store intermediate integration points. It is called with the current derivatives, dependent variables, independent variable, and exit function value. |
Definition at line 179 of file bsODEp.c.
long bs_odeint1 | ( | double * | y0, |
void(* | derivs )(), | ||
long | n_eq, | ||
double * | accuracy, | ||
long * | accmode, | ||
double * | tiny, | ||
long * | misses, | ||
double * | x0, | ||
double | xf, | ||
double | x_accuracy, | ||
double | h_start, | ||
double | h_max, | ||
double * | h_rec ) |
Integrates a system of ordinary differential equations to a specified upper limit without exit condition checks or intermediate data storage.
This function is a streamlined version of bs_odeint()
that integrates the ODE system until the upper limit of the independent variable is reached. It does not evaluate a user-supplied exit condition function or store intermediate integration points, resulting in improved performance.
y0 | Pointer to the array of initial values of the dependent variables. Upon successful completion, it contains the final values. |
derivs | Function pointer to compute the derivatives. It calculates dy/dx given the current state. |
n_eq | Number of equations or dependent variables in the system. |
accuracy | Pointer to the array specifying the desired accuracy for each dependent variable. |
accmode | Pointer to the array specifying the accuracy control mode for each dependent variable. Modes:
|
tiny | Pointer to the array of small values representing the lower limits of significance for each dependent variable. |
misses | Pointer to the array that counts the number of times each variable caused a step size reset due to exceeding error tolerance. |
x0 | Pointer to the initial value of the independent variable. It is updated to the final value after integration. |
xf | Upper limit of the independent variable to integrate up to. |
x_accuracy | Desired accuracy for the final value of the independent variable. |
h_start | Suggested starting step size for the integration. |
h_max | Maximum allowed step size for the integration. |
h_rec | Pointer to the variable where the recommended step size for continuation will be stored. |
Definition at line 456 of file bsODEp.c.
long bs_odeint2 | ( | double * | y0, |
void(* | derivs )(double *dydx, double *y, double x), | ||
long | n_eq, | ||
double * | accuracy, | ||
long * | accmode, | ||
double * | tiny, | ||
long * | misses, | ||
double * | x0, | ||
double | xf, | ||
double | x_accuracy, | ||
double | h_start, | ||
double | h_max, | ||
double * | h_rec, | ||
double | exit_value, | ||
long | i_exit_value, | ||
double | exit_accuracy, | ||
long | n_to_skip ) |
Integrates a system of ordinary differential equations until a specified component reaches a target value or the upper limit is met.
This function integrates the ODE system until either the independent variable reaches the specified upper limit or a particular dependent variable reaches a target value within a specified accuracy. It does not evaluate a general exit condition function or store intermediate data, offering improved performance compared to bs_odeint()
.
y0 | Pointer to the array of initial values of the dependent variables. Upon successful completion, it contains the final values. |
derivs | Function pointer to compute the derivatives. It calculates dy/dx given the current state. |
n_eq | Number of equations or dependent variables in the system. |
accuracy | Pointer to the array specifying the desired accuracy for each dependent variable. |
accmode | Pointer to the array specifying the accuracy control mode for each dependent variable. Modes:
|
tiny | Pointer to the array of small values representing the lower limits of significance for each dependent variable. |
misses | Pointer to the array that counts the number of times each variable caused a step size reset due to exceeding error tolerance. |
x0 | Pointer to the initial value of the independent variable. It is updated to the final value after integration. |
xf | Upper limit of the independent variable to integrate up to. |
x_accuracy | Desired accuracy for the final value of the independent variable. |
h_start | Suggested starting step size for the integration. |
h_max | Maximum allowed step size for the integration. |
h_rec | Pointer to the variable where the recommended step size for continuation will be stored. |
exit_value | Target value that the specified component of the solution should reach. |
i_exit_value | Index of the dependent variable component that is being monitored for reaching the target value. |
exit_accuracy | Desired accuracy for the target value condition. |
n_to_skip | Number of times the target condition can be met before integration stops. |
Definition at line 599 of file bsODEp.c.
long bs_odeint3 | ( | double * | yif, |
void(* | derivs )(double *dydx, double *y, double x), | ||
long | n_eq, | ||
double * | accuracy, | ||
long * | accmode, | ||
double * | tiny, | ||
long * | misses, | ||
double * | x0, | ||
double | xf, | ||
double | x_accuracy, | ||
double | h_start, | ||
double | h_max, | ||
double * | h_rec, | ||
double(* | exit_func )(double *dydx, double *y, double x), | ||
double | exit_accuracy ) |
Integrates a system of ordinary differential equations using the Bulirsch-Stoer method with optimized internal state management.
This function is a variant of bs_odeint()
that utilizes internal static variables to manage state across multiple integration steps, potentially improving performance in scenarios requiring repeated integrations.
yif | Pointer to the array of initial/final values of dependent variables. Upon successful completion, it contains the final values. |
derivs | Function pointer to compute the derivatives. It calculates dy/dx given the current state. |
n_eq | Number of equations or dependent variables in the system. |
accuracy | Pointer to the array specifying the desired accuracy for each dependent variable. |
accmode | Pointer to the array specifying the accuracy control mode for each dependent variable. Modes:
|
tiny | Pointer to the array of small values representing the lower limits of significance for each dependent variable. |
misses | Pointer to the array that counts the number of times each variable caused a step size reset due to exceeding error tolerance. |
x0 | Pointer to the initial value of the independent variable. It is updated to the final value after integration. |
xf | Upper limit of the independent variable to integrate up to. |
x_accuracy | Desired accuracy for the final value of the independent variable. |
h_start | Suggested starting step size for the integration. |
h_max | Maximum allowed step size for the integration. |
h_rec | Pointer to the variable where the recommended step size for continuation will be stored. |
exit_func | Function pointer to the exit condition function. It returns a value that, when zero, signals the integration to stop. |
exit_accuracy | Desired accuracy for the exit condition function to evaluate to zero. |
Definition at line 836 of file bsODEp.c.
long bs_odeint4 | ( | double * | y0, |
void(* | derivs )(double *dydx, double *y, double x), | ||
long | n_eq, | ||
double * | accuracy, | ||
long * | accmode, | ||
double * | tiny, | ||
long * | misses, | ||
double * | x0, | ||
double | xf, | ||
double | x_accuracy, | ||
double | h_start, | ||
double | h_max, | ||
double * | h_rec, | ||
double | exit_value, | ||
long | i_exit_value, | ||
double | exit_accuracy, | ||
long | n_to_skip, | ||
void(* | store_data )(double *dydx, double *y, double x, double exf) ) |
Integrates a system of ordinary differential equations until a specified component reaches a target value or the upper limit is met, with intermediate data storage.
This function extends bs_odeint2()
by allowing the storage of intermediate integration points. It integrates the ODE system until either the independent variable reaches the specified upper limit or a particular dependent variable reaches a target value within a specified accuracy.
y0 | Pointer to the array of initial values of dependent variables. Upon successful completion, it contains the final values. |
derivs | Function pointer to compute the derivatives. It calculates dy/dx given the current state. |
n_eq | Number of equations or dependent variables in the system. |
accuracy | Pointer to the array specifying the desired accuracy for each dependent variable. |
accmode | Pointer to the array specifying the accuracy control mode for each dependent variable. Modes:
|
tiny | Pointer to the array of small values representing the lower limits of significance for each dependent variable. |
misses | Pointer to the array that counts the number of times each variable caused a step size reset due to exceeding error tolerance. |
x0 | Pointer to the initial value of the independent variable. It is updated to the final value after integration. |
xf | Upper limit of the independent variable to integrate up to. |
x_accuracy | Desired accuracy for the final value of the independent variable. |
h_start | Suggested starting step size for the integration. |
h_max | Maximum allowed step size for the integration. |
h_rec | Pointer to the variable where the recommended step size for continuation will be stored. |
exit_value | Target value that the specified component of the solution should reach. |
i_exit_value | Index of the dependent variable component that is being monitored for reaching the target value. |
exit_accuracy | Desired accuracy for the target value condition. |
n_to_skip | Number of times the target condition can be met before integration stops. |
store_data | Function pointer to store intermediate integration points. It is called with the current derivatives, dependent variables, independent variable, and exit function value. |
Definition at line 1051 of file bsODEp.c.
void bs_qctune | ( | double | newStepIncreaseFactor, |
double | newStepDecreaseFactor ) |
long bs_step | ( | double * | yFinal, |
double * | x, | ||
double * | yInitial, | ||
double * | dydxInitial, | ||
double | step, | ||
double * | stepUsed, | ||
double * | stepRecommended, | ||
double * | yScale, | ||
long | equations, | ||
void(* | derivs )(double *dydx, double *y, double x), | ||
long * | misses ) |
Definition at line 47 of file bsODEp.c.
void initial_scale_factors_dp | ( | double * | yscale, |
double * | y0, | ||
double * | dydx0, | ||
double | h_start, | ||
double * | tiny, | ||
long * | accmode, | ||
double * | accuracy, | ||
double * | accur, | ||
double | x0, | ||
double | xf, | ||
long | n_eq ) |
Definition at line 70 of file rkODE.c.
void new_scale_factors_dp | ( | double * | yscale, |
double * | y0, | ||
double * | dydx0, | ||
double | h_start, | ||
double * | tiny, | ||
long * | accmode, | ||
double * | accuracy, | ||
long | n_eq ) |
Definition at line 28 of file rkODE.c.