14 #include "dpsim-models/Components.h"
15 #include "dpsim-models/SystemTopology.h"
16 #include <dpsim/Scheduler.h>
17 #include <dpsim/Solver.h>
47 CPS::SparseMatrixCompRow
mY;
61 std::vector<std::shared_ptr<CPS::SP::Ph1::SolidStateTransformer>>
64 std::vector<std::shared_ptr<CPS::SP::Ph1::SynchronGenerator>>
67 std::vector<std::shared_ptr<CPS::SP::Ph1::Load>>
mLoads;
69 std::vector<std::shared_ptr<CPS::SP::Ph1::PiLine>>
mLines;
71 std::vector<std::shared_ptr<CPS::SP::Ph1::Shunt>>
mShunts;
75 std::vector<std::shared_ptr<CPS::SP::Ph1::AvVoltageSourceInverterDQ>>
97 bool keep_last_solution =
false) = 0;
123 CPS::Real
G(
int i,
int j);
125 CPS::Real
B(
int i,
int j);
131 CPS::String
logVector(std::vector<CPS::UInt> indexVector) {
132 std::stringstream result;
133 std::copy(indexVector.begin(), indexVector.end(),
134 std::ostream_iterator<CPS::UInt>(result,
" "));
138 CPS::Task::List
getTasks()
override;
143 CPS::Logger::Level logLevel);
151 CPS::PowerflowBusType powerFlowBusType);
158 : Task(solver.
mName +
".Solve"), mSolver(solver) {
159 mModifiedAttributes.push_back(Scheduler::external);
162 void execute(Real time, Int timeStepCount);
Tasks to be defined by every component.
Solver class using the nonlinear powerflow (PF) formulation.
void determinePFBusType()
Determine bus type for all buses.
std::vector< std::shared_ptr< CPS::SP::Ph1::Load > > mLoads
Vector of load components.
CPS::TopologicalNode::List mPQBuses
Vector of nodes characterized as PQ buses.
UInt mNumPQBuses
Number of PQ nodes.
UInt mNumVDBuses
Number of PV nodes.
Real mTolerance
Solver tolerance.
CPS::String logVector(std::vector< CPS::UInt > indexVector)
Logging for integer vectors.
std::vector< std::shared_ptr< CPS::SP::Ph1::PiLine > > mLines
Vector of line components.
CPS::Task::List getTasks() override
Get tasks for scheduler.
void assignMatrixNodeIndices()
Assignment of matrix indices for nodes.
std::vector< CPS::UInt > mVDBusIndices
Vector with indices of VD buses.
void initializeComponents()
Initialization of individual components.
std::vector< std::shared_ptr< CPS::SP::Ph1::SynchronGenerator > > mSynchronGenerators
Vector of synchronous generator components.
std::vector< CPS::UInt > mPQBusIndices
Vector with indices of PQ buses.
void modifyPowerFlowBusComponent(CPS::String name, CPS::PowerflowBusType powerFlowBusType)
Allows to modify the powerflow bus type of a specific component.
std::vector< std::shared_ptr< CPS::SP::Ph1::NetworkInjection > > mExternalGrids
Vector of external grid components.
std::vector< std::shared_ptr< CPS::SP::Ph1::SolidStateTransformer > > mSolidStateTransformers
Vector of solid state transformer components.
std::vector< CPS::UInt > mPVBusIndices
Vector with indices of PV buses.
void setVDNode(CPS::String name)
Set a node to VD using its name.
std::vector< std::shared_ptr< CPS::SP::Ph1::Transformer > > mTransformers
Vector of transformer components.
std::vector< std::shared_ptr< CPS::SP::Ph1::Shunt > > mShunts
Vector of shunt components.
CPS::Bool checkConvergence()
Check whether below tolerance.
CPS::Matrix mJ
Jacobian matrix.
CPS::UInt mMaxIterations
Maximum number of iterations.
CPS::Vector mX
Solution vector.
std::vector< std::shared_ptr< CPS::SP::Ph1::AvVoltageSourceInverterDQ > > mAverageVoltageSourceInverters
Vector of average voltage source inverters.
CPS::Bool solutionInitialized
Flag whether solution vectors are initialized.
CPS::Real mBaseApparentPower
Base power of per-unit system.
void setBaseApparentPower()
Set apparent base power of per-unit system.
virtual void calculateMismatch()=0
Calculate mismatch.
CPS::SparseMatrixCompRow mY
Admittance matrix.
CPS::Bool solutionComplexInitialized
Flag whether complex solution vectors are initialized.
UInt mNumPVBuses
Number of PV nodes.
CPS::Real B(int i, int j)
Gets the imaginary part of admittance matrix element.
void composeAdmittanceMatrix()
Compose admittance matrix.
CPS::Bool isConverged
Convergence flag.
CPS::Vector mF
Vector of mismatch values.
CPS::UInt mIterations
Actual number of iterations.
PFSolver(CPS::String name, CPS::SystemTopology system, Real timeStep, CPS::Logger::Level logLevel)
Constructor to be used in simulation examples.
CPS::SystemTopology mSystem
System list.
virtual void calculateJacobian()=0
Calculate the Jacobian.
void determineNodeBaseVoltages()
Determine base voltages for each node.
void setSolverAndComponentBehaviour(Solver::Behaviour behaviour) override
set solver and component to initialization or simulation behaviour
std::map< CPS::TopologicalNode::Ptr, CPS::Real > mBaseVoltageAtNode
Map providing determined base voltages for each node.
virtual void setSolution()=0
Set final solution.
void initialize() override
Initialization of the solver.
virtual void generateInitialSolution(Real time, bool keep_last_solution=false)=0
Generate initial solution for current time step.
virtual void updateSolution()=0
Update solution in each iteration.
Bool solvePowerflow()
Solves the powerflow problem.
CPS::TopologicalNode::List mVDBuses
Vector of nodes characterized as VD buses.
CPS::TopologicalNode::List mPVBuses
Vector of nodes characterized as PV buses.
UInt mNumUnknowns
Number of unknowns, defining system dimension.
CPS::Real G(int i, int j)
Gets the real part of admittance matrix element.
std::vector< CPS::UInt > mPQPVBusIndices
Vector with indices of both PQ and PV buses.
Base class for more specific solvers such as MNA, ODE or IDA.
String mName
Name for logging.