gridfm / gridfm/gridfm-graphkit
Bug: Branch angle difference violation compares radians against degrees
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 105
- Forks
- 36
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 9
Description
The branch angle difference violation computation in OptimalPowerFlowTask.test_step compared angle_diff (in radians) directly against ANG_MIN and ANG_MAX (in degrees), producing incorrect violation magnitudes.
Cause
In the normalizers.py script, HeteroDataMVANormalizer.transform() converts both voltage angles and branch angle limits from degrees to radians when loading the dataset (same pattern in HeteroDataPerSampleMVANormalizer.transform()):
data.x_dict["bus"][:, VA_H] *= torch.pi / 180.0
data.edge_attr_dict[("bus", "connects", "bus")][:, ANG_MIN] *= torch.pi / 180.0
data.edge_attr_dict[("bus", "connects", "bus")][:, ANG_MAX] *= torch.pi / 180.0
The inverse_transform() reverses ANG_MIN/ANG_MAX back to degrees but intentionally leaves VA_H and model output angles in radians, because the physics layers (ComputeBranchFlow, ComputeNodeResiduals) expect radians:
data.edge_attr_dict[...][..., ANG_MIN] *= 180.0 / torch.pi
data.edge_attr_dict[...][..., ANG_MAX] *= 180.0 / torch.pi
Finally, the OptimalPowerFlowTask.test_step calls inverse_transform()and inverse_output() at the start so that when the violation check runs (here), the relu is comparing radians against degrees.
angle_minandangle_max(fromANG_MIN/ANG_MAXinbus_edge_attr) are in degreesangle_diff(fromVA_OUTmodel output) is in radians.
angle_excess_low = F.relu(angle_min - angle_diff)
angle_excess_high = F.relu(angle_diff - angle_max)
Proposed Solution
Convert ANG_MIN / ANG_MAX in bus_edge_attr back to radians prior to comparison
Addressed is PR: https://github.com/gridfm/gridfm-graphkit/pull/99
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in gridfm_graphkit/tasks/opf_task.py at OptimalPowerFlowTask.test_step and review the angle-limit handling in gridfm_graphkit/datasets/normalizers.py, including both normalizer transforms. Confirm that angle_diff, ANG_MIN, and ANG_MAX use the same units before the violation calculation; completion is a consistent comparison, though the issue notes that PR 99 addresses it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100