DPsim
Loading...
Searching...
No Matches
PFSolverPowerPolarSparse.h
1// SPDX-FileCopyrightText: 2026 Institute for Automation of Complex Power Systems, EONERC, RWTH Aachen University
2// SPDX-License-Identifier: MPL-2.0
3
4#pragma once
5
6#include <dpsim/DirectLinearSolver.h>
7#include <dpsim/PFSolverPowerPolar.h>
8
9namespace DPsim {
13protected:
15 CPS::SparseMatrixRow mJsparse;
17 std::shared_ptr<DirectLinearSolver> mLinearSolver;
19 std::vector<std::pair<CPS::UInt, CPS::UInt>> mVariableSystemMatrixEntries;
20
22 void setUpJacobianStorage() override;
24 void calculateJacobian() override;
26 void solveJacobianSystem() override;
27
31 bool isConnected(CPS::UInt k, CPS::UInt j);
32
33public:
35 PFSolverPowerPolarSparse(CPS::String name, const CPS::SystemTopology &system,
36 CPS::Real timeStep, CPS::Logger::Level logLevel);
38 virtual ~PFSolverPowerPolarSparse(){};
39};
40} // namespace DPsim
PFSolverPowerPolar(CPS::String name, const CPS::SystemTopology &system, CPS::Real timeStep, CPS::Logger::Level logLevel)
Constructor to be used in simulation examples.
std::shared_ptr< DirectLinearSolver > mLinearSolver
Direct linear solver reused across iterations (symbolic factorization computed once)
CPS::SparseMatrixRow mJsparse
Sparse Jacobian (row-major, fixed pattern, values updated in place each iteration)
bool isConnected(CPS::UInt k, CPS::UInt j)
Whether buses k and j are connected (off-diagonal Jacobian entry exists)
void setUpJacobianStorage() override
Build the fixed sparsity pattern, create the linear solver and analyze the pattern once.
std::vector< std::pair< CPS::UInt, CPS::UInt > > mVariableSystemMatrixEntries
Empty list: PF uses full refactorization, not partial refactorization.
void calculateJacobian() override
Fill the sparse Jacobian values in place (pattern unchanged)
PFSolverPowerPolarSparse(CPS::String name, const CPS::SystemTopology &system, CPS::Real timeStep, CPS::Logger::Level logLevel)
Constructor to be used in simulation examples.
void solveJacobianSystem() override
Factorize (first iteration of a run) or refactorize, then solve.
void buildJacobianPattern()
Construct the structural sparsity pattern of the Jacobian from the bus admittance matrix.