deltaFlow
NewtonRaphson.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
77#ifndef NEWTONRAPHSON_H
78#define NEWTONRAPHSON_H
79
80#include <Eigen/Dense>
81#include <utility>
82#include <vector>
83
84#include "ISolver.H"
85
86struct BranchData;
87struct BusData;
88
96class NewtonRaphson final : public ISolver {
97 public:
103 bool solve(SolverContext& ctx) override;
104
105 const char* name() const override { return "Newton-Raphson"; }
106
125 static bool run(
126 const Eigen::MatrixXd& G,
127 const Eigen::MatrixXd& B,
128 const Eigen::VectorXd& Ps,
129 const Eigen::VectorXd& Qs,
130 Eigen::VectorXd& V,
131 Eigen::VectorXd& delta,
132 int n_bus,
133 int n_pq,
134 const std::vector<int>& pq_bus_id,
135 int maxIter = 1024,
136 double tolerance = 1E-8,
137 std::vector<std::pair<int, double>>* iterHistory = nullptr,
138 ISolverObserver* observer = nullptr
139 );
140};
141
142#endif
Abstraction over power-flow solvers (Open/Closed Principle).
Common interface for power-flow solvers.
Definition ISolver.H:115
Sink for solver progress/diagnostics (Dependency Inversion / SRP).
Definition ISolver.H:93
Newton-Raphson power flow solver implementing the ISolver interface.
const char * name() const override
Human-readable solver name (e.g.
static bool run(const Eigen::MatrixXd &G, const Eigen::MatrixXd &B, const Eigen::VectorXd &Ps, const Eigen::VectorXd &Qs, Eigen::VectorXd &V, Eigen::VectorXd &delta, int n_bus, int n_pq, const std::vector< int > &pq_bus_id, int maxIter=1024, double tolerance=1E-8, std::vector< std::pair< int, double > > *iterHistory=nullptr, ISolverObserver *observer=nullptr)
Solves the power flow equations using the Newton-Raphson iterative method.
bool solve(SolverContext &ctx) override
Run the Newton-Raphson solver using the given context.
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
Shared input/output parameters for power-flow solvers.
Definition ISolver.H:49