Commit 379267e9 authored by Felix Wege's avatar Felix Wege
Browse files

added setParameters flag

parent ab23bcf6
......@@ -51,6 +51,9 @@ namespace CPS {
/// "Cached" flags for whether the connected nodes are grounded
std::vector<bool> mSimNodeIsGround;
/// Flag indicating that parameters are set via setParameters() function
bool parametersSet = false;
public:
typedef VarType Type;
typedef std::shared_ptr<PowerComponent<VarType>> Ptr;
......
......@@ -32,6 +32,7 @@ DP::Ph1::RXLoad::RXLoad(String uid, String name,
addAttribute<Real>("P", &mActivePower, Flags::read | Flags::write);
addAttribute<Real>("Q", &mReactivePower, Flags::read | Flags::write);
addAttribute<Real>("V_nom", &mNomVoltage, Flags::read | Flags::write);
}
DP::Ph1::RXLoad::RXLoad(String name,
......@@ -64,11 +65,12 @@ void DP::Ph1::RXLoad::initialize(Matrix frequencies) {
void DP::Ph1::RXLoad::initializeFromPowerflow(Real frequency) {
checkForUnconnectedTerminals();
mActivePower = mTerminals[0]->singleActivePower();
mReactivePower = mTerminals[0]->singleReactivePower();
mPower = { mActivePower, mReactivePower };
mNomVoltage = std::abs(mTerminals[0]->initialSingleVoltage());
if(!parametersSet){
mActivePower = mTerminals[0]->singleActivePower();
mReactivePower = mTerminals[0]->singleReactivePower();
mPower = { mActivePower, mReactivePower };
mNomVoltage = std::abs(mTerminals[0]->initialSingleVoltage());
}
if (mActivePower != 0) {
mResistance = std::pow(mNomVoltage, 2) / mActivePower;
......@@ -122,6 +124,8 @@ void DP::Ph1::RXLoad::setParameters(Real activePower, Real reactivePower, Real v
mReactivePower = reactivePower;
mPower = { mActivePower, mReactivePower};
mNomVoltage = volt;
parametersSet = true;
}
......
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