<commit_before>within iPSL.Electrical.Branches.PSSE;
model TwoWindingTransformer "Static Two-winding transformer according to PSS/E, without phase shift"
  outer iPSL.Electrical.SystemBase SysData;
  import Modelica.Constants.pi;
  import Modelica.ComplexMath.j;
  import Modelica.ComplexMath.conj;
  iPSL.Connectors.PwPin p annotation (Placement(transformation(extent={{-80,-10},{-60,10}}), iconTransformation(extent={{-80,-10},{-60,10}})));
  iPSL.Connectors.PwPin n annotation (Placement(transformation(extent={{60,-10},{80,10}}),iconTransformation(extent={{60,-10},{80,10}})));

  parameter Real S_b=SysData.S_b "System base power (MVA)" annotation (Dialog(enable=false));

  parameter Integer CZ=1 "Impedance I/O code"
    annotation (Dialog(tab="Transformer impedance data"), choices(
      choice=1 "Z pu (winding kV system MVA)",
      choice=2 "Z pu (winding kV widing MVA)",
      choice=3 "Load loss (W) & |Z| (pu)"));
  parameter Real R "Specified R (pu)" annotation (Dialog(tab="Transformer impedance data"));
  parameter Real X "Specified X (pu)" annotation (Dialog(tab="Transformer impedance data"));
  parameter Real G "Magnetizing G" annotation (Dialog(tab="Transformer impedance data"));
  parameter Real B "Magnetizing B" annotation (Dialog(tab="Transformer impedance data"));

  parameter Integer CW=1 "Winding I/O code" annotation (Dialog(tab="Transformer Nominal Ratings Data"), choices(
      choice=1 "Turns ratio (pu on bus base kV)",
      choice=2 "Winding voltage (kV)",
      choice=3 "Turns ratio (pu on nom wind kV)"));
  parameter Real t1=1 "Winding 1 ratio (pu)" annotation (Dialog(tab="Transformer Nominal Ratings Data"));
  parameter Real VNOM1=0 "Winding 1 Nominal kV" annotation (Dialog(tab="Transformer Nominal Ratings Data"));
  parameter Real VB1 "Bus Base kV on the side of winding 1" annotation (Dialog(tab="Transformer Nominal Ratings Data"));
  parameter Real t2=1 "Secondary winding tap ratio" annotation (Dialog(tab="Transformer Nominal Ratings Data"));
  parameter Real VNOM2=0 "Winding 2 Nominal kV" annotation (Dialog(tab="Transformer Nominal Ratings Data"));
  parameter Real VB2 "Bus Base kV on the side of winding 2" annotation (Dialog(tab="Transformer Nominal Ratings Data"));
  parameter Real ANG1=0 "Winding (1-2) Angle (degrees)" annotation (Dialog(tab="Transformer Nominal Ratings Data"));
  parameter Real S_n=S_b "Winding MVA" annotation (Dialog(tab="Transformer Nominal Ratings Data"));
protected
  parameter Real VNOM1_int=if (abs(VNOM1) < Modelica.Constants.eps) then VB1 else VNOM1;
  parameter Real VNOM2_int=if (abs(VNOM2) < Modelica.Constants.eps) then VB2 else VNOM2;
  parameter Real r=if (CZ == 1) then R else R*S_b/S_n;
  parameter Real x=if (CZ == 1) then X else X*S_b/S_n;

  parameter Complex t=T1/T2*(cos(ANG1/180*pi) + j*sin(ANG1/180*pi));
  parameter Real T2=if (CW == 1) then t2 elseif (CW == 3) then t2*(VNOM2_int/VB2) else t2/VB2;
  parameter Real T1=if (CW == 1) then t1 elseif (CW == 3) then t1*(VNOM1_int/VB1) else t1/VB1;
