diff --git a/src/mmoc/tests/system/gt_data/VIRplanoS/VIRplanoS.c b/src/mmoc/tests/system/gt_data/VIRplanoS/VIRplanoS.c new file mode 100644 index 00000000..7be0ee2a --- /dev/null +++ b/src/mmoc/tests/system/gt_data/VIRplanoS/VIRplanoS.c @@ -0,0 +1,2713 @@ +#include +#include +#include +#include + +#include "VIRplanoS.h" +#include "pkg_math.h" +#include +#include +#include +#include +#include + +void MOD_settings(SD_simulationSettings settings) +{ + settings->debug = 0; + settings->parallel = FALSE; + settings->hybrid = TRUE; + settings->method = 4; + settings->random_seed = 1; +} + +void MOD_definition(int idx, double *x, double *d, double *a, double t, double *dx) +{ + int _d1; + int _rg_d1; + int i; + switch(idx) { + case _eval_Vr(0): { + for(_rg_d1 = 4; _rg_d1<=7; _rg_d1+=1) { + _get_Vpar_idxs(_rg_d1); + _apply_usage_alg_eq_2(_d1); + if ((i >= 1 && i <= 4)) { + _Vpar(i,0) = _V(i,0)*_tr(i)*_inside(i); + _Vpar(i,1) = 0; + } + } + for(_rg_d1 = 4; _rg_d1<=7; _rg_d1+=1) { + _get_Vpar_idxs(_rg_d1); + _apply_usage_alg_eq_2(_d1); + if ((i >= 1 && i <= 4)) { + _Vpar(i,0) = _V(i,0)*_tr(i)*_inside(i); + _Vpar(i,1) = 0; + } + } + _sum_0(1,0) = _Vpar(1,0); + _sum_0(1,1) = 0; + for(_rg_d1 = 9; _rg_d1<=11; _rg_d1+=1) { + _get_sum_0_idxs(_rg_d1); + _apply_usage_alg_eq_4(_d1); + if ((i >= 2 && i <= 4)) { + _sum_0(i,0) = _sum_0(i-1,0)+_Vpar(i,0); + _sum_0(i,1) = 0; + } + } + _der_Vr(0) = _sum_0(4,0)*100/(double)4-_cr*_Vr(0); + _der_Vr(1) = (0)/2; + + return; + } + } + if (_is_var_V(idx)) { + _get_V_idxs(idx); + _apply_usage_eq_1(_d1); + if ((i >= 1 && i <= 4)) { + _der_V(i,0) = _gv(i)*_I(i,0)-_gva(i)*_S(i,0)*_A(i,0)*_V(i,0)-_gvh(i)*_H(i,0)*_V(i,0)-_av(i)*_V(i,0)-_av1(i)*_V(i,0)/(1+_av2(i)*_V(i,0))+_inside(i)*_re(i)*_Vr(0); + _der_V(i,1) = (0)/2; + + } + return; + } + if (_is_var_H(idx)) { + _get_H_idxs(idx); + _apply_usage_alg_eq_1(_d1); + if ((i >= 1 && i <= 4)) { + _D(i,0) = 1-_H(i,0)-_R(i,0)-_I(i,0); + _D(i,1) = 0; + } + _apply_usage_eq_2(_d1); + if ((i >= 1 && i <= 4)) { + _der_H(i,0) = _bhd(i)*_D(i,0)*(_H(i,0)+_R(i,0))+_ar(i)*_R(i,0)-_ghv(i)*_V(i,0)*_H(i,0)-_bhf(i)*_F(i,0)*_H(i,0); + _der_H(i,1) = (0)/2; + + } + return; + } + if (_is_var_I(idx)) { + _get_I_idxs(idx); + _apply_usage_eq_3(_d1); + if ((i >= 1 && i <= 4)) { + _der_I(i,0) = _ghv(i)*_V(i,0)*_H(i,0)-_bie(i)*_E(i,0)*_I(i,0)-_ai(i)*_I(i,0); + _der_I(i,1) = (0)/2; + + } + return; + } + if (_is_var_M(idx)) { + _get_M_idxs(idx); + _apply_usage_alg_eq_1(_d1); + if ((i >= 1 && i <= 4)) { + _D(i,0) = 1-_H(i,0)-_R(i,0)-_I(i,0); + _D(i,1) = 0; + } + _apply_usage_eq_4(_d1); + if ((i >= 1 && i <= 4)) { + _der_M(i,0) = (_bmd(i)*_D(i,0)+_bmv(i)*_V(i,0))*(1-_M(i,0))-_am(i)*_M(i,0); + _der_M(i,1) = (0)/2; + + } + return; + } + if (_is_var_F(idx)) { + _get_F_idxs(idx); + _apply_usage_eq_5(_d1); + if ((i >= 1 && i <= 4)) { + _der_F(i,0) = _bf(i)*_M(i,0)+_cf(i)*_I(i,0)-_bfh(i)*_H(i,0)*_F(i,0)-_af(i)*_F(i,0); + _der_F(i,1) = (0)/2; + + } + return; + } + if (_is_var_R(idx)) { + _get_R_idxs(idx); + _apply_usage_eq_6(_d1); + if ((i >= 1 && i <= 4)) { + _der_R(i,0) = _bhf(i)*_F(i,0)*_H(i,0)-_ar(i)*_R(i,0); + _der_R(i,1) = (0)/2; + + } + return; + } + if (_is_var_E(idx)) { + _get_E_idxs(idx); + _apply_usage_eq_7(_d1); + if ((i >= 1 && i <= 4)) { + _der_E(i,0) = _bem(i)*_M(i,0)*_E(i,0)-_bei(i)*_I(i,0)*_E(i,0)+_ae(i)*(1-_E(i,0)); + _der_E(i,1) = (0)/2; + + } + return; + } + if (_is_var_P(idx)) { + _get_P_idxs(idx); + _apply_usage_eq_8(_d1); + if ((i >= 1 && i <= 4)) { + _der_P(i,0) = _bpm(i)*_M(i,0)*_P(i,0)+_ap(i)*(1-_P(i,0)); + _der_P(i,1) = (0)/2; + + } + return; + } + if (_is_var_A(idx)) { + _get_A_idxs(idx); + _apply_usage_eq_9(_d1); + if ((i >= 1 && i <= 4)) { + _der_A(i,0) = _ba(i)*_P(i,0)-_gav(i)*_S(i,0)*_A(i,0)*_V(i,0)-_aa(i)*_A(i,0); + _der_A(i,1) = (0)/2; + + } + return; + } + if (_is_var_S(idx)) { + _get_S_idxs(idx); + _apply_usage_eq_10(_d1); + if ((i >= 1 && i <= 4)) { + _der_S(i,0) = _r(i)*_P(i,0)*(1-_S(i,0)); + _der_S(i,1) = (0)/2; + + } + return; + } +} + +void MOD_zeroCrossing(int idx, double *x, double *d, double *a, double t, double *zc) +{ + int _d1; + int i; + if (_is_var_event_1(idx)) { + _get_event_1_idxs(idx); + _apply_usage_event_1(_d1); + if ((i >= 1 && i <= 4)) { + _zc(0) = _time-(_inst(i)); + _zc(1) = (0)/1; + + } + return; + } + if (_is_var_event_2(idx)) { + _get_event_2_idxs(idx); + _apply_usage_event_2(_d1); + if ((i >= 1 && i <= 4)) { + _zc(0) = _V(i,0)-(1); + _zc(1) = (0)/1; + + } + return; + } + if (_is_var_event_3(idx)) { + _get_event_3_idxs(idx); + _apply_usage_event_3(_d1); + if ((i >= 1 && i <= 4)) { + _zc(0) = _time-(_day(i)); + _zc(1) = (0)/1; + + } + return; + } +} + +void MOD_handlerPos(int idx, double *x, double* q, double *d, double *a, double t) +{ + int _d1; + int i; + if (_is_var_event_1(idx)) { + _get_event_1_idxs(idx); + _apply_usage_event_1(_d1); + if ((i >= 1 && i <= 4)) { + if(_inside(i)==0) { + _inside(i) = 1-_inside(i); + _inst(i) = _inst(i)+__math__rand(8.330000e-02); + }else { + _inside(i) = 1-_inside(i); + _inst(i) = _inst(i)+__math__rand(2.075000e-01)+8.330000e-01; + } + } + return; + } + if (_is_var_event_2(idx)) { + _get_event_2_idxs(idx); + _apply_usage_event_2(_d1); + if ((i >= 1 && i <= 4)) { + _Su = _Su-1; + _In1 = _In1+1; + _day(i) = _time+10; + } + return; + } + if (_is_var_event_3(idx)) { + _get_event_3_idxs(idx); + _apply_usage_event_3(_d1); + if ((i >= 1 && i <= 4)) { + _In1 = _In1-1; + _Rec = _Rec+1; + } + return; + } +} + +void MOD_handlerNeg(int idx, double *x, double* q, double *d, double *a, double t) +{ +} + +void MOD_output(int idx, double *x, double *d, double *a, double t, double *out) +{ + switch(idx) { + case _eval_out_exp_1: { + _out = _In1; + return; + } + case _eval_out_exp_2: { + _out = _Rec; + return; + } + case _eval_out_exp_3: { + _out = _Su; + return; + } + case _eval_out_exp_4: { + _out = _Vr(0); + return; + } + } +} + +void MOD_jacobian(double *x, double *d, double *a, double t, SD_jacMatrices dvdx, double *jac) +{ + int row, row_t, eq_var, c_row, c_row_g; + int col, col_g, col_t; + int x_ind; + double aux; + int _d1; + int _rg_d1; + int i; + SD_cleanJacMatrices(dvdx); + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_1_var_idxs(row, eq_var); + _get_V_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_A(_d1,0); + col = pos(dvdx->df_dx[0]->index[c_row], dvdx->df_dx[0]->size[c_row], x_ind); + _apply_usage_eq_1(_d1); + aux = 0; + dvdx->df_dx[0]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_H(_d1,0); + col = pos(dvdx->df_dx[0]->index[c_row], dvdx->df_dx[0]->size[c_row], x_ind); + _apply_usage_eq_1(_d1); + aux = 0; + dvdx->df_dx[0]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_I(_d1,0); + col = pos(dvdx->df_dx[0]->index[c_row], dvdx->df_dx[0]->size[c_row], x_ind); + _apply_usage_eq_1(_d1); + aux = 0; + dvdx->df_dx[0]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_S(_d1,0); + col = pos(dvdx->df_dx[0]->index[c_row], dvdx->df_dx[0]->size[c_row], x_ind); + _apply_usage_eq_1(_d1); + aux = 0; + dvdx->df_dx[0]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_V(_d1,0); + col = pos(dvdx->df_dx[0]->index[c_row], dvdx->df_dx[0]->size[c_row], x_ind); + _apply_usage_eq_1(_d1); + aux = 0; + dvdx->df_dx[0]->value[c_row][col] += aux; + } + x_ind = _idx_Vr(0); + col = pos(dvdx->df_dx[0]->index[c_row], dvdx->df_dx[0]->size[c_row], x_ind); + _apply_usage_eq_1(_d1); + aux = 0; + dvdx->df_dx[0]->value[c_row][col] += aux; + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_alg_eq_1_var_idxs(row, eq_var); + _get_D_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_H(_d1,0); + col = pos(dvdx->dg_dx[0]->index[c_row], dvdx->dg_dx[0]->size[c_row], x_ind); + _apply_usage_alg_eq_1(_d1); + aux = 0; + dvdx->dg_dx[0]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_I(_d1,0); + col = pos(dvdx->dg_dx[0]->index[c_row], dvdx->dg_dx[0]->size[c_row], x_ind); + _apply_usage_alg_eq_1(_d1); + aux = 0; + dvdx->dg_dx[0]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_R(_d1,0); + col = pos(dvdx->dg_dx[0]->index[c_row], dvdx->dg_dx[0]->size[c_row], x_ind); + _apply_usage_alg_eq_1(_d1); + aux = 0; + dvdx->dg_dx[0]->value[c_row][col] += aux; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_2_var_idxs(row, eq_var); + _get_H_idxs(eq_var); + _apply_usage_eq_2(_d1); + aux = 0; + if((1 <= _d1 && _d1 <= 4) && (1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_H(_d1,0); + col = pos(dvdx->df_dx[1]->index[c_row], dvdx->df_dx[1]->size[c_row], x_ind); + c_row_g = _idx_D(_rg_d1,0) - 0; + col_g = pos(dvdx->dg_dx[0]->index[c_row_g], dvdx->dg_dx[0]->size[c_row_g], x_ind); + dvdx->df_dx[1]->value[c_row][col] += aux * dvdx->dg_dx[0]->value[c_row_g][col_g]; + } + if((1 <= _d1 && _d1 <= 4) && (1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_I(_d1,0); + col = pos(dvdx->df_dx[1]->index[c_row], dvdx->df_dx[1]->size[c_row], x_ind); + c_row_g = _idx_D(_rg_d1,0) - 0; + col_g = pos(dvdx->dg_dx[0]->index[c_row_g], dvdx->dg_dx[0]->size[c_row_g], x_ind); + dvdx->df_dx[1]->value[c_row][col] += aux * dvdx->dg_dx[0]->value[c_row_g][col_g]; + } + if((1 <= _d1 && _d1 <= 4) && (1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_R(_d1,0); + col = pos(dvdx->df_dx[1]->index[c_row], dvdx->df_dx[1]->size[c_row], x_ind); + c_row_g = _idx_D(_rg_d1,0) - 0; + col_g = pos(dvdx->dg_dx[0]->index[c_row_g], dvdx->dg_dx[0]->size[c_row_g], x_ind); + dvdx->df_dx[1]->value[c_row][col] += aux * dvdx->dg_dx[0]->value[c_row_g][col_g]; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_F(_d1,0); + col = pos(dvdx->df_dx[1]->index[c_row], dvdx->df_dx[1]->size[c_row], x_ind); + _apply_usage_eq_2(_d1); + aux = 0; + dvdx->df_dx[1]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_H(_d1,0); + col = pos(dvdx->df_dx[1]->index[c_row], dvdx->df_dx[1]->size[c_row], x_ind); + _apply_usage_eq_2(_d1); + aux = 0; + dvdx->df_dx[1]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_R(_d1,0); + col = pos(dvdx->df_dx[1]->index[c_row], dvdx->df_dx[1]->size[c_row], x_ind); + _apply_usage_eq_2(_d1); + aux = 0; + dvdx->df_dx[1]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_V(_d1,0); + col = pos(dvdx->df_dx[1]->index[c_row], dvdx->df_dx[1]->size[c_row], x_ind); + _apply_usage_eq_2(_d1); + aux = 0; + dvdx->df_dx[1]->value[c_row][col] += aux; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_3_var_idxs(row, eq_var); + _get_I_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_E(_d1,0); + col = pos(dvdx->df_dx[2]->index[c_row], dvdx->df_dx[2]->size[c_row], x_ind); + _apply_usage_eq_3(_d1); + aux = 0; + dvdx->df_dx[2]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_H(_d1,0); + col = pos(dvdx->df_dx[2]->index[c_row], dvdx->df_dx[2]->size[c_row], x_ind); + _apply_usage_eq_3(_d1); + aux = 0; + dvdx->df_dx[2]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_I(_d1,0); + col = pos(dvdx->df_dx[2]->index[c_row], dvdx->df_dx[2]->size[c_row], x_ind); + _apply_usage_eq_3(_d1); + aux = 0; + dvdx->df_dx[2]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_V(_d1,0); + col = pos(dvdx->df_dx[2]->index[c_row], dvdx->df_dx[2]->size[c_row], x_ind); + _apply_usage_eq_3(_d1); + aux = 0; + dvdx->df_dx[2]->value[c_row][col] += aux; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_4_var_idxs(row, eq_var); + _get_M_idxs(eq_var); + _apply_usage_eq_4(_d1); + aux = 0; + if((1 <= _d1 && _d1 <= 4) && (1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_H(_d1,0); + col = pos(dvdx->df_dx[3]->index[c_row], dvdx->df_dx[3]->size[c_row], x_ind); + c_row_g = _idx_D(_rg_d1,0) - 0; + col_g = pos(dvdx->dg_dx[0]->index[c_row_g], dvdx->dg_dx[0]->size[c_row_g], x_ind); + dvdx->df_dx[3]->value[c_row][col] += aux * dvdx->dg_dx[0]->value[c_row_g][col_g]; + } + if((1 <= _d1 && _d1 <= 4) && (1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_I(_d1,0); + col = pos(dvdx->df_dx[3]->index[c_row], dvdx->df_dx[3]->size[c_row], x_ind); + c_row_g = _idx_D(_rg_d1,0) - 0; + col_g = pos(dvdx->dg_dx[0]->index[c_row_g], dvdx->dg_dx[0]->size[c_row_g], x_ind); + dvdx->df_dx[3]->value[c_row][col] += aux * dvdx->dg_dx[0]->value[c_row_g][col_g]; + } + if((1 <= _d1 && _d1 <= 4) && (1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_R(_d1,0); + col = pos(dvdx->df_dx[3]->index[c_row], dvdx->df_dx[3]->size[c_row], x_ind); + c_row_g = _idx_D(_rg_d1,0) - 0; + col_g = pos(dvdx->dg_dx[0]->index[c_row_g], dvdx->dg_dx[0]->size[c_row_g], x_ind); + dvdx->df_dx[3]->value[c_row][col] += aux * dvdx->dg_dx[0]->value[c_row_g][col_g]; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_M(_d1,0); + col = pos(dvdx->df_dx[3]->index[c_row], dvdx->df_dx[3]->size[c_row], x_ind); + _apply_usage_eq_4(_d1); + aux = 0; + dvdx->df_dx[3]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_V(_d1,0); + col = pos(dvdx->df_dx[3]->index[c_row], dvdx->df_dx[3]->size[c_row], x_ind); + _apply_usage_eq_4(_d1); + aux = 0; + dvdx->df_dx[3]->value[c_row][col] += aux; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_5_var_idxs(row, eq_var); + _get_F_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_F(_d1,0); + col = pos(dvdx->df_dx[4]->index[c_row], dvdx->df_dx[4]->size[c_row], x_ind); + _apply_usage_eq_5(_d1); + aux = 0; + dvdx->df_dx[4]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_H(_d1,0); + col = pos(dvdx->df_dx[4]->index[c_row], dvdx->df_dx[4]->size[c_row], x_ind); + _apply_usage_eq_5(_d1); + aux = 0; + dvdx->df_dx[4]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_I(_d1,0); + col = pos(dvdx->df_dx[4]->index[c_row], dvdx->df_dx[4]->size[c_row], x_ind); + _apply_usage_eq_5(_d1); + aux = 0; + dvdx->df_dx[4]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_M(_d1,0); + col = pos(dvdx->df_dx[4]->index[c_row], dvdx->df_dx[4]->size[c_row], x_ind); + _apply_usage_eq_5(_d1); + aux = 0; + dvdx->df_dx[4]->value[c_row][col] += aux; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_6_var_idxs(row, eq_var); + _get_R_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_F(_d1,0); + col = pos(dvdx->df_dx[5]->index[c_row], dvdx->df_dx[5]->size[c_row], x_ind); + _apply_usage_eq_6(_d1); + aux = 0; + dvdx->df_dx[5]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_H(_d1,0); + col = pos(dvdx->df_dx[5]->index[c_row], dvdx->df_dx[5]->size[c_row], x_ind); + _apply_usage_eq_6(_d1); + aux = 0; + dvdx->df_dx[5]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_R(_d1,0); + col = pos(dvdx->df_dx[5]->index[c_row], dvdx->df_dx[5]->size[c_row], x_ind); + _apply_usage_eq_6(_d1); + aux = 0; + dvdx->df_dx[5]->value[c_row][col] += aux; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_7_var_idxs(row, eq_var); + _get_E_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_E(_d1,0); + col = pos(dvdx->df_dx[6]->index[c_row], dvdx->df_dx[6]->size[c_row], x_ind); + _apply_usage_eq_7(_d1); + aux = 0; + dvdx->df_dx[6]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_I(_d1,0); + col = pos(dvdx->df_dx[6]->index[c_row], dvdx->df_dx[6]->size[c_row], x_ind); + _apply_usage_eq_7(_d1); + aux = 0; + dvdx->df_dx[6]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_M(_d1,0); + col = pos(dvdx->df_dx[6]->index[c_row], dvdx->df_dx[6]->size[c_row], x_ind); + _apply_usage_eq_7(_d1); + aux = 0; + dvdx->df_dx[6]->value[c_row][col] += aux; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_8_var_idxs(row, eq_var); + _get_P_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_M(_d1,0); + col = pos(dvdx->df_dx[7]->index[c_row], dvdx->df_dx[7]->size[c_row], x_ind); + _apply_usage_eq_8(_d1); + aux = 0; + dvdx->df_dx[7]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_P(_d1,0); + col = pos(dvdx->df_dx[7]->index[c_row], dvdx->df_dx[7]->size[c_row], x_ind); + _apply_usage_eq_8(_d1); + aux = 0; + dvdx->df_dx[7]->value[c_row][col] += aux; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_9_var_idxs(row, eq_var); + _get_A_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_A(_d1,0); + col = pos(dvdx->df_dx[8]->index[c_row], dvdx->df_dx[8]->size[c_row], x_ind); + _apply_usage_eq_9(_d1); + aux = 0; + dvdx->df_dx[8]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_P(_d1,0); + col = pos(dvdx->df_dx[8]->index[c_row], dvdx->df_dx[8]->size[c_row], x_ind); + _apply_usage_eq_9(_d1); + aux = 0; + dvdx->df_dx[8]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_S(_d1,0); + col = pos(dvdx->df_dx[8]->index[c_row], dvdx->df_dx[8]->size[c_row], x_ind); + _apply_usage_eq_9(_d1); + aux = 0; + dvdx->df_dx[8]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_V(_d1,0); + col = pos(dvdx->df_dx[8]->index[c_row], dvdx->df_dx[8]->size[c_row], x_ind); + _apply_usage_eq_9(_d1); + aux = 0; + dvdx->df_dx[8]->value[c_row][col] += aux; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_10_var_idxs(row, eq_var); + _get_S_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_P(_d1,0); + col = pos(dvdx->df_dx[9]->index[c_row], dvdx->df_dx[9]->size[c_row], x_ind); + _apply_usage_eq_10(_d1); + aux = 0; + dvdx->df_dx[9]->value[c_row][col] += aux; + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_S(_d1,0); + col = pos(dvdx->df_dx[9]->index[c_row], dvdx->df_dx[9]->size[c_row], x_ind); + _apply_usage_eq_10(_d1); + aux = 0; + dvdx->df_dx[9]->value[c_row][col] += aux; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_alg_eq_2_var_idxs(row, eq_var); + _get_Vpar_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_V(_d1,0); + col = pos(dvdx->dg_dx[1]->index[c_row], dvdx->dg_dx[1]->size[c_row], x_ind); + _apply_usage_alg_eq_2(_d1); + aux = 0; + dvdx->dg_dx[1]->value[c_row][col] += aux; + } + } + for(row = 1; row <= 1; row++) { + c_row = _c_index(row); + aux = 0; + x_ind = _idx_V(1,0); + col = pos(dvdx->dg_dx[2]->index[c_row], dvdx->dg_dx[2]->size[c_row], x_ind); + c_row_g = _idx_Vpar(1,0) - 4; + col_g = pos(dvdx->dg_dx[1]->index[c_row_g], dvdx->dg_dx[1]->size[c_row_g], x_ind); + dvdx->dg_dx[2]->value[c_row][col] += aux * dvdx->dg_dx[1]->value[c_row_g][col_g]; + } + for(row = 1; row <= 3; row++) { + c_row = _c_index(row); + _get_alg_eq_4_var_idxs(row, eq_var); + _get_sum_0_idxs(eq_var); + _apply_usage_alg_eq_4(_d1); + aux = 0; + if((2 <= _d1 && _d1 <= 4) && (2 <= _d1 && _d1 <= 4)) { + x_ind = _idx_V(_d1,0); + col = pos(dvdx->dg_dx[3]->index[c_row], dvdx->dg_dx[3]->size[c_row], x_ind); + c_row_g = _idx_Vpar(_rg_d1,0) - 4; + col_g = pos(dvdx->dg_dx[1]->index[c_row_g], dvdx->dg_dx[1]->size[c_row_g], x_ind); + dvdx->dg_dx[3]->value[c_row][col] += aux * dvdx->dg_dx[1]->value[c_row_g][col_g]; + } + } + for(row = 1; row <= 1; row++) { + c_row = _c_index(row); + aux = 0; + x_ind = _idx_V(1,0); + col = pos(dvdx->df_dx[10]->index[c_row], dvdx->df_dx[10]->size[c_row], x_ind); + c_row_g = _idx_sum_0(1,0) - 8; + col_g = pos(dvdx->dg_dx[2]->index[c_row_g], dvdx->dg_dx[2]->size[c_row_g], x_ind); + dvdx->df_dx[10]->value[c_row][col] += aux * dvdx->dg_dx[2]->value[c_row_g][col_g]; + for(i = 2; i<=4; i+=1) { + _get_alg_eq_4_var_idxs(_idx_sum_0(i,0), eq_var); + _get_sum_0_idxs(eq_var); + if((2 <= _d1 && _d1 <= 4)) { + x_ind = _idx_V(_d1,0); + col = pos(dvdx->df_dx[10]->index[c_row], dvdx->df_dx[10]->size[c_row], x_ind); + c_row_g = _idx_sum_0(_rg_d1,0) - 9; + col_g = pos(dvdx->dg_dx[3]->index[c_row_g], dvdx->dg_dx[3]->size[c_row_g], x_ind); + dvdx->df_dx[10]->value[c_row][col] += aux * dvdx->dg_dx[3]->value[c_row_g][col_g]; + } + } x_ind = _idx_Vr(0); + col = pos(dvdx->df_dx[10]->index[c_row], dvdx->df_dx[10]->size[c_row], x_ind); + aux = 0; + dvdx->df_dx[10]->value[c_row][col] += aux; + } + // Assign Jacobian Matrix values for equation: 0 + for (row = 0; row < 4; row++) { + for (col = 0; col < dvdx->df_dx[0]->size[row]; col++) { + row_t = dvdx->df_dx[0]->index[row][col]; + _assign_jac(row_t, dvdx->df_dx[0]->value[row][col]); + } + } + // Assign Jacobian Matrix values for equation: 1 + for (row = 0; row < 4; row++) { + for (col = 0; col < dvdx->df_dx[1]->size[row]; col++) { + row_t = dvdx->df_dx[1]->index[row][col]; + _assign_jac(row_t, dvdx->df_dx[1]->value[row][col]); + } + } + // Assign Jacobian Matrix values for equation: 2 + for (row = 0; row < 4; row++) { + for (col = 0; col < dvdx->df_dx[2]->size[row]; col++) { + row_t = dvdx->df_dx[2]->index[row][col]; + _assign_jac(row_t, dvdx->df_dx[2]->value[row][col]); + } + } + // Assign Jacobian Matrix values for equation: 3 + for (row = 0; row < 4; row++) { + for (col = 0; col < dvdx->df_dx[3]->size[row]; col++) { + row_t = dvdx->df_dx[3]->index[row][col]; + _assign_jac(row_t, dvdx->df_dx[3]->value[row][col]); + } + } + // Assign Jacobian Matrix values for equation: 4 + for (row = 0; row < 4; row++) { + for (col = 0; col < dvdx->df_dx[4]->size[row]; col++) { + row_t = dvdx->df_dx[4]->index[row][col]; + _assign_jac(row_t, dvdx->df_dx[4]->value[row][col]); + } + } + // Assign Jacobian Matrix values for equation: 5 + for (row = 0; row < 4; row++) { + for (col = 0; col < dvdx->df_dx[5]->size[row]; col++) { + row_t = dvdx->df_dx[5]->index[row][col]; + _assign_jac(row_t, dvdx->df_dx[5]->value[row][col]); + } + } + // Assign Jacobian Matrix values for equation: 6 + for (row = 0; row < 4; row++) { + for (col = 0; col < dvdx->df_dx[6]->size[row]; col++) { + row_t = dvdx->df_dx[6]->index[row][col]; + _assign_jac(row_t, dvdx->df_dx[6]->value[row][col]); + } + } + // Assign Jacobian Matrix values for equation: 7 + for (row = 0; row < 4; row++) { + for (col = 0; col < dvdx->df_dx[7]->size[row]; col++) { + row_t = dvdx->df_dx[7]->index[row][col]; + _assign_jac(row_t, dvdx->df_dx[7]->value[row][col]); + } + } + // Assign Jacobian Matrix values for equation: 8 + for (row = 0; row < 4; row++) { + for (col = 0; col < dvdx->df_dx[8]->size[row]; col++) { + row_t = dvdx->df_dx[8]->index[row][col]; + _assign_jac(row_t, dvdx->df_dx[8]->value[row][col]); + } + } + // Assign Jacobian Matrix values for equation: 9 + for (row = 0; row < 4; row++) { + for (col = 0; col < dvdx->df_dx[9]->size[row]; col++) { + row_t = dvdx->df_dx[9]->index[row][col]; + _assign_jac(row_t, dvdx->df_dx[9]->value[row][col]); + } + } + // Assign Jacobian Matrix values for equation: 10 + for (row = 0; row < 1; row++) { + for (col = 0; col < dvdx->df_dx[10]->size[row]; col++) { + row_t = dvdx->df_dx[10]->index[row][col]; + _assign_jac(row_t, dvdx->df_dx[10]->value[row][col]); + } + } +} + +void MOD_dependencies(int idx, double *x, double *d, double *a, double t, double *dx, int *map) +{ + int _d1; + int _rg_d1; + int i; + switch(idx) { + case _eval_Vr(0): { + for(_rg_d1 = 4; _rg_d1<=7; _rg_d1+=1) { + _get_Vpar_idxs(_rg_d1); + _apply_usage_alg_eq_2(_d1); + if ((i >= 1 && i <= 4)) { + _Vpar(i,0) = _V(i,0)*_tr(i)*_inside(i); + _Vpar(i,1) = 0; + } + } + for(_rg_d1 = 4; _rg_d1<=7; _rg_d1+=1) { + _get_Vpar_idxs(_rg_d1); + _apply_usage_alg_eq_2(_d1); + if ((i >= 1 && i <= 4)) { + _Vpar(i,0) = _V(i,0)*_tr(i)*_inside(i); + _Vpar(i,1) = 0; + } + } + _sum_0(1,0) = _Vpar(1,0); + _sum_0(1,1) = 0; + for(_rg_d1 = 9; _rg_d1<=11; _rg_d1+=1) { + _get_sum_0_idxs(_rg_d1); + _apply_usage_alg_eq_4(_d1); + if ((i >= 2 && i <= 4)) { + _sum_0(i,0) = _sum_0(i-1,0)+_Vpar(i,0); + _sum_0(i,1) = 0; + } + } + for(i = 1; i<=4; i+=1) { + _apply_usage_eq_1(i); + if ((i >= 1 && i <= 4)) { + _eval_dep_V(i,1) = _gv(i)*_I(i,0)-_gva(i)*_S(i,0)*_A(i,0)*_V(i,0)-_gvh(i)*_H(i,0)*_V(i,0)-_av(i)*_V(i,0)-_av1(i)*_V(i,0)/(1+_av2(i)*_V(i,0))+_inside(i)*_re(i)*_Vr(0); + _eval_dep_V(i,2) = (0)/2; + } + } + _eval_dep_Vr(1) = _sum_0(4,0)*100/(double)4-_cr*_Vr(0); + _eval_dep_Vr(2) = (0)/2; + break; + } + } + if (_is_var_A(idx)) { + _get_A_idxs(idx); + _apply_usage_eq_1(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_V(i,1) = _gv(i)*_I(i,0)-_gva(i)*_S(i,0)*_A(i,0)*_V(i,0)-_gvh(i)*_H(i,0)*_V(i,0)-_av(i)*_V(i,0)-_av1(i)*_V(i,0)/(1+_av2(i)*_V(i,0))+_inside(i)*_re(i)*_Vr(0); + _eval_dep_V(i,2) = (0)/2; + } + } + if (_is_var_A(idx)) { + _get_A_idxs(idx); + _apply_usage_eq_9(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_A(i,1) = _ba(i)*_P(i,0)-_gav(i)*_S(i,0)*_A(i,0)*_V(i,0)-_aa(i)*_A(i,0); + _eval_dep_A(i,2) = (0)/2; + } + } + if (_is_var_E(idx)) { + _get_E_idxs(idx); + _apply_usage_eq_3(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_I(i,1) = _ghv(i)*_V(i,0)*_H(i,0)-_bie(i)*_E(i,0)*_I(i,0)-_ai(i)*_I(i,0); + _eval_dep_I(i,2) = (0)/2; + } + } + if (_is_var_E(idx)) { + _get_E_idxs(idx); + _apply_usage_eq_7(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_E(i,1) = _bem(i)*_M(i,0)*_E(i,0)-_bei(i)*_I(i,0)*_E(i,0)+_ae(i)*(1-_E(i,0)); + _eval_dep_E(i,2) = (0)/2; + } + } + if (_is_var_F(idx)) { + _get_F_idxs(idx); + _apply_usage_alg_eq_1(_d1); + if ((i >= 1 && i <= 4)) { + _D(i,0) = 1-_H(i,0)-_R(i,0)-_I(i,0); + _D(i,1) = 0; + } + _apply_usage_eq_2(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_H(i,1) = _bhd(i)*_D(i,0)*(_H(i,0)+_R(i,0))+_ar(i)*_R(i,0)-_ghv(i)*_V(i,0)*_H(i,0)-_bhf(i)*_F(i,0)*_H(i,0); + _eval_dep_H(i,2) = (0)/2; + } + } + if (_is_var_F(idx)) { + _get_F_idxs(idx); + _apply_usage_eq_5(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_F(i,1) = _bf(i)*_M(i,0)+_cf(i)*_I(i,0)-_bfh(i)*_H(i,0)*_F(i,0)-_af(i)*_F(i,0); + _eval_dep_F(i,2) = (0)/2; + } + } + if (_is_var_F(idx)) { + _get_F_idxs(idx); + _apply_usage_eq_6(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_R(i,1) = _bhf(i)*_F(i,0)*_H(i,0)-_ar(i)*_R(i,0); + _eval_dep_R(i,2) = (0)/2; + } + } + if (_is_var_H(idx)) { + _get_H_idxs(idx); + _apply_usage_eq_1(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_V(i,1) = _gv(i)*_I(i,0)-_gva(i)*_S(i,0)*_A(i,0)*_V(i,0)-_gvh(i)*_H(i,0)*_V(i,0)-_av(i)*_V(i,0)-_av1(i)*_V(i,0)/(1+_av2(i)*_V(i,0))+_inside(i)*_re(i)*_Vr(0); + _eval_dep_V(i,2) = (0)/2; + } + } + if (_is_var_H(idx)) { + _get_H_idxs(idx); + _apply_usage_alg_eq_1(_d1); + if ((i >= 1 && i <= 4)) { + _D(i,0) = 1-_H(i,0)-_R(i,0)-_I(i,0); + _D(i,1) = 0; + } + _apply_usage_eq_2(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_H(i,1) = _bhd(i)*_D(i,0)*(_H(i,0)+_R(i,0))+_ar(i)*_R(i,0)-_ghv(i)*_V(i,0)*_H(i,0)-_bhf(i)*_F(i,0)*_H(i,0); + _eval_dep_H(i,2) = (0)/2; + } + } + if (_is_var_H(idx)) { + _get_H_idxs(idx); + _apply_usage_eq_3(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_I(i,1) = _ghv(i)*_V(i,0)*_H(i,0)-_bie(i)*_E(i,0)*_I(i,0)-_ai(i)*_I(i,0); + _eval_dep_I(i,2) = (0)/2; + } + } + if (_is_var_H(idx)) { + _get_H_idxs(idx); + _apply_usage_eq_4(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_M(i,1) = (_bmd(i)*_D(i,0)+_bmv(i)*_V(i,0))*(1-_M(i,0))-_am(i)*_M(i,0); + _eval_dep_M(i,2) = (0)/2; + } + } + if (_is_var_H(idx)) { + _get_H_idxs(idx); + _apply_usage_eq_5(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_F(i,1) = _bf(i)*_M(i,0)+_cf(i)*_I(i,0)-_bfh(i)*_H(i,0)*_F(i,0)-_af(i)*_F(i,0); + _eval_dep_F(i,2) = (0)/2; + } + } + if (_is_var_H(idx)) { + _get_H_idxs(idx); + _apply_usage_eq_6(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_R(i,1) = _bhf(i)*_F(i,0)*_H(i,0)-_ar(i)*_R(i,0); + _eval_dep_R(i,2) = (0)/2; + } + } + if (_is_var_I(idx)) { + _get_I_idxs(idx); + _apply_usage_eq_1(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_V(i,1) = _gv(i)*_I(i,0)-_gva(i)*_S(i,0)*_A(i,0)*_V(i,0)-_gvh(i)*_H(i,0)*_V(i,0)-_av(i)*_V(i,0)-_av1(i)*_V(i,0)/(1+_av2(i)*_V(i,0))+_inside(i)*_re(i)*_Vr(0); + _eval_dep_V(i,2) = (0)/2; + } + } + if (_is_var_I(idx)) { + _get_I_idxs(idx); + _apply_usage_alg_eq_1(_d1); + if ((i >= 1 && i <= 4)) { + _D(i,0) = 1-_H(i,0)-_R(i,0)-_I(i,0); + _D(i,1) = 0; + } + _apply_usage_eq_2(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_H(i,1) = _bhd(i)*_D(i,0)*(_H(i,0)+_R(i,0))+_ar(i)*_R(i,0)-_ghv(i)*_V(i,0)*_H(i,0)-_bhf(i)*_F(i,0)*_H(i,0); + _eval_dep_H(i,2) = (0)/2; + } + } + if (_is_var_I(idx)) { + _get_I_idxs(idx); + _apply_usage_eq_3(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_I(i,1) = _ghv(i)*_V(i,0)*_H(i,0)-_bie(i)*_E(i,0)*_I(i,0)-_ai(i)*_I(i,0); + _eval_dep_I(i,2) = (0)/2; + } + } + if (_is_var_I(idx)) { + _get_I_idxs(idx); + _apply_usage_eq_4(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_M(i,1) = (_bmd(i)*_D(i,0)+_bmv(i)*_V(i,0))*(1-_M(i,0))-_am(i)*_M(i,0); + _eval_dep_M(i,2) = (0)/2; + } + } + if (_is_var_I(idx)) { + _get_I_idxs(idx); + _apply_usage_eq_5(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_F(i,1) = _bf(i)*_M(i,0)+_cf(i)*_I(i,0)-_bfh(i)*_H(i,0)*_F(i,0)-_af(i)*_F(i,0); + _eval_dep_F(i,2) = (0)/2; + } + } + if (_is_var_I(idx)) { + _get_I_idxs(idx); + _apply_usage_eq_7(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_E(i,1) = _bem(i)*_M(i,0)*_E(i,0)-_bei(i)*_I(i,0)*_E(i,0)+_ae(i)*(1-_E(i,0)); + _eval_dep_E(i,2) = (0)/2; + } + } + if (_is_var_M(idx)) { + _get_M_idxs(idx); + _apply_usage_alg_eq_1(_d1); + if ((i >= 1 && i <= 4)) { + _D(i,0) = 1-_H(i,0)-_R(i,0)-_I(i,0); + _D(i,1) = 0; + } + _apply_usage_eq_4(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_M(i,1) = (_bmd(i)*_D(i,0)+_bmv(i)*_V(i,0))*(1-_M(i,0))-_am(i)*_M(i,0); + _eval_dep_M(i,2) = (0)/2; + } + } + if (_is_var_M(idx)) { + _get_M_idxs(idx); + _apply_usage_eq_5(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_F(i,1) = _bf(i)*_M(i,0)+_cf(i)*_I(i,0)-_bfh(i)*_H(i,0)*_F(i,0)-_af(i)*_F(i,0); + _eval_dep_F(i,2) = (0)/2; + } + } + if (_is_var_M(idx)) { + _get_M_idxs(idx); + _apply_usage_eq_7(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_E(i,1) = _bem(i)*_M(i,0)*_E(i,0)-_bei(i)*_I(i,0)*_E(i,0)+_ae(i)*(1-_E(i,0)); + _eval_dep_E(i,2) = (0)/2; + } + } + if (_is_var_M(idx)) { + _get_M_idxs(idx); + _apply_usage_eq_8(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_P(i,1) = _bpm(i)*_M(i,0)*_P(i,0)+_ap(i)*(1-_P(i,0)); + _eval_dep_P(i,2) = (0)/2; + } + } + if (_is_var_P(idx)) { + _get_P_idxs(idx); + _apply_usage_eq_8(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_P(i,1) = _bpm(i)*_M(i,0)*_P(i,0)+_ap(i)*(1-_P(i,0)); + _eval_dep_P(i,2) = (0)/2; + } + } + if (_is_var_P(idx)) { + _get_P_idxs(idx); + _apply_usage_eq_9(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_A(i,1) = _ba(i)*_P(i,0)-_gav(i)*_S(i,0)*_A(i,0)*_V(i,0)-_aa(i)*_A(i,0); + _eval_dep_A(i,2) = (0)/2; + } + } + if (_is_var_P(idx)) { + _get_P_idxs(idx); + _apply_usage_eq_10(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_S(i,1) = _r(i)*_P(i,0)*(1-_S(i,0)); + _eval_dep_S(i,2) = (0)/2; + } + } + if (_is_var_R(idx)) { + _get_R_idxs(idx); + _apply_usage_alg_eq_1(_d1); + if ((i >= 1 && i <= 4)) { + _D(i,0) = 1-_H(i,0)-_R(i,0)-_I(i,0); + _D(i,1) = 0; + } + _apply_usage_eq_2(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_H(i,1) = _bhd(i)*_D(i,0)*(_H(i,0)+_R(i,0))+_ar(i)*_R(i,0)-_ghv(i)*_V(i,0)*_H(i,0)-_bhf(i)*_F(i,0)*_H(i,0); + _eval_dep_H(i,2) = (0)/2; + } + } + if (_is_var_R(idx)) { + _get_R_idxs(idx); + _apply_usage_eq_4(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_M(i,1) = (_bmd(i)*_D(i,0)+_bmv(i)*_V(i,0))*(1-_M(i,0))-_am(i)*_M(i,0); + _eval_dep_M(i,2) = (0)/2; + } + } + if (_is_var_R(idx)) { + _get_R_idxs(idx); + _apply_usage_eq_6(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_R(i,1) = _bhf(i)*_F(i,0)*_H(i,0)-_ar(i)*_R(i,0); + _eval_dep_R(i,2) = (0)/2; + } + } + if (_is_var_S(idx)) { + _get_S_idxs(idx); + _apply_usage_eq_1(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_V(i,1) = _gv(i)*_I(i,0)-_gva(i)*_S(i,0)*_A(i,0)*_V(i,0)-_gvh(i)*_H(i,0)*_V(i,0)-_av(i)*_V(i,0)-_av1(i)*_V(i,0)/(1+_av2(i)*_V(i,0))+_inside(i)*_re(i)*_Vr(0); + _eval_dep_V(i,2) = (0)/2; + } + } + if (_is_var_S(idx)) { + _get_S_idxs(idx); + _apply_usage_eq_9(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_A(i,1) = _ba(i)*_P(i,0)-_gav(i)*_S(i,0)*_A(i,0)*_V(i,0)-_aa(i)*_A(i,0); + _eval_dep_A(i,2) = (0)/2; + } + } + if (_is_var_S(idx)) { + _get_S_idxs(idx); + _apply_usage_eq_10(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_S(i,1) = _r(i)*_P(i,0)*(1-_S(i,0)); + _eval_dep_S(i,2) = (0)/2; + } + } + if (_is_var_V(idx)) { + _get_V_idxs(idx); + _apply_usage_eq_1(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_V(i,1) = _gv(i)*_I(i,0)-_gva(i)*_S(i,0)*_A(i,0)*_V(i,0)-_gvh(i)*_H(i,0)*_V(i,0)-_av(i)*_V(i,0)-_av1(i)*_V(i,0)/(1+_av2(i)*_V(i,0))+_inside(i)*_re(i)*_Vr(0); + _eval_dep_V(i,2) = (0)/2; + } + } + if (_is_var_V(idx)) { + _get_V_idxs(idx); + _apply_usage_alg_eq_1(_d1); + if ((i >= 1 && i <= 4)) { + _D(i,0) = 1-_H(i,0)-_R(i,0)-_I(i,0); + _D(i,1) = 0; + } + _apply_usage_eq_2(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_H(i,1) = _bhd(i)*_D(i,0)*(_H(i,0)+_R(i,0))+_ar(i)*_R(i,0)-_ghv(i)*_V(i,0)*_H(i,0)-_bhf(i)*_F(i,0)*_H(i,0); + _eval_dep_H(i,2) = (0)/2; + } + } + if (_is_var_V(idx)) { + _get_V_idxs(idx); + _apply_usage_eq_3(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_I(i,1) = _ghv(i)*_V(i,0)*_H(i,0)-_bie(i)*_E(i,0)*_I(i,0)-_ai(i)*_I(i,0); + _eval_dep_I(i,2) = (0)/2; + } + } + if (_is_var_V(idx)) { + _get_V_idxs(idx); + _apply_usage_eq_4(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_M(i,1) = (_bmd(i)*_D(i,0)+_bmv(i)*_V(i,0))*(1-_M(i,0))-_am(i)*_M(i,0); + _eval_dep_M(i,2) = (0)/2; + } + } + if (_is_var_V(idx)) { + _get_V_idxs(idx); + _apply_usage_eq_9(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_A(i,1) = _ba(i)*_P(i,0)-_gav(i)*_S(i,0)*_A(i,0)*_V(i,0)-_aa(i)*_A(i,0); + _eval_dep_A(i,2) = (0)/2; + } + } + if (_is_var_V(idx)) { + _get_V_idxs(idx); + for(_rg_d1 = 4; _rg_d1<=7; _rg_d1+=1) { + _get_Vpar_idxs(_rg_d1); + _apply_usage_alg_eq_2(_d1); + if ((i >= 1 && i <= 4)) { + _Vpar(i,0) = _V(i,0)*_tr(i)*_inside(i); + _Vpar(i,1) = 0; + } + } + for(_rg_d1 = 4; _rg_d1<=7; _rg_d1+=1) { + _get_Vpar_idxs(_rg_d1); + _apply_usage_alg_eq_2(_d1); + if ((i >= 1 && i <= 4)) { + _Vpar(i,0) = _V(i,0)*_tr(i)*_inside(i); + _Vpar(i,1) = 0; + } + } + _sum_0(1,0) = _Vpar(1,0); + _sum_0(1,1) = 0; + for(_rg_d1 = 9; _rg_d1<=11; _rg_d1+=1) { + _get_sum_0_idxs(_rg_d1); + _apply_usage_alg_eq_4(_d1); + if ((i >= 2 && i <= 4)) { + _sum_0(i,0) = _sum_0(i-1,0)+_Vpar(i,0); + _sum_0(i,1) = 0; + } + } + _eval_dep_Vr(1) = _sum_0(4,0)*100/(double)4-_cr*_Vr(0); + _eval_dep_Vr(2) = (0)/2; + } +} + +void MOD_BDF_definition(double *x, double *d, double *a, double t, double *dx, int *BDFMap, int nBDF) +{ + int idx; + int __bdf_it; + for(__bdf_it = 0; __bdf_it < nBDF; __bdf_it++) { + idx = BDFMap[__bdf_it]; + int _d1; + int _rg_d1; + int i; + switch(idx) { + case _eval_Vr(0): { + for(_rg_d1 = 4; _rg_d1<=7; _rg_d1+=1) { + _get_Vpar_idxs(_rg_d1); + _apply_usage_alg_eq_2(_d1); + if ((i >= 1 && i <= 4)) { + _Vpar(i,0) = _V(i,0)*_tr(i)*_inside(i); + + } + } + for(_rg_d1 = 4; _rg_d1<=7; _rg_d1+=1) { + _get_Vpar_idxs(_rg_d1); + _apply_usage_alg_eq_2(_d1); + if ((i >= 1 && i <= 4)) { + _Vpar(i,0) = _V(i,0)*_tr(i)*_inside(i); + + } + } + _sum_0(1,0) = _Vpar(1,0); + + for(_rg_d1 = 9; _rg_d1<=11; _rg_d1+=1) { + _get_sum_0_idxs(_rg_d1); + _apply_usage_alg_eq_4(_d1); + if ((i >= 2 && i <= 4)) { + _sum_0(i,0) = _sum_0(i-1,0)+_Vpar(i,0); + + } + } + _eval_dep_Vr(1) = _sum_0(4,0)*100/(double)4-_cr*_Vr(0); + + + continue; + } + } + if (_is_var_V(idx)) { + _get_V_idxs(idx); + _apply_usage_eq_1(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_V(i,1) = _gv(i)*_I(i,0)-_gva(i)*_S(i,0)*_A(i,0)*_V(i,0)-_gvh(i)*_H(i,0)*_V(i,0)-_av(i)*_V(i,0)-_av1(i)*_V(i,0)/(1+_av2(i)*_V(i,0))+_inside(i)*_re(i)*_Vr(0); + + + } + continue; + } + if (_is_var_H(idx)) { + _get_H_idxs(idx); + _apply_usage_alg_eq_1(_d1); + if ((i >= 1 && i <= 4)) { + _D(i,0) = 1-_H(i,0)-_R(i,0)-_I(i,0); + + } + _apply_usage_eq_2(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_H(i,1) = _bhd(i)*_D(i,0)*(_H(i,0)+_R(i,0))+_ar(i)*_R(i,0)-_ghv(i)*_V(i,0)*_H(i,0)-_bhf(i)*_F(i,0)*_H(i,0); + + + } + continue; + } + if (_is_var_I(idx)) { + _get_I_idxs(idx); + _apply_usage_eq_3(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_I(i,1) = _ghv(i)*_V(i,0)*_H(i,0)-_bie(i)*_E(i,0)*_I(i,0)-_ai(i)*_I(i,0); + + + } + continue; + } + if (_is_var_M(idx)) { + _get_M_idxs(idx); + _apply_usage_alg_eq_1(_d1); + if ((i >= 1 && i <= 4)) { + _D(i,0) = 1-_H(i,0)-_R(i,0)-_I(i,0); + + } + _apply_usage_eq_4(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_M(i,1) = (_bmd(i)*_D(i,0)+_bmv(i)*_V(i,0))*(1-_M(i,0))-_am(i)*_M(i,0); + + + } + continue; + } + if (_is_var_F(idx)) { + _get_F_idxs(idx); + _apply_usage_eq_5(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_F(i,1) = _bf(i)*_M(i,0)+_cf(i)*_I(i,0)-_bfh(i)*_H(i,0)*_F(i,0)-_af(i)*_F(i,0); + + + } + continue; + } + if (_is_var_R(idx)) { + _get_R_idxs(idx); + _apply_usage_eq_6(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_R(i,1) = _bhf(i)*_F(i,0)*_H(i,0)-_ar(i)*_R(i,0); + + + } + continue; + } + if (_is_var_E(idx)) { + _get_E_idxs(idx); + _apply_usage_eq_7(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_E(i,1) = _bem(i)*_M(i,0)*_E(i,0)-_bei(i)*_I(i,0)*_E(i,0)+_ae(i)*(1-_E(i,0)); + + + } + continue; + } + if (_is_var_P(idx)) { + _get_P_idxs(idx); + _apply_usage_eq_8(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_P(i,1) = _bpm(i)*_M(i,0)*_P(i,0)+_ap(i)*(1-_P(i,0)); + + + } + continue; + } + if (_is_var_A(idx)) { + _get_A_idxs(idx); + _apply_usage_eq_9(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_A(i,1) = _ba(i)*_P(i,0)-_gav(i)*_S(i,0)*_A(i,0)*_V(i,0)-_aa(i)*_A(i,0); + + + } + continue; + } + if (_is_var_S(idx)) { + _get_S_idxs(idx); + _apply_usage_eq_10(_d1); + if ((i >= 1 && i <= 4)) { + _eval_dep_S(i,1) = _r(i)*_P(i,0)*(1-_S(i,0)); + + + } + continue; + } + } +} + +void QSS_initializeDataStructs(QSS_simulator simulator) +{ + simulator->data = QSS_Data(41,16,12,0,12,11,4,"VIRplanoS"); + QSS_data modelData = simulator->data; + MODEL_DATA_ACCESS(modelData) + int* algebraics = (int*) malloc(12*sizeof(int)); + int* states = (int*) malloc(41*sizeof(int)); + int* discretes = (int*) malloc(16*sizeof(int)); + int* events = (int*) malloc(12*sizeof(int)); + int* outputs = (int*) malloc(4*sizeof(int)); + int row, eq_var, c_row; + int x_ind; + int _d1; + int _rg_d1; + int i; + for(_d1 = 1; _d1<=4; _d1+=1) { + _init_A(_d1,0) = 1; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + _init_E(_d1,0) = 1; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + _init_H(_d1,0) = 1; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + _init_P(_d1,0) = 1; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + _init_S(_d1,0) = 1.000000e-01; + } + _cr = 100; + _u = __math__rand(1); + for(i = 1; i<=4; i+=1) { + _gv(i) = 510; + _gva(i) = 6.192000e+02; + _gvh(i) = 1.020000e+00; + _av(i) = 1.700000e+00; + _av1(i) = 100; + _av2(i) = 23000; + _bhd(i) = 4; + _ar(i) = 1; + _ghv(i) = 3.400000e-01; + _bhf(i) = 1.000000e-02; + _bie(i) = 6.600000e-02; + _ai(i) = 1.500000e+00; + _bmd(i) = 1; + _bmv(i) = 3.700000e-03; + _am(i) = 1; + _bf(i) = 250000; + _cf(i) = 2000; + _bfh(i) = 17; + _af(i) = 8; + _bem(i) = 8.300000e+00; + _bei(i) = 2.720000e+00; + _ae(i) = 4.000000e-01; + _bpm(i) = 1.150000e+01; + _ap(i) = 4.000000e-01; + _ba(i) = 4.300000e-02; + _gav(i) = 1.462000e+02; + _aa(i) = 4.300000e-02; + _r(i) = 3.000000e-05; + } + for(i = 1; i<=2; i+=1) { + _re(i) = __math__rand(2.200000e-01)+1.800000e-01; + _tr(i) = _re(i); + } + for(i = 3; i<=4; i+=1) { + _re(i) = __math__rand(6.000000e-02)+4.000000e-02; + _tr(i) = _re(i); + } + _init_V(1,0) = 10; + _inside(1) = 1; + for(i = 1; i<=4; i+=1) { + _inst(i) = __math__rand(2); + _day(i) = 1000; + } + for(i = 1; i<=2; i+=1) { + _init_V(i,0) = 10; + _inside(i) = 1; + } + _Su = 4; + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_A(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_A(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_E(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_E(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_F(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_F(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_F(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_H(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_H(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_H(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_H(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_H(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_H(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_I(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_I(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_I(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_I(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_I(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_I(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_M(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_M(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_M(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_M(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_P(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_P(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_P(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_R(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_R(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_R(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_S(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_S(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_S(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_V(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_V(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_V(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_V(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_V(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_V(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSD[_idx_Vr(0)]++; + } + modelData->nSD[_idx_Vr(0)]++; + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_V(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_A(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_I(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_E(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_H(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_F(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_R(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_V(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_H(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_I(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_M(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_F(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_R(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_V(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_H(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_I(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_M(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_F(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_E(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_M(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_F(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_E(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_P(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_P(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_A(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_S(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_H(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_M(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_R(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_V(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_A(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_S(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_V(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_H(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_I(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_M(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_A(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_Vr(0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nDS[_idx_V(_d1,0)]++; + } + modelData->nDS[_idx_Vr(0)]++; + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_1_var_idxs(row, eq_var); + _get_V_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[0]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[0]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[0]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[0]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[0]->size[c_row]++; + } + modelData->jac_matrices->df_dx[0]->size[c_row]++; + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_alg_eq_1_var_idxs(row, eq_var); + _get_D_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->dg_dx[0]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->dg_dx[0]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->dg_dx[0]->size[c_row]++; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_2_var_idxs(row, eq_var); + _get_H_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4) && (1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[1]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4) && (1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[1]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4) && (1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[1]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[1]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[1]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[1]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[1]->size[c_row]++; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_3_var_idxs(row, eq_var); + _get_I_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[2]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[2]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[2]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[2]->size[c_row]++; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_4_var_idxs(row, eq_var); + _get_M_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4) && (1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[3]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4) && (1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[3]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4) && (1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[3]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[3]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[3]->size[c_row]++; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_5_var_idxs(row, eq_var); + _get_F_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[4]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[4]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[4]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[4]->size[c_row]++; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_6_var_idxs(row, eq_var); + _get_R_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[5]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[5]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[5]->size[c_row]++; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_7_var_idxs(row, eq_var); + _get_E_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[6]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[6]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[6]->size[c_row]++; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_8_var_idxs(row, eq_var); + _get_P_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[7]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[7]->size[c_row]++; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_9_var_idxs(row, eq_var); + _get_A_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[8]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[8]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[8]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[8]->size[c_row]++; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_10_var_idxs(row, eq_var); + _get_S_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[9]->size[c_row]++; + } + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[9]->size[c_row]++; + } + } + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_alg_eq_2_var_idxs(row, eq_var); + _get_Vpar_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->dg_dx[1]->size[c_row]++; + } + } + for(row = 1; row <= 1; row++) { + c_row = _c_index(row); + modelData->jac_matrices->dg_dx[2]->size[c_row]++; + } + for(row = 1; row <= 3; row++) { + c_row = _c_index(row); + _get_alg_eq_4_var_idxs(row, eq_var); + _get_sum_0_idxs(eq_var); + if((2 <= _d1 && _d1 <= 4) && (2 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->dg_dx[3]->size[c_row]++; + } + } + for(row = 1; row <= 1; row++) { + c_row = _c_index(row); + modelData->jac_matrices->df_dx[10]->size[c_row]++; + for(i = 2; i<=4; i+=1) { + _get_alg_eq_4_var_idxs(_idx_sum_0(i,0), eq_var); + _get_sum_0_idxs(eq_var); + if((2 <= _d1 && _d1 <= 4)) { + modelData->jac_matrices->df_dx[10]->size[c_row]++; + } + } modelData->jac_matrices->df_dx[10]->size[c_row]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nSZ[_idx_V(_d1,0)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nZS[_idx_event_2(_d1)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nHZ[_idx_event_1(_d1)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nHZ[_idx_event_2(_d1)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->nHD[_idx_event_1(_d1)]++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->event[_idx_event_2(_d1)].nLHSDsc++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->event[_idx_event_2(_d1)].nLHSDsc++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->event[_idx_event_3(_d1)].nLHSDsc++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->event[_idx_event_3(_d1)].nLHSDsc++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->event[_idx_event_2(_d1)].nLHSDsc++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->event[_idx_event_1(_d1)].nLHSDsc++; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->event[_idx_event_1(_d1)].nLHSDsc++; + } + QSS_allocDataMatrix(modelData); + cleanVector(states, 0, 41); + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_A(_d1,0)][states[_idx_A(_d1,0)]++] = _idx_V(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_A(_d1,0)][states[_idx_A(_d1,0)]++] = _idx_A(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_E(_d1,0)][states[_idx_E(_d1,0)]++] = _idx_I(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_E(_d1,0)][states[_idx_E(_d1,0)]++] = _idx_E(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_F(_d1,0)][states[_idx_F(_d1,0)]++] = _idx_H(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_F(_d1,0)][states[_idx_F(_d1,0)]++] = _idx_F(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_F(_d1,0)][states[_idx_F(_d1,0)]++] = _idx_R(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_H(_d1,0)][states[_idx_H(_d1,0)]++] = _idx_V(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_H(_d1,0)][states[_idx_H(_d1,0)]++] = _idx_H(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_H(_d1,0)][states[_idx_H(_d1,0)]++] = _idx_I(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_H(_d1,0)][states[_idx_H(_d1,0)]++] = _idx_M(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_H(_d1,0)][states[_idx_H(_d1,0)]++] = _idx_F(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_H(_d1,0)][states[_idx_H(_d1,0)]++] = _idx_R(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_I(_d1,0)][states[_idx_I(_d1,0)]++] = _idx_V(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_I(_d1,0)][states[_idx_I(_d1,0)]++] = _idx_H(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_I(_d1,0)][states[_idx_I(_d1,0)]++] = _idx_I(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_I(_d1,0)][states[_idx_I(_d1,0)]++] = _idx_M(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_I(_d1,0)][states[_idx_I(_d1,0)]++] = _idx_F(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_I(_d1,0)][states[_idx_I(_d1,0)]++] = _idx_E(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_M(_d1,0)][states[_idx_M(_d1,0)]++] = _idx_M(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_M(_d1,0)][states[_idx_M(_d1,0)]++] = _idx_F(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_M(_d1,0)][states[_idx_M(_d1,0)]++] = _idx_E(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_M(_d1,0)][states[_idx_M(_d1,0)]++] = _idx_P(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_P(_d1,0)][states[_idx_P(_d1,0)]++] = _idx_P(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_P(_d1,0)][states[_idx_P(_d1,0)]++] = _idx_A(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_P(_d1,0)][states[_idx_P(_d1,0)]++] = _idx_S(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_R(_d1,0)][states[_idx_R(_d1,0)]++] = _idx_H(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_R(_d1,0)][states[_idx_R(_d1,0)]++] = _idx_M(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_R(_d1,0)][states[_idx_R(_d1,0)]++] = _idx_R(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_S(_d1,0)][states[_idx_S(_d1,0)]++] = _idx_V(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_S(_d1,0)][states[_idx_S(_d1,0)]++] = _idx_A(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_S(_d1,0)][states[_idx_S(_d1,0)]++] = _idx_S(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_V(_d1,0)][states[_idx_V(_d1,0)]++] = _idx_V(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_V(_d1,0)][states[_idx_V(_d1,0)]++] = _idx_H(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_V(_d1,0)][states[_idx_V(_d1,0)]++] = _idx_I(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_V(_d1,0)][states[_idx_V(_d1,0)]++] = _idx_M(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_V(_d1,0)][states[_idx_V(_d1,0)]++] = _idx_A(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_V(_d1,0)][states[_idx_V(_d1,0)]++] = _idx_Vr(0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SD[_idx_Vr(0)][states[_idx_Vr(0)]++] = _idx_V(_d1,0); + } + modelData->SD[_idx_Vr(0)][states[_idx_Vr(0)]++] = _idx_Vr(0); + cleanVector(states, 0, 41); + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_V(_d1,0)][states[_idx_V(_d1,0)]++] = _idx_A(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_A(_d1,0)][states[_idx_A(_d1,0)]++] = _idx_A(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_I(_d1,0)][states[_idx_I(_d1,0)]++] = _idx_E(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_E(_d1,0)][states[_idx_E(_d1,0)]++] = _idx_E(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_H(_d1,0)][states[_idx_H(_d1,0)]++] = _idx_F(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_F(_d1,0)][states[_idx_F(_d1,0)]++] = _idx_F(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_R(_d1,0)][states[_idx_R(_d1,0)]++] = _idx_F(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_V(_d1,0)][states[_idx_V(_d1,0)]++] = _idx_H(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_H(_d1,0)][states[_idx_H(_d1,0)]++] = _idx_H(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_I(_d1,0)][states[_idx_I(_d1,0)]++] = _idx_H(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_M(_d1,0)][states[_idx_M(_d1,0)]++] = _idx_H(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_F(_d1,0)][states[_idx_F(_d1,0)]++] = _idx_H(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_R(_d1,0)][states[_idx_R(_d1,0)]++] = _idx_H(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_V(_d1,0)][states[_idx_V(_d1,0)]++] = _idx_I(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_H(_d1,0)][states[_idx_H(_d1,0)]++] = _idx_I(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_I(_d1,0)][states[_idx_I(_d1,0)]++] = _idx_I(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_M(_d1,0)][states[_idx_M(_d1,0)]++] = _idx_I(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_F(_d1,0)][states[_idx_F(_d1,0)]++] = _idx_I(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_E(_d1,0)][states[_idx_E(_d1,0)]++] = _idx_I(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_M(_d1,0)][states[_idx_M(_d1,0)]++] = _idx_M(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_F(_d1,0)][states[_idx_F(_d1,0)]++] = _idx_M(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_E(_d1,0)][states[_idx_E(_d1,0)]++] = _idx_M(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_P(_d1,0)][states[_idx_P(_d1,0)]++] = _idx_M(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_P(_d1,0)][states[_idx_P(_d1,0)]++] = _idx_P(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_A(_d1,0)][states[_idx_A(_d1,0)]++] = _idx_P(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_S(_d1,0)][states[_idx_S(_d1,0)]++] = _idx_P(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_H(_d1,0)][states[_idx_H(_d1,0)]++] = _idx_R(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_M(_d1,0)][states[_idx_M(_d1,0)]++] = _idx_R(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_R(_d1,0)][states[_idx_R(_d1,0)]++] = _idx_R(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_V(_d1,0)][states[_idx_V(_d1,0)]++] = _idx_S(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_A(_d1,0)][states[_idx_A(_d1,0)]++] = _idx_S(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_S(_d1,0)][states[_idx_S(_d1,0)]++] = _idx_S(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_V(_d1,0)][states[_idx_V(_d1,0)]++] = _idx_V(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_H(_d1,0)][states[_idx_H(_d1,0)]++] = _idx_V(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_I(_d1,0)][states[_idx_I(_d1,0)]++] = _idx_V(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_M(_d1,0)][states[_idx_M(_d1,0)]++] = _idx_V(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_A(_d1,0)][states[_idx_A(_d1,0)]++] = _idx_V(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_Vr(0)][states[_idx_Vr(0)]++] = _idx_V(_d1,0); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->DS[_idx_V(_d1,0)][states[_idx_V(_d1,0)]++] = _idx_Vr(0); + } + modelData->DS[_idx_Vr(0)][states[_idx_Vr(0)]++] = _idx_Vr(0); + cleanVector(states, 0, 41); + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_1_var_idxs(row, eq_var); + _get_V_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_A(_d1,0); + if(in(modelData->jac_matrices->df_dx[0]->index[c_row],modelData->jac_matrices->df_dx[0]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[0]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[0]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_H(_d1,0); + if(in(modelData->jac_matrices->df_dx[0]->index[c_row],modelData->jac_matrices->df_dx[0]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[0]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[0]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_I(_d1,0); + if(in(modelData->jac_matrices->df_dx[0]->index[c_row],modelData->jac_matrices->df_dx[0]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[0]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[0]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_S(_d1,0); + if(in(modelData->jac_matrices->df_dx[0]->index[c_row],modelData->jac_matrices->df_dx[0]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[0]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[0]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_V(_d1,0); + if(in(modelData->jac_matrices->df_dx[0]->index[c_row],modelData->jac_matrices->df_dx[0]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[0]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[0]->index[c_row][states[c_row]++] = x_ind; + } + } + x_ind = _idx_Vr(0); + if(in(modelData->jac_matrices->df_dx[0]->index[c_row],modelData->jac_matrices->df_dx[0]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[0]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[0]->index[c_row][states[c_row]++] = x_ind; + } + } + cleanVector(algebraics, 0, 12); + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_alg_eq_1_var_idxs(row, eq_var); + _get_D_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_H(_d1,0); + if(in(modelData->jac_matrices->dg_dx[0]->index[c_row],modelData->jac_matrices->dg_dx[0]->size[c_row], x_ind)){ + modelData->jac_matrices->dg_dx[0]->size[c_row]--; + } else { + modelData->jac_matrices->dg_dx[0]->index[c_row][algebraics[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_I(_d1,0); + if(in(modelData->jac_matrices->dg_dx[0]->index[c_row],modelData->jac_matrices->dg_dx[0]->size[c_row], x_ind)){ + modelData->jac_matrices->dg_dx[0]->size[c_row]--; + } else { + modelData->jac_matrices->dg_dx[0]->index[c_row][algebraics[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_R(_d1,0); + if(in(modelData->jac_matrices->dg_dx[0]->index[c_row],modelData->jac_matrices->dg_dx[0]->size[c_row], x_ind)){ + modelData->jac_matrices->dg_dx[0]->size[c_row]--; + } else { + modelData->jac_matrices->dg_dx[0]->index[c_row][algebraics[c_row]++] = x_ind; + } + } + } + cleanVector(states, 0, 41); + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_2_var_idxs(row, eq_var); + _get_H_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4) && (1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_H(_d1,0); + if(in(modelData->jac_matrices->df_dx[1]->index[c_row],modelData->jac_matrices->df_dx[1]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[1]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[1]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4) && (1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_I(_d1,0); + if(in(modelData->jac_matrices->df_dx[1]->index[c_row],modelData->jac_matrices->df_dx[1]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[1]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[1]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4) && (1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_R(_d1,0); + if(in(modelData->jac_matrices->df_dx[1]->index[c_row],modelData->jac_matrices->df_dx[1]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[1]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[1]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_F(_d1,0); + if(in(modelData->jac_matrices->df_dx[1]->index[c_row],modelData->jac_matrices->df_dx[1]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[1]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[1]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_H(_d1,0); + if(in(modelData->jac_matrices->df_dx[1]->index[c_row],modelData->jac_matrices->df_dx[1]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[1]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[1]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_R(_d1,0); + if(in(modelData->jac_matrices->df_dx[1]->index[c_row],modelData->jac_matrices->df_dx[1]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[1]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[1]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_V(_d1,0); + if(in(modelData->jac_matrices->df_dx[1]->index[c_row],modelData->jac_matrices->df_dx[1]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[1]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[1]->index[c_row][states[c_row]++] = x_ind; + } + } + } + cleanVector(states, 0, 41); + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_3_var_idxs(row, eq_var); + _get_I_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_E(_d1,0); + if(in(modelData->jac_matrices->df_dx[2]->index[c_row],modelData->jac_matrices->df_dx[2]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[2]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[2]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_H(_d1,0); + if(in(modelData->jac_matrices->df_dx[2]->index[c_row],modelData->jac_matrices->df_dx[2]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[2]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[2]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_I(_d1,0); + if(in(modelData->jac_matrices->df_dx[2]->index[c_row],modelData->jac_matrices->df_dx[2]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[2]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[2]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_V(_d1,0); + if(in(modelData->jac_matrices->df_dx[2]->index[c_row],modelData->jac_matrices->df_dx[2]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[2]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[2]->index[c_row][states[c_row]++] = x_ind; + } + } + } + cleanVector(states, 0, 41); + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_4_var_idxs(row, eq_var); + _get_M_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4) && (1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_H(_d1,0); + if(in(modelData->jac_matrices->df_dx[3]->index[c_row],modelData->jac_matrices->df_dx[3]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[3]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[3]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4) && (1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_I(_d1,0); + if(in(modelData->jac_matrices->df_dx[3]->index[c_row],modelData->jac_matrices->df_dx[3]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[3]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[3]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4) && (1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_R(_d1,0); + if(in(modelData->jac_matrices->df_dx[3]->index[c_row],modelData->jac_matrices->df_dx[3]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[3]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[3]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_M(_d1,0); + if(in(modelData->jac_matrices->df_dx[3]->index[c_row],modelData->jac_matrices->df_dx[3]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[3]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[3]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_V(_d1,0); + if(in(modelData->jac_matrices->df_dx[3]->index[c_row],modelData->jac_matrices->df_dx[3]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[3]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[3]->index[c_row][states[c_row]++] = x_ind; + } + } + } + cleanVector(states, 0, 41); + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_5_var_idxs(row, eq_var); + _get_F_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_F(_d1,0); + if(in(modelData->jac_matrices->df_dx[4]->index[c_row],modelData->jac_matrices->df_dx[4]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[4]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[4]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_H(_d1,0); + if(in(modelData->jac_matrices->df_dx[4]->index[c_row],modelData->jac_matrices->df_dx[4]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[4]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[4]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_I(_d1,0); + if(in(modelData->jac_matrices->df_dx[4]->index[c_row],modelData->jac_matrices->df_dx[4]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[4]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[4]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_M(_d1,0); + if(in(modelData->jac_matrices->df_dx[4]->index[c_row],modelData->jac_matrices->df_dx[4]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[4]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[4]->index[c_row][states[c_row]++] = x_ind; + } + } + } + cleanVector(states, 0, 41); + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_6_var_idxs(row, eq_var); + _get_R_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_F(_d1,0); + if(in(modelData->jac_matrices->df_dx[5]->index[c_row],modelData->jac_matrices->df_dx[5]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[5]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[5]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_H(_d1,0); + if(in(modelData->jac_matrices->df_dx[5]->index[c_row],modelData->jac_matrices->df_dx[5]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[5]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[5]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_R(_d1,0); + if(in(modelData->jac_matrices->df_dx[5]->index[c_row],modelData->jac_matrices->df_dx[5]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[5]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[5]->index[c_row][states[c_row]++] = x_ind; + } + } + } + cleanVector(states, 0, 41); + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_7_var_idxs(row, eq_var); + _get_E_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_E(_d1,0); + if(in(modelData->jac_matrices->df_dx[6]->index[c_row],modelData->jac_matrices->df_dx[6]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[6]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[6]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_I(_d1,0); + if(in(modelData->jac_matrices->df_dx[6]->index[c_row],modelData->jac_matrices->df_dx[6]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[6]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[6]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_M(_d1,0); + if(in(modelData->jac_matrices->df_dx[6]->index[c_row],modelData->jac_matrices->df_dx[6]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[6]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[6]->index[c_row][states[c_row]++] = x_ind; + } + } + } + cleanVector(states, 0, 41); + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_8_var_idxs(row, eq_var); + _get_P_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_M(_d1,0); + if(in(modelData->jac_matrices->df_dx[7]->index[c_row],modelData->jac_matrices->df_dx[7]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[7]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[7]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_P(_d1,0); + if(in(modelData->jac_matrices->df_dx[7]->index[c_row],modelData->jac_matrices->df_dx[7]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[7]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[7]->index[c_row][states[c_row]++] = x_ind; + } + } + } + cleanVector(states, 0, 41); + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_9_var_idxs(row, eq_var); + _get_A_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_A(_d1,0); + if(in(modelData->jac_matrices->df_dx[8]->index[c_row],modelData->jac_matrices->df_dx[8]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[8]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[8]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_P(_d1,0); + if(in(modelData->jac_matrices->df_dx[8]->index[c_row],modelData->jac_matrices->df_dx[8]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[8]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[8]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_S(_d1,0); + if(in(modelData->jac_matrices->df_dx[8]->index[c_row],modelData->jac_matrices->df_dx[8]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[8]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[8]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_V(_d1,0); + if(in(modelData->jac_matrices->df_dx[8]->index[c_row],modelData->jac_matrices->df_dx[8]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[8]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[8]->index[c_row][states[c_row]++] = x_ind; + } + } + } + cleanVector(states, 0, 41); + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_eq_10_var_idxs(row, eq_var); + _get_S_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_P(_d1,0); + if(in(modelData->jac_matrices->df_dx[9]->index[c_row],modelData->jac_matrices->df_dx[9]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[9]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[9]->index[c_row][states[c_row]++] = x_ind; + } + } + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_S(_d1,0); + if(in(modelData->jac_matrices->df_dx[9]->index[c_row],modelData->jac_matrices->df_dx[9]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[9]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[9]->index[c_row][states[c_row]++] = x_ind; + } + } + } + cleanVector(algebraics, 0, 12); + for(row = 1; row <= 4; row++) { + c_row = _c_index(row); + _get_alg_eq_2_var_idxs(row, eq_var); + _get_Vpar_idxs(eq_var); + if((1 <= _d1 && _d1 <= 4)) { + x_ind = _idx_V(_d1,0); + if(in(modelData->jac_matrices->dg_dx[1]->index[c_row],modelData->jac_matrices->dg_dx[1]->size[c_row], x_ind)){ + modelData->jac_matrices->dg_dx[1]->size[c_row]--; + } else { + modelData->jac_matrices->dg_dx[1]->index[c_row][algebraics[c_row]++] = x_ind; + } + } + } + cleanVector(algebraics, 0, 12); + for(row = 1; row <= 1; row++) { + c_row = _c_index(row); + x_ind = _idx_V(1,0); + if(in(modelData->jac_matrices->dg_dx[2]->index[c_row],modelData->jac_matrices->dg_dx[2]->size[c_row], x_ind)){ + modelData->jac_matrices->dg_dx[2]->size[c_row]--; + } else { + modelData->jac_matrices->dg_dx[2]->index[c_row][algebraics[c_row]++] = x_ind; + } + } + cleanVector(algebraics, 0, 12); + for(row = 1; row <= 3; row++) { + c_row = _c_index(row); + _get_alg_eq_4_var_idxs(row, eq_var); + _get_sum_0_idxs(eq_var); + if((2 <= _d1 && _d1 <= 4) && (2 <= _d1 && _d1 <= 4)) { + x_ind = _idx_V(_d1,0); + if(in(modelData->jac_matrices->dg_dx[3]->index[c_row],modelData->jac_matrices->dg_dx[3]->size[c_row], x_ind)){ + modelData->jac_matrices->dg_dx[3]->size[c_row]--; + } else { + modelData->jac_matrices->dg_dx[3]->index[c_row][algebraics[c_row]++] = x_ind; + } + } + } + cleanVector(states, 0, 41); + for(row = 1; row <= 1; row++) { + c_row = _c_index(row); + x_ind = _idx_V(1,0); + if(in(modelData->jac_matrices->df_dx[10]->index[c_row],modelData->jac_matrices->df_dx[10]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[10]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[10]->index[c_row][states[c_row]++] = x_ind; + } + for(i = 2; i<=4; i+=1) { + _get_alg_eq_4_var_idxs(_idx_sum_0(i,0), eq_var); + _get_sum_0_idxs(eq_var); + if((2 <= _d1 && _d1 <= 4)) { + x_ind = _idx_V(_d1,0); + if(in(modelData->jac_matrices->df_dx[10]->index[c_row],modelData->jac_matrices->df_dx[10]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[10]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[10]->index[c_row][states[c_row]++] = x_ind; + } + } + } x_ind = _idx_Vr(0); + if(in(modelData->jac_matrices->df_dx[10]->index[c_row],modelData->jac_matrices->df_dx[10]->size[c_row], x_ind)){ + modelData->jac_matrices->df_dx[10]->size[c_row]--; + } else { + modelData->jac_matrices->df_dx[10]->index[c_row][states[c_row]++] = x_ind; + } + } + cleanVector(states, 0, 41); + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->SZ[_idx_V(_d1,0)][states[_idx_V(_d1,0)]++] = _idx_event_2(_d1); + } + cleanVector(events, 0, 12); + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->ZS[_idx_event_2(_d1)][events[_idx_event_2(_d1)]++] = _idx_V(_d1,0); + } + cleanVector(events, 0, 12); + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->HZ[_idx_event_1(_d1)][events[_idx_event_1(_d1)]++] = _idx_event_1(_d1); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->HZ[_idx_event_2(_d1)][events[_idx_event_2(_d1)]++] = _idx_event_3(_d1); + } + cleanVector(events, 0, 12); + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->HD[_idx_event_1(_d1)][events[_idx_event_1(_d1)]++] = _idx_V(_d1,0); + } + cleanVector(events, 0, 12); + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->event[_idx_event_2(_d1)].LHSDsc[events[_idx_event_2(_d1)]++] = _idx_day(_d1); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->event[_idx_event_2(_d1)].LHSDsc[events[_idx_event_2(_d1)]++] = _idx_In1; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->event[_idx_event_3(_d1)].LHSDsc[events[_idx_event_3(_d1)]++] = _idx_In1; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->event[_idx_event_3(_d1)].LHSDsc[events[_idx_event_3(_d1)]++] = _idx_Rec; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->event[_idx_event_2(_d1)].LHSDsc[events[_idx_event_2(_d1)]++] = _idx_Su; + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->event[_idx_event_1(_d1)].LHSDsc[events[_idx_event_1(_d1)]++] = _idx_inside(_d1); + } + for(_d1 = 1; _d1<=4; _d1+=1) { + modelData->event[_idx_event_1(_d1)].LHSDsc[events[_idx_event_1(_d1)]++] = _idx_inst(_d1); + } + for(i = 1; i<=4; i+=1) { + modelData->event[_idx_event_1(i)].direction = 1; + modelData->event[_idx_event_1(i)].relation = 2; + } + for(i = 1; i<=4; i+=1) { + modelData->event[_idx_event_2(i)].direction = 1; + modelData->event[_idx_event_2(i)].relation = 2; + } + for(i = 1; i<=4; i+=1) { + modelData->event[_idx_event_3(i)].direction = 1; + modelData->event[_idx_event_3(i)].relation = 2; + } + SD_setupJacMatrices(modelData->jac_matrices); + simulator->time = QSS_Time(41,12,0,0,ST_Binary, NULL); + double period[1]; + period[0] = 0.01; + simulator->output = SD_Output("VIRplanoS",4,16,41,period,1,0,CI_Sampled,SD_Memory,MOD_output); + SD_output modelOutput = simulator->output; + modelOutput->nOS[_idx_out_exp_4]++; + modelOutput->nOD[_idx_out_exp_1]++; + modelOutput->nOD[_idx_out_exp_2]++; + modelOutput->nOD[_idx_out_exp_3]++; + modelOutput->nSO[_idx_Vr(0)]++; + modelOutput->nDO[_idx_In1]++; + modelOutput->nDO[_idx_Rec]++; + modelOutput->nDO[_idx_Su]++; + SD_allocOutputMatrix(modelOutput, 41, 16); + sprintf(modelOutput->variable[_idx_out_exp_1].name, "In1"); + sprintf(modelOutput->variable[_idx_out_exp_2].name, "Rec"); + sprintf(modelOutput->variable[_idx_out_exp_3].name, "Su"); + sprintf(modelOutput->variable[_idx_out_exp_4].name, "Vr"); + cleanVector(outputs, 0, 4); + modelOutput->OS[_idx_out_exp_4][outputs[_idx_out_exp_4]++] = _idx_Vr(0); + cleanVector(outputs, 0, 4); + modelOutput->OD[_idx_out_exp_1][outputs[_idx_out_exp_1]++] = _idx_In1; + modelOutput->OD[_idx_out_exp_2][outputs[_idx_out_exp_2]++] = _idx_Rec; + modelOutput->OD[_idx_out_exp_3][outputs[_idx_out_exp_3]++] = _idx_Su; + cleanVector(states, 0, 41); + modelOutput->SO[_idx_Vr(0)][states[_idx_Vr(0)]++] = _idx_out_exp_4; + cleanVector(discretes, 0, 16); + modelOutput->DO[_idx_In1][discretes[_idx_In1]++] = _idx_out_exp_1; + modelOutput->DO[_idx_Rec][discretes[_idx_Rec]++] = _idx_out_exp_2; + modelOutput->DO[_idx_Su][discretes[_idx_Su]++] = _idx_out_exp_3; + simulator->model = QSS_Model(MOD_definition, MOD_dependencies, MOD_zeroCrossing, MOD_handlerPos, MOD_handlerNeg, MOD_jacobian, MOD_BDF_definition); + free(algebraics); + free(states); + free(discretes); + free(events); + free(outputs); +} + +void CLC_initializeDataStructs(CLC_simulator simulator) +{ +} + diff --git a/src/mmoc/tests/system/gt_data/VIRplanoS/VIRplanoS.h b/src/mmoc/tests/system/gt_data/VIRplanoS/VIRplanoS.h new file mode 100644 index 00000000..56608dac --- /dev/null +++ b/src/mmoc/tests/system/gt_data/VIRplanoS/VIRplanoS.h @@ -0,0 +1,577 @@ +// Model data access macro. + +#define MODEL_DATA_ACCESS(m) \ + double* x = m->x; \ + double* d = m->d; \ + double* a = m->alg; + +// Coeff multipliers definition. + +#define COEFF_MULTIPLIER(c) COEFF_MULTIPLIER_##c +#define COEFF_MULTIPLIER_0 1 +#define COEFF_MULTIPLIER_1 1 +#define COEFF_MULTIPLIER_2 2 + +// Model Variables Macros + +// Macros definition for variable: A +#define _idx_A(d1,coeff) (32+(d1-1)) +#define _state_idx_A(d1,coeff) (32+(d1-1))*3 + coeff +#define _A(d1,coeff) x[_state_idx_A(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _init_A(d1,coeff) x[_state_idx_A(d1,coeff)] +#define _q_A(d1,coeff) q[_state_idx_A(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _eval_A(d1,coeff) (32+(d1-1)) +#define _is_var_A(idx) idx >= 32 && idx < 36 +#define _get_A_idxs(idx)\ + _d1 = (idx-32)+ 1; +#define _eval_dep_A(d1,coeff) dx[_state_idx_A(d1,coeff)] + +// Macros definition for variable: D +#define _idx_D(d1,coeff) ((d1-1)) +#define _state_idx_D(d1,coeff) ((d1-1))*3 + coeff +#define _D(d1,coeff) a[_state_idx_D(d1,coeff)] +#define _is_var_D(idx) idx >= 0 && idx < 4 +#define _get_D_idxs(idx)\ + _d1 = (idx)+ 1; + +// Macros definition for variable: E +#define _idx_E(d1,coeff) (24+(d1-1)) +#define _state_idx_E(d1,coeff) (24+(d1-1))*3 + coeff +#define _E(d1,coeff) x[_state_idx_E(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _init_E(d1,coeff) x[_state_idx_E(d1,coeff)] +#define _q_E(d1,coeff) q[_state_idx_E(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _eval_E(d1,coeff) (24+(d1-1)) +#define _is_var_E(idx) idx >= 24 && idx < 28 +#define _get_E_idxs(idx)\ + _d1 = (idx-24)+ 1; +#define _eval_dep_E(d1,coeff) dx[_state_idx_E(d1,coeff)] + +// Macros definition for variable: F +#define _idx_F(d1,coeff) (16+(d1-1)) +#define _state_idx_F(d1,coeff) (16+(d1-1))*3 + coeff +#define _F(d1,coeff) x[_state_idx_F(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _init_F(d1,coeff) x[_state_idx_F(d1,coeff)] +#define _q_F(d1,coeff) q[_state_idx_F(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _eval_F(d1,coeff) (16+(d1-1)) +#define _is_var_F(idx) idx >= 16 && idx < 20 +#define _get_F_idxs(idx)\ + _d1 = (idx-16)+ 1; +#define _eval_dep_F(d1,coeff) dx[_state_idx_F(d1,coeff)] + +// Macros definition for variable: H +#define _idx_H(d1,coeff) (4+(d1-1)) +#define _state_idx_H(d1,coeff) (4+(d1-1))*3 + coeff +#define _H(d1,coeff) x[_state_idx_H(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _init_H(d1,coeff) x[_state_idx_H(d1,coeff)] +#define _q_H(d1,coeff) q[_state_idx_H(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _eval_H(d1,coeff) (4+(d1-1)) +#define _is_var_H(idx) idx >= 4 && idx < 8 +#define _get_H_idxs(idx)\ + _d1 = (idx-4)+ 1; +#define _eval_dep_H(d1,coeff) dx[_state_idx_H(d1,coeff)] + +// Macros definition for variable: I +#define _idx_I(d1,coeff) (8+(d1-1)) +#define _state_idx_I(d1,coeff) (8+(d1-1))*3 + coeff +#define _I(d1,coeff) x[_state_idx_I(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _init_I(d1,coeff) x[_state_idx_I(d1,coeff)] +#define _q_I(d1,coeff) q[_state_idx_I(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _eval_I(d1,coeff) (8+(d1-1)) +#define _is_var_I(idx) idx >= 8 && idx < 12 +#define _get_I_idxs(idx)\ + _d1 = (idx-8)+ 1; +#define _eval_dep_I(d1,coeff) dx[_state_idx_I(d1,coeff)] + +// Macros definition for variable: In1 +#define _idx_In1 9 +#define _In1 d[_idx_In1] + +// Macros definition for variable: M +#define _idx_M(d1,coeff) (12+(d1-1)) +#define _state_idx_M(d1,coeff) (12+(d1-1))*3 + coeff +#define _M(d1,coeff) x[_state_idx_M(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _init_M(d1,coeff) x[_state_idx_M(d1,coeff)] +#define _q_M(d1,coeff) q[_state_idx_M(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _eval_M(d1,coeff) (12+(d1-1)) +#define _is_var_M(idx) idx >= 12 && idx < 16 +#define _get_M_idxs(idx)\ + _d1 = (idx-12)+ 1; +#define _eval_dep_M(d1,coeff) dx[_state_idx_M(d1,coeff)] + +// Macros definition for variable: P +#define _idx_P(d1,coeff) (28+(d1-1)) +#define _state_idx_P(d1,coeff) (28+(d1-1))*3 + coeff +#define _P(d1,coeff) x[_state_idx_P(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _init_P(d1,coeff) x[_state_idx_P(d1,coeff)] +#define _q_P(d1,coeff) q[_state_idx_P(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _eval_P(d1,coeff) (28+(d1-1)) +#define _is_var_P(idx) idx >= 28 && idx < 32 +#define _get_P_idxs(idx)\ + _d1 = (idx-28)+ 1; +#define _eval_dep_P(d1,coeff) dx[_state_idx_P(d1,coeff)] + +// Macros definition for variable: R +#define _idx_R(d1,coeff) (20+(d1-1)) +#define _state_idx_R(d1,coeff) (20+(d1-1))*3 + coeff +#define _R(d1,coeff) x[_state_idx_R(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _init_R(d1,coeff) x[_state_idx_R(d1,coeff)] +#define _q_R(d1,coeff) q[_state_idx_R(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _eval_R(d1,coeff) (20+(d1-1)) +#define _is_var_R(idx) idx >= 20 && idx < 24 +#define _get_R_idxs(idx)\ + _d1 = (idx-20)+ 1; +#define _eval_dep_R(d1,coeff) dx[_state_idx_R(d1,coeff)] + +// Macros definition for variable: Rec +#define _idx_Rec 10 +#define _Rec d[_idx_Rec] + +// Macros definition for variable: S +#define _idx_S(d1,coeff) (36+(d1-1)) +#define _state_idx_S(d1,coeff) (36+(d1-1))*3 + coeff +#define _S(d1,coeff) x[_state_idx_S(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _init_S(d1,coeff) x[_state_idx_S(d1,coeff)] +#define _q_S(d1,coeff) q[_state_idx_S(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _eval_S(d1,coeff) (36+(d1-1)) +#define _is_var_S(idx) idx >= 36 && idx < 40 +#define _get_S_idxs(idx)\ + _d1 = (idx-36)+ 1; +#define _eval_dep_S(d1,coeff) dx[_state_idx_S(d1,coeff)] + +// Macros definition for variable: Su +#define _idx_Su 8 +#define _Su d[_idx_Su] + +// Macros definition for variable: V +#define _idx_V(d1,coeff) ((d1-1)) +#define _state_idx_V(d1,coeff) ((d1-1))*3 + coeff +#define _V(d1,coeff) x[_state_idx_V(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _init_V(d1,coeff) x[_state_idx_V(d1,coeff)] +#define _q_V(d1,coeff) q[_state_idx_V(d1,coeff)] * COEFF_MULTIPLIER(coeff) +#define _eval_V(d1,coeff) ((d1-1)) +#define _is_var_V(idx) idx >= 0 && idx < 4 +#define _get_V_idxs(idx)\ + _d1 = (idx)+ 1; +#define _eval_dep_V(d1,coeff) dx[_state_idx_V(d1,coeff)] + +// Macros definition for variable: Vpar +#define _idx_Vpar(d1,coeff) (4+(d1-1)) +#define _state_idx_Vpar(d1,coeff) (4+(d1-1))*3 + coeff +#define _Vpar(d1,coeff) a[_state_idx_Vpar(d1,coeff)] +#define _is_var_Vpar(idx) idx >= 4 && idx < 8 +#define _get_Vpar_idxs(idx)\ + _d1 = (idx-4)+ 1; + +// Macros definition for variable: Vr +#define _idx_Vr(coeff) 40 +#define _state_idx_Vr(coeff) 40*3 + coeff +#define _Vr(coeff) x[_state_idx_Vr(coeff)] * COEFF_MULTIPLIER(coeff) +#define _init_Vr(coeff) x[_state_idx_Vr(coeff)] +#define _q_Vr(coeff) q[_state_idx_Vr(coeff)] * COEFF_MULTIPLIER(coeff) +#define _eval_Vr(coeff) 40 +#define _eval_dep_Vr(coeff) dx[_state_idx_Vr(coeff)] + +// Macros definition for variable: _event_1 +#define _idx_event_1(d1) ((d1-1)) +#define _eval_event_1(d1) ((d1-1)) +#define _is_var_event_1(idx) idx >= 0 && idx < 4 +#define _get_event_1_idxs(idx)\ + _d1 = (idx)+ 1; + +// Macros definition for variable: _event_2 +#define _idx_event_2(d1) (4+(d1-1)) +#define _eval_event_2(d1) (4+(d1-1)) +#define _is_var_event_2(idx) idx >= 4 && idx < 8 +#define _get_event_2_idxs(idx)\ + _d1 = (idx-4)+ 1; + +// Macros definition for variable: _event_3 +#define _idx_event_3(d1) (8+(d1-1)) +#define _eval_event_3(d1) (8+(d1-1)) +#define _is_var_event_3(idx) idx >= 8 && idx < 12 +#define _get_event_3_idxs(idx)\ + _d1 = (idx-8)+ 1; + +// Macros definition for variable: _out_exp_1 +#define _idx_out_exp_1 0 +#define _eval_out_exp_1 0 + +// Macros definition for variable: _out_exp_2 +#define _idx_out_exp_2 1 +#define _eval_out_exp_2 1 + +// Macros definition for variable: _out_exp_3 +#define _idx_out_exp_3 2 +#define _eval_out_exp_3 2 + +// Macros definition for variable: _out_exp_4 +#define _idx_out_exp_4 3 +#define _eval_out_exp_4 3 + +// Macros definition for variable: _sum_0 +#define _idx_sum_0(d1,coeff) (8+(d1-1)) +#define _state_idx_sum_0(d1,coeff) (8+(d1-1))*3 + coeff +#define _sum_0(d1,coeff) a[_state_idx_sum_0(d1,coeff)] +#define _is_var_sum_0(idx) idx >= 8 && idx < 12 +#define _get_sum_0_idxs(idx)\ + _d1 = (idx-8)+ 1; + +// Macros definition for variable: aa +#define _idx_aa(d1) ((d1-1)) +#define _aa(d1) __PAR__aa[_idx_aa(d1)] + +// Macros definition for variable: ae +#define _idx_ae(d1) ((d1-1)) +#define _ae(d1) __PAR__ae[_idx_ae(d1)] + +// Macros definition for variable: af +#define _idx_af(d1) ((d1-1)) +#define _af(d1) __PAR__af[_idx_af(d1)] + +// Macros definition for variable: ai +#define _idx_ai(d1) ((d1-1)) +#define _ai(d1) __PAR__ai[_idx_ai(d1)] + +// Macros definition for variable: am +#define _idx_am(d1) ((d1-1)) +#define _am(d1) __PAR__am[_idx_am(d1)] + +// Macros definition for variable: ap +#define _idx_ap(d1) ((d1-1)) +#define _ap(d1) __PAR__ap[_idx_ap(d1)] + +// Macros definition for variable: ar +#define _idx_ar(d1) ((d1-1)) +#define _ar(d1) __PAR__ar[_idx_ar(d1)] + +// Macros definition for variable: av +#define _idx_av(d1) ((d1-1)) +#define _av(d1) __PAR__av[_idx_av(d1)] + +// Macros definition for variable: av1 +#define _idx_av1(d1) ((d1-1)) +#define _av1(d1) __PAR__av1[_idx_av1(d1)] + +// Macros definition for variable: av2 +#define _idx_av2(d1) ((d1-1)) +#define _av2(d1) __PAR__av2[_idx_av2(d1)] + +// Macros definition for variable: ba +#define _idx_ba(d1) ((d1-1)) +#define _ba(d1) __PAR__ba[_idx_ba(d1)] + +// Macros definition for variable: bei +#define _idx_bei(d1) ((d1-1)) +#define _bei(d1) __PAR__bei[_idx_bei(d1)] + +// Macros definition for variable: bem +#define _idx_bem(d1) ((d1-1)) +#define _bem(d1) __PAR__bem[_idx_bem(d1)] + +// Macros definition for variable: bf +#define _idx_bf(d1) ((d1-1)) +#define _bf(d1) __PAR__bf[_idx_bf(d1)] + +// Macros definition for variable: bfh +#define _idx_bfh(d1) ((d1-1)) +#define _bfh(d1) __PAR__bfh[_idx_bfh(d1)] + +// Macros definition for variable: bhd +#define _idx_bhd(d1) ((d1-1)) +#define _bhd(d1) __PAR__bhd[_idx_bhd(d1)] + +// Macros definition for variable: bhf +#define _idx_bhf(d1) ((d1-1)) +#define _bhf(d1) __PAR__bhf[_idx_bhf(d1)] + +// Macros definition for variable: bie +#define _idx_bie(d1) ((d1-1)) +#define _bie(d1) __PAR__bie[_idx_bie(d1)] + +// Macros definition for variable: bmd +#define _idx_bmd(d1) ((d1-1)) +#define _bmd(d1) __PAR__bmd[_idx_bmd(d1)] + +// Macros definition for variable: bmv +#define _idx_bmv(d1) ((d1-1)) +#define _bmv(d1) __PAR__bmv[_idx_bmv(d1)] + +// Macros definition for variable: bpm +#define _idx_bpm(d1) ((d1-1)) +#define _bpm(d1) __PAR__bpm[_idx_bpm(d1)] + +// Macros definition for variable: cf +#define _idx_cf(d1) ((d1-1)) +#define _cf(d1) __PAR__cf[_idx_cf(d1)] + +// Macros definition for variable: cr +#define _cr __PAR__cr + +// Macros definition for variable: day +#define _idx_day(d1) (12+(d1-1)) +#define _day(d1) d[_idx_day(d1)] + +// Macros definition for variable: gav +#define _idx_gav(d1) ((d1-1)) +#define _gav(d1) __PAR__gav[_idx_gav(d1)] + +// Macros definition for variable: ghv +#define _idx_ghv(d1) ((d1-1)) +#define _ghv(d1) __PAR__ghv[_idx_ghv(d1)] + +// Macros definition for variable: gv +#define _idx_gv(d1) ((d1-1)) +#define _gv(d1) __PAR__gv[_idx_gv(d1)] + +// Macros definition for variable: gva +#define _idx_gva(d1) ((d1-1)) +#define _gva(d1) __PAR__gva[_idx_gva(d1)] + +// Macros definition for variable: gvh +#define _idx_gvh(d1) ((d1-1)) +#define _gvh(d1) __PAR__gvh[_idx_gvh(d1)] + +// Macros definition for variable: inside +#define _idx_inside(d1) ((d1-1)) +#define _inside(d1) d[_idx_inside(d1)] + +// Macros definition for variable: inst +#define _idx_inst(d1) (4+(d1-1)) +#define _inst(d1) d[_idx_inst(d1)] + +// Macros definition for variable: r +#define _idx_r(d1) ((d1-1)) +#define _r(d1) __PAR__r[_idx_r(d1)] + +// Macros definition for variable: re +#define _idx_re(d1) ((d1-1)) +#define _re(d1) __PAR__re[_idx_re(d1)] + +// Macros definition for variable: tr +#define _idx_tr(d1) ((d1-1)) +#define _tr(d1) __PAR__tr[_idx_tr(d1)] + +// Macros definition for variable: u +#define _idx_u 11 +#define _u d[_idx_u] + + +// Model Parameters Declaration + +// Macro for parameter: aa +double __PAR__aa[4]; +// Macro for parameter: ae +double __PAR__ae[4]; +// Macro for parameter: af +double __PAR__af[4]; +// Macro for parameter: ai +double __PAR__ai[4]; +// Macro for parameter: am +double __PAR__am[4]; +// Macro for parameter: ap +double __PAR__ap[4]; +// Macro for parameter: ar +double __PAR__ar[4]; +// Macro for parameter: av +double __PAR__av[4]; +// Macro for parameter: av1 +double __PAR__av1[4]; +// Macro for parameter: av2 +double __PAR__av2[4]; +// Macro for parameter: ba +double __PAR__ba[4]; +// Macro for parameter: bei +double __PAR__bei[4]; +// Macro for parameter: bem +double __PAR__bem[4]; +// Macro for parameter: bf +double __PAR__bf[4]; +// Macro for parameter: bfh +double __PAR__bfh[4]; +// Macro for parameter: bhd +double __PAR__bhd[4]; +// Macro for parameter: bhf +double __PAR__bhf[4]; +// Macro for parameter: bie +double __PAR__bie[4]; +// Macro for parameter: bmd +double __PAR__bmd[4]; +// Macro for parameter: bmv +double __PAR__bmv[4]; +// Macro for parameter: bpm +double __PAR__bpm[4]; +// Macro for parameter: cf +double __PAR__cf[4]; +// Macro for parameter: cr +double __PAR__cr; +// Macro for parameter: gav +double __PAR__gav[4]; +// Macro for parameter: ghv +double __PAR__ghv[4]; +// Macro for parameter: gv +double __PAR__gv[4]; +// Macro for parameter: gva +double __PAR__gva[4]; +// Macro for parameter: gvh +double __PAR__gvh[4]; +// Macro for parameter: r +double __PAR__r[4]; +// Macro for parameter: re +double __PAR__re[4]; +// Macro for parameter: tr +double __PAR__tr[4]; + +// Derivative Equations Macros + +// Macros for equation: 1 +#define _apply_usage_eq_1(_d1) \ + i = _d1; +#define _get_eq_1_var_idxs(row, var)\ + _rg_d1 = 0 + (row-1)+ 1;\ + var = _idx_V(_rg_d1,0); +// Macros for equation: 2 +#define _apply_usage_eq_2(_d1) \ + i = _d1; +#define _get_eq_2_var_idxs(row, var)\ + _rg_d1 = 0 + (row-1)+ 1;\ + var = _idx_H(_rg_d1,0); +// Macros for equation: 3 +#define _apply_usage_eq_3(_d1) \ + i = _d1; +#define _get_eq_3_var_idxs(row, var)\ + _rg_d1 = 0 + (row-1)+ 1;\ + var = _idx_I(_rg_d1,0); +// Macros for equation: 4 +#define _apply_usage_eq_4(_d1) \ + i = _d1; +#define _get_eq_4_var_idxs(row, var)\ + _rg_d1 = 0 + (row-1)+ 1;\ + var = _idx_M(_rg_d1,0); +// Macros for equation: 5 +#define _apply_usage_eq_5(_d1) \ + i = _d1; +#define _get_eq_5_var_idxs(row, var)\ + _rg_d1 = 0 + (row-1)+ 1;\ + var = _idx_F(_rg_d1,0); +// Macros for equation: 6 +#define _apply_usage_eq_6(_d1) \ + i = _d1; +#define _get_eq_6_var_idxs(row, var)\ + _rg_d1 = 0 + (row-1)+ 1;\ + var = _idx_R(_rg_d1,0); +// Macros for equation: 7 +#define _apply_usage_eq_7(_d1) \ + i = _d1; +#define _get_eq_7_var_idxs(row, var)\ + _rg_d1 = 0 + (row-1)+ 1;\ + var = _idx_E(_rg_d1,0); +// Macros for equation: 8 +#define _apply_usage_eq_8(_d1) \ + i = _d1; +#define _get_eq_8_var_idxs(row, var)\ + _rg_d1 = 0 + (row-1)+ 1;\ + var = _idx_P(_rg_d1,0); +// Macros for equation: 9 +#define _apply_usage_eq_9(_d1) \ + i = _d1; +#define _get_eq_9_var_idxs(row, var)\ + _rg_d1 = 0 + (row-1)+ 1;\ + var = _idx_A(_rg_d1,0); +// Macros for equation: 10 +#define _apply_usage_eq_10(_d1) \ + i = _d1; +#define _get_eq_10_var_idxs(row, var)\ + _rg_d1 = 0 + (row-1)+ 1;\ + var = _idx_S(_rg_d1,0); +// Macros for equation: 11 + + +// Algebraic Equations Macros + +// Macros for algebraic equation: 1 +#define _apply_usage_alg_eq_1(_d1) \ + i = _d1; +#define _get_alg_eq_1_var_idxs(row, var)\ + _rg_d1 = 0 + (row-1)+ 1;\ + var = _idx_D(_rg_d1,0); +// Macros for algebraic equation: 2 +#define _apply_usage_alg_eq_2(_d1) \ + i = _d1; +#define _get_alg_eq_2_var_idxs(row, var)\ + _rg_d1 = 0 + (row-1)+ 1;\ + var = _idx_Vpar(_rg_d1,0); +// Macros for algebraic equation: 3 + +// Macros for algebraic equation: 4 +#define _apply_usage_alg_eq_4(_d1) \ + i = _d1; +#define _get_alg_eq_4_var_idxs(row, var)\ + _rg_d1 = 1 + (row-1)+ 1;\ + var = _idx_sum_0(_rg_d1,0); + +// Event Macros + +// Macros for event: 1 +#define _apply_usage_event_1(_d1) \ + i = _d1; +#define _get_event_1_var_idxs(row, var)\ + _rg_d1 = 0 + (row-1)+ 1;\ + var = _idx_event_1(_rg_d1); +// Macros for event: 2 +#define _apply_usage_event_2(_d1) \ + i = _d1; +#define _get_event_2_var_idxs(row, var)\ + _rg_d1 = 0 + (row-1)+ 1;\ + var = _idx_event_2(_rg_d1); +// Macros for event: 3 +#define _apply_usage_event_3(_d1) \ + i = _d1; +#define _get_event_3_var_idxs(row, var)\ + _rg_d1 = 0 + (row-1)+ 1;\ + var = _idx_event_3(_rg_d1); +#define _zc(coeff) zc[coeff] + +// Output Equations Macros + +// Macros for output equation: 1 + +// Macros for output equation: 2 + +// Macros for output equation: 3 + +// Macros for output equation: 4 + +#define _out out[0] + +// Jacobian Macros definition. +#define _assign_jac(r, val) \ + col_t = dvdx->df_dx_t->size[r] + dvdx->df_dx_t->index[r][0]; \ + dvdx->df_dx_t->index[r][0]++; \ + jac[col_t] = val; +#define _c_index(i) (i-1) + +#define _time t + +// Derivative Macros definition. +// Derivative definition for variable: A +#define _der_A(d1,coeff) dx[coeff+1] +// Derivative definition for variable: E +#define _der_E(d1,coeff) dx[coeff+1] +// Derivative definition for variable: F +#define _der_F(d1,coeff) dx[coeff+1] +// Derivative definition for variable: H +#define _der_H(d1,coeff) dx[coeff+1] +// Derivative definition for variable: I +#define _der_I(d1,coeff) dx[coeff+1] +// Derivative definition for variable: M +#define _der_M(d1,coeff) dx[coeff+1] +// Derivative definition for variable: P +#define _der_P(d1,coeff) dx[coeff+1] +// Derivative definition for variable: R +#define _der_R(d1,coeff) dx[coeff+1] +// Derivative definition for variable: S +#define _der_S(d1,coeff) dx[coeff+1] +// Derivative definition for variable: V +#define _der_V(d1,coeff) dx[coeff+1] +// Derivative definition for variable: Vr +#define _der_Vr(coeff) dx[coeff+1] diff --git a/src/mmoc/tests/system/gt_data/VIRplanoS/VIRplanoS.ini b/src/mmoc/tests/system/gt_data/VIRplanoS/VIRplanoS.ini new file mode 100644 index 00000000..df481637 --- /dev/null +++ b/src/mmoc/tests/system/gt_data/VIRplanoS/VIRplanoS.ini @@ -0,0 +1,15 @@ +minstep=1.00000e-14; +zchyst=1.00000e-12; +derdelta=1.00000e-08; +symdiff=1; +lps=0; +nodesize=10000; +jacobian=1; +it=0.00000e+00; +ft=6.00000e+01; +sol="LIQSS2"; +dqmin=(1.00000e-06); +dqrel=(1.00000e-02); +bdf=0; +BDFPartitionDepth=1; +BDFMaxStep=0.00000e+00; diff --git a/src/mmoc/tests/system/gt_data/VIRplanoS/VIRplanoS.mo b/src/mmoc/tests/system/gt_data/VIRplanoS/VIRplanoS.mo new file mode 100644 index 00000000..6fc4cddc --- /dev/null +++ b/src/mmoc/tests/system/gt_data/VIRplanoS/VIRplanoS.mo @@ -0,0 +1,151 @@ +model VIRplanoS + +//SIN INMUNIDAD (S START=0.1) , 50% BARBIJOS (re, tr ) , VENTILADO medio ) +function SRND + input Real y; + output Real r; + external "C" r=srnd(y) annotation(IncludeDirectory="modelica://VIRplanoS", + Include="#include \"srnd.c\""); + end SRND; + function RND + input Real y; + output Real r; + external "C" r=rnd(y) annotation(IncludeDirectory="modelica://VIRplanoS", + Include="#include \"rnd.c\""); + end RND; +import math; + constant Integer N = 4; //maximum number of people in the room + Real V[N], H[N](each start = 1), I[N], M[N], F[N], R[N], E[N](each start = 1), P[N](each start = 1), A[N](each start = 1), S[N](each start = 0.1), D[N]; //// viral load, healthy cells, infected cells, activated antigen presenting cells, interferon, resistant cells, effector cells, plasma cells, antibodies, antigenic distance, dead cells + parameter Real gv[N](each fixed=false) , gva[N](each fixed=false), gvh[N](each fixed=false) , av[N](each fixed=false), av1[N](each fixed=false), av2[N](each fixed=false), bhd[N](each fixed=false), ar[N](each fixed=false), ghv[N](each fixed=false), bhf[N](each fixed=false) , bie[N](each fixed=false) , ai[N](each fixed=false), bmd[N](each fixed=false) , bmv[N](each fixed=false) , am[N](each fixed=false), bf[N](each fixed=false) , cf[N](each fixed=false), bfh[N](each fixed=false) , af[N](each fixed=false), bem[N](each fixed=false) , bei[N](each fixed=false) , ae[N](each fixed=false) , bpm[N](each fixed=false) , ap[N], ba[N](each fixed=false) , gav[N](each fixed=false) , aa[N](each fixed=false) , r[N](each fixed=false) ; // parameters characterizing disease processe + parameter Real re[N](each fixed=false) , tr[N](each fixed=false), cr = 100; //reception rate of viral load,transmission rate of viral load,decay rate of viral load inside the room + Real Vr, Vtot, Vpar[N]; //total viral load inside the room, viral load of people inside the room, Aux Var + discrete Real inside[N],inst[N]; // state: inside(1) o outside(0) of the room; time of change of state + discrete Real Su,In1,Rec; //Susceptible, Infected , Recovered people + discrete Real u,day[N]; //day=first day of non-contagion after infection + + +initial algorithm + u :=rand(1); + +//parameter definition + for i in 1:N loop + gv[i] := 510; + gva[i] := 619.2; + gvh[i] := 1.02; + av[i] := 1.7; + av1[i] := 100; + av2[i] := 23000; + bhd[i] := 4; + ar[i] :=1; + ghv[i] := 0.34; + bhf[i] := 0.01; + bie[i] := 0.066; + ai[i] := 1.5; + bmd[i]:= 1; + bmv[i] := 0.0037; + am[i] := 1; + bf[i] := 250000; + cf[i] := 2000; + bfh[i] := 17; + af[i] := 8; + bem[i] := 8.3; + bei[i] := 2.72; + ae[i] := 0.4; + bpm[i] := 11.5; + ap[i] := 0.4; + ba[i] := 0.043; + gav[i] := 146.2; + aa[i] := 0.043; + r[i] := 3e-5; + end for; + +// initialization of people's parameters + for i in 1:N/2 loop + re[i]:= rand(0.22) + 0.18; + tr[i]:= re[i]; + end for; + for i in N/2+1:N loop + re[i]:= rand(0.06) + 0.04; + tr[i]:= re[i]; + end for; + V[1] := 10; //one infected + inside[1]:= 1; + + for i in 1:N loop + inst[i] := rand(2); + day[i] :=1000; + end for; + +for i in 1:2 loop //(N*1/100) loop //1% of people start infected +V[i] :=10; +inside[i] :=1; +end for; + +Su := N; + +equation +for i in 1:N loop + der(V[i]) = gv[i] * I[i] - gva[i] * S[i] * A[i] * V[i] - gvh[i] * H[i] * V[i] - av[i] * V[i] - av1[i] * V[i] / (1 + av2[i] * V[i]) + inside[i]*re[i] * Vr; + der(H[i]) = bhd[i] * D[i] * (H[i] + R[i]) + ar[i] * R[i] - ghv[i] * V[i] * H[i] - bhf[i] * F[i] * H[i]; + der(I[i]) = ghv[i] * V[i] * H[i] - bie[i] * E[i] * I[i] - ai[i] * I[i]; + der(M[i]) = (bmd[i] * D[i] + bmv[i] * V[i]) * (1 - M[i]) - am[i] * M[i]; + der(F[i]) = bf[i] * M[i] + cf[i] * I[i] - bfh[i] * H[i] * F[i] - af[i] * F[i]; + der(R[i]) = bhf[i] * F[i] * H[i] - ar[i] * R[i]; + der(E[i]) = bem[i] * M[i] * E[i] - bei[i] * I[i] * E[i] + ae[i] * (1 - E[i]); + der(P[i]) = bpm[i] * M[i] * P[i] + ap[i] * (1 - P[i]); + der(A[i]) = ba[i] * P[i] - gav[i] * S[i] * A[i] * V[i] - aa[i] * A[i]; + der(S[i]) = r[i] * P[i] * (1 - S[i]); + D[i] = 1 - H[i] - R[i] - I[i]; +end for; + der(Vr)=sum(Vpar) *100/N- cr * Vr; + +for i in 1:N loop + Vpar[i]=V[i]*tr[i]*inside[i]; + end for; + + //Vtot= sum(Vpar); + + algorithm +u:=u; + +for i in 1:N loop + when time > inst[i] then + if inside[i]==0 then + inside[i]:= 1- inside[i]; + inst[i]:=inst[i]+rand(0.0833); + else + inside[i]:= 1- inside[i]; + inst[i]:=inst[i]+ rand(0.2075)+0.833; +end if; + end when; +end for; + + for i in 1:N loop + when V[i] > 1 then + Su:=Su-1; + In1:=In1+1; + day[i]:=time+10; + end when; + when time > day[i] then + In1:=In1-1; + Rec:=Rec+1; +end when; +end for; + annotation( + + experiment( + MMO_Description="", + MMO_Solver=LIQSS2, + MMO_PartitionMethod=Metis, + MMO_Output={In1,Rec,Su,Vr}, + MMO_OutputType=CI_Sampled, + Jacobian=Dense, + MMO_BDF_PDepth=1, + MMO_BDF_Max_Step=0, + MMO_RandomSeed=1, + StartTime=0.0, + StopTime=60, + Tolerance={1e-2}, + AbsTolerance={1e-6} + )); +end VIRplanoS;