Skip to content

Commit

Permalink
changes made to node --> error in nodescomponents
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Mees <[email protected]>
  • Loading branch information
matthiasmees committed Dec 7, 2023
1 parent 3dabcf0 commit a634ad7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
10 changes: 4 additions & 6 deletions dpsim-models/src/EMT/EMT_Ph3_VoltageGain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ void EMT::Ph3::VoltageGain::setParameters(Real K_p) {
SPDLOG_LOGGER_INFO(mSLog, "K_p = {}", K_p);

mGain->setParameters(K_p);

//mK_p = K_p;
}


Expand All @@ -108,7 +106,7 @@ void EMT::Ph3::VoltageGain::initializeFromNodesAndTerminals(Real frequency) {


// Set Node 0 voltage
mVirtualNodes[0]->setInitialVoltage(intfVoltageComplex); // 3x1 Matrix complex
//mVirtualNodes[0]->setInitialVoltage(intfVoltageComplex); // 3x1 Matrix complex


// Calculate Powers
Expand All @@ -119,8 +117,8 @@ void EMT::Ph3::VoltageGain::initializeFromNodesAndTerminals(Real frequency) {
**mElecPassivePower = ( 3./2. * intfVoltageComplex(0,0) * std::conj( - intfCurrentComplex(0,0)) ).imag();

// Initialize and connect controlled source
mSubCtrledVoltageSource->setParameters(mVirtualNodes[0]->initialVoltage(), frequency); //voltage ref, frequency
mSubCtrledVoltageSource->connect({ SimNode::GND, mVirtualNodes[0] });
mSubCtrledVoltageSource->setParameters(intfVoltageComplex, frequency); //voltage ref, frequency
mSubCtrledVoltageSource->connect({ SimNode::GND, terminal(0)->node() }); // terminal: direct connection, virtualnode: intern connections


// Initialize gain controller
Expand All @@ -136,7 +134,7 @@ void EMT::Ph3::VoltageGain::initializeFromNodesAndTerminals(Real frequency) {
// Initialize control subcomponents
// voltage input for gain controller
//Matrix ircdq;
Real theta = std::arg(mVirtualNodes[0]->initialSingleVoltage());
Real theta = std::arg(intfVoltageComplex(0,0));
**mVcdq = parkTransformPowerInvariant(theta, intfVoltageComplex.real());
//ircdq = parkTransformPowerInvariant(theta, -1 * filterInterfaceInitialCurrent.real());

Expand Down
22 changes: 11 additions & 11 deletions dpsim/examples/cxx/Circuits/EMT_P_Block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ int main(int argc, char* argv[]) {
Logger::setLogDir("logs/" + simNamePF);

// ----- POWERFLOW FOR INITIALIZATION -----
Real timeStepPF = finalTime;
Real finalTimePF = finalTime+timeStepPF;

//Real timeStepPF = finalTime;
//Real finalTimePF = finalTime+timeStepPF;

/*
// Components
auto n1PF = SimNode<Complex>::make("n1", PhaseType::Single);
auto n2PF = SimNode<Complex>::make("n2", PhaseType::Single);
Expand Down Expand Up @@ -71,34 +71,34 @@ int main(int argc, char* argv[]) {
simPF.addLogger(loggerPF);
simPF.run();

*/
// Define simulation scenario


// Nodes
auto n1 = SimNode<Real>::make("n1");
auto n2 = SimNode<Real>::make("n2");


// Components
auto vs = EMT::Ph3::VoltageSource::make("vs");
vs->setParameters(CPS::Math::singlePhaseVariableToThreePhase(Complex(10, 0)), 50);
//auto vs = EMT::Ph3::VoltageSource::make("vs");
//vs->setParameters(CPS::Math::singlePhaseVariableToThreePhase(Complex(10, 0)), 50);
auto r1 = EMT::Ph3::Resistor::make("r_1");
r1->setParameters(CPS::Math::singlePhaseParameterToThreePhase(5));
auto p1 = EMT::Ph3::VoltageGain::make("p_1");
p1->setParameters(5);

// Topology
vs->connect({ n1 });
//vs->connect({ n1 });
p1->connect({ n1 });
r1->connect({ n2 });
r1->connect({ n1 });

// Define system topology
auto sys = SystemTopology(50, SystemNodeList{n1, n2}, SystemComponentList{vs, r1, p1});
auto sys = SystemTopology(50, SystemNodeList{n1}, SystemComponentList{r1, p1});

// Logger
auto logger = DataLogger::make(simName);
logger->logAttribute("v1", n1->attribute("v"));
logger->logAttribute("v2", n2->attribute("v"));
//logger->logAttribute("v2", n2->attribute("v"));

Simulation sim(simName);
sim.setSystem(sys);
Expand Down

0 comments on commit a634ad7

Please sign in to comment.