Robotran C Documentation
mbs_w_methods.h
Go to the documentation of this file.
1 
16  #ifndef MBS_W_METHODS_H_INCLUDED
17 #define MBS_W_METHODS_H_INCLUDED
18 
19 #include "mbs_data.h"
20 #include "integrator.h"
21 #include "mbs_dirdyn.h"
22 #include "useful_functions.h"
23 #include "mbs_dirdyn_struct.h"
24 #include "mbs_project_interface.h"
25 #include "MBSfun.h"
26 
27 #define W_S 2 // order of the method, 2 per default
28 
30  //#define W_A21 (2.0/3.0)
31  //#define W_C1 0.0
32  //#define W_C2 0.0
33  //#define W_B1 1.0
34  //#define W_B2 0.0
35  //#define W_GAMMA11 1.0
36  //#define W_GAMMA22 0.0
37  //#define W_GAMMA21 0.0
38 
40 #define W_A21 0.66666666666667
41 #define W_C1 0.0
42 #define W_C2 0.66666666666667
43 #define W_B1 (0.25)
44 #define W_B2 (0.75)
45 #define W_GAMMA11 0.788675134594813 //(0.5 + (sqrt(3.0)/6.0))
46 #define W_GAMMA22 0.788675134594813 // (0.5 + (sqrt(3.0)/6.0))
47 #define W_GAMMA21 -1.051566846126417 //(-2.0 * W_A21 * W_GAMMA22)
48 
52 typedef struct MbsDirdynWMethods
53 {
54 
55  double **dfdy; // vector of derivatives of f by y [nxn]
56  double *dfdx; // vector of derivatives of f by x [1xn]
57  double *dysav; // vector save dydx from previous step [1xn]
58  double *ysav; // vector save y from previous step [1xn]
59 
60  double *f; // vector to store the call of f' [1xn]
61  int *indx; // index for LU decomp and system resolution
62 
63  // To freeze jacobian
66 
67  // internal vectors/matrices
68  double **A; // left side of the equation, at step i [nqu x nqu]
69  double *B; // right side of the equation, at step i [1 x nqu]
70  double *sum_alpha_gamma; // internal step variable [1 x nqu]
71  double *partial_right_hand_term; // partial rigth hand step variable [1 x nqu]
72  double *jpxv; // useful vector to store Jnp * xv [1 x nqu]
73  double **delta_p; // to store delta p
74  double **delta_v; // to store delta v
75  double *intermediate_y; // useful vector to store y [1xnqu]
76 
77  double *A_param; // Parameter A
78  double *B_param; // Parameter B
79  double *C_param; // Parameter C
80  double **GAM_param; // Parameter Gamma
81 
83 
89 void initialize_w_methods(MbsData *mbs_data, MbsDirdyn *mbs_dd);
90 
100 int loop_w_methods(double t0, double tf, MbsData *mbs_data, MbsDirdyn *mbs_dd);
101 
107 void finish_w_methods(MbsData *mbs_data, MbsDirdyn *mbs_dd);
108 
116 void error_w_methods(MbsData *mbs_data, MbsDirdyn *dd, int err);
117 
118 #endif // MBS_W_METHODS_H_INCLUDED
MbsDirdynWMethods::Freeze_dfdx
double * Freeze_dfdx
Definition: mbs_w_methods.h:64
MbsDirdynOptions::flag_precise_dynamics
int flag_precise_dynamics
= 1 to call the direct dynamics at the beginning of each time step of integration.
Definition: mbs_dirdyn_struct.h:112
MbsDirdynWMethods::jpxv
double * jpxv
Definition: mbs_w_methods.h:72
error_w_methods
void error_w_methods(MbsData *mbs_data, MbsDirdyn *dd, int err)
If an error occurs during time integration, this function prints the error message and call finish_w_...
Definition: mbs_w_methods.c:206
useful_functions.h
mbs_w_methods.h
This header defines global functions for W methods integrator in C.
mbs_dirdyn.h
MbsDirdynWMethods::Freeze_dfdy
double ** Freeze_dfdy
Definition: mbs_w_methods.h:64
MbsData::tsim
double tsim
The time value.
Definition: mbs_data.h:208
MbsDirdyn::y
double * y
Pointer to the state vector, this is a dvec_0 of size nState.
Definition: mbs_dirdyn_struct.h:153
mbs_data.h
W_S
#define W_S
Definition: mbs_w_methods.h:27
MbsDirdyn::nState
int nState
size of the state vector
Definition: mbs_dirdyn_struct.h:152
mbs_dirdyn_struct.h
loop_w_methods
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
MbsData::nqu
int nqu
Number of independent articulations.
Definition: mbs_data.h:165
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:880
MbsDirdyn::yd
double * yd
Pointers to the derivative vector (dvec_0) of size nState.
Definition: mbs_dirdyn_struct.h:160
MbsDirdynWMethods::dysav
double * dysav
Definition: mbs_w_methods.h:57
MbsDirdynWMethods::dfdy
double ** dfdy
Definition: mbs_w_methods.h:55
mbs_project_interface.h
free_ivec_0
void free_ivec_0(int *vec)
release memory for a vector of integers, starting with index 0
Definition: mbs_1D_array.c:415
MbsDirdynWMethods::B_param
double * B_param
Definition: mbs_w_methods.h:78
free_dmat_0
void free_dmat_0(double **mat)
release memory for a matrix of doubles, starting at index 0
Definition: mbs_matrix.c:293
MbsDirdyn::yout
double * yout
Allocation of a vector (dvec_0) of size nState.
Definition: mbs_dirdyn_struct.h:155
mbs_fct_dirdyn
int mbs_fct_dirdyn(double tsim, double y[], double dydt[], MbsData *s, MbsDirdyn *dd)
direct dynamics derivative computation
Definition: mbs_dirdyn.c:1067
MbsDirdynWMethods::A
double ** A
Definition: mbs_w_methods.h:68
error_w_methods
void error_w_methods(MbsData *mbs_data, MbsDirdyn *dd, int err)
If an error occurs during time integration, this function prints the error message and call finish_w_...
Definition: mbs_w_methods.c:206
finish_w_methods
void finish_w_methods(MbsData *mbs_data, MbsDirdyn *mbs_dd)
Finalize and clear memory allocated for W Methods integrator.
Definition: mbs_w_methods.c:151
MBSfun.h
MbsDirdynWMethods::partial_right_hand_term
double * partial_right_hand_term
Definition: mbs_w_methods.h:71
MbsDirdyn::integrator_struct
void * integrator_struct
pointer to store integrator structure
Definition: mbs_dirdyn_struct.h:183
MbsDirdynWMethods::B
double * B
Definition: mbs_w_methods.h:69
MbsDirdynWMethods::C_param
double * C_param
Definition: mbs_w_methods.h:79
get_dmat_0
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
initialize_w_methods
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
user_dirdyn_loop
void user_dirdyn_loop(MbsData *mbs_data, MbsDirdyn *mbs_dd)
user own loop functions
Definition: user_dirdyn.c:46
MbsDirdyn::tsim
double tsim
current simulation time
Definition: mbs_dirdyn_struct.h:149
mbs_msg
void mbs_msg(char *msg,...)
Send a message.
Definition: mbs_message.c:76
W_GAMMA11
#define W_GAMMA11
Definition: mbs_w_methods.h:45
MbsDirdynWMethods::sum_alpha_gamma
double * sum_alpha_gamma
Definition: mbs_w_methods.h:70
W_C1
#define W_C1
Definition: mbs_w_methods.h:41
MbsDirdynWMethods::GAM_param
double ** GAM_param
Definition: mbs_w_methods.h:80
MbsDirdynWMethods::dfdx
double * dfdx
Definition: mbs_w_methods.h:56
W_B2
#define W_B2
Definition: mbs_w_methods.h:44
W_GAMMA21
#define W_GAMMA21
Definition: mbs_w_methods.h:47
MbsDirdynWMethods::Freeze_dydx
double * Freeze_dydx
Definition: mbs_w_methods.h:64
W_GAMMA22
#define W_GAMMA22
Definition: mbs_w_methods.h:46
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:1146
MbsDirdynWMethods::ysav
double * ysav
Definition: mbs_w_methods.h:58
mbs_message.h
MbsDirdynWMethods
W Methods structure for dirdyn.
Definition: mbs_w_methods.h:52
get_ivec_0
int * get_ivec_0(int l_v)
create (with memory allocation) a vector (length l_v) of integers, starting at index 0
Definition: mbs_1D_array.c:399
MbsDirdynWMethods::Freeze_jacobian_index
int Freeze_jacobian_index
Definition: mbs_w_methods.h:65
MbsData
Definition: mbs_data.h:149
DIRDYN_INTEGRATOR_WAYPOINT_TIME_ERROR_max
#define DIRDYN_INTEGRATOR_WAYPOINT_TIME_ERROR_max
Definition: mbs_dirdyn_struct.h:32
MbsDirdynWMethods::A_param
double * A_param
Definition: mbs_w_methods.h:77
W_B1
#define W_B1
Definition: mbs_w_methods.h:43
MbsDirdynWMethods::intermediate_y
double * intermediate_y
Definition: mbs_w_methods.h:75
MbsDirdynOptions
Structure defining the option of a direct dynamic.
Definition: mbs_dirdyn_struct.h:38
loop_w_methods
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
integrator.h
This header defines specific integrators functions in C.
w_methods
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
MbsDirdynWMethods::f
double * f
Definition: mbs_w_methods.h:60
initialize_w_methods
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
MbsData::flag_stop
int flag_stop
stop the simulation. For dirdyn, equil, invdyn and solvekin only.
Definition: mbs_data.h:298
W_A21
#define W_A21
first order parameters
Definition: mbs_w_methods.h:40
free_dvec_0
void free_dvec_0(double *vec)
release memory for a vector of doubles, starting at index 0
Definition: mbs_1D_array.c:896
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:122
MbsDirdyn
General structure of the direct dynamic module.
Definition: mbs_dirdyn_struct.h:144
MbsDirdyn::dt
double dt
current integration step size
Definition: mbs_dirdyn_struct.h:150
MbsDirdyn::options
MbsDirdynOptions * options
structure defining the option of a direct dynamic
Definition: mbs_dirdyn_struct.h:146
MbsDirdynWMethods::delta_p
double ** delta_p
Definition: mbs_w_methods.h:73
mbs_warning_msg
void mbs_warning_msg(char *msg,...)
Send a warning message.
Definition: mbs_message.c:89
MbsDirdynWMethods::delta_v
double ** delta_v
Definition: mbs_w_methods.h:74
finish_w_methods
void finish_w_methods(MbsData *mbs_data, MbsDirdyn *dd)
Finalize and clear memory allocated for W Methods integrator.
Definition: mbs_w_methods.c:151
W_C2
#define W_C2
Definition: mbs_w_methods.h:42
MbsDirdynWMethods::indx
int * indx
Definition: mbs_w_methods.h:61