Commit dc8df8ea authored by Markus Mirz's avatar Markus Mirz
Browse files

initialize frequencies in SystemTopology


Former-commit-id: cbd2c837
parent 7173b79a
Subproject commit 2f2f246aee96a2f213a1ccceec3d392a3f0a06a0
Subproject commit c8daca4e5f2fbcbe4ca49c0917e975deacf7a43e
......@@ -46,7 +46,7 @@ int main(int argc, char* argv[]) {
auto n4 = Node::make("n4");
auto n5 = Node::make("n5");
Logger::Level level = Logger::Level::NONE;
Logger::Level level = Logger::Level::INFO;
// Components
auto inv = Inverter::make("inv", level);
......@@ -86,14 +86,15 @@ int main(int argc, char* argv[]) {
SystemNodeList{ n1, n2, n3, n4, n5 },
SystemComponentList{ inv, r1, l1, r2, l2, c1, rc, grid });
//Simulation sim(simName, sys, timeStep, finalTime, Domain::DP, Solver::Type::MNA, Logger::Level::INFO);
Simulation sim(simName, level);
sim.setSystem(sys);
sim.setTimeStep(timeStep);
sim.setFinalTime(finalTime);
sim.doHarmonicParallelization(false);
sim.initialize();
// Logging
auto logger = DataLogger::make(simName);
logger->addAttribute("v1", n1->attributeMatrixComp("v"), 1, 5);
......@@ -108,6 +109,7 @@ int main(int argc, char* argv[]) {
sim.run();
auto spdStepTimeLog = Logger::get("step_times", Logger::Level::INFO);
Logger::setLogPattern(spdStepTimeLog, "%v");
spdStepTimeLog->info("steptime_inv");
Real tot = 0;
......
aa21690e0f8f88c43b62233e96ffb0bb15b83464
\ No newline at end of file
c0ea9b7deb88988be85c50ddb6a0b8bf36a9d1bd
\ No newline at end of file
......@@ -110,19 +110,17 @@ void MnaSolver<VarType>::initialize(CPS::SystemTopology system) {
template <>
void MnaSolver<Real>::initializeComponents() {
// TODO: Move to base solver class?
// This intialization according to power flow information is not MNA specific.
mSLog->info("-- Initialize components from power flow");
for (auto comp : mPowerComponents) {
auto pComp = std::dynamic_pointer_cast<PowerComponent<Complex>>(comp);
if (!pComp) continue;
pComp->initialize(mSystem.mFrequencies);
auto pComp = std::dynamic_pointer_cast<PowerComponent<Real>>(comp);
if (!pComp) continue;
pComp->initializeFromPowerflow(mSystem.mSystemFrequency);
}
// Initialize signal components.
for (auto comp : mSignalComponents)
comp->initialize(mSystem.mSystemOmega, mTimeStep);
// Initialize MNA specific parts of components.
for (auto comp : mPowerComponents) {
comp->mnaInitialize(mSystem.mSystemOmega, mTimeStep, attribute<Matrix>("left_vector"));
......@@ -137,19 +135,12 @@ void MnaSolver<Real>::initializeComponents() {
template <>
void MnaSolver<Complex>::initializeComponents() {
// TODO: Move to base solver class?
// This intialization according to power flow information is not MNA specific.
mSLog->info("-- Initialize components from power flow");
// Initialize nodes
for (UInt nodeIdx = 0; nodeIdx < mNodes.size(); nodeIdx++)
mNodes[nodeIdx]->initialize(mSystem.mFrequencies);
// Initialize power components with frequencies and from powerflow results
for (auto comp : mPowerComponents) {
auto pComp = std::dynamic_pointer_cast<PowerComponent<Complex>>(comp);
if (!pComp) continue;
pComp->initialize(mSystem.mFrequencies);
pComp->initializeFromPowerflow(mSystem.mSystemFrequency);
}
......
......@@ -56,6 +56,8 @@ Simulation::Simulation(String name, Logger::Level logLevel) :
mSLog = Logger::get(name);
mSLog->set_pattern("[%L] %v");
mSLog->set_level(Logger::cpsLogLevelToSpd(logLevel));
mInitialized = false;
}
Simulation::Simulation(String name, SystemTopology system,
......
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