DPsim
|
The Simulation holds a SystemTopology and a Solver. More...
#include <Simulation.h>
Classes | |
struct | LoggerMapping |
Public Types | |
typedef std::shared_ptr< Simulation > | Ptr |
![]() | |
using | Ptr = std::shared_ptr<AttributeList> |
Public Member Functions | |
Simulation (String name, CommandLineArgs &args) | |
Creates simulation with name and CommandLineArgs. | |
Simulation (String name, CPS::Logger::Level logLevel=CPS::Logger::Level::info) | |
Creates simulation with name and log level. | |
virtual | ~Simulation () |
Desctructor. | |
void | setSystem (const CPS::SystemTopology &system) |
void | setTimeStep (Real timeStep) |
void | setFinalTime (Real finalTime) |
void | setDomain (CPS::Domain domain=CPS::Domain::DP) |
void | setSolverType (Solver::Type solverType=Solver::Type::MNA) |
void | setSolverAndComponentBehaviour (Solver::Behaviour behaviour) |
set solver and component to initialization or simulation behaviour | |
void | setDirectLinearSolverImplementation (DirectLinearSolverImpl directImpl) |
void | setDirectLinearSolverConfiguration (const DirectLinearSolverConfiguration &configuration) |
void | setMaxNumberOfIterations (int maxIterations) |
void | doInitFromNodesAndTerminals (Bool f=true) |
void | doSplitSubnets (Bool splitSubnets=true) |
void | setTearingComponents (CPS::IdentifiedObject::List tearComponents=CPS::IdentifiedObject::List()) |
void | setScheduler (const std::shared_ptr< Scheduler > &scheduler) |
Set the scheduling method. | |
void | doFrequencyParallelization (Bool value) |
Compute phasors of different frequencies in parallel. | |
void | doSystemMatrixRecomputation (Bool value) |
void | setLogStepTimes (Bool f) |
void | doSteadyStateInit (Bool f) |
activate steady state initialization | |
void | setSteadStIniTimeLimit (Real v) |
set steady state initialization time limit | |
void | setSteadStIniAccLimit (Real v) |
set steady state initialization accuracy limit | |
void | initialize () |
Create solver instances etc. | |
void | start () |
Start simulation without advancing in time. | |
void | stop () |
Stop simulation including scheduler and interfaces. | |
Real | next () |
Run until next time step. | |
void | run () |
Run simulation until total time is elapsed. | |
virtual Real | step () |
Solve system A * x = z for x and current time. | |
void | sync () const |
Synchronize simulation with remotes by exchanging intial state over interfaces. | |
void | schedule () |
Create the schedule for the independent tasks. | |
void | addEvent (Event::Ptr e) |
Schedule an event in the simulation. | |
void | addLogger (DataLoggerInterface::Ptr logger) |
Add a new data logger. | |
void | logStepTimes (String logName) |
Write step time measurements to log file. | |
void | checkForOverruns (String logName) |
Check for overruns. | |
void | logLUTimes () |
Write LU decomposition times measurements to log file. | |
void | addInterface (Interface::Ptr eint) |
String | name () const |
Real | time () const |
Real | finalTime () const |
Int | timeStepCount () const |
Real | timeStep () const |
DataLogger::List & | loggers () |
std::shared_ptr< Scheduler > | scheduler () |
std::vector< Real > & | stepTimes () |
CPS::AttributeBase::Ptr | getIdObjAttribute (const String &comp, const String &attr) |
CHECK: Can these be deleted? getIdObjAttribute + "**attr =" should suffice. | |
void | logIdObjAttribute (const String &comp, const String &attr) |
void | logAttribute (String name, CPS::AttributeBase::Ptr attr) |
CHECK: Can we store the attribute name / UID intrinsically inside the attribute? | |
![]() | |
const AttributeBase::Map & | attributes () const |
template<typename T> | |
Attribute< T >::Ptr | create (const String &name, T intitialValue=T()) |
template<typename T> | |
Attribute< T >::Ptr | createDynamic (const String &name) |
AttributeBase::Ptr | attribute (const String &name) const |
Return pointer to an attribute. | |
template<typename T> | |
Attribute< T >::Ptr | attributeTyped (const String &name) const |
Return pointer to an attribute. | |
Public Attributes | |
const CPS::Attribute< String >::Ptr | mName |
Simulation name. | |
String | mSolverPluginName |
If there we use a solver plugin, this specifies its name (excluding .so) | |
const CPS::Attribute< Real >::Ptr | mFinalTime |
Final time of the simulation. | |
const CPS::Attribute< Real >::Ptr | mTimeStep |
Simulation timestep. | |
const CPS::Attribute< Bool >::Ptr | mSplitSubnets |
const CPS::Attribute< Bool >::Ptr | mSteadyStateInit |
CPS::Logger::Log | mLog |
Simulation logger. | |
Protected Member Functions | |
void | create () |
Helper function for constructors. | |
template<typename VarType> | |
void | createSolvers () |
Create solvers depending on simulation settings. | |
template<typename VarType> | |
void | createMNASolver () |
Subroutine for MNA only because there are many MNA options. | |
void | prepSchedule () |
Prepare schedule for simulation. | |
Protected Attributes | |
Real | mTime = 0 |
Time variable that is incremented at every step. | |
Int | mTimeStepCount = 0 |
Number of step which have been executed for this simulation. | |
EventQueue | mEvents |
The simulation event queue. | |
CPS::SystemTopology | mSystem |
System list. | |
std::chrono::time_point< std::chrono::steady_clock > | mSimulationStartTimePoint |
Start time point to measure calculation time. | |
std::chrono::time_point< std::chrono::steady_clock > | mSimulationEndTimePoint |
End time point to measure calculation time. | |
std::chrono::duration< double > | mSimulationCalculationTime |
Measured calculation time for simulation. | |
CPS::Logger::Level | mLogLevel |
Simulation log level. | |
std::vector< Real > | mStepTimes |
(Real) time needed for the timesteps | |
Bool | mLogStepTimes = true |
activate collection of step times | |
CPS::Domain | mDomain = CPS::Domain::DP |
Solver::Type | mSolverType = Solver::Type::MNA |
Solver::Behaviour | mSolverBehaviour = Solver::Behaviour::Simulation |
Solver::List | mSolvers |
DirectLinearSolverImpl | mDirectImpl = DirectLinearSolverImpl::Undef |
DirectLinearSolverConfiguration | mDirectLinearSolverConfiguration |
Bool | mInitFromNodesAndTerminals = true |
Bool | mSystemMatrixRecomputation = false |
Enable recomputation of system matrix during simulation. | |
CPS::IdentifiedObject::List | mTearComponents = CPS::IdentifiedObject::List() |
Bool | mFreqParallel = false |
Bool | mInitialized = false |
Real | mSteadStIniTimeLimit = 10 |
steady state initialization time limit | |
Real | mSteadStIniAccLimit = 0.0001 |
steady state initialization accuracy limit | |
std::shared_ptr< Scheduler > | mScheduler |
Scheduler used for task scheduling. | |
CPS::Task::List | mTasks |
List of all tasks to be scheduled. | |
Scheduler::Edges | mTaskInEdges |
Task dependencies as incoming / outgoing edges. | |
Scheduler::Edges | mTaskOutEdges |
std::vector< Interface::Ptr > | mInterfaces |
Vector of Interfaces. | |
DataLoggerInterface::List | mLoggers |
The data loggers. | |
int | mMaxIterations = 10 |
Additional Inherited Members | |
![]() | |
static std::shared_ptr< AttributeList > | make (Args &&...args) |
The Simulation holds a SystemTopology and a Solver.
Every time step, the Simulation calls the step function of the Solver.
Definition at line 31 of file Simulation.h.
typedef std::shared_ptr<Simulation> DPsim::Simulation::Ptr |
Definition at line 33 of file Simulation.h.
Simulation::Simulation | ( | String | name, |
CommandLineArgs & | args ) |
Creates simulation with name and CommandLineArgs.
Definition at line 41 of file Simulation.cpp.
Simulation::Simulation | ( | String | name, |
CPS::Logger::Level | logLevel = CPS::Logger::Level::info ) |
Creates simulation with name and log level.
Definition at line 31 of file Simulation.cpp.
|
inlinevirtual |
Desctructor.
Definition at line 161 of file Simulation.h.
|
inline |
Schedule an event in the simulation.
Definition at line 247 of file Simulation.h.
|
inline |
Definition at line 261 of file Simulation.h.
|
inline |
Add a new data logger.
Definition at line 249 of file Simulation.h.
void Simulation::checkForOverruns | ( | String | logName | ) |
Check for overruns.
Definition at line 411 of file Simulation.cpp.
|
protected |
Helper function for constructors.
Definition at line 53 of file Simulation.cpp.
|
protected |
Subroutine for MNA only because there are many MNA options.
Definition at line 129 of file Simulation.cpp.
|
protected |
Create solvers depending on simulation settings.
Definition at line 88 of file Simulation.cpp.
|
inline |
Compute phasors of different frequencies in parallel.
Definition at line 211 of file Simulation.h.
|
inline |
Definition at line 194 of file Simulation.h.
|
inline |
Definition at line 198 of file Simulation.h.
|
inline |
activate steady state initialization
Definition at line 222 of file Simulation.h.
|
inline |
Definition at line 213 of file Simulation.h.
|
inline |
Definition at line 274 of file Simulation.h.
CPS::AttributeBase::Ptr Simulation::getIdObjAttribute | ( | const String & | comp, |
const String & | attr ) |
CHECK: Can these be deleted? getIdObjAttribute + "**attr =" should suffice.
Definition at line 432 of file Simulation.cpp.
void Simulation::initialize | ( | ) |
Create solver instances etc.
Definition at line 63 of file Simulation.cpp.
void Simulation::logAttribute | ( | String | name, |
CPS::AttributeBase::Ptr | attr ) |
CHECK: Can we store the attribute name / UID intrinsically inside the attribute?
Definition at line 460 of file Simulation.cpp.
|
inline |
Definition at line 277 of file Simulation.h.
void Simulation::logIdObjAttribute | ( | const String & | comp, |
const String & | attr ) |
Definition at line 454 of file Simulation.cpp.
void Simulation::logLUTimes | ( | ) |
Write LU decomposition times measurements to log file.
Definition at line 426 of file Simulation.cpp.
void Simulation::logStepTimes | ( | String | logName | ) |
Write step time measurements to log file.
Definition at line 393 of file Simulation.cpp.
|
inline |
Definition at line 272 of file Simulation.h.
Real Simulation::next | ( | ) |
Run until next time step.
Definition at line 354 of file Simulation.cpp.
|
protected |
Prepare schedule for simulation.
Definition at line 186 of file Simulation.cpp.
void Simulation::run | ( | ) |
Run simulation until total time is elapsed.
Definition at line 363 of file Simulation.cpp.
void Simulation::schedule | ( | ) |
Create the schedule for the independent tasks.
Definition at line 211 of file Simulation.cpp.
|
inline |
Definition at line 278 of file Simulation.h.
|
inline |
Definition at line 185 of file Simulation.h.
|
inline |
Definition at line 181 of file Simulation.h.
|
inline |
Definition at line 171 of file Simulation.h.
|
inline |
Definition at line 169 of file Simulation.h.
|
inline |
If logStepTimes is enabled, the time needed for every timesteps is logged and can be written to a file or the console using logStepTimes()
Definition at line 218 of file Simulation.h.
|
inline |
Definition at line 190 of file Simulation.h.
|
inline |
Set the scheduling method.
Definition at line 207 of file Simulation.h.
|
inline |
set solver and component to initialization or simulation behaviour
Definition at line 177 of file Simulation.h.
|
inline |
Definition at line 173 of file Simulation.h.
|
inline |
set steady state initialization accuracy limit
Definition at line 226 of file Simulation.h.
|
inline |
set steady state initialization time limit
Definition at line 224 of file Simulation.h.
|
inline |
Definition at line 165 of file Simulation.h.
|
inline |
Definition at line 202 of file Simulation.h.
|
inline |
Definition at line 167 of file Simulation.h.
void Simulation::start | ( | ) |
Start simulation without advancing in time.
Definition at line 302 of file Simulation.cpp.
|
virtual |
Solve system A * x = z for x and current time.
Definition at line 373 of file Simulation.cpp.
|
inline |
Definition at line 279 of file Simulation.h.
void Simulation::stop | ( | ) |
Stop simulation including scheduler and interfaces.
Definition at line 334 of file Simulation.cpp.
void Simulation::sync | ( | ) | const |
Synchronize simulation with remotes by exchanging intial state over interfaces.
Definition at line 174 of file Simulation.cpp.
|
inline |
Definition at line 273 of file Simulation.h.
|
inline |
Definition at line 276 of file Simulation.h.
|
inline |
Definition at line 275 of file Simulation.h.
|
protected |
Definition at line 90 of file Simulation.h.
|
protected |
Definition at line 92 of file Simulation.h.
|
protected |
Definition at line 82 of file Simulation.h.
|
protected |
The simulation event queue.
Definition at line 61 of file Simulation.h.
const CPS::Attribute<Real>::Ptr DPsim::Simulation::mFinalTime |
Final time of the simulation.
Definition at line 40 of file Simulation.h.
|
protected |
Determines if the system matrix is split into several smaller matrices, one for each frequency. This can only be done if the network is composed of linear components that do no create cross frequency coupling.
Definition at line 106 of file Simulation.h.
|
protected |
Definition at line 94 of file Simulation.h.
|
protected |
Definition at line 108 of file Simulation.h.
|
protected |
Vector of Interfaces.
Definition at line 125 of file Simulation.h.
CPS::Logger::Log DPsim::Simulation::mLog |
Simulation logger.
Definition at line 151 of file Simulation.h.
|
protected |
The data loggers.
Definition at line 135 of file Simulation.h.
|
protected |
Simulation log level.
Definition at line 74 of file Simulation.h.
|
protected |
activate collection of step times
Definition at line 78 of file Simulation.h.
|
protected |
Definition at line 147 of file Simulation.h.
const CPS::Attribute<String>::Ptr DPsim::Simulation::mName |
Simulation name.
Definition at line 36 of file Simulation.h.
|
protected |
Scheduler used for task scheduling.
Definition at line 118 of file Simulation.h.
|
protected |
Measured calculation time for simulation.
Definition at line 70 of file Simulation.h.
|
protected |
End time point to measure calculation time.
Definition at line 68 of file Simulation.h.
|
protected |
Start time point to measure calculation time.
Definition at line 66 of file Simulation.h.
|
protected |
Definition at line 86 of file Simulation.h.
String DPsim::Simulation::mSolverPluginName |
If there we use a solver plugin, this specifies its name (excluding .so)
Definition at line 38 of file Simulation.h.
|
protected |
Definition at line 88 of file Simulation.h.
|
protected |
Definition at line 84 of file Simulation.h.
const CPS::Attribute<Bool>::Ptr DPsim::Simulation::mSplitSubnets |
Determines if the network should be split into subnetworks at decoupling lines. If the system is split, each subsystem is solved by a dedicated MNA solver.
Definition at line 48 of file Simulation.h.
|
protected |
steady state initialization accuracy limit
Definition at line 114 of file Simulation.h.
|
protected |
steady state initialization time limit
Definition at line 112 of file Simulation.h.
const CPS::Attribute<Bool>::Ptr DPsim::Simulation::mSteadyStateInit |
Determines if steady-state initialization should be executed prior to the simulation. By default the initialization is disabled.
Definition at line 53 of file Simulation.h.
|
protected |
(Real) time needed for the timesteps
Definition at line 76 of file Simulation.h.
|
protected |
System list.
Definition at line 63 of file Simulation.h.
|
protected |
Enable recomputation of system matrix during simulation.
Definition at line 96 of file Simulation.h.
|
protected |
Task dependencies as incoming / outgoing edges.
Definition at line 122 of file Simulation.h.
|
protected |
Definition at line 122 of file Simulation.h.
|
protected |
List of all tasks to be scheduled.
Definition at line 120 of file Simulation.h.
|
protected |
If tearing components exist, the Diakoptics solver is selected automatically.
Definition at line 100 of file Simulation.h.
|
protected |
Time variable that is incremented at every step.
Definition at line 57 of file Simulation.h.
const CPS::Attribute<Real>::Ptr DPsim::Simulation::mTimeStep |
Simulation timestep.
Definition at line 42 of file Simulation.h.
|
protected |
Number of step which have been executed for this simulation.
Definition at line 59 of file Simulation.h.