18#ifndef ELECTRICCALCULATION_H
19#define ELECTRICCALCULATION_H
24#include "../elements/Element.h"
25#include "../elements/powerElement/Bus.h"
26#include "../elements/powerElement/Capacitor.h"
27#include "../elements/powerElement/HarmCurrent.h"
28#include "../elements/powerElement/IndMotor.h"
29#include "../elements/powerElement/Inductor.h"
30#include "../elements/powerElement/Line.h"
31#include "../elements/powerElement/Load.h"
32#include "../elements/powerElement/PowerElement.h"
33#include "../elements/powerElement/SyncGenerator.h"
34#include "../elements/powerElement/SyncMotor.h"
35#include "../elements/powerElement/Transformer.h"
36#include "../elements/powerElement/EMTElement.h"
38#include "../utils/PropertiesData.h"
142 virtual bool GetYBus(std::vector<std::vector<std::complex<double> > >& yBus,
143 double systemPowerBase,
145 bool includeSyncMachines =
false,
146 bool allLoadsAsImpedances =
false,
147 bool usePowerFlowVoltagesOnImpedances =
false);
155 virtual bool InvertMatrix(std::vector<std::vector<std::complex<double> > > matrix,
156 std::vector<std::vector<std::complex<double> > >& inverse);
167 std::vector<std::complex<double> > power,
168 std::vector<BusType> busType,
169 std::vector<ReactiveLimits> reactiveLimit,
170 double systemPowerBase);
179 void ABCtoDQ0(std::complex<double> complexValue,
double angle,
double& dValue,
double& qValue);
188 void DQ0toABC(
double dValue,
double qValue,
double angle, std::complex<double>& complexValue);
196 std::vector<std::complex<double> >
GaussianElimination(std::vector<std::vector<std::complex<double> > > matrix,
197 std::vector<std::complex<double> > array);
205 std::vector<double>
GaussianElimination(std::vector<std::vector<double> > matrix, std::vector<double> array);
220 std::vector<std::complex<double> >
ComplexMatrixTimesVector(std::vector<std::vector<std::complex<double> > > matrix,
221 std::vector<std::complex<double> > vector);
230 std::vector<std::vector<std::complex<double> > >& matrixL,
231 std::vector<std::vector<std::complex<double> > >& matrixU);
240 std::vector<std::complex<double> >
LUEvaluate(std::vector<std::vector<std::complex<double> > > u,
241 std::vector<std::vector<std::complex<double> > > l,
242 std::vector<std::complex<double> > b);
287 double CalculateEMTPowerError(
const std::vector< std::complex<double> >& voltage, std::vector< std::complex<double> >& power,
const double& basePower, wxString& errorMsg);
357 void GetNextConnection(
const unsigned int& checkBusNumber,
const std::vector< std::vector< std::complex<double> > >& yBus, std::vector<bool>& connToSlack);
BusType
Types of buses used in power flow analysis.
YBusSequence
Sequence type used when building the system admittance matrix.
ReactiveLimitsType
Types of reactive power limit conditions for buses.
Node for power elements. All others power elements are connected through this.
Base class for electrical calculations providing general utility methods.
void DistributeReactivePower(std::vector< ReactiveMachine > &machines, double qTotal)
Distribute reactive power among synchronous machines connected to the same bus.
std::vector< std::complex< double > > ComplexMatrixTimesVector(std::vector< std::vector< std::complex< double > > > matrix, std::vector< std::complex< double > > vector)
Multiply a complex matrix by a complex vector.
std::vector< Line * > m_lineList
List of transmission lines in the system.
std::vector< PowerElement * > m_powerElementList
List of power elements in the system.
std::vector< Bus * > m_busList
List of buses in the system.
const std::vector< IndMotor * > GetIndMotorList() const
Get the induction motors of the system (use GetElementsFromList first).
virtual void UpdateElementsPowerFlow(std::vector< std::complex< double > > voltage, std::vector< std::complex< double > > power, std::vector< BusType > busType, std::vector< ReactiveLimits > reactiveLimit, double systemPowerBase)
Update the elements after the power flow calculation.
~ElectricCalculation()
Destructor.
const std::vector< PowerElement * > GetPowerElementList() const
Get the power elements of the system (use GetElementsFromList first).
std::vector< Load * > m_loadList
List of load elements in the system.
void ABCtoDQ0(std::complex< double > complexValue, double angle, double &dValue, double &qValue)
Convert a complex phasor in ABC representation to DQ components.
std::vector< Capacitor * > m_capacitorList
List of capacitor elements in the system.
bool CalculateEMTElementsAdmittance(const double &basePower, wxString &errorMsg)
Calculate the admittance of EMT elements.
std::vector< std::complex< double > > LUEvaluate(std::vector< std::vector< std::complex< double > > > u, std::vector< std::vector< std::complex< double > > > l, std::vector< std::complex< double > > b)
Solve a linear system using LU decomposition.
const std::vector< Load * > GetLoadList() const
Get the loads of the system (use GetElementsFromList first).
const std::vector< SyncMotor * > GetSyncMotorList() const
Get the synchronous motors of the system (use GetElementsFromList first).
ElectricCalculation()
Constructor.
double CalculateEMTPowerError(const std::vector< std::complex< double > > &voltage, std::vector< std::complex< double > > &power, const double &basePower, wxString &errorMsg)
Calculate the power mismatch error for EMT simulation.
std::vector< IndMotor * > m_indMotorList
List of induction motors in the system.
bool GetParentBus(Element *childElement, Bus *&parentBus)
Get the parent bus of a given shunt element.
std::vector< Transformer * > m_transformerList
List of transformers in the system.
bool CalculateEMTElementsPower(const double &basePower, wxString &errorMsg, bool updateCurrent=true)
Calculate the power of EMT elements.
const std::vector< SyncGenerator * > GetSyncGeneratorList() const
Get the synchronous generators of the system (use GetElementsFromList first).
std::vector< SyncGenerator * > m_syncGeneratorList
List of synchronous generators in the system.
const std::vector< Transformer * > GetTransformerList() const
Get the transformers of the system (use GetElementsFromList first).
std::vector< EMTElement * > m_emtElementList
List of electromagnetic transient (EMT) elements in the system.
std::vector< std::complex< double > > GaussianElimination(std::vector< std::vector< std::complex< double > > > matrix, std::vector< std::complex< double > > array)
Solve a linear system using Gaussian elimination (complex version).
void GetNextConnection(const unsigned int &checkBusNumber, const std::vector< std::vector< std::complex< double > > > &yBus, std::vector< bool > &connToSlack)
Recursively check if a bus is electrically connected to the slack bus.
const std::vector< Capacitor * > GetCapacitorList() const
Get the capacitors of the system (use GetElementsFromList first).
const std::vector< Inductor * > GetInductorList() const
Get the inductors of the system (use GetElementsFromList first).
virtual bool GetYBus(std::vector< std::vector< std::complex< double > > > &yBus, double systemPowerBase, YBusSequence sequence=POSITIVE_SEQ, bool includeSyncMachines=false, bool allLoadsAsImpedances=false, bool usePowerFlowVoltagesOnImpedances=false)
Get the admittance matrix from the list of elements (use GetElementsFromList first).
std::vector< SyncMotor * > m_syncMotorList
List of synchronous motors in the system.
const std::vector< Line * > GetLineList() const
Get the lines of the system (use GetElementsFromList first).
const std::vector< EMTElement * > GetEMTElementList() const
Get the electromagnetic element list of the system (use GetElementsFromList first).
const std::vector< Bus * > GetBusList() const
Get the buses of the system (use GetElementsFromList first).
std::vector< HarmCurrent * > m_harmCurrentList
List of harmonic current sources in the system.
virtual void GetElementsFromList(std::vector< Element * > elementList)
Separate the power elements from a generic list.
std::vector< Inductor * > m_inductorList
List of inductors in the system.
Machines::SyncMachineModel GetMachineModel(SyncGenerator *generator)
Get the synchronous machine model used by the generator based on user-defined parameters.
void GetLUDecomposition(std::vector< std::vector< std::complex< double > > > matrix, std::vector< std::vector< std::complex< double > > > &matrixL, std::vector< std::vector< std::complex< double > > > &matrixU)
Compute the LU decomposition of a matrix.
void DQ0toABC(double dValue, double qValue, double angle, std::complex< double > &complexValue)
Convert DQ components to a complex phasor in ABC representation.
virtual bool InvertMatrix(std::vector< std::vector< std::complex< double > > > matrix, std::vector< std::vector< std::complex< double > > > &inverse)
Invert a matrix.
const std::vector< HarmCurrent * > GetHarmCurrentList() const
Get the harmonic current source of the system (use GetElementsFromList first).
Base class of all elements of the program. This class is responsible for manage graphical and his dat...
Abstract class for rotary machines power elements.
Synchronous generator power element.
Stores reactive power limits and their status for a bus.
ReactiveLimitsType maxLimitType
ReactiveLimitsType minLimitType
ReactiveLimitsType limitReached
Auxiliary structure used to distribute reactive power among machines connected to a bus.