Skip to content

Commit

Permalink
extend initialization and start values for AC1ph_DC, AC3ph and Spot e…
Browse files Browse the repository at this point in the history
…xamples
  • Loading branch information
rfranke committed Oct 19, 2014
1 parent a6da1d2 commit 500ca07
Show file tree
Hide file tree
Showing 23 changed files with 323 additions and 126 deletions.
42 changes: 40 additions & 2 deletions PowerSystems/AC1ph_DC/Impedances.mo
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ package Impedances "Impedance and admittance two terminal"
final parameter SI.Resistance[2] R=r*RL_base[1];
final parameter SI.Inductance[2,2] L=x*RL_base[2];

initial equation
if steadyIni_t then
der(i) = zeros(2);
elseif not system.steadyIni then
i = i_start;
end if;

equation
L*der(i) + diagonal(R)*i = v;
annotation (defaultComponentName="ind1",
Expand Down Expand Up @@ -167,6 +174,13 @@ package Impedances "Impedance and admittance two terminal"
final parameter SI.Conductance[2] G=g*GC_base[1];
final parameter SI.Capacitance[2] C=b*GC_base[2];

initial equation
if steadyIni_t then
der(v) = zeros(2);
elseif not system.steadyIni then
v = v_start;
end if;

equation
diagonal(C)*der(v) + diagonal(G)*v = i;
annotation (defaultComponentName="cap1",
Expand Down Expand Up @@ -255,6 +269,13 @@ package Impedances "Impedance and admittance two terminal"
final parameter SI.Resistance R=z_abs*cos_phi*RL_base[1];
final parameter SI.Inductance[2,2] L=([1,cpl;cpl,1]/(1 - cpl))*z_abs*sin(acos(cos_phi))*RL_base[2];

initial equation
if steadyIni_t then
der(i) = zeros(2);
elseif not system.steadyIni then
i = i_start;
end if;

equation
L*der(i) + R*i = v;
annotation (defaultComponentName="impedance1",
Expand Down Expand Up @@ -348,6 +369,13 @@ Instead of x and r the parameters z_abs and cos(phi) are used.</p>
final parameter SI.Conductance G=y_abs*cos_phi*GC_base[1];
final parameter SI.Capacitance C=y_abs*sin(acos(cos_phi))*GC_base[2];

initial equation
if steadyIni_t then
der(v) = zeros(2);
elseif not system.steadyIni then
v = v_start;
end if;

equation
C*der(v) + G*v = i;
annotation (defaultComponentName="admittance1",
Expand Down Expand Up @@ -892,8 +920,18 @@ Instead of b and g the parameters y_abs and cos(phi) are used.</p>
extends Ports.Port_pn;
extends Basic.Nominal.NominalAC;

SI.Voltage[2] v;
SI.Current[2] i;
parameter Boolean stIni_en=true "enable steady-state initialization"
annotation(Evaluate=true, Dialog(tab="Initialization"));
parameter SI.Voltage[2] v_start = zeros(2)
"start value of voltage drop" annotation(Dialog(tab="Initialization"));
parameter SI.Current[2] i_start = zeros(2)
"start value of current" annotation(Dialog(tab="Initialization"));

SI.Voltage[2] v(start = v_start);
SI.Current[2] i(start = i_start);

protected
final parameter Boolean steadyIni_t=system.steadyIni_t and stIni_en;

equation
v = term_p.v - term_n.v;
Expand Down
28 changes: 26 additions & 2 deletions PowerSystems/AC1ph_DC/ImpedancesOneTerm.mo
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ package ImpedancesOneTerm "Impedance and admittance one terminal"
final parameter SI.Resistance R=r*RL_base[1];
final parameter SI.Inductance L=x*RL_base[2];

initial equation
if steadyIni_t then
der(i) = 0;
elseif not system.steadyIni then
i = i_start;
end if;

equation
L*der(i) + R*i = v;
annotation (defaultComponentName="ind1",
Expand Down Expand Up @@ -138,6 +145,13 @@ package ImpedancesOneTerm "Impedance and admittance one terminal"
final parameter SI.Conductance G=g*GC_base[1];
final parameter SI.Capacitance C=b*GC_base[2];

initial equation
if steadyIni_t then
der(v) = 0;
elseif not system.steadyIni then
v = v_start;
end if;

equation
C*der(v) + G*v = i;
annotation (defaultComponentName="cap1",
Expand Down Expand Up @@ -243,8 +257,18 @@ package ImpedancesOneTerm "Impedance and admittance one terminal"
extends Ports.Port_p;
extends Basic.Nominal.NominalAC;

SI.Voltage v;
SI.Current i;
parameter Boolean stIni_en = true "enable steady-state initialization"
annotation(Evaluate=true);
parameter SI.Voltage v_start = 0 "start value of voltage drop"
annotation(Dialog(tab="Initialization"));
parameter SI.Current i_start = 0 "start value of current"
annotation(Dialog(tab="Initialization"));

SI.Voltage v(start = v_start);
SI.Current i(start = i_start);

protected
final parameter Boolean steadyIni_t=system.steadyIni_t and stIni_en;

equation
term.i[1] + term.i[2] = 0;
Expand Down
9 changes: 6 additions & 3 deletions PowerSystems/AC1ph_DC/ImpedancesSingle.mo
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,16 @@ package ImpedancesSingle "Simple mpedance and admittance two terminal"
extends Modelica.Icons.BasesPackage;

partial model ImpedBase "Impedance base, 1-phase"
SI.Voltage v;
SI.Current i;
parameter SI.Voltage v_start = 0 "start value of voltage drop"
annotation(Dialog(tab="Initialization"));
parameter SI.Current i_start = 0 "start value of current"
annotation(Dialog(tab="Initialization"));
SI.Voltage v(start = v_start);
SI.Current i(start = i_start);
Interfaces.Electric_p term_p annotation (Placement(transformation(extent=
{{-110,-10},{-90,10}}, rotation=0)));
Interfaces.Electric_n term_n annotation (Placement(transformation(extent=
{{90,-10},{110,10}}, rotation=0)));

equation
term_p.i + term_n.i = 0;
v = term_p.v - term_n.v;
Expand Down
52 changes: 42 additions & 10 deletions PowerSystems/AC1ph_DC/Lines.mo
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ package Lines "Transmission lines 1-phase"
extends Ports.Port_pn;
extends Partials.RXlineBase(final ne=1);

SI.Voltage[2] v;
SI.Current[2] i;
SI.Voltage[2] v(start = v_start);
SI.Current[2] i(start = i_start);

initial equation
if steadyIni_t then
der(i) = zeros(2);
elseif not system.steadyIni then
i = i_start;
end if;

equation
v = term_p.v - term_n.v;
i = term_p.i;
Expand Down Expand Up @@ -78,15 +86,18 @@ package Lines "Transmission lines 1-phase"
extends Ports.Port_p_n;
extends Partials.PIlineBase;

SIpu.Voltage v[2,ne];
SIpu.Current i[2,ne1];
SIpu.Voltage[2,ne] v(start = transpose(fill(v_start/ne, ne)));
SIpu.Current[2,ne1] i(start = transpose(fill(i_start, ne1)));
protected
final parameter Integer ne1=ne + 1;

initial equation
if system.steadyIni_t then
if steadyIni_t then
der(v) = zeros(2,ne);
der(i[:,2:ne1]) = zeros(2,ne);
elseif not system.steadyIni then
v = transpose(fill(v_start/ne, ne));
i[:,1:ne1] = transpose(fill(i_start, ne1));
end if;

equation
Expand Down Expand Up @@ -239,8 +250,17 @@ model FaultRXline "Faulted RX transmission line, 1-phase"
parameter Real p(min=0,max=1)=0.5 "rel fault-position (0 < p < 1)";
extends Partials.RXlineBase(final ne=1);

SI.Current[2] i1;
SI.Current[2] i2;
SI.Current[2] i1(start = i_start);
SI.Current[2] i2(start = i_start);

initial equation
if steadyIni_t then
der(i1) = zeros(2);
der(i2) = zeros(2);
elseif not system.steadyIni then
i1 = i_start;
i2 = i_start;
end if;

equation
term_p.i + term_n.i + term_f.i = {0,0};
Expand Down Expand Up @@ -378,8 +398,8 @@ model FaultPIline "Faulted PI transmission line, 1-phase"
"rel fault-pos (1/2ne <= p < 1 - 1/2ne)";
extends Partials.PIlineBase;

SI.Voltage[2,ne] v;
SI.Current[2,ne1] i;
SI.Voltage[2,ne] v(start = transpose(fill(v_start/ne, ne)));
SI.Current[2,ne1] i(start = transpose(fill(i_start, ne1)));
SI.Current[2] iF;
SI.Current[2,2] iF_p(each stateSelect=StateSelect.never);
protected
Expand All @@ -389,9 +409,12 @@ model FaultPIline "Faulted PI transmission line, 1-phase"
"relative fault position within element nF";

initial equation
if system.steadyIni_t then
if steadyIni_t then
der(v) = zeros(2,ne);
der(i[:,2:ne1]) = zeros(2,ne);
elseif not system.steadyIni then
v = transpose(fill(v_start/ne, ne));
i[:,1:ne1] = transpose(fill(i_start, ne1));
end if;

equation
Expand Down Expand Up @@ -506,8 +529,17 @@ end FaultPIline;
replaceable parameter Parameters.RXline par "line parameter"
annotation (Placement(transformation(
extent={{-80,60},{-60,80}}, rotation=0)));

parameter Boolean stIni_en=true "enable steady-state initialization"
annotation(Evaluate=true, Dialog(tab="Initialization"));
parameter SI.Voltage[2] v_start = zeros(2) "start value of voltage drop"
annotation(Dialog(tab="Initialization"));
parameter SI.Current[2] i_start = zeros(2) "start value of current"
annotation(Dialog(tab="Initialization"));

protected
outer System system;
final parameter Boolean steadyIni_t=system.steadyIni_t and stIni_en;
final parameter Real[2] RL_base=Basic.Precalculation.baseRL(par.puUnits, par.V_nom, par.S_nom, 2*pi*par.f_nom);
final parameter Real delta_len_km(final quantity="Length", final unit="km")=len/1e3/ne;
final parameter SI.Resistance[2] R=par.r*delta_len_km*RL_base[1];
Expand Down
38 changes: 26 additions & 12 deletions PowerSystems/AC1ph_DC/Loads.mo
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,20 @@ Consumes the desired power independent of voltage.</p>
extends Basic.Nominal.Nominal;
extends Ports.Port_p;

SI.Voltage v;
SI.Current i;
parameter Boolean stIni_en=true "enable steady-state initialization"
annotation(Evaluate=true, Dialog(tab="Initialization"));
parameter SI.Voltage v_start = 0
"start value of voltage drop" annotation(Dialog(tab="Initialization"));
parameter SI.Current i_start = 0
"start value of current" annotation(Dialog(tab="Initialization"));

SI.Voltage v(start = v_start);
SI.Current i(start = i_start);

protected
outer System system;
final parameter Real S_base=Basic.Precalculation.baseS( puUnits, S_nom);
final parameter Real S_base=Basic.Precalculation.baseS(puUnits, S_nom);
final parameter Boolean steadyIni_t=system.steadyIni_t and stIni_en;

equation
term.i[1] + term.i[2] = 0;
Expand Down Expand Up @@ -343,8 +352,6 @@ Consumes the desired power independent of voltage.</p>
partial model LoadBaseAC "Load base AC, 1-phase"
extends LoadBase;

parameter Boolean stIni_en=true "enable steady-state initial equation"
annotation(evaluate=true, choices(__Dymola_checkBox=true));
parameter Boolean scType_par = true
"= true if p0 defined by parameter p0_set otherwise by input signal p_set"
annotation(Evaluate=true, choices(__Dymola_checkBox=true));
Expand All @@ -360,8 +367,8 @@ Consumes the desired power independent of voltage.</p>
protected
Modelica.Blocks.Interfaces.RealInput[2] p_set_internal
"Needed to connect to conditional connector";
final parameter Boolean steadyIni_t=system.steadyIni_t and stIni_en;
SI.Power[2] p0;

equation
connect(p_set, p_set_internal);

Expand Down Expand Up @@ -393,7 +400,9 @@ Consumes the desired power independent of voltage.</p>
partial model IndLoadBaseAC "Inductive load base AC, 1-phase"
extends LoadBaseAC(v(start=vstart), i(start=istart));

SI.MagneticFlux psi(stateSelect=StateSelect.prefer)
parameter SI.MagneticFlux psi_start=0 "start value for magnetic flux"
annotation(Dialog(tab="Initialization"));
SI.MagneticFlux psi(start=psi_start, stateSelect=StateSelect.prefer)
"magnetic flux";
protected
final parameter Real V2_nom=V_nom*V_nom;
Expand All @@ -406,6 +415,8 @@ Consumes the desired power independent of voltage.</p>
initial equation
if steadyIni_t then
der(psi) = 0;
elseif not system.steadyIni then
psi = psi_start;
end if;

equation
Expand Down Expand Up @@ -442,7 +453,9 @@ Consumes the desired power independent of voltage.</p>
partial model CapLoadBaseAC "Capacitive load base AC, 1-phase"
extends LoadBaseAC(v(start=vstart), i(start=istart));

SI.ElectricCharge q(stateSelect=StateSelect.prefer)
parameter SI.ElectricCharge q_start=0 "start value for electric charge"
annotation(Dialog(tab="Initialization"));
SI.ElectricCharge q(start=q_start, stateSelect=StateSelect.prefer)
"electric charge";
protected
final parameter Real I2_nom=(S_nom/V_nom)^2;
Expand All @@ -455,6 +468,8 @@ Consumes the desired power independent of voltage.</p>
initial equation
if steadyIni_t then
der(q) = 0;
elseif not system.steadyIni then
q = q_start;
end if;

equation
Expand Down Expand Up @@ -499,8 +514,6 @@ Consumes the desired power independent of voltage.</p>
partial model LoadBaseDC "Inductive load base DC"
extends LoadBase;

parameter Boolean stIni_en=true "enable steady-state initial equation"
annotation(evaluate=true, choices(__Dymola_checkBox=true));
parameter Boolean scType_par = true
"= true if p0 defined by parameter p0_set otherwise by input signal p_set"
annotation(Evaluate=true, choices(__Dymola_checkBox=true));
Expand All @@ -515,9 +528,8 @@ Consumes the desired power independent of voltage.</p>
protected
Modelica.Blocks.Interfaces.RealInput p_set_internal
"Needed to connect to conditional connector";

final parameter Boolean steadyIni_t=system.steadyIni_t and stIni_en;
SI.Power p0;

equation
connect(p_set, p_set_internal);

Expand Down Expand Up @@ -563,6 +575,8 @@ Consumes the desired power independent of voltage.</p>
initial equation
if steadyIni_t then
der(L*i) = 0;
elseif not system.steadyIni then
i = i_start;
end if;

equation
Expand Down
Loading

0 comments on commit 500ca07

Please sign in to comment.