Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix consistency of calculations at first time step #210

Merged
merged 10 commits into from
Nov 27, 2023
16 changes: 15 additions & 1 deletion docs/hugo/content/en/docs/Development/Guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ linkTitle: "Guidelines"

This is a summary of general guidelines for the development of DPsim.

## Scaling of Voltages and Currents

Voltage quantities are expressed either as phase-to-phase RMS values (denominated as `RMS3PH`) or as phase-to-ground peak values (denominated as `PEAK1PH`):

- Initialisation quantities (e.g. `initialSingleVoltage` of `SimPowerComp`) as `RMS3PH` values
- Simulation quantities in both `SP` and `DP` domain (e.g. `mIntfVoltage` of `DP::Ph1::PiLine`) as `RMS3PH values`
- Simulation quantities in the `EMT` domain (e.g. `mIntfVoltage` of `EMT::Ph3::Transformer`) as `PEAK1PH` values

Current quantities are expressed either as `RMS` or as `PEAK` values:

- Simulation quantities in both `SP` and `DP` domain (e.g. `mIntfCurrent` of `DP::Ph1::PiLine`) as `RMS` values
- Simulation quantities in the `EMT` domain (e.g. `mIntfCurrent` of `EMT::Ph3::Transformer`) as `PEAK` values


## Logging

Debug or trace should be the default log level for information that might be nice to have but not necessary for every simulation case.
Expand All @@ -23,4 +37,4 @@ A new version of DPsim has to be indicated as follows:
- Update sonar-project.properties

