Robotran C Documentation
mbs_modal.h
Go to the documentation of this file.
1 
2 #ifndef MODAL_h
3 #define MODAL_h
4 
5 //#include "project_info.h"
6 //#include "cmake_config.h"
7 
8 #include "useful_functions.h"
9 
10 #include "mbs_data.h"
11 #include "MBSfun.h"
12 #include "mbs_modal_struct.h"
13 
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 //#include "mstr.h"
20 
29 MbsModal* mbs_new_modal(MbsData* mbs_data);
30 
40 MbsModal* mbs_new_modal_aux(MbsData* s, MbsAux* mbs_aux);
41 
58 int mbs_run_modal(MbsModal *mo,MbsData *s);
59 
69 int mbs_modal_init(MbsModal *mo,MbsData *s);
70 
89 int mbs_modal_loop(MbsModal *mo,MbsData *s);
90 
104 int mbs_modal_finish(MbsModal *mo,MbsData *s);
105 
114 void mbs_delete_modal(MbsModal *mo,MbsData *s);
115 
116 #ifdef __cplusplus
117 }
118 #endif
119 
138 int mbs_modal_norm_evec(double** mat_r, double** mat_phi, int nqu, int Nux, int ind, double *evec_r, double *evec_phi);
139 
151 int mbs_modal_save_result(MbsModal* mbs_modal,MbsData* s, char* filename);
152 
162 int mbs_modal_save_anim(MbsModal* mbs_modal,MbsData* s, char* filepath);
163 
164 #endif
mbs_modal_finish
int mbs_modal_finish(MbsModal *mo, MbsData *s)
Set Modal flag to done in MbsData structure and save the modal analysis.
Definition: mbs_modal.c:518
MbsModalOptions::lpk_absincr_max
double lpk_absincr_max
options for the lpk gradient [default = 1e-3]
Definition: mbs_modal_struct.h:31
MbsSS::Lr
double ** Lr
Linearized stiff state matrix : d Rr / d ux.
Definition: mbs_statespace_struct.h:28
MbsModal::Nux_saved
int Nux_saved
copy of mbs_data Nux
Definition: mbs_modal_struct.h:92
MbsModal::evec_a
double ** evec_a
Result of the Eigenvalue problem: real part of the eigen vectors (each column is a eigenvector) [nx X...
Definition: mbs_modal_struct.h:99
MbsModal::eval_b
double * eval_b
Result of the Eigenvalue problem: imaginary part of the nx eigen values [nx].
Definition: mbs_modal_struct.h:97
mbs_modal_loop
int mbs_modal_loop(MbsModal *mo, MbsData *s)
Perform the Modal analysis.
Definition: mbs_modal.c:289
MbsModalOptions::respath
char * respath
Path in which result file are saved.
Definition: mbs_modal_struct.h:46
get_char_cpy
char * get_char_cpy(const char *fmt,...)
Copy the provided formatted string into a newly allocated memory.
Definition: useful_functions.c:191
MbsModalOptions
Definition: mbs_modal_struct.h:12
MbsLpk::absincr_max
double absincr_max
Maximum increment value of variables, set to 0.0 to disable it [default = 0.0].
Definition: mbs_linearipk_struct.h:52
MbsData::qd
double * qd
Array with the current values of the generalized velocities.
Definition: mbs_data.h:188
useful_functions.h
MbsModal::iModeSorted
int * iModeSorted
Definition: mbs_modal_struct.h:107
MbsModalOptions::lpk_absincr
double lpk_absincr
options for the lpk gradient [default = 1e-3]
Definition: mbs_modal_struct.h:30
MbsData::mbs_filename
char * mbs_filename
Path to mbs file including the file with the extension (.mbs)
Definition: mbs_data.h:310
mbs_error_msg
void mbs_error_msg(char *msg,...)
Send an error message.
Definition: mbs_message.c:102
MbsData::nqv
int nqv
Number of dependent articulations.
Definition: mbs_data.h:170
mbs_delete_modal
void mbs_delete_modal(MbsModal *mo, MbsData *s)
Free the MbsModal structure (pointers table, ...)
Definition: mbs_modal.c:663
MbsData::DoneEquil
int DoneEquil
Flag that indicates if the equilibrium module has been executed (default: 0=not done; 1=done).
Definition: mbs_data.h:294
MbsLpk::relincr
double relincr
options for the lpk linearization [default = 1e-2]
Definition: mbs_linearipk_struct.h:50
MbsModalOptions::mode_ampl
double mode_ampl
amplification factor for the animation of the modes, application dependent [default = 0....
Definition: mbs_modal_struct.h:21
mbs_data.h
mbs_modal_save_result
int mbs_modal_save_result(MbsModal *mo, MbsData *s, char *filename)
Write the modal analysis results (eigenmode, eigenfrequencies, mode type, ...) into a ASCII text file...
Definition: mbs_modal.c:773
MbsModalOptions::save_result
int save_result
no = 0, yes = 1, flag to save the modal results summary [default = 1]
Definition: mbs_modal_struct.h:18
mbs_compute_statespace
int mbs_compute_statespace(MbsSS *ss, MbsData *mbs_data)
Compute the matrices (A,B,C,D) for a mbs configuration (q,qd,qdd).
Definition: mbs_statespace.c:402
MbsData::nqu
int nqu
Number of independent articulations.
Definition: mbs_data.h:165
MbsSS::Mr
double ** Mr
unused for the moment
Definition: mbs_statespace_struct.h:25
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
_MBS_ERR_LOW_FILES
#define _MBS_ERR_LOW_FILES
Low Level error number Error during opening/writing files = -9.
Definition: mbs_errors_names.h:147
MbsModalOptions::lpk_itermax
int lpk_itermax
options for the lpk gradient [default = 10]
Definition: mbs_modal_struct.h:28
MbsData::njoint
int njoint
Number of joints in the system.
Definition: mbs_data.h:162
MbsModalMode::q_phi
double * q_phi
Phase of the generalized position corresponding to the mode motion (computed from evec_r and evec_phi...
Definition: mbs_modal_struct.h:68
MbsModalOptions::save_eval
int save_eval
no = 0, yes = 1, flag to save the eigen values in two separate files: "_a" for Real part and "_b" for...
Definition: mbs_modal_struct.h:16
mbs_modal.h
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
mbs_new_lpk
MbsLpk * mbs_new_lpk(MbsData *s, int nx, int nF)
create a new lpk structure that is used to compute the linearized matrices Gr and Kr.
Definition: mbs_linearipk.c:344
mbs_modal_finish
int mbs_modal_finish(MbsModal *mo, MbsData *s)
Set Modal flag to done in MbsData structure and save the modal analysis.
Definition: mbs_modal.c:518
MbsModalOptions::compute_uxd
int compute_uxd
no = 0, yes = 1, flag to compute the modes associated with the extra constitutive differential equati...
Definition: mbs_modal_struct.h:22
MbsModalMode
Definition: mbs_modal_struct.h:51
mbs_modal_norm_evec
int mbs_modal_norm_evec(double **mat_r, double **mat_phi, int nqu, int Nux, int ind, double *evec_r, double *evec_phi)
Additional function necessary for modal analysis post-process.
Definition: mbs_modal.c:721
MbsModalMode::nu_0
double nu_0
Undamped frequency [Hz].
Definition: mbs_modal_struct.h:59
MbsModal::lpk
MbsLpk * lpk
working structure to compute the linearized matrices (one by one)
Definition: mbs_modal_struct.h:82
MbsModalOptions::verbose
int verbose
no = 0, yes = 1, [default = 1]
Definition: mbs_modal_struct.h:20
MbsData::Nux
int Nux
Number of user variable.
Definition: mbs_data.h:288
MbsModalOptions::norm_evec
int norm_evec
no = 0, yes = 1, flag to normalize the eigenvectors [default = 1]
Definition: mbs_modal_struct.h:24
_MBS_ERR_MOD_SPEC_13
#define _MBS_ERR_MOD_SPEC_13
Generic error number Module specific errors range from -10 to -19 please read the error message a...
Definition: mbs_errors_names.h:174
MbsData::DoneModal
int DoneModal
Flag that indicates if the modal module has been executed (default: 0=not done; 1=done).
Definition: mbs_data.h:295
MbsModal::options
MbsModalOptions * options
Definition: mbs_modal_struct.h:79
mbs_linalg.h
_MBS_ERR_INIT
#define _MBS_ERR_INIT
Generic error number Check user options at initialization = -10.
Definition: mbs_errors_names.h:156
MbsModal::modeList
MbsModalMode ** modeList
List of model object.
Definition: mbs_modal_struct.h:106
MBSfun.h
mbs_check_nhu_nqv
int mbs_check_nhu_nqv(MbsData *mbs_data)
Check the coherence between the number of (independant) constraints and the number of dependant varia...
Definition: mbs_check.c:19
MbsModalOptions::lpk_lintol
double lpk_lintol
options for the lpk gradient [default = 1e-3]
Definition: mbs_modal_struct.h:33
save_dvec_0
void save_dvec_0(double *vec, int l_v, char *name)
save a (x sized) vector of doubles in the specified file, starting with index 0 The file is open with...
Definition: mbs_1D_array.c:1205
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
MbsModalOptions::anim_speed
int anim_speed
flag to decide whether the independent speeds have to be integrated while generating the animation fi...
Definition: mbs_modal_struct.h:36
mbs_run_modal
int mbs_run_modal(MbsModal *mo, MbsData *s)
Run the Modal Analysis.
Definition: mbs_modal.c:109
MbsModalMode::type
int type
1=unoscillating stable; 2=rigid; 3=unoscillating unstable; 4=oscillating damped; 5=oscillating undamp...
Definition: mbs_modal_struct.h:53
mbs_new_modal
MbsModal * mbs_new_modal(MbsData *mbs_data)
Create a new modal structure.
Definition: mbs_modal.c:28
mbs_modal_save_anim
int mbs_modal_save_anim(MbsModal *mbs_modal, MbsData *s, char *filepath)
Save the modes animations in the MbSysPad format.
Definition: mbs_modal.c:895
MbsLpk::absincr
double absincr
Minimum increment value of variables [default = 1e-3].
Definition: mbs_linearipk_struct.h:51
DBL_MAX
#define DBL_MAX
Definition: useful_functions.h:26
_MBS_ERR_MOD_MODAL
#define _MBS_ERR_MOD_MODAL
Module error number module: Modal = -300.
Definition: mbs_errors_names.h:53
mbs_msg
void mbs_msg(char *msg,...)
Send a message.
Definition: mbs_message.c:76
MbsSS::A
double ** A
state space matrix [nx nx]
Definition: mbs_statespace_struct.h:19
MbsModalMode::q_r
double * q_r
Norm of the generalized position corresponding to the mode motion (computed from evec_r and evec_phi)
Definition: mbs_modal_struct.h:67
MbsData::qu
int * qu
Array with the indices of the independent articulations (free)
Definition: mbs_data.h:174
MbsModalMode::nu
double nu
Frequency of the -damped- mode [Hz].
Definition: mbs_modal_struct.h:60
MbsModal
Definition: mbs_modal_struct.h:77
MbsModalOptions::save_anim
int save_anim
no = 0, yes = 1, flag to save and generate the animation for the modes [default = 0]
Definition: mbs_modal_struct.h:19
MbsData::qv
int * qv
Array with the indices of the dependent articulations .
Definition: mbs_data.h:182
freeMbsAux
void freeMbsAux(MbsAux *mbs_aux, MbsData *s)
Definition: mbs_aux.c:174
MbsLpk::itermax
int itermax
options for the lpk linearization [default = 10]
Definition: mbs_linearipk_struct.h:49
MbsData::Qq
double * Qq
Array with the values of the joint forces.
Definition: mbs_data.h:204
MbsModalMode::q_b
double * q_b
Img part of the generalized position corresponding to the mode motion (computed from q_phi)
Definition: mbs_modal_struct.h:63
MbsModalOptions::anim_t
double anim_t
time for the animation generation [default = 2]
Definition: mbs_modal_struct.h:38
MbsModalMode::q_a
double * q_a
Real part of the generalized position corresponding to the mode motion (computed from q_r)
Definition: mbs_modal_struct.h:62
MbsData::q
double * q
Array with the current values of the generalized coordinates.
Definition: mbs_data.h:187
MbsModalOptions::save_mat
int save_mat
no = 0, yes = 1, flag to save the linearized matrix A,Mr,Gr,Kr [default = 0]
Definition: mbs_modal_struct.h:15
MbsModalOptions::save_evec
int save_evec
no = 0, yes = 1, flag to save the eigen vector in two separate files: "_a" for Real part,...
Definition: mbs_modal_struct.h:17
MbsSS::Lx
double ** Lx
Linearized ODE stiff state matrix : d uxd / d ux.
Definition: mbs_statespace_struct.h:34
MbsModal::q_saved
double * q_saved
copy of vector q before the modal process.
Definition: mbs_modal_struct.h:87
mbs_new_modal_aux
MbsModal * mbs_new_modal_aux(MbsData *s, MbsAux *mbs_aux)
Create a new modal structure.
Definition: mbs_modal.c:38
mbs_new_modal
MbsModal * mbs_new_modal(MbsData *s)
Create a new modal structure.
Definition: mbs_modal.c:28
mbs_delete_modal
void mbs_delete_modal(MbsModal *mo, MbsData *s)
Free the MbsModal structure (pointers table, ...)
Definition: mbs_modal.c:663
MbsData::project_path
char * project_path
Path to the mbs project folder.
Definition: mbs_data.h:312
MbsModal::qd_saved
double * qd_saved
copy of vector qd before the modal process.
Definition: mbs_modal_struct.h:88
MbsModal::eval_a
double * eval_a
Result of the Eigenvalue problem: real part of the nx eigen values [nx].
Definition: mbs_modal_struct.h:96
MbsModalOptions::lpk_relincr
double lpk_relincr
options for the lpk gradient [default = 1e-2]
Definition: mbs_modal_struct.h:29
MbsModal::evec_b
double ** evec_b
Result of the Eigenvalue problem: img part of the eigen vectors (each column is a eigenvector) [nx X ...
Definition: mbs_modal_struct.h:100
MbsSS::Kx
double ** Kx
Linearized ODE stiffness matrix : d uxd / d qu.
Definition: mbs_statespace_struct.h:33
MbsModalMode::evec_phi
double * evec_phi
Phase of the eigen vector associated to the mode [nx].
Definition: mbs_modal_struct.h:73
MbsModalMode::eval_b
double eval_b
Imaginary part of the mode eigenvalue.
Definition: mbs_modal_struct.h:56
_MBS_ERR_MOD_SPEC_12
#define _MBS_ERR_MOD_SPEC_12
Generic error number Module specific errors range from -11 to -19 please read the error message a...
Definition: mbs_errors_names.h:168
mbs_init_sin_cos_q_vecs
int mbs_init_sin_cos_q_vecs(MbsData *s, int *qrot_qu_indvec, int *qrot_qc_indvec, int *qrot_qv_indvec)
Initialize the three vectors of indices (they are usually contained in the mbs_aux structure)
Definition: mbs_trigo.c:23
MbsModal::nx
int nx
number of 1st order equations, nx = 2*nqu (+Nux)
Definition: mbs_modal_struct.h:94
mbs_check_mbs_data_values
int mbs_check_mbs_data_values(MbsAux *module_mbs_aux, MbsData *mbs_data)
Check the coherence between the mbs_data used before module initialization and module run.
Definition: mbs_check.c:87
mbs_trigo.h
This header defines the functions for trigonometric handling in MBsysC integrator in C.
MbsSS::Kr
double ** Kr
Linearized stiffness matrix : d Rr / d qu.
Definition: mbs_statespace_struct.h:27
MbsModalOptions::zeroEigenPrecision
double zeroEigenPrecision
Define the limit at which the eigen value will be considered as null [default = 1e-6].
Definition: mbs_modal_struct.h:25
MbsModal::Bvuc
double ** Bvuc
copy of the Bvuc matrix (index 1)
Definition: mbs_modal_struct.h:85
mbs_modal_loop
int mbs_modal_loop(MbsModal *mo, MbsData *s)
Perform the Modal analysis.
Definition: mbs_modal.c:289
MbsModalMode::ux_b
double * ux_b
Img part of the extra ODE states corresponding to the mode motion (computed from ux_phi)
Definition: mbs_modal_struct.h:65
MbsData::nqc
int nqc
Number of driven articulations, it includes qlocked and qdriven.
Definition: mbs_data.h:166
mbs_modal_save_anim
int mbs_modal_save_anim(MbsModal *mo, MbsData *s, char *filepath)
Save the modes animations in the MbSysPad format.
Definition: mbs_modal.c:895
mbs_modal_norm_evec
int mbs_modal_norm_evec(double **mat_r, double **mat_phi, int nqu, int Nux, int ind, double *evec_r, double *evec_phi)
Additional function necessary for modal analysis post-process.
Definition: mbs_modal.c:721
MbsModalOptions::compute_JS
int compute_JS
no = 0, yes = 1, flag to compute the non diagonal terms [default = 0] TO IMPLEMENT !
Definition: mbs_modal_struct.h:23
mbs_message.h
MbsModalOptions::lpk_equitol
double lpk_equitol
options for the lpk gradient [default = 1e-6]
Definition: mbs_modal_struct.h:32
MbsModal::Qq_saved
double * Qq_saved
copy of vector Qq before the modal process.
Definition: mbs_modal_struct.h:90
MbsModal::qdd_saved
double * qdd_saved
copy of vector qdd before the modal process.
Definition: mbs_modal_struct.h:89
initMbsAux
MbsAux * initMbsAux(MbsData *s)
Definition: mbs_aux.c:18
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
get_time_machine
char * get_time_machine()
returns the current time as a String
Definition: useful_functions.c:131
mbs_new_statespace
MbsSS * mbs_new_statespace(MbsData *s, int nu, int ny, int compute_uxd, int compute_JS)
Create a new structure state-space that contains the matrices (A,B,C,D).
Definition: mbs_statespace.c:18
mbs_modal_init
int mbs_modal_init(MbsModal *mo, MbsData *s)
Initialize the Modal structure variables.
Definition: mbs_modal.c:140
MbsData
Definition: mbs_data.h:149
MbsModalMode::ux_a
double * ux_a
Real part of the extra ODE states corresponding to the mode motion (computed from ux_r)
Definition: mbs_modal_struct.h:64
MbsModalMode::ksi
double ksi
Damping factor [%].
Definition: mbs_modal_struct.h:58
_MBS_ERR_MOD_SPEC_11
#define _MBS_ERR_MOD_SPEC_11
Mid Level error number Module specific errors range from -11 to -19 please read the error message...
Definition: mbs_errors_names.h:162
mbs_modal_save_result
int mbs_modal_save_result(MbsModal *mbs_modal, MbsData *s, char *filename)
Write the modal analysis results (eigenmode, eigenfrequencies, mode type, ...) into a ASCII text file...
Definition: mbs_modal.c:773
MbsModalMode::evec_r
double * evec_r
Norm of the eigen vector associated to the mode [nx].
Definition: mbs_modal_struct.h:72
MbsLpk::verbose
int verbose
Definition: mbs_linearipk_struct.h:47
MbsModalOptions::resfilename
char * resfilename
Definition: mbs_modal_struct.h:41
save_dmat_0
void save_dmat_0(double **mat, int nb_r, int nb_c, char *name)
save a [nb_r times nb_c] matrix of doubles to a second matrix, starting with index 0 The file is open...
Definition: mbs_matrix.c:551
MbsModalMode::ux_phi
double * ux_phi
Phase of the extra ODE states corresponding to the mode motion (computed from evec_r and evec_phi)
Definition: mbs_modal_struct.h:70
MbsModalOptions::save2file
int save2file
no = 0, yes = 1, flag to save any results or animations [default = 1]
Definition: mbs_modal_struct.h:14
mbs_run_modal
int mbs_run_modal(MbsModal *mo, MbsData *s)
Run the Modal Analysis.
Definition: mbs_modal.c:109
mbs_eig_0
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
MbsModal::nMode
int nMode
Number of modes (nx duplication)
Definition: mbs_modal_struct.h:105
mbs_modal_struct.h
MbsModalMode::eval_a
double eval_a
Real part of the mode eigenvalue.
Definition: mbs_modal_struct.h:55
mbs_delete_lpk
void mbs_delete_lpk(MbsLpk *lpk)
free memory of the lpk structure.
Definition: mbs_linearipk.c:393
MbsSS::Gx
double ** Gx
Linearized ODE damping matrix : d uxd / d qdu.
Definition: mbs_statespace_struct.h:32
MbsLpk::equitol
double equitol
options for the lpk linearization [default = 1e-6]
Definition: mbs_linearipk_struct.h:53
MbsData::flag_stop
int flag_stop
stop the simulation. For dirdyn, equil, invdyn and solvekin only.
Definition: mbs_data.h:298
get_dvec_1
double * get_dvec_1(int l_v)
create (with memory allocation) a vector (length l_v) of doubles, starting at index 1
Definition: mbs_1D_array.c:885
copy_dvec_0
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
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
MbsModal::aux
MbsAux * aux
Definition: mbs_modal_struct.h:80
MbsModal::evec_r
double ** evec_r
Result of the Eigenvalue problem: norm of the eigen vectors (each column is a eigenvector) [nx X nx].
Definition: mbs_modal_struct.h:101
MbsModalOptions::animpath
char * animpath
Definition: mbs_modal_struct.h:47
find_ivec_0
int find_ivec_0(int *vec, int l_v, int f)
return the index of the value f in the (x sized) vector vec of integers, starting with index 0....
Definition: mbs_1D_array.c:802
MbsModal::evec_phi
double ** evec_phi
Result of the Eigenvalue problem: phase of the eigen vectors (each column is a eigenvector) [nx X nx]...
Definition: mbs_modal_struct.h:102
MbsModal::ss
MbsSS * ss
working structure containing a state space representation (with the matrix A)
Definition: mbs_modal_struct.h:83
MbsLpk::lintol
double lintol
options for the lpk linearization [default = 1e-3]
Definition: mbs_linearipk_struct.h:54
MbsModalMode::ux_r
double * ux_r
Norm of the extra ODE states corresponding to the mode motion (computed from evec_r and evec_phi)
Definition: mbs_modal_struct.h:69
MAX
#define MAX(a, b)
Definition: useful_functions.h:14
MbsSS::Gr
double ** Gr
Linearized damping matrix : d Rr / d qdu.
Definition: mbs_statespace_struct.h:26
mbs_check.h
mbs_compute_linearMatrices
int mbs_compute_linearMatrices(MbsSS *ss, MbsData *mbs_data, MbsLpk *lpk, MbsAux *aux)
Compute the linearized matrices necessary to obtain the (A,B,C) state-space representation.
Definition: mbs_statespace.c:207
mbs_modal_init
int mbs_modal_init(MbsModal *mo, MbsData *s)
Initialize the Modal structure variables.
Definition: mbs_modal.c:140
mbs_new_modal_aux
MbsModal * mbs_new_modal_aux(MbsData *s, MbsAux *mbs_aux)
Create a new modal structure.
Definition: mbs_modal.c:38
mbs_warning_msg
void mbs_warning_msg(char *msg,...)
Send a warning message.
Definition: mbs_message.c:89
mbs_delete_statespace
void mbs_delete_statespace(MbsSS *ss)
Free memory of the state-space structure.
Definition: mbs_statespace.c:542
mbs_statespace.h
mbs_errors_names.h
MbsModalOptions::anim_dt
double anim_dt
delta t for the animation generation [default = 1e-2]
Definition: mbs_modal_struct.h:37