Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1783520
state querries in core and ready for python interface
Jerry-Jinfeng-Guo Oct 9, 2026
e298d9d
python side
Jerry-Jinfeng-Guo Oct 9, 2026
204d34d
fix link solver
Jerry-Jinfeng-Guo Oct 9, 2026
8c643e0
basic unit test
Jerry-Jinfeng-Guo Oct 9, 2026
de52da2
add a python example usage
Jerry-Jinfeng-Guo Oct 9, 2026
f8c70a2
jacobian void capture fixed; add full histroy
Jerry-Jinfeng-Guo Oct 10, 2026
4d059c6
restructured model state
Jerry-Jinfeng-Guo Oct 10, 2026
16b3a74
nodal state request seperate
Jerry-Jinfeng-Guo Oct 10, 2026
69c1ce4
iterartive current has no jacobian
Jerry-Jinfeng-Guo Oct 10, 2026
c4f0b18
update ajcobian member namign and example notebook
Jerry-Jinfeng-Guo Oct 11, 2026
6fa8866
documentation
Jerry-Jinfeng-Guo Oct 11, 2026
429138d
finalize unit test values
Jerry-Jinfeng-Guo Oct 11, 2026
a9dcc05
linux werror initializers
Jerry-Jinfeng-Guo Oct 11, 2026
af4a716
mypy complaints
Jerry-Jinfeng-Guo Oct 11, 2026
ed3b60e
more initializers
Jerry-Jinfeng-Guo Oct 11, 2026
d57d6da
ruff
Jerry-Jinfeng-Guo Oct 11, 2026
bba8dcc
more initializers
Jerry-Jinfeng-Guo Oct 11, 2026
9e6aed9
format
Jerry-Jinfeng-Guo Oct 11, 2026
a750318
clang-tidy complaints
Jerry-Jinfeng-Guo Oct 11, 2026
b6ec738
format
Jerry-Jinfeng-Guo Oct 11, 2026
1ff97ce
clang-tidy complaints
Jerry-Jinfeng-Guo Oct 12, 2026
52f2b03
updated the example for power flow with trap changing transformers
Jerry-Jinfeng-Guo Oct 20, 2026
cfa132c
merge from main
Jerry-Jinfeng-Guo Oct 22, 2026
572c820
format
Jerry-Jinfeng-Guo Oct 27, 2026
ba58e6c
format
Jerry-Jinfeng-Guo Oct 27, 2026
3151a99
format
Jerry-Jinfeng-Guo Oct 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docs/algorithms/pf-algorithms.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,37 @@ They are most accurate when the actual voltages are close to 1 p.u. and the erro
level.
When we approximate the load as impedance at 1 p.u., the voltage error has quadratic relation to the actual voltage.
When it is approximated as a current at 1 p.u., the voltage error is only linearly dependent in comparison.

## Retrieving calculation state

`PowerGridModel.calculate_power_flow` can return solver state together with the usual result data. Set
`get_model_state=True` to request the Y-bus, Jacobians, and nodal states:

```python
output_data, model_state = model.calculate_power_flow(get_model_state=True)

group = model_state.groups[0]
y_bus = group.y_bus
jacobians = group.jacobians
nodal_states = group.nodal_states
```

State is organized by solver group. The group mapping relates input node IDs to the solver's internal bus order. The
Y-bus is stored in CSR form; its row pointers and column indices define the positions of its admittance values.
`jacobian_structure` similarly provides the shared sparse pattern for the Jacobian blocks. Jacobians and nodal states
are sequences indexed by iteration; nodal voltage arrays are bus-major, with three phase values per bus for asymmetric
calculations.

To request only selected state, pass a `StateOutputRequest` for each scenario instead of `True`:

```python
from power_grid_model import StateOutputRequest

output_data, model_state = model.calculate_power_flow(get_model_state=[StateOutputRequest(nodal_state=True)])
```

The request flags select which data to capture, but not every method produces every kind of state. Newton-Raphson
provides Jacobians and nodal states per iteration. Iterative Current provides nodal states but no Jacobians. The linear
method has no iteration history, so Jacobians and nodal states are empty even when requested. For batch calculations,
`model_state` contains one state (or `None` for a failed scenario) per flattened scenario, and the request sequence
must have the same length.
Loading
Loading