DPsim
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
DPsim::Simulation Class Reference

The Simulation holds a SystemTopology and a Solver. More...

#include <Simulation.h>

Inheritance diagram for DPsim::Simulation:
[legend]
Collaboration diagram for DPsim::Simulation:
[legend]

Classes

struct  LoggerMapping
 

Public Types

typedef std::shared_ptr< SimulationPtr
 
- 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 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 (DataLogger::Ptr logger)
 Add a new data logger.
 
void logStepTimes (String logName)
 Write step time measurements to log file.
 
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< Schedulerscheduler ()
 
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?
 
- 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 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
 
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< SchedulermScheduler
 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.
 
DataLogger::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)
 

Detailed Description

The Simulation holds a SystemTopology and a Solver.

Every time step, the Simulation calls the step function of the Solver.

Definition at line 34 of file Simulation.h.

Member Data Documentation

◆ mFreqParallel

Bool DPsim::Simulation::mFreqParallel = false
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 107 of file Simulation.h.

◆ mMaxIterations

int DPsim::Simulation::mMaxIterations = 10
protected

SynGen Interface

Definition at line 148 of file Simulation.h.

◆ mSplitSubnets

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 51 of file Simulation.h.

◆ mSteadyStateInit

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 56 of file Simulation.h.

◆ mTearComponents

CPS::IdentifiedObject::List DPsim::Simulation::mTearComponents = CPS::IdentifiedObject::List()
protected

If tearing components exist, the Diakoptics solver is selected automatically.

Definition at line 101 of file Simulation.h.


The documentation for this class was generated from the following files: