示例#1
0
SimController::SimController(PATH library_path, PATH modelicasystem_path)
    : SimControllerPolicy(library_path, modelicasystem_path, library_path)
    , _initialized(false)
{
    _config = boost::shared_ptr<Configuration>(new Configuration(_library_path, _config_path, modelicasystem_path));
    _algloopsolverfactory = createAlgLoopSolverFactory(_config->getGlobalSettings());

    #ifdef RUNTIME_PROFILING
    if(MeasureTime::getInstance() != NULL)
    {
        measureTimeFunctionsArray = std::vector<MeasureTimeData>(2); //0 initialize //1 solveInitialSystem
        measuredFunctionStartValues = MeasureTime::getZeroValues();
        measuredFunctionEndValues = MeasureTime::getZeroValues();

        measureTimeFunctionsArray[0] = MeasureTimeData("initialize");
        measureTimeFunctionsArray[1] = MeasureTimeData("solveInitialSystem");
    }
    else
    {
      measureTimeFunctionsArray = std::vector<MeasureTimeData>();
      measuredFunctionStartValues = NULL;
      measuredFunctionEndValues = NULL;
    }
    #endif
}
示例#2
0
SimManager::SimManager(boost::shared_ptr<IMixedSystem> system, Configuration* config)
  : _mixed_system      (system)
  , _config            (config)
  , _timeeventcounter  (NULL)
  , _events            (NULL)
  , _sampleCycles     (NULL)
  ,_cycleCounter     (0)
  ,_resetCycle         (0)
  ,_lastCycleTime     (0)
{
    _solver = _config->createSelectedSolver(system.get());
    _initialization = boost::shared_ptr<Initialization>(new Initialization(boost::dynamic_pointer_cast<ISystemInitialization>(_mixed_system), _solver));

    #ifdef RUNTIME_PROFILING
    if(MeasureTime::getInstance() != NULL)
    {
        measureTimeFunctionsArray = std::vector<MeasureTimeData>(2); //0 runSimulation, initializeSimulation
        MeasureTime::addResultContentBlock(system->getModelName(),"simmanager",&measureTimeFunctionsArray);

        initSimStartValues = MeasureTime::getZeroValues();
        initSimEndValues = MeasureTime::getZeroValues();
        runSimStartValues = MeasureTime::getZeroValues();
        runSimEndValues = MeasureTime::getZeroValues();

        measureTimeFunctionsArray[0] = MeasureTimeData("initializeSimulation");
        measureTimeFunctionsArray[1] = MeasureTimeData("runSimulation");
    }
    else
    {
        measureTimeFunctionsArray = std::vector<MeasureTimeData>();
        initSimStartValues = NULL;
        initSimEndValues = NULL;
        runSimStartValues = NULL;
        runSimEndValues = NULL;
    }
    #endif
}
SolverDefaultImplementation::SolverDefaultImplementation(IMixedSystem* system, ISolverSettings* settings)
    : SimulationMonitor()
    , _system               (system)
    , _settings             (settings)

    , _tInit                (0.0)
    , _tCurrent             (0.0)
    , _tEnd                 (0.0)
    , _tLastSuccess         (0.0)
    , _tLastUnsucess        (0.0)
    , _tLargeStep           (0.0)
    , _h                    (0.0)

    //, _firstCall            (true)
    , _firstStep            (true)

    , _totStps              (0)
    , _accStps              (0)
    , _rejStps              (0)
    , _zeroStps             (0)
    , _zeros                (0)

    , _zeroStatus           (ISolver::UNCHANGED_SIGN)
    , _zeroValInit          (NULL)
    , _dimZeroFunc          (0)
    , _zeroVal              (NULL)
    , _zeroValLastSuccess   (NULL)
    , _events               (NULL)

    , _outputCommand        (IWriteOutput::WRITEOUT)
{
  _state_selection = boost::shared_ptr<SystemStateSelection>(new SystemStateSelection(system));

    #ifdef RUNTIME_PROFILING
    if(MeasureTime::getInstance() != NULL)
    {
        measureTimeFunctionsArray = std::vector<MeasureTimeData>(1); //0 write output
        MeasureTime::addResultContentBlock(system->getModelName(),"solver",&measureTimeFunctionsArray);
        writeFunctionStartValues = MeasureTime::getZeroValues();
        writeFunctionEndValues = MeasureTime::getZeroValues();

        measureTimeFunctionsArray[0] = MeasureTimeData("writeOutput");
    }
    #endif
}