Commit d96009fd authored by Markus Mirz's avatar Markus Mirz
Browse files

check for unconnected terminals in solver

parent b93a5c5a
......@@ -97,6 +97,7 @@ void MnaSolver<Real>::initializeComponents() {
for (auto comp : mMNAComponents) {
auto pComp = std::dynamic_pointer_cast<SimPowerComp<Real>>(comp);
if (!pComp) continue;
pComp->checkForUnconnectedTerminals();
pComp->initializeFromPowerflow(mSystem.mSystemFrequency);
}
......@@ -124,6 +125,7 @@ void MnaSolver<Complex>::initializeComponents() {
for (auto comp : mMNAComponents) {
auto pComp = std::dynamic_pointer_cast<SimPowerComp<Complex>>(comp);
if (!pComp) continue;
pComp->checkForUnconnectedTerminals();
pComp->initializeFromPowerflow(mSystem.mSystemFrequency);
}
......
......@@ -148,7 +148,6 @@ void DP::Ph1::AvVoltageSourceInverterDQ::initialize(Matrix frequencies) {
}
void DP::Ph1::AvVoltageSourceInverterDQ::initializeFromPowerflow(Real frequency) {
checkForUnconnectedTerminals();
// set initial interface quantities
mIntfVoltage(0, 0) = initialSingleVoltage(0);
......
......@@ -36,7 +36,6 @@ void DP::Ph1::Capacitor::initialize(Matrix frequencies) {
}
void DP::Ph1::Capacitor::initializeFromPowerflow(Real frequency) {
checkForUnconnectedTerminals();
Real omega = 2 * PI * frequency;
Complex impedance = { 0, - 1. / (omega * mCapacitance) };
......@@ -212,7 +211,7 @@ void DP::Ph1::Capacitor::mnaApplyRightSideVectorStampHarm(Matrix& rightVector, I
}
void DP::Ph1::Capacitor::mnaAddPreStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes) {
// actually depends on C, but then we'd have to modify the system matrix anyway
// actually depends on C, but then we'd have to modify the system matrix anyway
prevStepDependencies.push_back(this->attribute("i_intf"));
prevStepDependencies.push_back(this->attribute("v_intf"));
modifiedAttributes.push_back(this->attribute("right_vector"));
......
......@@ -41,7 +41,6 @@ void DP::Ph1::ControlledVoltageSource::initialize(Matrix frequencies) {
void DP::Ph1::ControlledVoltageSource::mnaInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
checkForUnconnectedTerminals();
MNAInterface::mnaInitialize(omega, timeStep);
updateMatrixNodeIndices();
......@@ -94,7 +93,7 @@ void DP::Ph1::ControlledVoltageSource::mnaAddPostStepDependencies(AttributeBase:
modifiedAttributes.push_back(this->attribute("i_intf"));
}
void DP::Ph1::ControlledVoltageSource::mnaPostStep(Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) {
void DP::Ph1::ControlledVoltageSource::mnaPostStep(Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) {
this->mnaUpdateCurrent(*leftVector);
}
......
......@@ -36,7 +36,6 @@ SimPowerComp<Complex>::Ptr DP::Ph1::CurrentSource::clone(String name) {
}
void DP::Ph1::CurrentSource::initializeFromPowerflow(Real frequency) {
checkForUnconnectedTerminals();
mIntfVoltage(0,0) = initialSingleVoltage(0) - initialSingleVoltage(1);
mCurrentRef = attribute<Complex>("I_ref");
......
......@@ -35,7 +35,6 @@ void DP::Ph1::Inductor::initialize(Matrix frequencies) {
}
void DP::Ph1::Inductor::initializeFromPowerflow(Real frequency) {
checkForUnconnectedTerminals();
Real omega = 2. * PI * frequency;
Complex impedance = { 0, omega * mInductance };
......
......@@ -32,10 +32,7 @@ void DP::Ph1::Inverter::setParameters(std::vector<Int> carrierHarms, std::vector
mParametersSet= true;
}
void DP::Ph1::Inverter::initializeFromPowerflow(Real frequency) {
checkForUnconnectedTerminals();
//mIntfVoltage(0,0) = initialSingleVoltage(0));
}
void DP::Ph1::Inverter::initializeFromPowerflow(Real frequency) { }
void DP::Ph1::Inverter::generateFrequencies() {
for (Int m = 2; m <= mMaxCarrierHarm; m = m+2) {
......
......@@ -28,7 +28,6 @@ SimPowerComp<Complex>::Ptr DP::Ph1::NetworkInjection::clone(String name) {
}
void DP::Ph1::NetworkInjection::initialize(Matrix frequencies) {
checkForUnconnectedTerminals();
mFrequencies = frequencies;
mNumFreqs = static_cast<UInt>(mFrequencies.size());
......
......@@ -57,7 +57,6 @@ SimPowerComp<Complex>::Ptr DP::Ph1::PQLoadCS::clone(String name) {
}
void DP::Ph1::PQLoadCS::initializeFromPowerflow(Real frequency) {
checkForUnconnectedTerminals();
mActivePower = attribute<Real>("P");
mReactivePower = attribute<Real>("Q");
......
......@@ -36,7 +36,6 @@ void DP::Ph1::PiLine::initialize(Matrix frequencies) {
}
void DP::Ph1::PiLine::initializeFromPowerflow(Real frequency) {
checkForUnconnectedTerminals();
// Static calculation
Real omega = 2.*PI * frequency;
......@@ -165,7 +164,7 @@ void DP::Ph1::PiLine::mnaAddPreStepDependencies(AttributeBase::List &prevStepDep
modifiedAttributes.push_back(this->attribute("right_vector"));
}
void DP::Ph1::PiLine::mnaPreStep(Real time, Int timeStepCount) {
void DP::Ph1::PiLine::mnaPreStep(Real time, Int timeStepCount) {
// pre-step of subcomponents
this->mSubSeriesInductor->mnaPreStep(time, timeStepCount);
if (this->mParallelCap >= 0) {
......
......@@ -39,7 +39,6 @@ void DP::Ph1::RXLoad::initialize(Matrix frequencies) {
}
void DP::Ph1::RXLoad::initializeFromPowerflow(Real frequency) {
checkForUnconnectedTerminals();
if(!mParametersSet){
setParameters(
......
......@@ -16,7 +16,7 @@ DP::Ph1::RXLoadSwitch::RXLoadSwitch(String uid, String name, Logger::Level logLe
setVirtualNodeNumber(1);
mIntfVoltage = MatrixComp::Zero(1, 1);
mIntfCurrent = MatrixComp::Zero(1, 1);
// Create sub components
mSubRXLoad = std::make_shared<DP::Ph1::RXLoad>(mName + "_rxload", mLogLevel);
mSubSwitch = std::make_shared<DP::Ph1::Switch>(mName + "_switch", mLogLevel);
......@@ -34,13 +34,12 @@ void DP::Ph1::RXLoadSwitch::initialize(Matrix frequencies) {
}
void DP::Ph1::RXLoadSwitch::initializeFromPowerflow(Real frequency) {
checkForUnconnectedTerminals();
if(!mParametersSet) {
// use powerflow results
mSubRXLoad->setParameters(
mTerminals[0]->singleActivePower(),
mTerminals[0]->singleReactivePower(),
mTerminals[0]->singleActivePower(),
mTerminals[0]->singleReactivePower(),
std::abs(mTerminals[0]->initialSingleVoltage()));
}
......@@ -120,18 +119,18 @@ void DP::Ph1::RXLoadSwitch::mnaAddPreStepDependencies(AttributeBase::List &prevS
void DP::Ph1::RXLoadSwitch::mnaPreStep(Real time, Int timeStepCount) {
mSubRXLoad->mnaPreStep(time, timeStepCount);
// pre-step of component itself
updateSwitchState(time);
mnaApplyRightSideVectorStamp(mRightVector);
}
void DP::Ph1::RXLoadSwitch::mnaAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
void DP::Ph1::RXLoadSwitch::mnaAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector) {
// add post-step dependencies of subcomponents
mSubRXLoad->mnaAddPostStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes, leftVector);
mSubSwitch->mnaAddPostStepDependencies(prevStepDependencies, attributeDependencies, modifiedAttributes, leftVector);
// add post-step dependencies of component itself
attributeDependencies.push_back(leftVector);
modifiedAttributes.push_back(attribute("v_intf"));
......@@ -142,7 +141,7 @@ void DP::Ph1::RXLoadSwitch::mnaPostStep(Real time, Int timeStepCount, Attribute<
// post-step of subcomponents
this->mSubRXLoad->mnaPostStep(time, timeStepCount, leftVector);
this->mSubSwitch->mnaPostStep(time, timeStepCount, leftVector);
mIntfVoltage = mSubRXLoad->attributeMatrixComp("v_intf")->get();
mIntfCurrent = mSubRXLoad->attributeMatrixComp("i_intf")->get();
}
......
......@@ -36,7 +36,6 @@ void DP::Ph1::ResIndSeries::initialize(Matrix frequencies) {
}
void DP::Ph1::ResIndSeries::initializeFromPowerflow(Real frequency) {
checkForUnconnectedTerminals();
Real omega = 2. * PI * frequency;
Complex impedance = { 0, omega * mInductance };
......
......@@ -30,7 +30,6 @@ void DP::Ph1::Resistor::initialize(Matrix frequencies) {
}
void DP::Ph1::Resistor::initializeFromPowerflow(Real frequency) {
checkForUnconnectedTerminals();
Complex impedance = { mResistance, 0 };
mIntfVoltage(0,0) = initialSingleVoltage(1) - initialSingleVoltage(0);
......
......@@ -30,7 +30,6 @@ SimPowerComp<Complex>::Ptr DP::Ph1::RxLine::clone(String name) {
}
void DP::Ph1::RxLine::initializeFromPowerflow(Real frequency) {
checkForUnconnectedTerminals();
mIntfVoltage(0,0) = initialSingleVoltage(1) - initialSingleVoltage(0);
Complex impedance = { mSeriesRes, mSeriesInd * 2.*PI * frequency };
......
......@@ -28,7 +28,6 @@ SimPowerComp<Complex>::Ptr DP::Ph1::Switch::clone(String name) {
}
void DP::Ph1::Switch::initializeFromPowerflow(Real frequency) {
checkForUnconnectedTerminals();
Real impedance = (mIsClosed) ? mClosedResistance : mOpenResistance;
mIntfVoltage(0,0) = initialSingleVoltage(1) - initialSingleVoltage(0);
......@@ -127,10 +126,10 @@ void DP::Ph1::Switch::mnaUpdateCurrent(const Matrix& leftVector) {
mIntfVoltage(0,0) / mOpenResistance;
}
void DP::Ph1::Switch::mnaAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes,
void DP::Ph1::Switch::mnaAddPostStepDependencies(AttributeBase::List &prevStepDependencies,
AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes,
Attribute<Matrix>::Ptr &leftVector) {
attributeDependencies.push_back(leftVector);
modifiedAttributes.push_back(attribute("v_intf"));
modifiedAttributes.push_back(attribute("i_intf"));
......@@ -139,4 +138,4 @@ void DP::Ph1::Switch::mnaAddPostStepDependencies(AttributeBase::List &prevStepDe
void DP::Ph1::Switch::mnaPostStep(Real time, Int timeStepCount, Attribute<Matrix>::Ptr &leftVector) {
mnaUpdateVoltage(*leftVector);
mnaUpdateCurrent(*leftVector);
}
\ No newline at end of file
}
......@@ -35,7 +35,6 @@ void DP::Ph1::SynchronGeneratorIdeal::initialize(Matrix frequencies) {
}
void DP::Ph1::SynchronGeneratorIdeal::initializeFromPowerflow(Real frequency) {
checkForUnconnectedTerminals();
// maybe not necessary because voltage source is also set up from powerflow
mVoltageRef = initialSingleVoltage(0);
......
......@@ -105,7 +105,6 @@ void DP::Ph1::SynchronGeneratorTrStab::initialize(Matrix frequencies) {
}
void DP::Ph1::SynchronGeneratorTrStab::initializeFromPowerflow(Real frequency) {
checkForUnconnectedTerminals();
// Initialize omega mech with nominal system frequency
mOmMech = mNomOmega;
......
......@@ -52,7 +52,6 @@ void DP::Ph1::Transformer::initialize(Matrix frequencies) {
}
void DP::Ph1::Transformer::initializeFromPowerflow(Real frequency) {
checkForUnconnectedTerminals();
// Component parameters are referred to high voltage side.
// Switch terminals if transformer is connected the other way around.
......@@ -125,13 +124,13 @@ void DP::Ph1::Transformer::mnaInitialize(Real omega, Real timeStep, Attribute<Ma
if (mSubResistor)
subComponents.push_back(mSubResistor);
for (auto comp : subComponents) {
comp->mnaInitialize(omega, timeStep, leftVector);
for (auto task : comp->mnaTasks())
mMnaTasks.push_back(task);
}
mMnaTasks.push_back(std::make_shared<MnaPreStep>(*this));
......@@ -190,7 +189,7 @@ void DP::Ph1::Transformer::mnaAddPreStepDependencies(AttributeBase::List &prevSt
modifiedAttributes.push_back(this->attribute("right_vector"));
}
void DP::Ph1::Transformer::mnaPreStep(Real time, Int timeStepCount) {
void DP::Ph1::Transformer::mnaPreStep(Real time, Int timeStepCount) {
// pre-step of subcomponents
this->mSubInductor->mnaPreStep(time, timeStepCount);
// pre-step of component itself
......
......@@ -31,7 +31,6 @@ SimPowerComp<Complex>::Ptr DP::Ph3::Capacitor::clone(String name) {
}
void DP::Ph3::Capacitor::initializeFromPowerflow(Real frequency) {
checkForUnconnectedTerminals();
Real omega = 2 * PI * frequency;
MatrixComp susceptance = Matrix::Zero(3, 3);
......
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