<commit_before>within OpenIPSL.Electrical.Controls.PSSE.ES;
model SCRX "Bus Fed or Solid Fed Static Exciter"
  extends OpenIPSL.Electrical.Controls.PSSE.ES.BaseClasses.BaseExciter;
  parameter Real T_AT_B;
  parameter Real T_B;
  parameter Real K;
  parameter Real T_E;
  parameter Real E_MIN;
  parameter Real E_MAX;
  parameter Boolean C_SWITCH;
  parameter Real r_cr_fd;
  Modelica.Blocks.Math.Add3 V_erro
    annotation (Placement(transformation(extent={{-60,-10},{-40,10}})));
  OpenIPSL.NonElectrical.Continuous.LeadLag imLeadLag(
    K=1,
    y_start=VR0/K,
    T1=T_AT_B*T_B,
    T2=T_B) annotation (Placement(transformation(extent={{-20,-10},{0,10}})));
  OpenIPSL.NonElectrical.Logical.NegCurLogic negCurLogic(nstartvalue=Efd0,
      RC_rfd=r_cr_fd)
    annotation (Placement(transformation(extent={{150,-10},{180,10}})));
  NonElectrical.Continuous.SimpleLagLim simpleLagLim(
    K=K,
    T=T_E,
    y_start=VR0,
    outMax=E_MAX,
    outMin=E_MIN)
    annotation (Placement(transformation(extent={{10,-10},{30,10}})));
  Modelica.Blocks.Logical.Switch switch1
    annotation (Placement(transformation(extent={{72,18},{84,30}})));
  Modelica.Blocks.Sources.BooleanConstant booleanConstant(k=C_SWITCH)
    annotation (Placement(transformation(extent={{40,46},{52,58}})));
  Modelica.Blocks.Math.Product product
    annotation (Placement(transformation(extent={{42,14},{54,26}})));
  Modelica.Blocks.Math.Add DiffV1(k2=-1) annotation (Placement(transformation(
        extent={{-10,-10},{10,10}},
        rotation=90,
        origin={-100,-150})));
protected
  parameter Real VR0(fixed=false);
initial equation
  if not C_SWITCH then
    VR0 = Efd0/ECOMP0;
    V_REF = VR0/K + ECOMP0;
  else
    VR0 = Efd0;
    V_REF = VR0/K + ECOMP0;
  end if;
equation
  connect(V_erro.y, imLeadLag.u)
    annotation (Line(points={{-39,0},{-39,0},{-22,0}}, color={0,0,127}));
  connect(imLeadLag.y, simpleLagLim.u)
    annotation (Line(points={{1,0},{8,0}}, color={0,0,127}));
  connect(booleanConstant.y, switch1.u2) annotation (Line(points={{52.6,52},{66,
          52},{66,24},{70.8,24}}, color={255,0,255}));
  connect(product.u2, simpleLagLim.y) annotation (Line(points={{40.8,16.4},{36,<commit_msg>Fixing units and parameters for SCRX<commit_after>within OpenIPSL.Electrical.Controls.PSSE.ES;
model SCRX "Bus Fed or Solid Fed Static Exciter"
  extends OpenIPSL.Electrical.Controls.PSSE.ES.BaseClasses.BaseExciter;
  parameter Real T_AT_B=0.1"Ratio between regulator numerator (lead) and denominator (lag) time constants";
  parameter SI.Time T_B=1 "Regulator denominator (lag) time constant";
  parameter SI.PerUnit K=100 "Excitation power source output gain";
  parameter SI.Time T_E=0.005 "Excitation power source output time constant";
  parameter SI.PerUnit E_MIN=-10 "Minimum exciter output";
  parameter SI.PerUnit E_MAX=10 "Maximum exciter output";
  parameter Boolean C_SWITCH=false "Feeding selection. False for bus fed, and True for solid fed";
  parameter Real r_cr_fd=10 "Ratio between crowbar circuit resistance and field circuit resistance";
  Modelica.Blocks.Math.Add3 V_erro
    annotation (Placement(transformation(extent={{-60,-10},{-40,10}})));
  OpenIPSL.NonElectrical.Continuous.LeadLag imLeadLag(
    K=1,
    y_start=VR0/K,
    T1=T_AT_B*T_B,
    T2=T_B) annotation (Placement(transformation(extent={{-20,-10},{0,10}})));
  OpenIPSL.NonElectrical.Logical.NegCurLogic negCurLogic(nstartvalue=Efd0,
      RC_rfd=r_cr_fd)
    annotation (Placement(transformation(extent={{150,-10},{180,10}})));
  NonElectrical.Continuous.SimpleLagLim simpleLagLim(
    K=K,
    T=T_E,
    y_start=VR0,
    outMax=E_MAX,
    outMin=E_MIN)
    annotation (Placement(transformation(extent={{10,-10},{30,10}})));
  Modelica.Blocks.Logical.Switch switch1
    annotation (Placement(transformation(extent={{72,18},{84,30}})));
  Modelica.Blocks.Sources.BooleanConstant booleanConstant(k=C_SWITCH)
    annotation (Placement(transformation(extent={{40,46},{52,58}})));
  Modelica.Blocks.Math.Product product
    annotation (Placement(transformation(extent={{42,14},{54,26}})));
  Modelica.Blocks.Math.Add DiffV1(k2=-1) annotation (Placement(transformation(
        extent={{-10,-10},{10,10}},
        rotation=90,
        origin={-100,-150})));
protected
  parameter SI.PerUnit VR0(fixed=false);
initial equation
  if not C_SWITCH then
    VR0 = Efd0/ECOMP0;
    V_REF = VR0/K + ECOMP0;
  else
    VR0 = Efd0;
    V_REF = VR0/K + ECOMP0;
  end if;
equation
  connect(V_erro.y, imLeadLag.u)
    annotation (Line(points={{-39,0},{-39,0},{-22,0}}, color={0,0,127}));
  connect(imLeadLag.y, simpleLagLim.u)
    annotation (Line(points={{1,0},{8,0}}, color={0,0,127}));
  connect(booleanConstant.y, switch1.u2) annotation (Line(points={{52.6,52},{66,
          52},{66,24},{70.8,24}}, color={255,0,255}));
  connect(product.u2, simpleLagLim.y) annotation (Line(points={{40.8,16.4},{36,
{'fraction_non_alphanumeric': 0.1585315832649713, 'fraction_numerical': 0.0660377358490566, 'mean_word_length': 5.0583850931677015, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3303295', 'n_tokens_mistral': 1972, 'n_tokens_neox': 1794, 'n_words': 307}