|
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 | 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 | 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 | |
| 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 | mPFKeepLastSolution |
| const CPS::Attribute< Real >::Ptr | mPFBaseApparentPowerFallback |
| const CPS::Attribute< CPS::UInt >::Ptr | mPFMaxIterations |
| Maximum number of Newton-Raphson iterations for the PF solver. | |
| const CPS::Attribute< Bool >::Ptr | mPFSolverUseSparse |
| 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. | |
| Bool | mStateSpaceExtraction = false |
| Enable extraction of the MNA-coupled discrete-time state matrix. | |
| 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 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 48 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 34 of file Simulation.cpp.
|
inlinevirtual |
Desctructor.
Definition at line 177 of file Simulation.h.
|
inline |
Schedule an event in the simulation.
Definition at line 283 of file Simulation.h.
|
inline |
Definition at line 297 of file Simulation.h.
|
inline |
Add a new data logger.
Definition at line 285 of file Simulation.h.
| void Simulation::checkForOverruns | ( | String | logName | ) |
Check for overruns.
Definition at line 480 of file Simulation.cpp.
|
protected |
Helper function for constructors.
Definition at line 64 of file Simulation.cpp.
|
protected |
Subroutine for MNA only because there are many MNA options.
Definition at line 164 of file Simulation.cpp.
|
protected |
Create solvers depending on simulation settings.
Definition at line 99 of file Simulation.cpp.
|
inline |
Compute phasors of different frequencies in parallel.
Definition at line 227 of file Simulation.h.
|
inline |
Definition at line 210 of file Simulation.h.
|
inline |
Definition at line 214 of file Simulation.h.
|
inline |
Enable extraction of the MNA-coupled discrete-time state matrix.
Definition at line 233 of file Simulation.h.
|
inline |
activate steady state initialization
Definition at line 242 of file Simulation.h.
|
inline |
Definition at line 229 of file Simulation.h.
|
inline |
Definition at line 310 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 520 of file Simulation.cpp.
| Real Simulation::getPFBaseApparentPowerFallback | ( | ) | const |
Definition at line 355 of file Simulation.cpp.
| Bool Simulation::getPFKeepLastSolution | ( | ) | const |
Definition at line 349 of file Simulation.cpp.
| CPS::UInt Simulation::getPFMaxIterations | ( | ) | const |
Definition at line 363 of file Simulation.cpp.
| Bool Simulation::getPFSolverUseSparse | ( | ) | const |
Definition at line 369 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 502 of file Simulation.cpp.
| void Simulation::initialize | ( | ) |
Create solver instances etc.
Definition at line 74 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 548 of file Simulation.cpp.
|
inline |
Definition at line 313 of file Simulation.h.
| void Simulation::logIdObjAttribute | ( | const String & | comp, |
| const String & | attr ) |
Definition at line 542 of file Simulation.cpp.
| void Simulation::logLUTimes | ( | ) |
Write LU decomposition times measurements to log file.
Definition at line 495 of file Simulation.cpp.
| void Simulation::logStepTimes | ( | String | logName | ) |
Write step time measurements to log file.
Definition at line 462 of file Simulation.cpp.
|
inline |
Definition at line 308 of file Simulation.h.
| Real Simulation::next | ( | ) |
Run until next time step.
Definition at line 423 of file Simulation.cpp.
|
protected |
Prepare schedule for simulation.
Definition at line 229 of file Simulation.cpp.
| void Simulation::run | ( | ) |
Run simulation until total time is elapsed.
Definition at line 432 of file Simulation.cpp.
| void Simulation::schedule | ( | ) |
Create the schedule for the independent tasks.
Definition at line 254 of file Simulation.cpp.
|
inline |
Definition at line 314 of file Simulation.h.
|
inline |
Definition at line 201 of file Simulation.h.
|
inline |
Definition at line 197 of file Simulation.h.
|
inline |
Definition at line 187 of file Simulation.h.
|
inline |
Definition at line 185 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 238 of file Simulation.h.
|
inline |
Definition at line 206 of file Simulation.h.
| void Simulation::setPFBaseApparentPowerFallback | ( | Real | value | ) |
Definition at line 351 of file Simulation.cpp.
| void Simulation::setPFKeepLastSolution | ( | Bool | value | ) |
Definition at line 345 of file Simulation.cpp.
| void Simulation::setPFMaxIterations | ( | CPS::UInt | value | ) |
Definition at line 359 of file Simulation.cpp.
| void Simulation::setPFSolverUseSparse | ( | Bool | value | ) |
Definition at line 365 of file Simulation.cpp.
|
inline |
Set the scheduling method.
Definition at line 223 of file Simulation.h.
|
inline |
set solver and component to initialization or simulation behaviour
Definition at line 193 of file Simulation.h.
|
inline |
Definition at line 189 of file Simulation.h.
|
inline |
set steady state initialization accuracy limit
Definition at line 246 of file Simulation.h.
|
inline |
set steady state initialization time limit
Definition at line 244 of file Simulation.h.
|
inline |
Definition at line 181 of file Simulation.h.
|
inline |
Definition at line 218 of file Simulation.h.
|
inline |
Definition at line 183 of file Simulation.h.
| void Simulation::start | ( | ) |
Start simulation without advancing in time.
Definition at line 371 of file Simulation.cpp.
|
virtual |
Solve system A * x = z for x and current time.
Definition at line 442 of file Simulation.cpp.
|
inline |
Definition at line 315 of file Simulation.h.
| void Simulation::stop | ( | ) |
Stop simulation including scheduler and interfaces.
Definition at line 403 of file Simulation.cpp.
| void Simulation::sync | ( | ) | const |
Synchronize simulation with remotes by exchanging intial state over interfaces.
Definition at line 217 of file Simulation.cpp.
|
inline |
Definition at line 309 of file Simulation.h.
|
inline |
Definition at line 312 of file Simulation.h.
|
inline |
Definition at line 311 of file Simulation.h.
|
protected |
Definition at line 104 of file Simulation.h.
|
protected |
Definition at line 106 of file Simulation.h.
|
protected |
Definition at line 96 of file Simulation.h.
|
protected |
The simulation event queue.
Definition at line 75 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 122 of file Simulation.h.
|
protected |
Definition at line 108 of file Simulation.h.
|
protected |
Definition at line 124 of file Simulation.h.
|
protected |
Vector of Interfaces.
Definition at line 141 of file Simulation.h.
| CPS::Logger::Log DPsim::Simulation::mLog |
Simulation logger.
Definition at line 167 of file Simulation.h.
|
protected |
The data loggers.
Definition at line 151 of file Simulation.h.
|
protected |
Simulation log level.
Definition at line 88 of file Simulation.h.
|
protected |
activate collection of step times
Definition at line 92 of file Simulation.h.
|
protected |
Definition at line 163 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<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 134 of file Simulation.h.
|
protected |
Measured calculation time for simulation.
Definition at line 84 of file Simulation.h.
|
protected |
End time point to measure calculation time.
Definition at line 82 of file Simulation.h.
|
protected |
Start time point to measure calculation time.
Definition at line 80 of file Simulation.h.
|
protected |
Definition at line 100 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 102 of file Simulation.h.
|
protected |
Definition at line 98 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 62 of file Simulation.h.
|
protected |
Enable extraction of the MNA-coupled discrete-time state matrix.
Definition at line 112 of file Simulation.h.
|
protected |
steady state initialization accuracy limit
Definition at line 130 of file Simulation.h.
|
protected |
steady state initialization time limit
Definition at line 128 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 67 of file Simulation.h.
|
protected |
(Real) time needed for the timesteps
Definition at line 90 of file Simulation.h.
|
protected |
System list.
Definition at line 77 of file Simulation.h.
|
protected |
Enable recomputation of system matrix during simulation.
Definition at line 110 of file Simulation.h.
|
protected |
Task dependencies as incoming / outgoing edges.
Definition at line 138 of file Simulation.h.
|
protected |
Definition at line 138 of file Simulation.h.
|
protected |
List of all tasks to be scheduled.
Definition at line 136 of file Simulation.h.
|
protected |
If tearing components exist, the Diakoptics solver is selected automatically.
Definition at line 116 of file Simulation.h.
|
protected |
Time variable that is incremented at every step.
Definition at line 71 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 73 of file Simulation.h.