Commit 074d7866 authored by Martin Alonso Moraga's avatar Martin Alonso Moraga

fixed some errors

parent 249c98dd
......@@ -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,21 +107,6 @@ 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;}
};
}
}
......
......@@ -135,33 +135,3 @@ 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();
}
Markdown is supported
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