Commit 8836e7c7 authored by Markus Mirz's avatar Markus Mirz
Browse files

add correct phase shift to transmission line

parent 60db82d2
......@@ -43,7 +43,7 @@ namespace Signal {
Complex mSrcCur1Ref;
Complex mSrcCur2Ref;
// TODO also EMT support?
std::shared_ptr<DP::Node> mNode1, mNode2;
std::shared_ptr<DP::Ph1::Resistor> mRes1, mRes2;
std::shared_ptr<DP::Ph1::CurrentSource> mSrc1, mSrc2;
Attribute<Complex>::Ptr mSrcCur1, mSrcCur2;
......@@ -64,6 +64,9 @@ namespace Signal {
DecouplingLine(String name, Node<Complex>::Ptr node1, Node<Complex>::Ptr node2,
Real resistance, Real inductance, Real capacitance, Logger::Level logLevel = Logger::Level::info);
DecouplingLine(String name, Logger::Level logLevel = Logger::Level::info);
void setParameters(Node<Complex>::Ptr node1, Node<Complex>::Ptr node2, Real resistance, Real inductance, Real capacitance);
void initialize(Real omega, Real timeStep);
void step(Real time, Int timeStepCount);
void postStep();
......
/**
* @author Markus Mirz <mmirz@eonerc.rwth-aachen.de>
* @copyright 2017-2018, Institute for Automation of Complex Power Systems, EONERC
* @copyright 2017 Institute for Automation of Complex Power Systems, EONERC
*
* CPowerSystems
*
......
......@@ -54,6 +54,46 @@ DecouplingLine::DecouplingLine(String name, Node<Complex>::Ptr node1, Node<Compl
mSrcCur2 = mSrc2->attributeComplex("I_ref");
}
DecouplingLine::DecouplingLine(String name, Logger::Level logLevel) :
SignalComponent(name, name, logLevel) {
addAttribute<Matrix>("states", &mStates);
addAttribute<Complex>("i_src1", &mSrcCur1Ref, Flags::read);
addAttribute<Complex>("i_src2", &mSrcCur2Ref, Flags::read);
mRes1 = Resistor::make(name + "_r1", logLevel);
mRes2 = Resistor::make(name + "_r2", logLevel);
mSrc1 = CurrentSource::make(name + "_i1", logLevel);
mSrc2 = CurrentSource::make(name + "_i2", logLevel);
mSrcCur1 = mSrc1->attributeComplex("I_ref");
mSrcCur2 = mSrc2->attributeComplex("I_ref");
}
void DecouplingLine::setParameters(Node<Complex>::Ptr node1, Node<Complex>::Ptr node2,
Real resistance, Real inductance, Real capacitance) {
mResistance = resistance;
mInductance = inductance;
mCapacitance = capacitance;
mNode1 = node1;
mNode2 = node2;
mSurgeImpedance = sqrt(inductance / capacitance);
mDelay = sqrt(inductance * capacitance);
mSLog->info("surge impedance: {}", mSurgeImpedance);
mSLog->info("delay: {}", mDelay);
mRes1->setParameters(mSurgeImpedance + resistance / 4);
mRes1->connect({node1, Node<Complex>::GND});
mRes2->setParameters(mSurgeImpedance + resistance / 4);
mRes2->connect({node2, Node<Complex>::GND});
mSrc1->setParameters(0);
mSrc1->connect({node1, Node<Complex>::GND});
mSrc2->setParameters(0);
mSrc2->connect({node2, Node<Complex>::GND});
}
void DecouplingLine::initialize(Real omega, Real timeStep) {
if (mDelay < timeStep)
throw SystemError("Timestep too large for decoupling");
......@@ -62,14 +102,16 @@ void DecouplingLine::initialize(Real omega, Real timeStep) {
mAlpha = 1 - (mBufSize - mDelay / timeStep);
mSLog->info("bufsize {} alpha {}", mBufSize, mAlpha);
Complex volt1 = mRes1->initialSingleVoltage(0);
Complex volt2 = mRes2->initialSingleVoltage(0);
Complex volt1 = mNode1->initialSingleVoltage();
Complex volt2 = mNode2->initialSingleVoltage();
// TODO different initialization for lumped resistance?
Complex initAdmittance = 1. / Complex(mResistance, omega * mInductance) + Complex(0, omega * mCapacitance / 2);
Complex cur1 = volt1 * initAdmittance - volt2 / Complex(mResistance, omega * mInductance);
Complex cur2 = volt2 * initAdmittance - volt1 / Complex(mResistance, omega * mInductance);
mSLog->info("initial voltages: v_k {} v_m {}", volt1, volt2);
mSLog->info("initial currents: i_km {} i_mk {}", cur1, cur2);
// Resize ring buffers and initialize
mVolt1.resize(mBufSize, volt1);
mVolt2.resize(mBufSize, volt2);
mCur1.resize(mBufSize, cur1);
......@@ -92,17 +134,19 @@ void DecouplingLine::step(Real time, Int timeStepCount) {
if (timeStepCount == 0) {
// bit of a hack for proper initialization
mSrcCur1Ref = cur1 - volt1 / (mSurgeImpedance + mResistance / 4);
mSrcCur1Ref = cur2 - volt2 / (mSurgeImpedance + mResistance / 4);
mSrcCur2Ref = cur2 - volt2 / (mSurgeImpedance + mResistance / 4);
} else {
// Update currents
Real denom = (mSurgeImpedance + mResistance/4) * (mSurgeImpedance + mResistance/4);
mSrcCur1Ref = -mSurgeImpedance / denom * (volt2 + (mSurgeImpedance - mResistance/4) * cur2)
- mResistance/4 / denom * (volt1 + (mSurgeImpedance - mResistance/4) * cur1);
mSrcCur1Ref = -mSurgeImpedance / denom * (volt1 + (mSurgeImpedance - mResistance/4) * cur1)
mSrcCur2Ref = -mSurgeImpedance / denom * (volt1 + (mSurgeImpedance - mResistance/4) * cur1)
- mResistance/4 / denom * (volt2 + (mSurgeImpedance - mResistance/4) * cur2);
mSrcCur1Ref = mSrcCur1Ref * Complex(cos(-2.*PI*50*mDelay),sin(-2.*PI*50*mDelay));
mSrcCur2Ref = mSrcCur2Ref * Complex(cos(-2.*PI*50*mDelay),sin(-2.*PI*50*mDelay));
}
mSrcCur1->set(mSrcCur1Ref);
mSrcCur2->set(mSrcCur1Ref);
mSrcCur2->set(mSrcCur2Ref);
}
void DecouplingLine::PreStep::execute(Real time, Int timeStepCount) {
......
......@@ -80,7 +80,7 @@ void DecouplingLineEMT::initialize(Real omega, Real timeStep) {
mSLog->info("initial voltages: v_k {} v_m {}", volt1, volt2);
mSLog->info("initial currents: i_km {} i_mk {}", cur1, cur2);
// Resize ring buffers
// Resize ring buffers and initialize
mVolt1.resize(mBufSize, volt1.real());
mVolt2.resize(mBufSize, volt2.real());
mCur1.resize(mBufSize, cur1.real());
......@@ -104,16 +104,16 @@ void DecouplingLineEMT::step(Real time, Int timeStepCount) {
if (timeStepCount == 0) {
// initialization
mSrcCur1Ref = cur1 - volt1 / (mSurgeImpedance + mResistance / 4);
mSrcCur1Ref = cur2 - volt2 / (mSurgeImpedance + mResistance / 4);
mSrcCur2Ref = cur2 - volt2 / (mSurgeImpedance + mResistance / 4);
} else {
// Update currents
mSrcCur1Ref = -mSurgeImpedance / denom * (volt2 + (mSurgeImpedance - mResistance/4) * cur2)
-mResistance/4 / denom * (volt1 + (mSurgeImpedance - mResistance/4) * cur1);
mSrcCur1Ref = -mSurgeImpedance / denom * (volt1 + (mSurgeImpedance - mResistance/4) * cur1)
mSrcCur2Ref = -mSurgeImpedance / denom * (volt1 + (mSurgeImpedance - mResistance/4) * cur1)
-mResistance/4 / denom * (volt2 + (mSurgeImpedance - mResistance/4) * cur2);
}
mSrcCur1->set(mSrcCur1Ref);
mSrcCur2->set(mSrcCur1Ref);
mSrcCur2->set(mSrcCur2Ref);
}
void DecouplingLineEMT::PreStep::execute(Real time, Int timeStepCount) {
......
......@@ -90,15 +90,14 @@ void simDecoupling() {
auto n2 = Node::make("n2");
// Components
auto vs = Ph1::VoltageSource::make("v_1");
vs->setParameters(CPS::Math::polar(100000, -PI/2.));
auto vs = Ph1::VoltageSource::make("Vsrc");
vs->setParameters(CPS::Math::polar(100000, 0));
Real resistance = 5;
Real inductance = 0.16;
Real capacitance = 1.0e-6;
auto dline = CPS::Signal::DecouplingLine::make("dline",
n1, n2, resistance, inductance, capacitance,
Logger::Level::debug);
auto dline = CPS::Signal::DecouplingLine::make("DecLine", Logger::Level::debug);
dline->setParameters(n1, n2, resistance, inductance, capacitance);
auto load = Ph1::Resistor::make("R_load");
load->setParameters(10000);
......@@ -141,14 +140,13 @@ void simDecouplingEMT() {
auto n2 = CPS::EMT::Node::make("n2");
// Components
auto vs = CPS::EMT::Ph1::VoltageSource::make("v_1");
vs->setParameters(CPS::Math::polar(100000, -PI/2.), 50);
auto vs = CPS::EMT::Ph1::VoltageSource::make("Vsrc_emt");
vs->setParameters(CPS::Math::polar(100000, 0), 50);
Real resistance = 5;
Real inductance = 0.16;
Real capacitance = 1.0e-6;
auto dline = CPS::Signal::DecouplingLineEMT::make("dline", Logger::Level::debug);
auto dline = CPS::Signal::DecouplingLineEMT::make("DecLine_emt", Logger::Level::debug);
dline->setParameters(n1, n2, resistance, inductance, capacitance);
auto load = CPS::EMT::Ph1::Resistor::make("R_load");
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment