@@ -187,7 +187,7 @@ private void createMetrixInputs() {
187
187
// Quadripoles are lines, transformers and switches
188
188
cqnbquad = metrixNetwork .getLineList ().size ()
189
189
+ metrixNetwork .getTwoWindingsTransformerList ().size ()
190
- + 3 * metrixNetwork .getThreeWindingsTransformerList ().size ()
190
+ + metrixNetwork .getThreeWindingsTransformerLegsList ().size ()
191
191
+ metrixNetwork .getSwitchList ().size ()
192
192
+ metrixNetwork .getUnpairedDanglingLineList ().size ()
193
193
+ metrixNetwork .getTieLineList ().size ();
@@ -198,7 +198,9 @@ private void createMetrixInputs() {
198
198
199
199
dcnblies = metrixNetwork .getHvdcLineList ().size ();
200
200
201
- tnnbntot = metrixNetwork .getBusList ().size () + metrixNetwork .getUnpairedDanglingLineList ().size ();
201
+ tnnbntot = metrixNetwork .getBusList ().size ()
202
+ + metrixNetwork .getUnpairedDanglingLineList ().size () // boundary bus
203
+ + metrixNetwork .getThreeWindingsTransformerList ().size (); // star bus
202
204
203
205
if (dslData != null ) {
204
206
sectnbse = dslData .getSectionList ().size ();
@@ -396,10 +398,9 @@ private void writeBranches(boolean constantLossFactor, MetrixDie die) {
396
398
metrixNetwork .getTwoWindingsTransformerList ().forEach (twoWindingsTransformer ->
397
399
writeTwoWindingsTransformer (twoWindingsTransformer , metrixInputBranch , metrixInputPhaseTapChanger , constantLossFactor , dtlowran , dtuppran , dttapdep ));
398
400
399
- // Three Windings Transformers
400
- metrixNetwork .getThreeWindingsTransformerList ().forEach (twt -> {
401
- throw new PowsyblException ("Three Windings Transformers are not yet supported in metrix" );
402
- });
401
+ // Three Windings Transformers Legs
402
+ metrixNetwork .getThreeWindingsTransformerLegsList ().forEach (t3wtLeg ->
403
+ writeThreeWindingsTransformerLeg (t3wtLeg , metrixInputBranch , metrixInputPhaseTapChanger , constantLossFactor , dtlowran , dtuppran , dttapdep ));
403
404
404
405
// Switches
405
406
metrixNetwork .getSwitchList ().forEach (sw -> writeSwitch (sw , metrixInputBranch ));
@@ -502,7 +503,7 @@ private void writeTwoWindingsTransformer(TwoWindingsTransformer twt,
502
503
ptc .getLowTapPosition ()));
503
504
}
504
505
505
- //Per-unitage
506
+ // Per-uniting
506
507
double admittance = toAdmittance (twt .getId (), x , nominalVoltage2 , parameters .getNominalU ());
507
508
r = (r * Math .pow (parameters .getNominalU (), 2 )) / Math .pow (nominalVoltage2 , 2 );
508
509
@@ -513,6 +514,59 @@ private void writeTwoWindingsTransformer(TwoWindingsTransformer twt,
513
514
new BranchValues (twt .getId (), admittance , r , getMonitoringTypeBasecase (twt .getId ()), getMonitoringTypeOnContingency (twt .getId ()), bus1Index , bus2Index ));
514
515
}
515
516
517
+ private void writeThreeWindingsTransformerLeg (ThreeWindingsTransformer .Leg leg ,
518
+ MetrixInputBranch metrixInputBranch ,
519
+ MetrixInputPhaseTapChanger metrixInputPhaseTapChanger ,
520
+ boolean constantLossFactor ,
521
+ List <Integer > dtlowran ,
522
+ List <Integer > dtuppran ,
523
+ List <Float > dttapdep ) {
524
+ double nominalVoltage2 = leg .getTerminal ().getVoltageLevel ().getNominalV ();
525
+ double x = leg .getX ();
526
+ double r = leg .getR ();
527
+ String t3wtLegId = MetrixNetwork .getThreeWindingsTransformerLegId (leg );
528
+ int index = metrixNetwork .getThreeWindingsTransformerLegIndex (leg );
529
+
530
+ if (leg .hasPhaseTapChanger ()) {
531
+ PhaseTapChanger ptc = leg .getPhaseTapChanger ();
532
+ int position = ptc .getTapPosition ();
533
+ x = x * (1 + ptc .getStep (position ).getX () / 100 );
534
+ r = r * (1 + ptc .getStep (position ).getR () / 100 );
535
+ if (constantLossFactor ) {
536
+ float val = (float ) (Math .pow (x , 2 ) + Math .pow (r , 2 ) - Math .pow (leg .getR (), 2 ));
537
+ if (val >= 0 ) {
538
+ x = (float ) Math .sqrt (val );
539
+ }
540
+ LOGGER .debug ("constantLossFactor -> t3wt <{} leg {}> x = <{}>" , leg .getTransformer ().getId (), leg .getSide (), x );
541
+ }
542
+
543
+ MetrixPtcControlType mode = MetrixPtcControlType .FIXED_ANGLE_CONTROL ; // FIXME-TODO = getMetrixPtcControlType(leg, index, dtlowran, dtuppran);
544
+
545
+ for (int pos = ptc .getLowTapPosition (); pos < ptc .getLowTapPosition () + ptc .getStepCount (); pos ++) {
546
+ dttapdep .add ((float ) ptc .getStep (pos ).getAlpha ());
547
+ }
548
+
549
+ writePhaseTapChanger (metrixInputPhaseTapChanger ,
550
+ metrixNetwork .getIndex (MetrixSubset .DEPHA , t3wtLegId ),
551
+ new PhaseTapChangerValues (index , mode .getType (),
552
+ (float ) ptc .getStep (ptc .getLowTapPosition ()).getAlpha (),
553
+ (float ) ptc .getStep (ptc .getHighTapPosition ()).getAlpha (),
554
+ (float ) ptc .getStep (ptc .getTapPosition ()).getAlpha (),
555
+ ptc .getStepCount (),
556
+ ptc .getLowTapPosition ()));
557
+ }
558
+
559
+ // Per-uniting
560
+ double admittance = toAdmittance (t3wtLegId , x , nominalVoltage2 , parameters .getNominalU ());
561
+ r = (r * Math .pow (parameters .getNominalU (), 2 )) / Math .pow (nominalVoltage2 , 2 );
562
+
563
+ int bus1Index = metrixNetwork .getThreeWindingsTransformerStarBusIndex (leg .getTransformer ());
564
+ int bus2Index = metrixNetwork .getIndex (leg .getTerminal ().getBusBreakerView ().getBus ());
565
+ writeBranch (metrixInputBranch ,
566
+ index ,
567
+ new BranchValues (t3wtLegId , admittance , r , getMonitoringTypeBasecase (t3wtLegId ), getMonitoringTypeOnContingency (t3wtLegId ), bus1Index , bus2Index ));
568
+ }
569
+
516
570
private MetrixPtcControlType getMetrixPtcControlType (TwoWindingsTransformer twt ,
517
571
int index ,
518
572
List <Integer > dtlowran ,
0 commit comments