Commit 6acbea70 authored by Markus Mirz's avatar Markus Mirz
Browse files

move singlePhaseToThreePhase methods to Math

parent aceb388f
......@@ -19,7 +19,6 @@
using namespace DPsim;
using namespace CPS;
using namespace CPS::CIM;
int main(int argc, char* argv[]) {
......@@ -127,7 +126,7 @@ int main(int argc, char* argv[]) {
loggerDP->addAttribute("irx", loadDP->attribute("i_intf"));
// load step sized in absolute terms
std::shared_ptr<SwitchEvent> loadStepEvent = Examples::createEventAddPowerConsumption("n2", 0.1-timeStepDP, 100e3, systemDP, Domain::DP, loggerDP);
std::shared_ptr<SwitchEvent> loadStepEvent = CIM::Examples::createEventAddPowerConsumption("n2", 0.1-timeStepDP, 100e3, systemDP, Domain::DP, loggerDP);
// Simulation
Simulation sim(simNameDP, Logger::Level::debug);
......
......@@ -19,11 +19,10 @@
using namespace DPsim;
using namespace CPS;
using namespace CPS::CIM;
int main(int argc, char* argv[]) {
Examples::SGIB::ScenarioConfig scenario;
CIM::Examples::SGIB::ScenarioConfig scenario;
Real finalTime = 2;
Real timeStep = 0.0001;
......@@ -137,10 +136,10 @@ int main(int argc, char* argv[]) {
loggerDP->addAttribute("v2", n2DP->attribute("v"));
loggerDP->addAttribute("i12", lineDP->attribute("i_intf"));
Examples::CIGREMV::logPVAttributes(loggerDP, pv);
CIM::Examples::CIGREMV::logPVAttributes(loggerDP, pv);
// load step sized in absolute terms
std::shared_ptr<SwitchEvent> loadStepEvent = Examples::createEventAddPowerConsumption("n2", std::round(5.0/timeStep)*timeStep, 10e6, systemDP, Domain::DP, loggerDP);
std::shared_ptr<SwitchEvent> loadStepEvent = CIM::Examples::createEventAddPowerConsumption("n2", std::round(5.0/timeStep)*timeStep, 10e6, systemDP, Domain::DP, loggerDP);
// Simulation
Simulation sim(simNameDP, Logger::Level::debug);
......
......@@ -17,7 +17,6 @@
#include <DPsim.h>
using namespace DPsim;
using namespace CPS::CIM;
using namespace CPS::EMT;
void EMT_CS_R1() {
......@@ -321,7 +320,7 @@ void EMT_Ph3_VS_R2L3() {
// Components
auto vs = Ph3::VoltageSource::make("vs");
vs->setParameters(Reader::singlePhaseVariableToThreePhase(Complex(10,0)), 50);
vs->setParameters(CPS::Math::singlePhaseVariableToThreePhase(Complex(10,0)), 50);
auto r1 = Ph3::Resistor::make("r_1");
Matrix r1_param = Matrix::Zero(3, 3);
r1_param <<
......@@ -391,7 +390,7 @@ void EMT_Ph3_VS_RC1() {
// Components
auto vs = Ph3::VoltageSource::make("vs");
vs->setParameters(Reader::singlePhaseVariableToThreePhase(Complex(10,0)), 50);
vs->setParameters(CPS::Math::singlePhaseVariableToThreePhase(Complex(10,0)), 50);
auto r1 = Ph3::Resistor::make("r_1");
Matrix r1_param = Matrix::Zero(3, 3);
r1_param <<
......
......@@ -18,7 +18,6 @@
using namespace DPsim;
using namespace CPS;
using namespace CPS::CIM;
void simElementsSP1ph() {
Real timeStep = 0.00005;
......@@ -183,10 +182,10 @@ void simElementsEMT3ph() {
// Components
auto vs = EMT::Ph3::VoltageSource::make("vs1");
vs->setParameters(Reader::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
vs->setParameters(CPS::Math::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
auto load = EMT::Ph3::Resistor::make("Rload");
load->setParameters(Reader::singlePhaseParameterToThreePhase(10000));
load->setParameters(CPS::Math::singlePhaseParameterToThreePhase(10000));
// Topology
vs->connect({ SimNode<Real>::GND, n1 });
......@@ -222,10 +221,10 @@ void simComponentEMT3ph() {
// Components
auto vs = EMT::Ph3::NetworkInjection::make("vs1", Logger::Level::debug);
vs->setParameters(Reader::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
vs->setParameters(CPS::Math::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
auto load = EMT::Ph3::Resistor::make("Rload");
load->setParameters(Reader::singlePhaseParameterToThreePhase(10000));
load->setParameters(CPS::Math::singlePhaseParameterToThreePhase(10000));
// Topology
vs->connect({ n1 });
......
......@@ -19,7 +19,6 @@
using namespace DPsim;
using namespace CPS;
using namespace CPS::CIM;
void simTrafoElementsSP1ph() {
Real timeStep = 0.00005;
......@@ -277,11 +276,11 @@ void simTrafoElementsEMT3ph() {
loadRes->connect({ n2, SimNode<Real>::GND });
// Parameters
vs->setParameters(Reader::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
trafoRes->setParameters(Reader::singlePhaseParameterToThreePhase(trafoResistance));
trafoInd->setParameters(Reader::singlePhaseParameterToThreePhase(trafoInductance));
trafoSnubberRes->setParameters(Reader::singlePhaseParameterToThreePhase(snubberResistanceHVSide));
loadRes->setParameters(Reader::singlePhaseParameterToThreePhase(loadResistanceHVSide));
vs->setParameters(CPS::Math::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
trafoRes->setParameters(CPS::Math::singlePhaseParameterToThreePhase(trafoResistance));
trafoInd->setParameters(CPS::Math::singlePhaseParameterToThreePhase(trafoInductance));
trafoSnubberRes->setParameters(CPS::Math::singlePhaseParameterToThreePhase(snubberResistanceHVSide));
loadRes->setParameters(CPS::Math::singlePhaseParameterToThreePhase(loadResistanceHVSide));
// Define system topology
SystemTopology sys(50, SystemNodeList{n1, n2, vn1 }, SystemComponentList{vs, trafoRes, trafoInd, trafoSnubberRes, loadRes});
......@@ -331,9 +330,9 @@ void simTrafoEMT3ph() {
loadRes->connect({ n2, SimNode<Real>::GND });
// Parameters
vs->setParameters(Reader::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
trafo->setParameters(voltageHVSide, voltageMVSide, ratio, 0, Reader::singlePhaseParameterToThreePhase(trafoResistance), Reader::singlePhaseParameterToThreePhase(trafoInductance));
loadRes->setParameters(Reader::singlePhaseParameterToThreePhase(loadResistanceMVSide));
vs->setParameters(CPS::Math::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
trafo->setParameters(voltageHVSide, voltageMVSide, ratio, 0, CPS::Math::singlePhaseParameterToThreePhase(trafoResistance), CPS::Math::singlePhaseParameterToThreePhase(trafoInductance));
loadRes->setParameters(CPS::Math::singlePhaseParameterToThreePhase(loadResistanceMVSide));
// Define system topology
SystemTopology sys(50, SystemNodeList{n1, n2 }, SystemComponentList{vs, trafo, loadRes});
......
......@@ -18,7 +18,6 @@
using namespace DPsim;
using namespace CPS;
using namespace CPS::CIM;
void voltageSourceResistorEMT3ph() {
Real timeStep = 0.00005;
......@@ -31,10 +30,10 @@ void voltageSourceResistorEMT3ph() {
// Components
auto vs = EMT::Ph3::VoltageSource::make("vs1");
vs->setParameters(Reader::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
vs->setParameters(CPS::Math::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
auto res = EMT::Ph3::Resistor::make("R1", Logger::Level::debug);
res->setParameters(Reader::singlePhaseParameterToThreePhase(100));
res->setParameters(CPS::Math::singlePhaseParameterToThreePhase(100));
// Topology
vs->connect({ SimNode<Real>::GND, n1 });
......@@ -149,13 +148,13 @@ void voltageSourceInductorEMT3ph() {
// Components
auto vs = EMT::Ph3::VoltageSource::make("vs1", Logger::Level::debug);
vs->setParameters(Reader::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
vs->setParameters(CPS::Math::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
auto res = EMT::Ph3::Resistor::make("R1", Logger::Level::debug);
res->setParameters(Reader::singlePhaseParameterToThreePhase(5));
res->setParameters(CPS::Math::singlePhaseParameterToThreePhase(5));
auto ind = EMT::Ph3::Inductor::make("L1", Logger::Level::debug);
ind->setParameters(Reader::singlePhaseParameterToThreePhase(0.5));
ind->setParameters(CPS::Math::singlePhaseParameterToThreePhase(0.5));
// Topology
vs->connect({ SimNode<Real>::GND, n1 });
......@@ -287,13 +286,13 @@ void voltageSourceCapacitorEMT3ph() {
// Components
auto vs = EMT::Ph3::VoltageSource::make("vs1", Logger::Level::debug);
vs->setParameters(Reader::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
vs->setParameters(CPS::Math::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
auto res = EMT::Ph3::Resistor::make("R1", Logger::Level::debug);
res->setParameters(Reader::singlePhaseParameterToThreePhase(5));
res->setParameters(CPS::Math::singlePhaseParameterToThreePhase(5));
auto cap = EMT::Ph3::Capacitor::make("C1", Logger::Level::debug);
cap->setParameters(Reader::singlePhaseParameterToThreePhase(10e-3));
cap->setParameters(CPS::Math::singlePhaseParameterToThreePhase(10e-3));
// Topology
vs->connect({ SimNode<Real>::GND, n1 });
......
......@@ -2,7 +2,6 @@
using namespace DPsim;
using namespace CPS;
using namespace CPS::CIM;
void vsSetParamsDP1ph() {
Real timeStep = 0.00005;
......@@ -49,7 +48,7 @@ void vsSetParamsEMT3ph() {
// Components
auto vs = EMT::Ph3::VoltageSource::make("vs1");
vs->setParameters(Reader::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
vs->setParameters(CPS::Math::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
// Topology
vs->connect({ SimNode<Real>::GND, n1 });
......@@ -114,7 +113,7 @@ void vsSetAttrEMT3ph() {
String simName = "EMT_VS_SetAttr";
Logger::setLogDir("logs/"+simName);
MatrixComp vref = Reader::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0));
MatrixComp vref = CPS::Math::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0));
// Nodes
auto n1 = SimNode<Real>::make("n1", PhaseType::ABC);
......
......@@ -17,7 +17,6 @@
#include <DPsim.h>
using namespace DPsim;
using namespace CPS::CIM;
using namespace CPS::EMT;
using namespace CPS::EMT::Ph3;
......@@ -34,7 +33,7 @@ void simElements() {
// Components
auto vs = VoltageSource::make("v_1", Logger::Level::debug);
vs->setParameters(Reader::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
vs->setParameters(CPS::Math::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
// Parametrization of components
Real resistance = 5;
......@@ -43,20 +42,20 @@ void simElements() {
Real conductance = 1e-6;
auto res = Resistor::make("R_line", Logger::Level::debug);
res->setParameters(Reader::singlePhaseParameterToThreePhase(resistance));
res->setParameters(CPS::Math::singlePhaseParameterToThreePhase(resistance));
auto ind = Inductor::make("L_line", Logger::Level::debug);
ind->setParameters(Reader::singlePhaseParameterToThreePhase(inductance));
ind->setParameters(CPS::Math::singlePhaseParameterToThreePhase(inductance));
auto cap1 = Capacitor::make("Cp_1", Logger::Level::debug);
cap1->setParameters(Reader::singlePhaseParameterToThreePhase(capacitance/2.));
cap1->setParameters(CPS::Math::singlePhaseParameterToThreePhase(capacitance/2.));
auto cap2 = Capacitor::make("Cp_2", Logger::Level::debug);
cap2->setParameters(Reader::singlePhaseParameterToThreePhase(capacitance/2.));
cap2->setParameters(CPS::Math::singlePhaseParameterToThreePhase(capacitance/2.));
auto con1 = Resistor::make("Gp_1", Logger::Level::debug);
con1->setParameters(Reader::singlePhaseParameterToThreePhase(2./conductance));
con1->setParameters(CPS::Math::singlePhaseParameterToThreePhase(2./conductance));
auto con2 = Resistor::make("Gp_2", Logger::Level::debug);
con2->setParameters(Reader::singlePhaseParameterToThreePhase(2./conductance));
con2->setParameters(CPS::Math::singlePhaseParameterToThreePhase(2./conductance));
auto load = Resistor::make("R_load", Logger::Level::debug);
load->setParameters(Reader::singlePhaseParameterToThreePhase(10000));
load->setParameters(CPS::Math::singlePhaseParameterToThreePhase(10000));
// Topology
vs->connect({ SimNode::GND, n1 });
......@@ -103,7 +102,7 @@ void simPiLine() {
// Components
auto vs = VoltageSource::make("v_1", Logger::Level::debug);
vs->setParameters(Reader::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
vs->setParameters(CPS::Math::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
// Parametrization of components
Real resistance = 5;
......@@ -112,10 +111,10 @@ void simPiLine() {
Real conductance = 1e-6;
auto line = PiLine::make("Line", Logger::Level::debug);
line->setParameters(Reader::singlePhaseParameterToThreePhase(resistance), Reader::singlePhaseParameterToThreePhase(inductance), Reader::singlePhaseParameterToThreePhase(capacitance), Reader::singlePhaseParameterToThreePhase(conductance));
line->setParameters(CPS::Math::singlePhaseParameterToThreePhase(resistance), CPS::Math::singlePhaseParameterToThreePhase(inductance), CPS::Math::singlePhaseParameterToThreePhase(capacitance), CPS::Math::singlePhaseParameterToThreePhase(conductance));
auto load = Resistor::make("R_load", Logger::Level::debug);
load->setParameters(Reader::singlePhaseParameterToThreePhase(10000));
load->setParameters(CPS::Math::singlePhaseParameterToThreePhase(10000));
// Topology
vs->connect({ SimNode::GND, n1 });
......
......@@ -19,7 +19,6 @@
using namespace DPsim;
using namespace CPS;
using namespace CPS::CIM;
int main(int argc, char* argv[]) {
......@@ -101,10 +100,10 @@ int main(int argc, char* argv[]) {
auto extnetEMT = EMT::Ph3::NetworkInjection::make("Slack", Logger::Level::debug);
auto lineEMT = EMT::Ph3::PiLine::make("PiLine", Logger::Level::debug);
lineEMT->setParameters(Reader::singlePhaseParameterToThreePhase(lineResistance), Reader::singlePhaseParameterToThreePhase(lineInductance), Reader::singlePhaseParameterToThreePhase(lineCapacitance));
lineEMT->setParameters(CPS::Math::singlePhaseParameterToThreePhase(lineResistance), CPS::Math::singlePhaseParameterToThreePhase(lineInductance), CPS::Math::singlePhaseParameterToThreePhase(lineCapacitance));
auto loadEMT = EMT::Ph3::RXLoad::make("Load", Logger::Level::debug);
loadEMT->setParameters(Reader::singlePhasePowerToThreePhase(pLoadNom), Reader::singlePhasePowerToThreePhase(qLoadNom), Vnom);
loadEMT->setParameters(CPS::Math::singlePhasePowerToThreePhase(pLoadNom), CPS::Math::singlePhasePowerToThreePhase(qLoadNom), Vnom);
// Topology
extnetEMT->connect({ n1EMT });
......@@ -126,7 +125,7 @@ int main(int argc, char* argv[]) {
loggerEMT->addAttribute("irx", loadEMT->attribute("i_intf"));
// load step sized in absolute terms
std::shared_ptr<SwitchEvent3Ph> loadStepEvent = Examples::createEventAddPowerConsumption3Ph("n2", 0.1-timeStepEMT, 100e3, systemEMT, Domain::EMT, loggerEMT);
std::shared_ptr<SwitchEvent3Ph> loadStepEvent = CIM::Examples::createEventAddPowerConsumption3Ph("n2", 0.1-timeStepEMT, 100e3, systemEMT, Domain::EMT, loggerEMT);
// Simulation
Simulation sim(simNameEMT, Logger::Level::debug);
......
......@@ -19,11 +19,10 @@
using namespace DPsim;
using namespace CPS;
using namespace CPS::CIM;
int main(int argc, char* argv[]) {
Examples::SGIB::ScenarioConfig scenario;
CIM::Examples::SGIB::ScenarioConfig scenario;
Real finalTime = 2;
Real timeStep = 0.0001;
......@@ -107,7 +106,7 @@ int main(int argc, char* argv[]) {
auto extnetEMT = EMT::Ph3::NetworkInjection::make("Slack", Logger::Level::debug);
auto lineEMT = EMT::Ph3::PiLine::make("PiLine", Logger::Level::debug);
lineEMT->setParameters(Reader::singlePhaseParameterToThreePhase(scenario.lineResistance), Reader::singlePhaseParameterToThreePhase(scenario.lineInductance), Reader::singlePhaseParameterToThreePhase(scenario.lineCapacitance));
lineEMT->setParameters(CPS::Math::singlePhaseParameterToThreePhase(scenario.lineResistance), CPS::Math::singlePhaseParameterToThreePhase(scenario.lineInductance), CPS::Math::singlePhaseParameterToThreePhase(scenario.lineCapacitance));
auto pv = EMT::Ph3::AvVoltageSourceInverterDQ::make("pv", "pv", Logger::Level::debug, true);
pv->setParameters(scenario.systemOmega, scenario.pvNominalVoltage, scenario.pvNominalActivePower, scenario.pvNominalReactivePower);
......@@ -135,10 +134,10 @@ int main(int argc, char* argv[]) {
loggerEMT->addAttribute("v2", n2EMT->attribute("v"));
loggerEMT->addAttribute("i12", lineEMT->attribute("i_intf"));
Examples::CIGREMV::logPVAttributes(loggerEMT, pv);
CIM::Examples::CIGREMV::logPVAttributes(loggerEMT, pv);
// load step sized in absolute terms
std::shared_ptr<SwitchEvent3Ph> loadStepEvent = Examples::createEventAddPowerConsumption3Ph("n2", std::round(5.0/timeStep)*timeStep, 10e6, systemEMT, Domain::EMT, loggerEMT);
std::shared_ptr<SwitchEvent3Ph> loadStepEvent = CIM::Examples::createEventAddPowerConsumption3Ph("n2", std::round(5.0/timeStep)*timeStep, 10e6, systemEMT, Domain::EMT, loggerEMT);
// Simulation
Simulation sim(simNameEMT, Logger::Level::debug);
......
......@@ -17,7 +17,6 @@
#include <DPsim.h>
using namespace DPsim;
using namespace CPS::CIM;
using namespace CPS::EMT;
using namespace CPS::EMT::Ph3;
......@@ -51,7 +50,7 @@ void EMT_Ph3_VSI2_4bus_SampleGrid() {
Real Qref2 = 1000;
auto vs = VoltageSource::make("vs", Logger::Level::info);
vs->setParameters(Reader::singlePhaseVariableToThreePhase(Complex(Vnom, 0)), 50);
vs->setParameters(CPS::Math::singlePhaseVariableToThreePhase(Complex(Vnom, 0)), 50);
auto vsi2 = AvVoltageSourceInverterDQ::make("vsi2", Logger::Level::debug);
auto trans_DG1 = Ph3::Transformer::make("trans_pv1", Logger::Level::debug);
auto trans_DG2 = Ph3::Transformer::make("trans_pv2", Logger::Level::debug);
......
......@@ -18,7 +18,6 @@
using namespace DPsim;
using namespace CPS;
using namespace CPS::CIM;
void vsEMT3ph() {
Real timeStep = 0.00005;
......@@ -31,10 +30,10 @@ void vsEMT3ph() {
// Components
auto vs = EMT::Ph3::VoltageSource::make("vs1", Logger::Level::debug);
vs->setParameters(Reader::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
vs->setParameters(CPS::Math::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0)), 50);
auto res = EMT::Ph3::Resistor::make("R1");
res->setParameters(Reader::singlePhaseParameterToThreePhase(100));
res->setParameters(CPS::Math::singlePhaseParameterToThreePhase(100));
// Topology
vs->connect({ SimNode<Real>::GND, n1 });
......@@ -72,7 +71,7 @@ void vsControlledEMT3ph() {
auto vs = EMT::Ph3::ControlledVoltageSource::make("vs1", Logger::Level::debug);
auto res = EMT::Ph3::Resistor::make("R1");
res->setParameters(Reader::singlePhaseParameterToThreePhase(100));
res->setParameters(CPS::Math::singlePhaseParameterToThreePhase(100));
// Topology
vs->connect({ SimNode<Real>::GND, n1 });
......
......@@ -19,11 +19,10 @@
using namespace DPsim;
using namespace CPS;
using namespace CPS::CIM;
int main(int argc, char* argv[]) {
Examples::SGIB::ScenarioConfig scenario;
CIM::Examples::SGIB::ScenarioConfig scenario;
Real finalTime = 2;
Real timeStep = 0.0001;
......@@ -137,10 +136,10 @@ int main(int argc, char* argv[]) {
loggerSP->addAttribute("v2", n2SP->attribute("v"));
loggerSP->addAttribute("i12", lineSP->attribute("i_intf"));
Examples::CIGREMV::logPVAttributes(loggerSP, pv);
CIM::Examples::CIGREMV::logPVAttributes(loggerSP, pv);
// load step sized in absolute terms
std::shared_ptr<SwitchEvent> loadStepEvent = Examples::createEventAddPowerConsumption("n2", std::round(5.0/timeStep)*timeStep, 10e6, systemSP, Domain::SP, loggerSP);
std::shared_ptr<SwitchEvent> loadStepEvent = CIM::Examples::createEventAddPowerConsumption("n2", std::round(5.0/timeStep)*timeStep, 10e6, systemSP, Domain::SP, loggerSP);
// Simulation
Simulation sim(simNameSP, Logger::Level::debug);
......
......@@ -176,12 +176,6 @@ namespace CIM {
///
void initDynamicSystemTopologyWithPowerflow(SystemTopology& systemPF, SystemTopology& system);
/// To convert single phase complex variables (voltages, currents) to symmetrical three phase ones
static MatrixComp singlePhaseVariableToThreePhase(Complex var_1ph);
///
static Matrix singlePhaseParameterToThreePhase(Real parameter);
///
static Matrix singlePhasePowerToThreePhase(Real power);
// #### shunt component settings ####
/// set shunt capacitor value
......
......@@ -185,5 +185,35 @@ namespace CPS {
static void FFT(std::vector<Complex>& samples);
static Complex rotatingFrame2to1(Complex f2, Real theta1, Real theta2);
/// To convert single phase complex variables (voltages, currents) to symmetrical three phase ones
static MatrixComp singlePhaseVariableToThreePhase(Complex var_1ph) {
MatrixComp var_3ph = MatrixComp::Zero(3, 1);
var_3ph <<
var_1ph,
var_1ph * SHIFT_TO_PHASE_B,
var_1ph * SHIFT_TO_PHASE_C;
return var_3ph;
}
/// To convert single phase real variables (voltages, currents) to symmetrical three phase ones
static Matrix singlePhaseParameterToThreePhase(Real parameter) {
Matrix param_3ph = Matrix::Zero(3, 3);
param_3ph <<
parameter, 0., 0.,
0., parameter, 0.,
0, 0., parameter;
return param_3ph;
}
/// To convert single phase power to symmetrical three phase
static Matrix singlePhasePowerToThreePhase(Real power) {
Matrix power_3ph = Matrix::Zero(3, 3);
power_3ph <<
power/3., 0., 0.,
0., power/3., 0.,
0, 0., power/3.;
return power_3ph;
}
};
}
......@@ -86,33 +86,6 @@ TopologicalPowerComp::Ptr Reader::mapComponent(BaseClass* obj) {
return nullptr;
}
MatrixComp Reader::singlePhaseVariableToThreePhase(Complex var_1ph) {
MatrixComp var_3ph = MatrixComp::Zero(3, 1);
var_3ph <<
var_1ph,
var_1ph * SHIFT_TO_PHASE_B,
var_1ph * SHIFT_TO_PHASE_C;
return var_3ph;
}
Matrix Reader::singlePhaseParameterToThreePhase(Real parameter) {
Matrix param_3ph = Matrix::Zero(3, 3);
param_3ph <<
parameter, 0., 0.,
0., parameter, 0.,
0, 0., parameter;
return param_3ph;
}
Matrix Reader::singlePhasePowerToThreePhase(Real power) {
Matrix power_3ph = Matrix::Zero(3, 3);
power_3ph <<
power/3., 0., 0.,
0., power/3., 0.,
0, 0., power/3.;
return power_3ph;
}
void Reader::addFiles(const fs::path &filename) {
if (!mModel->addCIMFile(filename.string()))
mSLog->error("Failed to read file {}", filename);
......@@ -365,10 +338,10 @@ TopologicalPowerComp::Ptr Reader::mapACLineSegment(CIMPP::ACLineSegment* line) {
if (mDomain == Domain::EMT) {
if (mPhase == PhaseType::ABC) {
Matrix res_3ph = singlePhaseParameterToThreePhase(resistance);
Matrix ind_3ph = singlePhaseParameterToThreePhase(inductance);
Matrix cap_3ph = singlePhaseParameterToThreePhase(capacitance);
Matrix cond_3ph = singlePhaseParameterToThreePhase(conductance);
Matrix res_3ph = CPS::Math::singlePhaseParameterToThreePhase(resistance);
Matrix ind_3ph = CPS::Math::singlePhaseParameterToThreePhase(inductance);
Matrix cap_3ph = CPS::Math::singlePhaseParameterToThreePhase(capacitance);
Matrix cond_3ph = CPS::Math::singlePhaseParameterToThreePhase(conductance);
auto cpsLine = std::make_shared<EMT::Ph3::PiLine>(line->mRID, line->name, mComponentLogLevel);
cpsLine->setParameters(res_3ph, ind_3ph, cap_3ph, cond_3ph);
......@@ -489,8 +462,8 @@ TopologicalPowerComp::Ptr Reader::mapPowerTransformer(CIMPP::PowerTransformer* t
if (mDomain == Domain::EMT) {
if (mPhase == PhaseType::ABC) {
Matrix resistance_3ph = singlePhaseParameterToThreePhase(resistance);
Matrix inductance_3ph = singlePhaseParameterToThreePhase(inductance);
Matrix resistance_3ph = CPS::Math::singlePhaseParameterToThreePhase(resistance);
Matrix inductance_3ph = CPS::Math::singlePhaseParameterToThreePhase(inductance);
Bool withResistiveLosses = resistance > 0;
auto transformer = std::make_shared<EMT::Ph3::Transformer>(trans->mRID, trans->name, mComponentLogLevel, withResistiveLosses);
transformer->setParameters(voltageNode1, voltageNode2, ratioAbs, ratioPhase, resistance_3ph, inductance_3ph);
......
......@@ -107,7 +107,7 @@ void EMT::Ph3::AvVoltageSourceInverterDQ::setTransformerParameters(Real nomVolta
if (mWithConnectionTransformer)
// TODO: resistive losses neglected so far (mWithResistiveLosses=false)
mConnectionTransformer->setParameters(mTransformerNominalVoltageEnd1, mTransformerNominalVoltageEnd2, mTransformerRatioAbs, mTransformerRatioPhase, CPS::CIM::Reader::singlePhaseParameterToThreePhase(mTransformerResistance), CPS::CIM::Reader::singlePhaseParameterToThreePhase(mTransformerInductance));
mConnectionTransformer->setParameters(mTransformerNominalVoltageEnd1, mTransformerNominalVoltageEnd2, mTransformerRatioAbs, mTransformerRatioPhase, CPS::Math::singlePhaseParameterToThreePhase(mTransformerResistance), CPS::Math::singlePhaseParameterToThreePhase(mTransformerInductance));
}
void EMT::Ph3::AvVoltageSourceInverterDQ::setControllerParameters(Real Kp_pll, Real Ki_pll,
......@@ -132,10 +132,10 @@ void EMT::Ph3::AvVoltageSourceInverterDQ::setFilterParameters(Real Lf, Real Cf,
mSLog->info("Inductance Lf={} [H] Capacitance Cf={} [F]", mLf, mCf);
mSLog->info("Resistance Rf={} [H] Resistance Rc={} [F]", mRf, mRc);
mSubResistorC->setParameters(CPS::CIM::Reader::singlePhaseParameterToThreePhase(mRc));
mSubResistorF->setParameters(CPS::CIM::Reader::singlePhaseParameterToThreePhase(mRf));
mSubInductorF->setParameters(CPS::CIM::Reader::singlePhaseParameterToThreePhase(mLf));
mSubCapacitorF->setParameters(CPS::CIM::Reader::singlePhaseParameterToThreePhase(mCf));
mSubResistorC->setParameters(CPS::Math::singlePhaseParameterToThreePhase(mRc));
mSubResistorF->setParameters(CPS::Math::singlePhaseParameterToThreePhase(mRf));
mSubInductorF->setParameters(CPS::Math::singlePhaseParameterToThreePhase(mLf));
mSubCapacitorF->setParameters(CPS::Math::singlePhaseParameterToThreePhase(mCf));
}
void EMT::Ph3::AvVoltageSourceInverterDQ::setInitialStateValues(Real pInit, Real qInit,
......
......@@ -90,7 +90,7 @@ void EMT::Ph3::ControlledVoltageSource::updateSignalReference(Real time, Int tim
// TODO: currently support only hard-coded sinusoid
// later signal components can be used here
MatrixComp vrefcos = CIM::Reader::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0));
MatrixComp vrefcos = CPS::Math::singlePhaseVariableToThreePhase(CPS::Math::polar(100000, 0));
Real fref = 50;