Skip to content

Commit

Permalink
Check if USER_SOLUTION_TIMES exceed section times
Browse files Browse the repository at this point in the history
  • Loading branch information
schmoelder committed Mar 26, 2022
1 parent 926a763 commit 895538d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions include/common/Driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,25 +253,25 @@ class Driver

// Configure main solver parameters
pp.pushScope("solver");
_sim->configure(pp);


// Configure section times
std::vector<double> secTimes;
std::vector<bool> secCont;
extractSectionTimes(pp, secTimes, secCont);
_sim->setSectionTimes(secTimes, secCont);
_sim->configure(pp);

pp.popScope(); // solver scope

// Create and configure model
pp.pushScope("model");

// Create and configure model
cadet::IModelSystem* model = _builder->createSystem(pp);

// Hand model over to simulator
_sim->initializeModel(*model);
_sim->setSectionTimes(secTimes, secCont);

// Specify initial values
// Specify initial values
if (pp.exists("INIT_STATE_Y"))
{
const std::vector<double> initY = pp.getDoubleArray("INIT_STATE_Y");
Expand Down
5 changes: 5 additions & 0 deletions src/libcadet/SimulatorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,11 @@ namespace cadet
if (paramProvider.exists("USER_SOLUTION_TIMES"))
_solutionTimes = paramProvider.getDoubleArray("USER_SOLUTION_TIMES");

if (static_cast<double>(_solutionTimes.back()) > static_cast<double>(_sectionTimes.back()))
{
throw InvalidParameterException("USER_SOLUTION_TIMES exceed section times");
}

if (paramProvider.exists("CONSISTENT_INIT_MODE"))
_consistentInitMode = toConsistentInitialization(paramProvider.getInt("CONSISTENT_INIT_MODE"));

Expand Down

0 comments on commit 895538d

Please sign in to comment.