...
 
Commits (21)
......@@ -11,7 +11,6 @@
#include <cps/SimPowerComp.h>
#include <cps/Solver/PFSolverInterfaceBus.h>
#include <cps/Solver/MNAInterface.h>
#include <cps/Solver/DAEInterface.h>
namespace CPS {
namespace SP {
......@@ -21,8 +20,7 @@ namespace Ph1 {
public SimPowerComp<Complex>,
public SharedFactory<externalGridInjection>,
public PFSolverInterfaceBus,
public MNAInterface,
public DAEInterface {
public MNAInterface {
private:
......@@ -109,22 +107,7 @@ namespace Ph1 {
externalGridInjection& mExternalGridInjection;
Attribute<Matrix>::Ptr mLeftVector;
};
// #### DAE Section ####
///
Complex daeInitialize() override;
// TODO
void daeInitialize(double time, double state[], double dstate_dt[], int& counter){};
/// Residual function for DAE Solver
void daeResidual(double time, const double state[], const double dstate_dt[], double resid[], std::vector<int>& off) override;
//TODO
void daePostStep(const double state[], const double dstate_dt[], int& counter){};
//TODO
int getNumberOfStateVariables() {return 0;}
};
};
}
}
}
......@@ -146,4 +146,4 @@ void EMT::Ph1::Resistor::daePostStep(const double state[], const double dstate_d
mIntfVoltage(0,0) += state[Pos2];
}
mIntfCurrent(0,0) = mIntfVoltage(0,0) / mResistance;
}
}
\ No newline at end of file
......@@ -194,7 +194,6 @@ void EMT::Ph3::NetworkInjection::daeResidual(double sim_time,
resid[c_offset] = -mIntfVoltage(0,0);
resid[c_offset+1] = -mIntfVoltage(1,0);
resid[c_offset+2] = -mIntfVoltage(2,0);
// update nodal equations
resid[matrixNodeIndex(0, 0)] += state[c_offset];
resid[matrixNodeIndex(0, 1)] += state[c_offset+1];
......
......@@ -264,7 +264,7 @@ void EMT::Ph3::PiLine::mnaUpdateCurrent(const Matrix& leftVector) {
// #### DAE functions ####
void EMT::Ph3::PiLine::daeInitialize(double time, double state[],
void EMT::Ph3::PiLine::daeInitialize(double time, double state[],
double dstate_dt[], int& offset) {
// offset: number of component in state, dstate_dt
// state[offset] = current through voltage source flowing into node matrixNodeIndex(1)
......@@ -332,8 +332,8 @@ void EMT::Ph3::PiLine::daeInitialize(double time, double state[],
offset+=3;
}
void EMT::Ph3::PiLine::daeResidual(double sim_time,
const double state[], const double dstate_dt[],
void EMT::Ph3::PiLine::daeResidual(double sim_time,
const double state[], const double dstate_dt[],
double resid[], std::vector<int>& off) {
/*
R*i_rx + L*der(i_rx) = v1 - v2;
......
......@@ -134,34 +134,4 @@ void SP::Ph1::externalGridInjection::MnaPostStep::execute(Real time, Int timeSte
void SP::Ph1::externalGridInjection::mnaUpdateCurrent(const Matrix& leftVector) {
mIntfCurrent(0, 0) = Math::complexFromVectorElement(leftVector, mVirtualNodes[0]->matrixNodeIndex());
}
void SP::Ph1::externalGridInjection::daeResidual(double ttime, const double state[], const double dstate_dt[], double resid[], std::vector<int>& off) {
/* new state vector definintion:
state[0]=node0_voltage
state[1]=node1_voltage
....
state[n]=noden_voltage
state[n+1]=component0_voltage
state[n+2]=component0_inductance (not yet implemented)
...
state[m-1]=componentm_voltage
state[m]=componentm_inductance
*/
int Pos1 = matrixNodeIndex(0);
int Pos2 = matrixNodeIndex(1);
int c_offset = off[0] + off[1]; //current offset for component
int n_offset_1 = c_offset + Pos1 + 1;// current offset for first nodal equation
int n_offset_2 = c_offset + Pos2 + 1;// current offset for second nodal equation
resid[c_offset] = (state[Pos2] - state[Pos1]) - state[c_offset]; // Voltage equation for Resistor
//resid[++c_offset] = ; //TODO : add inductance equation
resid[n_offset_1] += mIntfCurrent(0, 0).real();
resid[n_offset_2] += mIntfCurrent(0, 0).real();
off[1] += 1;
}
Complex SP::Ph1::externalGridInjection::daeInitialize() {
mIntfVoltage(0, 0) = mVoltageRef->get();
return mVoltageRef->get();
}
}
\ No newline at end of file