|
DPsim
|
The Simulation holds a SystemTopology and a Solver. More...
#include <Simulation.h>
Classes | |
| struct | LoggerMapping |
Public Types | |
| typedef std::shared_ptr< Simulation > | Ptr |
Public Types inherited from CPS::AttributeList | |
| 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 | setSystemMatrixRecomputationMode (Solver::SystemMatrixRecomputationMode mode) |
| Set the system-matrix recomputation mode. | |
| void | doSystemMatrixRecomputation (Bool value) |
| void | doStateSpaceExtraction (Bool value=true) |
| Enable extraction of the MNA-coupled discrete-time state matrix. | |
| 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 | setPFKeepLastSolution (Bool value) |
| Bool | getPFKeepLastSolution () const |
| void | setPFBaseApparentPowerFallback (Real value) |
| Real | getPFBaseApparentPowerFallback () const |
| void | setPFMaxIterations (CPS::UInt value) |
| CPS::UInt | getPFMaxIterations () const |
| void | setPFSolverUseSparse (Bool value) |
| Bool | getPFSolverUseSparse () const |
| void | setZeroSkipping (Bool enabled) |
| Enable or disable exact-zero skipping in matrix assembly and power flow. | |
| Bool | getZeroSkipping () const |
| void | setPFSolverEnforceReactiveLimits (Bool value) |
| Bool | getPFSolverEnforceReactiveLimits () const |
| void | setPFSolverBaseVoltageLooseTolerance (Real tolerance) |
| Real | getPFSolverBaseVoltageLooseTolerance () const |
| void | setPFSolverBaseVoltageStrictTolerance (Real tolerance) |
| Real | getPFSolverBaseVoltageStrictTolerance () const |
| 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 () |
| const MNAStateSpaceExtractor & | getStateSpaceExtractor (UInt solverIndex=0) const |
| 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? | |
Public Member Functions inherited from CPS::AttributeList | |
| AttributeList () | |
| 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. | |
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 = false |
| 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 |
| Solver::SystemMatrixRecomputationMode | mSystemMatrixRecomputationMode |
| Requested system-matrix recomputation mode. | |
| Bool | mStateSpaceExtraction = false |
| Enable extraction of the MNA-coupled discrete-time state matrix. | |
| Bool | mZeroSkipping = true |
| Skip exact zero matrix contributions. Enabled by default for all solvers. | |
| CPS::IdentifiedObject::List | mTearComponents = CPS::IdentifiedObject::List() |
| Bool | mFreqParallel = false |
| Bool | mInitialized = false |
| Real | mSteadStIniTimeLimit = Solver::DEFAULT_STEAD_ST_INI_TIME_LIMIT |
| steady state initialization time limit | |
| Real | mSteadStIniAccLimit = Solver::DEFAULT_STEAD_ST_INI_ACC_LIMIT |
| 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 Public Member Functions inherited from SharedFactory< AttributeList > | |
| 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 53 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 36 of file Simulation.cpp.
|
inlinevirtual |
Desctructor.
Definition at line 190 of file Simulation.h.
|
inline |
Schedule an event in the simulation.
Definition at line 321 of file Simulation.h.
|
inline |
Definition at line 335 of file Simulation.h.
|
inline |
Add a new data logger.
Definition at line 323 of file Simulation.h.
| void Simulation::checkForOverruns | ( | String | logName | ) |
Check for overruns.
Definition at line 541 of file Simulation.cpp.
|
protected |
Helper function for constructors.
Definition at line 72 of file Simulation.cpp.
|
protected |
Subroutine for MNA only because there are many MNA options.
Definition at line 176 of file Simulation.cpp.
|
protected |
Create solvers depending on simulation settings.
Definition at line 107 of file Simulation.cpp.
|
inline |
Compute phasors of different frequencies in parallel.
Definition at line 240 of file Simulation.h.
|
inline |
Definition at line 223 of file Simulation.h.
|
inline |
Definition at line 227 of file Simulation.h.
|
inline |
Enable extraction of the MNA-coupled discrete-time state matrix.
Definition at line 254 of file Simulation.h.
|
inline |
activate steady state initialization
Definition at line 263 of file Simulation.h.
|
inline |
DEPRECATED: Enable or disable system-matrix recomputation explicitly. This compatibility method maps true to Enabled and false to Disabled.
Definition at line 248 of file Simulation.h.
|
inline |
Definition at line 348 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 585 of file Simulation.cpp.
| Real Simulation::getPFBaseApparentPowerFallback | ( | ) | const |
Definition at line 370 of file Simulation.cpp.
| Bool Simulation::getPFKeepLastSolution | ( | ) | const |
Definition at line 364 of file Simulation.cpp.
| CPS::UInt Simulation::getPFMaxIterations | ( | ) | const |
Definition at line 378 of file Simulation.cpp.
| Real Simulation::getPFSolverBaseVoltageLooseTolerance | ( | ) | const |
Definition at line 398 of file Simulation.cpp.
| Real Simulation::getPFSolverBaseVoltageStrictTolerance | ( | ) | const |
Definition at line 406 of file Simulation.cpp.
| Bool Simulation::getPFSolverEnforceReactiveLimits | ( | ) | const |
Definition at line 390 of file Simulation.cpp.
| Bool Simulation::getPFSolverUseSparse | ( | ) | const |
Definition at line 384 of file Simulation.cpp.
| const MNAStateSpaceExtractor & Simulation::getStateSpaceExtractor | ( | UInt | solverIndex = 0 | ) | const |
Read-only access to the MNA state-space extractor of one solver.
If the system is split into subnetworks, one MNA solver is created per subnet. The solverIndex selects the corresponding solver.
Definition at line 563 of file Simulation.cpp.
|
inline |
Definition at line 288 of file Simulation.h.
| void Simulation::initialize | ( | ) |
Create solver instances etc.
Definition at line 82 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 613 of file Simulation.cpp.
|
inline |
Definition at line 351 of file Simulation.h.
Definition at line 607 of file Simulation.cpp.
| void Simulation::logLUTimes | ( | ) |
Write LU decomposition times measurements to log file.
Definition at line 556 of file Simulation.cpp.
| void Simulation::logStepTimes | ( | String | logName | ) |
Write step time measurements to log file.
Definition at line 523 of file Simulation.cpp.
|
inline |
Definition at line 346 of file Simulation.h.
| Real Simulation::next | ( | ) |
Run until next time step.
Definition at line 462 of file Simulation.cpp.
|
protected |
Prepare schedule for simulation.
Definition at line 244 of file Simulation.cpp.
| void Simulation::run | ( | ) |
Run simulation until total time is elapsed.
Definition at line 471 of file Simulation.cpp.
| void Simulation::schedule | ( | ) |
Create the schedule for the independent tasks.
Definition at line 269 of file Simulation.cpp.
|
inline |
Definition at line 352 of file Simulation.h.
|
inline |
Definition at line 214 of file Simulation.h.
|
inline |
Definition at line 210 of file Simulation.h.
|
inline |
Definition at line 200 of file Simulation.h.
|
inline |
Definition at line 198 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 259 of file Simulation.h.
|
inline |
Definition at line 219 of file Simulation.h.
| void Simulation::setPFBaseApparentPowerFallback | ( | Real | value | ) |
Definition at line 366 of file Simulation.cpp.
| void Simulation::setPFKeepLastSolution | ( | Bool | value | ) |
Definition at line 360 of file Simulation.cpp.
| void Simulation::setPFMaxIterations | ( | CPS::UInt | value | ) |
Definition at line 374 of file Simulation.cpp.
| void Simulation::setPFSolverBaseVoltageLooseTolerance | ( | Real | tolerance | ) |
Definition at line 394 of file Simulation.cpp.
| void Simulation::setPFSolverBaseVoltageStrictTolerance | ( | Real | tolerance | ) |
Definition at line 402 of file Simulation.cpp.
| void Simulation::setPFSolverEnforceReactiveLimits | ( | Bool | value | ) |
Definition at line 386 of file Simulation.cpp.
| void Simulation::setPFSolverUseSparse | ( | Bool | value | ) |
Definition at line 380 of file Simulation.cpp.
|
inline |
Set the scheduling method.
Definition at line 236 of file Simulation.h.
|
inline |
set solver and component to initialization or simulation behaviour
Definition at line 206 of file Simulation.h.
|
inline |
Definition at line 202 of file Simulation.h.
|
inline |
set steady state initialization accuracy limit
Definition at line 267 of file Simulation.h.
|
inline |
set steady state initialization time limit
Definition at line 265 of file Simulation.h.
|
inline |
Definition at line 194 of file Simulation.h.
|
inline |
Set the system-matrix recomputation mode.
Definition at line 243 of file Simulation.h.
|
inline |
Definition at line 231 of file Simulation.h.
|
inline |
Definition at line 196 of file Simulation.h.
|
inline |
Enable or disable exact-zero skipping in matrix assembly and power flow.
Definition at line 286 of file Simulation.h.
| void Simulation::start | ( | ) |
Start simulation without advancing in time.
Definition at line 410 of file Simulation.cpp.
|
virtual |
Solve system A * x = z for x and current time.
Definition at line 503 of file Simulation.cpp.
|
inline |
Definition at line 353 of file Simulation.h.
| void Simulation::stop | ( | ) |
Stop simulation including scheduler and interfaces.
Definition at line 442 of file Simulation.cpp.
| void Simulation::sync | ( | ) | const |
Synchronize simulation with remotes by exchanging intial state over interfaces.
Definition at line 232 of file Simulation.cpp.
|
inline |
Definition at line 347 of file Simulation.h.
|
inline |
Definition at line 350 of file Simulation.h.
|
inline |
Definition at line 349 of file Simulation.h.
|
protected |
Definition at line 114 of file Simulation.h.
|
protected |
Definition at line 116 of file Simulation.h.
|
protected |
Definition at line 106 of file Simulation.h.
|
protected |
The simulation event queue.
Definition at line 85 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 135 of file Simulation.h.
|
protected |
Definition at line 118 of file Simulation.h.
|
protected |
Definition at line 137 of file Simulation.h.
|
protected |
Vector of Interfaces.
Definition at line 154 of file Simulation.h.
| CPS::Logger::Log DPsim::Simulation::mLog |
Simulation logger.
Definition at line 180 of file Simulation.h.
|
protected |
The data loggers.
Definition at line 164 of file Simulation.h.
|
protected |
Simulation log level.
Definition at line 98 of file Simulation.h.
|
protected |
activate collection of step times
Definition at line 102 of file Simulation.h.
|
protected |
Definition at line 176 of file Simulation.h.
| const CPS::Attribute<String>::Ptr DPsim::Simulation::mName |
Simulation name.
Definition at line 36 of file Simulation.h.
| const CPS::Attribute<Real>::Ptr DPsim::Simulation::mPFBaseApparentPowerFallback |
Fallback base apparent power used by the PF solver when no generator or transformer rating is available to derive it from.
Definition at line 48 of file Simulation.h.
| const CPS::Attribute<Real>::Ptr DPsim::Simulation::mPFBaseVoltageLooseTolerance |
Loose tolerance for a zone's Load base-voltage vs. its rating; default 0.1.
Definition at line 63 of file Simulation.h.
| const CPS::Attribute<Real>::Ptr DPsim::Simulation::mPFBaseVoltageStrictTolerance |
Strict tolerance between authoritative base-voltage sources in a zone; default 0.01.
Definition at line 66 of file Simulation.h.
| const CPS::Attribute<Bool>::Ptr DPsim::Simulation::mPFEnforceReactiveLimits |
Enforce generator reactive-power limits in the powerflow via PV<->PQ switching. Default false; opt in via setPFSolverEnforceReactiveLimits(true).
Definition at line 60 of file Simulation.h.
| const CPS::Attribute<Bool>::Ptr DPsim::Simulation::mPFKeepLastSolution |
Definition at line 44 of file Simulation.h.
| const CPS::Attribute<CPS::UInt>::Ptr DPsim::Simulation::mPFMaxIterations |
Maximum number of Newton-Raphson iterations for the PF solver.
Definition at line 51 of file Simulation.h.
| const CPS::Attribute<Bool>::Ptr DPsim::Simulation::mPFSolverUseSparse |
Use the sparse-Jacobian powerflow solver (scales to large grids). Default false (dense solver); opt in via setPFSolverUseSparse(true). Ignored (dense solver used) if no sparse linear solver is available.
Definition at line 56 of file Simulation.h.
|
protected |
Scheduler used for task scheduling.
Definition at line 147 of file Simulation.h.
|
protected |
Measured calculation time for simulation.
Definition at line 94 of file Simulation.h.
|
protected |
End time point to measure calculation time.
Definition at line 92 of file Simulation.h.
|
protected |
Start time point to measure calculation time.
Definition at line 90 of file Simulation.h.
|
protected |
Definition at line 110 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 112 of file Simulation.h.
|
protected |
Definition at line 108 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 72 of file Simulation.h.
|
protected |
Enable extraction of the MNA-coupled discrete-time state matrix.
Definition at line 123 of file Simulation.h.
|
protected |
steady state initialization accuracy limit
Definition at line 143 of file Simulation.h.
|
protected |
steady state initialization time limit
Definition at line 141 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 77 of file Simulation.h.
|
protected |
(Real) time needed for the timesteps
Definition at line 100 of file Simulation.h.
|
protected |
System list.
Definition at line 87 of file Simulation.h.
|
protected |
Requested system-matrix recomputation mode.
Definition at line 120 of file Simulation.h.
|
protected |
Task dependencies as incoming / outgoing edges.
Definition at line 151 of file Simulation.h.
|
protected |
Definition at line 151 of file Simulation.h.
|
protected |
List of all tasks to be scheduled.
Definition at line 149 of file Simulation.h.
|
protected |
If tearing components exist, the Diakoptics solver is selected automatically.
Definition at line 129 of file Simulation.h.
|
protected |
Time variable that is incremented at every step.
Definition at line 81 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 83 of file Simulation.h.
|
protected |
Skip exact zero matrix contributions. Enabled by default for all solvers.
Definition at line 125 of file Simulation.h.