GridCal icon indicating copy to clipboard operation
GridCal copied to clipboard

Issue with reading PSSE transformers

Open jahanbani opened this issue 10 months ago • 4 comments

This issue is more of a resiliency of the code issue rather than a bug. I am working with real network data and there are situations that the following happens:

Image

The code throws an error on line 421 of raw_to_gridcal.py elif psse_elm.VMA2 != 0: In reality, this line of code should have not been compiled. However, since there is a data entry issue (highlighted yellow in the picture), the code eaches line 421 and throws TypeError: '>' not supported between instances of 'NoneType' and 'int'

This is more of a code resiliency which would help in adoption of the code by industry.

Potential Fix: Maybe a try, except and then if except, we check which winding has NPT>0?

Another issue that may arise with the data of two-winding transformer is as follows:

Image

This will throw the following error: GridCal\src\GridCalEngine\IO\raw\devices\transformer.py:1255, in RawTransformer.get_2w_pu_impedances(self, Sbase, v_bus_i, v_bus_j) 1252 I0 = I0 * Sn / Sbase # try? 1253 zm = 1.0 / (I0 / 100.0) -> 1255 inside_sqrt = (-zm ** 2 * rm ** 2) / (zm ** 2 - rm ** 2) 1256 if inside_sqrt > 0: 1257 xm = np.sqrt(inside_sqrt)

ZeroDivisionError: float division by zero

This condition happens when the transformer's magnetizing parameters (its no‐load losses and no‐load current, as given by MAG1 and MAG2) are such that the computed shunt resistance and reactance are equal in magnitude. When that happens, the denominator becomes zero and the division fails.

jahanbani avatar Feb 17 '25 22:02 jahanbani

Hi,

It would be super helpful if you could attach a simple .raw file just with the transformers that cause trouble. This way I can create testing for those.

SanPen avatar Feb 18 '25 09:02 SanPen

I created the test_issue_337 in tests/test_load_all_grids.py and it passes.

@jahanbani Can you confirm it works for the case you created?

SanPen avatar Jul 22 '25 17:07 SanPen

@SanPen I will create a small test system with these issue and will let you know. Meanwhile, I have a question regarding Phase Angle Regulators (PARs). Is there a way to know which transformers are PARs? It seems that all transformers are converted to fixed tap; see raw_to_grical.py Line 461. Thank you.

jahanbani avatar Aug 17 '25 05:08 jahanbani

Hi, you can determine that by checking the tap_phase_control_mode property on the transformers.

The line you mention, sets the active power control at the from side if COD1 > 0, or to fixed otherwise.

tap_phase_control_mode = TapPhaseControl.Pf if psse_elm.COD1 > 0 else TapPhaseControl.fixed

SanPen avatar Aug 17 '25 08:08 SanPen