#ifndef ELECTROMECHANICAL_H #define ELECTROMECHANICAL_H #include "ElectricCalculation.h" #include class ControlElementSolver; /** * @brief Synchronous machine data for different models * * This struct have the parameters and calculated data that depends on each machine model. */ struct SyncMachineModelData { /** Direct-axis reactance (transient for models 1, 2 and 3; subtransient for models 4 and 5) */ double xd; /** Quadrature-axis reactance (transient for models 1, 2 and 3; subtransient for models 4 and 5) */ double xq; /** Direct-axis internal voltage (transient for models 1, 2 and 3; subtransient for models 4 and 5) */ double ed; /** Quadrature-axis internal voltage (transient for models 1, 2 and 3; subtransient for models 4 and 5) */ double eq; }; /** * @class Electromechanical * @author Thales Lima Oliveira * @date 23/09/2017 * @file Electromechanical.h * @brief Calculates the electromechanical transient based on disturbances (e.g. system fault). */ class Electromechanical : public ElectricCalculation { public: Electromechanical(wxWindow* parent, std::vector elementList, SimulationData data); ~Electromechanical(); bool RunStabilityCalculation(); wxString GetErrorMessage() const { return m_errorMsg; } std::vector GetTimeVector() const { return m_timeVector; } std::vector m_wErrorVector; std::vector m_deltaErrorVector; std::vector m_transEdErrorVector; std::vector m_transEqErrorVector; std::vector m_numItVector; std::vector m_sdCVector; std::vector m_sqCVector; protected: void SetEventTimeList(); bool HasEvent(double currentTime); void SetEvent(double currentTime); inline bool EventTrigger(double eventTime, double currentTime); // double GetPowerValue(double value, ElectricalUnit unit); void InsertSyncMachinesOnYBus(); std::complex GetSyncMachineAdmittance(SyncGenerator* generator); bool InitializeDynamicElements(); bool CalculateMachinesCurrents(); void CalculateIntegrationConstants(SyncGenerator* syncGenerator, double id, double iq, double k = 1.0); bool SolveSynchronousMachines(); void SetSyncMachinesModel(); SyncMachineModelData GetSyncMachineModelData(SyncGenerator* syncMachine); double CalculateSyncMachineIntVariables(SyncGenerator* syncGenerator, double id, double iq, double sd, double sq, double pe, double k = 1.0); void CalculateSyncMachineNonIntVariables(SyncGenerator* syncGenerator, double& id, double& iq, double& sd, double& sq, double& pe, double k = 1.0); void CalculateReferenceSpeed(); bool CalculateSyncMachineSaturation(SyncGenerator* syncMachine, double k = 1.0); void SaveData(); wxWindow* m_parent = NULL; wxString m_errorMsg = _("Unknown error"); double m_systemFreq = 60.0; double m_refSpeed = 2.0 * M_PI * 60.0; bool m_useCOI = false; std::vector > > m_yBus; std::vector > > m_yBusU; std::vector > > m_yBusL; std::vector > m_vBus; std::vector > m_iBus; double m_powerSystemBase = 100e6; double m_simTime = 10.0; double m_plotTime = 1e-2; double m_timeStep = 1e-2; double m_ctrlTimeStepMultiplier = 0.1; double m_tolerance = 1e-8; int m_maxIterations = 100; double m_saturationTolerance = 1e-4; std::vector m_eventTimeList; std::vector m_eventOccurrenceList; std::vector m_timeVector; // tests double m_wError = 0.0; double m_sdC = 0.0; double m_sqC = 0.0; double m_numIt = 0; }; #endif // ELECTROMECHANICAL_H