From 30181ca0ae73f5f7f1856ac289db8fcf849c9a84 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Sat, 20 May 2017 17:22:47 -0300 Subject: Electromechanical class and several methods implemented --- Project/ElectricCalculation.h | 69 ++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 27 deletions(-) (limited to 'Project/ElectricCalculation.h') diff --git a/Project/ElectricCalculation.h b/Project/ElectricCalculation.h index 3eea5dd..be9aa89 100644 --- a/Project/ElectricCalculation.h +++ b/Project/ElectricCalculation.h @@ -5,6 +5,7 @@ #include #include "Element.h" +#include "PowerElement.h" #include "Bus.h" #include "Capacitor.h" #include "IndMotor.h" @@ -18,16 +19,18 @@ enum BusType { BUS_SLACK = 0, BUS_PV, BUS_PQ }; enum ReactiveLimitsType { - RL_UNLIMITED = 0, // The bus can generate any ammount of reactive power. - RL_LIMITED, // The bus reactive power generation is limited. - RL_UNLIMITED_SOURCE, // The bus have at least one source of infinite reative power. - RL_MAX_REACHED, // Max limit reached - RL_MIN_REACHED, // Min limit reached - RL_NONE_REACHED // No limits reached + RL_UNLIMITED = 0, // The bus can generate any ammount of reactive power. + RL_LIMITED, // The bus reactive power generation is limited. + RL_UNLIMITED_SOURCE, // The bus have at least one source of infinite reative power. + RL_MAX_REACHED, // Max limit reached + RL_MIN_REACHED, // Min limit reached + RL_NONE_REACHED // No limits reached }; enum YBusSequence { POSITIVE_SEQ = 0, NEGATIVE_SEQ, ZERO_SEQ }; +enum SyncMachineModel { SM_MODEL_1 = 0, SM_MODEL_2, SM_MODEL_3, SM_MODEL_4, SM_MODEL_5 }; + struct ReactiveLimits { double maxLimit = 0.0; double minLimit = 0.0; @@ -45,7 +48,7 @@ struct ReactiveLimits { */ class ElectricCalculation { -public: + public: /** * @brief Constructor. */ @@ -57,7 +60,7 @@ public: ~ElectricCalculation(); /** - * @brief Separate the elements from a generic list. + * @brief Separate the power elements from a generic list. * @param elementList List of generic elements. */ virtual void GetElementsFromList(std::vector elementList); @@ -71,9 +74,10 @@ public: * @return Return true if was possible to build the admittance matrix. */ virtual bool GetYBus(std::vector > >& yBus, - double systemPowerBase, - YBusSequence sequence = POSITIVE_SEQ, - bool includeSyncMachines = false); + double systemPowerBase, + YBusSequence sequence = POSITIVE_SEQ, + bool includeSyncMachines = false, + bool allLoadsAsImpedances = false); /** * @brief Invert a matrix. @@ -82,7 +86,7 @@ public: * @return Return true if was possible to invert the matrix. */ virtual bool InvertMatrix(std::vector > > matrix, - std::vector > >& inverse); + std::vector > >& inverse); /** * @brief Update the elements after the power flow calculation. @@ -93,66 +97,77 @@ public: * @param systemPowerBase Base power of the system. */ virtual void UpdateElementsPowerFlow(std::vector > voltage, - std::vector > power, - std::vector busType, - std::vector reactiveLimit, - double systemPowerBase); + std::vector > power, + std::vector busType, + std::vector reactiveLimit, + double systemPowerBase); + + void ABCtoDQ0(std::complex complexValue, double angle, double& dValue, double& qValue); + void DQ0toABC(double dValue, double qValue, double angle, std::complex& complexValue); + + std::vector > GaussianElimination(std::vector > > matrix, + std::vector > array); + + SyncMachineModel GetMachineModel(SyncGenerator* generator); + + std::vector > ComplexMatrixTimesVector(std::vector > > matrix, + std::vector > vector); + + void GetLUDecomposition(std::vector > > matrix, + std::vector > >& matrixL, + std::vector > >& matrixU); + + std::vector > LUEvaluate(std::vector > > u, + std::vector > > l, + std::vector > b); /** * @brief Get the buses of the system (use GetElementsFromList first). * @return A list of bus elements. */ const std::vector GetBusList() const { return m_busList; } - /** * @brief Get the capacitors of the system (use GetElementsFromList first). * @return A list of capacitor elements. */ const std::vector GetCapacitorList() const { return m_capacitorList; } - /** * @brief Get the induction motors of the system (use GetElementsFromList first). * @return A list of induction motor elements. */ const std::vector GetIndMotorList() const { return m_indMotorList; } - /** * @brief Get the inductors of the system (use GetElementsFromList first). * @return A list of inductor elements. */ const std::vector GetInductorList() const { return m_inductorList; } - /** * @brief Get the lines of the system (use GetElementsFromList first). * @return A list of line elements. */ const std::vector GetLineList() const { return m_lineList; } - /** * @brief Get the loads of the system (use GetElementsFromList first). * @return A list of load elements. */ const std::vector GetLoadList() const { return m_loadList; } - /** * @brief Get the synchronous generators of the system (use GetElementsFromList first). * @return A list of synchronous generator elements. */ const std::vector GetSyncGeneratorList() const { return m_syncGeneratorList; } - /** * @brief Get the synchronous motors of the system (use GetElementsFromList first). * @return A list of synchronous motor elements. */ const std::vector GetSyncMotorList() const { return m_syncMotorList; } - /** * @brief Get the transformers of the system (use GetElementsFromList first). * @return A list of transformer elements. */ const std::vector GetTransformerList() const { return m_transformerList; } - -protected: + protected: + std::vector m_powerElementList; std::vector m_busList; std::vector m_capacitorList; std::vector m_indMotorList; @@ -164,4 +179,4 @@ protected: std::vector m_transformerList; }; -#endif // ELECTRICCALCULATION_H +#endif // ELECTRICCALCULATION_H -- cgit