Due to the creation of a new tag, a new PyPi package will be deployed automatically.
To release an updated Docker image, the container workflow needs to be triggered manually.
To release an updated Docker image, the container workflow needs to be triggered manually.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ namespace Ph1 {
class VoltageSource :
public MNASimPowerComp<Real>,
public SharedFactory<VoltageSource> {
private:
Real mTimeStep;
protected:
void updateVoltage(Real time);
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,13 @@ namespace Ph3 {
void CalculateAuxiliarConstants(Real dt);
void CalculateAuxiliarVariables();

/// Getters
//Matrix& rotorFluxes() { return mRotorFlux; }
Matrix& dqStatorCurrents();
Real electricalTorque() const;
Real rotationalSpeed() const;
Real rotorPosition() const;
Matrix& statorCurrents();
Matrix& dqStatorCurrents() { return mDqStatorCurrents; }
Real electricalTorque() const { return **mElecTorque * mBase_T; }
Real rotationalSpeed() const { return **mOmMech * mBase_OmMech; }
Real rotorPosition() const { return mThetaMech; }
Matrix& statorCurrents() { return mIabc; }

// #### MNA section ####
/// Stamps system matrix
Expand All @@ -262,7 +263,7 @@ namespace Ph3 {
/// Add MNA post step dependencies
void mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector);
/// Mark that parameter changes so that system matrix is updated
Bool hasParameterChanged() override;
Bool hasParameterChanged() override { return true; }
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ namespace CPS {
private:
///
CPS::Signal::SignalGenerator::Ptr mSrcSig;
///
Real mTimeStep;
protected:
// Updates voltage according to reference phasor and frequency
void updateVoltage(Real time);
Expand Down
2 changes: 2 additions & 0 deletions dpsim-models/include/dpsim-models/SimNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ namespace CPS {
SimNode(UInt matrixNodeIndex, PhaseType phaseType = PhaseType::Single)
: SimNode("N" + std::to_string(matrixNodeIndex), "N" + std::to_string(matrixNodeIndex), matrixNodeIndex, phaseType) { }

/// Initialize mVoltage according to mInitialVoltage
void initialize();
/// Initialize state matrices with size according to phase type and frequency number
void initialize(Matrix frequencies);
/// Returns matrix index for specified phase
Expand Down
46 changes: 26 additions & 20 deletions dpsim-models/src/Base/Base_ReducedOrderSynchronGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,16 @@ void Base::ReducedOrderSynchronGenerator<Real>::initializeFromNodesAndTerminals(
// initialize theta and calculate transform matrix
**mThetaMech = **mDelta - PI / 2.;

// set initial interface current
(**mIntfCurrent)(0,0) = (mInitCurrent * mBase_I).real();
(**mIntfCurrent)(1,0) = (mInitCurrent * mBase_I * SHIFT_TO_PHASE_B).real();
(**mIntfCurrent)(2,0) = (mInitCurrent * mBase_I * SHIFT_TO_PHASE_C).real();

// set initial interface voltage
(**mIntfVoltage)(0,0) = (mInitVoltage * mBase_V).real();
(**mIntfVoltage)(1,0) = (mInitVoltage * mBase_V * SHIFT_TO_PHASE_B).real();
(**mIntfVoltage)(2,0) = (mInitVoltage * mBase_V * SHIFT_TO_PHASE_C).real();

SPDLOG_LOGGER_DEBUG(this->mSLog,
"\n--- Initialization from power flow ---"
"\nInitial Vd (per unit): {:f}"
Expand Down Expand Up @@ -423,6 +433,12 @@ void Base::ReducedOrderSynchronGenerator<Complex>::initializeFromNodesAndTermina
// initialize theta and calculate transform matrix
**mThetaMech = **mDelta - PI / 2.;

// set initial value of current
(**mIntfCurrent)(0,0) = mInitCurrent * mBase_I_RMS;

// set initial interface voltage
(**mIntfVoltage)(0,0) = mInitVoltage * mBase_V_RMS;

SPDLOG_LOGGER_DEBUG(this->mSLog,
"\n--- Initialization from power flow ---"
"\nInitial Vd (per unit): {:f}"
Expand Down Expand Up @@ -476,16 +492,11 @@ void Base::ReducedOrderSynchronGenerator<Complex>::mnaCompPreStep(Real time, Int
**mMechTorque = mTurbineGovernor->step(**mOmMech, mTimeStep);
}

// predict mechanical vars for all reduced-order models in the same manner
if (mSimTime > 0.0) {
// predict omega at t=k+1 (forward euler)
**mElecTorque = (**mVdq)(0,0) * (**mIdq)(0,0) + (**mVdq)(1,0) * (**mIdq)(1,0);
**mOmMech = **mOmMech + mTimeStep * (1. / (2. * mH) * (mMechTorque_prev - **mElecTorque));

// predict theta and delta at t=k+1 (backward euler)
**mThetaMech = **mThetaMech + mTimeStep * (**mOmMech * mBase_OmMech);
**mDelta = **mDelta + mTimeStep * (**mOmMech - 1.) * mBase_OmMech;
}
// calculate mechanical variables at t=k+1 with forward euler
**mElecTorque = (**mVdq)(0,0) * (**mIdq)(0,0) + (**mVdq)(1,0) * (**mIdq)(1,0);
**mOmMech = **mOmMech + mTimeStep * (1. / (2. * mH) * (mMechTorque_prev - **mElecTorque));
**mThetaMech = **mThetaMech + mTimeStep * (**mOmMech * mBase_OmMech);
**mDelta = **mDelta + mTimeStep * (**mOmMech - 1.) * mBase_OmMech;

// model specific calculation of electrical vars
stepInPerUnit();
Expand All @@ -509,16 +520,11 @@ void Base::ReducedOrderSynchronGenerator<Real>::mnaCompPreStep(Real time, Int ti
**mMechTorque = mTurbineGovernor->step(**mOmMech, mTimeStep);
}

// predict mechanical vars for all reduced-order models in the same manner
if (mSimTime > 0.0) {
// predict omega at t=k+1 (forward euler)
**mElecTorque = (**mVdq0)(0,0) * (**mIdq0)(0,0) + (**mVdq0)(1,0) * (**mIdq0)(1,0);
**mOmMech = **mOmMech + mTimeStep * (1. / (2. * mH) * (mMechTorque_prev - **mElecTorque));

// predict theta and delta at t=k+1 (backward euler)
**mThetaMech = **mThetaMech + mTimeStep * (**mOmMech * mBase_OmMech);
**mDelta = **mDelta + mTimeStep * (**mOmMech - 1.) * mBase_OmMech;
}
// calculate mechanical variables at t=k+1 with forward euler
**mElecTorque = ((**mVdq0)(0,0) * (**mIdq0)(0,0) + (**mVdq0)(1,0) * (**mIdq0)(1,0));
**mOmMech = **mOmMech + mTimeStep * (1. / (2. * mH) * (mMechTorque_prev - **mElecTorque));
**mThetaMech = **mThetaMech + mTimeStep * (**mOmMech * mBase_OmMech);
**mDelta = **mDelta + mTimeStep * (**mOmMech - 1.) * mBase_OmMech;

// model specific calculation of electrical vars
stepInPerUnit();
Expand Down
2 changes: 2 additions & 0 deletions dpsim-models/src/DP/DP_Ph1_Capacitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void DP::Ph1::Capacitor::initializeFromNodesAndTerminals(Real frequency) {
Logger::phasorToString((**mIntfCurrent)(0,0)),
Logger::phasorToString(initialSingleVoltage(0)),
Logger::phasorToString(initialSingleVoltage(1)));
mSLog->flush();
}

void DP::Ph1::Capacitor::mnaCompInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
Expand Down Expand Up @@ -82,6 +83,7 @@ void DP::Ph1::Capacitor::mnaCompInitialize(Real omega, Real timeStep, Attribute<
Logger::phasorToString((**mIntfVoltage)(0,0)),
Logger::phasorToString((**mIntfCurrent)(0,0)),
Logger::complexToString(mEquivCurrent(0,0)));
mSLog->flush();
}

void DP::Ph1::Capacitor::mnaCompInitializeHarm(Real omega, Real timeStep, std::vector<Attribute<Matrix>::Ptr> leftVectors) {
Expand Down
12 changes: 5 additions & 7 deletions dpsim-models/src/DP/DP_Ph1_SynchronGenerator4OrderTPM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ void DP::Ph1::SynchronGenerator4OrderTPM::specificInitialization() {
// initial emf in the dq reference frame
(**mEdq_t)(0,0) = (**mVdq)(0,0) - (**mIdq)(1,0) * mLq_t;
(**mEdq_t)(1,0) = (**mVdq)(1,0) + (**mIdq)(0,0) * mLd_t;

// set previous values of stator current at simulation start
//(**mIntfCurrent)(0,0) = std::conj(mInitElecPower / (mInitVoltage * mBase_V_RMS));
mIdpTwoPrevStep = **mIntfCurrent;

SPDLOG_LOGGER_INFO(mSLog,
"\n--- Model specific initialization ---"
"\nInitial Ed_t (per unit): {:f}"
Expand Down Expand Up @@ -147,13 +152,6 @@ void DP::Ph1::SynchronGenerator4OrderTPM::stepInPerUnit() {
mResistanceMatrixVarying(1,1) = (mA + mB) / 2.0 * sin(2*DeltaTheta);
SPDLOG_LOGGER_DEBUG(mSLog, "\nR_var [pu] (t={:f}): {:s}", mSimTime, Logger::matrixToString(mResistanceMatrixVarying));

// predict electrical vars
// set previous values of stator current at simulation start
if (mSimTime == 0.0) {
(**mIntfCurrent)(0,0) = std::conj(mInitElecPower / (mInitVoltage * mBase_V_RMS));
mIdpTwoPrevStep = **mIntfCurrent;
}

// predict stator current (linear extrapolation)
Matrix IdpPrediction = Matrix::Zero(2,1);
IdpPrediction(0,0) = 2 * (**mIntfCurrent)(0,0).real() - mIdpTwoPrevStep(0,0).real();
Expand Down
18 changes: 10 additions & 8 deletions dpsim-models/src/DP/DP_Ph1_SynchronGenerator6aOrderVBR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ void DP::Ph1::SynchronGenerator6aOrderVBR::specificInitialization() {
(**mEdq_s)(0,0) = (**mVdq)(0,0) - mLq_s * (**mIdq)(1,0);
(**mEdq_s)(1,0) = (**mVdq)(1,0) + mLd_s * (**mIdq)(0,0);

// initialize history term behind the transient reactance
mEh_t(0,0) = mAd_t * (**mIdq)(1,0) + mBd_t * (**mEdq_t)(0,0);
mEh_t(1,0) = mAq_t * (**mIdq)(0,0) + mBq_t * (**mEdq_t)(1,0) + mDq_t * (**mEf) + mDq_t * mEf_prev;

SPDLOG_LOGGER_INFO(mSLog,
"\n--- Model specific initialization ---"
"\nSG model: 6th order type a (Marconato's model)"
Expand All @@ -63,15 +67,13 @@ void DP::Ph1::SynchronGenerator6aOrderVBR::stepInPerUnit() {
mDomainInterface.updateDQToDPTransform(**mThetaMech, mSimTime);
mDomainInterface.updateDPToDQTransform(**mThetaMech, mSimTime);

if (mSimTime>0.0){
// calculate Edq_t at t=k
(**mEdq_t)(0,0) = mAd_t * (**mIdq)(1,0) + mEh_t(0,0);
(**mEdq_t)(1,0) = mAq_t * (**mIdq)(0,0) + mEh_t(1,0);
// calculate Edq_t at t=k
(**mEdq_t)(0,0) = mAd_t * (**mIdq)(1,0) + mEh_t(0,0);
(**mEdq_t)(1,0) = mAq_t * (**mIdq)(0,0) + mEh_t(1,0);

// calculate Edq_s at t=k
(**mEdq_s)(0,0) = -(**mIdq)(1,0) * mLq_s + (**mVdq)(0,0);
(**mEdq_s)(1,0) = (**mIdq)(0,0) * mLd_s + (**mVdq)(1,0);
}
// calculate Edq_s at t=k
(**mEdq_s)(0,0) = -(**mIdq)(1,0) * mLq_s + (**mVdq)(0,0);
(**mEdq_s)(1,0) = (**mIdq)(0,0) * mLd_s + (**mVdq)(1,0);

// Update time-varying reactance matrix
calculateConductanceMatrix();
Expand Down
20 changes: 11 additions & 9 deletions dpsim-models/src/DP/DP_Ph1_SynchronGenerator6bOrderVBR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ void DP::Ph1::SynchronGenerator6bOrderVBR::specificInitialization() {
(**mEdq_s)(0,0) = (**mVdq)(0,0) - mLq_s * (**mIdq)(1,0);
(**mEdq_s)(1,0) = (**mVdq)(1,0) + mLd_s * (**mIdq)(0,0);

SPDLOG_LOGGER_INFO(mSLog,
// initialize history term behind the transient reactance
mEh_t(0,0) = mAd_t * (**mIdq)(1,0) + mBd_t * (**mEdq_t)(0,0);
mEh_t(1,0) = mAq_t * (**mIdq)(0,0) + mBq_t * (**mEdq_t)(1,0) + mDq_t * (**mEf) + mDq_t * mEf_prev;

SPDLOG_LOGGER_INFO(mSLog,
"\n--- Model specific initialization ---"
"\nSG model: 6th order type b (Anderson - Fouad's model)"
"\nInitial Ed_t (per unit): {:f}"
Expand All @@ -64,15 +68,13 @@ void DP::Ph1::SynchronGenerator6bOrderVBR::stepInPerUnit() {
mDomainInterface.updateDQToDPTransform(**mThetaMech, mSimTime);
mDomainInterface.updateDPToDQTransform(**mThetaMech, mSimTime);

if (mSimTime>0.0){
// calculate Edq_t at t=k
(**mEdq_t)(0,0) = mAd_t * (**mIdq)(1,0) + mEh_t(0,0);
(**mEdq_t)(1,0) = mAq_t * (**mIdq)(0,0) + mEh_t(1,0);
// calculate Edq_t at t=k
(**mEdq_t)(0,0) = mAd_t * (**mIdq)(1,0) + mEh_t(0,0);
(**mEdq_t)(1,0) = mAq_t * (**mIdq)(0,0) + mEh_t(1,0);

// calculate Edq_s at t=k
(**mEdq_s)(0,0) = -(**mIdq)(1,0) * mLq_s + (**mVdq)(0,0);
(**mEdq_s)(1,0) = (**mIdq)(0,0) * mLd_s + (**mVdq)(1,0);
}
// calculate Edq_s at t=k
(**mEdq_s)(0,0) = -(**mIdq)(1,0) * mLq_s + (**mVdq)(0,0);
(**mEdq_s)(1,0) = (**mIdq)(0,0) * mLd_s + (**mVdq)(1,0);

// Update time-varying reactance matrix
calculateConductanceMatrix();
Expand Down
10 changes: 6 additions & 4 deletions dpsim-models/src/EMT/EMT_Ph1_Capacitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ void EMT::Ph1::Capacitor::initializeFromNodesAndTerminals(Real frequency) {

Real omega = 2 * PI * frequency;
Complex impedance = { 0, - 1. / (omega * **mCapacitance) };
(**mIntfVoltage)(0,0) = (initialSingleVoltage(1) - initialSingleVoltage(0)).real();
(**mIntfCurrent)(0,0) = ((initialSingleVoltage(1) - initialSingleVoltage(0)) / impedance).real();
Complex voltage = RMS3PH_TO_PEAK1PH * (initialSingleVoltage(1) - initialSingleVoltage(0));
(**mIntfVoltage)(0,0) = voltage.real();
(**mIntfCurrent)(0,0) = (voltage / impedance).real();

SPDLOG_LOGGER_INFO(mSLog,
"\n--- Initialization from powerflow ---"
Expand All @@ -40,8 +41,9 @@ void EMT::Ph1::Capacitor::initializeFromNodesAndTerminals(Real frequency) {
"\n--- Initialization from powerflow finished ---",
(**mIntfVoltage)(0,0),
(**mIntfCurrent)(0,0),
initialSingleVoltage(0).real(),
initialSingleVoltage(1).real());
(RMS3PH_TO_PEAK1PH * initialSingleVoltage(0)).real(),
(RMS3PH_TO_PEAK1PH * initialSingleVoltage(1)).real());
mSLog->flush();
}

void EMT::Ph1::Capacitor::mnaCompInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
Expand Down
9 changes: 5 additions & 4 deletions dpsim-models/src/EMT/EMT_Ph1_Inductor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ void EMT::Ph1::Inductor::initializeFromNodesAndTerminals(Real frequency) {

Real omega = 2 * PI * frequency;
Complex impedance = { 0, omega * **mInductance };
(**mIntfVoltage)(0,0) = (initialSingleVoltage(1) - initialSingleVoltage(0)).real();
(**mIntfCurrent)(0,0) = ((initialSingleVoltage(1) - initialSingleVoltage(0)) / impedance).real();
Complex voltage = RMS3PH_TO_PEAK1PH * (initialSingleVoltage(1) - initialSingleVoltage(0));
(**mIntfVoltage)(0,0) = voltage.real();
(**mIntfCurrent)(0,0) = (voltage / impedance).real();

SPDLOG_LOGGER_INFO(mSLog,
"\n--- Initialization from powerflow ---"
Expand All @@ -40,8 +41,8 @@ void EMT::Ph1::Inductor::initializeFromNodesAndTerminals(Real frequency) {
"\n--- Initialization from powerflow finished ---",
(**mIntfVoltage)(0,0),
(**mIntfCurrent)(0,0),
initialSingleVoltage(0).real(),
initialSingleVoltage(1).real());
(RMS3PH_TO_PEAK1PH * initialSingleVoltage(0)).real(),
(RMS3PH_TO_PEAK1PH * initialSingleVoltage(1)).real());
}

void EMT::Ph1::Inductor::mnaCompInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
Expand Down
10 changes: 6 additions & 4 deletions dpsim-models/src/EMT/EMT_Ph1_Resistor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ SimPowerComp<Real>::Ptr EMT::Ph1::Resistor::clone(String name) {
}

void EMT::Ph1::Resistor::initializeFromNodesAndTerminals(Real frequency) {

(**mIntfVoltage)(0,0) = (initialSingleVoltage(1) - initialSingleVoltage(0)).real();
Complex voltage = RMS3PH_TO_PEAK1PH * (initialSingleVoltage(1) - initialSingleVoltage(0));
(**mIntfVoltage)(0,0) = voltage.real();
(**mIntfCurrent)(0,0) = (**mIntfVoltage)(0,0) / **mResistance;

SPDLOG_LOGGER_INFO(mSLog,
Expand All @@ -37,8 +37,9 @@ void EMT::Ph1::Resistor::initializeFromNodesAndTerminals(Real frequency) {
"\n--- Initialization from powerflow finished ---",
(**mIntfVoltage)(0,0),
(**mIntfCurrent)(0,0),
initialSingleVoltage(0).real(),
initialSingleVoltage(1).real());
(RMS3PH_TO_PEAK1PH * initialSingleVoltage(0)).real(),
(RMS3PH_TO_PEAK1PH * initialSingleVoltage(1)).real());
mSLog->flush();
}

void EMT::Ph1::Resistor::mnaCompInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
Expand Down Expand Up @@ -67,6 +68,7 @@ void EMT::Ph1::Resistor::mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMa
SPDLOG_LOGGER_INFO(mSLog, "Add {:f} to system at ({:d},{:d})", -conductance, matrixNodeIndex(0), matrixNodeIndex(1));
SPDLOG_LOGGER_INFO(mSLog, "Add {:f} to system at ({:d},{:d})", -conductance, matrixNodeIndex(1), matrixNodeIndex(0));
}
mSLog->flush();
}

void EMT::Ph1::Resistor::mnaCompAddPostStepDependencies(AttributeBase::List &prevStepDependencies, AttributeBase::List &attributeDependencies, AttributeBase::List &modifiedAttributes, Attribute<Matrix>::Ptr &leftVector) {
Expand Down
6 changes: 4 additions & 2 deletions dpsim-models/src/EMT/EMT_Ph1_VoltageSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ SimPowerComp<Real>::Ptr EMT::Ph1::VoltageSource::clone(String name) {
}

void EMT::Ph1::VoltageSource::mnaCompInitialize(Real omega, Real timeStep, Attribute<Matrix>::Ptr leftVector) {
updateMatrixNodeIndices();
updateMatrixNodeIndices();
(**mIntfVoltage)(0,0) = Math::abs(**mVoltageRef) * cos(Math::phase(**mVoltageRef));

mTimeStep = timeStep;
}

void EMT::Ph1::VoltageSource::mnaCompApplySystemMatrixStamp(SparseMatrixRow& systemMatrix) {
Expand Down Expand Up @@ -66,7 +68,7 @@ void EMT::Ph1::VoltageSource::updateVoltage(Real time) {
Complex voltageRef = mVoltageRef->get();
Real srcFreq = mSrcFreq->get();
if (srcFreq > 0)
(**mIntfVoltage)(0,0) = Math::abs(voltageRef) * cos(time * 2.*PI*srcFreq + Math::phase(voltageRef));
(**mIntfVoltage)(0,0) = Math::abs(voltageRef) * cos((time) * 2.*PI*srcFreq + Math::phase(voltageRef));
else
(**mIntfVoltage)(0,0) = voltageRef.real();
}
Expand Down
4 changes: 2 additions & 2 deletions dpsim-models/src/EMT/EMT_Ph1_VoltageSourceRamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ void EMT::Ph1::VoltageSourceRamp::setParameters(Complex voltage, Complex addVolt
void EMT::Ph1::VoltageSourceRamp::initialize(Matrix frequencies) {
SimPowerComp<Real>::initialize(frequencies);

if (**mVoltageRef == Complex(0, 0))
**mVoltageRef = initialSingleVoltage(1) - initialSingleVoltage(0);
if (**mVoltageRef == Complex(0, 0))
**mVoltageRef = RMS3PH_TO_PEAK1PH * (initialSingleVoltage(1) - initialSingleVoltage(0));

mSubVoltageSource = VoltageSource::make(**mName + "_src", mLogLevel);
mSubVoltageSource->setParameters(**mVoltageRef, 0);
Expand Down
Loading
Loading