SDDSlib
|
Fourth-order Runge-Kutta ODE integration routines (double-precision version). More...
#include "mdb.h"
#include <float.h>
Go to the source code of this file.
Macros | |
#define | MAX_EXIT_ITERATIONS 400 |
#define | ITER_FACTOR 0.995 |
#define | TINY 1.0e-30 |
#define | DEBUG 0 |
#define | MAX_N_STEP_UPS 10 |
#define | MAX_N_STEP_UPS 10 |
#define | MAX_N_STEP_UPS 10 |
#define | MAX_N_STEP_UPS 10 |
#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 | report_state_dp (FILE *fp, double *y, double *dydx, double *yscale, long *misses, double x, double h, long n_eq) |
void | rk4_step (double *yf, double x, double *yi, double *dydx, double h, long n_eq, void(*derivs)(double *dydx, double *y, double x)) |
void | rk4_qctune (double newSafetyMargin, double newIncreasePower, double newDecreasePower, double newMaxIncreaseFactor) |
long | rk_qcstep (double *yFinal, double *x, double *yInitial, double *dydxInitial, double hInput, double *hUsed, double *hRecommended, double *yScale, long equations, void(*derivs)(double *dydx, double *y, double x), long *misses) |
long | rk_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 exval)) |
Integrate a set of ODEs until the upper limit or an exit condition is met. | |
long | rk_odeint1 (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) |
Integrate ODEs without exit conditions or intermediate output. | |
long | rk_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) |
Integrate ODEs until a specific component reaches a target value. | |
long | rk_odeint_na (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, double h_max, double *h_rec) |
Integrate ODEs without adaptive step-size control. | |
long | rk_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) |
Integrate ODEs with an exit condition. | |
long | rk_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)) |
Integrate ODEs until a specific component reaches a target value with intermediate storage. | |
long | rk_odeint3_na (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_step, double h_max, double *h_rec, double(*exit_func)(double *dydx, double *y, double x), double exit_accuracy, void(*stochastic)(double *y, double x, double h)) |
Integrate ODEs without adaptive step-size and with stochastic processes. | |
Variables | |
static double | safetyMargin = 0.9 |
static double | increasePower = 0.2 |
static double | decreasePower = 0.25 |
static double | maxIncreaseFactor = 4.0 |
Fourth-order Runge-Kutta ODE integration routines (double-precision version).
This file provides functions for integrating ordinary differential equations using fourth-order Runge-Kutta methods. It includes adaptive step-size control and supports various integration scenarios.
Definition in file rkODE.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.
void report_state_dp | ( | FILE * | fp, |
double * | y, | ||
double * | dydx, | ||
double * | yscale, | ||
long * | misses, | ||
double | x, | ||
double | h, | ||
long | n_eq ) |
Definition at line 116 of file rkODE.c.
void rk4_qctune | ( | double | newSafetyMargin, |
double | newIncreasePower, | ||
double | newDecreasePower, | ||
double | newMaxIncreaseFactor ) |
Definition at line 220 of file rkODE.c.
void rk4_step | ( | double * | yf, |
double | x, | ||
double * | yi, | ||
double * | dydx, | ||
double | h, | ||
long | n_eq, | ||
void(* | derivs )(double *dydx, double *y, double x) ) |
Definition at line 141 of file rkODE.c.
long rk_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 exval) ) |
Integrate a set of ODEs until the upper limit or an exit condition is met.
Integrates a system of ordinary differential equations using adaptive step-size control until the independent variable reaches the upper limit or a user-defined exit condition is satisfied.
y0 | Initial and final values of dependent variables. |
derivs | Function to compute derivatives. |
n_eq | Number of equations. |
accuracy | Desired accuracies for each variable. |
accmode | Accuracy control modes for each variable. |
tiny | Small values relative to what's important for each variable. |
misses | Array tracking the number of step size reductions per variable. |
x0 | Pointer to the initial value of the independent variable. Updated to final value. |
xf | Upper limit of the independent variable. |
x_accuracy | Desired accuracy for the final value of the independent variable. |
h_start | Suggested starting step size. |
h_max | Maximum step size allowed. |
h_rec | Pointer to store the recommended step size for continuation. |
exit_func | Function to determine when to stop integration based on a condition. |
exit_accuracy | Accuracy required for the exit condition. |
n_to_skip | Number of zeros of the exit function to skip before returning. |
store_data | Function to store intermediate data points. |
Definition at line 397 of file rkODE.c.
long rk_odeint1 | ( | 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 ) |
Integrate ODEs without exit conditions or intermediate output.
Integrates a system of ordinary differential equations until the upper limit of the independent variable is reached. This function does not monitor exit conditions or store intermediate data, making it faster for simple integrations.
y0 | Initial and final values of dependent variables. |
derivs | Function to compute derivatives. |
n_eq | Number of equations. |
accuracy | Ignored in this function. |
accmode | Ignored in this function. |
tiny | Ignored in this function. |
misses | Ignored in this function. |
x0 | Pointer to the initial value of the independent variable. Updated to final value. |
xf | Upper limit of the independent variable. |
x_accuracy | Ignored in this function. |
h_start | Step size. |
h_max | Maximum step size allowed. |
h_rec | Pointer to store the recommended step size for continuation. |
Definition at line 659 of file rkODE.c.
long rk_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 ) |
Integrate ODEs until a specific component reaches a target value.
Integrates a system of ordinary differential equations until a specified component of the solution reaches a target value within a given accuracy. This function does not monitor general exit conditions or store intermediate data.
y0 | Initial and final values of dependent variables. |
derivs | Function to compute derivatives. |
n_eq | Number of equations. |
accuracy | Desired accuracies for each variable. |
accmode | Accuracy control modes for each variable. |
tiny | Small values relative to what's important for each variable. |
misses | Array tracking the number of step size reductions per variable. |
x0 | Pointer to the initial value of the independent variable. Updated to final value. |
xf | Upper limit of the independent variable. |
x_accuracy | Desired accuracy for the final value of the independent variable. |
h_start | Suggested starting step size. |
h_max | Maximum step size allowed. |
h_rec | Pointer to store the recommended step size for continuation. |
exit_value | Target value for the specified component. |
i_exit_value | Index of the component to monitor. |
exit_accuracy | Accuracy required for the target value. |
n_to_skip | Number of target value crossings to skip before stopping. |
Definition at line 812 of file rkODE.c.
long rk_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 ) |
Integrate ODEs with an exit condition.
Integrates a system of ordinary differential equations until the upper limit of the independent variable is reached or a user-defined exit condition is satisfied.
yif | Initial and final values of dependent variables. |
derivs | Function to compute derivatives. |
n_eq | Number of equations. |
accuracy | Desired accuracies for each variable. |
accmode | Accuracy control modes for each variable. |
tiny | Small values relative to what's important for each variable. |
misses | Array tracking the number of step size reductions per variable. |
x0 | Pointer to the initial value of the independent variable. Updated to final value. |
xf | Upper limit of the independent variable. |
x_accuracy | Desired accuracy for the final value of the independent variable. |
h_start | Suggested starting step size. |
h_max | Maximum step size allowed. |
h_rec | Pointer to store the recommended step size for continuation. |
exit_func | Function to determine when to stop integration based on a condition. |
exit_accuracy | Accuracy required for the exit condition. |
Definition at line 1147 of file rkODE.c.
long rk_odeint3_na | ( | 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_step, | ||
double | h_max, | ||
double * | h_rec, | ||
double(* | exit_func )(double *dydx, double *y, double x), | ||
double | exit_accuracy, | ||
void(* | stochastic )(double *y, double x, double h) ) |
Integrate ODEs without adaptive step-size and with stochastic processes.
Integrates a system of ordinary differential equations without using adaptive step-size control and allows for the inclusion of stochastic processes.
yif | Initial and final values of dependent variables. |
derivs | Function to compute derivatives. |
n_eq | Number of equations. |
accuracy | Ignored in this function. |
accmode | Ignored in this function. |
tiny | Ignored in this function. |
misses | Ignored in this function. |
x0 | Pointer to the initial value of the independent variable. Updated to final value. |
xf | Upper limit of the independent variable. |
x_accuracy | Desired accuracy for the final value of the independent variable. |
h_step | Step size. |
h_max | Ignored in this function. |
h_rec | Ignored in this function. |
exit_func | Function to determine when to stop integration based on a condition. |
exit_accuracy | Accuracy required for the exit condition. |
stochastic | Function to add stochastic processes to the solution. |
Definition at line 1609 of file rkODE.c.
long rk_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) ) |
Integrate ODEs until a specific component reaches a target value with intermediate storage.
Integrates a system of ordinary differential equations until a specified component of the solution reaches a target value within a given accuracy. Allows for storing intermediate data points during the integration process.
y0 | Initial and final values of dependent variables. |
derivs | Function to compute derivatives. |
n_eq | Number of equations. |
accuracy | Desired accuracies for each variable. |
accmode | Accuracy control modes for each variable. |
tiny | Small values relative to what's important for each variable. |
misses | Array tracking the number of step size reductions per variable. |
x0 | Pointer to the initial value of the independent variable. Updated to final value. |
xf | Upper limit of the independent variable. |
x_accuracy | Desired accuracy for the final value of the independent variable. |
h_start | Suggested starting step size. |
h_max | Maximum step size allowed. |
h_rec | Pointer to store the recommended step size for continuation. |
exit_value | Target value for the specified component. |
i_exit_value | Index of the component to monitor. |
exit_accuracy | Accuracy required for the target value. |
n_to_skip | Number of target value crossings to skip before stopping. |
store_data | Function to store intermediate data points. |
Definition at line 1362 of file rkODE.c.
long rk_odeint_na | ( | 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, | ||
double | h_max, | ||
double * | h_rec ) |
Integrate ODEs without adaptive step-size control.
Integrates a system of ordinary differential equations without using adaptive step-size control. This function is intended for scenarios where adaptive control is not required and allows for faster computations.
y0 | Initial and final values of dependent variables. |
derivs | Function to compute derivatives. |
n_eq | Number of equations. |
accuracy | Ignored in this function. |
accmode | Ignored in this function. |
tiny | Ignored in this function. |
misses | Ignored in this function. |
x0 | Pointer to the initial value of the independent variable. Updated to final value. |
xf | Upper limit of the independent variable. |
x_accuracy | Ignored in this function. |
h | Step size. |
h_max | Ignored in this function. |
h_rec | Ignored in this function. |
Definition at line 1046 of file rkODE.c.
long rk_qcstep | ( | double * | yFinal, |
double * | x, | ||
double * | yInitial, | ||
double * | dydxInitial, | ||
double | hInput, | ||
double * | hUsed, | ||
double * | hRecommended, | ||
double * | yScale, | ||
long | equations, | ||
void(* | derivs )(double *dydx, double *y, double x), | ||
long * | misses ) |
Definition at line 232 of file rkODE.c.