modelica-3rdparty / PowerSystems

Free (standard conform) library that is intended to model electrical power systems at different levels of detail both in transient and steady-state mode.
65 stars 36 forks source link

Ac1ph_DC inductor allows unphysical parameters #34

Open ceraolo opened 7 years ago

ceraolo commented 7 years ago

Consider AC1ph_DC.Impedances.Inductor. The inductor reactance is entered as a 2x2 matrix, containing [xs[1],xm; xm,xs[2]] This matrix is directly accessible through the parameter dialog box. This implies that the user can use a matrix having the four values all different from each-other, which, AFAIK, is unrealistic, since the matrix should be symmetric. I propose the change the code into the following one:

model Inductor "Inductor with series resistor, 1-phase"
  extends Partials.ImpedBase;

  parameter Types.Generic.Resistance[2] r={0,0} "resistance";
  parameter Types.Generic.Reactance[2] xs={1,1} "self reactances";
  parameter Types.Generic.Reactance xm=0 
    "mutual reactance between conds 1 and 2";
protected 
  final parameter Real[2] RL_base=Utilities.Precalculation.baseRL(
      puUnits,
      V_nom,
      S_nom,
      2*pi*f_nom);
  final parameter SI.Resistance[2] R=r*RL_base[1];
  //  final parameter SI.Inductance[2, 2] L=x*RL_base[2];
  final parameter SI.Inductance[2, 2] L=[xs[1], xm; xm, xs[2]]*RL_base[2];

initial equation 
  if dynType == Types.Dynamics.SteadyInitial then
    der(i) = zeros(2);
  elseif dynType == Types.Dynamics.FixedInitial then
    i = i_start;
  end if;

equation 
  L*der(i) + diagonal(R)*i = v;
end Inductor;