<commit_msg>Setting default values for base voltages in 2windingtrafo to avoid empty parameters.<commit_after>within iPSL.Electrical.Branches.PSSE;
model TwoWindingTransformer "Static Two-winding transformer according to PSS/E, without phase shift"
  outer iPSL.Electrical.SystemBase SysData;
  import Modelica.Constants.pi;
  import Modelica.ComplexMath.j;
  import Modelica.ComplexMath.conj;
  iPSL.Connectors.PwPin p annotation (Placement(transformation(extent={{-80,-10},{-60,10}}), iconTransformation(extent={{-80,-10},{-60,10}})));
  iPSL.Connectors.PwPin n annotation (Placement(transformation(extent={{60,-10},{80,10}}),iconTransformation(extent={{60,-10},{80,10}})));

  parameter Real S_b=SysData.S_b "System base power (MVA)" annotation (Dialog(enable=false));

  parameter Integer CZ=1 "Impedance I/O code"
    annotation (Dialog(tab="Transformer impedance data"), choices(
      choice=1 "Z pu (winding kV system MVA)",
      choice=2 "Z pu (winding kV widing MVA)",
      choice=3 "Load loss (W) & |Z| (pu)"));
  parameter Real R "Specified R (pu)" annotation (Dialog(tab="Transformer impedance data"));
  parameter Real X "Specified X (pu)" annotation (Dialog(tab="Transformer impedance data"));
  parameter Real G "Magnetizing G" annotation (Dialog(tab="Transformer impedance data"));
  parameter Real B "Magnetizing B" annotation (Dialog(tab="Transformer impedance data"));

  parameter Integer CW=1 "Winding I/O code" annotation (Dialog(tab="Transformer Nominal Ratings Data"), choices(
      choice=1 "Turns ratio (pu on bus base kV)",
      choice=2 "Winding voltage (kV)",
      choice=3 "Turns ratio (pu on nom wind kV)"));
  parameter Real t1=1 "Winding 1 ratio (pu)" annotation (Dialog(tab="Transformer Nominal Ratings Data"));
  parameter Real VNOM1=0 "Winding 1 Nominal kV" annotation (Dialog(tab="Transformer Nominal Ratings Data"));
  parameter Real VB1=300 "Bus Base kV on the side of winding 1" annotation (Dialog(tab="Transformer Nominal Ratings Data"));
  parameter Real t2=1 "Secondary winding tap ratio" annotation (Dialog(tab="Transformer Nominal Ratings Data"));
  parameter Real VNOM2=0 "Winding 2 Nominal kV" annotation (Dialog(tab="Transformer Nominal Ratings Data"));
  parameter Real VB2=300 "Bus Base kV on the side of winding 2" annotation (Dialog(tab="Transformer Nominal Ratings Data"));
  parameter Real ANG1=0 "Winding (1-2) Angle (degrees)" annotation (Dialog(tab="Transformer Nominal Ratings Data"));
  parameter Real S_n=S_b "Winding MVA" annotation (Dialog(tab="Transformer Nominal Ratings Data"));
protected
  parameter Real VNOM1_int=if (abs(VNOM1) < Modelica.Constants.eps) then VB1 else VNOM1;
  parameter Real VNOM2_int=if (abs(VNOM2) < Modelica.Constants.eps) then VB2 else VNOM2;
  parameter Real r=if (CZ == 1) then R else R*S_b/S_n;
  parameter Real x=if (CZ == 1) then X else X*S_b/S_n;

  parameter Complex t=T1/T2*(cos(ANG1/180*pi) + j*sin(ANG1/180*pi));
  parameter Real T2=if (CW == 1) then t2 elseif (CW == 3) then t2*(VNOM2_int/VB2) else t2/VB2;
  parameter Real T1=if (CW == 1) then t1 elseif (CW == 3) then t1*(VNOM1_int/VB1) else t1/VB1;

{'fraction_non_alphanumeric': 0.12939636839522328, 'fraction_numerical': 0.032880745951251435, 'mean_word_length': 5.46984126984127, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6739333', 'n_tokens_mistral': 2148, 'n_tokens_neox': 2003, 'n_words': 639}