|
Robotran C Documentation
|
Go to the documentation of this file.
14 #ifndef __INTEGRATOR_H_INCLUDED__ // guard against multiple/recursive includes
15 #define __INTEGRATOR_H_INCLUDED__
83 int rk4(
double y[],
double dydx[],
int n,
double x,
double h,
double yout[],
112 double *x,
double y[],
double eps,
double hmax,
double htry,
113 long nmax,
double dydx[],
double yscal[],
double *hnext,
MbsData *s,
120 int ThetaSC(
double y[],
double dydx[],
int n,
double x,
double h,
double yout[],
143 int mbs_estim_jac_acc(
double x,
double htry,
double y[],
double dydx[],
int compute_dfdx,
double dfdx[],
double **dfdy,
int n,
171 int mbs_freeze_jac(
int freeze_index,
int *next_freeze_index,
double x,
double h,
double y[],
double dydx[],
172 int compute_dfdx,
double dfdx[],
double **dfdy,
double dydx_freeze[],
double dfdx_freeze[],
double **dfdy_freeze,
193 int euler_implicit(
double y[],
double dydx[],
int n,
double *x,
double h,
double yout[],
214 int w_methods(
double y[],
double dydx[],
int n,
double x,
double h,
double yout[],
void print_warnings_integrator(MbsData *mbs_data, MbsDirdyn *mbs_dd, int type_of_integrator)
Check the options set by user to warn him when he modified an unused option for the integrator.
Definition: integrator.c:250
Implementation of eig function using lapacke without using the lapackE interface.
Definition: cholesky.c:14
int loop_bader(double t0, double tf, MbsData *mbs_data, MbsDirdyn *mbs_dd)
Integrate the motion from t0 to tf.
Definition: mbs_bader.c:61
int mbs_estim_jac_acc(double x, double htry, double y[], double dydx[], int compute_dfdx, double dfdx[], double **dfdy, int n, int(*derivs)(double, double[], double[], MbsData *, MbsDirdyn *), MbsData *s, MbsDirdyn *dd)
Evaluate the Jacobian of a function accelerations using finite difference.
Definition: integrator.c:30
@ Bader
Definition: integrator.h:29
This header defines global functions for Euler Implicit integrator in C.
int(* loop_integrator_ptr)(double t0, double tf, MbsData *mbs_data, MbsDirdyn *mbs_dd)
main loop of integration, in which the integrator is called
Definition: integrator.h:39
This header defines global functions for W methods integrator in C.
int mbs_eig_0(double **A, int n, double *eval_a, double *eval_b, double **evec_r, double **evec_phi)
Compute the eigen values and vector of a matrix with index starting a 0.
Definition: eig_lapacke.c:29
void mbs_error_msg(char *msg,...)
Send an error message.
Definition: mbs_message.c:102
int nState
size of the state vector
Definition: mbs_dirdyn_struct.h:152
@ EulerEx
Definition: integrator.h:29
This header defines global functions for Bader integrator in C.
int loop_w_methods(double t0, double tf, MbsData *mbs_data, MbsDirdyn *mbs_dd)
Integrate the motion from t0 to tf.
Definition: mbs_w_methods.c:77
double * get_dvec_0(int l_v)
create (with memory allocation) a vector (length l_v) of doubles, starting at index 0
Definition: mbs_1D_array.c:880
double dt_max
maximal time step [s], default = 1.0e-3
Definition: mbs_dirdyn_struct.h:130
#define DIRDYN_INTEGRATOR_OPTION_DEFAULT_dt_max
Definition: mbs_dirdyn_struct.h:31
void print_warnings_constant_step_integrator(MbsDirdyn *mbs_dd, char *integrator_name)
Print the warning message, called by print_warnings_integrator for constant step size dt integrators.
Definition: integrator.c:324
void copy_dmat_0(double **tab_src, double **tab_dest, int nb_r, int nb_c)
Copy the content of a [nb_r times nb_c] matrix of doubles to a second matrix, starting with index 0.
Definition: mbs_matrix.c:363
int nmax
maximal number of steps [-], default = 1e9
Definition: mbs_dirdyn_struct.h:126
#define DIRDYN_INTEGRATOR_OPTION_DEFAULT_atoler
Definition: mbs_dirdyn_struct.h:30
void free_dmat_0(double **mat)
release memory for a matrix of doubles, starting at index 0
Definition: mbs_matrix.c:293
void initialize_euler_implicit(MbsData *mbs_data, MbsDirdyn *mbs_dd)
Initialize all needed fields in MbsDirdyn for Euler Implicit integrator.
Definition: mbs_euler_implicit.c:21
@ Eulaire
Definition: integrator.h:29
#define DIRDYN_INTEGRATOR_OPTION_DEFAULT_toler
Definition: mbs_dirdyn_struct.h:28
void(* initialize_integrator_ptr)(MbsData *mbs_data, MbsDirdyn *mbs_dd)
These three pointers of functions should be defined for each integrator separately,...
Definition: integrator.h:37
@ EulerIm
Definition: integrator.h:29
int mbs_cholsl_0(double **A, int n, double **B, int nb)
Solves a symmetric positive definite system of linear equations AX=B (B being the right hand side wit...
Definition: cholesky.c:40
int Nux
Number of user variable.
Definition: mbs_data.h:288
This header defines global functions for rosenbrock integrator in C.
int loop_rosenbrock(double t0, double tf, MbsData *mbs_data, MbsDirdyn *mbs_dd)
Integrate the motion from t0 to tf.
Definition: mbs_rosenbrock.c:63
int mbs_freeze_jac(int freeze_index, int *next_freeze_index, double x, double h, double y[], double dydx[], int compute_dfdx, double dfdx[], double **dfdy, double dydx_freeze[], double dfdx_freeze[], double **dfdy_freeze, int n, int(*derivs)(double, double[], double[], MbsData *, MbsDirdyn *), MbsData *s, MbsDirdyn *mbs_dd)
Freeze the Jacobian of an integrator structure until mbs_dd->options->n_freeze.
Definition: integrator.c:107
Definition: cholesky.c:15
float x
Definition: cholesky.c:14
int choldc_0(double **a, int n, double *p)
Definition: choldc.c:47
int loop_euler_implicit(double t0, double tf, MbsData *mbs_data, MbsDirdyn *mbs_dd)
Integrate the motion from t0 to tf.
Definition: mbs_euler_implicit.c:56
#define DIRDYN_INTEGRATOR_OPTION_DEFAULT_rtoler
Definition: mbs_dirdyn_struct.h:29
finish_integrator_ptr finish_integrator
pointer to integrator closing function
Definition: mbs_dirdyn_struct.h:189
int mbs_freeze_jac(int freeze_index, int *next_freeze_index, double x, double h, double y[], double dydx[], int compute_dfdx, double dfdx[], double **dfdy, double dydx_freeze[], double dfdx_freeze[], double **dfdy_freeze, int n, int(*derivs)(double, double[], double[], MbsData *, MbsDirdyn *), MbsData *s, MbsDirdyn *mbs_dd)
Freeze the Jacobian of an integrator structure until mbs_dd->options->n_freeze.
Definition: integrator.c:107
double ** get_dmat_0(int nb_r, int nb_c)
create (with memory allocation) a [nb_r times nb_c] matrix of doubles, starting at index 0
Definition: mbs_matrix.c:238
double dt0
initial value of the integration step size, default = 0.001
Definition: mbs_dirdyn_struct.h:45
int rk4(double y[], double dydx[], int n, double x, double h, double yout[], int(*derivs)(double, double[], double[], MbsData *, MbsDirdyn *), MbsData *s, MbsDirdyn *dd)
Runge Kutta 4 integrator implementation Given values for the variables y[1..n] and their derivatives ...
Definition: rk4.c:21
void initialize_rk4(MbsData *mbs_data, MbsDirdyn *mbs_dd)
Initialize all needed fields in MbsDirdyn for RK4 integrator.
Definition: mbs_rk4.c:19
void finish_euler_implicit(MbsData *mbs_data, MbsDirdyn *dd)
Finalize and clear memory allocated for Euler Implicit integrator.
Definition: mbs_euler_implicit.c:128
int loop_custom(double t0, double tf, MbsData *mbs_data, MbsDirdyn *mbs_dd)
Integrate the motion from t0 to tf with a custom integrator implemented by the user.
Definition: mbs_custom.c:39
int loop_eulerEx(double t0, double tf, MbsData *mbs_data, MbsDirdyn *mbs_dd)
Integrate the motion from t0 to tf.
Definition: mbs_euler_explicit.c:55
int mbs_choldc_0(double **A, int n)
Compute the Cholesky decomposition of A, i.e.
Definition: cholesky.c:25
void mbs_msg(char *msg,...)
Send a message.
Definition: mbs_message.c:76
void finish_dopri5(MbsData *mbs_data, MbsDirdyn *mbs_dd)
Finalize and clear memory allocated for dopri5 integrator.
Definition: mbs_dopri5.c:64
@ WMethods
Definition: integrator.h:29
void initialize_rosenbrock(MbsData *mbs_data, MbsDirdyn *mbs_dd)
Initialize all needed fields in MbsDirdyn for Rosenbrock integrator.
Definition: mbs_rosenbrock.c:26
void(* finish_integrator_ptr)(MbsData *mbs_data, MbsDirdyn *mbs_dd)
end of the integration, free the memory
Definition: integrator.h:41
float y
Definition: cholesky.c:14
int n_freeze
number of time step when the jacobian is freezed (computed once at the start of the n_freeze time ste...
Definition: mbs_dirdyn_struct.h:134
void initialize_dopri5(MbsData *mbs_data, MbsDirdyn *mbs_dd)
Initialize all needed fields in MbsDirdyn for Dopri5 integrator.
Definition: mbs_dopri5.c:20
void initialize_custom(MbsData *mbs_data, MbsDirdyn *mbs_dd)
Initialize all needed fields in MbsDirdyn for Custom integrator.
Definition: mbs_custom.c:22
@ Dopri5
Definition: integrator.h:29
double y
Definition: cholesky.c:15
void finish_bader(MbsData *mbs_data, MbsDirdyn *dd)
Finalize and clear memory allocated for Bader integrator.
Definition: mbs_bader.c:158
double toler
mixed error tolerances [-], default = 1.0e-3
Definition: mbs_dirdyn_struct.h:127
void finish_eulerEx(MbsData *mbs_data, MbsDirdyn *dd)
Finalize and clear memory allocated for Euler Explicit integrator.
Definition: mbs_euler_explicit.c:116
int flag_oneshot
1 to compute the derivative function only once (no time integration !), default = 0 The time is the v...
Definition: mbs_dirdyn_struct.h:92
void print_warnings_constant_step_integrator(MbsDirdyn *mbs_dd, char *integrator_name)
Print the warning message, called by print_warnings_integrator for constant step size dt integrators.
Definition: integrator.c:324
void finish_rosenbrock(MbsData *mbs_data, MbsDirdyn *dd)
Finalize and clear memory allocated for Rosenbrock integrator.
Definition: mbs_rosenbrock.c:143
@ AlphaM
Definition: integrator.h:29
void transpose_dmat_0(double **tab_src, double **tab_dest, int nb_r, int nb_c)
Transpose a [nb_r times nb_c] matrix of doubles and store the results in a [y times nb_r] matrix,...
Definition: mbs_matrix.c:440
void initialize_bader(MbsData *mbs_data, MbsDirdyn *mbs_dd)
Initialize all needed fields in MbsDirdyn for Bader integrator.
Definition: mbs_bader.c:23
This header defines global functions for Euler Explicit integrator in C.
#define _MBS_ERR_LOW_EIG_VAL
Low Level error number Eigen value problem = -4.
Definition: mbs_errors_names.h:132
int ThetaSC(double y[], double dydx[], int n, double x, double h, double yout[], int(*derivs)(double, double[], double[], MbsData *, MbsDirdyn *), MbsData *s, MbsDirdyn *dd)
Unknown integrator.
Definition: thetaSC.c:26
double x
Definition: cholesky.c:15
Definition: mbs_data.h:149
double rtoler
relative error tolerances [-], default = 1.0e-3
Definition: mbs_dirdyn_struct.h:128
void set_integrator(MbsDirdyn *dd)
Set the function pointer in MbsDirdyn.
Definition: integrator.c:151
Structure defining the option of a direct dynamic.
Definition: mbs_dirdyn_struct.h:38
void cholsl_0(double **a, int n, double *p, double *b, double *x)
Definition: cholsl.c:25
void set_integrator(MbsDirdyn *mbs_dd)
Set the function pointer in MbsDirdyn.
Definition: integrator.c:151
int mbs_eig_0(double **A, int n, double *eval_a, double *eval_b, double **evec_a, double **evec_b)
Compute the eigen values and vector of a matrix with index starting a 0.
Definition: eig_lapack.c:32
This header defines specific integrators functions in C.
int w_methods(double y[], double dydx[], int n, double x, double h, double yout[], int(*derivs)(double, double[], double[], MbsData *, MbsDirdyn *), MbsData *s, MbsDirdyn *mbs_dd)
W Methods integrator implementation.
Definition: w_methods.c:27
void initialize_w_methods(MbsData *mbs_data, MbsDirdyn *mbs_dd)
Initialize all needed fields in MbsDirdyn for W Methods integrator.
Definition: mbs_w_methods.c:22
initialize_integrator_ptr initialize_integrator
pointer to integrator initialize function
Definition: mbs_dirdyn_struct.h:185
int integrator
Set integrator to use, available value: RK4, Dopri5, Rosenbrock, EulerEx, Eulaire,...
Definition: mbs_dirdyn_struct.h:108
#define DIRDYN_INTEGRATOR_OPTION_DEFAULT_nmax
Define of default options for integrator in DirdynStruc.
Definition: mbs_dirdyn_struct.h:27
void cholsl(double **a, int n, double p[], double b[], double x[])
Definition: cholsl.c:10
This header defines global functions for custom integrator in C. Advanced user can modify this file.
void print_warnings_integrator(MbsData *mbs_data, MbsDirdyn *mbs_dd, int type_of_integrator)
Check the options set by user to warn him when he modified an unused option for the integrator.
Definition: integrator.c:250
int choldc(double **a, int n, double p[])
Compute the Cholesky decomposition of a, i.e.
Definition: choldc.c:25
int verbose
1 to get print indications related to time adaptive integrator, 0 otherwise, default = 1
Definition: mbs_dirdyn_struct.h:110
void copy_dvec_0(double *vec_src, double *vec_dest, int l_v)
Copy the content of a vector (of sizel_v) of doubles to a second vector, starting with index 0.
Definition: mbs_1D_array.c:906
void free_dvec_0(double *vec)
release memory for a vector of doubles, starting at index 0
Definition: mbs_1D_array.c:896
int mbs_estim_jac_acc(double x, double htry, double y[], double dydx[], int compute_dfdx, double dfdx[], double **dfdy, int n, int(*derivs)(double, double[], double[], MbsData *, MbsDirdyn *), MbsData *s, MbsDirdyn *dd)
Evaluate the Jacobian of a function accelerations using finite difference.
Definition: integrator.c:30
void finish_rk4(MbsData *mbs_data, MbsDirdyn *dd)
Finalize and clear memory allocated for RK4 integrator.
Definition: mbs_rk4.c:108
@ Custom
Definition: integrator.h:29
@ RK4
Definition: integrator.h:29
double atoler
absolute error tolerances [-], default = 1.0e-6
Definition: mbs_dirdyn_struct.h:129
General structure of the direct dynamic module.
Definition: mbs_dirdyn_struct.h:144
@ Rosenbrock
Definition: integrator.h:29
int flag_waypoint
1 to use waypoints, 0 otherwise, default =0
Definition: mbs_dirdyn_struct.h:121
int euler_implicit(double y[], double dydx[], int n, double *x, double h, double yout[], int(*derivs)(double, double[], double[], MbsData *, MbsDirdyn *), MbsData *s, MbsDirdyn *mbs_dd)
Euler Implicit integrator implementation.
Definition: euler_implicit.c:27
This header defines global functions for Runge Kutta 4 integrator in C.
int loop_dopri5(double t0, double tf, MbsData *mbs_data, MbsDirdyn *mbs_dd)
Integrate the motion from t0 to tf.
Definition: mbs_dopri5.c:43
loop_integrator_ptr loop_integrator
pointer to integrator looping function
Definition: mbs_dirdyn_struct.h:187
MbsDirdynOptions * options
structure defining the option of a direct dynamic
Definition: mbs_dirdyn_struct.h:146
void initialize_eulerEx(MbsData *mbs_data, MbsDirdyn *mbs_dd)
Initialize all needed fields in MbsDirdyn for Euler Explicit integrator.
Definition: mbs_euler_explicit.c:19
void mbs_warning_msg(char *msg,...)
Send a warning message.
Definition: mbs_message.c:89
void finish_custom(MbsData *mbs_data, MbsDirdyn *mbs_dd)
Finalize and clear memory allocated for Custom integrator.
Definition: mbs_custom.c:115
int flag_ongoing_jac_computation
flag is ON (=1) when the implicit integrator is currently computing the jacobian, default is 0.
Definition: mbs_dirdyn_struct.h:179
void finish_w_methods(MbsData *mbs_data, MbsDirdyn *dd)
Finalize and clear memory allocated for W Methods integrator.
Definition: mbs_w_methods.c:151
int loop_rk4(double t0, double tf, MbsData *mbs_data, MbsDirdyn *mbs_dd)
Integrate the motion from t0 to tf.
Definition: mbs_rk4.c:34
#define _MBS_ERR_LOW_LAPACKE
Low Level error number problem with Lapacke system resolution = -5.
Definition: mbs_errors_names.h:137
int rosenbrock(int n, int(*derivs)(double, double[], double[], MbsData *, MbsDirdyn *), double *x, double y[], double eps, double hmax, double htry, long nmax, double dydx[], double yscal[], double *hnext, MbsData *s, MbsDirdyn *dd, double *hdid)
Fourth-order Rosenbrock step for integrating stiff problems, with monitoring of local truncation erro...
Definition: rosenbrock.c:103