deltaFlow
PowerFlowApplication.H
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Saud Zahir
3 *
4 * This file is part of deltaFlow.
5 *
6 * deltaFlow is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * deltaFlow is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public
17 * License along with deltaFlow. If not, see
18 * <https://www.gnu.org/licenses/>.
19 */
20
35#ifndef POWER_FLOW_APPLICATION_H
36#define POWER_FLOW_APPLICATION_H
37
38#include <memory>
39#include <utility>
40#include <vector>
41
42#include <Eigen/Dense>
43
44#include "Data.H"
45#include "PowerFlowOptions.H"
46#include "Reader.H"
47
56 public:
61 explicit PowerFlowApplication(PowerFlowOptions options);
62
64
65 // Non-copyable, non-movable: owns no shareable resources, single-use orchestrator.
68
74 int run();
75
76 private:
78
79 std::unique_ptr<Reader> reader_;
82 Eigen::MatrixXcd Y_;
83
84 int N_ = 0;
85 int nBranch_ = 0;
86
87 Eigen::VectorXd V_;
88 Eigen::VectorXd delta_;
89 Eigen::VectorXi typeBus_;
90
91 bool finalConverged_ = false;
93 double finalError_ = 0.0;
94 std::vector<std::pair<int, double>> iterationHistory_;
95
96 std::string solverName_;
97 std::string formatName_;
98
100 void loadInput();
101
103 void prepareModel();
104
106 void solve();
107
109 void finalizeResults();
110
112 void writeOutputs(double elapsedSec) const;
113
115 void writeFailureStatus(double elapsedSec) const;
116};
117
118#endif
Data structures and utility functions for reading and displaying bus and branch data in power system ...
Plain parsed-options data, separated from ArgumentParser's parsing logic (ISP).
Abstract base class for power system data file readers.
Orchestrates the full power-flow analysis pipeline for one run.
std::unique_ptr< Reader > reader_
void loadInput()
Reads and validates the input file via ReaderFactory.
void writeFailureStatus(double elapsedSec) const
Writes only the status file, used on the non-convergence early-exit path.
void finalizeResults()
Recomputes slack/PV bus power injections and updates busData_ post-solve.
~PowerFlowApplication()=default
void writeOutputs(double elapsedSec) const
Writes all output files (.out, .sta, .dat, .msg) and CSV/terminal display.
int run()
Runs the full analysis pipeline: load input, solve, apply Q-limits, recompute results,...
PowerFlowApplication & operator=(const PowerFlowApplication &)=delete
void solve()
Runs the selected solver, re-running on Q-limit violations.
std::vector< std::pair< int, double > > iterationHistory_
PowerFlowApplication(const PowerFlowApplication &)=delete
void prepareModel()
Computes Y_bus and sets up the flat-start voltage/angle vectors.
Contains all relevant data for each transmission line or transformer branch.
Definition Data.H:83
Contains all relevant data for each bus in the power system.
Definition Data.H:55
Plain data holder for parsed command-line options.