Issue with reading PSSE transformers
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:
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:
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.
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.
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 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.
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