Skip to content

Commit

Permalink
Updated GT test files.
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquinffernandez committed May 31, 2023
1 parent d522b80 commit 6daa8bd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 55 deletions.
13 changes: 5 additions & 8 deletions src/mmoc/tests/system/gt_data/NeuralNetwork1/NeuralNetwork1.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ void MOD_settings(SD_simulationSettings settings)
void MOD_definition(int idx, double *x, double *d, double *a, double t, double *dx)
{
int _d1;
int _d2;
int i;
if (_is_var_V(idx)) {
_get_V_idxs(idx);
_apply_usage_alg_eq_1(_d1);
if ((i >= 1 && i <= 100)) {
_Is(i,0) = _Islast(i)*exp(-(_time-_tlast(i))/_taus);
_Is(i,1) = 0;
_Is(i,0) = _Islast(i)*exp(-(_time-_tlast(i))/_taus);
_Is(i,1) = 0;
}
_apply_usage_eq_1(_d1);
if ((i >= 1 && i <= 100)) {
Expand Down Expand Up @@ -175,14 +174,13 @@ void MOD_jacobian(double *x, double *d, double *a, double t, SD_jacMatrices dvdx
void MOD_dependencies(int idx, double *x, double *d, double *a, double t, double *dx, int *map)
{
int _d1;
int _d2;
int i;
if (_is_var_V(idx)) {
_get_V_idxs(idx);
_apply_usage_alg_eq_1(_d1);
if ((i >= 1 && i <= 100)) {
_Is(i,0) = _Islast(i)*exp(-(_time-_tlast(i))/_taus);
_Is(i,1) = 0;
_Is(i,0) = _Islast(i)*exp(-(_time-_tlast(i))/_taus);
_Is(i,1) = 0;
}
_apply_usage_eq_1(_d1);
if ((i >= 1 && i <= 100)) {
Expand All @@ -199,13 +197,12 @@ void MOD_BDF_definition(double *x, double *d, double *a, double t, double *dx, i
for(__bdf_it = 0; __bdf_it < nBDF; __bdf_it++) {
idx = BDFMap[__bdf_it];
int _d1;
int _d2;
int i;
if (_is_var_V(idx)) {
_get_V_idxs(idx);
_apply_usage_alg_eq_1(_d1);
if ((i >= 1 && i <= 100)) {
_Is(i,0) = _Islast(i)*exp(-(_time-_tlast(i))/_taus);
_Is(i,0) = _Islast(i)*exp(-(_time-_tlast(i))/_taus);

}
_apply_usage_eq_1(_d1);
Expand Down
16 changes: 8 additions & 8 deletions src/mmoc/tests/system/gt_data/cuk2/cuk2.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,22 +187,22 @@ void MOD_jacobian(double *x, double *d, double *a, double t, SD_jacMatrices dvdx
aux = 0;
x_ind = _idx_iL(0);
col = pos(dvdx->df_dx[0]->index[c_row], dvdx->df_dx[0]->size[c_row], x_ind);
c_row_g = _idx_iD(0) - 0;
c_row_g = _idx_iD(0) - 1;
col_g = pos(dvdx->dg_dx[1]->index[c_row_g], dvdx->dg_dx[1]->size[c_row_g], x_ind);
dvdx->df_dx[0]->value[c_row][col] += aux * dvdx->dg_dx[1]->value[c_row_g][col_g];
x_ind = _idx_phi(0);
col = pos(dvdx->df_dx[0]->index[c_row], dvdx->df_dx[0]->size[c_row], x_ind);
c_row_g = _idx_iD(0) - 0;
c_row_g = _idx_iD(0) - 1;
col_g = pos(dvdx->dg_dx[1]->index[c_row_g], dvdx->dg_dx[1]->size[c_row_g], x_ind);
dvdx->df_dx[0]->value[c_row][col] += aux * dvdx->dg_dx[1]->value[c_row_g][col_g];
x_ind = _idx_iL(0);
col = pos(dvdx->df_dx[0]->index[c_row], dvdx->df_dx[0]->size[c_row], x_ind);
c_row_g = _idx_iD(0) - 0;
c_row_g = _idx_iD(0) - 1;
col_g = pos(dvdx->dg_dx[1]->index[c_row_g], dvdx->dg_dx[1]->size[c_row_g], x_ind);
dvdx->df_dx[0]->value[c_row][col] += aux * dvdx->dg_dx[1]->value[c_row_g][col_g];
x_ind = _idx_uC1(0);
col = pos(dvdx->df_dx[0]->index[c_row], dvdx->df_dx[0]->size[c_row], x_ind);
c_row_g = _idx_iD(0) - 0;
c_row_g = _idx_iD(0) - 1;
col_g = pos(dvdx->dg_dx[1]->index[c_row_g], dvdx->dg_dx[1]->size[c_row_g], x_ind);
dvdx->df_dx[0]->value[c_row][col] += aux * dvdx->dg_dx[1]->value[c_row_g][col_g];
x_ind = _idx_iL(0);
Expand Down Expand Up @@ -237,22 +237,22 @@ void MOD_jacobian(double *x, double *d, double *a, double t, SD_jacMatrices dvdx
aux = 0;
x_ind = _idx_iL(0);
col = pos(dvdx->df_dx[3]->index[c_row], dvdx->df_dx[3]->size[c_row], x_ind);
c_row_g = _idx_iD(0) - 0;
c_row_g = _idx_iD(0) - 1;
col_g = pos(dvdx->dg_dx[1]->index[c_row_g], dvdx->dg_dx[1]->size[c_row_g], x_ind);
dvdx->df_dx[3]->value[c_row][col] += aux * dvdx->dg_dx[1]->value[c_row_g][col_g];
x_ind = _idx_phi(0);
col = pos(dvdx->df_dx[3]->index[c_row], dvdx->df_dx[3]->size[c_row], x_ind);
c_row_g = _idx_iD(0) - 0;
c_row_g = _idx_iD(0) - 1;
col_g = pos(dvdx->dg_dx[1]->index[c_row_g], dvdx->dg_dx[1]->size[c_row_g], x_ind);
dvdx->df_dx[3]->value[c_row][col] += aux * dvdx->dg_dx[1]->value[c_row_g][col_g];
x_ind = _idx_iL(0);
col = pos(dvdx->df_dx[3]->index[c_row], dvdx->df_dx[3]->size[c_row], x_ind);
c_row_g = _idx_iD(0) - 0;
c_row_g = _idx_iD(0) - 1;
col_g = pos(dvdx->dg_dx[1]->index[c_row_g], dvdx->dg_dx[1]->size[c_row_g], x_ind);
dvdx->df_dx[3]->value[c_row][col] += aux * dvdx->dg_dx[1]->value[c_row_g][col_g];
x_ind = _idx_uC1(0);
col = pos(dvdx->df_dx[3]->index[c_row], dvdx->df_dx[3]->size[c_row], x_ind);
c_row_g = _idx_iD(0) - 0;
c_row_g = _idx_iD(0) - 1;
col_g = pos(dvdx->dg_dx[1]->index[c_row_g], dvdx->dg_dx[1]->size[c_row_g], x_ind);
dvdx->df_dx[3]->value[c_row][col] += aux * dvdx->dg_dx[1]->value[c_row_g][col_g];
x_ind = _idx_uC(0);
Expand Down
47 changes: 8 additions & 39 deletions src/mmoc/tests/system/gt_data/interleaved/interleaved.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void MOD_jacobian(double *x, double *d, double *a, double t, SD_jacMatrices dvdx
for(i = 2; i<=4; i+=1) {
_get_alg_eq_2_var_idxs(_idx_sum_0(i,0), eq_var);
_get_sum_0_idxs(eq_var);
if((2 <= _d1 && _d1 <= 3)) {
if((2 <= _d1 && _d1 <= 4)) {
x_ind = _idx_iL(_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);
Expand All @@ -215,19 +215,14 @@ void MOD_jacobian(double *x, double *d, double *a, double t, SD_jacMatrices dvdx
for(i = 2; i<=4; i+=1) {
_get_alg_eq_2_var_idxs(_idx_sum_0(i,0), eq_var);
_get_sum_0_idxs(eq_var);
if((2 <= _d1 && _d1 <= 3)) {
if((2 <= _d1 && _d1 <= 4)) {
x_ind = _idx_iL(_d1,0);
col = pos(dvdx->df_dx[0]->index[c_row], dvdx->df_dx[0]->size[c_row], x_ind);
c_row_g = _idx_sum_0(_rg_d1,0) - 1;
col_g = pos(dvdx->dg_dx[1]->index[c_row_g], dvdx->dg_dx[1]->size[c_row_g], x_ind);
dvdx->df_dx[0]->value[c_row][col] += aux * dvdx->dg_dx[1]->value[c_row_g][col_g];
}
} x_ind = _idx_iL(4,0);
col = pos(dvdx->df_dx[0]->index[c_row], dvdx->df_dx[0]->size[c_row], x_ind);
c_row_g = _idx_sum_0(4,0) - 1;
col_g = pos(dvdx->dg_dx[1]->index[c_row_g], dvdx->dg_dx[1]->size[c_row_g], x_ind);
dvdx->df_dx[0]->value[c_row][col] += aux * dvdx->dg_dx[1]->value[c_row_g][col_g];
x_ind = _idx_uC(0);
} x_ind = _idx_uC(0);
col = pos(dvdx->df_dx[0]->index[c_row], dvdx->df_dx[0]->size[c_row], x_ind);
aux = 0;
dvdx->df_dx[0]->value[c_row][col] += aux;
Expand Down Expand Up @@ -271,21 +266,6 @@ void MOD_dependencies(int idx, double *x, double *d, double *a, double t, double
int _rg_d1;
int i;
switch(idx) {
case _eval_iL(4,0): {
_sum_0(1,0) = _iL(1,0);
_sum_0(1,1) = 0;
for(_rg_d1 = 1; _rg_d1<=3; _rg_d1+=1) {
_get_sum_0_idxs(_rg_d1);
_apply_usage_alg_eq_2(_d1);
if ((i >= 2 && i <= 4)) {
_sum_0(i,0) = _sum_0(i-1,0)+_iL(i,0);
_sum_0(i,1) = 0;
}
}
_eval_dep_uC(1) = (_sum_0(4,0)-_uC(0)/_R)/_C;
_eval_dep_uC(2) = (0)/2;
break;
}
case _eval_uC(0): {
_sum_0(1,0) = _iL(1,0);
_sum_0(1,1) = 0;
Expand Down Expand Up @@ -404,7 +384,6 @@ void QSS_initializeDataStructs(QSS_simulator simulator)
_T = 1.000000e-04;
_U = 24;
_nextT = 1.000000e-08;
modelData->nSD[_idx_iL(4,0)]++;
modelData->nSD[_idx_uC(0)]++;
for(_d1 = 1; _d1<=4; _d1+=1) {
modelData->nSD[_idx_uC(0)]++;
Expand All @@ -416,7 +395,6 @@ void QSS_initializeDataStructs(QSS_simulator simulator)
modelData->nSD[_idx_iL(_d1,0)]++;
}
modelData->nDS[_idx_uC(0)]++;
modelData->nDS[_idx_uC(0)]++;
for(_d1 = 1; _d1<=4; _d1+=1) {
modelData->nDS[_idx_iL(_d1,0)]++;
}
Expand All @@ -440,7 +418,7 @@ void QSS_initializeDataStructs(QSS_simulator simulator)
for(i = 2; i<=4; i+=1) {
_get_alg_eq_2_var_idxs(_idx_sum_0(i,0), eq_var);
_get_sum_0_idxs(eq_var);
if((2 <= _d1 && _d1 <= 3)) {
if((2 <= _d1 && _d1 <= 4)) {
modelData->jac_matrices->dg_dx[1]->size[c_row]++;
}
} modelData->jac_matrices->dg_dx[1]->size[c_row]++;
Expand All @@ -451,11 +429,10 @@ void QSS_initializeDataStructs(QSS_simulator simulator)
for(i = 2; i<=4; i+=1) {
_get_alg_eq_2_var_idxs(_idx_sum_0(i,0), eq_var);
_get_sum_0_idxs(eq_var);
if((2 <= _d1 && _d1 <= 3)) {
if((2 <= _d1 && _d1 <= 4)) {
modelData->jac_matrices->df_dx[0]->size[c_row]++;
}
} 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);
Expand Down Expand Up @@ -507,7 +484,6 @@ void QSS_initializeDataStructs(QSS_simulator simulator)
modelData->event[_idx_event_1].nLHSDsc++;
QSS_allocDataMatrix(modelData);
cleanVector(states, 0, 5);
modelData->SD[_idx_iL(4,0)][states[_idx_iL(4,0)]++] = _idx_uC(0);
modelData->SD[_idx_uC(0)][states[_idx_uC(0)]++] = _idx_uC(0);
for(_d1 = 1; _d1<=4; _d1+=1) {
modelData->SD[_idx_uC(0)][states[_idx_uC(0)]++] = _idx_iL(_d1,0);
Expand All @@ -519,7 +495,6 @@ void QSS_initializeDataStructs(QSS_simulator simulator)
modelData->SD[_idx_iL(_d1,0)][states[_idx_iL(_d1,0)]++] = _idx_iL(_d1,0);
}
cleanVector(states, 0, 5);
modelData->DS[_idx_uC(0)][states[_idx_uC(0)]++] = _idx_iL(4,0);
modelData->DS[_idx_uC(0)][states[_idx_uC(0)]++] = _idx_uC(0);
for(_d1 = 1; _d1<=4; _d1+=1) {
modelData->DS[_idx_iL(_d1,0)][states[_idx_iL(_d1,0)]++] = _idx_uC(0);
Expand Down Expand Up @@ -556,7 +531,7 @@ void QSS_initializeDataStructs(QSS_simulator simulator)
for(i = 2; i<=4; i+=1) {
_get_alg_eq_2_var_idxs(_idx_sum_0(i,0), eq_var);
_get_sum_0_idxs(eq_var);
if((2 <= _d1 && _d1 <= 3)) {
if((2 <= _d1 && _d1 <= 4)) {
x_ind = _idx_iL(_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]--;
Expand All @@ -583,21 +558,15 @@ void QSS_initializeDataStructs(QSS_simulator simulator)
for(i = 2; i<=4; i+=1) {
_get_alg_eq_2_var_idxs(_idx_sum_0(i,0), eq_var);
_get_sum_0_idxs(eq_var);
if((2 <= _d1 && _d1 <= 3)) {
if((2 <= _d1 && _d1 <= 4)) {
x_ind = _idx_iL(_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_iL(4,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_uC(0);
} x_ind = _idx_uC(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 {
Expand Down

0 comments on commit 6daa8bd

Please sign in to comment.