Commit f8042150 authored by Georg Martin Reinke's avatar Georg Martin Reinke
Browse files

add Python attributes to many components


Former-commit-id: 348e7d7f
parent 0ac69ef5
...@@ -4,6 +4,7 @@ using namespace DPsim; ...@@ -4,6 +4,7 @@ using namespace DPsim;
Capacitor::Capacitor(std::string name, Int src, Int dest, Real capacitance) : BaseComponent(name, src, dest) { Capacitor::Capacitor(std::string name, Int src, Int dest, Real capacitance) : BaseComponent(name, src, dest) {
this->capacitance = capacitance; this->capacitance = capacitance;
attrMap["capacitance"] = {AttrReal, &this->capacitance};
}; };
void Capacitor::applySystemMatrixStamp(SystemModel& system) { void Capacitor::applySystemMatrixStamp(SystemModel& system) {
......
...@@ -4,6 +4,7 @@ using namespace DPsim; ...@@ -4,6 +4,7 @@ using namespace DPsim;
Inductor::Inductor(std::string name, int src, int dest, double inductance) : BaseComponent(name, src, dest) { Inductor::Inductor(std::string name, int src, int dest, double inductance) : BaseComponent(name, src, dest) {
mInductance = inductance; mInductance = inductance;
attrMap["inductance"] = {AttrReal, &mInductance};
} }
void Inductor::applySystemMatrixStamp(SystemModel& system) { void Inductor::applySystemMatrixStamp(SystemModel& system) {
......
...@@ -4,6 +4,7 @@ using namespace DPsim; ...@@ -4,6 +4,7 @@ using namespace DPsim;
InductorEMT::InductorEMT(std::string name, int src, int dest, double inductance) : BaseComponent(name, src, dest) { InductorEMT::InductorEMT(std::string name, int src, int dest, double inductance) : BaseComponent(name, src, dest) {
mInductance = inductance; mInductance = inductance;
attrMap["inductance"] = {AttrReal, &mInductance};
} }
void InductorEMT::applySystemMatrixStamp(SystemModel& system) { void InductorEMT::applySystemMatrixStamp(SystemModel& system) {
......
...@@ -4,6 +4,7 @@ using namespace DPsim; ...@@ -4,6 +4,7 @@ using namespace DPsim;
InterfacedInductor::InterfacedInductor(std::string name, int src, int dest, Real inductance) : BaseComponent(name, src, dest) { InterfacedInductor::InterfacedInductor(std::string name, int src, int dest, Real inductance) : BaseComponent(name, src, dest) {
this->mInductance = inductance; this->mInductance = inductance;
attrMap["inductance"] = {AttrReal, &mInductance};
} }
......
...@@ -4,11 +4,11 @@ using namespace DPsim; ...@@ -4,11 +4,11 @@ using namespace DPsim;
LinearResistor::LinearResistor(std::string name, int src, int dest, Real resistance) : BaseComponent(name, src, dest) { LinearResistor::LinearResistor(std::string name, int src, int dest, Real resistance) : BaseComponent(name, src, dest) {
this->mResistance = resistance; this->mResistance = resistance;
this->mConductance = 1.0 / resistance; attrMap["resistance"] = {AttrReal, &this->mResistance};
} }
void LinearResistor::applySystemMatrixStamp(SystemModel& system) { void LinearResistor::applySystemMatrixStamp(SystemModel& system) {
this->mConductance = 1.0 / mResistance;
// Set diagonal entries // Set diagonal entries
if (mNode1 >= 0) { if (mNode1 >= 0) {
system.addCompToSystemMatrix(mNode1, mNode1, mConductance, 0); system.addCompToSystemMatrix(mNode1, mNode1, mConductance, 0);
......
...@@ -4,10 +4,11 @@ using namespace DPsim; ...@@ -4,10 +4,11 @@ using namespace DPsim;
LinearResistorEMT::LinearResistorEMT(std::string name, int src, int dest, Real resistance) : BaseComponent(name, src, dest) { LinearResistorEMT::LinearResistorEMT(std::string name, int src, int dest, Real resistance) : BaseComponent(name, src, dest) {
this->mResistance = resistance; this->mResistance = resistance;
this->mConductance = 1.0 / resistance; attrMap["resistance"] = {AttrReal, &this->mResistance};
} }
void LinearResistorEMT::applySystemMatrixStamp(SystemModel& system) { void LinearResistorEMT::applySystemMatrixStamp(SystemModel& system) {
this->mConductance = 1.0 / mResistance;
// Set diagonal entries // Set diagonal entries
if (mNode1 >= 0) { if (mNode1 >= 0) {
system.addRealToSystemMatrix(mNode1, mNode1, mConductance); system.addRealToSystemMatrix(mNode1, mNode1, mConductance);
......
...@@ -8,6 +8,14 @@ PQLoad::PQLoad(std::string name, int src, int dest, Real p, Real q, Real volt, R ...@@ -8,6 +8,14 @@ PQLoad::PQLoad(std::string name, int src, int dest, Real p, Real q, Real volt, R
mActivePower = p; mActivePower = p;
mReactivePower = q; mReactivePower = q;
mSvVoltage = volt; mSvVoltage = volt;
// the parameters of the RxLine shouldn't be modified directly; the face that
// this component inherits from RxLine is just an implementation details that
// may change
attrMap.erase(attrMap.find("resistance"));
attrMap.erase(attrMap.find("inductance"));
attrMap["activePower"] = {AttrReal, &this->mActivePower};
attrMap["reactivePower"] = {AttrReal, &this->mReactivePower};
attrMap["svVoltage"] = {AttrReal, &this->mSvVoltage};
} }
void PQLoad::init(Real om, Real dt) { void PQLoad::init(Real om, Real dt) {
...@@ -18,3 +26,13 @@ void PQLoad::init(Real om, Real dt) { ...@@ -18,3 +26,13 @@ void PQLoad::init(Real om, Real dt) {
mInductance = reactance/om; mInductance = reactance/om;
RxLine::init(om, dt); RxLine::init(om, dt);
} }
void PQLoad::applySystemMatrixStamp(SystemModel& system) {
// powers / svvoltage might have changed, so update them
Real abs = mActivePower*mActivePower+mReactivePower*mReactivePower;
mResistance = mSvVoltage*mSvVoltage*mActivePower/abs;
mConductance = 1.0 / mResistance;
Real reactance = mSvVoltage*mSvVoltage*mReactivePower/abs;
mInductance = reactance/system.getOmega();
RxLine::applySystemMatrixStamp(system);
}
...@@ -13,6 +13,7 @@ namespace DPsim { ...@@ -13,6 +13,7 @@ namespace DPsim {
public: public:
PQLoad(std::string name, int src, int dest, Real p, Real q, Real volt, Real angle); PQLoad(std::string name, int src, int dest, Real p, Real q, Real volt, Real angle);
void init(Real om, Real dt); void init(Real om, Real dt);
void applySystemMatrixStamp(SystemModel&);
}; };
}; };
......
...@@ -4,13 +4,15 @@ using namespace DPsim; ...@@ -4,13 +4,15 @@ using namespace DPsim;
PiLine::PiLine(std::string name, int node1, int node2, int node3, Real resistance, Real inductance, Real capacitance) : BaseComponent(name, node1, node2, node3) { PiLine::PiLine(std::string name, int node1, int node2, int node3, Real resistance, Real inductance, Real capacitance) : BaseComponent(name, node1, node2, node3) {
mResistance = resistance; mResistance = resistance;
mConductance = 1.0 / resistance;
mInductance = inductance; mInductance = inductance;
mCapacitance = capacitance / 2; mCapacitance = capacitance;
attrMap["resistance"] = {AttrReal, &this->mResistance};
attrMap["inductance"] = {AttrReal, &this->mInductance};
attrMap["capacitance"] = {AttrReal, &this->mCapacitance};
} }
void PiLine::applySystemMatrixStamp(SystemModel& system) { void PiLine::applySystemMatrixStamp(SystemModel& system) {
mConductance = 1.0 / mResistance;
Real a = system.getTimeStep() / (2. * mInductance); Real a = system.getTimeStep() / (2. * mInductance);
Real b = system.getTimeStep() * system.getOmega() / 2.; Real b = system.getTimeStep() * system.getOmega() / 2.;
mGlr = a / (1 + b*b); mGlr = a / (1 + b*b);
...@@ -43,9 +45,9 @@ void PiLine::applySystemMatrixStamp(SystemModel& system) { ...@@ -43,9 +45,9 @@ void PiLine::applySystemMatrixStamp(SystemModel& system) {
system.addCompToSystemMatrix(mNode2, mNode3, -mGlr, -mGli); system.addCompToSystemMatrix(mNode2, mNode3, -mGlr, -mGli);
} }
//capacitive part //capacitive part (only using half of nominal capaticance)
mGcr = 2.0 * mCapacitance / system.getTimeStep(); mGcr = mCapacitance / system.getTimeStep();
mGci = system.getOmega() * mCapacitance; mGci = system.getOmega() * mCapacitance / 2;
if (mNode1 >= 0) { if (mNode1 >= 0) {
system.addCompToSystemMatrix(mNode1, mNode1, mGcr, mGci); system.addCompToSystemMatrix(mNode1, mNode1, mGcr, mGci);
......
...@@ -95,4 +95,4 @@ namespace DPsim { ...@@ -95,4 +95,4 @@ namespace DPsim {
}; };
} }
#endif #endif
\ No newline at end of file
...@@ -216,4 +216,3 @@ void RxLine::postStep(SystemModel& system) { ...@@ -216,4 +216,3 @@ void RxLine::postStep(SystemModel& system) {
Complex RxLine::getCurrent(SystemModel& system) { Complex RxLine::getCurrent(SystemModel& system) {
return Complex(mCurrRe, mCurrIm); return Complex(mCurrRe, mCurrIm);
} }
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