Skip to content

Commit

Permalink
[iss-250]
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 16940f9
Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com>
Date:   Wed Jul 31 10:40:04 2024 -0300

    Updated workflow deps.

commit 7857ba8
Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com>
Date:   Wed Jul 31 10:33:45 2024 -0300

    Updated pre-commit hook.

commit 160dce6
Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com>
Date:   Wed Jul 31 10:33:34 2024 -0300

    Updated vscode settings.

commit e0d3c57
Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com>
Date:   Wed Jul 31 10:33:03 2024 -0300

    Set new parameter in integrator.

commit 294f238
Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com>
Date:   Wed Jul 31 10:32:51 2024 -0300

    Set new parameter data.

commit 186038a
Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com>
Date:   Wed Jul 31 10:32:18 2024 -0300

    Added CVODE max order parameter to simulator engine.

commit 5c7d22e
Author: joaquin.f.fernandez <joaquin.f.fernandez@gmail.com>
Date:   Wed Jul 31 10:31:22 2024 -0300

    Added CVODE max order to model settings.
  • Loading branch information
joaquinffernandez committed Jul 31, 2024
1 parent 0b3620c commit 86abc6d
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
sudo apt-get install pkgconf
sudo apt-get install python
sudo apt-get install qt5-default
sudo apt-get install rapidjson-dev
- name: Build
working-directory: ./src
Expand Down
10 changes: 5 additions & 5 deletions .hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ def get_files():
'--name-only', 'HEAD']).split()

def apply_code_style():
files = filter(lambda x: x.find('tests/system/gt_data') == -1, get_files())
files = filter(lambda x: x.find(b'tests/system/gt_data') == -1, get_files())

files = filter(lambda x: x.endswith('.c') or
x.endswith('.h') or
x.endswith('.cpp'), files)
files = filter(lambda x: x.endswith(b'.c') or
x.endswith(b'.h') or
x.endswith(b'.cpp'), files)
for f in files:
print("Apply code style to: " + f)
print("Apply code style to: " + str(f))
subprocess.check_output(['clang-format-7', '-i', f])
subprocess.check_output(['git', 'add', f])

Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"sonarlint.pathToCompileCommands": "${workspaceFolder}/src/engine/compile_commands.json"
}
7 changes: 7 additions & 0 deletions src/engine/classic/classic_cvode_integrator.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ void CVODE_integrate(SIM_simulator simulate)
if (check_flag(&flag, "CVDense", 1, simulator)) return;
}

if (simulator->data->params->CVODE_max_order != 0) {
flag = CVodeSetMaxOrd(cvode_mem, simulator->data->params->CVODE_max_order);
if (check_flag(&flag, "CVodeSetMaxOrd", 1, simulator)) {
return;
}
}

getTime(simulator->stats->sTime);
if (is_sampled) {
CLC_save_step(simOutput, solution, solution_time, t, totalOutputSteps, NV_DATA_S(y), clcData->d, clcData->alg);
Expand Down
6 changes: 3 additions & 3 deletions src/engine/classic/classic_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ CLC_data CLC_Data(int states, int discretes, int events, int inputs, int algebra
strcat(fileName, ".ini");
SET_settings settings = SET_Settings(fileName);
CLC_data p = checkedMalloc(sizeof(*p));
int i;
p->states = states;
p->discretes = discretes;
p->events = events;
Expand Down Expand Up @@ -78,14 +77,15 @@ CLC_data CLC_Data(int states, int discretes, int events, int inputs, int algebra
cleanVector(p->nDS, 0, states);
double sameDQMin = (settings->nDQMin == 1) ? settings->dqmin[0] : 0;
double sameDQRel = (settings->nDQRel == 1) ? settings->dqrel[0] : 0;
for (i = 0; i < states; i++) {
for (int i = 0; i < states; i++) {
p->nSD[i] = 0;
p->dQMin[i] = (sameDQMin > 0) ? sameDQMin : settings->dqmin[i];
p->dQRel[i] = (sameDQRel > 0) ? sameDQRel : settings->dqrel[i];
}
p->event = SD_EventData(events);
p->params = SD_Parameters(settings->derdelta, settings->zchyst, settings->minstep, settings->symdiff, settings->lps, settings->nodesize,
settings->pm, settings->dt, settings->dtSynch, settings->partitionerOptions, settings->jacobian);
settings->pm, settings->dt, settings->dtSynch, settings->partitionerOptions, settings->jacobian,
settings->CVODE_max_order);
p->scalarEvaluations = 0;
p->zeroCrossings = 0;
p->funEvaluations = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/engine/common/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void SD_cleanEventData(SD_eventData events, int size)
}

SD_parameters SD_Parameters(double derDelta, double zcHyst, double minStep, int symDiff, int lps, int nodeSize, SD_PartitionMethod pm,
double dt, SD_DtSynch synch, SD_partitionerOptions partitionerOptions, int jacobian)
double dt, SD_DtSynch synch, SD_partitionerOptions partitionerOptions, int jacobian, int CVODE_max_order)
{
SD_parameters p = checkedMalloc(sizeof(*p));
p->derDelta = derDelta;
Expand All @@ -185,6 +185,7 @@ SD_parameters SD_Parameters(double derDelta, double zcHyst, double minStep, int
p->dtSynch = synch;
p->partitionerOptions = partitionerOptions;
p->jacobian = jacobian;
p->CVODE_max_order = CVODE_max_order;
return p;
}

Expand Down
3 changes: 2 additions & 1 deletion src/engine/common/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,14 @@ struct SD_parameters_ {
int lps; //!< Number of LPs defined for parallel simulations.
int nodeSize; //!< Node size used in the memory list for output simulation values.
int jacobian;
int CVODE_max_order;
SD_PartitionMethod pm; //!< Partition method used to obtain a model partition for parallel simulations.
SD_DtSynch dtSynch; //!< \f $ \delta t $ \f synchronization policy.
SD_partitionerOptions partitionerOptions;
};

SD_parameters SD_Parameters(double derDelta, double zcHyst, double minStep, int symDiff, int lps, int nodeSize, SD_PartitionMethod pm,
double dt, SD_DtSynch synch, SD_partitionerOptions partitionerOptions, int jacobian);
double dt, SD_DtSynch synch, SD_partitionerOptions partitionerOptions, int jacobian, int CVODE_max_order);

SD_parameters SD_copyParameters(SD_parameters parameters);

Expand Down
12 changes: 10 additions & 2 deletions src/engine/common/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,13 @@ int _getOrder(SD_Solver sol)

SET_settings SET_Settings(char *fname)
{
config_t cfg, *cf;
config_t cfg;
config_t *cf;
const config_setting_t *lists;
int count, n, ires, option;
int count;
int n;
int ires;
int option;
double dres;
const char *sol;
const char *bdf;
Expand Down Expand Up @@ -153,6 +157,7 @@ SET_settings SET_Settings(char *fname)
p->dtSynch = SD_DT_Adaptive;
p->BDFPart = 0;
p->BDFPartitionDepth = 1;
p->CVODE_max_order = 0;
p->BDFMaxStep = 0;
if (config_lookup_float(cf, "minstep", &dres)) {
if (dres == 0) {
Expand Down Expand Up @@ -201,6 +206,9 @@ SET_settings SET_Settings(char *fname)
if (config_lookup_int(cf, "jacobian", &ires)) {
p->jacobian = ires;
}
if (config_lookup_int(cf, "CVODEMaxOrder", &ires)) {
p->CVODE_max_order = ires;
}
if (config_lookup_int(cf, "nodesize", &ires)) {
if (ires == 0) {
p->nodesize = NODE_SIZE;
Expand Down
1 change: 1 addition & 0 deletions src/engine/common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct SET_settings_ {
int nDQRel;
int jacobian;
int BDFPartitionDepth;
int CVODE_max_order;
SD_PartitionMethod pm;
SD_DtSynch dtSynch;
SD_partitionerOptions partitionerOptions;
Expand Down
7 changes: 4 additions & 3 deletions src/engine/qss/qss_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ QSS_data QSS_Data(int states, int discretes, int events, int inputs, int algs, i
exit(-1);
}
QSS_data p = checkedMalloc(sizeof(*p));
int i, order = settings->order;
int order = settings->order;
int xOrder = order + 1;
p->states = states;
p->discretes = discretes;
Expand Down Expand Up @@ -421,7 +421,7 @@ QSS_data QSS_Data(int states, int discretes, int events, int inputs, int algs, i
}
}

for (i = 0; i < states; i++) {
for (int i = 0; i < states; i++) {
p->dQMin[i] = (same_DQMin) ? settings->dqmin[0] : settings->dqmin[i];
p->dQRel[i] = (same_DQRel) ? settings->dqrel[0] : settings->dqrel[i];
}
Expand All @@ -439,7 +439,8 @@ QSS_data QSS_Data(int states, int discretes, int events, int inputs, int algs, i
p->event = NULL;
}
p->params = SD_Parameters(settings->derdelta, settings->zchyst, settings->minstep, settings->symdiff, settings->lps, settings->nodesize,
settings->pm, settings->dt, settings->dtSynch, settings->partitionerOptions, settings->jacobian);
settings->pm, settings->dt, settings->dtSynch, settings->partitionerOptions, settings->jacobian,
settings->CVODE_max_order);
p->lp = NULL;
if (settings->lps > 0) {
QSS_setReinitBuffer(TRUE);
Expand Down

0 comments on commit 86abc6d

Please sign in to comment.