Robotran C Documentation
mbs_dopri5.h
Go to the documentation of this file.
1 
13  #ifndef MBS_DOPRI5_H_INCLUDED
14 #define MBS_DOPRI5_H_INCLUDED
15 
16 
17 #include "mbs_project_interface.h"
18 #include "mbs_message.h"
19 
23 typedef struct MbsDirdynDopri5
24 {
25  int flag_save;
26 
27  double solout_last_t;
28 
29  double *dydt_save;
30 
31  double **alloc_tab;
32 
33  int(*derivs)(double, double[], double[], MbsData *, MbsDirdyn *);
35  void (*loop_fct)(MbsData *, MbsDirdyn *);
37  //
38  int (*save_realtime_update)(MbsDirdyn* dd, MbsData* mbs_data);
40 
41 
49 void initialize_dopri5(MbsData *mbs_data, MbsDirdyn *mbs_dd,
50  int (*derivs)(double, double[], double[], MbsData *, MbsDirdyn *),
51  void (*loop_fct)(MbsData *, MbsDirdyn *),
52  int (*save_realtime_update)(MbsDirdyn* dd, MbsData* mbs_data)
53  );
54 
64 int loop_dopri5(double t0, double tf, MbsData *mbs_data, MbsDirdyn *mbs_dd);
65 
71 void finish_dopri5(MbsData *mbs_data, MbsDirdyn *mbs_dd);
72 
85 int fcn_dopri5(unsigned int n, long nr, double tsim, double y[], double dydt[], MbsData *s, MbsDirdyn *mbs_dd);
86 
101 int solout_dopri5(long nr, double tsim_old, double tsim, double y[], unsigned n, int* irtrn, int init_flag, MbsData *s, MbsDirdyn *mbs_dd);
102 
103 
111 void error_dopri5(MbsData *mbs_data, MbsDirdyn *dd, int err);
112 
113 #endif // MBS_DOPRI5_H_INCLUDED
initialize_dopri5
void initialize_dopri5(MbsData *mbs_data, MbsDirdyn *mbs_dd, int(*derivs)(double, double[], double[], MbsData *, MbsDirdyn *), void(*loop_fct)(MbsData *, MbsDirdyn *), int(*save_realtime_update)(MbsDirdyn *dd, MbsData *mbs_data))
Initialize all needed fields in MbsDirdyn for Dopri5 integrator.
Definition: mbs_dopri5.c:23
mbs_msg
void mbs_msg(const char *msg,...)
Send a message.
Definition: mbs_message.c:87
fcn_dopri5
int fcn_dopri5(unsigned int n, long nr, double tsim, double y[], double dydt[], MbsData *s, MbsDirdyn *mbs_dd)
dopri5 derivative function
Definition: mbs_dopri5.c:92
MbsData::dt0
double dt0
Initial value of the integration step size [s]. For dirdyn and invdyn only. This parameter is set fro...
Definition: mbs_data.h:309
MbsDirdynDopri5
Dopri5 structure for dirdyn.
Definition: mbs_dopri5.h:23
MbsData::tsim
double tsim
The time value.
Definition: mbs_data.h:305
MbsDirdyn::y
double * y
Pointer to the state vector, this is a dvec_0 of size nState.
Definition: mbs_dirdyn_struct.h:175
DOPRI5_NB_ALLOC_VEC
#define DOPRI5_NB_ALLOC_VEC
number of vectors to allocate for dopri5
Definition: mbs_dirdyn_struct.h:22
error_dopri5
void error_dopri5(MbsData *mbs_data, MbsDirdyn *dd, int err)
If an error occurs during time integration, this function prints the error message and call finish_do...
Definition: mbs_dopri5.c:168
MbsDirdyn::nState
int nState
size of the state vector
Definition: mbs_dirdyn_struct.h:174
mbs_dirdyn_struct.h
get_dvec_0
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:955
MbsDirdynOptions::dt_max
double dt_max
maximal time step [s], default = 1.0e-3
Definition: mbs_dirdyn_struct.h:136
mbs_project_interface.h
Declaration of functions that are project dependent.
MbsDirdynOptions::nmax
int nmax
maximal number of steps [-], default = 1e9
Definition: mbs_dirdyn_struct.h:132
MbsDirdynDopri5::save_realtime_update
int(* save_realtime_update)(MbsDirdyn *dd, MbsData *mbs_data)
Definition: mbs_dopri5.h:38
solout_dopri5
int solout_dopri5(long nr, double tsim_old, double tsim, double y[], unsigned n, int *irtrn, int init_flag, MbsData *s, MbsDirdyn *mbs_dd)
dopri5 simulation own gestion at each succesful step
Definition: mbs_dopri5.c:133
MbsDirdynDopri5::loop_fct
void(* loop_fct)(MbsData *, MbsDirdyn *)
The function to be called at the end of each time step, or waypoints.
Definition: mbs_dopri5.h:35
mbs_1D_array.h
loop_dopri5
int loop_dopri5(double t0, double tf, MbsData *mbs_data, MbsDirdyn *mbs_dd)
Integrate the motion from t0 to tf.
Definition: mbs_dopri5.c:50
MbsDirdyn::integrator_struct
void * integrator_struct
pointer to store integrator structure
Definition: mbs_dirdyn_struct.h:205
dopri5.h
This header defines function for dopri5 in C. based on an external source (see below)
MbsDirdynOptions::dt0
double dt0
initial value of the integration step size, default = 0.001
Definition: mbs_dirdyn_struct.h:45
initialize_dopri5
void initialize_dopri5(MbsData *mbs_data, MbsDirdyn *mbs_dd, int(*derivs)(double, double[], double[], MbsData *, MbsDirdyn *), void(*loop_fct)(MbsData *, MbsDirdyn *), int(*save_realtime_update)(MbsDirdyn *dd, MbsData *mbs_data))
Initialize all needed fields in MbsDirdyn for Dopri5 integrator.
Definition: mbs_dopri5.c:23
finish_dopri5
void finish_dopri5(MbsData *mbs_data, MbsDirdyn *mbs_dd)
Finalize and clear memory allocated for dopri5 integrator.
Definition: mbs_dopri5.c:71
error_dopri5
void error_dopri5(MbsData *mbs_data, MbsDirdyn *dd, int err)
If an error occurs during time integration, this function prints the error message and call finish_do...
Definition: mbs_dopri5.c:168
hout
static double hout
Definition: dopri5.c:31
save_realtime_update
int save_realtime_update(MbsDirdyn *dd, MbsData *mbs_data)
update the real-time and saving modules if requested
Definition: mbs_dirdyn.c:1252
dopri5
int dopri5(unsigned n, FcnEqDiff fcn, double x, double *y, double xend, double *rtoler, double *atoler, int itoler, SolTrait solout, int iout, double uround, double safe, double fac1, double fac2, double beta, double hmax, double h, long nmax, int meth, long nstiff, unsigned nrdens, unsigned *icont, unsigned licont, double **dopri5_alloc_tab, MbsData *s, MbsDirdyn *dd, double *last_h)
See the source file for more informations.
Definition: dopri5.c:528
mbs_message.h
finish_dopri5
void finish_dopri5(MbsData *mbs_data, MbsDirdyn *mbs_dd)
Finalize and clear memory allocated for dopri5 integrator.
Definition: mbs_dopri5.c:71
MbsDirdynDopri5::dydt_save
double * dydt_save
save dydt of the last time step
Definition: mbs_dopri5.h:29
MbsDirdynDopri5::flag_save
int flag_save
1 if first dydt save done, 0 otherwise
Definition: mbs_dopri5.h:25
MbsData
Definition: mbs_data.h:246
MbsDirdynOptions::rtoler
double rtoler
relative error tolerances [-], default = 1.0e-3
Definition: mbs_dirdyn_struct.h:134
MbsData::t0
double t0
Initial time of the simulation [s]. For dirdyn and invdyn only. This parameter is set from dirdyn/inv...
Definition: mbs_data.h:307
MbsData::flag_stop
int flag_stop
stop the simulation. For dirdyn, equil, invdyn and solvekin only.
Definition: mbs_data.h:397
MbsDirdynDopri5::solout_last_t
double solout_last_t
last time solout was called
Definition: mbs_dopri5.h:27
solout_dopri5
int solout_dopri5(long nr, double tsim_old, double tsim, double y[], unsigned n, int *irtrn, int init_flag, MbsData *s, MbsDirdyn *mbs_dd)
dopri5 simulation own gestion at each succesful step
Definition: mbs_dopri5.c:133
fcn_dopri5
int fcn_dopri5(unsigned int n, long nr, double tsim, double y[], double dydt[], MbsData *s, MbsDirdyn *mbs_dd)
dopri5 derivative function
Definition: mbs_dopri5.c:92
mbs_dopri5.h
MbsDirdynOptions::flag_solout_wp
int flag_solout_wp
1 to call solout only at required waypoints (only if flag_waypoint activated), default = 0
Definition: mbs_dirdyn_struct.h:128
MbsDirdynDopri5::alloc_tab
double ** alloc_tab
allocated state vectors
Definition: mbs_dopri5.h:31
MbsDirdynOptions::atoler
double atoler
absolute error tolerances [-], default = 1.0e-6
Definition: mbs_dirdyn_struct.h:135
MbsDirdyn
General structure of the direct dynamic module.
Definition: mbs_dirdyn_struct.h:166
MbsDirdynOptions::flag_waypoint
int flag_waypoint
1 to use waypoints, 0 otherwise, default =0
Definition: mbs_dirdyn_struct.h:127
loop_dopri5
int loop_dopri5(double t0, double tf, MbsData *mbs_data, MbsDirdyn *mbs_dd)
Integrate the motion from t0 to tf.
Definition: mbs_dopri5.c:50
MbsDirdyn::options
MbsDirdynOptions * options
structure defining the option of a direct dynamic
Definition: mbs_dirdyn_struct.h:168
MbsDirdynDopri5::derivs
int(* derivs)(double, double[], double[], MbsData *, MbsDirdyn *)
The function computing the derivative of the system.
Definition: mbs_dopri5.h:33