gridfm / gridfm/gridfm-graphkit

Bug: Branch angle difference violation compares radians against degrees

Open
#98 0 comments 0 reactions 0 assignees View on GitHub

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_min and angle_max (from ANG_MIN / ANG_MAX in bus_edge_attr) are in degrees
  • angle_diff(from VA_OUT model 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.