text
stringlengths 1
4.74k
| code
stringlengths 69
637k
|
---|---|
DC-drives | within PowerSystems.AC1ph_DC;
package Drives "DC-drives"
extends Modelica.Icons.VariantsPackage;
model DCMser "DC machine, series connected"
extends Partials.DriveBase(heat(final m=2));
replaceable model Motor = PowerSystems.AC1ph_DC.Machines.DCser
"DC motor series"
Motor motor "DC motor series"
equation
connect(motor.heat, heat)
connect(motor.airgap, rotor.rotor)
connect(term, motor.term)
end DCMser;
model DCMpar "DC machine, parallel connected"
extends Partials.DriveBase(heat(final m=2));
replaceable model Motor = PowerSystems.AC1ph_DC.Machines.DCpar
"DC motor parallel"
Motor motor "DC motor parallel"
AC1ph_DC.Ports.TwoPin_p field
equation
connect(motor.heat, heat)
connect(motor.airgap, rotor.rotor)
connect(term, motor.term)
connect(field, motor.field)
end DCMpar;
model DCMpm "DC machine, permanent magnet"
extends Partials.DriveBase(heat(final m=2));
replaceable model Motor = PowerSystems.AC1ph_DC.Machines.DCpm
"DC motor magnet"
Motor motor "DC motor magnet"
equation
connect(motor.heat, heat)
connect(motor.airgap, rotor.rotor)
connect(term, motor.term)
end DCMpm;
model BLDC "BLDC machine"
extends Partials.DriveBase(heat(final m=sum(heat_adapt.m)));
replaceable model Inverter = PowerSystems.AC3ph.Inverters.InverterAverage (
modulation=3) constrainedby
PowerSystems.AC3ph.Inverters.Partials.AC_DC_base
"inverter (average or modulated)"
Inverter inverter "inverter (average or modulated)"
replaceable model Motor =
PowerSystems.AC1ph_DC.Drives.Partials.Synchron3rd_bldc
"BLDC motor (syn pm machine)"
Motor motor "BLDC motor (syn pm machine)"
Common.Thermal.HeatV_a_b_ab heat_adapt(final m={2,inverter.heat.m})
equation
connect(motor.heat, heat_adapt.port_a)
connect(inverter.heat, heat_adapt.port_b)
connect(heat_adapt.port_ab, heat)
connect(motor.airgap, rotor.rotor)
connect(term, inverter.DC)
connect(inverter.AC, motor.term)
connect(motor.rotorAngle, inverter.theta)
connect(motor.vPhasor,inverter.vPhasor)
end BLDC;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model DriveBase "DC drives base"
parameter SI.AngularVelocity w_start = 0
"initial rpm (start-value if steady init)"
AC1ph_DC.Ports.TwoPin_p term "electric terminal"
Interfaces.Rotation_n flange "mechanical flange"
replaceable model Rotor = PowerSystems.Mechanics.Rotational.ElectricRotor
"machine rotor"
Rotor rotor(w(start=w_start)) "machine rotor"
replaceable model Gear = PowerSystems.Mechanics.Rotational.NoGear
"type of gear"
Gear gear "type of gear"
Interfaces.ThermalV_n heat( m=2) "heat source port {stator, rotor}"
protected
outer System system;
equation
connect(rotor.flange_b,gear.flange_a)
connect(gear.flange_b, flange)
end DriveBase;
model Synchron3rd_bldc
"Synchronous machine, torque-control, 3rd order model, 3-phase dq0"
extends AC3ph.Machines.Synchron3rd_pm(i_s(start={0,1,0}));
Modelica.Blocks.Interfaces.RealOutput rotorAngle=
phi_el "rotor angle el"
Modelica.Blocks.Interfaces.RealOutput[2] vPhasor
"desired {abs(u), phase(u)}"
equation
vPhasor[1] = 1; //not used if no PWM
vPhasor[2] = atan2(c.R_s*i_s[2] + w_el*psi_e, -w_el*c.L_s[2]*i_s[2]);
v_sq = 1;
vPhasor[1] = sqrt(v_sd*v_sd + v_sq*v_sq);
vPhasor[2] = atan2(v_sq, v_sd);
</pre></p>
<p>For reluctance (<tt>excite=3</tt>) machines psi_e is replaced by a desired magnetising current in d-axis <tt>i_sd</tt>.
<pre>
vPhasor[2] = atan2(c.R_s*i_s[2] + w_el*c.L_s[1]*i_sd, c.R_s*i_sd - w_el*c.L_s[2]*i_s[2]);
</pre>
Using a pu-current <tt>i_sd_pu</tt> we obtain
<pre>
vPhasor[2] = atan2(c.R_s*i_s[2] + w_el*c.L_s[1]*i_sd, (par.V_nom/(c.omega_nom*c.L_s[1]))*i_sd_pu - w_el*c.L_s[2]*i_s[2]);
</pre></p>
<p>More information see Partials.Synchron3rdBase.</p>
</html>"), Icon(graphics={Rectangle(
extent={{-90,112},{90,88}},
lineColor={0,0,127},
fillColor={170,213,255},
fillPattern=FillPattern.Solid)}));
end Synchron3rd_bldc;
end Partials;
end Drives; |
Line-faults | within PowerSystems.AC1ph_DC;
package Faults "Line-faults "
extends Modelica.Icons.VariantsPackage;
model Short_ABC "a, b, c to ground short, 3-phase abc"
extends Partials.FaultBase;
Real[2] s;
equation
{v,i} = if on then {epsR*s,s} else {s,epsG*s};
end Short_ABC;
model Fault_ab "a to b fault, 1-phase"
extends Partials.Fault_pp;
end Fault_ab;
model Fault_A "a to ground fault, 1-phase"
extends Partials.Fault_pg(final n_ph=1);
end Fault_A;
model Fault_B "b to ground fault, 1-phase"
extends Partials.Fault_pg(final n_ph=2);
end Fault_B;
model Fault_Ab "b to a to ground fault, 1-phase"
extends Partials.Fault_ppg(final n_ph=1);
end Fault_Ab;
model Fault_aB "a to b to ground fault, 1-phase"
extends Partials.Fault_ppg(final n_ph=2);
end Fault_aB;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model FaultBase "Line fault base, 1-phase"
extends Ports.Port_f;
parameter SI.Frequency f=system.f_nom "frequency (when fault occurs)";
parameter SI.Time t_on=0.1 "approx time fault on";
parameter SI.Angle phi_on(min=0)=0 "voltage phase angle fault on";
parameter SI.Resistance epsR=1e-4 "resistance 'fault'";
parameter SI.Conductance epsG=1e-4 "conductance 'no fault'";
PS.Voltage[2] v;
PS.Current[2] i;
Boolean on(final start=false, fixed=true);
protected
outer System system;
constant Integer[2] pair={2, 1};
discrete SI.Time t_zero(start=Modelica.Constants.inf, fixed=true);
Boolean v_pos(start=true, fixed=true);
Boolean first(start=true, fixed=true);
equation
v = term.v;
term.i = i;
v_pos = v[1] - v[2] > 0;
when time > t_on and edge(v_pos) and pre(first) then
t_zero = time;
first = false;
end when;
on = time > pre(t_zero) + phi_on/(2*pi*f);
end FaultBase;
partial model Fault_pp "Conductor to conductor fault, 1-phase"
extends FaultBase;
replaceable Common.Switching.Short fault_pp(
final on=on,
final epsR=epsR,
final epsG=epsG) "fault model"
// extends Common.Switching.Partials.FaultBase
equation
fault_pp.v = v[1] - v[2];
fault_pp.i = i[1];
sum(i) = epsG*sum(v);
end Fault_pp;
partial model Fault_pg "Conductor to ground fault, 1-phase"
extends FaultBase;
parameter Integer n_ph(min=1,max=2)=1 "faulted phase"
replaceable Common.Switching.Short fault_pg(
final on=on,
final epsR=epsR,
final epsG=epsG) "fault model"
// extends Common.Switching.Partials.FaultBase
protected
final parameter Integer m_ph=pair[n_ph];
equation
fault_pg.v=v[n_ph];
fault_pg.i=i[n_ph];
i[m_ph] = epsG*v[m_ph];
end Fault_pg;
partial model Fault_ppg "Conductor to conductor to ground fault, 1-phase"
extends FaultBase;
parameter Integer n_ph(min=1,max=2)=1 "which phase to ground"
replaceable Common.Switching.Short fault_pp(
final on=on,
final epsR=epsR,
final epsG=epsG) "fault model"
// extends Common.Switching.Partials.FaultBase
replaceable Common.Switching.Short fault_pg(
final on=on,
final epsR=epsR,
final epsG=epsG) "fault model"
// extends Common.Switching.Partials.FaultBase
protected
final parameter Integer m_ph=pair[n_ph];
equation
fault_pp.v=v[m_ph] - v[n_ph];
fault_pp.i=i[m_ph];
fault_pg.v=v[n_ph];
fault_pg.i=sum(i);
end Fault_ppg;
end Partials;
end Faults; |
Impedance and admittance two terminal | within PowerSystems.AC1ph_DC;
package Impedances "Impedance and admittance two terminal"
extends Modelica.Icons.VariantsPackage;
model Resistor "Resistor, 1-phase"
extends Partials.ImpedBase(final f_nom=0);
parameter SIpu.Resistance[2] r={1,1} "resistance";
protected
final parameter SI.Resistance[2] R=r*Utilities.Precalculation.baseR(
puUnits,
V_nom,
S_nom);
equation
diagonal(R)*i = v;
end Resistor;
model Conductor "Conductor, 1-phase"
extends Partials.ImpedBase(final f_nom=0);
parameter SIpu.Conductance[2] g={1,1} "conductance";
protected
final parameter SI.Conductance[2] G=g/Utilities.Precalculation.baseR(
puUnits,
V_nom,
S_nom);
equation
diagonal(G)*v = i;
end Conductor;
model Inductor "Inductor with series resistor, 1-phase"
extends Partials.ImpedBase;
parameter SIpu.Resistance[2] r={0,0} "resistance";
parameter SIpu.Reactance[2,2] x=[1,0;0,1] "reactance matrix";
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];
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;
model Capacitor "Capacitor with parallel conductor, 1-phase"
extends Partials.ImpedBase;
parameter SIpu.Conductance[2] g={0,0} "conductance";
parameter SIpu.Susceptance[2] b={1,1} "susceptance";
protected
final parameter Real[2] GC_base=Utilities.Precalculation.baseGC(
puUnits,
V_nom,
S_nom,
2*pi*f_nom);
final parameter SI.Conductance[2] G=g*GC_base[1];
final parameter SI.Capacitance[2] C=b*GC_base[2];
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(v) = zeros(2);
elseif dynType == Types.Dynamics.FixedInitial then
v = v_start;
end if;
equation
diagonal(C)*der(v) + diagonal(G)*v = i;
end Capacitor;
model Impedance "Impedance (inductive) with series resistor, 1-phase"
extends Partials.ImpedBase;
parameter SIpu.Impedance z_abs=1 "impedance-value";
parameter Real cos_phi(min=0,max=1)=0.1 "cos-phi of impedance";
parameter Real cpl(min=-1,max=1)=0 "phase coupling, -1 < cpl < 1";
protected
final parameter Real[2] RL_base=Utilities.Precalculation.baseRL(
puUnits,
V_nom,
S_nom,
2*pi*f_nom);
function acos = Modelica.Math.acos;
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 dynType == Types.Dynamics.SteadyInitial then
der(i) = zeros(2);
elseif dynType == Types.Dynamics.FixedInitial then
i = i_start;
end if;
equation
L*der(i) + R*i = v;
end Impedance;
model Admittance "Admittance (capacitive) with parallel conductor, 1-phase"
extends Partials.ImpedBase;
parameter SIpu.Admittance y_abs=1 "abs value of admittance";
parameter Real cos_phi(min=0,max=1)=0.1 "cos-phi of admittance";
protected
final parameter Real[2] GC_base=Utilities.Precalculation.baseGC(
puUnits,
V_nom,
S_nom,
2*pi*f_nom);
function acos = Modelica.Math.acos;
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 dynType == Types.Dynamics.SteadyInitial then
der(v) = zeros(2);
elseif dynType == Types.Dynamics.FixedInitial then
v = v_start;
end if;
equation
C*der(v) + G*v = i;
end Admittance;
model Varistor "Varistor, 1-phase"
extends Partials.ImpedBase(final f_nom=0);
parameter SIpu.Resistance r0=100 "small voltage resistance";
parameter SIpu.Voltage v0=1 "saturation voltage";
protected
final parameter Real V0=(v0*Utilities.Precalculation.baseV(puUnits, V_nom));
final parameter Real H0=(r0*Utilities.Precalculation.baseR(
puUnits,
V_nom,
S_nom)/V0);
equation
v = V0*tanh(H0*i);
end Varistor;
model ResistorSym "Symmetrical capacitor with neutral access"
extends Partials.ImpedBase0;
parameter SI.Resistance R=1;
Interfaces.Electric_n neutral "symmetrical point"
Nodes.Electric_pn_p_n pn_p_n
Nodes.Electric_pn_p_n p_n_pn
ImpedancesSingle.ResistorSym resSym(final R=R)
equation
connect(pn_p_n.term_p, resSym.term_p)
connect(resSym.term_p, p_n_pn.term_p)
connect(pn_p_n.term_n, resSym.term_n)
connect(resSym.term_n, p_n_pn.term_n)
connect(term_p, pn_p_n.term_pn)
connect(p_n_pn.term_pn, term_n)
connect(resSym.neutral, neutral)
end ResistorSym;
model CapacitorSym "Symmetrical capacitor with neutral access"
extends Partials.ImpedBase0;
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter PS.Voltage V_start=0 "start voltage"
parameter SI.Conductance G=1e-6;
parameter SI.Capacitance C=1e-6;
Interfaces.Electric_n neutral "symmetrical point"
Nodes.Electric_pn_p_n pn_p_n
Nodes.Electric_pn_p_n p_n_pn
ImpedancesSingle.CapacitorSym capSym(final G=G, final C=C, final V_start=V_start)
protected
outer System system;
initial equation
capSym.cap1.v = capSym.cap2.v;
if dynType == Types.Dynamics.SteadyInitial then
der(capSym.cap1.v) + der(capSym.cap2.v) = 0;
end if;
equation
connect(pn_p_n.term_p, capSym.term_p)
connect(capSym.term_p, p_n_pn.term_p)
connect(pn_p_n.term_n, capSym.term_n)
connect(capSym.term_n, p_n_pn.term_n)
connect(term_p, pn_p_n.term_pn)
connect(p_n_pn.term_pn, term_n)
connect(capSym.neutral, neutral)
end CapacitorSym;
model DClink "DC-link with filter circuit"
extends Partials.ImpedBase0;
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter PS.Voltage V_start=0 "start voltage"
parameter SI.Resistance Rfilter=1e-3;
parameter SI.Inductance Lfilter=1e-3;
parameter SI.Capacitance Cfilter=1e-6;
parameter SI.Capacitance Cdc=1e-6;
ImpedancesSingle.Resistor res1(final R=Rfilter)
ImpedancesSingle.Inductor ind1(final L=Lfilter)
ImpedancesSingle.Capacitor cap1(final C=Cfilter)
ImpedancesSingle.Capacitor cap(final C=Cdc, final v(start=V_start))
Interfaces.Electric_n grd "ground"
Nodes.Electric_pn_p_n pn_p_n
Nodes.Electric_pn_p_n p_n_pn
protected
outer System system;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(cap.v) = 0;
der(cap1.v) = 0;
end if;
equation
connect(pn_p_n.term_p, res1.term_p)
connect(res1.term_n, ind1.term_p)
connect(ind1.term_n, cap1.term_p)
connect(cap1.term_n, pn_p_n.term_n)
connect(p_n_pn.term_p, cap.term_p)
connect(p_n_pn.term_n, cap.term_n)
connect(res1.term_p, cap.term_p)
connect(cap.term_n, cap1.term_n)
connect(cap.term_n, grd)
connect(term_p, pn_p_n.term_pn)
connect(p_n_pn.term_pn, term_n)
end DClink;
model DClinkSym "Symmetrical DC-link with filter circuit and neutral access"
extends Partials.ImpedBase0;
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter PS.Voltage V_start=0 "start voltage"
parameter SI.Resistance Rfilter=1e-3;
parameter SI.Inductance Lfilter=1e-3;
parameter SI.Capacitance Cfilter=1e-6;
parameter SI.Capacitance Cdc=1e-6;
ImpedancesSingle.Resistor res1(final R=Rfilter)
ImpedancesSingle.Inductor ind1(final L=Lfilter)
ImpedancesSingle.Capacitor cap1(final C=Cfilter)
ImpedancesSingle.CapacitorSym capSym(final C=Cdc, final V_start=V_start)
Interfaces.Electric_n neutral "symmetrical point"
Nodes.Electric_pn_p_n pn_p_n
Nodes.Electric_pn_p_n p_n_pn
protected
outer System system;
initial equation
capSym.cap1.v = capSym.cap2.v;
if dynType == Types.Dynamics.SteadyInitial then
der(cap1.v) = 0;
end if;
equation
connect(pn_p_n.term_p, res1.term_p)
connect(res1.term_n, ind1.term_p)
connect(ind1.term_n, cap1.term_p)
connect(cap1.term_n, pn_p_n.term_n)
connect(p_n_pn.term_p, capSym.term_p)
connect(p_n_pn.term_n, capSym.term_n)
connect(res1.term_p, capSym.term_p)
connect(capSym.term_n, cap1.term_n)
connect(capSym.neutral, neutral)
connect(term_p, pn_p_n.term_pn)
connect(p_n_pn.term_pn, term_n)
end DClinkSym;
package Partials "Partial models"
partial model ImpedBase0 "Impedance base 0, 1-phase"
extends Ports.PortBase;
Ports.TwoPin_p term_p "positive terminal"
Ports.TwoPin_n term_n "negative terminal"
end ImpedBase0;
extends Modelica.Icons.BasesPackage;
partial model ImpedBase "Impedance base, 1-phase"
extends Ports.Port_pn;
extends Common.Nominal.NominalAC;
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter PS.Voltage[2] v_start = zeros(2)
"start value of voltage drop"
parameter PS.Current[2] i_start = zeros(2)
"start value of current"
PS.Voltage[2] v(start = v_start);
PS.Current[2] i(start = i_start);
equation
v = term_p.v - term_n.v;
i = term_p.i;
end ImpedBase;
partial model ImpedBaseHeat "Impedance base with heat port, 1-phase"
extends ImpedBase;
extends Interfaces.AddHeat;
end ImpedBaseHeat;
partial model ImpedNonSymHeat
"Impedance base non symmetric with heat port, 3-phase abc"
extends ImpedBase;
extends Interfaces.AddHeatV( final m_heat=2);
equation
Q_flow = v.*i;
end ImpedNonSymHeat;
end Partials;
end Impedances; |
Impedance and admittance one terminal | within PowerSystems.AC1ph_DC;
package ImpedancesOneTerm "Impedance and admittance one terminal"
extends Modelica.Icons.VariantsPackage;
model Resistor "Resistor, 1-phase"
extends Partials.ImpedBase(final f_nom=0);
parameter SIpu.Resistance r=1 "resistance";
protected
final parameter SI.Resistance R=r*Utilities.Precalculation.baseR(
puUnits,
V_nom,
S_nom);
equation
R*i = v;
end Resistor;
model Conductor "Conductor, 1-phase"
extends Partials.ImpedBase(final f_nom=0);
parameter SIpu.Conductance g=1 "conductance";
protected
final parameter SI.Conductance G=g/Utilities.Precalculation.baseR(
puUnits,
V_nom,
S_nom);
equation
G*v = i;
end Conductor;
model Inductor "Inductor with series resistor, 1-phase"
extends Partials.ImpedBase;
parameter SIpu.Resistance r=0 "resistance";
parameter SIpu.Reactance x=1 "reactance matrix";
protected
final parameter Real[2] RL_base=Utilities.Precalculation.baseRL(
puUnits,
V_nom,
S_nom,
2*pi*f_nom);
final parameter SI.Resistance R=r*RL_base[1];
final parameter SI.Inductance L=x*RL_base[2];
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i) = 0;
elseif dynType == Types.Dynamics.FixedInitial then
i = i_start;
end if;
equation
L*der(i) + R*i = v;
end Inductor;
model Capacitor "Capacitor with parallel conductor, 1-phase"
extends Partials.ImpedBase;
parameter SIpu.Conductance g=0 "conductance";
parameter SIpu.Susceptance b=1 "susceptance";
protected
final parameter Real[2] GC_base=Utilities.Precalculation.baseGC(
puUnits,
V_nom,
S_nom,
2*pi*f_nom);
final parameter SI.Conductance G=g*GC_base[1];
final parameter SI.Capacitance C=b*GC_base[2];
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(v) = 0;
elseif dynType == Types.Dynamics.FixedInitial then
v = v_start;
end if;
equation
C*der(v) + G*v = i;
end Capacitor;
model Varistor "Varistor, 1-phase"
extends Partials.ImpedBase(final f_nom=0);
parameter SIpu.Resistance r0=100 "small voltage resistance";
parameter SIpu.Voltage v0=1 "saturation voltage";
protected
final parameter Real V0=(v0*Utilities.Precalculation.baseV(puUnits, V_nom));
final parameter Real H0=(r0*Utilities.Precalculation.baseR(
puUnits,
V_nom,
S_nom)/V0);
equation
v = V0*tanh(H0*i);
end Varistor;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model ImpedBase "One terminal impedance base, 1-phase"
extends Ports.Port_p;
extends Common.Nominal.NominalAC;
parameter Types.Dynamics dynType=system.dynType "transient or steady-state initialization"
parameter PS.Voltage v_start = 0 "start value of voltage drop"
parameter PS.Current i_start = 0 "start value of current"
PS.Voltage v(start = v_start);
PS.Current i(start = i_start);
equation
term.i[1] + term.i[2] = 0;
v = term.v[1] - term.v[2];
i = term.i[1];
end ImpedBase;
partial model ImpedBaseHeat
"One terminal impedance base with heat port, 1-phase"
extends ImpedBase;
extends Interfaces.AddHeat;
end ImpedBaseHeat;
end Partials;
end ImpedancesOneTerm; |
Simple mpedance and admittance two terminal | within PowerSystems.AC1ph_DC;
package ImpedancesSingle "Simple mpedance and admittance two terminal"
extends Modelica.Icons.VariantsPackage;
model Resistor "Resistor, 1-phase"
extends Partials.ImpedBase;
parameter SI.Resistance R=1;
equation
R*i = v;
end Resistor;
model Conductor "Conductor, 1-phase"
extends Partials.ImpedBase;
parameter SI.Conductance G=1;
equation
G*v = i;
end Conductor;
model Inductor "Inductor with series resistor, 1-phase"
extends Partials.ImpedBase;
parameter SI.Resistance R=0;
parameter SI.Inductance L=1e-3;
equation
L*der(i) + R*i = v;
end Inductor;
model Capacitor "Capacitor with parallel conductor, 1-phase"
extends Partials.ImpedBase;
parameter SI.Conductance G=0;
parameter SI.Capacitance C=1e-6;
equation
C*der(v) + G*v = i;
end Capacitor;
model ResistorSym "Symmetrical capacitor with neutral access, 1-phase"
extends Ports.PortBase;
parameter SI.Resistance R=1;
Interfaces.Electric_p term_p
Interfaces.Electric_n term_n
Interfaces.Electric_n neutral "symmetrical point"
Resistor res1(final R=R/2)
Resistor res2(final R=R/2)
equation
connect(term_p, res1.term_p)
connect(res1.term_n, neutral)
connect(neutral, res2.term_p)
connect(res2.term_n, term_n)
end ResistorSym;
model CapacitorSym "Symmetrical capacitor with neutral access, 1-phase"
extends Ports.PortBase;
parameter SI.Conductance G=0;
parameter SI.Capacitance C=1e-6;
parameter PS.Voltage V_start=0 "start voltage";
Interfaces.Electric_p term_p
Interfaces.Electric_n term_n
Interfaces.Electric_n neutral "symmetrical point"
Capacitor cap1(final G=2*G, final C=2*C, v(start=V_start/2))
Capacitor cap2(final G=2*G, final C=2*C, v(start=V_start/2))
equation
connect(term_p, cap1.term_p)
connect(cap1.term_n, neutral)
connect(neutral, cap2.term_p)
connect(cap2.term_n, term_n)
end CapacitorSym;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model ImpedBase "Impedance base, 1-phase"
extends Ports.PortBase;
parameter PS.Voltage v_start = 0 "start value of voltage drop"
parameter PS.Current i_start = 0 "start value of current"
PS.Voltage v(start = v_start);
PS.Current i(start = i_start);
Interfaces.Electric_p term_p
Interfaces.Electric_n term_n
equation
term_p.i + term_n.i = 0;
v = term_p.v - term_n.v;
i = term_p.i;
end ImpedBase;
end Partials;
end ImpedancesSingle; |
Rectifiers and Inverters | within PowerSystems.AC1ph_DC;
package Inverters "Rectifiers and Inverters"
extends Modelica.Icons.VariantsPackage;
block Select "Select frequency and voltage-phasor type"
extends PowerSystems.Icons.Block;
parameter Types.SourceFrequency fType=PowerSystems.Types.SourceFrequency.System
"frequency type"
parameter SI.Frequency f=system.f "frequency if type is parameter"
parameter Boolean use_vPhasor_in = false
"= true to enable signal input vPhasor_in"
parameter Real v0=1 "voltage amplitude pu vDC/2"
parameter SI.Angle alpha0=0 "phase angle"
Modelica.Blocks.Interfaces.RealInput[2] vPhasor_in if use_vPhasor_in
"{abs(u), phase(u)}"
Modelica.Blocks.Interfaces.RealInput omega_in(final unit="rad/s") if fType
== PowerSystems.Types.SourceFrequency.Signal
"angular frequency"
Modelica.Blocks.Interfaces.RealOutput[2] vPhasor_out
"{abs(u), phase(u)} to inverter"
Modelica.Blocks.Interfaces.RealOutput theta_out
"abs angle to inverter, der(theta)=omega"
outer System system;
protected
SI.Angle theta;
Modelica.Blocks.Interfaces.RealInput omega_internal
"Needed to connect to conditional connector";
Modelica.Blocks.Interfaces.RealInput[2] vPhasor_internal
"Needed to connect to conditional connector";
initial equation
if fType == Types.SourceFrequency.Signal then
theta = 0;
end if;
equation
connect(omega_in, omega_internal);
connect(vPhasor_in, vPhasor_internal);
if fType <> Types.SourceFrequency.Signal then
omega_internal = 0.0;
end if;
if not use_vPhasor_in then
vPhasor_internal = {v0, alpha0};
end if;
if fType == Types.SourceFrequency.System then
theta = system.theta;
elseif fType == Types.SourceFrequency.Parameter then
theta = 2*pi*f*(time - system.initime);
elseif fType == Types.SourceFrequency.Signal then
der(theta) = omega_internal;
end if;
theta_out = theta;
vPhasor_out = vPhasor_internal;
end Select;
model Rectifier "Rectifier, 1-phase"
extends Partials.AC_DC_base(heat(final m=2));
replaceable model Rectifier =
PowerSystems.AC1ph_DC.Inverters.Components.RectifierEquation
"rectifier model"
Rectifier rectifier "rectifier model"
equation
connect(AC, rectifier.AC)
connect(rectifier.DC, DC)
connect(rectifier.heat, heat)
end Rectifier;
model Inverter "Complete modulator and inverter, 1-phase"
extends Partials.AC_DC_base(heat(final m=2));
Modelica.Blocks.Interfaces.RealInput theta "abs angle, der(theta)=omega"
Modelica.Blocks.Interfaces.RealInput[2] vPhasor "desired {abs(v), phase(v)}"
replaceable model Modulator = PowerSystems.Control.Modulation.PWMasyn1ph
constrainedby Control.Modulation.Partials.ModulatorBase "modulator type"
Modulator modulator "modulator type"
replaceable model Inverter =
PowerSystems.AC1ph_DC.Inverters.Components.InverterSwitch "inverter model"
Inverter inverter "inverter model"
protected
outer System system;
equation
connect(theta, modulator.theta)
connect(vPhasor,modulator.vPhasor)
connect(AC, inverter.AC)
connect(inverter.DC, DC)
connect(modulator.gates, inverter.gates)
connect(inverter.heat, heat)
end Inverter;
model InverterAverage "Inverter time-average, 1-phase"
extends Partials.SwitchEquation(heat(final m=1));
replaceable record Data = PowerSystems.Semiconductors.Ideal.SCparameter
"SC parameters"
final parameter Data par "SC parameters"
parameter Integer modulation=1 "equivalent modulation :"
parameter Boolean syn=false "synchronous, asynchronous"
parameter Integer m_carr(min=1)=1 "f_carr/f, pulses/period"
parameter SI.Frequency f_carr=1e3 "carrier frequency"
parameter Real width0=2/3 "relative width, (0 - 1)"
Modelica.Blocks.Interfaces.RealInput theta "abs angle, der(theta)=omega"
Modelica.Blocks.Interfaces.RealInput[2] vPhasor "desired {abs(v), phase(v)}"
protected
outer System system;
final parameter SI.Resistance R_nom=par.V_nom/par.I_nom;
final parameter Real factor=
if modulation==1 then 1 else
if modulation==3 then (4/pi)*sin(width0*pi/2) else 0
SI.Angle phi;
PS.Voltage Vloss;
Real cT;
Real hsw_nom;
equation
Vloss = if par.Vf<1e-3 then 0 else tanh(10*iDC1/par.I_nom)*2*par.Vf;
cT = if size(par.cT_loss,1)>0 then loss(T[1]-par.T0_loss, par.cT_loss) else 1;
hsw_nom = if syn then (2*par.Hsw_nom*m_carr/(pi*par.V_nom*par.I_nom))*der(theta) else
4*par.Hsw_nom*f_carr/(par.V_nom*par.I_nom);
phi = theta +vPhasor [2] + system.alpha0;
switch[1] = factor*vPhasor[1]*cos(phi);
switch[2] = -switch[1];
v = (vDC1 - cT*Vloss)*switch;
// passive mode?
Q_flow = {par.eps[1]*R_nom*AC.i*AC.i+
cT*(par.Vf + hsw_nom*abs(vDC1))*(abs(AC.i[1])+abs(AC.i[2]))};
end InverterAverage;
model Chopper "DC-DC converter"
extends Partials.DC_DC_base(heat(final m=2));
Modelica.Blocks.Interfaces.RealInput vDC "desired vDC"
replaceable model Modulator = PowerSystems.Control.Modulation.ChopperPWM
constrainedby PowerSystems.Icons.BlockS "modulator type"
Modulator modulator "modulator type"
replaceable model Chopper =
PowerSystems.AC1ph_DC.Inverters.Components.ChopperModular "chopper model"
Chopper chopper "chopper model"
equation
connect(vDC,modulator.vDC)
connect(DCin, chopper.DCin)
connect(chopper.DCout, DCout)
connect(modulator.gate, chopper.gate)
connect(chopper.heat, heat)
end Chopper;
model ChopperAverage "DC-DC converter time-average"
extends Partials.DC_DC_base(heat(final m=1));
replaceable record Data = PowerSystems.Semiconductors.Ideal.SCparameter
"SC parameters"
final parameter Data par "SC parameters"
parameter SI.Frequency f_carr=1e3 "carrier frequency"
Modelica.Blocks.Interfaces.RealInput uDC "desired uDC"
protected
PS.Voltage vDCin=DCin.v[1] - DCin.v[2];
PS.Voltage vDCout=DCout.v[1] - DCout.v[2];
final parameter SI.Resistance R_nom=par.V_nom/par.I_nom;
Real hsw_nom;
Real cT;
SI.Temperature[heat.m] T = heat.ports.T "component temperature";
SI.HeatFlowRate[heat.m] Q_flow = -heat.ports.Q_flow
"component loss-heat flow";
function lossT = Utilities.Math.taylor
"spec loss function of temperature";
equation
DCin.v[2] = DCout.v[2];
DCin.i + DCout.i = {0, 0};
vDCout = uDC*max(vDCin - cT*par.Vf, 0);
hsw_nom = 4*par.Hsw_nom*f_carr/(par.V_nom*par.I_nom);
cT = if size(par.cT_loss,1)==0 then 1 else lossT(T[1]-par.T0_loss, par.cT_loss);
Q_flow = {par.eps[1]*R_nom*DCin.i[1]*DCin.i[1] +
cT*(par.Vf + hsw_nom*abs(vDCin))*abs(DCin.i[1])};
end ChopperAverage;
package Components "Equation-based and modular components"
extends Modelica.Icons.VariantsPackage;
model RectifierEquation "Rectifier equation, 1-phase"
extends Partials.SwitchEquation(heat(final m=2));
replaceable record Data = PowerSystems.Semiconductors.Ideal.SCparameter(final Hsw_nom=0)
"SC parameters"
final parameter Data par "SC parameters"
protected
PS.Voltage[2] V;
PS.Voltage[2] i_sc "current scaled to voltage in inertial abc representation";
Real[2] s(each start = 0.5) "arc-length on characteristic";
equation
i_sc = AC.i*par.V_nom/par.I_nom;
for k in 1:2 loop
V[k] = if size(par.cT_loss,1)==0 then vDC1 + par.Vf else vDC1 + par.Vf*loss(T[k]-par.T0_loss, par.cT_loss);
if s[k] > V[k] then // vDC+ < vAC
{v[k],i_sc[k]} = {par.eps[1]*s[k] + (1 - par.eps[1])*V[k], s[k] - (1 - par.eps[2])*V[k]};
elseif s[k] < -V[k] then // vAC < vDC-
{v[k],i_sc[k]} = {par.eps[1]*s[k] - (1 - par.eps[1])*V[k], s[k] + (1 - par.eps[2])*V[k]};
else // vDC- < vAC < vDC+
{v[k],i_sc[k]} = {s[k],par.eps[2]*s[k]};
end if;
switch[k] = noEvent(sign(s[k]));
end for;
Q_flow = (v - switch*vDC1).*i_sc*par.I_nom/par.V_nom;
end RectifierEquation;
model RectifierModular "Rectifier modular, 1-phase"
extends Partials.AC_DC_base(heat(final m=2));
package SCpackage = PowerSystems.Semiconductors.Ideal "SC package";
replaceable record Data = SCpackage.SCparameter(final Hsw_nom=0)
"SC parameters"
final parameter Data par "SC parameters"
AC1ph_DC.Nodes.Electric_pn_p_n pn_p_n
Common.Thermal.Heat_a_b_ab heat_adapt
Semiconductors.PhaseModules.DiodeModule diodeMod_a1(par=par)
"diode module AC_a1"
Semiconductors.PhaseModules.DiodeModule diodeMod_a2(par=par)
"diode module AC_a2"
equation
connect(AC, pn_p_n.term_pn)
connect(pn_p_n.term_p, diodeMod_a1.AC)
connect(diodeMod_a1.DC, DC)
connect(pn_p_n.term_n, diodeMod_a2.AC)
connect(diodeMod_a2.DC, DC)
connect(diodeMod_a1.heat, heat_adapt.port_a)
connect(diodeMod_a2.heat, heat_adapt.port_b)
connect(heat_adapt.port_ab, heat)
end RectifierModular;
model InverterSwitch "Inverter equation, 1-phase"
extends Partials.SwitchEquation(heat(final m=2));
Modelica.Blocks.Interfaces.BooleanInput[4] gates
"gates pairs {a1_p, a1_n, a2_p, a2_n}"
protected
constant Integer[2] pgt={1,3} "positive gates";
constant Integer[2] ngt={2,4} "negative gates";
equation
for k in 1:2 loop
if gates[pgt[k]] then // switched mode DC+ to AC
switch[k] = 1;
v[k] = vDC1;
elseif gates[ngt[k]] then // switched mode DC- to AC
switch[k] = -1;
v[k] = -vDC1;
else
switch[k] = 0;
v[k] = 0;
end if;
end for;
Q_flow = zeros(heat.m);
end InverterSwitch;
model InverterEquation "Inverter equation, 1-phase"
extends Partials.SwitchEquation(heat(final m=2));
replaceable record Data = PowerSystems.Semiconductors.Ideal.SCparameter
"SC parameters"
final parameter Data par "SC parameters"
Modelica.Blocks.Interfaces.BooleanInput[4] gates
"gates pairs {a1_p, a1_n, a2_p, a2_n}"
protected
constant Integer[2] pgt={1,3} "positive gates";
constant Integer[2] ngt={2,4} "negative gates";
PS.Voltage[2] V_s;
PS.Voltage[2] V_d;
PS.Voltage[2] i_sc "current scaled to voltage in inertial abc representation";
Real[2] s(each start = 0.5) "arc-length on characteristic";
equation
i_sc = AC.i*par.V_nom/par.I_nom;
if par.Vf<1e-3 then // faster code if forward voltage drop Vf not used (Vf_s=0 and Vf_d=0).
for k in 1:2 loop
V_s[k] = 0;
V_d[k] = vDC1;
if gates[pgt[k]] then // switched mode DC+ to AC
switch[k] = 1;
{v[k],i_sc[k]} = {par.eps[1]*s[k] + (1 - par.eps[1])*V_d[k],s[k] - (1 - par.eps[2])*V_d[k]};
elseif gates[ngt[k]] then // switched mode DC- to AC
switch[k] = -1;
{v[k],i_sc[k]} = {par.eps[1]*s[k] - (1 - par.eps[1])*V_d[k],s[k] + (1 - par.eps[2])*V_d[k]};
else // rectifier mode
if s[k] > V_d[k] then // vDC+ < vAC
{v[k],i_sc[k]} = {par.eps[1]*s[k] + (1 - par.eps[1])*V_d[k], s[k] - (1 - par.eps[2])*V_d[k]};
elseif s[k] < -V_d[k] then // vAC < vDC-
{v[k],i_sc[k]} = {par.eps[1]*s[k] - (1 - par.eps[1])*V_d[k], s[k] + (1 - par.eps[2])*V_d[k]};
else // vDC- < vAC < vDC+
{v[k],i_sc[k]} = {s[k],par.eps[2]*s[k]};
end if;
switch[k] = noEvent(sign(s[k]));
end if;
end for;
Q_flow = zeros(heat.m);
else // slower code if voltage drop used (Vf_s>0 or Vf_d>0).
for k in 1:2 loop
{V_s[k], V_d[k]} = if size(par.cT_loss,1)==0 then {vDC1-par.Vf, vDC1+par.Vf} else {vDC1, vDC1} + {-par.Vf, par.Vf}*loss(T[k]-par.T0_loss, par.cT_loss);
if gates[pgt[k]] then // switched mode DC+ to AC
switch[k] = 1;
if s[k] > V_d[k] then
{v[k],i_sc[k]} = {par.eps[1]*s[k] + (1 - par.eps[1])*V_d[k],s[k] - (1 - par.eps[2])*V_d[k]};
elseif s[k] < V_s[k] then
{v[k],i_sc[k]} = {par.eps[1]*s[k] + (1 - par.eps[1])*V_s[k],s[k] - (1 - par.eps[2])*V_s[k]};
else
{v[k],i_sc[k]} = {s[k],par.eps[2]*s[k]};
end if;
elseif gates[ngt[k]] then // switched mode DC- to AC
switch[k] = -1;
if s[k] < -V_d[k] then
{v[k],i_sc[k]} = {par.eps[1]*s[k] - (1 - par.eps[1])*V_d[k],s[k] + (1 - par.eps[2])*V_d[k]};
elseif s[k] > -V_s[k] then
{v[k],i_sc[k]} = {par.eps[1]*s[k] -(1 - par.eps[1])*V_s[k],s[k] + (1 - par.eps[2])*V_s[k]};
else
{v[k],i_sc[k]} = {s[k],par.eps[2]*s[k]};
end if;
else // rectifier mode
if s[k] > V_d[k] then // vDC+ < vAC
{v[k],i_sc[k]} = {par.eps[1]*s[k] + (1 - par.eps[1])*V_d[k], s[k] - (1 - par.eps[2])*V_d[k]};
elseif s[k] < -V_d[k] then // vAC < vDC-
{v[k],i_sc[k]} = {par.eps[1]*s[k] - (1 - par.eps[1])*V_d[k], s[k] + (1 - par.eps[2])*V_d[k]};
else // vDC- < vAC < vDC+
{v[k],i_sc[k]} = {s[k],par.eps[2]*s[k]};
end if;
switch[k] = noEvent(sign(s[k]));
end if;
end for;
Q_flow = (v - switch*vDC1).*i_sc*par.I_nom/par.V_nom;
end if;
end InverterEquation;
model InverterModular "Inverter modular, 1-phase"
extends Partials.AC_DC_base(heat(final m=2));
package SCpackage = PowerSystems.Semiconductors.Ideal "SC package";
replaceable record Data = SCpackage.SCparameter "SC parameters"
final parameter Data par "SC parameters"
Modelica.Blocks.Interfaces.BooleanInput[4] gates
"gates pairs {a1_p, a1_n, a2_p, a2_n}"
Nodes.Electric_pn_p_n pn_p_n
Common.Thermal.Heat_a_b_ab heat_adapt
Blocks.Multiplex.Gate2demux gate2demux1(final n=2)
Semiconductors.PhaseModules.SwitchModule switchMod_a1(par=par)
"switch + reverse diode module AC_a1"
Semiconductors.PhaseModules.SwitchModule switchMod_a2(par=par)
"switch + reverse diode module AC_a2"
equation
connect(gate2demux1.gates_1, switchMod_a1.gates)
connect(gate2demux1.gates_2, switchMod_a2.gates)
connect(gates, gate2demux1.gates)
connect(AC, pn_p_n.term_pn)
connect(pn_p_n.term_p, switchMod_a1.AC)
connect(switchMod_a1.DC, DC)
connect(pn_p_n.term_n, switchMod_a2.AC)
connect(switchMod_a2.DC, DC)
connect(switchMod_a1.heat, heat_adapt.port_a)
connect(switchMod_a2.heat, heat_adapt.port_b)
connect(heat_adapt.port_ab, heat)
end InverterModular;
model ChopperModular "DC_DC converter modular"
extends Partials.DC_DC_base(heat(final m=2));
package SCpackage = PowerSystems.Semiconductors.Ideal "SC package";
replaceable record Data = SCpackage.SCparameter "SC parameters"
final parameter Data par "SC parameters"
Modelica.Blocks.Interfaces.BooleanInput gate "gate"
AC1ph_DC.Nodes.Electric_pn_p_n pn_p_n
AC1ph_DC.Nodes.Electric_pn_p_n p_n_pn
SCpackage.SCswitch_Diode switch_D(par=par) "switch + reverse diode"
SCpackage.Diode diode(par=par) "diode"
Common.Thermal.Heat_a_b_ab heat_adapt
equation
connect(gate, switch_D.gate)
connect(DCin, pn_p_n.term_pn)
connect(pn_p_n.term_p, switch_D.term_p)
connect(switch_D.term_n, p_n_pn.term_p)
connect(pn_p_n.term_n, p_n_pn.term_n)
connect(p_n_pn.term_n, diode.term_p)
connect(diode.term_n, p_n_pn.term_p)
connect(p_n_pn.term_pn, DCout)
connect(switch_D.heat, heat_adapt.port_a)
connect(diode.heat, heat_adapt.port_b)
connect(heat_adapt.port_ab, heat)
end ChopperModular;
end Components;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model AC_DC_base "AC-DC base, 1-phase"
extends Icons.Inverter;
extends Ports.PortBase;
Ports.TwoPin_n AC "AC connection"
Ports.TwoPin_p DC "DC connection"
Interfaces.ThermalV_n heat( m=2) "vector heat port"
end AC_DC_base;
partial model DC_DC_base "DC-DC base"
extends Icons.Inverter;
extends Ports.PortBase;
Ports.TwoPin_p DCin "DC in connection"
Ports.TwoPin_n DCout "DC out connection"
Interfaces.ThermalV_n heat( m=2) "vector heat port"
end DC_DC_base;
partial model SwitchEquation "Switch equation, 1-phase"
extends AC_DC_base;
protected
PS.Voltage vDC1=0.5*(DC.v[1] - DC.v[2]);
PS.Voltage vDC0=0.5*(DC.v[1] + DC.v[2]);
PS.Current iDC1=(DC.i[1] - DC.i[2]);
PS.Current iDC0=(DC.i[1] + DC.i[2]);
Real[2] v "switching function voltage";
Real[2] switch "switching function";
SI.Temperature[heat.m] T "component temperature";
SI.HeatFlowRate[heat.m] Q_flow "component loss-heat flow";
function loss = Utilities.Math.taylor
"spec loss function of temperature";
equation
AC.v = v + {vDC0,vDC0};
iDC1 + switch*AC.i = 0;
iDC0 + sum(AC.i) = 0;
T = heat.ports.T;
heat.ports.Q_flow = -Q_flow;
end SwitchEquation;
end Partials;
end Inverters; |
Transmission lines 1-phase | within PowerSystems.AC1ph_DC;
package Lines "Transmission lines 1-phase"
extends Modelica.Icons.VariantsPackage;
model RXline "RX transmission line, 1-phase"
extends Ports.Port_pn;
extends Partials.RXlineBase(final ne=1);
PS.Voltage[2] v(start = v_start);
PS.Current[2] i(start = i_start);
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i) = zeros(2);
elseif dynType == Types.Dynamics.FixedInitial then
i = i_start;
end if;
equation
v = term_p.v - term_n.v;
i = term_p.i;
L*der(i) + diagonal(R)*i = v;
end RXline;
model PIline "PI transmission line, 1-phase"
extends Ports.Port_p_n;
extends Partials.LineBase;
PS.Voltage[2,ne1] v(start = transpose(fill(v_start, ne1)));
PS.Current[2,ne] i(start = transpose(fill(i_start, ne)));
protected
final parameter Integer ne1=ne + 1;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(v) = zeros(2,ne1);
der(i) = zeros(2,ne);
elseif dynType == Types.Dynamics.FixedInitial then
v = transpose(fill(v_start, ne1));
i = transpose(fill(i_start, ne));
end if;
equation
v[:, 1] = term_p.v;
v[:, ne1] = term_n.v;
C*der(v) + G*v =
[[2*(term_p.i - i[:, 1])], i[:, 1:ne - 1] - i[:, 2:ne], [2*(i[:, ne] + term_n.i)]];
L*der(i) + diagonal(R)*i =
v[:, 1:ne] - v[:, 2:ne1];
end PIline;
model Tline "T transmission line, 1-phase"
extends Ports.Port_p_n;
extends Partials.LineBase;
PS.Voltage[2,ne] v(start = transpose(fill(v_start, ne)));
PS.Current[2,ne1] i(start = transpose(fill(i_start, ne1)));
protected
final parameter Integer ne1=ne + 1;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(v) = zeros(2,ne);
der(i) = zeros(2,ne1);
elseif dynType == Types.Dynamics.FixedInitial then
v = transpose(fill(v_start, ne));
i = transpose(fill(i_start, ne1));
end if;
equation
i[:, 1] = term_p.i;
i[:, ne1] = -term_n.i;
C*der(v) + G*v = i[:, 1:ne] - i[:, 2:ne1];
L*der(i) + diagonal(R)*i = [[2*(term_p.v - v[:, 1])], v[:, 1:ne - 1] - v[:, 2:ne], [2*(v[:, ne] - term_n.v)]];
end Tline;
model FaultRXline "Faulted RX transmission line, 1-phase"
extends Ports.Port_p_n_f;
parameter Real p(min=0,max=1)=0.5 "rel fault-position (0 < p < 1)";
extends Partials.RXlineBase(final ne=1);
PS.Current[2] i1(start = i_start);
PS.Current[2] i2(start = i_start);
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i1) = zeros(2);
der(i2) = zeros(2);
elseif dynType == Types.Dynamics.FixedInitial then
i1 = i_start;
i2 = i_start;
end if;
equation
term_p.i + term_n.i + term_f.i = {0,0};
i1 = term_p.i;
i2 = -term_n.i;
p*(L*der(i1) + diagonal(R)*i1) = term_p.v - term_f.v;
(1 - p)*(L*der(i2) + diagonal(R)*i2) = term_f.v - term_n.v;
end FaultRXline;
model FaultTline "Faulted T transmission line, 1-phase"
extends Ports.Port_p_n_f;
parameter Real p(min=0.5/ne,max=1-0.5/ne)=0.5
"rel fault-pos (1/2ne <= p < 1 - 1/2ne)";
extends Partials.LineBase;
parameter PS.Current[2] iF_start = zeros(2) "start value of fault current"
PS.Voltage[2,ne] v(start = transpose(fill(v_start, ne)));
PS.Current[2,ne1] i(start = transpose(fill(i_start, ne1)));
PS.Current[2] iF;
PS.Current[2,2] iF_p(each stateSelect=StateSelect.never);
protected
final parameter Integer ne1=ne + 1;
final parameter Integer nF=integer(ne*p + 1.5);
final parameter Real pe=min(0.9, max(0.1, ne*p + 1.5 - nF))
"relative fault position within element nF";
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(v) = zeros(2,ne);
der(i) = zeros(2,ne1);
der(iF) = zeros(2);
elseif dynType == Types.Dynamics.FixedInitial then
v = transpose(fill(v_start, ne));
i = transpose(fill(i_start, ne1));
iF = iF_start;
end if;
equation
i[:, 1] = term_p.i;
i[:, ne1] = -term_n.i;
iF = -term_f.i;
iF_p = [(1-pe)*iF, pe*iF];
C*der(v) + G*v = [i[:,1:nF-2]-i[:, 2:nF-1], i[:,nF-1:nF]-i[:,nF:nF+1]-iF_p, i[:,nF+1:ne]-i[:,nF+2:ne1]];
L*der(i) + diagonal(R)*i = [[2*(term_p.v - v[:, 1])], v[:, 1:ne - 1] - v[:, 2:ne], [2*(v[:, ne] - term_n.v)]];
L*der(iF) + diagonal(R)*iF = (v[:, nF-1] - term_f.v)/pe + (v[:, nF] - term_f.v)/(1-pe);
end FaultTline;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model RXlineBase "RX-line base, 1-phase"
extends Ports.PortBase;
parameter SI.Length len=100e3 "line length";
parameter Integer ne(min=1)=1 "number of line elements";
replaceable record Data = PowerSystems.AC1ph_DC.Lines.Parameters.RXline
"line parameters"
final parameter Data par "line parameters"
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter PS.Voltage[2] v_start = zeros(2) "start value of voltage drop"
parameter PS.Current[2] i_start = zeros(2) "start value of current"
protected
outer System system;
final parameter Real[2] RL_base=Utilities.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];
final parameter SI.Inductance[2,2] L=([(par.x + par.x0),(par.x0 - par.x);(par.x0 - par.x),(par.x + par.x0)]/2)*delta_len_km*RL_base[2];
end RXlineBase;
partial model LineBase "PI- and T-line base, 1-phase"
extends RXlineBase(ne=3, redeclare replaceable record Data =
PowerSystems.AC1ph_DC.Lines.Parameters.Line);
protected
final parameter Real[2] GC_base=Utilities.Precalculation.baseGC(
par.puUnits,
par.V_nom,
par.S_nom,
2*pi*par.f_nom);
final parameter SI.Conductance[2,2] G=[par.g_pg+par.g_pp,-par.g_pp;-par.g_pp,par.g_pg+par.g_pp]*delta_len_km*GC_base[1];
final parameter SI.Capacitance[2,2] C=[par.b_pg+par.b_pp,-par.b_pp;-par.b_pp,par.b_pg+par.b_pp]*delta_len_km*GC_base[2];
end LineBase;
end Partials;
package Parameters "Parameter data for interactive use"
extends Modelica.Icons.MaterialPropertiesPackage;
record RXline "RX-line parameters, 1-phase"
extends Common.Nominal.NominalDataAC(S_nom=100e6);
SIpu.Resistance[2] r={0.1,0.1}*1e-3 "resistance/km"
SIpu.Reactance_km x=1e-3 "reactance/km"
SIpu.Reactance_km x0=3*x "reactance/km zero-comp"
end RXline;
record Line "Line parameters, 1-phase"
extends RXline;
SIpu.Conductance g_pg=0 "shunt conductance/km ph-grd"
SIpu.Conductance g_pp=0 "shunt conductance/km ph_ph"
SIpu.Susceptance_km b_pg=0.025e-3 "susceptance/km ph-grd"
SIpu.Susceptance_km b_pp=0.025e-3 "susceptance/km ph-ph"
end Line;
end Parameters;
end Lines; |
Loads | within PowerSystems.AC1ph_DC;
package Loads "Loads"
model Rload "Resistance load, 1-phase"
extends Partials.ResLoadBase;
equation
R = V2_nom/p;
end Rload;
extends Modelica.Icons.VariantsPackage;
model ZloadAC "Impedance load AC, 1-phase"
extends Partials.IndLoadBaseAC;
equation
Z = (pq/(pq*pq))*V2_nom;
end ZloadAC;
model YloadAC "Admittance load AC, 1-phase"
extends Partials.CapLoadBaseAC;
equation
Y = (pq/(pq*pq))*I2_nom;
end YloadAC;
model ZloadDC "Impedance load DC"
extends Partials.IndLoadBaseDC;
equation
R = V2_nom/p;
L = t_RL*R;
end ZloadDC;
model PindLoadDC "Inductive load DC"
extends Partials.IndLoadBaseDC;
parameter SIpu.Current imax(unit="1")=2 "maximum current";
parameter SI.Time tcst=0.01 "time constant R";
protected
Real v2 = v*v;
initial equation
der(R) = 0;
equation
// der(R) = (v2/p - R)/tcst;
der(R) = ((v2/p)*tanh(imax)/tanh(imax*v2/V2_nom) - R)/tcst;
L = t_RL*R;
end PindLoadDC;
model PresLoadDC "P resistive load"
extends Partials.ResLoadBase;
parameter SIpu.Current imax(unit="1")=2 "maximum current";
parameter SI.Time tcst=0.01 "time constant R";
protected
Real v2 = v*v;
initial equation
der(R) = 0;
equation
// der(R) = (v2/p - R)/tcst;
der(R) = ((v2/p)*tanh(imax)/tanh(imax*v2/V2_nom) - R)/tcst;
end PresLoadDC;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model LoadBase "Load base, 1-phase"
extends Common.Nominal.Nominal;
extends Ports.Port_p;
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
PS.Voltage v;
PS.Current i;
protected
outer System system;
final parameter Real S_base=Utilities.Precalculation.baseS(puUnits, S_nom);
equation
term.i[1] + term.i[2] = 0;
v = term.v[1] - term.v[2];
i = term.i[1];
end LoadBase;
partial model ResLoadBase "Resistive load base, 1-phase"
extends LoadBase(v(start=V_nom), i(start=V_nom/R_start));
parameter Boolean use_p_in = false
"= true to use input signal p_in, otherwise use parameter p0"
parameter SIpu.Power p0(min=0)=1 "fixed power (start value if signal input)"
Modelica.Blocks.Interfaces.RealInput p_in(min=0) if use_p_in
"desired power"
protected
Modelica.Blocks.Interfaces.RealInput p_internal
"Needed to connect to conditional connector";
final parameter Real V2_nom(unit="V2")=V_nom*V_nom;
final parameter Real R_start=V2_nom/(p0*S_base);
SI.Power p;
SI.Resistance R(start=R_start);
equation
connect(p_in, p_internal);
if not use_p_in then
p_internal = p0;
end if;
p = p_internal*S_base;
R*i = v;
end ResLoadBase;
partial model LoadBaseAC "Load base AC, 1-phase"
extends LoadBase;
parameter Boolean use_pq_in = false
"= true to use input signal pq_in, otherwise use parameter pq0"
parameter SIpu.Power[2] pq0(each min=0)={1,1}/sqrt(2)
"fixed {active, reactive} power (start value if use_pq_in)"
Modelica.Blocks.Interfaces.RealInput[2] pq_in(each min=0) if use_pq_in
"desired {active, reactive} power"
protected
Modelica.Blocks.Interfaces.RealInput[2] pq_internal
"Needed to connect to conditional connector";
SI.Power[2] pq;
equation
connect(pq_in, pq_internal);
if not use_pq_in then
pq_internal = pq0;
end if;
pq = pq_internal*S_base;
end LoadBaseAC;
partial model IndLoadBaseAC "Inductive load base AC, 1-phase"
extends LoadBaseAC(v(start=v_start), i(start=i_start));
parameter SI.MagneticFlux psi_start=0 "start value for magnetic flux"
SI.MagneticFlux psi(start=psi_start, stateSelect=StateSelect.prefer)
"magnetic flux";
protected
final parameter Real V2_nom=V_nom*V_nom;
final parameter Real[2] Z_start=(pq0/(pq0*pq0*S_base))*V2_nom;
final parameter PS.Voltage v_start=cos(system.alpha0)*V_nom;
final parameter PS.Current i_start=cos(system.alpha0-atan(Z_start[2]/Z_start[1]))*V_nom/sqrt(Z_start*Z_start);
SI.Impedance[2] Z(start=Z_start);
function atan=Modelica.Math.atan;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(psi) = 0;
elseif dynType == Types.Dynamics.FixedInitial then
psi = psi_start;
end if;
equation
psi = Z[2]*i/system.omega_nom;
if dynType <> Types.Dynamics.SteadyState then
der(psi) + Z[1]*i = v;
else
Z[1]*i = v;
end if;
end IndLoadBaseAC;
partial model CapLoadBaseAC "Capacitive load base AC, 1-phase"
extends LoadBaseAC(v(start=v_start), i(start=i_start));
parameter SI.ElectricCharge q_start=0 "start value for electric charge"
SI.ElectricCharge q(start=q_start, stateSelect=StateSelect.prefer)
"electric charge";
protected
final parameter Real I2_nom=(S_nom/V_nom)^2;
final parameter SI.Admittance[2] Y_start=(pq0/(pq0*pq0*S_base))*I2_nom;
final parameter PS.Voltage v_start=cos(system.alpha0)*V_nom;
final parameter PS.Current i_start=cos(system.alpha0+atan(Y_start[2]/Y_start[1]))*V_nom*sqrt(Y_start*Y_start);
SI.Admittance[2] Y(start=Y_start);
function atan=Modelica.Math.atan;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(q) = 0;
elseif dynType == Types.Dynamics.FixedInitial then
q = q_start;
end if;
equation
q = Y[2]*v/system.omega_nom;
if dynType <> Types.Dynamics.SteadyState then
der(q) + Y[1]*v = i;
else
Y[1]*v = i;
end if;
end CapLoadBaseAC;
partial model LoadBaseDC "Inductive load base DC"
extends LoadBase;
parameter Boolean use_p_in = false
"= true to use input signal p_in, otherwise use parameter p0"
parameter SIpu.Power p0(min=0)=1 "fixed power (start value if use_p_in)"
Modelica.Blocks.Interfaces.RealInput p_in(min=0) if use_p_in
"desired power"
protected
Modelica.Blocks.Interfaces.RealInput p_internal
"Needed to connect to conditional connector";
SI.Power p;
equation
connect(p_in, p_internal);
if not use_p_in then
p_internal = p0;
end if;
p = p_internal*S_base;
end LoadBaseDC;
partial model IndLoadBaseDC "Inductive load base DC"
extends LoadBaseDC;
parameter SI.Time t_RL=0.1 "R-L time constant";
parameter PS.Current i_start = 0
"start value of current"
protected
final parameter Real V2_nom(unit="V2")=V_nom*V_nom;
final parameter Real R_start=V2_nom/(p0*S_base);
SI.Resistance R(start=R_start);
SI.Inductance L(start=t_RL*R_start);
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(L*i) = 0;
elseif dynType == Types.Dynamics.FixedInitial then
i = i_start;
end if;
equation
der(L*i) + R*i = v;
end IndLoadBaseDC;
end Partials;
end Loads; |
DC-machines, electric part | within PowerSystems.AC1ph_DC;
package Machines "DC-machines, electric part"
extends Modelica.Icons.VariantsPackage;
model EMF "Electro motoric force"
extends Ports.Port_p;
parameter Real k(final unit="N.m/A") = 1 "transformation coefficient";
SI.AngularVelocity w "ang velocity rotor";
Interfaces.Rotation_n airgap "electro-mechanical connection"
equation
sum(term.i) = 0;
w = der(airgap.phi);
k*w = term.v[1] - term.v[2];
airgap.tau = -k*term.i[1];
end EMF;
model DCser "DC machine series excited"
extends Partials.DCserBase;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i) = 0;
elseif dynType == Types.Dynamics.FixedInitial then
i = i_start;
end if;
equation
if dynType <> Types.Dynamics.SteadyState then
c.L*der(i) + (w_el*c.L_md + sum(c.R))*i = v;
else
(w_el*c.L_md + sum(c.R))*i = v;
end if;
tau_el = i*(c.L_md*i);
heat.ports.Q_flow = -c.R*i*i;
end DCser;
model DCpar "DC machine parallel excited"
extends Partials.DCparBase;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der({i_f, i}) = {0,0};
elseif dynType == Types.Dynamics.FixedInitial then
i = i_start;
end if;
equation
if dynType <> Types.Dynamics.SteadyState then
diagonal(c.L)*der({i_f, i}) + {0, w_el*c.L_md*i_f} + diagonal(c.R)*{i_f, i} = {v_f, v};
else
{0, w_el*c.L_md*i_f} + diagonal(c.R)*{i_f, i} = {v_f, v};
end if;
tau_el = i*(c.L_md*i_f);
heat.ports.Q_flow = -{c.R[1]*i_f*i_f, c.R[2]*i*i};
end DCpar;
model DCpm "DC machine permanent magnet excited"
extends Partials.DCpmBase;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i) = 0;
elseif dynType == Types.Dynamics.FixedInitial then
i = i_start;
end if;
equation
if dynType <> Types.Dynamics.SteadyState then
c.L*der(i) + c.R*i = v - w_el*c.Psi_pm;
else
c.R*i = v - w_el*c.Psi_pm;
end if;
tau_el = i*c.Psi_pm;
heat.ports.Q_flow = -{0, c.R*i*i};
end DCpm;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model DCBase "Base DC machine"
extends Ports.Port_p;
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter PS.Voltage v_start = 0 "start value of voltage drop"
parameter PS.Current i_start = 0 "start value of current"
parameter Integer pp=2 "pole-pair number";
parameter SI.Angle phi_el_start=0 "initial rotor angle electric"
SI.Angle phi_el(start=phi_el_start, stateSelect=StateSelect.prefer)
"rotor angle electric";
SI.AngularVelocity w_el "rotor angular velocity el";
SI.Torque tau_el "electromagnetic torque";
PS.Voltage v(start = v_start) "voltage";
PS.Current i(start = i_start) "current";
Interfaces.Rotation_n airgap "electro-mechanical connection"
Interfaces.ThermalV_n heat(m=2) "heat source port {stator, rotor}"
protected
outer System system;
initial equation
phi_el = phi_el_start;
equation
sum(term.i) = 0;
v = term.v[1] - term.v[2];
i = term.i[1];
pp*airgap.phi = phi_el;
airgap.tau = -pp*tau_el;
w_el = der(phi_el);
end DCBase;
partial model DCserBase "DC machine series excited, parameter"
extends DCBase(final pp=par.pp);
replaceable record Data = PowerSystems.AC1ph_DC.Machines.Parameters.DCser
"machine parameters"
final parameter Data par "machine parameters"
protected
final parameter Coefficients.DCser c = Utilities.Precalculation.machineDCser(
par);
end DCserBase;
partial model DCparBase "DC machine parallel excited, parameter"
extends DCBase(final pp=par.pp);
replaceable record Data = PowerSystems.AC1ph_DC.Machines.Parameters.DCpar
"machine parameters"
final parameter Data par "machine parameters"
PS.Voltage v_f;
PS.Current i_f;
Ports.TwoPin_p field
protected
final parameter Coefficients.DCpar c = Utilities.Precalculation.machineDCpar(
par);
equation
sum(field.i) = 0;
v_f = field.v[1] - field.v[2];
i_f = field.i[1];
end DCparBase;
partial model DCpmBase "DC machine permanent magnet excited, parameter"
extends DCBase(final pp=par.pp);
replaceable record Data = PowerSystems.AC1ph_DC.Machines.Parameters.DCpm
"machine parameters"
final parameter Data par "machine parameters"
protected
final parameter Coefficients.DCpm c = Utilities.Precalculation.machineDCpm(
par);
end DCpmBase;
end Partials;
package Parameters "Parameter data for interactive use"
extends Modelica.Icons.MaterialPropertiesPackage;
record DCser "DC machine parameters series excited"
extends Common.Nominal.NominalDataDC(
w_nom=157.079632679489661923);
Integer pp=2 "pole-pair nb"
SIpu.Inductance l_fd=0.15 "inductance field (d-axis)"
SIpu.Resistance r_fd=0.01 "resistance field (d-axis)"
SIpu.Inductance l_q=0.5 "inductance armature+ (q-axis)"
SIpu.Resistance r_q=0.05 "resistance armature+ (q-axis)"
end DCser;
record DCpar "DC machine parameters parallel excited"
extends Common.Nominal.NominalDataDC(
w_nom=157.079632679489661923);
SI.Voltage Vf_nom=1 "nom field voltage"
Integer pp=2 "pole-pair nb"
SIpu.Inductance l_fd=100*pi "inductance field (d-axis)"
SIpu.Resistance r_fd=100 "resistance field (d-axis)"
SIpu.Inductance l_q=0.5 "inductance armature+ (q-axis)"
SIpu.Resistance r_q=0.05 "resistance armature+ (q-axis)"
end DCpar;
record DCpm "DC machine parameters permanent magnet excited"
extends Common.Nominal.NominalDataDC(
w_nom=157.079632679489661923);
Integer pp=2 "pole-pair nb"
SIpu.Inductance l_aq=0.5 "inductance armature (q-axis)"
SIpu.Resistance r_aq=0.05 "resistance armature (q-axis)"
end DCpm;
end Parameters;
package Coefficients "Coefficient matrices of machine equations"
extends Modelica.Icons.MaterialPropertiesPackage;
record DCser "Coefficients of DC machine series excited"
extends Modelica.Icons.Record;
SI.Inductance L "series inductance";
SI.Resistance[2] R "resistance {d (field), q (armature)} axis";
SI.Inductance L_md "mutual inductance";
end DCser;
record DCpar "Coefficients of DC machine parallel excited"
extends Modelica.Icons.Record;
SI.Inductance[2] L "inductance {d (field), q (armature)} axis";
SI.Resistance[2] R "resistance {d (field), q (armature)} axis";
SI.Inductance L_md "mutual inductance";
end DCpar;
record DCpm "Coefficients of DC machine permanent magnet excited"
extends Modelica.Icons.Record;
SI.Resistance R "resistance";
SI.Inductance L "inductance";
SI.MagneticFlux Psi_pm "flux permanent magnet";
end DCpm;
end Coefficients;
end Machines; |
Nodes | within PowerSystems.AC1ph_DC;
package Nodes "Nodes "
extends Modelica.Icons.VariantsPackage;
model Ground "Ground, 1-phase"
extends Ports.Port_p;
equation
term.v = zeros(2);
end Ground;
model PolarityGround "Polarity grounding, 1-phase"
extends Ports.Port_p;
parameter Integer pol(min=-1,max=1)=-1 "grounding scheme"
equation
if pol==1 then
term.v[1] = 0;
term.i[2] = 0;
elseif pol==-1 then
term.v[2] = 0;
term.i[1] = 0;
else
term.v[1] + term.v[2] = 0;
term.i[1] = term.i[2];
end if;
end PolarityGround;
model GroundOne "Ground, one conductor"
Interfaces.Electric_p term
equation
term.v = 0;
end GroundOne;
model BusBar "Busbar, 1-phase"
extends Ports.PortBase;
output PS.Voltage v(stateSelect=StateSelect.never);
Ports.TwoPin_p term
equation
term.i = zeros(2);
v = term.v[1] - term.v[2];
end BusBar;
model Electric_pn_p_n "Adaptor ElectricV[2] (vector) to Electric (scalar)."
Ports.TwoPin_p term_pn "vector pin {p,n}"
Interfaces.Electric_p term_p "scalar p"
Interfaces.Electric_n term_n "scalar n"
equation
term_pn.v = {term_p.v, term_n.v};
term_pn.i + {term_p.i, term_n.i} = zeros(2);
end Electric_pn_p_n;
/*
model Electric_abc_a_b_c "Adaptor ElectricV[3] (vector) to Electric (scalar)"
Basic.Interfaces.ElectricV_p term_abc(
final m=3) "vector {a,b,c}"
Interfaces.Electric_n term_a "scalar a"
Interfaces.Electric_n term_b "scalar b"
Interfaces.Electric_n term_c "scalar c"
equation
{term_a.v,term_b.v,term_c.v} = term_abc.v;
term_abc.i + {term_a.i,term_b.i,term_c.i} = zeros(3);
end Electric_abc_a_b_c;
*/
end Nodes; |
AC 1-phase and DC components from Spot AC1ph_DC | within PowerSystems;
package AC1ph_DC "AC 1-phase and DC components from Spot AC1ph_DC"
extends Modelica.Icons.VariantsPackage;
end AC1ph_DC; |
Strandard electric ports | within PowerSystems.AC1ph_DC;
package Ports "Strandard electric ports"
extends Modelica.Icons.InterfacesPackage;
partial model PortBase "base model defining PhaseSystem"
package PS = PhaseSystems.TwoConductor;
end PortBase;
connector TwoPin_p "AC1/DC terminal ('positive')"
extends Interfaces.TerminalDC(redeclare package PhaseSystem =
PhaseSystems.TwoConductor);
end TwoPin_p;
connector TwoPin_n "AC1/DC terminal ('negative')"
extends Interfaces.TerminalDC(redeclare package PhaseSystem =
PhaseSystems.TwoConductor);
end TwoPin_n;
partial model Port_p "One port, 'positive'"
extends PortBase;
Ports.TwoPin_p term "positive terminal"
end Port_p;
partial model Port_n "One port, 'negative'"
extends PortBase;
Ports.TwoPin_n term "negative terminal"
end Port_n;
partial model Port_f "One port, 'fault'"
extends PortBase;
Ports.TwoPin_p term "fault terminal"
end Port_f;
partial model Port_p_n "Two port"
extends PortBase;
Ports.TwoPin_p term_p "positive terminal"
Ports.TwoPin_n term_n "negative terminal"
end Port_p_n;
partial model Port_pn "Two port, 'current_in = current_out'"
extends Port_p_n;
equation
term_p.i + term_n.i = zeros(2);
end Port_pn;
partial model Port_p_n_f "Three port"
extends Port_p_n;
Ports.TwoPin_n term_f "fault terminal"
end Port_p_n_f;
partial model PortTrafo_p_n "Two port for transformers"
extends Port_p_n;
PS.Voltage v1 "voltage 1";
PS.Current i1 "current 1";
PS.Voltage v2 "voltage 2";
PS.Current i2 "current 2";
protected
Real w1 "1: voltage ratio to nominal";
Real w2 "2: voltage ratio to nominal";
equation
term_p.i[1] + term_p.i[2] = 0;
term_n.i[1] + term_n.i[2] = 0;
v1 = (term_p.v[1] - term_p.v[2])/w1;
term_p.i[1] = i1/w1;
v2 = (term_n.v[1] - term_n.v[2])/w2;
term_n.i[1] = i2/w2;
end PortTrafo_p_n;
partial model PortTrafo_p_n_n "Three port for 3-winding transformers"
extends PortBase;
Ports.TwoPin_p term_p "positive terminal"
Ports.TwoPin_n term_na "negative terminal a"
Ports.TwoPin_n term_nb "negative terminal b"
PS.Voltage v1 "voltage 1";
PS.Current i1 "current 1";
PS.Voltage v2a "voltage 2a";
PS.Current i2a "current 2a";
PS.Voltage v2b "voltage 2b";
PS.Current i2b "current 2b";
PS.Voltage v0;
protected
Real w1 "1: voltage ratio to nominal";
Real w2a "2a: voltage ratio to nominal";
Real w2b "2b: voltage ratio to nominal";
equation
term_p.i[1] + term_p.i[2] = 0;
term_na.i[1] + term_na.i[2] = 0;
term_nb.i[1] + term_nb.i[2] = 0;
v1 = (term_p.v[1] - term_p.v[2])/w1;
term_p.i[1] = i1/w1;
v2a = (term_na.v[1] - term_na.v[2])/w2a;
term_na.i[1] = i2a/w2a;
v2b = (term_nb.v[1] - term_nb.v[2])/w2b;
term_nb.i[1] = i2b/w2b;
end PortTrafo_p_n_n;
end Ports; |
Sensors n-phase or DC | within PowerSystems.AC1ph_DC;
package Sensors "Sensors n-phase or DC"
extends Modelica.Icons.SensorsPackage;
model VdiffSensor "Voltage difference sensor, 1-phase"
extends Partials.Sensor1Base(final S_nom=1);
Modelica.Blocks.Interfaces.RealOutput v
"difference voltage 'plus' - 'minus'"
protected
final parameter PS.Voltage V_base=Utilities.Precalculation.baseV(
puUnits, V_nom);
equation
v = (term.v[1] - term.v[2])/V_base;
end VdiffSensor;
model IdiffSensor "Current difference sensor, 1-phase"
extends Partials.Sensor2Base;
Modelica.Blocks.Interfaces.RealOutput i
"current ('plus' - 'minus')/2, term_p to term_n"
protected
final parameter PS.Current I_base=Utilities.Precalculation.baseI(
puUnits, V_nom, S_nom);
equation
i = 0.5*(term_p.i[1] - term_p.i[2])/I_base;
end IdiffSensor;
model Vsensor "Voltage sensor, 1-phase"
extends Partials.Sensor1Base(final S_nom=1);
Modelica.Blocks.Interfaces.RealOutput[2] v
"voltage 'plus' and 'minus'-to-ground"
protected
final parameter PS.Voltage V_base=Utilities.Precalculation.baseV(
puUnits, V_nom);
equation
v = term.v/V_base;
end Vsensor;
model Isensor "Current sensor, 1-phase"
extends Partials.Sensor2Base;
Modelica.Blocks.Interfaces.RealOutput[2] i
"current 'plus' and 'minus', term_p to term_n"
protected
final parameter PS.Current I_base=Utilities.Precalculation.baseI(
puUnits, V_nom, S_nom);
equation
i = term_p.i/I_base;
end Isensor;
model Psensor "Power sensor, 1-phase"
extends Partials.Sensor2Base;
Modelica.Blocks.Interfaces.RealOutput p "power, term_p to term_n"
protected
final parameter SI.ApparentPower S_base=Utilities.Precalculation.baseS(
puUnits, S_nom);
equation
p = term_p.v*term_p.i/S_base;
end Psensor;
model Vmeter "Voltage meter, 1-phase"
extends Partials.Meter1Base(final S_nom=1);
output SIpu.Voltage v(stateSelect=StateSelect.never);
output SIpu.Voltage v0(stateSelect=StateSelect.never);
protected
SIpu.Voltage[2] v_ab(each stateSelect=StateSelect.never);
final parameter PS.Voltage V_base=Utilities.Precalculation.baseV(
puUnits, V_nom);
equation
v_ab = term.v/V_base;
v = v_ab[1] - v_ab[2];
v0 = (v_ab[1] + v_ab[2])/2;
end Vmeter;
model Imeter "Current meter, 1-phase"
extends Partials.Meter2Base;
output SIpu.Current i(stateSelect=StateSelect.never);
output SIpu.Current i0(stateSelect=StateSelect.never);
protected
SIpu.Current[2] i_ab(each stateSelect=StateSelect.never);
final parameter PS.Current I_base=Utilities.Precalculation.baseI(
puUnits, V_nom, S_nom);
equation
i_ab = term_p.i/I_base;
i = (i_ab[1] - i_ab[2])/2;
i0 = (i_ab[1] + i_ab[2]);
end Imeter;
model Pmeter "Power meter, 1-phase"
parameter Boolean av=false "time average power"
parameter SI.Time tcst(min=1e-9)=1 "average time-constant"
extends Partials.Meter2Base(final V_nom=1);
output SIpu.Power p(stateSelect=StateSelect.never);
output SIpu.Power p_av=pav if av;
protected
outer System system;
final parameter SI.ApparentPower S_base=Utilities.Precalculation.baseS(
puUnits, S_nom);
SIpu.Power pav;
initial equation
if av then
pav = p;
end if;
equation
p = (term_p.v*term_p.i)/S_base;
if av then
der(pav) = (p - pav)/tcst;
else
pav = 0;
end if;
end Pmeter;
model PVImeter "Power-voltage-current meter, 1-phase"
parameter Boolean av=false "time average power"
parameter SI.Time tcst(min=1e-9)=1 "average time-constant"
extends Partials.Meter2Base;
output SIpu.Power p(stateSelect=StateSelect.never);
output SIpu.Power p_av=pav if av;
output SIpu.Voltage v(stateSelect=StateSelect.never);
output SIpu.Voltage v0(stateSelect=StateSelect.never);
output SIpu.Current i(stateSelect=StateSelect.never);
output SIpu.Current i0(stateSelect=StateSelect.never);
protected
outer System system;
final parameter PS.Voltage V_base=Utilities.Precalculation.baseV(
puUnits, V_nom);
final parameter PS.Current I_base=Utilities.Precalculation.baseI(
puUnits, V_nom, S_nom);
SIpu.Power pav;
SIpu.Voltage[2] v_ab;
SIpu.Current[2] i_ab;
initial equation
if av then
pav = p;
end if;
equation
v_ab = term_p.v/V_base;
i_ab = term_p.i/I_base;
v = v_ab[1] - v_ab[2];
v0 = (v_ab[1] + v_ab[2])/2;
i = (i_ab[1] - i_ab[2])/2;
i0 = (i_ab[1] + i_ab[2]);
p = v_ab*i_ab;
if av then
der(pav) = (p - pav)/tcst;
else
pav = 0;
end if;
end PVImeter;
model Efficiency "Power sensor, 3-phase dq0"
extends Partials.Sensor2Base;
Interfaces.ThermalV_p heat( m=m) "vector heat port"
parameter Boolean dir_in=true "direction"
parameter Integer m(final min=1)=1 "dimension of heat port";
parameter Boolean av=false "time average efficiency"
parameter SI.Time tcst(min=1e-9)=1 "average time-constant"
parameter SI.Temperature T_amb=300 "ambient temperature";
output Real eta "efficiency";
protected
SI.Power p "total el power, term_p to term_n";
SI.HeatFlowRate q "total heat flow 'in'";
SI.Power pav(start=1);
SI.HeatFlowRate qav(start=1);
initial equation
if av then
pav = p;
qav = q;
end if;
equation
heat.ports.T = fill(T_amb, heat.m);
p = term_p.v*term_p.i;
q = sum(heat.ports.Q_flow);
if av then
der(pav) = (p - pav)/tcst;
der(qav) = (q - qav)/tcst;
else
pav = p;
qav = q;
end if;
if qav < abs(pav) then
if dir_in then
eta = if pav > 0 then 100*(pav - qav)/pav else -100*pav/(pav - qav);
else
eta = if pav > 0 then 100*pav/(pav + qav) else -100*(pav + qav)/pav;
end if;
else
eta = 0;
end if;
end Efficiency;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model Sensor1Base "Sensor Base, 1-phase"
extends Ports.Port_p;
extends Common.Nominal.Nominal;
equation
term.i = zeros(2);
end Sensor1Base;
partial model Sensor2Base "Sensor Base, 1-phase"
extends Ports.Port_pn;
extends Common.Nominal.Nominal;
equation
term_p.v = term_n.v;
end Sensor2Base;
partial model Meter1Base "Meter base 1 terminal, 1-phase"
extends Sensor1Base;
end Meter1Base;
partial model Meter2Base "Meter base 2 terminal, 1-phase"
extends Sensor2Base;
end Meter2Base;
end Partials;
end Sensors; |
Shunt reactor with parallel conductor, 1-phase | within PowerSystems.AC1ph_DC;
package Shunts
extends Modelica.Icons.VariantsPackage;
model ReactiveShunt "Shunt reactor with parallel conductor, 1-phase"
extends Partials.ShuntBase;
parameter SIpu.Conductance g=0 "conductance (parallel)";
parameter SIpu.Resistance r=0 "resistance (serial)";
parameter SIpu.Reactance x_s=1 "self reactance";
parameter SIpu.Reactance x_m=0 "mutual reactance, -x_s < x_m < x_s";
protected
final parameter SI.Resistance[2] RL_base=Utilities.Precalculation.baseRL(
puUnits,
V_nom,
S_nom,
2*pi*f_nom);
SI.Conductance G=g/RL_base[1];
SI.Resistance R=r*RL_base[1];
SI.Inductance[2,2] L=[x_s,x_m;x_m,x_s]*RL_base[2];
PS.Current[2] i_x;
equation
i_x = i - G*v;
L*der(i_x) + R*i_x = v;
end ReactiveShunt;
model CapacitiveShunt "Shunt capacitor with parallel conductor, 1-phase, pp pg"
extends Partials.ShuntBase;
parameter SIpu.Conductance g_pg=0 "conductance ph-grd";
parameter SIpu.Conductance g_pp=0 "conductance ph_ph";
parameter SIpu.Susceptance b_pg=0.5 "susceptance ph-grd";
parameter SIpu.Susceptance b_pp=0.5 "susceptance ph-ph";
protected
final parameter SI.Resistance[2] GC_base=Utilities.Precalculation.baseGC(
puUnits,
V_nom,
S_nom,
2*pi*f_nom);
SI.Conductance[2,2] G=[g_pg+g_pp,-g_pp;-g_pp,g_pg+g_pp]*GC_base[1];
SI.Capacitance[2,2] C=[b_pg+b_pp,-b_pp;-b_pp,b_pg+b_pp]*GC_base[2];
equation
C*der(v) + G*v = i;
end CapacitiveShunt;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model ShuntBase "Load base, 1-phase"
extends Ports.Port_p;
extends Common.Nominal.NominalAC;
PS.Voltage[2] v "voltage";
PS.Current[2] i "current";
equation
v = term.v;
i = term.i;
end ShuntBase;
end Partials;
end Shunts; |
DC voltage sources | within PowerSystems.AC1ph_DC;
package Sources "DC voltage sources"
extends Modelica.Icons.SourcesPackage;
model ACvoltage "Ideal AC voltage, 1-phase"
extends Partials.ACvoltageBase;
parameter SIpu.Voltage v0eff=1 "fixed effective voltage"
parameter SI.Angle alpha0=0 "fixed phase angle"
protected
PS.Voltage V;
SI.Angle alpha;
SI.Angle phi;
equation
if not use_vPhasor_in then
vPhasor_internal = {v0eff, alpha0};
end if;
V = vPhasor_internal[1]*sqrt(2)*V_base;
alpha = vPhasor_internal[2];
phi = theta + alpha + system.alpha0;
term.v[1] - term.v[2] = V*cos(phi);
end ACvoltage;
model Vspectrum "Ideal voltage spectrum, 1-phase"
extends Partials.ACvoltageBase;
parameter Integer[:] h={1,3,5} "[1,.. ], which harmonics?";
parameter SIpu.Voltage[N] v0eff={1,0.3,0.1} "effective voltages";
parameter SI.Angle[N] alpha0=zeros(N) "phase angles";
protected
final parameter Integer N=size(h, 1) "nb of harmonics";
PS.Voltage V;
SI.Angle alpha;
SI.Angle[N] phi;
equation
if not use_vPhasor_in then
vPhasor_internal = {1, 0};
end if;
V = vPhasor_internal[1]*sqrt(2)*V_base;
alpha = vPhasor_internal[2];
phi = h*(theta + alpha + system.alpha0) + h.*alpha0;
term.v[1] - term.v[2] = V*v0eff*cos(phi);
end Vspectrum;
model DCvoltage "Ideal DC voltage"
extends Partials.DCvoltageBase(pol=-1);
parameter SIpu.Voltage v0=1 "fixed DC voltage"
protected
PS.Voltage v;
equation
if not use_vDC_in then
vDC_internal = v0;
end if;
v = vDC_internal*V_base;
term.v[1] - term.v[2] = v;
end DCvoltage;
model Battery "Battery"
extends Ports.Port_n;
extends Common.Nominal.Nominal;
parameter SIpu.Voltage v0=1 "battery voltage";
protected
final parameter Real V_base=Utilities.Precalculation.baseV(puUnits, V_nom);
PS.Voltage v;
PS.Current i;
equation
v = v0*V_base;
term.v[2] = 0;
term.v[1] - term.v[2] = v;
term.i[1] = -i;
end Battery;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model VoltageBase "Voltage base"
extends Ports.Port_n;
extends Common.Nominal.Nominal(
final S_nom=1);
parameter Integer pol(min=-1,max=1)=-1 "grounding scheme"
Interfaces.Electric_p neutral "(use for grounding)"
protected
final parameter Real V_base=Utilities.Precalculation.baseV(puUnits, V_nom);
equation
if pol==1 then
term.v[1] = neutral.v;
elseif pol==-1 then
term.v[2] = neutral.v;
else
term.v[1] + term.v[2] = neutral.v;
end if;
sum(term.i) + neutral.i = 0;
end VoltageBase;
partial model ACvoltageBase "AC voltage base"
extends VoltageBase;
parameter Types.SourceFrequency fType=PowerSystems.Types.SourceFrequency.System
"frequency type"
parameter SI.Frequency f=system.f "frequency if type is parameter"
parameter Boolean use_vPhasor_in = false
"= true to use input signal vPhasor_in, otherwise use fixed values"
Modelica.Blocks.Interfaces.RealInput[2] vPhasor_in if use_vPhasor_in
"{abs(voltage), phase(voltage)}"
Modelica.Blocks.Interfaces.RealInput omega_in(final unit="rad/s") if fType
== PowerSystems.Types.SourceFrequency.Signal
"Angular frequency of source"
protected
Modelica.Blocks.Interfaces.RealInput omega_internal
"Needed to connect to conditional connector";
Modelica.Blocks.Interfaces.RealInput[2] vPhasor_internal
"Needed to connect to conditional connector";
outer System system;
SI.Angle theta(stateSelect=StateSelect.prefer);
initial equation
if fType == Types.SourceFrequency.Signal then
theta = 0;
end if;
equation
connect(omega_in, omega_internal);
connect(vPhasor_in, vPhasor_internal);
if fType <> Types.SourceFrequency.Signal then
omega_internal = 0.0;
end if;
if fType == Types.SourceFrequency.System then
theta = system.theta;
elseif fType == Types.SourceFrequency.Parameter then
theta = 2*pi*f*(time - system.initime);
elseif fType == Types.SourceFrequency.Signal then
der(theta) = omega_internal;
end if;
end ACvoltageBase;
partial model DCvoltageBase "DC voltage base"
extends VoltageBase;
parameter Integer pol(min=-1,max=1)=-1 "grounding scheme"
parameter Boolean use_vDC_in = false
"= true to use input signal vDC_in, otherwise use fixed value"
Modelica.Blocks.Interfaces.RealInput vDC_in if
use_vDC_in "DC voltage"
protected
Modelica.Blocks.Interfaces.RealInput vDC_internal
"Needed to connect to conditional connector";
equation
connect(vDC_in, vDC_internal);
end DCvoltageBase;
end Partials;
end Sources; |
Transformers 1-phase | within PowerSystems.AC1ph_DC;
package Transformers "Transformers 1-phase "
extends Modelica.Icons.VariantsPackage;
model TrafoIdeal "Ideal transformer, 1-phase"
extends Partials.TrafoIdealBase;
equation
i1 + i2 = 0;
v1 = v2;
end TrafoIdeal;
model TrafoStray "Ideal magnetic coupling transformer, 1-phase"
extends Partials.TrafoStrayBase;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i1) = 0;
elseif dynType == Types.Dynamics.FixedInitial then
i1 = i1_start;
end if;
equation
i1 + i2 = 0;
sum(L)*der(i1) + sum(R)*i1 = v1 - v2;
end TrafoStray;
model TrafoMag "Magnetic coupling transformer, 1-phase"
extends Partials.TrafoMagBase;
PS.Voltage v0;
PS.Current imag;
PS.Current iedc;
Real psi0 "unsaturated flux";
equation
i1 + i2 = imag + iedc;
Redc*iedc = v0;
psi0 = Lm*imag;
L[1]*der(i1) + R[1]*i1 = v1 - v0;
L[2]*der(i2) + R[2]*i2 = v2 - v0;
Lm*der(imag) = v0;
end TrafoMag;
model TrafoSat "Saturation transformer, 1-phase"
extends Partials.TrafoSatBase;
PS.Voltage v0;
PS.Current imag;
PS.Current iedc;
protected
Real psi0 "unsaturated flux";
Real g;
function der_sat = Common.IronSaturation.der_saturationAnalytic;
equation
i1 + i2 = imag + iedc;
Redc*iedc = v0;
psi0 = Lm*imag;
g = scalar(der_sat({psi0}/psi_nom, c_sat));
L[1]*der(i1) + R[1]*i1 = v1 - v0;
L[2]*der(i2) + R[2]*i2 = v2 - v0;
g*der(psi0) = v0;
end TrafoSat;
model Trafo3Stray "Ideal magnetic coupling transformer, 1-phase"
extends Partials.Trafo3StrayBase;
equation
i1 + i2a + i2b = 0;
L[1]*der(i1) + R[1]*i1 = v1 - v0;
L[2]*der(i2a) + R[2]*i2a = v2a - v0;
L[3]*der(i2b) + R[3]*i2b = v2b - v0;
end Trafo3Stray;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model TrafoIdealBase "Base for ideal transformer, 1-phase"
extends Ports.PortTrafo_p_n(i1(start = i1_start), i2(start = i2_start));
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter PS.Current i1_start = 0 "start value of primary current"
parameter PS.Current i2_start = i1_start
"start value of secondary current"
parameter Boolean use_tap_1_in = false "= true to enable input tap_1_in"
parameter Integer tap_1 = par.tap_neutral[1] "fixed tap_1 position"
parameter Boolean use_tap_2_in = false "= true to enable input tap_2_in"
parameter Integer tap_2 = par.tap_neutral[2] "fixed tap_2 position"
parameter Boolean dynTC=false "enable dynamic tap-changing"
Modelica.Blocks.Interfaces.IntegerInput tap_1_in if use_tap_1_in
"1: index of voltage level"
Modelica.Blocks.Interfaces.IntegerInput tap_2_in if use_tap_2_in
"2: index of voltage level"
replaceable record Data =
PowerSystems.AC1ph_DC.Transformers.Parameters.TrafoIdeal1ph
"trafo parameters"
final parameter Data par "trafo parameter record"
protected
Modelica.Blocks.Interfaces.IntegerInput tap_1_internal
"Needed to connect to conditional connector";
Modelica.Blocks.Interfaces.IntegerInput tap_2_internal
"Needed to connect to conditional connector";
outer System system;
constant Real tc=0.01 "time constant tap-chg switching";
final parameter PS.Voltage[2] V_base=Utilities.Precalculation.baseTrafoV(
par.puUnits, par.V_nom);
final parameter Real[2,2] RL_base=Utilities.Precalculation.baseTrafoRL(
par.puUnits,
par.V_nom,
par.S_nom,
2*pi*par.f_nom);
Real w_nom = par.V_nom[2]/par.V_nom[1] "nominal turns ratio";
Real[2] dv_tap_pu = par.dv_tap .* V_base ./ par.V_nom;
Real w1_set = (1 + (tap_1_internal - par.tap_neutral[1]) * dv_tap_pu[1])
"1: set voltage ratio to nominal primary";
Real w2_set = (1 + (tap_2_internal - par.tap_neutral[2]) * dv_tap_pu[2]) * w_nom
"2: set voltage ratio to nominal primary";
initial equation
if dynTC then
w1 = w1_set;
w2 = w2_set;
end if;
equation
connect(tap_1_in, tap_1_internal);
connect(tap_2_in, tap_2_internal);
if not use_tap_1_in then
tap_1_internal = tap_1;
end if;
if not use_tap_2_in then
tap_2_internal = tap_2;
end if;
if dynTC then
der(w1) + (w1 - w1_set)/tc = 0;
der(w2) + (w2 - w2_set)/tc = 0;
else
w1 = w1_set;
w2 = w2_set;
end if;
end TrafoIdealBase;
partial model TrafoStrayBase
"Base for ideal magnetic coupling transformer, 1-phase"
extends TrafoIdealBase(redeclare replaceable record Data =
PowerSystems.AC1ph_DC.Transformers.Parameters.TrafoStray1ph);
protected
SI.Resistance[2] R=par.r.*RL_base[:, 1];
SI.Inductance[2] L=par.x.*RL_base[:, 2];
end TrafoStrayBase;
partial model TrafoMagBase
"Base for magnetic coupling transformer, 1-phase"
extends TrafoStrayBase(redeclare replaceable record Data =
PowerSystems.AC1ph_DC.Transformers.Parameters.TrafoMag1ph);
protected
final parameter SI.Resistance[2] RL12_base = sqrt((RL_base[1,:].*RL_base[2,:]));
SI.Resistance Redc=par.redc*RL12_base[1];
SI.Inductance Lm=par.xm*RL12_base[2];
end TrafoMagBase;
partial model TrafoSatBase "Base for saturation transformer, 1-phase"
extends TrafoMagBase(redeclare replaceable record Data =
PowerSystems.AC1ph_DC.Transformers.Parameters.TrafoSat1ph);
protected
Real xratio=par.xm_sat/par.xm;
Real[3] c_sat={1-xratio,(1-xratio)/(par.psi_sat-xratio),xratio};
final parameter SI.MagneticFlux psi_nom=sqrt(2)*par.V_nom[1]/(2*pi*par.f_nom)
"amplitude!";
end TrafoSatBase;
partial model Trafo3IdealBase "Base for ideal transformer, 1-phase"
extends Ports.PortTrafo_p_n_n;
parameter Boolean use_tap_1_in = false "= true to enable input tap_1_in"
parameter Integer tap_1 = par.tap_neutral[1] "fixed tap_1 position"
parameter Boolean use_tap_2_in = false "= true to enable input tap_2_in"
parameter Integer[2] tap_2 = par.tap_neutral[2:3] "fixed tap_2 position"
parameter Boolean dynTC=false "enable dynamic tap-changing"
Modelica.Blocks.Interfaces.IntegerInput tap_1_in if use_tap_1_in
"1: index of voltage level"
Modelica.Blocks.Interfaces.IntegerInput[2] tap_2_in if use_tap_2_in
"2: indices of voltage levels"
replaceable record Data =
PowerSystems.AC1ph_DC.Transformers.Parameters.Trafo3Ideal1ph
"trafo parameters"
final parameter Data par "trafo parameter"
protected
Modelica.Blocks.Interfaces.IntegerInput tap_1_internal
"Needed to connect to conditional connector";
Modelica.Blocks.Interfaces.IntegerInput[2] tap_2_internal
"Needed to connect to conditional connector";
outer System system;
constant Real tc=0.01 "time constant tap-chg switching";
final parameter PS.Voltage[3] V_base=Utilities.Precalculation.baseTrafoV(
par.puUnits, par.V_nom);
final parameter Real[3,2] RL_base=Utilities.Precalculation.baseTrafoRL(
par.puUnits,
par.V_nom,
par.S_nom,
2*pi*par.f_nom);
Real wa_nom = par.V_nom[2]/par.V_nom[1] "nominal turns ratio";
Real wb_nom = par.V_nom[3]/par.V_nom[1] "nominal turns ratio";
Real[3] dv_tap_pu = par.dv_tap .* V_base ./ par.V_nom;
Real w1_set = (1 + (tap_1_internal - par.tap_neutral[1]) * dv_tap_pu[1])
"1: set voltage ratio to nominal primary";
Real w2a_set = (1 + (tap_2_internal[1] - par.tap_neutral[2]) * dv_tap_pu[2]) * wa_nom
"2a: set voltage ratio to nominal primary";
Real w2b_set = (1 + (tap_2_internal[2] - par.tap_neutral[3]) * dv_tap_pu[3]) * wb_nom
"2b: set voltage ratio to nominal primary";
initial equation
if dynTC then
w1 = w1_set;
w2a = w2a_set;
w2b = w2b_set;
end if;
equation
connect(tap_1_in, tap_1_internal);
connect(tap_2_in, tap_2_internal);
if not use_tap_1_in then
tap_1_internal = tap_1;
end if;
if not use_tap_2_in then
tap_2_internal = tap_2;
end if;
if dynTC then
der(w1) + (w1 - w1_set)/tc = 0;
der(w2a) + (w2a - w2a_set)/tc = 0;
der(w2b) + (w2b - w2b_set)/tc = 0;
else
w1 = w1_set;
w2a = w2a_set;
w2b = w2b_set;
end if;
end Trafo3IdealBase;
partial model Trafo3StrayBase
"Base for ideal magnetic coupling transformer, 1-phase"
extends Trafo3IdealBase(redeclare replaceable record Data =
PowerSystems.AC1ph_DC.Transformers.Parameters.Trafo3Stray1ph);
protected
SI.Resistance[3] R=par.r.*RL_base[:, 1];
SI.Inductance[3] L=par.x.*RL_base[:, 2];
end Trafo3StrayBase;
end Partials;
package Parameters "Parameter data for interactive use"
extends Modelica.Icons.MaterialPropertiesPackage;
record TrafoIdeal1ph "Parameters for ideal transformer, 1-phase"
extends Common.Nominal.NominalDataTrafo;
Integer[2] tap_neutral={0, 0} "{1,2}: neutral tap position"
SIpu.Voltage[2] dv_tap={0, 0} "{1,2}: delta-v per tap change"
end TrafoIdeal1ph;
record TrafoStray1ph
"Parameters for ideal magnetic coupling transformer, 1-phase"
extends TrafoIdeal1ph;
SIpu.Resistance[2] r={0.05,0.05} "{1,2}: resistance"
SIpu.Reactance[2] x={0.05,0.05} "{1,2}: stray reactance"
end TrafoStray1ph;
record TrafoMag1ph "Parameters for magnetic coupling transformer, 1-phase"
extends TrafoStray1ph;
SIpu.Resistance redc=500 "resistance eddy current"
SIpu.Reactance xm=500 "mutual reactance"
end TrafoMag1ph;
record TrafoSat1ph "Parameters for saturation transformer, 1-phase"
extends TrafoMag1ph;
Real psi_sat(unit="1")=1.5 "saturation flux"
SIpu.Reactance xm_sat=1 "mutual reactance saturated"
end TrafoSat1ph;
record Trafo3Ideal1ph "Parameters for ideal transformer, 1-phase"
Integer[3] tap_neutral={0, 0, 0} "{1,2a,2b}: neutral tap position"
SIpu.Voltage[3] dv_tap={0, 0, 0} "{1,2a,2b}: delta-v per tap change"
extends Common.Nominal.NominalDataTrafo(V_nom={1,1,1}
"{prim,sec_a,sec_b} nom Voltage (= base if pu)");
end Trafo3Ideal1ph;
record Trafo3Stray1ph
"Parameters for ideal magnetic coupling transformer, 1-phase"
extends Trafo3Ideal1ph;
SIpu.Resistance[3] r={0.05,0.05,0.05} "{1,2a,2b}: resistance"
SIpu.Reactance[3] x={0.05,0.05,0.05} "{1,2a,2b}: stray reactance"
end Trafo3Stray1ph;
end Parameters;
end Transformers; |
Switches and Breakers 3-phase | within PowerSystems.AC3ph;
package Breakers "Switches and Breakers 3-phase"
extends Modelica.Icons.VariantsPackage;
model ForcedSwitch "Forced switch, 3-phase dq0"
extends Partials.SwitchBase(final n=1);
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter SI.Time t_relax=10e-3 "switch relaxation time";
parameter Integer p_relax(min=2)=4 "power of relaxation exponent";
protected
outer System system;
SI.Time t0(start=-Modelica.Constants.inf);
Real[2] r(start={0,1});
Real[PS.n] s;
/*
Boolean open(start=not control[1])=not control[1];
Boolean closed(start=control[1])=control[1];
Start values not correct, since no parameter expressions.
Removed start values and initalized the pre(..) values in the
initial equation section.
*/
Boolean open=not control[1];
Boolean closed=control[1];
function relaxation=PowerSystems.Utilities.Math.relaxation;
initial equation
pre(open) = not control[1];
pre(closed) = control[1];
if dynType <> Types.Dynamics.SteadyState then
t0 = -Modelica.Constants.inf;
end if;
equation
if dynType <> Types.Dynamics.SteadyState then
when edge(open) or edge(closed) then
t0 = time;
end when;
r = relaxation(time - t0, t_relax, p_relax);
{v,i} = if closed then {(r[1]+r[2]*epsR)*s,(r[1]*epsG+r[2])*s} else {(r[1]*epsR+r[2])*s,(r[1]+r[2]*epsG)*s};
else
t0 = 0;
r = {1,0};
{v,i} = if closed then {epsR*s,s} else {s,epsG*s};
end if;
end ForcedSwitch;
model ForcedCommSwitch "Forced commuting switch, 3-phase dq0"
extends Ports.PortBase;
extends PowerSystems.Common.Nominal.NominalVI;
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter Real[2] eps(final min={0,0}, each unit="1")={1e-4,1e-4}
"{resistance 'closed', conductance 'open'}";
parameter SI.Time t_relax=10e-3 "switch relaxation time";
parameter Integer p_relax(min=2)=4 "power of relaxation exponent";
PS.Voltage[PS.n] v_t;
PS.Voltage[PS.n] v_f;
PS.Current[PS.n] i_t;
PS.Current[PS.n] i_f;
Ports.ACdq0_p term_p "positive terminal"
Ports.ACdq0_n term_nt "negative terminal 'true'"
Ports.ACdq0_n term_nf "negative terminal 'false'"
Modelica.Blocks.Interfaces.BooleanInput control
"true: p - nt closed, false: p - nf closed"
protected
outer System system;
final parameter SI.Resistance epsR=eps[1]*V_nom/I_nom;
final parameter SI.Conductance epsG=eps[2]*I_nom/V_nom;
SI.Time t0(start=-Modelica.Constants.inf);
Real[2] r(start={0,1});
Real[PS.n] s_t;
Real[PS.n] s_f;
/*
Boolean open_t(start=not control)=not control;
Boolean closed_t(start=control)=control;
Start values not correct, since no parameter expressions.
Removed start values and initalized the pre(..) values in the
initial equation section.
*/
Boolean open_t = not control;
Boolean closed_t = control;
function relaxation=PowerSystems.Utilities.Math.relaxation;
initial equation
pre(open_t) = not control;
pre(closed_t) = control;
if dynType <> Types.Dynamics.SteadyState then
t0 = -Modelica.Constants.inf;
end if;
equation
Connections.branch(term_p.theta, term_nt.theta);
Connections.branch(term_p.theta, term_nf.theta);
term_nt.theta = term_p.theta;
term_nf.theta = term_p.theta;
v_t = term_p.v - term_nt.v;
v_f = term_p.v - term_nf.v;
term_nt.i = -i_t;
term_nf.i = -i_f;
term_p.i + term_nt.i + term_nf.i = zeros(PS.n);
if dynType <> Types.Dynamics.SteadyState then
when edge(open_t) or edge(closed_t) then
t0 = time;
end when;
r = relaxation(time - t0, t_relax, p_relax);
{v_t,i_t} = if closed_t then {(r[1]+r[2]*epsR)*s_t,(r[1]*epsG+r[2])*s_t} else {(r[1]*epsR+r[2])*s_t,(r[1]+r[2]*epsG)*s_t};
{v_f,i_f} = if open_t then {(r[1]+r[2]*epsR)*s_f,(r[1]*epsG+r[2])*s_f} else {(r[1]*epsR+r[2])*s_f,(r[1]+r[2]*epsG)*s_f};
else
t0 = 0;
r = {1,0};
{v_t,i_t} = if control then {epsR*s_t,s_t} else {s_t,epsG*s_t};
{v_f,i_f} = if not control then {epsR*s_f,s_f} else {s_f,epsG*s_f};
end if;
end ForcedCommSwitch;
model Switch "Ideal switch, 3-phase dq0"
extends Partials.SwitchSinglePhaseBase;
protected
Common.Switching.Switch switch_a(
epsR=epsR,
epsG=epsG)
Common.Switching.Switch switch_b(
epsR=epsR,
epsG=epsG)
Common.Switching.Switch switch_c(
epsR=epsR,
epsG=epsG)
equation
switch_a.v=v_abc[1];
switch_a.i=i_abc[1];
switch_b.v=v_abc[2];
switch_b.i=i_abc[2];
switch_c.v=v_abc[3];
switch_c.i=i_abc[3];
connect(control[1], switch_a.closed)
connect(control[2], switch_b.closed)
connect(control[3], switch_c.closed)
end Switch;
model Breaker "Breaker, 3-phase dq0"
extends Partials.SwitchSinglePhaseBase;
replaceable parameter Parameters.BreakerArc par "breaker parameter"
protected
replaceable Common.Switching.Breaker breaker_a(
D=par.D,
t_opening=par.t_opening,
Earc=par.Earc,
R0=par.R0,
epsR=epsR,
epsG=epsG)
replaceable Common.Switching.Breaker breaker_b(
D=par.D,
t_opening=par.t_opening,
Earc=par.Earc,
R0=par.R0,
epsR=epsR,
epsG=epsG)
replaceable Common.Switching.Breaker breaker_c(
D=par.D,
t_opening=par.t_opening,
Earc=par.Earc,
R0=par.R0,
epsR=epsR,
epsG=epsG)
equation
breaker_a.v=v_abc[1];
breaker_a.i=i_abc[1];
breaker_b.v=v_abc[2];
breaker_b.i=i_abc[2];
breaker_c.v=v_abc[3];
breaker_c.i=i_abc[3];
connect(control[1], breaker_a.closed)
connect(control[2], breaker_b.closed)
connect(control[3], breaker_c.closed)
end Breaker;
package Partials "Partial models"
extends Modelica.Icons.MaterialPropertiesPackage;
partial model SwitchBase "Switch base, 3-phase dq0"
extends Ports.Port_pn;
extends PowerSystems.Common.Nominal.NominalVI;
parameter Integer n=3 "number of independent switches";
parameter Real[2] eps(final min={0,0}, each unit="1")={1e-4,1e-4}
"{resistance 'closed', conductance 'open'}";
PS.Voltage[PS.n] v;
PS.Current[PS.n] i;
Modelica.Blocks.Interfaces.BooleanInput[n] control
"true:closed, false:open"
protected
final parameter SI.Resistance epsR=eps[1]*V_nom/I_nom;
final parameter SI.Conductance epsG=eps[2]*I_nom/V_nom;
equation
v = term_p.v - term_n.v;
term_p.i = i;
end SwitchBase;
partial model SwitchSinglePhaseBase
"Switch base, additional abc-variables for single-phase switching"
extends SwitchBase(final n=3);
PS.Voltage[3] v_abc(each stateSelect=StateSelect.never)
"voltage switch a, b, c";
PS.Current[3] i_abc(each stateSelect=StateSelect.never)
"current switch a, b, c";
protected
Real[3,3] Park=PowerSystems.Utilities.Transforms.park(term_p.theta[2]);
equation
v = Park*v_abc;
i_abc = transpose(Park)*i;
/*
Loop not solvable for this version:
static = not (switch_a.arc or switch_b.arc or switch_c.arc); //Switch
static = not (breaker_a.arc or breaker_b.arc or breaker_c.arc); //Breaker
if static then
v_abc = {0,0,0} "v_abc not needed";
i_abc = {0,0,0} "i_abc not needed)";
else
v = Park*v_abc;
i_abc = transpose(Park)*i;
end if;
*/
/*
Initial equation needed, if the equation
der(i_abc) = transpose(Park)*(der(i) + omega[2]*j_dq0(i));
is used:
initial equation
i_abc = transpose(Park)*i;
*/
end SwitchSinglePhaseBase;
end Partials;
package Parameters "Parameter data for interactive use"
extends Modelica.Icons.BasesPackage;
record BreakerArc "Breaker parameters, 3-phase"
extends Modelica.Icons.Record;
SI.Distance D=50e-3 "contact distance open"
SI.Time t_opening=30e-3 "opening duration"
SI.ElectricFieldStrength Earc=50e3 "electric field arc"
Real R0=1 "small signal resistance arc"
end BreakerArc;
end Parameters;
end Breakers; |
AC-drives dq0 | within PowerSystems.AC3ph;
package Drives "AC-drives dq0"
extends Modelica.Icons.VariantsPackage;
model ASM "Asynchronous machine with cage rotor"
extends Partials.DriveBase(rotor(w(start=w_start)));
replaceable model Motor = PowerSystems.AC3ph.Machines.Asynchron
"asyn motor"
Motor motor "asyn motor"
equation
connect(motor.heat, heat)
connect(motor.airgap, rotor.rotor)
connect(term, motor.term)
end ASM;
model ASM_Y_D "Asynchronous machine with cage rotor, Y-Delta switcheable"
extends Partials.DriveBase;
replaceable model Motor = PowerSystems.AC3ph.Machines.AsynchronY_D
"asyn motor Y-Delta switcheable"
Motor motor "asyn motor Y-Delta switcheable"
input Modelica.Blocks.Interfaces.BooleanInput YDcontrol
"true:Y, false:Delta"
equation
connect(YDcontrol, motor.YDcontrol)
connect(motor.heat, heat)
connect(motor.airgap, rotor.rotor)
connect(term, motor.term)
end ASM_Y_D;
model ASM_ctrl "Asynchronous machine, current-control"
extends Partials.DriveBase_ctrl(heat_adapt(final m={2,inverter.heat.m}));
replaceable model Inverter = PowerSystems.AC3ph.Inverters.InverterAverage
constrainedby PowerSystems.AC3ph.Inverters.Partials.AC_DC_base
"inverter (average or modulated)"
Inverter inverter "inverter (average or modulated)"
replaceable model Motor = PowerSystems.AC3ph.Machines.Asynchron_ctrl
"asyn motor, current controlled"
Motor motor "asyn motor, current controlled"
equation
connect(motor.airgap, rotor.rotor)
connect(term, inverter.DC)
connect(inverter.AC, motor.term)
connect(motor.heat, heat_adapt.port_a)
connect(inverter.heat, heat_adapt.port_b)
connect(motor.vPhasor,inverter.vPhasor)
connect(motor.i_meas, i_meas)
connect(i_act, motor.i_act)
connect(motor.phiRotorflux, inverter.theta)
end ASM_ctrl;
model SM_el "Synchronous machine, electric excitation"
extends Partials.DriveBase;
replaceable model Excitation =
PowerSystems.AC3ph.Machines.Control.Excitation "excitation model"
Excitation excitation "excitation model"
replaceable model Motor = PowerSystems.AC3ph.Machines.Synchron3rd_ee
"syn motor"
Motor motor "syn motor"
Modelica.Blocks.Interfaces.RealInput fieldVoltage(final unit="1")
"field voltage pu from exciter control"
Modelica.Blocks.Interfaces.RealOutput[3] termVoltage(final unit="1")
"terminal voltage pu to exciter control"
equation
connect(fieldVoltage, excitation.fieldVoltage)
connect(excitation.term, motor.term)
connect(excitation.field, motor.field)
connect(term, motor.term)
connect(motor.airgap, rotor.rotor)
connect(motor.heat, heat)
connect(excitation.termVoltage, termVoltage)
end SM_el;
model SM_ctrl "Synchronous machine, current-control"
extends Partials.DriveBase_ctrl(heat_adapt(final m={2,inverter.heat.m}));
replaceable model Inverter = PowerSystems.AC3ph.Inverters.InverterAverage
constrainedby PowerSystems.AC3ph.Inverters.Partials.AC_DC_base
"inverter (average or modulated)"
Inverter inverter "inverter (average or modulated)"
replaceable model Motor = PowerSystems.AC3ph.Machines.Synchron3rd_pm_ctrl
"syn motor, current controlled"
Motor motor "syn motor, current controlled"
equation
connect(motor.airgap, rotor.rotor)
connect(term, inverter.DC)
connect(inverter.AC, motor.term)
connect(motor.heat, heat_adapt.port_a)
connect(inverter.heat, heat_adapt.port_b)
connect(motor.phiRotor, inverter.theta)
connect(motor.vPhasor,inverter.vPhasor)
connect(motor.i_meas, i_meas)
connect(i_act, motor.i_act)
end SM_ctrl;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model DriveBase0 "AC drives base mechanical"
parameter SI.AngularVelocity w_start=0
"initial rpm (start-value if steady init)"
Interfaces.Rotation_n flange "mechanical flange"
replaceable model Rotor = PowerSystems.Mechanics.Rotational.ElectricRotor
"machine rotor"
Rotor rotor(w_start=w_start) "machine rotor"
replaceable model Gear = PowerSystems.Mechanics.Rotational.NoGear
"type of gear"
Gear gear "type of gear"
Interfaces.ThermalV_n heat(m=2)
"heat source port {stator, rotor}"
protected
outer System system;
equation
connect(rotor.flange_b,gear.flange_a)
connect(gear.flange_b, flange)
end DriveBase0;
partial model DriveBase "AC drives base"
extends DriveBase0;
AC3ph.Ports.ACdq0_p term "electric terminal"
end DriveBase;
partial model DriveBase_ctrl "AC drives base control"
extends DriveBase0(heat(final m=sum(heat_adapt.m)));
AC1ph_DC.Ports.TwoPin_p term "electric terminal DC"
Modelica.Blocks.Interfaces.RealOutput[2] i_meas(each final unit="1")
"measured current {i_d, i_q} pu"
Modelica.Blocks.Interfaces.RealInput[2] i_act(each final unit="1")
"actuated current {i_d, i_q} pu"
protected
Common.Thermal.HeatV_a_b_ab heat_adapt
equation
connect(heat_adapt.port_ab, heat)
end DriveBase_ctrl;
end Partials;
end Drives; |
Line-faults | within PowerSystems.AC3ph;
package Faults "Line-faults "
extends Modelica.Icons.VariantsPackage;
model Short_ABC "a, b, c to ground short, 3-phase dq0"
extends Partials.FaultBase;
Real[3] s;
equation
v_pos = v_abc[n_phRef] > 0;
{v,i} = if on then {epsR*s,s} else {s,epsG*s};
end Short_ABC;
model Fault_bc "b to c fault, 3-phase dq0"
extends Partials.Fault_pp(final n_ph=1);
end Fault_bc;
model Fault_ca "c to a fault, 3-phase dq0"
extends Partials.Fault_pp(final n_ph=2);
end Fault_ca;
model Fault_ab "a to b fault, 3-phase dq0"
extends Partials.Fault_pp(final n_ph=3);
end Fault_ab;
model Fault_abc "a to b to c fault, 3-phase dq0"
extends Partials.FaultBase;
parameter Integer n_ph=1 "double connected phase, 2=(1-2,2-3)";
replaceable Common.Switching.Short fault_pp1(
final on=on,
final epsR=epsR,
final epsG=epsG) "fault model"
replaceable Common.Switching.Short fault_pp2(
final on=on,
final epsR=epsR,
final epsG=epsG) "fault model"
protected
final parameter Integer[2] m_ph=pair[n_ph, :];
equation
fault_pp1.v = v_abc[m_ph[1]] - v_abc[n_ph];
fault_pp1.i = i_abc[m_ph[1]];
fault_pp2.v = v_abc[m_ph[2]] - v_abc[n_ph];
fault_pp2.i = i_abc[m_ph[2]];
v_pos = v_abc[n_phRef] > 0;
i[3] = epsG*v[3];
// sum(i_abc) = epsG*sum(v_abc);
end Fault_abc;
model Fault_A "a to ground fault, 3-phase dq0"
extends Partials.Fault_pg(final n_ph=1);
end Fault_A;
model Fault_B "b to ground fault, 3-phase dq0"
extends Partials.Fault_pg(final n_ph=2);
end Fault_B;
model Fault_C "c to ground fault, 3-phase dq0"
extends Partials.Fault_pg(final n_ph=3);
end Fault_C;
model Fault_bC "b to c to ground fault, 3-phase dq0"
extends Partials.Fault_ppg(final n_ph=1);
end Fault_bC;
model Fault_cA "c to a to ground fault, 3-phase dq0"
extends Partials.Fault_ppg(final n_ph=2);
end Fault_cA;
model Fault_aB "a to b to ground fault, 3-phase dq0"
extends Partials.Fault_ppg(final n_ph=3);
end Fault_aB;
model Fault_Abc "b to a, c to a, a to ground fault, 3-phase dq0"
extends Partials.Fault_pppg(final n_ph=1);
end Fault_Abc;
model Fault_aBc "a to b, c to b, b to ground fault, 3-phase dq0"
extends Partials.Fault_pppg(final n_ph=2);
end Fault_aBc;
model Fault_abC "a to c, b to c, c to ground fault, 3-phase dq0"
extends Partials.Fault_pppg(final n_ph=3);
end Fault_abC;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model FaultBase "Line fault base, 3-phase dq0"
extends Ports.Port_f;
parameter SI.Time t_on=0.1 "approx time fault on";
parameter SI.Angle phi_on(min=0)=0 "voltage phase angle fault on";
parameter Integer n_phRef(min=1,max=3)=1 "of reference phase"
parameter SI.Resistance epsR=1e-4 "resistance 'fault'";
parameter SI.Conductance epsG=1e-4 "conductance 'no fault'";
parameter PS.Voltage[3] v_abc_start = zeros(3)
"start value of voltage phase a, b, c"
PS.Voltage[3] v "voltage";
PS.Current[3] i "current";
PS.Voltage[3] v_abc(each stateSelect=StateSelect.never, start = v_abc_start)
"voltage phase a, b, c";
PS.Current[3] i_abc(each stateSelect=StateSelect.never)
"current phase a, b, c";
protected
constant Integer[3, 2] pair=[2, 3; 3, 1; 1, 2];
discrete SI.Angle theta_zero(start=Modelica.Constants.inf, fixed=true);
Boolean on(final start=false, fixed=true);
Boolean v_pos(start=true, fixed=true);
Boolean first(start=true, fixed=true);
Real[3,3] Park=Utilities.Transforms.park(term.theta[2]);
equation
v = term.v;
term.i = i;
v = Park*v_abc;
i_abc = transpose(Park)*i;
when time > t_on and edge(v_pos) and pre(first) then
theta_zero = sum(term.theta);
first = false;
end when;
on = sum(term.theta) > pre(theta_zero) + phi_on;
end FaultBase;
partial model Fault_pp "Two-phase fault, 3-phase dq0"
extends FaultBase(final n_phRef=n_ph);
parameter Integer n_ph(min=1,max=3)=1 "faulted pair"
replaceable Common.Switching.Short fault_pp(
final on=on,
final epsR=epsR,
final epsG=epsG) "fault model"
//extends Common.Switching.Partials.FaultBase
protected
final parameter Integer[2] m_ph=pair[n_ph, :];
equation
fault_pp.v=v_abc[m_ph[1]] - v_abc[m_ph[2]];
fault_pp.i=i_abc[m_ph[1]];
v_pos = v_abc[m_ph[1]] - v_abc[m_ph[2]] > 0;
i_abc[n_ph] = epsG*v_abc[n_ph];
sum(i_abc[m_ph]) = epsG*sum(v_abc[m_ph]);
end Fault_pp;
partial model Fault_pg "One-phase to ground fault, 3-phase dq0"
extends FaultBase(final n_phRef=n_ph);
parameter Integer n_ph(min=1,max=3)=1 "faulted phase"
replaceable Common.Switching.Short fault_pg(
final on=on,
final epsR=epsR,
final epsG=epsG) "fault model"
// extends Common.Switching.Partials.FaultBase
protected
final parameter Integer[2] m_ph=pair[n_ph, :];
equation
fault_pg.v=v_abc[n_ph];
fault_pg.i=i_abc[n_ph];
v_pos = v_abc[n_phRef] > 0;
i_abc[m_ph] = epsG*v_abc[m_ph];
end Fault_pg;
partial model Fault_ppg "Two-phase to ground fault, 3-phase dq0"
extends FaultBase(final n_phRef=n_ph);
parameter Integer n_ph(min=1,max=3)=1 "faulted pair"
replaceable Common.Switching.Short fault_pp(
final on=on,
final epsR=epsR,
final epsG=epsG) "fault model"
// extends Common.Switching.Partials.FaultBase
replaceable Common.Switching.Short fault_pg(
final on=on,
final epsR=epsR,
final epsG=epsG) "fault model"
// extends Common.Switching.Partials.FaultBase
protected
final parameter Integer[2] m_ph=pair[n_ph, :];
equation
fault_pp.v=v_abc[m_ph[1]] - v_abc[m_ph[2]];
fault_pp.i=i_abc[m_ph[1]];
fault_pg.v=v_abc[m_ph[2]];
fault_pg.i=sum(i_abc[m_ph]);
v_pos = v_abc[m_ph[1]] - v_abc[m_ph[2]] > 0;
i_abc[n_ph] = epsG*v_abc[n_ph];
end Fault_ppg;
partial model Fault_pppg "Three-phase to ground fault, 3-phase dq0"
extends FaultBase;
parameter Integer n_ph(min=1,max=3)=1 "which phase to ground"
replaceable Common.Switching.Short fault_pp1(
final on=on,
final epsR=epsR,
final epsG=epsG) "fault model"
// extends Common.Switching.Partials.FaultBase
replaceable Common.Switching.Short fault_pp2(
final on=on,
final epsR=epsR,
final epsG=epsG) "fault model"
// extends Common.Switching.Partials.FaultBase
replaceable Common.Switching.Short fault_pg(
final on=on,
final epsR=epsR,
final epsG=epsG) "fault model"
// extends Common.Switching.Partials.FaultBase
protected
final parameter Integer[2] m_ph=pair[n_ph, :];
equation
fault_pp1.v=v_abc[m_ph[1]] - v_abc[n_ph];
fault_pp1.i=i_abc[m_ph[1]];
fault_pp2.v=v_abc[m_ph[2]] - v_abc[n_ph];
fault_pp2.i=i_abc[m_ph[2]];
fault_pg.v = v_abc[n_ph];
fault_pg.i = sum(i_abc);
v_pos = v_abc[n_ph] > 0;
end Fault_pppg;
end Partials;
end Faults; |
Turbo generator groups dq0 | within PowerSystems.AC3ph;
package Generation "Turbo generator groups dq0"
extends Modelica.Icons.VariantsPackage;
model TurboGenerator "Turbo generator single mass"
extends Partials.GenBase_el;
replaceable model Rotor = PowerSystems.Mechanics.TurboGroups.SingleMassTG (
final w_start=w_start,
final H=H,
final P_nom=generator.par.S_nom,
final w_nom=w_nom) "single-mass rotor (turbine-rotor + generator-rotor)"
Rotor rotor "single-mass rotor (turbine-rotor + generator-rotor)"
equation
connect(rotor.airgap, generator.airgap)
connect(rotor.speed, governor.speed)
connect(governor.power, rotor.power)
end TurboGenerator;
model TurboGrpGenerator "Example turbogroup generator"
extends Partials.GenBase_el(final H=h);
replaceable model Torque =
PowerSystems.Mechanics.TurboGroups.PcontrolTorque (
final w_nom=turboGroup.par.w_nom, final P_nom=turboGroup.par.P_nom)
"torque-model"
Torque turbTorq "torque-model"
replaceable model TurboGroup =
PowerSystems.Mechanics.TurboGroups.SteamTurboGroup (
final w_start=w_start) "steam turbo-goup with generator-rotor"
TurboGroup turboGroup "steam turbo-goup with generator-rotor"
protected
final parameter SI.Time h=(sum(turboGroup.par.J_turb) +
turboGroup.par.J_gen + sum(turboGroup.par.J_aux))*w_nom^2/(2
*generator.par.S_nom) "inertia cst turb + gen";
equation
connect(turbTorq.blades, turboGroup.blades)
connect(turboGroup.airgap, generator.airgap)
connect(turbTorq.speed, governor.speed)
connect(governor.power, turbTorq.power)
end TurboGrpGenerator;
model GTGenerator "Example gas turbine generator"
extends Partials.GenBase_el(final H=h);
replaceable model Torque =
PowerSystems.Mechanics.TurboGroups.PcontrolTorque (
final w_nom=GT.par.w_nom, final P_nom=GT.par.P_nom) "torque-model"
Torque turbTorq "torque-model"
replaceable model Gear =
PowerSystems.Mechanics.TurboGroups.GasTurbineGear(final w_start=w_start)
"gas turbine with gear and generator-rotor"
Gear GT "gas turbine with gear and generator-rotor"
protected
final parameter Real[3] gr2=diagonal(GT.par.ratio)*GT.par.ratio/GT.par.ratio[end]^2;
final parameter SI.Inertia J_red=(GT.par.J_turb + GT.par.J_comp)
*gr2[1] + GT.par.J_gear1*gr2[1:2] + GT.par.J_gear2*gr2[2:3] + (GT.par.J_acc
+ GT.par.J_cpl + GT.par.J_gen) "gear reduced inertia";
final parameter SI.Time h=J_red*w_nom^2/(2*generator.par.S_nom);
equation
assert(abs(2*pi*generator.par.f_nom/(generator.par.pp*GT.par.w_nom) - 1) < 1e-3,
"nominal rpm, frequency and pole-pair number seems to be incompatible");
connect(turbTorq.blades, GT.blades)
connect(GT.airgap, generator.airgap)
connect(turbTorq.speed, governor.speed)
connect(governor.power, turbTorq.power)
end GTGenerator;
model HydroGenerator "Hydro generator"
extends Partials.GenBase_el(final H=h);
replaceable model Torque =
PowerSystems.Mechanics.TurboGroups.PcontrolTorque (
final w_nom=hydro.par.w_nom, final P_nom={hydro.par.P_nom})
"torque-model"
Torque turbTorq "torque-model"
replaceable model HydroTurbine =
PowerSystems.Mechanics.TurboGroups.HydroTurbine(final w_start=w_start)
"hydro turbine with generator-rotor"
HydroTurbine hydro "hydro turbine with generator-rotor"
protected
final parameter SI.Time h=(hydro.par.J_turb + hydro.par.J_gen)
*w_nom^2/(2*generator.par.S_nom);
equation
assert(abs(2*pi*generator.par.f_nom/(generator.par.pp*hydro.par.w_nom) - 1) < 1e-3,
"nominal rpm, frequency and pole-pair number seems to be incompatible");
connect(turbTorq.blades, hydro.blades)
connect(hydro.airgap, generator.airgap)
connect(turbTorq.speed, governor.speed)
connect(governor.power, turbTorq.power)
end HydroGenerator;
model DieselGenerator "Diesel generator"
extends Partials.GenBase_el(final H=h);
replaceable model Torque =
PowerSystems.Mechanics.TurboGroups.PcontrolTorque (
final w_nom=diesel.par.w_nom, final P_nom={diesel.par.P_nom})
"torque-model"
Torque turbTorq "torque-model"
replaceable model Diesel = PowerSystems.Mechanics.TurboGroups.Diesel (
final w_start=w_start) "Diesel engine with generator-rotor"
Diesel diesel "Diesel engine with generator-rotor"
protected
final parameter SI.Time h=(diesel.par.J_turb + diesel.par.J_gen)
*w_nom^2/(2*generator.par.S_nom);
equation
assert(abs(2*pi*generator.par.f_nom/(generator.par.pp*diesel.par.w_nom) - 1) < 1e-3,
"nominal rpm, frequency and pole-pair number seems to be incompatible");
connect(turbTorq.blades, diesel.blades)
connect(diesel.airgap, generator.airgap)
connect(turbTorq.speed, governor.speed)
connect(governor.power, turbTorq.power)
end DieselGenerator;
model TurboPMgenerator "Turbo generator single mass, permanent magnet"
extends Partials.GenBase;
parameter SI.AngularVelocity w_start=2*pi*generator.par.f_nom/generator.par.pp
"initial angular velocity (start-value if ini='st')";
AC3ph.Ports.ACdq0_n term "negative terminal"
Modelica.Blocks.Interfaces.RealInput[2] setpts
"setpoints {speed, power} pu"
Modelica.Blocks.Interfaces.RealOutput phiRotor "rotor angle el"
replaceable model Generator = PowerSystems.AC3ph.Machines.Synchron3rd_pm
"synchron pm generator"
Generator generator "synchron pm generator"
replaceable model Governor = PowerSystems.Control.Governors.GovernorConst
"governor (control)"
Governor governor "governor (control)"
parameter SI.Time H=10 "inertia cst turb + gen";
replaceable model Rotor = PowerSystems.Mechanics.TurboGroups.SingleMassTG (
final w_start=w_start,
final H=H,
final P_nom=generator.par.S_nom,
final w_nom=w_nom) "single-mass rotor (turbine-rotor + generator-rotor)"
Rotor rotor "single-mass rotor (turbine-rotor + generator-rotor)"
protected
final parameter SI.AngularVelocity w_nom=2*pi*generator.par.f_nom/generator.par.pp
"nominal angular velocity";
equation
connect(setpts[1], governor.setptSpeed)
connect(setpts[2], governor.setptPower)
connect(rotor.speed, governor.speed)
connect(governor.power, rotor.power)
connect(rotor.airgap, generator.airgap)
connect(generator.heat, heat)
connect(generator.term, term)
connect(generator.phiRotor, phiRotor)
end TurboPMgenerator;
model PMgenerator "Generator inverter time-average"
extends Partials.GenBase_ctrl(heat_adapt(final m={2,inverter.heat.m}));
replaceable model Generator =
PowerSystems.AC3ph.Machines.Synchron3rd_pm_ctrl
"synchron pm generator"
Generator generator "synchron pm generator"
replaceable model Inverter = PowerSystems.AC3ph.Inverters.InverterAverage
constrainedby PowerSystems.AC3ph.Inverters.Partials.AC_DC_base
"inverter (average or modulated)"
Inverter inverter "inverter (average or modulated)"
equation
connect(rotor.flange_b, generator.airgap)
connect(generator.term, inverter.AC)
connect(inverter.DC, term)
connect(generator.heat, heat_adapt.port_a)
connect(inverter.heat, heat_adapt.port_b)
connect(generator.phiRotor, inverter.theta)
connect(generator.vPhasor,inverter.vPhasor)
connect(generator.i_meas, i_meas)
connect(i_act, generator.i_act)
end PMgenerator;
model WindGenerator "Wind generator"
extends Partials.GenBase;
parameter SI.AngularVelocity w_start=2*pi*generator.par.f_nom/generator.par.pp
"initial angular velocity (start-value if ini='st')"
AC3ph.Ports.ACdq0_n term "negative terminal"
replaceable model Generator = PowerSystems.AC3ph.Machines.Asynchron
"asynchron generator"
Generator generator "asynchron generator"
replaceable model Torque = PowerSystems.Mechanics.TurboGroups.WindTabTorque
(
final w_nom=WT.par.w_nom, final P_nom=WT.par.P_nom)
"table: wind speed, torque"
Torque turbTorq "table: wind speed, torque"
replaceable model Gear =
PowerSystems.Mechanics.TurboGroups.WindTurbineGear(final w_start= w_start)
"wind turbine with generator-rotor"
Gear WT "wind turbine with generator-rotor"
Modelica.Blocks.Interfaces.RealInput windSpeed "wind speed m/s"
equation
connect(windSpeed, turbTorq.windSpeed)
connect(turbTorq.blades, WT.blades[1])
connect(WT.airgap, generator.airgap)
connect(generator.term, term)
connect(generator.heat, heat)
end WindGenerator;
package Partials "Partial models"
partial model GenBase0 "Generation base"
Interfaces.ThermalV_n heat(m=2) "heat source port {stator, rotor}"
protected
outer System system;
end GenBase0;
extends Modelica.Icons.BasesPackage;
partial model GenBase "Generation base"
extends GenBase0;
AC3ph.Ports.ACdq0_n term "negative terminal"
end GenBase;
partial model GenBase_el "Generation base el, synchron machines"
extends GenBase;
parameter SI.AngularVelocity w_start=2*pi*generator.par.f_nom/generator.par.pp
"initial angular velocity (start-value if steady-state)"
parameter Types.Init initType=PowerSystems.Types.Init.v_alpha
"initialisation type (if steady-state)"
parameter SIpu.Voltage v_start(unit="1")=1 "initial terminal voltage"
parameter SI.Angle alpha_start=system.alpha0 "initial voltage phase angle"
parameter SIpu.Power p_start(unit="1")=1 "initial terminal active power"
parameter SIpu.Power q_start(unit="1")=1 "initial terminal reactive power"
parameter Boolean dispPA=false "display power angle"
AC3ph.Ports.ACdq0_n term "negative terminal"
Modelica.Blocks.Interfaces.RealInput[3] setpts
"setpoints {speed, power, voltage} pu"
replaceable model Generator = PowerSystems.AC3ph.Machines.Synchron3rd_ee
"synchron generator"
Generator generator "synchron generator"
replaceable model Exciter = Control.Exciters.ExciterConst
"exciter (control)"
Exciter exciter "exciter (control)"
replaceable model Excitation =
PowerSystems.AC3ph.Machines.Control.Excitation (
V_nom = generator.par.V_nom, Vf_nom = generator.Vf_nom)
"exciter (electric)"
Excitation excitation "exciter (electric)"
replaceable model Governor = PowerSystems.Control.Governors.GovernorConst
"governor (control)"
Governor governor "governor (control)"
parameter SI.Time H=10 "inertia cst turb + gen";
protected
final parameter SI.AngularVelocity w_nom=2*pi*generator.par.f_nom/generator.par.pp
"nominal angular velocity";
Interfaces.Sender sender(w=generator.w_el, H=H)
"sends weighted frequency"
function atan2 = Modelica.Math.atan2;
initial equation
if initType == PowerSystems.Types.Init.v_alpha then
sqrt(term.v[1:2]*term.v[1:2]) = v_start*generator.par.V_nom;
atan2(term.v[2], term.v[1]) = alpha_start;
elseif initType == PowerSystems.Types.Init.v_p then
sqrt(term.v[1:2]*term.v[1:2]) = v_start*generator.par.V_nom;
-term.v[1:2]*term.i[1:2] = p_start*generator.par.S_nom;
elseif initType == PowerSystems.Types.Init.v_q then
sqrt(term.v[1:2]*term.v[1:2]) = v_start*generator.par.V_nom;
-{term.v[2],-term.v[1]}*term.i[1:2] = q_start*generator.par.S_nom;
elseif initType == PowerSystems.Types.Init.p_q then
-term.v[1:2]*term.i[1:2] = p_start*generator.par.S_nom;
-{term.v[2],-term.v[1]}*term.i[1:2] = q_start*generator.par.S_nom;
end if;
equation
if initType == PowerSystems.Types.Init.v_alpha then
Connections.potentialRoot(term.theta);
end if;
if Connections.isRoot(term.theta) then
term.theta = if system.synRef then {0, system.theta} else {system.theta, 0};
end if;
connect(sender.sendFreq, system.receiveFreq);
connect(term, generator.term)
connect(exciter.fieldVoltage,excitation.fieldVoltage)
connect(excitation.termVoltage, exciter.termVoltage)
connect(setpts[1], governor.setptSpeed)
connect(setpts[2], governor.setptPower)
connect(setpts[3], exciter.setptVoltage)
connect(generator.term, excitation.term)
connect(excitation.field, generator.field)
connect(generator.heat, heat)
end GenBase_el;
partial model GenBase_ctrl "Generation base pm, synchronous machines"
extends GenBase0(heat(final m=sum(heat_adapt.m)));
parameter SI.AngularVelocity w_start=0
"initial rpm (start-value if steady init)"
Interfaces.Rotation_p flange
AC1ph_DC.Ports.TwoPin_n term "negative terminal"
Common.Thermal.HeatV_a_b_ab heat_adapt
replaceable model Gear = PowerSystems.Mechanics.Rotational.NoGear
"type of gear"
Gear gear "type of gear"
replaceable model Rotor = PowerSystems.Mechanics.Rotational.Rotor (
w(start=w_start)) "rotor generator"
Rotor rotor "rotor generator"
Modelica.Blocks.Interfaces.RealOutput[2] i_meas(each final unit="1")
"measured current {i_d, i_q} pu"
Modelica.Blocks.Interfaces.RealInput[2] i_act(each final unit="1")
"actuated current {i_d, i_q} pu"
equation
connect(heat_adapt.port_ab, heat)
connect(flange,gear.flange_a)
connect(gear.flange_b,rotor.flange_a)
end GenBase_ctrl;
end Partials;
end Generation; |
Impedance and admittance two terminal | within PowerSystems.AC3ph;
package Impedances "Impedance and admittance two terminal"
extends Modelica.Icons.VariantsPackage;
model Resistor "Resistor, 3-phase dq0"
extends Partials.ImpedBase(final f_nom=0, final dynType=Types.Dynamics.SteadyState);
parameter SIpu.Resistance r=1 "resistance";
protected
final parameter SI.Resistance R=r*Utilities.Precalculation.baseR(
puUnits,
V_nom,
S_nom);
equation
R*i = v;
end Resistor;
model Conductor "Conductor, 3-phase dq0"
extends Partials.ImpedBase(final f_nom=0, final dynType=Types.Dynamics.SteadyState);
parameter SIpu.Conductance g=1 "conductance";
protected
final parameter SI.Conductance G=g/Utilities.Precalculation.baseR(
puUnits,
V_nom,
S_nom);
equation
G*v = i;
end Conductor;
model Inductor "Inductor with series resistor, 3-phase dq0"
extends Partials.ImpedBase;
parameter SIpu.Resistance r=0 "resistance";
parameter SIpu.Reactance x_s=1 "self reactance";
parameter SIpu.Reactance x_m=0 "mutual reactance, -x_s/2 < x_m < x_s";
protected
final parameter Real[2] RL_base=Utilities.Precalculation.baseRL(
puUnits,
V_nom,
S_nom,
2*pi*f_nom);
final parameter SI.Resistance R=r*RL_base[1];
final parameter SI.Inductance L=(x_s-x_m)*RL_base[2];
final parameter SI.Inductance L0=(x_s+2*x_m)*RL_base[2];
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i) = omega[1]*j(i);
elseif dynType == Types.Dynamics.FixedInitial then
i = i_start;
end if;
equation
if dynType <> Types.Dynamics.SteadyState then
PS.map({L,L,L0}).*der(i) + omega[2]*L*j(i) + R*i = v;
else
omega[2]*L*j(i) + R*i = v;
end if;
end Inductor;
model Capacitor "Capacitor with parallel conductor, 3-phase dq0"
extends Partials.ImpedBase;
parameter SIpu.Conductance g=0 "conductance";
parameter SIpu.Susceptance b=1 "susceptance";
protected
final parameter SI.Resistance[2] GC_base=Utilities.Precalculation.baseGC(
puUnits,
V_nom,
S_nom,
2*pi*f_nom);
final parameter SI.Conductance G=g*GC_base[1];
final parameter SI.Capacitance C=b*GC_base[2];
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(v) = omega[1]*j(v);
elseif dynType == Types.Dynamics.FixedInitial then
v = v_start;
end if;
equation
if dynType <> Types.Dynamics.SteadyState then
C*der(v) + omega[2]*C*j(v) + G*v = i;
else
omega[2]*C*j(v) + G*v = i;
end if;
end Capacitor;
model Impedance "Impedance (inductive) with series resistor, 3-phase dq0"
extends Partials.ImpedBase;
parameter SIpu.Impedance z_abs=1 "abs value of impedance";
parameter Real cos_phi(min=0,max=1)=0.1 "cos-phi of impedance";
parameter Real cpl(min=-0.5,max=1)=0
"phase coupling x_m/x_s, -1/2 < cpl < 1";
protected
final parameter SI.Resistance[2] RL_base=Utilities.Precalculation.baseRL(
puUnits,
V_nom,
S_nom,
2*pi*f_nom);
function acos = Modelica.Math.acos;
final parameter SI.Resistance R=z_abs*cos_phi*RL_base[1];
final parameter SI.Inductance L=z_abs*sin(acos(cos_phi))*RL_base[2];
final parameter SI.Inductance L0=L*(1 + 2*cpl)/(1-cpl);
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i) = omega[1]*j(i);
elseif dynType == Types.Dynamics.FixedInitial then
i = i_start;
end if;
equation
if dynType <> Types.Dynamics.SteadyState then
PS.map({L,L,L0}).*der(i) + omega[2]*L*j(i) + R*i = v;
else
omega[2]*L*j(i) + R*i = v;
end if;
end Impedance;
model Admittance
"Admittance (capacitive) with parallel conductor, 3-phase dq0"
extends Partials.ImpedBase;
parameter SIpu.Admittance y_abs=1 "abs value of admittance";
parameter Real cos_phi(min=0,max=1)=0.1 "cos-phi of admittance";
protected
final parameter SI.Resistance[2] GC_base=Utilities.Precalculation.baseGC(
puUnits,
V_nom,
S_nom,
2*pi*f_nom);
function acos = Modelica.Math.acos;
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 dynType == Types.Dynamics.SteadyInitial then
der(v) = omega[1]*j(v);
elseif dynType == Types.Dynamics.FixedInitial then
v = v_start;
end if;
equation
if dynType <> Types.Dynamics.SteadyState then
C*der(v) + omega[2]*C*j(v) + G*v = i;
else
omega[2]*C*j(v) + G*v = i;
end if;
end Admittance;
model ResistorNonSym "Resistor non symmetric, 3-phase dq0."
extends Partials.ImpedNonSymBase(final f_nom=0, final dynType=Types.Dynamics.SteadyState);
parameter SIpu.Resistance[3] r={1,1,1} "resistance[3] abc";
protected
final parameter SI.Resistance[3] R_abc=r*Utilities.Precalculation.baseR(
puUnits,
V_nom,
S_nom);
SI.Resistance[3, 3] R;
equation
R = Park*diagonal(R_abc)*transpose(Park);
R*i = v;
end ResistorNonSym;
model InductorNonSym
"Inductor with series resistor non symmetric, 3-phase dq0."
extends Partials.ImpedNonSymBase;
parameter SIpu.Resistance[3] r={0,0,0} "resistance[3] abc";
parameter SIpu.Reactance[3, 3] x=[1, 0, 0; 0, 1, 0; 0, 0, 1]
"reactance[3,3] abc";
SI.MagneticFlux[3] psi(each stateSelect=StateSelect.prefer) "magnetic flux";
protected
final parameter SI.Resistance[2] RL_base=Utilities.Precalculation.baseRL(
puUnits,
V_nom,
S_nom,
2*pi*f_nom);
final parameter SI.Resistance[3] R_abc=r*RL_base[1];
final parameter SI.Inductance[3, 3] L_abc=x*RL_base[2];
SI.Resistance[3, 3] R;
SI.Inductance[3, 3] L;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(psi[1:2]) = omega[1]*j_dq0(psi[1:2]);
psi[3] = 0;
end if;
equation
L = Park*L_abc*transpose(Park);
R = Park*diagonal(R_abc)*transpose(Park);
psi = L*i;
der(psi) + omega[2]*j_dq0(psi) + R*i = v;
end InductorNonSym;
model CapacitorNonSym
"Capacitor with parallel conductor non symmetric, 3-phase dq0."
extends Partials.ImpedNonSymBase;
parameter SIpu.Conductance[3] g={0,0,0} "conductance[3] abc";
parameter SIpu.Susceptance[3] b={1,1,1} "susceptance[3] abc";
SI.ElectricCharge[3] q(each stateSelect=StateSelect.prefer)
"electric charge";
protected
final parameter SI.Resistance[2] GC_base=Utilities.Precalculation.baseGC(
puUnits,
V_nom,
S_nom,
2*pi*f_nom);
final parameter SI.Conductance[3] G_abc=g*GC_base[1];
final parameter SI.Capacitance[3] C_abc=b*GC_base[2];
SI.Conductance[3, 3] G;
SI.Capacitance[3, 3] C;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(q[1:2]) = omega[1]*j_dq0(q[1:2]);
q[3] = 0;
end if;
equation
C = Park*diagonal(C_abc)*transpose(Park);
G = Park*diagonal(G_abc)*transpose(Park);
q = C*v;
der(q) + omega[2]*j_dq0(q) + G*v = i;
end CapacitorNonSym;
model Varistor "Varistor, 3-phase dq0"
extends Partials.ImpedNonSymBase(final f_nom=0, final dynType=Types.Dynamics.SteadyState);
parameter SIpu.Resistance r0=100 "small voltage resistance";
parameter SIpu.Voltage v0=1 "saturation voltage";
PS.Voltage[3] v_abc;
PS.Current[3] i_abc(start=zeros(3));
protected
final parameter Real V0=(v0*Utilities.Precalculation.baseV(puUnits, V_nom));
final parameter Real H0=(r0*Utilities.Precalculation.baseR(
puUnits,
V_nom,
S_nom)/V0);
equation
i_abc = transpose(Park)*i;
v_abc = V0*tanh(H0*i_abc);
v = Park*v_abc;
end Varistor;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model ImpedBase "Impedance base, 3-phase dq0"
extends Ports.Port_pn;
extends Common.Nominal.NominalAC;
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter PS.Voltage[PS.n] v_start = zeros(PS.n)
"start value of voltage drop"
parameter PS.Current[PS.n] i_start = zeros(PS.n)
"start value of current"
PS.Voltage[PS.n] v(start = v_start);
PS.Current[PS.n] i(start = i_start);
protected
SI.AngularFrequency[2] omega;
equation
omega = der(term_p.theta);
v = term_p.v - term_n.v;
i = term_p.i;
end ImpedBase;
partial model ImpedNonSymBase "Impedance base non symmetric, 3-phase dq0."
extends ImpedBase;
protected
Real[3,3] Park=Utilities.Transforms.park(term_p.theta[2]);
end ImpedNonSymBase;
partial model ImpedHeat "Impedance base with heat port, 3-phase dq0"
extends ImpedBase;
extends PowerSystems.Interfaces.AddHeat;
equation
Q_flow = v*i;
end ImpedHeat;
partial model ImpedNonSymHeat
"Impedance base non symmetric with heat port, 3-phase dq0"
extends ImpedNonSymBase;
extends PowerSystems.Interfaces.AddHeatV(final m_heat=3);
PS.Voltage[3] v_abc=Park*v;
PS.Current[3] i_abc=Park*i;
equation
Q_flow = v_abc.*i_abc;
end ImpedNonSymHeat;
end Partials;
end Impedances; |
Impedance and admittance one terminal, Y and Delta topology | within PowerSystems.AC3ph;
package ImpedancesYD
"Impedance and admittance one terminal, Y and Delta topology"
extends Modelica.Icons.VariantsPackage;
model Resistor "Resistor, 3-phase dq0"
extends Partials.ImpedYDBase(final f_nom=0, final dynType=Types.Dynamics.SteadyState);
parameter SIpu.Resistance r=1 "resistance";
protected
final parameter SI.Resistance R=r*Utilities.Precalculation.baseR(
puUnits,
V_nom,
S_nom,
top.scale);
equation
R*i = v;
end Resistor;
model Conductor "Conductor, 3-phase dq0"
extends Partials.ImpedYDBase(final f_nom=0, final dynType=Types.Dynamics.SteadyState);
parameter SIpu.Conductance g=1 "conductance";
protected
final parameter SI.Conductance G=g/Utilities.Precalculation.baseR(
puUnits,
V_nom,
S_nom,
top.scale);
equation
G*v = i;
end Conductor;
model Inductor "Inductor with series resistor, 3-phase dq0"
extends Partials.ImpedYDBase;
parameter SIpu.Resistance r=0 "resistance";
parameter SIpu.Reactance x_s=1 "self reactance";
parameter SIpu.Reactance x_m=0 "mutual reactance, -x_s/2 < x_m < x_s";
protected
final parameter SI.Resistance[2] RL_base=Utilities.Precalculation.baseRL(
puUnits,
V_nom,
S_nom,
2*pi*f_nom,
top.scale);
final parameter SI.Resistance R=r*RL_base[1];
final parameter SI.Inductance L=(x_s-x_m)*RL_base[2];
final parameter SI.Inductance L0=(x_s+2*x_m)*RL_base[2];
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i) = omega[1]*j_dq0(i);
end if;
equation
if dynType <> Types.Dynamics.SteadyState then
diagonal({L,L,L0})*der(i) + omega[2]*L*j_dq0(i) + R*i = v;
else
omega[2]*L*j_dq0(i) + R*i = v;
end if;
end Inductor;
model Capacitor "Capacitor with parallel conductor, 3-phase dq0"
extends Partials.ImpedYDBase;
parameter SIpu.Conductance g=0 "conductance";
parameter SIpu.Susceptance b=1 "susceptance";
protected
final parameter SI.Resistance[2] GC_base=Utilities.Precalculation.baseGC(
puUnits,
V_nom,
S_nom,
2*pi*f_nom,
top.scale);
final parameter SI.Conductance G=g*GC_base[1];
final parameter SI.Capacitance C=b*GC_base[2];
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(v) = omega[1]*j_dq0(v);
end if;
equation
if dynType <> Types.Dynamics.SteadyState then
C*der(v) + omega[2]*C*j_dq0(v) + G*v = i;
else
omega[2]*C*j_dq0(v) + G*v = i;
end if;
end Capacitor;
model ResistorNonSym "Resistor non symmetric, 3-phase dq0"
extends Partials.ImpedYDNonSymBase(final f_nom=0, final dynType=Types.Dynamics.SteadyState);
parameter SIpu.Resistance[3] r={1,1,1} "resistance[3] abc";
protected
final parameter SI.Resistance[3] R_abc=r*Utilities.Precalculation.baseR(
puUnits,
V_nom,
S_nom,
top.scale);
SI.Resistance[3, 3] R;
equation
R = Park*diagonal(R_abc)*transpose(Park);
R*i = v;
end ResistorNonSym;
model InductorNonSym
"Inductor with series resistor non symmetric, 3-phase dq0"
extends Partials.ImpedYDNonSymBase;
parameter SIpu.Resistance[3] r={0,0,0} "resistance[3] abc";
parameter SIpu.Reactance[3, 3] x=[1, 0, 0; 0, 1, 0; 0, 0, 1]
"reactance[3,3] abc";
SI.MagneticFlux[3] psi(each stateSelect=StateSelect.prefer) "magnetic flux";
protected
final parameter SI.Resistance[2] RL_base=Utilities.Precalculation.baseRL(
puUnits,
V_nom,
S_nom,
2*pi*f_nom,
top.scale);
final parameter SI.Resistance[3] R_abc=r*RL_base[1];
final parameter SI.Inductance[3, 3] L_abc=x*RL_base[2];
SI.Resistance[3, 3] R;
SI.Inductance[3, 3] L;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(psi[1:2]) = omega[1]*j_dq0(psi[1:2]);
psi[3] = 0;
end if;
equation
L = Park*L_abc*transpose(Park);
R = Park*diagonal(R_abc)*transpose(Park);
psi = L*i;
der(psi) + omega[2]*j_dq0(psi) + R*i = v;
end InductorNonSym;
model CapacitorNonSym
"Capacitor with parallel conductor non symmetric, 3-phase dq0"
extends Partials.ImpedYDNonSymBase;
parameter SIpu.Conductance[3] g={0,0,0} "conductance[3] abc";
parameter SIpu.Susceptance[3] b={1,1,1} "susceptance[3] abc";
SI.ElectricCharge[3] q(each stateSelect=StateSelect.prefer)
"electric charge";
protected
final parameter SI.Resistance[2] GC_base=Utilities.Precalculation.baseGC(
puUnits,
V_nom,
S_nom,
2*pi*f_nom,
top.scale);
final parameter SI.Conductance[3] G_abc=g*GC_base[1];
final parameter SI.Capacitance[3] C_abc=b*GC_base[2];
SI.Conductance[3, 3] G;
SI.Capacitance[3, 3] C;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(q[1:2]) = omega[1]*j_dq0(q[1:2]);
q[3] = 0;
end if;
equation
C = Park*diagonal(C_abc)*transpose(Park);
G = Park*diagonal(G_abc)*transpose(Park);
q = C*v;
der(q) + omega[2]*j_dq0(q) + G*v = i;
end CapacitorNonSym;
model Varistor "Varistor, 3-phase dq0"
extends Partials.ImpedYDNonSymBase(final f_nom=0, final dynType=Types.Dynamics.SteadyState);
parameter SIpu.Resistance r0=100 "small voltage resistance";
parameter SIpu.Voltage v0=1 "saturation voltage";
PS.Voltage[3] v_abc;
PS.Current[3] i_abc(start=zeros(3));
protected
final parameter Real V0=(v0*Utilities.Precalculation.baseV(puUnits, V_nom));
final parameter Real H0=(r0*Utilities.Precalculation.baseR(
puUnits,
V_nom,
S_nom)/V0);
equation
i_abc = transpose(Park)*i;
v_abc = V0*tanh(H0*i_abc);
v = Park*v_abc;
end Varistor;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model ImpedYDBase "One terminal impedance base, 3-phase dq0"
extends Ports.YDport_p;
extends Common.Nominal.NominalAC;
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter SIpu.Resistance r_n=1 "resistance neutral to grd"
protected
final parameter SI.Resistance R_n=r_n*Utilities.Precalculation.baseR(
puUnits,
V_nom,
S_nom);
SI.AngularFrequency[2] omega;
equation
omega = der(term.theta);
v_n = R_n*i_n "equation neutral to ground (if Y-topology)";
end ImpedYDBase;
partial model ImpedYDNonSymBase
"One terminal impedance base non symmetric, 3-phase dq0"
extends ImpedYDBase;
protected
Real[3,3] Park=Utilities.Transforms.park(term.theta[2]);
end ImpedYDNonSymBase;
partial model ImpedYDHeat
"One terminal impedance base with heat port, 3-phase dq0"
extends ImpedYDBase;
extends PowerSystems.Interfaces.AddHeat;
equation
Q_flow = v*i;
end ImpedYDHeat;
partial model ImpedYDNonSymHeat
"One terminal impedance base non symmetric with heat port, 3-phase dq0"
extends ImpedYDNonSymBase;
extends PowerSystems.Interfaces.AddHeatV(
final m_heat=3);
PS.Voltage[3] v_abc=Park*top.v_cond;
PS.Current[3] i_abc=Park*top.i_cond;
equation
Q_flow = v_abc.*i_abc;
end ImpedYDNonSymHeat;
end Partials;
end ImpedancesYD; |
Rectifiers and Inverters | within PowerSystems.AC3ph;
package Inverters "Rectifiers and Inverters"
extends Modelica.Icons.VariantsPackage;
block Select "Select frequency and voltage-phasor type"
extends PowerSystems.Icons.Block;
parameter Types.SourceFrequency fType=PowerSystems.Types.SourceFrequency.System
"frequency type"
parameter SI.Frequency f=system.f "frequency if type is parameter"
parameter Boolean use_vPhasor_in = false
"= true to enable signal input vPhasor_in"
parameter Real v0=1 "voltage amplitude pu vDC/2"
parameter SI.Angle alpha0=0 "phase angle"
Modelica.Blocks.Interfaces.RealInput[2] vPhasor_in if use_vPhasor_in
"{abs(v), phase(v)}"
Modelica.Blocks.Interfaces.RealInput omega_in(final unit="rad/s") if fType
== PowerSystems.Types.SourceFrequency.Signal "angular frequency"
Modelica.Blocks.Interfaces.RealOutput[2] vPhasor_out
"{abs(u), phase(u)} to inverter"
Modelica.Blocks.Interfaces.RealOutput theta_out
"abs angle to inverter, der(theta)=omega"
outer System system;
protected
SI.Angle theta;
Modelica.Blocks.Interfaces.RealInput omega_internal
"Needed to connect to conditional connector";
Modelica.Blocks.Interfaces.RealInput[2] vPhasor_internal
"Needed to connect to conditional connector";
initial equation
if fType == Types.SourceFrequency.Signal then
theta = 0;
end if;
equation
connect(omega_in, omega_internal);
connect(vPhasor_in, vPhasor_internal);
if fType <> Types.SourceFrequency.Signal then
omega_internal = 0.0;
end if;
if not use_vPhasor_in then
vPhasor_internal = {v0, alpha0};
end if;
if fType == Types.SourceFrequency.System then
theta = system.theta;
elseif fType == Types.SourceFrequency.Parameter then
theta = 2*pi*f*(time - system.initime);
elseif fType == Types.SourceFrequency.Signal then
der(theta) = omega_internal;
end if;
theta_out = theta;
vPhasor_out = vPhasor_internal;
end Select;
model Rectifier "Rectifier, 3-phase dq0"
extends Partials.AC_DC_base(heat(final m=3));
replaceable model Rectifier = PowerSystems.AC3ph.Inverters.Components.RectifierEquation
constrainedby PowerSystems.AC3ph.Inverters.Partials.AC_DC_base "rectifier model"
Rectifier rectifier "rectifier model"
equation
connect(AC, rectifier.AC)
connect(rectifier.DC, DC)
connect(rectifier.heat, heat)
end Rectifier;
model RectifierAverage "Rectifier time-average, 3-phase dq0"
extends Partials.SwitchEquation(heat(final m=1));
replaceable record Data = PowerSystems.Semiconductors.Ideal.SCparameter(final Hsw_nom=0)
"SC parameters"
final parameter Data par "SC parameters"
parameter Real sigma=1 "power correction"
protected
final parameter Real S_abs=sigma*(2*sqrt(6)/pi);
final parameter SI.Resistance R_nom=par.V_nom/par.I_nom;
Real cT;
Real iAC2;
equation
cT = if size(par.cT_loss,1)==0 then 1 else loss(T[1]-par.T0_loss, par.cT_loss);
iAC2 = AC.i*AC.i;
switch_dq0 = S_abs*AC.i/(sqrt(iAC2) + 1e-5);
v_dq0 = (vDC1 + cT*par.Vf)*switch_dq0;
Q_flow = {par.eps[1]*R_nom*iAC2 + (2*sqrt(6)/pi)*par.Vf*sqrt(iAC2)};
end RectifierAverage;
model Inverter "Complete modulator and inverter, 3-phase dq0"
extends Partials.AC_DC_base(heat(final m=3));
Modelica.Blocks.Interfaces.RealInput theta "abs angle, der(theta)=omega"
Modelica.Blocks.Interfaces.RealInput[2] vPhasor "desired {abs(v), phase(v)}"
replaceable model Modulator = PowerSystems.Control.Modulation.PWMasyn
constrainedby PowerSystems.Control.Modulation.Partials.ModulatorBase
"modulator type"
Modulator modulator
replaceable model Inverter = PowerSystems.AC3ph.Inverters.Components.InverterSwitch
constrainedby PowerSystems.AC3ph.Inverters.Partials.AC_DC_base "inverter model"
Inverter inverter "inverter model"
protected
outer System system;
equation
Connections.potentialRoot(AC.theta);
if Connections.isRoot(AC.theta) then
AC.theta = if system.synRef then {0, theta} else {theta, 0};
end if;
connect(AC, inverter.AC)
connect(inverter.DC, DC)
connect(theta, modulator.theta)
connect(vPhasor,modulator.vPhasor)
connect(modulator.gates, inverter.gates)
connect(inverter.heat, heat)
end Inverter;
model InverterAverage "Inverter time-average, 3-phase dq0"
extends Partials.SwitchEquation(heat(final m=1));
replaceable record Data = PowerSystems.Semiconductors.Ideal.SCparameter
"SC parameters"
final parameter Data par "SC parameters"
parameter Integer modulation=1 "equivalent modulation :"
parameter Boolean syn=false "synchronous, asynchronous"
parameter Integer m_carr(min=1)=1 "f_carr/f, pulses/period"
parameter SI.Frequency f_carr=1e3 "carrier frequency"
parameter Real width0=2/3 "relative width, (0 - 1)"
Modelica.Blocks.Interfaces.RealInput theta "abs angle, der(theta)=omega"
Modelica.Blocks.Interfaces.RealInput[2] vPhasor "desired {abs(v), phase(v)}"
protected
outer System system;
final parameter SI.Resistance R_nom=par.V_nom/par.I_nom;
final parameter Real factor=
if modulation==1 then sqrt(3/2) else
if modulation==2 then (4/3)*sqrt(3/2) else
if modulation==3 then (4/pi)*sin(width0*pi/2)*sqrt(3/2) else 0
SI.Angle phi;
PS.Voltage Vloss;
Real iAC2;
Real cT;
Real hsw_nom;
equation
Connections.potentialRoot(AC.theta);
if Connections.isRoot(AC.theta) then
AC.theta = if system.synRef then {0, theta} else {theta, 0};
end if;
Vloss = if par.Vf<1e-3 then 0 else tanh(10*iDC1/par.I_nom)*2*par.Vf;
iAC2 = AC.i*AC.i;
cT = if size(par.cT_loss,1)==0 then 1 else loss(T[1]-par.T0_loss, par.cT_loss);
hsw_nom = if syn then (2*par.Hsw_nom*m_carr/(pi*par.V_nom*par.I_nom))*der(theta) else
4*par.Hsw_nom*f_carr/(par.V_nom*par.I_nom);
phi = AC.theta[1] + vPhasor[2] + system.alpha0;
switch_dq0 = factor*vPhasor[1]*PS.map({cos(phi), sin(phi), 0});
v_dq0 = (vDC1 - cT*Vloss)*switch_dq0;
// passive mode?
Q_flow = {par.eps[1]*R_nom*iAC2 +
(2*sqrt(6)/pi)*cT*(par.Vf + hsw_nom*abs(vDC1))*sqrt(iAC2)};
end InverterAverage;
package Components "Equation-based and modular components"
extends Modelica.Icons.VariantsPackage;
model RectifierEquation "Rectifier equation, 3-phase dq0"
extends Partials.SwitchEquation(heat(final m=3));
replaceable record Data = PowerSystems.Semiconductors.Ideal.SCparameter(final Hsw_nom=0)
"SC parameters"
final parameter Data par "SC parameters"
protected
PS.Voltage[3] V;
PS.Voltage[3] v "voltage in inertial abc representation";
PS.Voltage[3] i_sc
"current scaled to voltage in inertial abc representation";
Real[3] s(each start = 0.5) "arc-length on characteristic";
Real[3] switch "switch function in inertial abc representation";
Real[3,3] Park=Utilities.Transforms.park(AC.theta[2]);
equation
i_sc = transpose(Park)*AC.i*par.V_nom/par.I_nom;
for k in 1:3 loop
V[k] = if size(par.cT_loss,1)==0 then vDC1 + par.Vf else vDC1 + par.Vf*loss(T[k]-par.T0_loss, par.cT_loss);
if s[k] > V[k] then // vDC+ < vAC
{v[k],i_sc[k]} = {par.eps[1]*s[k] + (1 - par.eps[1])*V[k], s[k] - (1 - par.eps[2])*V[k]};
elseif s[k] < -V[k] then // vAC < vDC-
{v[k],i_sc[k]} = {par.eps[1]*s[k] - (1 - par.eps[1])*V[k], s[k] + (1 - par.eps[2])*V[k]};
else // vDC- < vAC < vDC+
{v[k],i_sc[k]} = {s[k],par.eps[2]*s[k]};
end if;
switch[k] = noEvent(sign(s[k]));
end for;
v_dq0 = Park*v;
switch_dq0 = Park*switch;
Q_flow = (v - switch*vDC1).*i_sc*par.I_nom/par.V_nom;
end RectifierEquation;
model RectifierModular "Rectifier modular, 3-phase"
extends Partials.AC_DC_base(heat(final m=3));
replaceable record Data = PowerSystems.Semiconductors.Ideal.SCparameter(final Hsw_nom=0)
"SC parameters"
final parameter Data par "SC parameters"
Nodes.ACdq0_a_b_c acdq0_a_b_c
Common.Thermal.Heat_a_b_c_abc heat_adapt
Semiconductors.PhaseModules.DiodeModule diodeMod_a(final par=par)
"diode module AC_a"
Semiconductors.PhaseModules.DiodeModule diodeMod_b(final par=par)
"diode module AC_b"
Semiconductors.PhaseModules.DiodeModule diodeMod_c(final par=par)
"diode module AC_c"
equation
connect(AC, acdq0_a_b_c.term)
connect(acdq0_a_b_c.term_a, diodeMod_a.AC)
connect(acdq0_a_b_c.term_b, diodeMod_b.AC)
connect(acdq0_a_b_c.term_c, diodeMod_c.AC)
connect(diodeMod_a.DC, DC)
connect(diodeMod_b.DC, DC)
connect(diodeMod_c.DC, DC)
connect(diodeMod_a.heat, heat_adapt.port_a)
connect(diodeMod_b.heat, heat_adapt.port_b)
connect(diodeMod_c.heat, heat_adapt.port_c)
connect(heat_adapt.port_abc, heat)
end RectifierModular;
model InverterSwitch "Inverter switch, 3-phase dq0"
extends Partials.SwitchEquation(heat(final m=3));
Modelica.Blocks.Interfaces.BooleanInput[6] gates
"gates pairs {a_p, a_n, b_p, b_n, c_p, c_n}"
protected
constant Integer[3] pgt={1,3,5} "positive gates";
constant Integer[3] ngt={2,4,6} "negative gates";
PS.Voltage[3] v "voltage in inertial abc representation";
Real[3] switch "switch function in inertial abc representation";
Real[3,3] Park=Utilities.Transforms.park(AC.theta[2]);
equation
for k in 1:3 loop
if gates[pgt[k]] then // switched mode DC+ to AC
switch[k] = 1;
v[k] = vDC1;
elseif gates[ngt[k]] then // switched mode DC- to AC
switch[k] = -1;
v[k] = -vDC1;
else
switch[k] = 0;
v[k] = 0;
end if;
end for;
v_dq0 = Park*v;
switch_dq0 = Park*switch;
Q_flow = zeros(heat.m);
end InverterSwitch;
model InverterEquation "Inverter equation, 3-phase dq0"
extends Partials.SwitchEquation(heat(final m=3));
replaceable record Data = PowerSystems.Semiconductors.Ideal.SCparameter
"SC parameters"
final parameter Data par "SC parameters"
Modelica.Blocks.Interfaces.BooleanInput[6] gates
"gates pairs {a_p, a_n, b_p, b_n, c_p, c_n}"
protected
constant Integer[3] pgt={1,3,5} "positive gates";
constant Integer[3] ngt={2,4,6} "negative gates";
PS.Voltage[3] V_s;
PS.Voltage[3] V_d;
PS.Voltage[3] v "voltage in inertial abc representation";
PS.Voltage[3] i_sc
"current scaled to voltage in inertial abc representation";
Real[3] s(each start = 0.5) "arc-length on characteristic";
Real[3] switch "switch function in inertial abc representation";
Real[3,3] Park=Utilities.Transforms.park(AC.theta[2]);
equation
i_sc = transpose(Park)*AC.i*par.V_nom/par.I_nom;
if par.Vf<1e-3 then // faster code if forward voltage drop Vf not used (Vf=0).
for k in 1:3 loop
V_s[k] = 0;
V_d[k] = vDC1;
if gates[pgt[k]] then // switched mode DC+ to AC
switch[k] = 1;
{v[k],i_sc[k]} = {par.eps[1]*s[k] + (1 - par.eps[1])*V_d[k],s[k] - (1 - par.eps[2])*V_d[k]};
elseif gates[ngt[k]] then // switched mode DC- to AC
switch[k] = -1;
{v[k],i_sc[k]} = {par.eps[1]*s[k] - (1 - par.eps[1])*V_d[k],s[k] + (1 - par.eps[2])*V_d[k]};
else // rectifier mode
if s[k] > V_d[k] then // vDC+ < vAC
{v[k],i_sc[k]} = {par.eps[1]*s[k] + (1 - par.eps[1])*V_d[k], s[k] - (1 - par.eps[2])*V_d[k]};
elseif s[k] < -V_d[k] then // vAC < vDC-
{v[k],i_sc[k]} = {par.eps[1]*s[k] - (1 - par.eps[1])*V_d[k], s[k] + (1 - par.eps[2])*V_d[k]};
else // vDC- < vAC < vDC+
{v[k],i_sc[k]} = {s[k],par.eps[2]*s[k]};
end if;
switch[k] = noEvent(sign(s[k]));
end if;
end for;
Q_flow = zeros(heat.m);
else // slower code if voltage drop used (Vf_s>0 or Vf_d>0).
for k in 1:3 loop
{V_s[k], V_d[k]} = if size(par.cT_loss,1)==0 then {vDC1-par.Vf, vDC1+par.Vf} else {vDC1, vDC1} + {-par.Vf, par.Vf}*loss(T[k]-par.T0_loss, par.cT_loss);
if gates[pgt[k]] then // switched mode DC+ to AC
switch[k] = 1;
if s[k] > V_d[k] then
{v[k],i_sc[k]} = {par.eps[1]*s[k] + (1 - par.eps[1])*V_d[k],s[k] - (1 - par.eps[2])*V_d[k]};
elseif s[k] < V_s[k] then
{v[k],i_sc[k]} = {par.eps[1]*s[k] + (1 - par.eps[1])*V_s[k],s[k] - (1 - par.eps[2])*V_s[k]};
else
{v[k],i_sc[k]} = {s[k],par.eps[2]*s[k]};
end if;
elseif gates[ngt[k]] then // switched mode DC- to AC
switch[k] = -1;
if s[k] < -V_d[k] then
{v[k],i_sc[k]} = {par.eps[1]*s[k] - (1 - par.eps[1])*V_d[k],s[k] + (1 - par.eps[2])*V_d[k]};
elseif s[k] > -V_s[k] then
{v[k],i_sc[k]} = {par.eps[1]*s[k] -(1 - par.eps[1])*V_s[k],s[k] + (1 - par.eps[2])*V_s[k]};
else
{v[k],i_sc[k]} = {s[k],par.eps[2]*s[k]};
end if;
else // rectifier mode
if s[k] > V_d[k] then // vDC+ < vAC
{v[k],i_sc[k]} = {par.eps[1]*s[k] + (1 - par.eps[1])*V_d[k], s[k] - (1 - par.eps[2])*V_d[k]};
elseif s[k] < -V_d[k] then // vAC < vDC-
{v[k],i_sc[k]} = {par.eps[1]*s[k] - (1 - par.eps[1])*V_d[k], s[k] + (1 - par.eps[2])*V_d[k]};
else // vDC- < vAC < vDC+
{v[k],i_sc[k]} = {s[k],par.eps[2]*s[k]};
end if;
switch[k] = noEvent(sign(s[k]));
end if;
end for;
Q_flow = (v - switch*vDC1).*i_sc*par.I_nom/par.V_nom;
end if;
v_dq0 = Park*v;
switch_dq0 = Park*switch;
end InverterEquation;
model InverterModular "Inverter modular, 3-phase"
extends Partials.AC_DC_base(heat(final m=3));
replaceable model Switch = PowerSystems.Semiconductors.Ideal.SCswitch_Diode "Semiconductor model"
constrainedby PowerSystems.Semiconductors.Partials.GateInput
replaceable record Data = PowerSystems.Semiconductors.Ideal.SCparameter "SC parameters"
final parameter Data par "SC parameters"
Modelica.Blocks.Interfaces.BooleanInput[6] gates
"gates pairs {a_p, a_n, b_p, b_n, c_p, c_n}"
Nodes.ACdq0_a_b_c acdq0_a_b_c
Common.Thermal.Heat_a_b_c_abc heat_adapt
Blocks.Multiplex.Gate3demux gate3demux1(final n=2)
Semiconductors.PhaseModules.SwitchModule switchMod_a(redeclare model Switch=Switch, final par=par)
"switch + reverse diode module AC_a"
Semiconductors.PhaseModules.SwitchModule switchMod_b(redeclare model Switch=Switch, final par=par)
"switch + reverse diode module AC_b"
Semiconductors.PhaseModules.SwitchModule switchMod_c(redeclare model Switch=Switch, final par=par)
"switch + reverse diode module AC_c"
equation
connect(AC, acdq0_a_b_c.term)
connect(acdq0_a_b_c.term_a, switchMod_a.AC)
connect(switchMod_a.DC, DC)
connect(acdq0_a_b_c.term_b, switchMod_b.AC)
connect(switchMod_b.DC, DC)
connect(acdq0_a_b_c.term_c, switchMod_c.AC)
connect(switchMod_c.DC, DC)
connect(gates, gate3demux1.gates)
connect(gate3demux1.gates_a, switchMod_a.gates)
connect(gate3demux1.gates_b, switchMod_b.gates)
connect(gate3demux1.gates_c, switchMod_c.gates)
connect(switchMod_a.heat, heat_adapt.port_a)
connect(switchMod_b.heat, heat_adapt.port_b)
connect(switchMod_c.heat, heat_adapt.port_c)
connect(heat_adapt.port_abc, heat)
end InverterModular;
end Components;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model AC_DC_base "AC-DC base, 3-phase dq0"
extends PowerSystems.Icons.Inverter_dq0;
extends Ports.PortBase;
Ports.ACdq0_n AC "AC 3-phase connection"
AC1ph_DC.Ports.TwoPin_p DC "DC connection"
Interfaces.ThermalV_n heat(m=3) "vector heat port"
end AC_DC_base;
partial model SwitchEquation "Switch equation, 3-phase dq0"
extends AC_DC_base;
protected
PS.Voltage vDC1=0.5*(DC.v[1] - DC.v[2]);
PS.Voltage vDC0=0.5*(DC.v[1] + DC.v[2]);
PS.Current iDC1=(DC.i[1] - DC.i[2]);
PS.Current iDC0=(DC.i[1] + DC.i[2]);
Real[PS.n] v_dq0 "switching function voltage in dq0 representation";
Real[PS.n] switch_dq0 "switching function in dq0 representation";
SI.Temperature[heat.m] T "component temperature";
SI.HeatFlowRate[heat.m] Q_flow "component loss-heat flow";
function loss = Utilities.Math.taylor "temp dependence of losses";
SI.Conductance C0 = 1 "for dq phase system";
equation
AC.v = v_dq0 + PS.map({0,0,sqrt(3)*vDC0});
iDC1 + switch_dq0*AC.i = 0;
if PS.n > 2 then
iDC0 + sqrt(3)*AC.i[3] = 0;
else
iDC0 = C0*vDC0 "iDC0 = 0, vDC0 = 0";
end if;
T = heat.ports.T;
heat.ports.Q_flow = -Q_flow;
end SwitchEquation;
end Partials;
end Inverters; |
Transmission lines 3-phase | within PowerSystems.AC3ph;
package Lines "Transmission lines 3-phase"
extends Modelica.Icons.VariantsPackage;
model RXline0 "RX line without length parameter, 3-phase dq0"
extends Impedances.Partials.ImpedBase;
parameter SIpu.Resistance r=0.01 "resistance";
parameter SIpu.Reactance x=0.1 "reactance";
parameter SIpu.Reactance x0=3*x "reactance zero-comp";
protected
final parameter SI.Resistance[2] RL_base=Utilities.Precalculation.baseRL(
puUnits,
V_nom,
S_nom,
2*pi*f_nom);
final parameter SI.Resistance R=r*RL_base[1];
final parameter SI.Inductance L=x*RL_base[2];
final parameter SI.Inductance L0=x0*RL_base[2];
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i) = omega[1]*j(i);
elseif dynType == Types.Dynamics.FixedInitial then
i = i_start;
end if;
equation
if dynType <> Types.Dynamics.SteadyState then
PS.map({L,L,L0}).*der(i) + omega[2]*L*j(i) + R*i = v;
else
omega[2]*L*j(i) + R*i = v;
end if;
end RXline0;
model RXline "RX transmission line, 3-phase dq0"
extends Ports.Port_pn;
extends Partials.RXlineBase(final ne=1);
PS.Voltage[PS.n] v(start = v_start);
PS.Current[PS.n] i(start = i_start);
protected
SI.AngularFrequency[2] omega;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i) = omega[1]*j(i);
elseif dynType == Types.Dynamics.FixedInitial then
i = i_start;
end if;
equation
omega = der(term_p.theta);
v = term_p.v - term_n.v;
i = term_p.i;
if dynType <> Types.Dynamics.SteadyState then
PS.map({L,L,L0}).*der(i) + omega[2]*L*j(i) + R*i = v;
else
omega[2]*L*j(i) + R*i = v;
end if;
end RXline;
model PIline "PI transmission line, 3-phase dq0"
extends Ports.Port_p_n;
extends Partials.LineBase;
PS.Voltage[PS.n,ne1] v(start = transpose(fill(v_start, ne1)));
PS.Current[PS.n,ne] i(start = transpose(fill(i_start, ne)));
protected
final parameter Integer ne1=ne + 1;
SI.AngularFrequency[2] omega;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(v) = omega[1]*jj(v);
der(i) = omega[1]*jj(i);
elseif dynType == Types.Dynamics.FixedInitial then
v = transpose(fill(v_start, ne1));
i = transpose(fill(i_start, ne));
end if;
equation
omega = der(term_p.theta);
v[:, 1] = term_p.v;
v[:, ne1] = term_n.v;
if dynType <> Types.Dynamics.SteadyState then
diagonal(PS.map({C,C,C0}))*der(v) + omega[2]*C*jj(v) + G*v =
[[2*(term_p.i - i[:, 1])], i[:, 1:ne - 1] - i[:, 2:ne], [2*(i[:, ne] + term_n.i)]];
diagonal(PS.map({L,L,L0}))*der(i) + omega[2]*L*jj(i) + R*i =
v[:,1:ne] - v[:,2:ne1];
else
omega[2]*C*jj(v) + G*v =
[[2*(term_p.i - i[:, 1])], i[:, 1:ne - 1] - i[:, 2:ne], [2*(i[:, ne] + term_n.i)]];
omega[2]*L*jj(i) + R*i =
v[:,1:ne] - v[:,2:ne1];
end if;
end PIline;
model Tline "T transmission line, 3-phase dq0"
extends Ports.Port_p_n;
extends Partials.LineBase;
PS.Voltage[PS.n,ne] v(start = transpose(fill(v_start, ne)));
PS.Current[PS.n,ne1] i(start = transpose(fill(i_start, ne1)));
protected
final parameter Integer ne1=ne + 1;
SI.AngularFrequency[2] omega;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(v) = omega[1]*jj(v);
der(i) = omega[1]*jj(i);
elseif dynType == Types.Dynamics.FixedInitial then
v = transpose(fill(v_start, ne));
i = transpose(fill(i_start, ne1));
end if;
equation
omega = der(term_p.theta);
i[:, 1] = term_p.i;
i[:, ne1] = -term_n.i;
if dynType <> Types.Dynamics.SteadyState then
diagonal(PS.map({C,C,C0}))*der(v) + omega[2]*C*jj(v) + G*v =
i[:,1:ne] - i[:,2:ne1];
diagonal(PS.map({L,L,L0}))*der(i) + omega[2]*L*jj(i) + R*i =
[[2*(term_p.v - v[:, 1])], v[:, 1:ne - 1] - v[:, 2:ne], [2*(v[:, ne] - term_n.v)]];
else
omega[2]*C*jj(v) + G*v = i[:,1:ne] - i[:,2:ne1];
omega[2]*L*jj(i) + R*i =
[[2*(term_p.v - v[:, 1])], v[:, 1:ne - 1] - v[:, 2:ne], [2*(v[:, ne] - term_n.v)]];
end if;
end Tline;
model FaultRXline "Faulted RX transmission line, 3-phase dq0"
extends Ports.Port_p_n_f;
parameter Real p(min=0,max=1)=0.5 "rel fault-position (0 < p < 1)";
extends Partials.RXlineBase(final ne=1);
PS.Current[PS.n] i1(start = i_start);
PS.Current[PS.n] i2(start = i_start);
protected
SI.AngularFrequency[2] omega;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i1) = omega[1]*j(i1);
der(i2) = omega[1]*j(i2);
elseif dynType == Types.Dynamics.FixedInitial then
i1 = i_start;
i2 = i_start;
end if;
equation
omega = der(term_p.theta);
term_p.i + term_n.i + term_f.i = zeros(PS.n);
i1 = term_p.i;
i2 = -term_n.i;
if dynType <> Types.Dynamics.SteadyState then
p*(PS.map({L,L,L0}).*der(i1) + omega[2]*L*j(i1) + R*i1) =
term_p.v - term_f.v;
(1 - p)*(PS.map({L,L,L0}).*der(i2) + omega[2]*L*j(i2) + R*i2) =
term_f.v - term_n.v;
else
p*(omega[2]*L*j(i1) + R*i1) = term_p.v - term_f.v;
(1 - p)*(omega[2]*L*j(i2) + R*i2) = term_f.v - term_n.v;
end if;
end FaultRXline;
model FaultTline "Faulted T transmission line, 3-phase dq0"
extends Ports.Port_p_n_f;
parameter Real p(min=0.5/ne,max=1-0.5/ne)=0.5
"rel fault-pos (1/2ne <= p < 1 - 1/2ne)";
extends Partials.LineBase;
parameter PS.Current[PS.n] iF_start = zeros(PS.n) "start value of fault current"
PS.Voltage[PS.n,ne] v(start = transpose(fill(v_start, ne)));
PS.Current[PS.n,ne1] i(start = transpose(fill(i_start, ne1)));
PS.Current[PS.n] iF(start = iF_start);
PS.Current[PS.n,2] iF_p(each stateSelect=StateSelect.never);
protected
final parameter Integer ne1=ne + 1;
final parameter Integer nF=integer(ne*p + 1.5);
final parameter Real pe=min(0.9, max(0.1, ne*p + 1.5 - nF))
"relative fault position within element nF";
SI.AngularFrequency[2] omega;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(v) = omega[1]*jj(v);
der(i) = omega[1]*jj(i);
der(iF) = omega[1]*j(iF);
elseif dynType == Types.Dynamics.FixedInitial then
v = transpose(fill(v_start, ne));
i = transpose(fill(i_start, ne1));
iF = iF_start;
end if;
equation
omega = der(term_p.theta);
i[:, 1] = term_p.i;
i[:, ne1] = -term_n.i;
iF = -term_f.i;
iF_p = [(1-pe)*iF, pe*iF];
if dynType <> Types.Dynamics.SteadyState then
diagonal(PS.map({C,C,C0}))*der(v) + omega[2]*C*jj(v) + G*v =
[i[:,1:nF-2]-i[:, 2:nF-1], i[:,nF-1:nF]-i[:,nF:nF+1]-iF_p, i[:,nF+1:ne]-i[:,nF+2:ne1]];
diagonal(PS.map({L,L,L0}))*der(i) + omega[2]*L*jj(i) + R*i =
[[2*(term_p.v - v[:, 1])], v[:, 1:ne - 1] - v[:, 2:ne], [2*(v[:, ne] - term_n.v)]];
PS.map({L,L,L0}).*der(iF) + omega[2]*L*j(iF) + R*iF =
(v[:, nF-1] - term_f.v)/pe + (v[:, nF] - term_f.v)/(1-pe);
else
omega[2]*C*jj(v) + G*v =
[i[:,1:nF-2]-i[:, 2:nF-1], i[:,nF-1:nF]-i[:,nF:nF+1]-iF_p, i[:,nF+1:ne]-i[:,nF+2:ne1]];
omega[2]*L*jj(i) + R*i =
[[2*(term_p.v - v[:, 1])], v[:, 1:ne - 1] - v[:, 2:ne], [2*(v[:, ne] - term_n.v)]];
omega[2]*L*j(iF) + R*iF =
(v[:, nF-1] - term_f.v)/pe + (v[:, nF] - term_f.v)/(1-pe);
end if;
end FaultTline;
package Partials "Partial models"
extends Modelica.Icons.MaterialPropertiesPackage;
partial model RXlineBase "RX-line base, 3-phase dq0"
extends Ports.PortBase;
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter PS.Voltage[PS.n] v_start = zeros(PS.n) "start value of voltage drop"
parameter PS.Current[PS.n] i_start = zeros(PS.n) "start value of current"
parameter SI.Length len=100e3 "line length";
parameter Integer ne(min=1)=1 "number of line elements";
replaceable record Data = PowerSystems.AC3ph.Lines.Parameters.RXline
constrainedby PowerSystems.AC3ph.Lines.Parameters.RXline
"line parameters"
final parameter Data par "line parameters"
protected
outer System system;
final parameter SI.Resistance[2] RL_base=Utilities.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 R=par.r*delta_len_km*RL_base[1];
final parameter SI.Inductance L=par.x*delta_len_km*RL_base[2];
final parameter SI.Inductance L0=par.x0*delta_len_km*RL_base[2];
end RXlineBase;
partial model LineBase "PI- and T-line base, 3-phase dq0"
extends RXlineBase(ne=3, redeclare replaceable record Data =
PowerSystems.AC3ph.Lines.Parameters.Line);
protected
final parameter Real[2] GC_base=Utilities.Precalculation.baseGC(
par.puUnits,
par.V_nom,
par.S_nom,
2*pi*par.f_nom);
final parameter SI.Conductance G=(par.g_pg + 3*par.g_pp)*delta_len_km*GC_base[1];
final parameter SI.Capacitance C=(par.b_pg + 3*par.b_pp)*delta_len_km*GC_base[2];
final parameter SI.Capacitance C0=par.b_pg*delta_len_km*GC_base[2];
end LineBase;
end Partials;
package Parameters "Parameter data for interactive use"
extends Modelica.Icons.BasesPackage;
record RXline "RX-line parameters, 3-phase"
extends Common.Nominal.NominalDataAC(
S_nom=100e6);
SIpu.Resistance_km r=0.1e-3 "resistance/km"
SIpu.Reactance_km x=1e-3 "reactance/km"
SIpu.Reactance_km x0=3*x "reactance/km zero-comp"
end RXline;
record Line "Line parameters, 3-phase"
extends RXline;
SIpu.Conductance_km g_pg=0 "shunt conductance/km ph-grd"
SIpu.Conductance_km g_pp=0 "shunt conductance/km ph_ph"
SIpu.Susceptance_km b_pg=0.025e-3 "susceptance/km ph-grd"
SIpu.Susceptance_km b_pp=0.025e-3 "susceptance/km ph-ph"
end Line;
end Parameters;
end Lines; |
Loads | within PowerSystems.AC3ph;
package Loads "Loads"
extends Modelica.Icons.VariantsPackage;
model PQload "PQ steady-state load"
extends PowerSystems.AC3ph.Loads.Partials.LoadBase;
equation
PS.map({pq[1], pq[2], 0}) = PS.phasePowers_vi(v, i);
end PQload;
model Zload "Impedance load, 3-phase dq0"
extends Partials.IndLoadBase;
equation
Z = (pq/(pq*pq))*V2_nom;
end Zload;
model PQindLoad "PQ inductive load, 3-phase dq0"
extends Partials.IndLoadBase;
parameter SIpu.Current imax(unit="1")=2 "maximum current";
parameter SI.Time tcst=0.01 "time constant Z";
protected
Real v2 = v*v;
initial equation
der(Z) = {0, 0};
equation
// der(Z) = ((pq/(pq*pq))*v2 - Z)/tcst;
der(Z) = ((pq/(pq*pq))*v2*tanh(imax)/tanh((imax/V2_nom)*v2) - Z)/tcst;
end PQindLoad;
model Yload "Admittance load, 3-phase dq0"
extends Partials.CapLoadBase;
equation
Y = (pq/(pq*pq))*I2_nom;
end Yload;
model PQcapLoad "PQ capacitive load, 3-phase dq0"
extends Partials.CapLoadBase;
parameter SIpu.Voltage vmax(unit="1")=2 "maximum voltage";
parameter SI.Time tcst=0.01 "time constant Y";
protected
Real i2 = i*i;
initial equation
der(Y) = {0, 0};
equation
// der(Y) = ((pq/(pq*pq))*i2 - Y)/tcst;
der(Y) = ((pq/(pq*pq))*i2*tanh(vmax)/tanh((vmax/I2_nom)*i2) - Y)/tcst;
end PQcapLoad;
model ZIPload "ZIP inductive load, 3-phase dq0"
extends Partials.IndLoadBase;
parameter SIpu.Current imax(unit="1")=2 "maximum current";
parameter Real[2] aZ={1/3,1/3} "weight(power) impedance-dependent";
parameter Real[2] aI={1/3,1/3} "weight(power) current-dependent";
parameter Real[2] aP={1,1}-aZ-aI "weight(power) fixed";
parameter SI.Time tcst=0.01 "time constant Z";
protected
SI.Power[2] pq_ZIP(start=pq0);
Real v2 = v*v;
Real v2_pu = v2/V2_nom;
initial equation
der(Z) = {0, 0};
equation
pq_ZIP = diagonal(aZ*v2_pu + aI*sqrt(v2_pu) + aP)*pq;
// der(Z) = ((pq_ZIP/(pq_ZIP*pq_ZIP))*v2 - Z)/tcst;
der(Z) = ((pq_ZIP/(pq_ZIP*pq_ZIP))*v2*tanh(imax)/tanh(imax*v2_pu) - Z)/tcst;
end ZIPload;
model FrequencyLoad "Frequency inductive load, 3-phase dq0"
extends Partials.IndLoadBase;
parameter SIpu.Current imax(unit="1")=2 "maximum current";
parameter Real[2] af={1,1} "frequency sensitivity";
parameter Real[2] aV={1,1} "voltage sensitivity";
parameter SI.Time tcst=0.01 "time constant Z";
protected
final parameter Real[2] aw=af/(2*pi);
SI.Power[2] pq_fV(start=pq0);
Real v2 = v*v;
Real v2_pu = v2/V2_nom;
initial equation
der(Z) = {0, 0};
equation
pq_fV = diagonal({1,1} + aV*(sqrt(v2_pu)-1) + aw*(sum(omega) - system.omega_nom))*pq;
// der(Z) = ((pq_fV/(pq_fV*pq_fV))*v2 - Z)/tcst;
der(Z) = ((pq_fV/(pq_fV*pq_fV))*v2*tanh(imax)/tanh(imax*v2_pu) - Z)/tcst;
end FrequencyLoad;
model DynamicLoad "Dynamic inductive load, 3-phase dq0"
extends Partials.IndLoadBase;
parameter SIpu.Current imax(unit="1")=2 "maximum current";
parameter Real[2] as={0.5,1} "voltage exponent steady-state power";
parameter Real[2] at={2,2} "voltage exponent transient power";
parameter SI.Time[2] t_rec={60,60} "power recovery times";
parameter SI.Time tcst=0.01 "time constant Z";
protected
SI.Power[2] pq_st(start=pq0);
Real v2 = v*v;
Real v2_pu = v2/V2_nom;
Real[2] x;
Real[2] vs;
Real[2] vt;
Real[2] xT;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(x) = {0,0};
end if;
der(Z) = {0,0};
equation
vs = {v2_pu^(as[1]/2), v2_pu^(as[2]/2)};
vt = {v2_pu^(at[1]/2), v2_pu^(at[2]/2)};
xT = {x[1]/t_rec[1], x[2]/t_rec[2]};
der(x) = diagonal(vs - vt)*pq - xT;
pq_st = diagonal(vt)*pq + xT;
// der(Z) = ((pq_st/(pq_st*pq_st))*v2 - Z)/tcst;
der(Z) = ((pq_st/(pq_st*pq_st))*v2*tanh(imax)/tanh(imax*v2_pu) - Z)/tcst;
end DynamicLoad;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model LoadBase "Load base, 3-phase dq0"
extends Ports.Yport_p;
extends Common.Nominal.Nominal;
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter Boolean use_pq_in = false
"= true to use input signal pq_in, otherwise use parameter pq0"
parameter SIpu.Power[2] pq0(each min=0)={sqrt(3),1}/2
"fixed {active, reactive} power (start value if use_pq_in)"
parameter SIpu.Resistance r_n=0 "resistance neutral to grd";
Modelica.Blocks.Interfaces.RealInput[2] pq_in(each min=0) if use_pq_in
"desired {active, reactive} power"
protected
outer System system;
final parameter Real S_base=Utilities.Precalculation.baseS(puUnits, S_nom);
final parameter Real R_base=Utilities.Precalculation.baseR(
puUnits,
V_nom,
S_nom);
final parameter SI.Resistance R_n=r_n*R_base;
SI.AngularFrequency[2] omega;
SI.Power[2] pq(start=pq0);
Modelica.Blocks.Interfaces.RealInput[2] pq_internal
"Needed to connect to conditional connector";
equation
connect(pq_in, pq_internal);
omega = der(term.theta);
if not use_pq_in then
pq_internal = pq0;
end if;
pq = pq_internal*S_base;
v_n = R_n*i_n "equation neutral to ground";
end LoadBase;
partial model IndLoadBase "Inductive load base, 3-phase dq0"
extends LoadBase(v(start={v_start[1],v_start[2],0}), i(start={i_start[1],i_start[2],0}));
parameter Real cpl(min=-0.5,max=1)=0
"phase coupling x_m/x_s, (-1/2 < cpl < 1)";
SI.MagneticFlux[3] psi(each stateSelect=StateSelect.prefer)
"magnetic flux";
protected
final parameter Real c0=(1 + 2*cpl)/(1 - cpl);
final parameter Real V2_nom=V_nom*V_nom;
final parameter Real[2] Z_start=(pq0/(pq0*pq0*S_base))*V2_nom;
final parameter PS.Voltage[2] v_start={cos(system.alpha0), sin(system.alpha0)}*V_nom;
final parameter PS.Current[2] i_start=[Z_start[1],Z_start[2];-Z_start[2],Z_start[1]]*v_start/(Z_start*Z_start);
SI.Impedance[2] Z(start=Z_start);
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(psi) = omega[1]*{-psi[2], psi[1], 0};
end if;
equation
psi = Z[2]*{i[1], i[2], c0*i[3]}/system.omega_nom;
if dynType <> Types.Dynamics.SteadyState then
der(psi) + omega[2]*j_dq0(psi) + Z[1]*i = v;
else
omega[2]*j_dq0(psi) + Z[1]*i = v;
end if;
end IndLoadBase;
partial model CapLoadBase "Capacitive load base, 3-phase dq0"
extends LoadBase(v(start={v_start[1],v_start[2],0}), i(start={i_start[1],i_start[2],0}));
parameter Real beta(min=0)=0 "ratio b_pp/b_pg, (beta > 0)";
SI.ElectricCharge[3] q(each stateSelect=StateSelect.prefer)
"electric charge";
protected
final parameter Real c0=1/(1+3*beta);
final parameter Real I2_nom=(S_nom/V_nom)^2;
final parameter SI.Admittance[2] Y_start=(pq0/(pq0*pq0*S_base))*I2_nom;
final parameter PS.Voltage[2] v_start={cos(system.alpha0), sin(system.alpha0)}*V_nom;
final parameter PS.Current[2] i_start=[Y_start[1],-Y_start[2];Y_start[2],Y_start[1]]*v_start;
SI.Admittance[2] Y(start=Y_start);
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(q) = omega[1]*{-q[2], q[1], 0};
end if;
equation
q = Y[2]*{v[1], v[2], c0*v[3]}/system.omega_nom;
if dynType <> Types.Dynamics.SteadyState then
der(q) + omega[2]*j_dq0(q) + Y[1]*v = i;
else
omega[2]*j_dq0(q) + Y[1]*v = i;
end if;
end CapLoadBase;
end Partials;
end Loads; |
AC machines, electric part | within PowerSystems.AC3ph;
package Machines "AC machines, electric part "
extends Modelica.Icons.VariantsPackage;
model Asynchron "Asynchronous machine, cage-rotor, 3-phase dq0"
extends Partials.AsynchronBase(redeclare replaceable record Data =
PowerSystems.AC3ph.Machines.Parameters.Asynchron_cage);
initial equation
phi_el = phi_el_start;
end Asynchron;
model AsynchronY_D "Asynchronous machine Y-Delta, cage-rotor, 3-phase dq0"
extends Partials.AsynchronBase(redeclare model Topology_p =
PowerSystems.AC3ph.Ports.Topology.Y_Delta(control=YDcontrol) "Y-Delta",
redeclare replaceable record Data =
PowerSystems.AC3ph.Machines.Parameters.Asynchron_cage);
Modelica.Blocks.Interfaces.BooleanInput YDcontrol "true:Y, false:Delta"
initial equation
phi_el = phi_el_start;
equation
/*
connect(YDcontrol, top.control)
*/
end AsynchronY_D;
model Asynchron_ctrl
"Asynchronous machine, cage-rotor, for field-oriented control, 3-phase dq0"
extends Partials.AsynchronBase(redeclare replaceable record Data =
PowerSystems.AC3ph.Machines.Parameters.Asynchron_cage);
parameter PS.Current[n_r] i_d_start = zeros(n_r)
"start value of current d_axis"
parameter PS.Current[n_r] i_q_start = zeros(n_r)
"start value of current q_axis"
Modelica.Blocks.Interfaces.RealOutput[2] i_meas(each final unit="1")
"measured current {i_d, i_q} pu"
Modelica.Blocks.Interfaces.RealInput[2] i_act(each final unit="1")
"actuated current {i_d, i_q} pu"
Modelica.Blocks.Interfaces.RealOutput phiRotorflux "rotor-flux angle"
Modelica.Blocks.Interfaces.RealOutput[2] vPhasor
"desired {abs(v), phase(v)}"
protected
constant Real eps=Modelica.Constants.eps;
final parameter PS.Current I_nom=par.S_nom/par.V_nom;
SI.Angle alpha_i;
SI.Angle alpha_psi;
PS.Voltage[2] v_dq "stator voltage demand in rotor flux-system";
PS.Current[2] i_dq "stator current demand in rotor flux-system";
PS.Current[n_r] i_d(start = i_d_start);
PS.Current[n_r] i_q(start = i_q_start);
function acos=Modelica.Math.acos;
initial equation
phi_el = phi_el_start;
phiRotorflux = 0;
equation
der(phiRotorflux) = w_el - (-diagonal(R_r)*i_rd*psi_rq + diagonal(R_r)*i_rq*psi_rd)/(psi_rd*psi_rd + psi_rq*psi_rq + eps);
alpha_i = atan2(i[2], i[1]);
alpha_psi = atan2(R_m*psi_rq, R_m*psi_rd);
i_meas = {cos(alpha_i - alpha_psi),sin(alpha_i - alpha_psi)}*sqrt(i[1:2]*i[1:2])/I_nom;
i_dq = i_act*I_nom;
(sum(omega) - w_el)*(-L_m*i_dq[2] - L_r*i_q) + diagonal(R_r)*i_d = zeros(n_r);
(sum(omega) - w_el)*(L_m*i_dq[1] + L_r*i_d) + diagonal(R_r)*i_q = zeros(n_r);
v_dq = sum(omega)*{-(c.L_s[2]*i_dq[2] + L_m*i_q), c.L_s[1]*i_dq[1] + L_m*i_d} + c.R_s*i_dq;
vPhasor = {sqrt(v_dq*v_dq)/par.V_nom, atan2(v_dq[2], v_dq[1]) + atan2(sin(alpha_psi - term.theta[1]), cos(alpha_psi - term.theta[1]))};
end Asynchron_ctrl;
model Asynchron_dfig "Doubly fed induction generator, 3-phase dq0"
extends AC3ph.Machines.Partials.AsynchronBase(v_rd = term_r.v[1]*ones(n_r), v_rq = term_r.v[2]*ones(n_r));
Modelica.Blocks.Interfaces.RealOutput phiRotor "rotor angle"
AC3ph.Ports.ACdq0_p term_r "positive terminal"
initial equation
phi_el = phi_el_start;
phiRotor = 0;
equation
der(phiRotor) = w_el;
term_r.i = {sum(i_rd), sum(i_rq), 0};
end Asynchron_dfig;
model Synchron3rd_ee
"Synchronous machine electrically excited, 3rd order model, 3-phase dq0"
extends Partials.Synchron3rdBase(final phi_el_start=-pi/2+system.alpha0,
redeclare replaceable record Data =
PowerSystems.AC3ph.Machines.Parameters.Synchron3rd_ee);
final parameter PS.Voltage Vf_nom=par.V_nom; // to be accessible from 'excitation'.
output SI.Angle powerAngle(start=0, stateSelect=StateSelect.never)
"power angle";
AC1ph_DC.Ports.TwoPin_p field "field winding"
initial equation
w_el = sum(omega);
equation
if par.excite==1 then
psi_e = (field.v[1] - field.v[2])/c.omega_nom;
field.i = zeros(2);
else
assert(false, "machine-parameter must be excite = 1 (el)");
end if;
powerAngle = noEvent(mod(phi_el - term.theta[2] - atan2(-v[1], v[2]) + pi, 2*pi)) - pi;
end Synchron3rd_ee;
model Synchron_ee "Synchronous machine electrically excited, 3-phase dq0"
extends Partials.SynchronBase(final phi_el_start=-pi/2+system.alpha0,
redeclare replaceable record Data =
PowerSystems.AC3ph.Machines.Parameters.Synchron_ee);
final parameter PS.Voltage Vf_nom=c.Vf_nom; // to be accessible from 'excitation'.
output SI.Angle powerAngle(start=0, stateSelect=StateSelect.never)
"power angle";
AC1ph_DC.Ports.TwoPin_p field "field winding"
initial equation
w_el = sum(omega);
equation
if par.excite==1 then
psi_e = 0;
v_rd[1] = (field.v[1] - field.v[2])*c.wf;
field.i = zeros(2);
else
assert(false, "machine-parameter must be excite = 1 (el)");
end if;
powerAngle = noEvent(mod(phi_el - term.theta[2] - atan2(-v[1], v[2]) + pi, 2*pi)) - pi;
end Synchron_ee;
model Synchron3rd_pm "Synchronous machine pm, 3rd order model, 3-phase dq0"
extends Partials.Synchron3rdBase(redeclare replaceable record Data =
PowerSystems.AC3ph.Machines.Parameters.Synchron3rd_pm);
Modelica.Blocks.Interfaces.RealOutput phiRotor=
phi_el "rotor angle el"
initial equation
phi_el = phi_el_start;
equation
if par.excite==1 then
assert(false, "machine-parameter must be excite = 2 (pm) or 3 (reluctance)");
elseif par.excite==2 then
psi_e = c.Psi_pm; // = par.psi_pm*(par.V_nom/c.omega_nom)
elseif par.excite==3 then
psi_e = 0;
end if;
end Synchron3rd_pm;
model Synchron_pm "Synchronous machine pm, 3-phase dq0"
extends Partials.SynchronBase(redeclare replaceable record Data =
PowerSystems.AC3ph.Machines.Parameters.Synchron_pm);
Modelica.Blocks.Interfaces.RealOutput phiRotor=
phi_el "rotor angle el"
initial equation
phi_el = phi_el_start;
equation
if par.excite==1 then
assert(false, "machine-parameter must be excite = 2 (pm) or 3 (reluctance)");
elseif par.excite==2 then
psi_e = c.Psi_pm; // = par.psi_pm*(par.V_nom/c.omega_nom)
v_rd[1] = 0;
elseif par.excite==3 then
psi_e = 0;
v_rd[1] = 0;
end if;
end Synchron_pm;
model Synchron3rd_pm_ctrl
"Synchronous machine, for field-oriented control, 3rd order model, 3-phase dq0"
extends Partials.Synchron3rdBase(redeclare replaceable record Data =
PowerSystems.AC3ph.Machines.Parameters.Synchron3rd_pm);
Modelica.Blocks.Interfaces.RealOutput[2] i_meas(each final unit="1")
"measured current {i_d, i_q} pu"
Modelica.Blocks.Interfaces.RealInput[2] i_act(each final unit="1")
"actuated current {i_d, i_q} pu"
Modelica.Blocks.Interfaces.RealOutput phiRotor=phi_el "rotor angle el"
Modelica.Blocks.Interfaces.RealOutput[2] vPhasor
"desired {abs(u), phase(u)}"
protected
final parameter PS.Current I_nom=par.S_nom/par.V_nom;
PS.Voltage[2] v_dq "voltage demand {v_d, v_q} pu";
PS.Current[2] i_dq "current demand {i_d, i_q} pu";
initial equation
phi_el = phi_el_start;
equation
if par.excite==1 then
assert(false, "machine-parameter must be excite = 2 (pm) or 3 (reluctance)");
elseif par.excite==2 then
psi_e = c.Psi_pm; // = par.psi_pm*(par.V_nom/c.omega_nom)
elseif par.excite==3 then
psi_e = 0;
end if;
i_meas = i_s[1:2]/I_nom;
i_dq = i_act*I_nom;
v_dq = w_el*{-(c.L_s[2]*i_dq[2]),c.L_s[1]*i_dq[1] + psi_e} + c.R_s*i_dq;
vPhasor = {sqrt(v_dq*v_dq)/par.V_nom,atan2(v_dq[2], v_dq[1])};
end Synchron3rd_pm_ctrl;
model Synchron_pm_ctrl
"Synchronous machine, for field-oriented control, 3-phase dq0"
extends Partials.SynchronBase(redeclare replaceable record Data =
PowerSystems.AC3ph.Machines.Parameters.Synchron_pm);
Modelica.Blocks.Interfaces.RealOutput[2] i_meas(
each final unit="1") "measured current {i_d, i_q} pu"
Modelica.Blocks.Interfaces.RealInput[2] i_act(
each final unit="1") "actuated current {i_d, i_q} pu"
Modelica.Blocks.Interfaces.RealOutput phiRotor=
phi_el "rotor angle el"
Modelica.Blocks.Interfaces.RealOutput[2] vPhasor
"desired {abs(u), phase(u)}"
protected
final parameter PS.Current I_nom=par.S_nom/par.V_nom;
PS.Voltage[2] v_dq "voltage demand {v_d, v_q} pu";
PS.Current[2] i_dq "current demand {i_d, i_q} pu";
initial equation
phi_el = phi_el_start;
equation
if par.excite==1 then
assert(false, "machine-parameter must be excite = 2 (pm) or 3 (reluctance)");
elseif par.excite==2 then
psi_e = c.Psi_pm; // = par.psi_pm*(par.V_nom/c.omega_nom)
v_rd[1] = 0;
elseif par.excite==3 then
psi_e = 0;
v_rd[1] = 0;
end if;
i_meas = i_s[1:2]/I_nom;
i_dq = i_act*I_nom;
v_dq = w_el*{-c.L_s[2]*i_dq[2],c.L_s[1]*i_dq[1] + c.L_md[1]*i_rd[1] + psi_e}
+ c.R_s*i_dq;
vPhasor = {sqrt(v_dq*v_dq)/par.V_nom,atan2(v_dq[2], v_dq[1])};
end Synchron_pm_ctrl;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model ACmachine "AC machine base, 3-phase dq0"
extends Ports.YDport_p(i(start = i_start));
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter PS.Current[3] i_start = zeros(3)
"start value of current conductor"
parameter SI.Angle phi_el_start=0 "initial rotor angle electric"
parameter Integer pp=1 "pole-pair number";
SI.Angle phi_el(stateSelect=StateSelect.prefer, start=phi_el_start)
"rotor angle electric (syn: +pi/2)";
SI.AngularVelocity w_el "rotor angular velocity el";
SI.Torque tau_el "electromagnetic torque";
Interfaces.Rotation_n airgap "electro-mechanical connection"
Interfaces.ThermalV_n heat(m=2) "heat source port {stator, rotor}"
protected
outer System system;
SI.AngularFrequency[2] omega;
function atan2 = Modelica.Math.atan2;
equation
omega = der(term.theta);
pp*airgap.phi = phi_el;
airgap.tau = -pp*tau_el;
w_el = der(phi_el);
end ACmachine;
partial model AsynchronBase "Asynchronous machine base, 3-phase dq0"
extends ACmachine(final pp=par.pp, v(start={cos(system.alpha0),sin(system.alpha0),0}*par.V_nom));
output Real slip "<0: motor, >0: generator";
replaceable record Data =
PowerSystems.AC3ph.Machines.Parameters.Asynchron(f_nom=system.f_nom)
"machine parameters"
final parameter Data par "machine parameters"
protected
final parameter Integer n_r = par.n_r
"number of rotor circuits d- and q-axis";
final parameter Coefficients.Asynchron c = Utilities.Precalculation.machineAsyn(
par, top.scale);
parameter SI.Inductance L_m[n_r] = c.L_m;
parameter SI.Resistance R_r[n_r] = c.R_r;
parameter SI.Resistance R_m[n_r] = c.R_m;
parameter SI.Inductance L_r[n_r,n_r] = c.L_r;
parameter PS.Current[n_r] i_rd_start = zeros(n_r)
"start value of rotor current d_axis"
parameter PS.Current[n_r] i_rq_start = zeros(n_r)
"start value of rotor current q_axis"
PS.Voltage[n_r] v_rd=zeros(n_r) "rotor voltage d_axis, cage-rotor = 0";
PS.Voltage[n_r] v_rq=zeros(n_r) "rotor voltage q_axis, cage-rotor = 0";
PS.Current[n_r] i_rd(start = i_rd_start) "rotor current d_axis";
PS.Current[n_r] i_rq(start = i_rq_start) "rotor current q_axis";
SI.MagneticFlux[2] psi_s "magnetic flux stator dq";
SI.MagneticFlux[n_r] psi_rd "magnetic flux rotor d";
SI.MagneticFlux[n_r] psi_rq "magnetic fluxrotor q";
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(psi_s) = omega[1]*{-psi_s[2], psi_s[1]};
der(i[3]) = 0;
der(psi_rd) = omega[1]*(-psi_rq);
der(psi_rq) = omega[1]*psi_rd;
elseif dynType <> Types.Dynamics.SteadyState then
der(psi_rd) = omega[1]*(-psi_rq);
der(psi_rq) = omega[1]*psi_rd;
end if;
equation
psi_s = diagonal(c.L_s[1:2])*i[1:2] + {L_m*i_rd, L_m*i_rq};
psi_rd = L_m*i[1] + L_r*i_rd;
psi_rq = L_m*i[2] + L_r*i_rq;
if dynType <> Types.Dynamics.SteadyState then
der(psi_s) + omega[2]*{-psi_s[2], psi_s[1]} + c.R_s*i[1:2] = v[1:2];
c.L_s[3]*der(i[3]) + c.R_s*i[3] = v[3];
der(psi_rd) + (omega[2] - w_el)*(-psi_rq) + diagonal(R_r)*i_rd = v_rd;
der(psi_rq) + (omega[2] - w_el)*psi_rd + diagonal(R_r)*i_rq = v_rq;
else
omega[2]*{-psi_s[2], psi_s[1]} + c.R_s*i[1:2] = v[1:2];
c.R_s*i[3] = v[3];
(omega[2] - w_el)*(-psi_rq) + diagonal(R_r)*i_rd = v_rd;
(omega[2] - w_el)*psi_rd + diagonal(R_r)*i_rq = v_rq;
end if;
if par.neu_iso then
i_n = zeros(top.n_n);
else
v_n = c.R_n*i_n "equation neutral to ground (relevant if Y-topology)";
end if;
slip = (w_el/sum(omega) - 1);
tau_el = i[1:2]*{-psi_s[2], psi_s[1]};
heat.ports.Q_flow = -{c.R_s*i*i, diagonal(R_r)*i_rd*i_rd + diagonal(R_r)*i_rq*i_rq};
end AsynchronBase;
partial model SynTransform "Rotation transform dq"
extends ACmachine;
import Modelica.Math.Matrices.inv;
PS.Voltage[3] v_s "stator voltage dq0 in rotor-system";
PS.Current[3] i_s(each stateSelect=StateSelect.prefer, start = i_s_start)
"stator current dq0 in rotor-system";
protected
parameter PS.Current[3] i_s_start = cat(1, inv(Utilities.Transforms.rotation_dq(
phi_el_start))*i_start[1:2], {i_start[3]})
"start value of stator current dq0 in rotor-system";
SI.MagneticFlux psi_e "excitation flux";
Real[2,2] Rot_dq "Rotation reference-dq0 to rotor-dq0 system";
initial equation
if dynType == Types.Dynamics.FixedInitial then
// initialize i_s from i_start
i_start = cat(1, Rot_dq*i_s[1:2], {i_s[3]});
end if;
equation
Rot_dq =Utilities.Transforms.rotation_dq(phi_el - term.theta[2]);
v_s = cat(1, transpose(Rot_dq)*v[1:2], {v[3]});
i = cat(1, Rot_dq*i_s[1:2], {i_s[3]});
end SynTransform;
partial model Synchron3rdBase "Synchronous machine 3rd base, 3-phase dq0"
extends SynTransform(final pp=par.pp, v(start={cos(system.alpha0),sin(system.alpha0),0}*par.V_nom));
replaceable record Data =
PowerSystems.AC3ph.Machines.Parameters.Synchron3rd(f_nom=system.f_nom)
"machine parameters"
final parameter Data par "machine parameters"
protected
final parameter Coefficients.Synchron3rd c = Utilities.Precalculation.machineSyn3rd(
par,top.scale);
SI.MagneticFlux[2] psi_s "magnetic flux stator dq";
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(psi_s) = zeros(2);
der(c.L_s[3]*i_s[3]) = 0;
end if;
equation
psi_s = {c.L_s[1]*i_s[1] + psi_e, c.L_s[2]*i_s[2]};
if dynType <> Types.Dynamics.SteadyState then
der(psi_s) + w_el*{-psi_s[2], psi_s[1]} + c.R_s*i_s[1:2] = v_s[1:2];
c.L_s[3]*der(i_s[3]) + c.R_s*i_s[3] = v_s[3];
else
w_el*{-psi_s[2], psi_s[1]} + c.R_s*i_s[1:2] = v_s[1:2];
c.R_s*i_s[3] = v_s[3];
end if;
if par.neu_iso then
i_n = zeros(top.n_n);
else
v_n = c.R_n*i_n "equation neutral to ground (relevant if Y-topology)";
end if;
tau_el = i_s[1:2]*{-psi_s[2], psi_s[1]};
heat.ports.Q_flow = -{c.R_s*i_s*i_s, 0};
end Synchron3rdBase;
partial model SynchronBase "Synchronous machine base, 3-phase dq0"
extends SynTransform(final pp=par.pp,v(start={cos(system.alpha0),sin(system.alpha0),0}*par.V_nom));
replaceable record Data =
PowerSystems.AC3ph.Machines.Parameters.Synchron(f_nom=system.f_nom)
"machine parameters"
final parameter Data par "machine parameters"
protected
final parameter Integer n_d = par.n_d "number of rotor circuits d-axis";
final parameter Integer n_q = par.n_q "number of rotor circuits q-axis";
final parameter Coefficients.Synchron c = Utilities.Precalculation.machineSyn(
par, top.scale);
parameter SI.Inductance[n_d, n_d] L_rd = c.L_rd "L matrix rotor";
parameter SI.Inductance[n_q, n_q] L_rq = c.L_rq "L matrix rotor";
parameter SI.Inductance[n_d] L_md = c.L_md "L matrix mutual d-axis";
parameter SI.Inductance[n_q] L_mq = c.L_mq "L matrix mutual q-axis";
parameter SI.Resistance[n_d] R_rd = c.R_rd "R matrix rotor";
parameter SI.Resistance[n_q] R_rq = c.R_rq "R matrix rotor";
PS.Voltage[n_d] v_rd(start=ones(n_d))
"rotor voltage d-axis in rotor-system";
PS.Voltage[n_q] v_rq "rotor voltage q-axis in rotor-system";
PS.Current[n_d] i_rd(each stateSelect=StateSelect.prefer)
"rotor current d-axis in rotor-system";
PS.Current[n_q] i_rq(each stateSelect=StateSelect.prefer)
"rotor current q-axis in rotor-system";
SI.MagneticFlux[2] psi_s "magnetic flux stator dq";
SI.MagneticFlux[n_d] psi_rd "magnetic flux rotor d";
SI.MagneticFlux[n_q] psi_rq "magnetic fluxrotor q";
PS.Voltage v_f "field voltage (not scaled to stator units)";
PS.Current i_f "field current (not scaled to stator units)";
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(psi_s) = zeros(2);
der(c.L_s[3]*i_s[3]) = 0;
der(psi_rd) = zeros(n_d);
der(psi_rq) = zeros(n_q);
elseif dynType <> Types.Dynamics.SteadyState then
der(psi_rd) = zeros(n_d);
der(psi_rq) = zeros(n_q);
end if;
equation
v_rd[2:end] = zeros(n_d - 1);
v_rq = zeros(n_q);
psi_s = diagonal(c.L_s[1:2])*i_s[1:2] + {L_md*i_rd + psi_e, L_mq*i_rq};
psi_rd = L_md*i_s[1] + L_rd*i_rd;
psi_rq = L_mq*i_s[2] + L_rq*i_rq;
v_f = v_rd[1]/c.wf;
i_f = i_rd[1]*c.wf;
if dynType <> Types.Dynamics.SteadyState then
der(psi_s) + w_el*{-psi_s[2], psi_s[1]} + c.R_s*i_s[1:2] = v_s[1:2];
c.L_s[3]*der(i_s[3]) + c.R_s*i_s[3] = v_s[3];
der(psi_rd) + diagonal(R_rd)*i_rd = v_rd;
der(psi_rq) + diagonal(R_rq)*i_rq = v_rq;
else
w_el*{-psi_s[2], psi_s[1]} + c.R_s*i_s[1:2] = v_s[1:2];
c.R_s*i_s[3] = v_s[3];
diagonal(R_rd)*i_rd = v_rd;
diagonal(R_rq)*i_rq = v_rq;
end if;
if par.neu_iso then
i_n = zeros(top.n_n);
else
v_n = c.R_n*i_n "equation neutral to ground (relevant if Y-topology)";
end if;
tau_el = i_s[1:2]*{-psi_s[2], psi_s[1]};
heat.ports.Q_flow = -{c.R_s*i_s*i_s, diagonal(R_rd)*i_rd*i_rd + diagonal(R_rq)*i_rq*i_rq};
end SynchronBase;
end Partials;
package Control
extends Modelica.Icons.Package;
model Excitation "Excitation (electric part)"
extends Ports.Port_p;
parameter PS.Voltage V_nom=1 "nom voltage armature"
parameter PS.Voltage Vf_nom=1 "nom voltage field-winding"
Modelica.Blocks.Interfaces.RealOutput[3] termVoltage(each final unit="1")
"terminal voltage pu to exciter control"
Modelica.Blocks.Interfaces.RealInput fieldVoltage(final unit="1")
"field voltage pu from exciter control"
AC1ph_DC.Ports.TwoPin_n field "to generator field-winding"
equation
term.i = zeros(3);
termVoltage = term.v/V_nom;
field.v = {fieldVoltage*Vf_nom, 0};
end Excitation;
model PowerAngle "Direct determination of generator power angle"
extends Ports.Port_p;
outer System system;
parameter Integer pp=1 "pole-pair number";
parameter SI.Angle delta=0 "power angle";
parameter SI.AngularFrequency gamma=1 "inverse time constant";
SI.Angle phi_el(start=delta-pi/2+system.alpha0) "rotor angle";
Interfaces.Rotation_n airgap( phi(start=(delta-pi/2+system.alpha0)/pp))
"to airgap of generator"
protected
function atan2 = Modelica.Math.atan2;
equation
term.i = zeros(3);
pp*airgap.phi = phi_el;
phi_el = delta + atan2(-term.v[1], term.v[2]) + term.theta[2]; // steady state!
// der(phi_el) = gamma*(delta + atan2(-term.v[1], term.v[2]) + term.theta[2] - phi_el);
end PowerAngle;
end Control;
package Parameters "Parameter data for interactive use"
extends Modelica.Icons.MaterialPropertiesPackage;
record Asynchron3rd "Asynchronous machine 3rd order parameters"
extends PowerSystems.Common.Nominal.NominalDataAC;
Boolean neu_iso "isolated neutral if Y"
Integer pp "pole-pair number"
SIpu.Reactance x "total reactance d- and q-axis"
SIpu.Reactance x_0 "reactance 0-axis"
SIpu.Resistance r_s "resistance stator"
SIpu.Resistance r_n "resistance neutral to grd (if Y)"
end Asynchron3rd;
record Asynchron "Asynchronous machine parameters"
extends Asynchron3rd;
parameter Integer n_r(min=0) "# rotor circuits d- and q-axis";
Boolean transDat "use transient data"
Boolean use_xtr "use x_transient and t_closed"
SIpu.Reactance[n_r] xtr "transient reactance {xtr', xtr'', ..}"
SI.Time[n_r] tc "time constant closed-loop {tc', tc'', ..}"
SI.Time[n_r] to "time constant open-loop {to', to'', ..}"
SIpu.Reactance xsig_s "leakage reactance stator"
SIpu.Reactance[n_r] xsig_r "leakage reactance rotor"
SIpu.Resistance[n_r] r_r "resistance rotor"
end Asynchron;
record Asynchron3rd_cage "Asynchronous machine 3rd order parameters"
extends Asynchron3rd(
neu_iso=false,
pp=1,
x=4,
x_0=0.1,
r_s=0.04,
r_n=1);
end Asynchron3rd_cage;
record Asynchron_cage "Asynchronous machine parameters"
extends Asynchron(
neu_iso=false,
pp=1,
x=4,
x_0=0.1,
r_s=0.04,
r_n=1,
n_r=1,
transDat=true,
use_xtr=true,
xtr={0.4844},
tc={0.03212},
to={0.2653},
xsig_s=0.25,
xsig_r={0.25},
r_r={0.04});
end Asynchron_cage;
record Synchron3rd "Synchronous machine 3rd order parameters"
extends PowerSystems.Common.Nominal.NominalDataAC;
Boolean neu_iso "isolated neutral if Y"
Integer pp "pole-pair number"
Integer excite(min=0,max=3) "excitation (1:el, 2:pm, 3:reluctance)"
SIpu.MagneticFlux psi_pm
"magnetisation (V/V_nom at open term at omega_nom)"
SIpu.Reactance x_d "syn reactance d-axis"
SIpu.Reactance x_q "syn reactance q-axis"
SIpu.Reactance x_0 "reactance 0-axis"
SIpu.Resistance r_s "resistance armature"
SIpu.Resistance r_n "resistance neutral to grd (if Y)"
end Synchron3rd;
record Synchron "Synchronous machine parameters"
extends Synchron3rd;
parameter Integer n_d(min=1) "# rotor circuits d-axis";
parameter Integer n_q(min=0) "# rotor circuits q-axis";
Boolean transDat "use transient data?"
Boolean use_xtr "use x_transient and t_closed?"
SIpu.Reactance[n_d] xtr_d "trans reactance d-axis {xtr_d', xtr_d'', ..}"
SIpu.Reactance[n_q] xtr_q "trans reactance q-axis {xtr_q', xtr_q'', ..}"
SI.Time[n_d] tc_d "time constant closed-loop d-axis {tc_d', tc_d'', ..}"
SI.Time[n_q] tc_q "time constant closed-loop q-axis {tc_q', tc_q'', ..}"
SI.Time[n_d] to_d "time constant open-loop d-axis {to_d', to_d'', ..}"
SI.Time[n_q] to_q "time constant open-loop q-axis {to_q', to_q'', ..}"
Boolean use_if0 "induced field current and phase available?"
SIpu.Current if0 "induced field current at v_s=Vnom/0deg"
SI.Angle alpha_if0 "angle(if0) at v_s=Vnom/0deg (sign: i_f behind v_s)"
Real tol "tolerance precalculation"
SIpu.Reactance xsig_s "leakage reactance armature"
SIpu.Reactance[n_d] xsig_rd "leakage reactance rotor d-axis {f, D, ..}"
SIpu.Reactance[n_q] xsig_rq "leakage reactance rotor q-axis {Q1, ..}"
SIpu.Reactance[n_d-1] xm_d "coupling-reactance d-axis {xm1, ..}"
SIpu.Resistance[n_d] r_rd "resistance rotor d-axis {f, D, ..}"
SIpu.Resistance[n_q] r_rq "resistance rotor q-axis {Q1, ..}"
SI.Current If_nom "nom field current (V=V_nom at open term)"
end Synchron;
record Synchron3rd_ee "Synchronous machine 3rd order parameters"
extends Synchron3rd(
neu_iso=false,
pp=1,
final excite=1,
final psi_pm=0,
x_d=1.9,
x_q=1.77,
x_0=0.1,
r_s=0.005,
r_n=1);
end Synchron3rd_ee;
record Synchron_ee "Synchronous machine parameters"
extends Synchron(
neu_iso=false,
pp=1,
final excite=1,
final psi_pm=0,
x_d=1.9,
x_q=1.77,
x_0=0.1,
r_s=0.005,
r_n=1,
n_d=2,
n_q=2,
transDat=true,
use_xtr=true,
xtr_d={0.33,0.25},
xtr_q={0.44,0.27},
tc_d={0.86, 0.025},
tc_q={0.25, 0.04},
to_d={4.9898, 0.032747},
to_q={1.0867, 0.060327},
use_if0=true,
if0=0.85,
alpha_if0=-1.7453292519943,
tol=1e-6,
xsig_s=0.17,
xsig_rd={0.135194,0.0365214},
xsig_rq={0.407386,0.144502},
xm_d={0.0555125},
r_rd={1.32139e-3, 14.376e-3},
r_rq={7.38411e-3, 19.7148e-3},
If_nom=1);
// example: V_nom=20e3, S_nom=500e6, If_nom=1500.
end Synchron_ee;
record Synchron3rd_pm "Synchronous machine pm 3rd order parameters"
extends Synchron3rd(
neu_iso=false,
pp=2,
final excite=2,
psi_pm=1.2,
x_d=0.4,
x_q=0.4,
x_0=0.1,
r_s=0.05,
r_n=1);
end Synchron3rd_pm;
record Synchron_pm "Synchronous machine pm parameters"
extends Synchron(
neu_iso=false,
pp=2,
final excite=2,
psi_pm=1.2,
x_d=0.4,
x_q=0.4,
x_0=0.1,
r_s=0.05,
r_n=1,
n_d=1,
n_q=1,
transDat=true,
use_xtr=true,
xtr_d={0.142857},
xtr_q={0.142857},
tc_d={0.00994718},
tc_q={0.00994718},
to_d={0.0278521},
to_q={0.0278521},
use_if0=false,
if0=0,
alpha_if0=0,
tol=1e-6,
xsig_s=0.1,
xsig_rd={0.05},
xsig_rq={0.05},
xm_d=fill(0, 0),
r_rd={0.04},
r_rq={0.04},
If_nom=0);
end Synchron_pm;
record Synchron3rd_reluctance "Synchronous machine pm 3rd order parameters"
extends Synchron3rd(
neu_iso=false,
pp=2,
final excite=3,
final psi_pm=0,
x_d=2.0,
x_q=0.6,
x_0=0.1,
r_s=0.05,
r_n=1);
end Synchron3rd_reluctance;
end Parameters;
package Coefficients "Coefficient matrices of machine equations"
extends Modelica.Icons.MaterialPropertiesPackage;
record Asynchron "Coefficient matrices of asynchronous machine"
extends Modelica.Icons.Record;
parameter Integer n_r "number of rotor circuits";
SI.Inductance[3] L_s "L matrix stator dq0, d=q";
SI.Inductance[n_r, n_r] L_r "L matrix rotor";
SI.Inductance[n_r] L_m "L matrix mutual";
SI.Resistance R_s "R matrix stator";
SI.Resistance[n_r] R_r "R matrix rotor";
SI.Resistance R_n "resistance neutral to grd (if Y)";
SI.Resistance[n_r] R_m "= diagonal(R_r)*inv(L_r)*L_m";
end Asynchron;
record Synchron3rd "Coefficient matrices of synchronous machine, 3rd order"
extends Modelica.Icons.Record;
SI.Inductance[3] L_s "L matrix stator dq0";
SI.Resistance R_s "R stator (armature)";
SI.Resistance R_n "resistance neutral to grd (if Y)";
SI.MagneticFlux Psi_pm "flux permanent magnet";
SI.AngularFrequency omega_nom;
end Synchron3rd;
record Synchron "Coefficient matrices of synchronous machine"
extends Modelica.Icons.Record;
parameter Integer n_d "number of rotor circuits d-axis";
parameter Integer n_q "number of rotor circuits q-axis";
SI.Inductance[3] L_s "L matrix stator dq0";
SI.Inductance[n_d, n_d] L_rd "L matrix rotor";
SI.Inductance[n_q, n_q] L_rq "L matrix rotor";
SI.Inductance[n_d] L_md "L matrix mutual d-axis";
SI.Inductance[n_q] L_mq "L matrix mutual q-axis";
SI.Resistance R_s "R stator (armature)";
SI.Resistance[n_d] R_rd "R matrix rotor";
SI.Resistance[n_q] R_rq "R matrix rotor";
SI.Resistance R_n "resistance neutral to grd (if Y)";
SI.MagneticFlux Psi_pm "flux permanent magnet";
Real wf "ratio field winding";
SI.Voltage Vf_nom "nom voltage field winding";
SI.AngularFrequency omega_nom;
end Synchron;
end Coefficients;
end Machines; |
Nodes and adaptors | within PowerSystems.AC3ph;
package Nodes "Nodes and adaptors"
extends Modelica.Icons.VariantsPackage;
model Ground "AC Ground, 3-phase dq0"
extends Ports.Port_p;
equation
term.v = zeros(PS.n);
end Ground;
model GroundOne "Ground, one conductor"
Interfaces.Electric_p term "positive scalar terminal"
equation
term.v = 0;
end GroundOne;
model BusBar "Busbar, 3-phase dq0"
extends Ports.PortBase;
output PS.Voltage v_norm(stateSelect=StateSelect.never);
output SI.Angle alpha_v(stateSelect=StateSelect.never);
Ports.ACdq0_p term "bus bar"
protected
Real[2,2] R=Utilities.Transforms.rotation_dq(term.theta[1]);
function atan2 = Modelica.Math.atan2;
equation
term.i = zeros(PS.n);
v_norm = sqrt(term.v*term.v);
alpha_v = atan2(R[:, 2]*term.v[1:2], R[:, 1]*term.v[1:2]);
end BusBar;
/*
model Y_Delta "Y_Delta switch, 3-phase dq0"
extends Ports.PortBase;
Ports.ACdq0_p term_p
"connect to non source side of windings"
Ports.ACdq0_n term_n
"connect to source side of windings"
Interfaces.ElectricV_n switchY_D( final m=3)
"connect to switch 'commute' position"
Interfaces.ElectricV_p switchD( final m=3)
"connect to switch 'Delta' position"
Interfaces.ElectricV_p switchY( final m=3)
"connect to switch 'Y' position"
Interfaces.Electric_n neutral "neutral Y"
protected
Real[3,3] Park = Basic.Transforms.park(
term_p.theta[2]);
equation
switchY_D.pin.v = transpose(Park)*term_p.v;
term_p.i + Park*switchY_D.pin.i = zeros(3);
switchY.pin.v = fill(neutral.v, 3);
sum(switchY.pin.i) + neutral.i = 0;
switchD.pin[{3,1,2}].v = transpose(Park)*term_n.v;
term_n.i + Park*switchD.pin[{3,1,2}].i = zeros(3);
end Y_Delta;
*/
model Ynode "Y-node with neutral-access, 3-phase dq0"
extends Ports.Port_p;
Interfaces.Electric_n neutral "neutral Y"
equation
term.v[3] = sqrt(3)*neutral.v;
term.i[1:2] = {0, 0};
neutral.i + sqrt(3)*term.i[3] = 0;
end Ynode;
model ResistiveGround "Y-node with neutral-access, 3-phase dq0"
extends Ports.Yport_p;
extends Common.Nominal.Nominal;
parameter SIpu.Resistance r_n=0 "resistance neutral to grd";
protected
final parameter Real R_base=Utilities.Precalculation.baseR(
puUnits,
V_nom,
S_nom);
final parameter SI.Resistance R_n=r_n*R_base;
equation
v = zeros(3);
R_n*i_n = v_n "equation neutral to ground";
end ResistiveGround;
model InductiveGround "Y-node with neutral-access, 3-phase dq0"
extends Ports.Yport_p;
extends Common.Nominal.NominalAC;
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter SIpu.Reactance x_n=1 "reactance neutral to grd";
parameter SIpu.Resistance r_n=0 "resistance neutral to grd";
protected
final parameter Real R_base=Utilities.Precalculation.baseR(
puUnits,
V_nom,
S_nom);
final parameter SI.Inductance L_n=x_n*R_base/(2*pi*f_nom);
final parameter SI.Resistance R_n=r_n*R_base;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i_n) = 0;
end if;
equation
v = zeros(3);
if dynType <> Types.Dynamics.SteadyState then
L_n*der(i_n) + R_n*i_n = v_n;
else
R_n*i_n = v_n;
end if;
end InductiveGround;
model CapacitiveGround "Y-node with neutral-access, 3-phase dq0"
extends Ports.Yport_p;
extends Common.Nominal.NominalAC;
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter SIpu.Susceptance b_n=1 "susceptance neutral to grd";
parameter SIpu.Conductance g_n=0 "conductance neutral to grd";
protected
final parameter Real R_base=Utilities.Precalculation.baseR(
puUnits,
V_nom,
S_nom);
final parameter SI.Capacitance C_n=b_n/(R_base*2*pi*f_nom);
final parameter SI.Conductance G_n=g_n/R_base;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i_n) = 0;
end if;
equation
v = zeros(3);
if dynType <> Types.Dynamics.SteadyState then
C_n*der(v_n) + G_n*v_n = i_n;
else
G_n*v_n = i_n;
end if;
end CapacitiveGround;
model Y_OnePhase "Terminator, ACdq0 to an, bn, cn"
extends Ports.Port_p;
extends Icons.Adaptor_dq0;
Interfaces.Electric_p neutral "neutral Y"
AC1ph_DC.Ports.TwoPin_n plug_a "phase a and neutral"
AC1ph_DC.Ports.TwoPin_n plug_b "phase b and neutral"
AC1ph_DC.Ports.TwoPin_n plug_c "phase c and neutral"
protected
Real[3,3] P=Utilities.Transforms.park(term.theta[2]);
equation
plug_a.v = cat(1, transpose(P[:, 1:1])*term.v, {neutral.v});
plug_b.v = cat(1, transpose(P[:, 2:2])*term.v, {neutral.v});
plug_c.v = cat(1, transpose(P[:, 3:3])*term.v, {neutral.v});
term.i + P*{plug_a.i[1], plug_b.i[1], plug_c.i[1]} = zeros(3);
end Y_OnePhase;
model ACdq0_a_b_c "Adaptor ACdq0 to pins a, b, c"
extends Ports.Port_p;
extends PowerSystems.Icons.Adaptor_dq0;
Interfaces.Electric_n term_a "phase a"
Interfaces.Electric_n term_b "phase b"
Interfaces.Electric_n term_c "phase c"
protected
Real[3,3] P=Utilities.Transforms.park(term.theta[2]);
equation
{term_a.v,term_b.v,term_c.v} = transpose(P)*term.v;
term.i + P*{term_a.i,term_b.i,term_c.i} = zeros(3);
end ACdq0_a_b_c;
/*
model ACdq0_abc "Adaptor ACdq0 to 3-vector abc"
extends Ports.Port_p;
extends Basic.Icons.Adaptor_dq0;
Interfaces.ElectricV_n term_abc( final m=3) "phase abc vector-pin"
protected
Real[3,3] P = Basic.Transforms.park(
term.theta[2]);
equation
term_abc.pin.v = transpose(P)*term.v;
term.i + P*term_abc.pin.i = zeros(3);
end ACdq0_abc;
*/
model DefReference "Defines reference frame, 3phase dq0"
extends Ports.PortBase;
outer System system;
Ports.ACdq0_p term "bus bar"
Modelica.Blocks.Interfaces.RealInput theta "absolute angle"
equation
term.i = zeros(PS.n);
Connections.potentialRoot(term.theta);
if Connections.isRoot(term.theta) then
term.theta = if system.synRef then {0, theta} else {theta, 0};
end if;
end DefReference;
model Break "Breaks transmission of term.theta, 3phase dq0"
extends Ports.PortBase;
Ports.ACdq0_p term_p "positive terminal"
Ports.ACdq0_n term_n "negative terminal"
equation
term_p.v = term_n.v;
term_p.i + term_n.i = zeros(PS.n);
end Break;
end Nodes; |
AC three phase components from Spot ACdq0 | within PowerSystems;
package AC3ph "AC three phase components from Spot ACdq0"
extends Modelica.Icons.VariantsPackage;
replaceable package PackagePhaseSystem = PhaseSystems.ThreePhase_dq0
"Default phase system for AC3ph"
end AC3ph; |
AC three-phase ports dq0 representation | within PowerSystems.AC3ph;
package Ports "AC three-phase ports dq0 representation"
extends Modelica.Icons.InterfacesPackage;
partial model PortBase "base model adapting Spot to PowerSystems"
package PS = PackagePhaseSystem;
function j = PS.j
function jj = PS.jj
function j_dq0 = PhaseSystems.ThreePhase_dq0.j
function jj_dq0 = PhaseSystems.ThreePhase_dq0.jj
end PortBase;
connector ACdq0_p "AC terminal, 3-phase dq0 ('positive')"
extends Interfaces.Terminal(redeclare package PhaseSystem =
PackagePhaseSystem);
end ACdq0_p;
connector ACdq0_n "AC terminal, 3-phase dq0 ('negative')"
extends Interfaces.Terminal(redeclare package PhaseSystem =
PackagePhaseSystem);
end ACdq0_n;
partial model Port_p "AC one port 'positive', 3-phase"
extends PortBase;
Ports.ACdq0_p term "positive terminal"
end Port_p;
partial model Port_n "AC one port 'negative', 3-phase"
extends PortBase;
Ports.ACdq0_n term "negative terminal"
end Port_n;
partial model Port_f "AC one port 'fault', 3-phase"
extends PortBase;
Ports.ACdq0_p term "fault terminal"
end Port_f;
partial model Port_p_n "AC two port, 3-phase"
extends PortBase;
Ports.ACdq0_p term_p "positive terminal"
Ports.ACdq0_n term_n "negative terminal"
equation
Connections.branch(term_p.theta, term_n.theta);
term_n.theta = term_p.theta;
end Port_p_n;
partial model Port_pn "AC two port 'current_in = current_out', 3-phase"
extends Port_p_n;
equation
term_p.i + term_n.i = zeros(PS.n);
end Port_pn;
partial model Port_p_n_f "AC three port, 3-phase"
extends Port_p_n;
Ports.ACdq0_n term_f "fault terminal"
equation
Connections.branch(term_p.theta, term_f.theta);
term_f.theta = term_p.theta;
end Port_p_n_f;
partial model Yport_p "AC one port Y topology 'positive'"
extends Port_p;
PS.Voltage[PS.n] v "voltage terminal to neutral";
PS.Current[PS.n] i "current terminal in";
PS.Voltage v_n(final start=0) "voltage neutral";
PS.Current i_n(final start=0) "current neutral";
equation
v = term.v - PS.map({0, 0, sqrt(3)*v_n});
term.i = i;
if PS.n > 2 then
i_n = sqrt(3)*term.i[3];
else
i_n = 0;
end if;
end Yport_p;
partial model Yport_n "AC one port Y topology 'negative'"
extends Port_n;
PS.Voltage[PS.n] v "voltage terminal to neutral";
PS.Current[PS.n] i "current terminal in";
PS.Voltage v_n(final start=0) "voltage neutral";
PS.Current i_n(final start=0) "current neutral";
equation
v = term.v - PS.map({0, 0, sqrt(3)*v_n});
term.i = i;
if PS.n > 2 then
i_n = sqrt(3)*term.i[3];
else
i_n = 0;
end if;
end Yport_n;
partial model YDport_p "AC one port Y or Delta topology 'positive'"
extends Port_p;
/*
replaceable Topology.Y top "Y or Delta topology"
*/
replaceable model Topology_p = Topology.Y constrainedby Topology.TopologyBase
"Y or Delta topology"
Topology_p top(v_cond=v, i_cond=i, v_n=v_n)
PS.Voltage[PS.n] v "voltage conductor";
PS.Current[PS.n] i "current conductor";
PS.Voltage[n_n] v_n "voltage neutral";
PS.Current[n_n] i_n=top.i_n "current neutral to ground";
protected
final parameter Integer n_n=top.n_n
equation
term.v = top.v_term;
term.i = top.i_term;
end YDport_p;
partial model YDport_n "AC one port Y or Delta topology 'positive'"
extends Port_n;
replaceable model Topology_n = Topology.Y constrainedby Topology.TopologyBase
"Y or Delta topology"
Topology_n top(v_cond=v, i_cond=i, v_n=v_n) "Y or Delta topology"
PS.Voltage[PS.n] v "voltage conductor";
PS.Current[PS.n] i "current conductor";
PS.Voltage[n_n] v_n "voltage neutral";
PS.Current[n_n] i_n=top.i_n "current neutral to ground";
protected
final parameter Integer n_n=top.n_n
equation
term.v = top.v_term;
term.i = top.i_term;
end YDport_n;
partial model Y_Dport_p "AC two port, switcheable Y-Delta topology"
extends Port_p;
replaceable model Topology_p = Topology.Y_Delta constrainedby
Topology.TopologyBase "Y-Delta switcheable"
Topology_p top(v_cond=v, i_cond=i, control=YDcontrol) "Y-Delta switcheable"
PS.Voltage[PS.n] v "voltage conductor";
PS.Current[PS.n] i "current conductor";
Modelica.Blocks.Interfaces.BooleanInput YDcontrol "true:Y, false:Delta"
equation
term.v = top.v_term;
term.i = top.i_term;
/*
connect(YDcontrol, top.control)
*/
end Y_Dport_p;
partial model YDportTrafo_p_n
"AC two port with Y or Delta topology for transformers"
extends Port_p_n;
replaceable model Topology_p = Topology.Y constrainedby Topology.TopologyBase
"p: Y, Delta or PAR topology"
Topology_p top_p(v_cond=v1, i_cond=i1, v_n=v_n1, w=w1)
"p: Y, Delta or PAR topology"
replaceable model Topology_n = Topology.Y constrainedby Topology.TopologyBase
"n: Y, Delta or PAR topology"
Topology_n top_n(v_cond=v2*w2_nom, i_cond=i2/w2_nom, v_n=v_n2, w=w2)
"n: Y, Delta or PAR topology"
PS.Voltage[PS.n] v1 "voltage conductor";
PS.Current[PS.n] i1 "current conductor";
PS.Voltage[n_n1] v_n1 "voltage neutral";
PS.Current[n_n1] i_n1=top_p.i_n "current neutral to ground";
PS.Voltage[PS.n] v2 "voltage conductor";
PS.Current[PS.n] i2 "current conductor";
PS.Voltage[n_n2] v_n2 "voltage neutral";
PS.Current[n_n2] i_n2=top_n.i_n "current neutral to ground";
protected
constant Integer[2] scale={top_p.scale, top_n.scale};
final parameter Integer n_n1=top_p.n_n
final parameter Integer n_n2=top_n.n_n
Real w1 "1: voltage ratio to nominal for topology";
Real w2 "2: voltage ratio to nominal for topology";
Real w2_nom "2: nominal turns ratio";
equation
term_p.v = top_p.v_term;
term_p.i = top_p.i_term;
term_n.v = top_n.v_term;
term_n.i = top_n.i_term;
end YDportTrafo_p_n;
partial model YDportTrafo_p_n_n
"AC three port with Y or Delta topology for 3-winding transformers"
extends PortBase;
Ports.ACdq0_p term_p "positive terminal"
Ports.ACdq0_n term_na "negative terminal a"
Ports.ACdq0_n term_nb "negative terminal b"
replaceable model Topology_p = Topology.Y constrainedby Topology.TopologyBase
"p: Y or Delta topology"
Topology_p top_p(v_cond=v1, i_cond=i1, v_n=v_n1, w=w1)
"p: Y or Delta topology"
replaceable model Topology_na = Topology.Y constrainedby
Topology.TopologyBase "na: Y or Delta topology"
Topology_na top_na(v_cond=v2a*w2a_nom, i_cond=i2a/w2a_nom, v_n=v_n2a, w=w2a)
"na: Y or Delta topology"
replaceable model Topology_nb = Topology.Y constrainedby
Topology.TopologyBase "nb: Y or Delta topology"
Topology_nb top_nb(v_cond=v2b*w2b_nom, i_cond=i2b/w2b_nom, v_n=v_n2b, w=w2b)
"nb: Y or Delta topology"
PS.Voltage[PS.n] v1 "voltage conductor";
PS.Current[PS.n] i1 "current conductor";
PS.Voltage[n_n1] v_n1 "voltage neutral";
PS.Current[n_n1] i_n1=top_p.i_n "current neutral to ground";
PS.Voltage[PS.n] v2a "voltage conductor";
PS.Current[PS.n] i2a "current conductor";
PS.Voltage[n_n2a] v_n2a "voltage neutral";
PS.Current[n_n2a] i_n2a=top_na.i_n "current neutral to ground";
PS.Voltage[PS.n] v2b "voltage conductor";
PS.Current[PS.n] i2b "current conductor";
PS.Voltage[n_n2b] v_n2b "voltage neutral";
PS.Current[n_n2b] i_n2b=top_nb.i_n "current neutral to ground";
PS.Voltage[PS.n] v0;
protected
constant Integer[3] scale={top_p.scale, top_na.scale, top_nb.scale};
final parameter Integer n_n1=top_p.n_n
final parameter Integer n_n2a=top_na.n_n
final parameter Integer n_n2b=top_nb.n_n
Real w1 "1: voltage ratio to nominal for topology";
Real w2a "2a: voltage ratio to nominal for topology";
Real w2b "2b: voltage ratio to nominal for topology";
Real w2a_nom "2a: nominal turns ratio";
Real w2b_nom "2b: nominal turns ratio";
equation
Connections.branch(term_p.theta, term_na.theta);
Connections.branch(term_p.theta, term_nb.theta);
term_na.theta = term_p.theta;
term_nb.theta = term_p.theta;
term_p.v = top_p.v_term;
term_p.i = top_p.i_term;
term_na.v = top_na.v_term;
term_na.i = top_na.i_term;
term_nb.v = top_nb.v_term;
term_nb.i = top_nb.i_term;
end YDportTrafo_p_n_n;
package Topology "Topology transforms "
extends Modelica.Icons.BasesPackage;
partial model TopologyBase "Topology transform base"
extends PortBase;
constant Integer scale "for scaling of impedance values";
parameter Integer n_n(min=0,max=1)=1 "1 for Y, 0 for Delta";
PS.Voltage[PS.n] v_term "terminal voltage";
PS.Current[PS.n] i_term "terminal current";
input PS.Voltage[PS.n] v_cond "conductor voltage";
input PS.Current[PS.n] i_cond "conductor current";
input PS.Voltage[n_n] v_n(start=fill(0,n_n)) "voltage neutral";
input Real w = 1 "voltage ratio to nominal";
PS.Current[n_n] i_n(start=fill(0,n_n)) "current neutral to ground";
protected
constant Real s3=sqrt(3);
end TopologyBase;
model Y "Y transform"
extends TopologyBase(final scale=1, final n_n=1);
equation
w*v_cond = v_term - PS.map({0, 0, s3*v_n[1]});
i_term = i_cond/w;
if PS.n > 2 then
i_n[1] = s3*i_term[3];
else
i_n[1] = 0;
end if;
end Y;
model Delta "Delta transform"
extends TopologyBase(final scale=3, final n_n=0);
parameter Integer shift(min=0, max=11) = 1 "(0, 1 .. 11)*30deg phase shift"
protected
Real[2,2] Rot = Utilities.Transforms.rotation_dq(shift*pi/6)*s3/w;
equation
v_cond[1:2] = Rot*v_term[1:2];
i_term[1:2] = i_cond[1:2]*Rot;
if PS.n > 2 then
v_cond[3] = 0;
i_term[3] = 0;
end if;
end Delta;
model Y_Delta "Y Delta switcheble transform"
extends TopologyBase(final scale=1, final n_n=1);
/*
Modelica.Blocks.Interfaces.BooleanInput control "true:Y, false:Delta"
*/
input Boolean control "true:Y, false:Delta";
// in switcheable topology impedance defined as WINDING-impedance (i.e. Y-topology)
protected
parameter SI.Conductance epsG=1e-5;
constant Real[2,2] Rot=Utilities.Transforms.rotation_dq(pi/6);
equation
if control then
w*v_cond = v_term - {0, 0, s3*v_n[1]};
i_term = i_cond/w;
i_n[1] = s3*i_term[3];
else
w*v_cond[1:2] = s3*Rot*v_term[1:2];
v_cond[3] = 0;
i_term[1:2] = s3*transpose(Rot)*i_cond[1:2]/w;
i_term[3] = 0;
i_n[1] = 0;
end if;
//i_n[1] = epsG*v_n[1]; // neutral point isolated
end Y_Delta;
model Y_DeltaRegular "Y Delta switcheble transform, eps-regularised"
extends TopologyBase(final scale=1, final n_n=1);
/*
Modelica.Blocks.Interfaces.BooleanInput control "true:Y, false:Delta"
*/
input Boolean control "true:Y, false:Delta";
// in switcheable topology impedance defined as WINDING-impedance (i.e. Y-topology)
protected
parameter SI.Conductance epsG=1e-5;
parameter SI.Resistance epsR=1e-5;
constant Real[2,2] Rot=Utilities.Transforms.rotation_dq(pi/6);
SI.Current[3] i_neu;
SI.Current[3] i_del;
equation
i_term[1:2] = i_cond[1:2]/w - Rot*{-i_del[2], i_del[1]};
i_term[3] = i_cond[3]/w - i_del[3];
i_cond/w = i_neu + i_del;
i_n[1] = s3*i_neu[3];
if control then
w*v_cond = v_term - {0, 0, s3*v_n[1]} - epsR*i_neu;
i_del[1:2] = epsG*(s3*Rot*v_term[1:2] - w*v_cond[1:2]);
i_del[3] = -epsG*w*v_cond[3];
else
w*v_cond[1:2] = s3*Rot*v_term[1:2] - epsR*i_del[1:2];
w*v_cond[3] = -epsR*i_del[3];
i_neu = epsG*(v_term - w*v_cond - {0, 0, s3*v_n[1]});
end if;
//i_n[1] = epsG*v_n[1]; // neutral point isolated
end Y_DeltaRegular;
model PAR "Phase angle regulating (quadrature booster)"
extends PowerSystems.AC3ph.Ports.Topology.TopologyBase(
final scale=1, final n_n=1);
SI.Angle alpha = atan(w - 1) "phase shift";
protected
Real[2, 2] Rot = [1, -w+1; w-1, 1] "Transforms.rotation_dq(alpha)/cos(alpha)";
equation
v_term[1:2] = Rot*v_cond[1:2];
i_cond[1:2] = i_term[1:2]*Rot;
if PS.n > 2 then
v_term[3] = s3*v_n[1];
i_cond[3] = i_term[3];
i_n[1] = s3*i_term[3];
else
i_n[1] = 0;
end if;
end PAR;
end Topology;
end Ports; |
Sensors and meters 3-phase | within PowerSystems.AC3ph;
package Sensors "Sensors and meters 3-phase"
extends Modelica.Icons.SensorsPackage;
model VnormSensor "Voltage-norm sensor, 3-phase dq0"
extends Partials.Sensor1Base(final S_nom=1);
parameter Integer n_eval(
min=2,
max=3) = 2 "dq- or dq0-norm"
Modelica.Blocks.Interfaces.RealOutput v "voltage norm, phase-to-ground"
protected
final parameter PS.Voltage V_base=Utilities.Precalculation.baseV(
puUnits, V_nom);
equation
v = sqrt(term.v[1:n_eval]*term.v[1:n_eval])/V_base;
end VnormSensor;
model InormSensor "Current-norm sensor, 3-phase dq0"
extends Partials.Sensor2Base;
parameter Integer n_eval(
min=2,
max=3) = 2 "dq- or dq0-norm"
Modelica.Blocks.Interfaces.RealOutput i "current norm, term_p to term_n"
protected
final parameter PS.Current I_base=Utilities.Precalculation.baseI(
puUnits, V_nom, S_nom);
equation
i = sqrt(term_p.i[1:n_eval]*term_p.i[1:n_eval])/I_base;
end InormSensor;
model Vsensor "Voltage sensor, 3-phase dq0"
extends Partials.Sensor1Base(final S_nom=1);
parameter Integer signalTrsf=0 "signal in which reference frame?"
Modelica.Blocks.Interfaces.RealOutput[3] v "voltage, phase-to-ground"
protected
final parameter PS.Voltage V_base=Utilities.Precalculation.baseV(
puUnits, V_nom);
equation
if signalTrsf == 0 then
v = term.v/V_base; // actual
elseif signalTrsf == 1 then
v = cat(1, transpose(rot_dq(term.theta[1]))*term.v[1:2], term.v[3:3])/V_base; // dq0
elseif signalTrsf == 2 then
v = cat(1, rot_dq(term.theta[2])*term.v[1:2], term.v[3:3])/V_base; // alpha-beta_o
elseif signalTrsf == 3 then
v = transpose(park(term.theta[2]))*term.v/V_base; // abc
end if;
end Vsensor;
model Isensor "Current sensor, 3-phase dq0"
extends Partials.Sensor2Base;
parameter Integer signalTrsf=0 "signal in which reference frame?"
Modelica.Blocks.Interfaces.RealOutput[3] i "current, term_p to term_n"
protected
final parameter PS.Current I_base=Utilities.Precalculation.baseI(
puUnits, V_nom, S_nom);
equation
if signalTrsf == 0 then
i = term_p.i/I_base;
elseif signalTrsf == 1 then // actual
i = cat(1, transpose(rot_dq(term_p.theta[1]))*term_p.i[1:2], term_p.i[3:3])/I_base; // dq0
elseif signalTrsf == 2 then
i = cat(1, rot_dq(term_p.theta[2])*term_p.i[1:2], term_p.i[3:3])/I_base; // alpha-beta_o
elseif signalTrsf == 3 then
i = transpose(park(term_p.theta[2]))*term_p.i/I_base; // abc
end if;
end Isensor;
model Psensor "Power sensor, 3-phase dq0"
extends Partials.Sensor2Base(final V_nom=1);
Modelica.Blocks.Interfaces.RealOutput[PS.n] p
"{active, reactive, DC} power, term_p to term_n"
protected
final parameter SI.ApparentPower S_base=Utilities.Precalculation.baseS(
puUnits, S_nom);
equation
p = PS.phasePowers_vi(term_p.v, term_p.i)/S_base;
end Psensor;
model Vmeter "Voltage meter, 3-phase dq0"
extends Partials.Meter1Base(final S_nom=1);
output SIpu.Voltage[PS.n] v(each stateSelect=StateSelect.never);
output SIpu.Voltage[2] vpp(each stateSelect=StateSelect.never);
output SIpu.Voltage[3] v_abc(each stateSelect=StateSelect.never)=transpose(Park)*v if abc;
output SIpu.Voltage[3] vpp_abc(each stateSelect=StateSelect.never)=
{v_abc[2],v_abc[3],v_abc[1]} - {v_abc[3],v_abc[1],v_abc[2]} if abc;
output SIpu.Voltage v_norm(stateSelect=StateSelect.never);
output SI.Angle alpha_v(stateSelect=StateSelect.never);
protected
final parameter PS.Voltage V_base=Utilities.Precalculation.baseV(
puUnits, V_nom);
equation
v = term.v/V_base;
vpp = sqrt(3)*{v[2],-v[1]};
v_norm = sqrt(v*v);
alpha_v = atan2(Rot_dq[:,2]*v[1:2], Rot_dq[:,1]*v[1:2]);
end Vmeter;
model Imeter "Current meter, 3-phase dq0"
extends Partials.Meter2Base;
output SIpu.Current[PS.n] i(each stateSelect=StateSelect.never);
output SIpu.Current[3] i_abc(each stateSelect=StateSelect.never)=transpose(Park)*i if abc;
output SIpu.Current i_norm(stateSelect=StateSelect.never);
output SI.Angle alpha_i(stateSelect=StateSelect.never);
protected
final parameter PS.Current I_base=Utilities.Precalculation.baseI(
puUnits, V_nom, S_nom);
equation
i = term_p.i/I_base;
i_norm = sqrt(i*i);
alpha_i = atan2(Rot_dq[:,2]*i[1:2], Rot_dq[:,1]*i[1:2]);
end Imeter;
model Pmeter "Power meter, 3-phase dq0"
extends Partials.Meter2Base(final V_nom=1, final abc=false);
parameter Boolean av=false "time average power"
parameter SI.Time tcst(min=1e-9)=1 "average time-constant"
output SIpu.Power[PS.n] p(each stateSelect=StateSelect.never);
output SIpu.Power[PS.n] p_av=pav if av;
protected
outer System system;
final parameter SI.ApparentPower S_base=Utilities.Precalculation.baseS(
puUnits, S_nom);
SIpu.Power[PS.n] pav;
initial equation
if av then
pav = p;
end if;
equation
p = PS.phasePowers_vi(term_p.v, term_p.i)/S_base;
if av then
der(pav) = (p - pav)/tcst;
else
pav = zeros(PS.n);
end if;
end Pmeter;
model PVImeter "Power-voltage-current meter, 3-phase dq0"
extends Partials.Meter2Base;
parameter Boolean av=false "time average power"
parameter SI.Time tcst(min=1e-9)=1 "average time-constant"
function v2vpp_abc
input SIpu.Voltage[3] v_abc;
output SIpu.Voltage[3] vpp_abc;
algorithm
vpp_abc := {v_abc[2],v_abc[3],v_abc[1]} - {v_abc[3],v_abc[1],v_abc[2]};
end v2vpp_abc;
output SIpu.Power[PS.n] p(each stateSelect=StateSelect.never);
output SIpu.Power[PS.n] p_av=pav if av;
output SIpu.Voltage[PS.n] v(each stateSelect=StateSelect.never);
output SIpu.Voltage[2] vpp(each stateSelect=StateSelect.never);
output SIpu.Current[PS.n] i(each stateSelect=StateSelect.never);
output SIpu.Voltage[3] v_abc(each stateSelect=StateSelect.never)=transpose(Park)*v if abc;
output SIpu.Voltage[3] vpp_abc(each stateSelect=StateSelect.never)=v2vpp_abc(transpose(Park)*v) if abc;
output SIpu.Current[3] i_abc(each stateSelect=StateSelect.never)=transpose(Park)*i if abc;
output SIpu.Voltage v_norm(stateSelect=StateSelect.never);
output SI.Angle alpha_v(stateSelect=StateSelect.never);
output SIpu.Current i_norm(stateSelect=StateSelect.never);
output SI.Angle alpha_i(stateSelect=StateSelect.never);
output Real cos_phi(stateSelect=StateSelect.never);
protected
outer System system;
final parameter PS.Voltage V_base=Utilities.Precalculation.baseV(
puUnits, V_nom);
final parameter PS.Current I_base=Utilities.Precalculation.baseI(
puUnits, V_nom, S_nom);
SIpu.Power[PS.n] pav;
initial equation
if av then
pav = p;
end if;
equation
v = term_p.v/V_base;
vpp = sqrt(3)*{v[2],-v[1]};
i = term_p.i/I_base;
p = PS.phasePowers_vi(v, i);
if av then
der(pav) = (p - pav)/tcst;
else
pav = zeros(PS.n);
end if;
v_norm = sqrt(v*v);
alpha_v = atan2(Rot_dq[:,2]*v[1:2], Rot_dq[:,1]*v[1:2]);
i_norm = sqrt(i*i);
alpha_i = atan2(Rot_dq[:,2]*i[1:2], Rot_dq[:,1]*i[1:2]);
cos_phi = cos(alpha_v - alpha_i);
end PVImeter;
model Efficiency "Power sensor, 3-phase dq0"
extends Partials.Sensor2Base;
Interfaces.ThermalV_p heat( m=m) "vector heat port"
parameter Boolean dir_in=true "direction"
parameter Integer m(final min=1)=1 "dimension of heat port";
parameter Boolean av=false "time average efficiency"
parameter SI.Time tcst(min=1e-9)=1 "average time-constant"
parameter SI.Temperature T_amb=300 "ambient temperature";
output Real eta "efficiency";
protected
SI.Power p "total el power, term_p to term_n";
SI.HeatFlowRate q "total heat flow 'in'";
SI.Power pav;
SI.HeatFlowRate qav;
initial equation
if av then
pav = p;
qav = q;
end if;
equation
heat.ports.T = fill(T_amb, heat.m);
p = term_p.v*term_p.i;
q = sum(heat.ports.Q_flow);
if av then
der(pav) = (p - pav)/tcst;
der(qav) = (q - qav)/tcst;
else
pav = p;
qav = q;
end if;
if qav < abs(pav) then
if dir_in then
eta = if pav > 0 then 100*(pav - qav)/pav else -100*pav/(pav - qav);
else
eta = if pav > 0 then 100*pav/(pav + qav) else -100*(pav + qav)/pav;
end if;
else
eta = 0;
end if;
end Efficiency;
model Phasor "Visualiser of voltage and current phasor, 3-phase dq0"
extends Partials.PhasorBase;
Types.Color color_p;
Types.Color color_n;
extends Icons.LeftBar(colorL={0,127,127}, xL=x_norm*abs(p[1])/V_base/I_base);
extends Icons.RightBar(colorR={127,0,127}, xR=x_norm*abs(p[2])/V_base/I_base);
extends Icons.DoubleNeedle(
color1={255,0,0},
color2={0,0,255},
x1=r_norm*v_dq[1]/V_base,
y1=r_norm*v_dq[2]/V_base,
x2=r_norm*i_dq[1]/I_base,
y2=r_norm*i_dq[2]/I_base);
equation
color_p = if p[1]>0 then {0,127,127} else {215,215,215};
color_n = if p[1]<0 then {0,127,127} else {215,215,215};
end Phasor;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model Sensor1Base "Sensor 1 terminal base, 3-phase dq0"
extends Ports.Port_p;
extends Common.Nominal.Nominal;
protected
function park = Utilities.Transforms.park;
function rot_dq = Utilities.Transforms.rotation_dq;
equation
term.i = zeros(PS.n);
end Sensor1Base;
partial model Sensor2Base "Sensor 2 terminal base, 3-phase dq0"
extends Ports.Port_pn;
extends Common.Nominal.Nominal;
protected
function park = Utilities.Transforms.park;
function rot_dq = Utilities.Transforms.rotation_dq;
equation
term_p.v = term_n.v;
end Sensor2Base;
partial model Meter1Base "Meter 1 terminal base, 3-phase dq0"
extends Sensor1Base;
parameter Boolean abc=false "abc inertial"
protected
Real[3,3] Park;
Real[2,2] Rot_dq;
function atan2 = Modelica.Math.atan2;
equation
if abc then
Park = park(term.theta[2]);
else
Park = zeros(3,3);
end if;
Rot_dq = rot_dq(term.theta[1]);
end Meter1Base;
partial model Meter2Base "Meter 2 terminal base, 3-phase dq0"
extends Sensor2Base;
parameter Boolean abc=false "abc inertial"
protected
Real[3,3] Park;
Real[2,2] Rot_dq;
function atan2 = Modelica.Math.atan2;
equation
if abc then
Park = park(term_p.theta[2]);
else
Park = zeros(3,3);
end if;
Rot_dq = rot_dq(term_p.theta[1]);
end Meter2Base;
partial model PhasorBase "Phasor base, 3-phase dq0"
extends Ports.Port_pn;
extends Common.Nominal.Nominal(final puUnits=true);
PS.Voltage[2] v_dq;
PS.Current[2] i_dq;
SI.Power[2] p;
protected
constant Real r_norm(unit="1")=0.8 "norm radius phasor";
constant Real x_norm(unit="1")=0.8 "norm amplitude power";
final parameter PS.Voltage V_base=Utilities.Precalculation.baseV(
puUnits, V_nom);
final parameter PS.Current I_base=Utilities.Precalculation.baseI(
puUnits, V_nom, S_nom);
Real[2,2] Rot_dq=Utilities.Transforms.rotation_dq(term_p.theta[1]);
equation
term_p.v = term_n.v;
v_dq = transpose(Rot_dq)*term_p.v[1:2];
i_dq = transpose(Rot_dq)*term_p.i[1:2];
p = {v_dq*i_dq, -j_dq0(v_dq)*i_dq};
end PhasorBase;
end Partials;
end Sensors; |
Reactive and capacitive shunts | within PowerSystems.AC3ph;
package Shunts "Reactive and capacitive shunts"
extends Modelica.Icons.VariantsPackage;
model ReactiveShunt "Shunt reactor with parallel conductor, 3-phase dq0"
extends Partials.ShuntBase;
parameter SIpu.Conductance g=0 "conductance (parallel)";
parameter SIpu.Resistance r=0 "resistance (serial)";
parameter SIpu.Reactance x_s=1 "self reactance";
parameter SIpu.Reactance x_m=0 "mutual reactance, -x_s/2 < x_m < x_s";
protected
final parameter SI.Resistance[2] RL_base=Utilities.Precalculation.baseRL(
puUnits,
V_nom,
S_nom,
2*pi*f_nom);
SI.Conductance G=g/RL_base[1];
SI.Resistance R=r*RL_base[1];
SI.Inductance L=(x_s-x_m)*RL_base[2];
SI.Inductance L0=(x_s+2*x_m)*RL_base[2];
PS.Current[PS.n] i_x;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i_x) = omega[1]*j(i_x);
end if;
equation
i_x = i - G*v;
if dynType <> Types.Dynamics.SteadyState then
PS.map({L,L,L0}).*der(i_x) + omega[2]*L*j(i_x) + R*i_x = v;
else
omega[2]*L*j(i_x) + R*i_x = v;
end if;
end ReactiveShunt;
model CapacitiveShunt
"Shunt capacitor with parallel conductor, 3-phase dq0, pp pg"
extends Partials.ShuntBase;
parameter SIpu.Conductance g_pg=0 "conductance ph-grd";
parameter SIpu.Conductance g_pp=0 "conductance ph_ph";
parameter SIpu.Susceptance b_pg=1 "susceptance ph-grd";
parameter SIpu.Susceptance b_pp=1/3 "susceptance ph-ph";
protected
final parameter SI.Resistance[2] GC_base=Utilities.Precalculation.baseGC(
puUnits,
V_nom,
S_nom,
2*pi*f_nom);
SI.Conductance G=(g_pg+3*g_pp)*GC_base[1];
SI.Conductance G0=g_pg*GC_base[1];
SI.Capacitance C=(b_pg+3*b_pp)*GC_base[2];
SI.Capacitance C0=b_pg*GC_base[2];
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(v) = omega[1]*j(v);
end if;
equation
if dynType <> Types.Dynamics.SteadyState then
PS.map({C,C,C0}).*der(v) + omega[2]*C*j(v) + PS.map({G,G,G0}).*v = i;
else
omega[2]*C*j(v) + PS.map({G,G,G0}).*v = i;
end if;
end CapacitiveShunt;
model ReactiveShuntNonSym
"Shunt reactor with parallel conductor non symmetric, 3-phase dq0"
extends Partials.ShuntBaseNonSym;
parameter SIpu.Conductance[3] g={0,0,0} "conductance abc (parallel)";
parameter SIpu.Resistance[3] r={0,0,0} "resistance abc (serial)";
parameter SIpu.Reactance[3, 3] x=[1, 0, 0; 0, 1, 0; 0, 0, 1] "reactance abc";
SI.MagneticFlux[3] psi_x(each stateSelect=StateSelect.prefer) "magnetic flux";
protected
final parameter SI.Resistance[2] RL_base=Utilities.Precalculation.baseRL(
puUnits,
V_nom,
S_nom,
2*pi*f_nom);
final parameter SI.Conductance[3] G_abc=g/RL_base[1];
final parameter SI.Reactance[3] R_abc=r*RL_base[1];
final parameter SI.Inductance[3, 3] L_abc=x*RL_base[2];
SI.Conductance[3, 3] G;
SI.Resistance[3, 3] R;
SI.Inductance[3, 3] L;
PS.Current[3] i_x;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(psi_x[1:2]) = omega[1]*j_dq0(psi_x[1:2]);
psi_x[3] = 0;
end if;
equation
L = Park*L_abc*transpose(Park);
R = Park*diagonal(R_abc)*transpose(Park);
G = Park*diagonal(G_abc)*transpose(Park);
i_x = i - G*v;
psi_x = L*(i - G*v);
if dynType <> Types.Dynamics.SteadyState then
der(psi_x) + omega[2]*j_dq0(psi_x) + R*i_x = v;
else
omega[2]*j_dq0(psi_x) + R*i_x = v;
end if;
end ReactiveShuntNonSym;
model CapacitiveShuntNonSym
"Shunt capacitor with parallel conductor non symmetric, 3-phase dq0, pp pg"
extends Partials.ShuntBaseNonSym;
parameter SIpu.Conductance[3] g_pg={0,0,0} "conductance ph-grd abc";
parameter SIpu.Conductance[3] g_pp={0,0,0} "conductance ph_ph abc";
parameter SIpu.Susceptance[3] b_pg={1,1,1} "susceptance ph-grd abc";
parameter SIpu.Susceptance[3] b_pp={1,1,1}/3 "susceptance ph-ph abc";
SI.ElectricCharge[3] q(each stateSelect=StateSelect.prefer) "electric charge";
protected
final parameter SI.Resistance[2] GC_base=Utilities.Precalculation.baseGC(
puUnits,
V_nom,
S_nom,
2*pi*f_nom);
final parameter SI.Conductance[3,3] G_abc=(diagonal(g_pg)+
[g_pp[2]+g_pp[3],-g_pp[3],-g_pp[2];-g_pp[3],g_pp[3]+g_pp[1],-g_pp[1];-g_pp[2],-g_pp[1],g_pp[1]+g_pp[2]])
*GC_base[1];
final parameter SI.Capacitance[3,3] C_abc=(diagonal(b_pg)+
[b_pp[2]+b_pp[3],-b_pp[3],-b_pp[2];-b_pp[3],b_pp[3]+b_pp[1],-b_pp[1];-b_pp[2],-b_pp[1],b_pp[1]+b_pp[2]])
*GC_base[2];
SI.Conductance[3, 3] G;
SI.Capacitance[3, 3] C;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(q[1:2]) = omega[1]*j_dq0(q[1:2]);
q[3] = 0;
end if;
equation
C = Park*C_abc*transpose(Park);
G = Park*G_abc*transpose(Park);
q = C*v;
if dynType <> Types.Dynamics.SteadyState then
der(q) + omega[2]*j_dq0(q) + G*v = i;
else
omega[2]*j_dq0(q) + G*v = i;
end if;
end CapacitiveShuntNonSym;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model ShuntBase "Shunt base, 3-phase dq0"
extends Ports.Port_p;
extends Common.Nominal.NominalAC;
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
PS.Voltage[PS.n] v;
PS.Current[PS.n] i;
protected
SI.AngularFrequency[2] omega;
equation
omega = der(term.theta);
v = term.v;
i = term.i;
end ShuntBase;
partial model ShuntBaseNonSym "Shunt base non symmetric, 3-phase dq0"
extends ShuntBase;
protected
Real[3,3] Park=Utilities.Transforms.park(term.theta[2]);
end ShuntBaseNonSym;
end Partials;
end Shunts; |
Voltage and Power Sources | within PowerSystems.AC3ph;
package Sources "Voltage and Power Sources"
extends Modelica.Icons.SourcesPackage;
model Voltage "Ideal voltage, 3-phase dq0"
extends Partials.VoltageBase;
parameter SIpu.Voltage v0=1 "fixed voltage"
parameter SI.Angle alpha0=0 "fixed phase angle"
protected
PS.Voltage V;
SI.Angle alpha;
SI.Angle phi;
equation
if not use_vPhasor_in then
vPhasor_internal = {v0, alpha0};
end if;
V = vPhasor_internal[1]*V_base;
alpha = vPhasor_internal[2];
phi = term.theta[1] + alpha + system.alpha0;
term.v = PS.map({V*cos(phi), V*sin(phi), sqrt(3)*neutral.v});
end Voltage;
model Vspectrum "Ideal voltage spectrum, 3-phase dq0"
extends Partials.VoltageBase;
constant Real s2=sqrt(2);
parameter Integer[:] h={1,3,5} "{1, ...}, which harmonics?";
parameter SIpu.Voltage[N] v0={1,0.3,0.1} "voltages";
parameter SI.Angle[N] alpha0=zeros(N) "phase angles";
protected
final parameter Integer N=size(h, 1) "nb of harmonics";
PS.Voltage V;
SI.Angle alpha;
SI.Angle phi;
Integer[N] h_mod3;
Real[PS.n, N] H;
equation
if not use_vPhasor_in then
vPhasor_internal = {1, 0};
end if;
V = vPhasor_internal[1]*V_base;
alpha = vPhasor_internal[2];
algorithm
h_mod3 := mod(h, 3);
for n in 1:N loop
if h_mod3[n] == 1 then
phi := h[n]*(theta + alpha + system.alpha0 + alpha0[n]) - term.theta[2];
H[:, n] := PS.map({cos(phi), sin(phi), 0});
elseif h_mod3[n] == 2 then
phi := h[n]*(theta + alpha + system.alpha0 + alpha0[n]) + term.theta[2];
H[:, n] := PS.map({cos(phi), -sin(phi), 0});
else
phi := h[n]*(theta + alpha + system.alpha0 + alpha0[n]);
H[:, n] := PS.map({0, 0, s2*cos(phi)});
end if;
end for;
term.v := V*(H*v0);
end Vspectrum;
model InfBus "Infinite slack bus, 3-phase dq0"
extends Partials.PowerBase(final S_nom=1);
Modelica.Blocks.Interfaces.RealInput[2] vPhasor_in if use_vPhasor_in
"{abs(voltage), phase}"
parameter Boolean use_vPhasor_in = false
"= true to use input signal vPhasor_in, otherwise use {v0, alpha0}"
parameter SIpu.Voltage v0=1 "fixed voltage"
parameter SI.Angle alpha0=0 "fixed phase angle"
protected
PS.Voltage V;
SI.Angle alpha;
SI.Angle phi;
Modelica.Blocks.Interfaces.RealInput[2] vPhasor_internal
"Needed to connect to conditional connector";
equation
connect(vPhasor_in, vPhasor_internal);
if not use_vPhasor_in then
vPhasor_internal = {v0, alpha0};
end if;
V = vPhasor_internal[1]*V_base;
alpha = vPhasor_internal[2];
phi = term.theta[1] + alpha + system.alpha0;
term.v = PS.map({V*cos(phi), V*sin(phi), sqrt(3)*neutral.v});
end InfBus;
model VsourceRX "Voltage behind reactance source, 3-phase dq0"
extends Partials.PowerBase;
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter PowerSystems.Types.Init initType=PowerSystems.Types.Init.v_alpha
"initialisation type"
parameter SIpu.Voltage v_start=1 "initial terminal voltage"
parameter SI.Angle alpha_start=0 "initial terminal phase angle"
parameter SIpu.ApparentPower p_start=1 "initial terminal active power"
parameter SIpu.ApparentPower q_start=1 "initial terminal reactive power"
parameter SIpu.ApparentPower pq_start[2]={1,0}
"initial terminal {active, reactive} power"
parameter SIpu.Resistance r=0.01 "resistance";
parameter SIpu.Reactance x=1 "reactance d- and q-axis";
parameter SIpu.Reactance x0=0.1 "reactance 0-axis";
protected
final parameter SIpu.Voltage v0(final fixed=false, start=1)
"voltage behind reactance";
final parameter SI.Angle alpha0(final fixed=false, start=0)
"phase angle of voltage b r";
final parameter PS.Voltage V(start=V_base)=v0*V_base;
final parameter Real[2] RL_base=Utilities.Precalculation.baseRL(
puUnits,
V_nom,
S_nom,
2*pi*system.f_nom);
final parameter SI.Resistance R=r*RL_base[1];
final parameter SI.Inductance L = x*RL_base[2];
final parameter SI.Inductance L0 = x0*RL_base[2];
PS.Voltage[PS.n] v(start=PS.map({cos(system.alpha0),sin(system.alpha0),0})*V_base);
PS.Current[PS.n] i(start=zeros(PS.n));
SI.AngularFrequency[2] omega;
SI.Angle phi(start=alpha0+system.alpha0);
function atan2 = Modelica.Math.atan2;
initial equation
if initType == PowerSystems.Types.Init.v_alpha then
sqrt(v[1:2]*v[1:2]) = v_start*V_base;
atan2(v[2], v[1]) = alpha_start + system.alpha0;
elseif initType == PowerSystems.Types.Init.v_p then
sqrt(v[1:2]*v[1:2]) = v_start*V_base;
v[1:2]*i[1:2] = p_start*S_base;
elseif initType == PowerSystems.Types.Init.v_q then
sqrt(v[1:2]*v[1:2]) = v_start*V_base;
{v[2],-v[1]}*i[1:2] = q_start*S_base;
elseif initType == PowerSystems.Types.Init.p_q then
{v[1:2]*i[1:2], {v[2],-v[1]}*i[1:2]} = pq_start*S_base;
end if;
if dynType == Types.Dynamics.SteadyInitial then
der(i) = omega[1]*j(i);
end if;
equation
omega = der(term.theta);
v = term.v;
i = -term.i;
phi = term.theta[1] + alpha0 + system.alpha0;
if dynType <> Types.Dynamics.SteadyState then
PS.map({L,L,L0}).*der(i) + omega[2]*L*j(i) + R*i = PS.map({V*cos(phi), V*sin(phi), sqrt(3)*neutral.v}) - v;
else
omega[2]*L*j(i) + R*i = PS.map({V*cos(phi), V*sin(phi), sqrt(3)*neutral.v}) - v;
end if;
end VsourceRX;
model PVsource "Power-voltage source, 3-phase dq0"
extends Partials.PowerBase;
Modelica.Blocks.Interfaces.RealInput[2] pv_in if use_pv_in
"{active power, abs(voltage)}"
parameter Boolean use_pv_in = false
"= true to use input signal pv_in, otherwise use {p0, v0}"
parameter SIpu.ApparentPower p0=1 "fixed active power"
parameter SIpu.Voltage v0=1 "fixed voltage"
parameter PS.Voltage V_start=V_nom "start value terminal voltage"
protected
SI.Power P;
PS.Voltage V;
PS.Voltage[2] v(start={cos(system.alpha0),sin(system.alpha0)}*V_start);
PS.Current[2] i(start={0,0});
Modelica.Blocks.Interfaces.RealInput[2] pv_internal
"Needed to connect to conditional connector";
equation
connect(pv_in, pv_internal);
i = -term.i[1:2];
if not use_pv_in then
pv_internal={p0, v0};
end if;
P = pv_internal[1]*S_base;
V = pv_internal[2]*V_base;
v*v = V*V;
v*i = P;
term.v = PS.map(cat(1, v, {sqrt(3)*neutral.v}));
end PVsource;
model PQsource "Power source, 3-phase dq0"
extends Partials.PowerBase;
Modelica.Blocks.Interfaces.RealInput[2] pq_in(each final unit="1") if use_pq_in
"{active, reactive} power"
parameter Boolean use_pq_in = false
"= true to use input signal pq_in, otherwise use pq0"
parameter SIpu.ApparentPower pq0[2]={1,0} "fixed {active, reactive} power"
parameter PS.Voltage V_start=V_nom "start value terminal voltage"
protected
SI.Power[2] P;
PS.Voltage[2] v(start={cos(system.alpha0),sin(system.alpha0)}*V_start);
PS.Current[2] i(start={0,0});
Modelica.Blocks.Interfaces.RealInput[2] pq_internal
"Needed to connect to conditional connector";
equation
connect(pq_in, pq_internal);
i = -term.i[1:2];
if not use_pq_in then
pq_internal = pq0;
end if;
P = pq_internal*S_base;
{v*i, {v[2],-v[1]}*i} = P;
term.v = PS.map(cat(1, v, {sqrt(3)*neutral.v}));
end PQsource;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model SourceBase "Voltage base, 3-phase dq0"
extends Ports.Port_n;
extends Common.Nominal.Nominal;
Interfaces.Electric_p neutral "(use for grounding)"
protected
outer System system;
final parameter PS.Voltage V_base=Utilities.Precalculation.baseV(
puUnits, V_nom);
SI.Angle theta(stateSelect=StateSelect.prefer) "absolute angle";
equation
Connections.potentialRoot(term.theta);
if Connections.isRoot(term.theta) then
term.theta = {system.thetaRel, system.thetaRef};
end if;
if PS.n > 2 then
sqrt(3)*term.i[3] + neutral.i = 0;
else
neutral.i = 0;
end if;
end SourceBase;
partial model VoltageBase "Voltage base, 3-phase dq0"
extends SourceBase(final S_nom=1);
parameter Types.SourceFrequency fType=PowerSystems.Types.SourceFrequency.System
"frequency type"
parameter SI.Frequency f=system.f "frequency if type is parameter"
parameter Boolean use_vPhasor_in = false
"= true to use input signal vPhasor_in, otherwise use fixed values"
Modelica.Blocks.Interfaces.RealInput omega_in(final unit="rad/s") if fType
== PowerSystems.Types.SourceFrequency.Signal
"angular frequency"
Modelica.Blocks.Interfaces.RealInput[2] vPhasor_in if use_vPhasor_in
"{abs(voltage), phase}"
protected
Modelica.Blocks.Interfaces.RealInput omega_internal
"Needed to connect to conditional connector";
Modelica.Blocks.Interfaces.RealInput[2] vPhasor_internal
"Needed to connect to conditional connector";
initial equation
if fType == Types.SourceFrequency.Signal then
theta = 0;
end if;
equation
connect(omega_in, omega_internal);
connect(vPhasor_in, vPhasor_internal);
if fType <> Types.SourceFrequency.Signal then
omega_internal = 0.0;
end if;
if fType == Types.SourceFrequency.System then
theta = system.theta;
elseif fType == Types.SourceFrequency.Parameter then
theta = 2*pi*f*(time - system.initime);
elseif fType == Types.SourceFrequency.Signal then
der(theta) = omega_internal;
end if;
end VoltageBase;
partial model PowerBase "Power source base, 3-phase dq0"
extends SourceBase;
protected
final parameter Real S_base=Utilities.Precalculation.baseS(puUnits, S_nom);
equation
theta=system.theta;
end PowerBase;
end Partials;
end Sources; |
Transformers 3-phase | within PowerSystems.AC3ph;
package Transformers "Transformers 3-phase"
extends Modelica.Icons.VariantsPackage;
model TrafoIdeal "Ideal transformer, 3-phase dq0"
parameter Boolean D_D=false "set true if Delta-Delta topology!";
extends Partials.TrafoIdealBase(final dynType=Types.Dynamics.SteadyState);
equation
i1 + i2 = zeros(PS.n);
if D_D then
v1[1:2] = v2[1:2];
i1[3]=0;
else
v1 = v2;
end if;
end TrafoIdeal;
model TrafoStray "Ideal magnetic coupling transformer, 3-phase dq0"
extends Partials.TrafoStrayBase;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i1) = omega[1]*j(i1);
end if;
equation
i1 + i2 = zeros(PS.n);
if dynType <> Types.Dynamics.SteadyState then
PS.map({sum(L),sum(L),sum(L0)}).*der(i1) + omega[2]*sum(L)*j(i1) + sum(R)*i1 = v1 - v2;
else
omega[2]*sum(L)*j(i1) + sum(R)*i1 = v1 - v2;
end if;
end TrafoStray;
model TrafoMag "Magnetic coupling transformer, 3-phase dq0"
extends Partials.TrafoMagBase;
PS.Voltage[PS.n] v0;
PS.Current[PS.n] imag;
PS.Current[PS.n] iedc;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i1) = omega[1]*j(i1);
der(i2) = omega[1]*j(i2);
der(imag) = omega[1]*j(imag);
elseif dynType <> Types.Dynamics.SteadyState then
der(imag) = omega[1]*j(imag);
end if;
equation
i1 + i2 = imag + iedc;
Redc*iedc = v0;
if dynType <> Types.Dynamics.SteadyState then
PS.map({L[1],L[1],L0[1]}).*der(i1) + omega[2]*L[1]*j(i1) + R[1]*i1 = v1 - v0;
PS.map({L[2],L[2],L0[2]}).*der(i2) + omega[2]*L[2]*j(i2) + R[2]*i2 = v2 - v0;
Lm*der(imag) + omega[2]*Lm*j(imag) = v0;
else
omega[2]*L[1]*j(i1) + R[1]*i1 = v1 - v0;
omega[2]*L[2]*j(i2) + R[2]*i2 = v2 - v0;
omega[2]*Lm*j(imag) = v0;
end if;
end TrafoMag;
model TrafoSatEff "Averaged saturation transformer, 3-phase dq0"
extends Partials.TrafoSatBase;
PS.Voltage[PS.n] v0;
PS.Current[PS.n] imag;
PS.Current[PS.n] iedc;
protected
Real[PS.n] psi0(each stateSelect=StateSelect.prefer) "unsaturated flux";
Real gp;
function der_sat = Common.IronSaturation.der_saturationAnalytic;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i1) = omega[1]*j(i1);
der(i2) = omega[1]*j(i2);
der(psi0) = omega[1]*j(psi0);
elseif dynType <> Types.Dynamics.SteadyState then
der(psi0) = omega[1]*j(psi0);
end if;
equation
i1 + i2 = imag + iedc;
Redc*iedc = v0;
psi0 = Lm*imag;
gp = scalar(der_sat({0.66*sqrt(psi0*psi0)/psi_nom}, c_sat));
if dynType <> Types.Dynamics.SteadyState then
PS.map({L[1],L[1],L0[1]}).*der(i1) + omega[2]*L[1]*j(i1) + R[1]*i1 = v1 - v0;
PS.map({L[2],L[2],L0[2]}).*der(i2) + omega[2]*L[2]*j(i2) + R[2]*i2 = v2 - v0;
gp*(der(psi0) + omega[2]*j(psi0)) = v0;
else
omega[2]*L[1]*j(i1) + R[1]*i1 = v1 - v0;
omega[2]*L[2]*j(i2) + R[2]*i2 = v2 - v0;
gp*(omega[2]*j(psi0)) = v0;
end if;
end TrafoSatEff;
model TrafoSat "Saturation transformer, 3-phase dq0"
extends Partials.TrafoSatBase;
PS.Voltage[3] v0;
PS.Current[3] imag;
PS.Current[3] iedc;
protected
Real[3] psi0(each stateSelect=StateSelect.prefer) "unsaturated flux";
Real[3] gp;
Real[3,3] Park=Utilities.Transforms.park(term_p.theta[2]);
function der_sat = Common.IronSaturation.der_saturationAnalytic;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i1) = omega[1]*j_dq0(i1);
der(i2) = omega[1]*j_dq0(i2);
der(psi0) = omega[1]*j_dq0(psi0);
elseif dynType <> Types.Dynamics.SteadyState then
der(psi0) = omega[1]*j_dq0(psi0);
end if;
equation
i1 + i2 = imag + iedc;
Redc*iedc = v0;
psi0 = Lm*imag;
gp = der_sat(transpose(Park)*psi0/psi_nom, c_sat);
diagonal({L[1],L[1],L0[1]})*der(i1) + omega[2]*L[1]*j_dq0(i1) + R[1]*i1 = v1 - v0;
diagonal({L[2],L[2],L0[2]})*der(i2) + omega[2]*L[2]*j_dq0(i2) + R[2]*i2 = v2 - v0;
Park*diagonal(gp)*transpose(Park)*(der(psi0) + omega[2]*j_dq0(psi0)) = v0;
end TrafoSat;
model Trafo3Stray
extends Partials.Trafo3StrayBase;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(i2a) = omega[1]*j(i2a);
der(i2b) = omega[1]*j(i2b);
end if;
equation
i1 + i2a + i2b = zeros(PS.n);
if dynType <> Types.Dynamics.SteadyState then
PS.map({L[1],L[1],L0[1]}).*der(i1) + omega[2]*L[1]*j(i1) + R[1]*i1 = v1 - v0;
PS.map({L[2],L[2],L0[2]}).*der(i2a) + omega[2]*L[2]*j(i2a) + R[2]*i2a = v2a - v0;
PS.map({L[3],L[3],L0[3]}).*der(i2b) + omega[2]*L[3]*j(i2b) + R[3]*i2b = v2b - v0;
else
omega[2]*L[1]*j(i1) + R[1]*i1 = v1 - v0;
omega[2]*L[2]*j(i2a) + R[2]*i2a = v2a - v0;
omega[2]*L[3]*j(i2b) + R[3]*i2b = v2b - v0;
end if;
end Trafo3Stray;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model TrafoIdealBase "Base for ideal transformer, 3-phase dq0"
extends Ports.YDportTrafo_p_n(
final term_p(v(start=PS.map({cos(system.alpha0),sin(system.alpha0),0}*par.V_nom[1]))),
final term_n(v(start=PS.map({cos(system.alpha0),sin(system.alpha0),0}*par.V_nom[2]))),
i1(start=i1_start), i2(start=i2_start));
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter PS.Current[PS.n] i1_start = zeros(PS.n)
"start value of primary current"
parameter PS.Current[PS.n] i2_start = i1_start
"start value of secondary current"
parameter Boolean use_tap_1_in = false "= true to enable input tap_1_in"
parameter Integer tap_1 = par.tap_neutral[1] "fixed tap_1 position"
parameter Boolean use_tap_2_in = false "= true to enable input tap_2_in"
parameter Integer tap_2 = par.tap_neutral[2] "fixed tap_2 position"
parameter Boolean dynTC=false "enable dynamic tap-changing"
Modelica.Blocks.Interfaces.IntegerInput tap_1_in if use_tap_1_in
"1: index of voltage level"
Modelica.Blocks.Interfaces.IntegerInput tap_2_in if use_tap_2_in
"2: index of voltage level"
replaceable record Data =
PowerSystems.AC3ph.Transformers.Parameters.TrafoIdeal
constrainedby PowerSystems.AC3ph.Transformers.Parameters.TrafoIdeal
"trafo parameters"
final parameter Data par
protected
Modelica.Blocks.Interfaces.IntegerInput tap_1_internal
"Needed to connect to conditional connector";
Modelica.Blocks.Interfaces.IntegerInput tap_2_internal
"Needed to connect to conditional connector";
outer System system;
constant Real tc=0.01 "time constant tap-chg switching";
final parameter PS.Voltage[2] V_base=Utilities.Precalculation.baseTrafoV(
par.puUnits, par.V_nom);
final parameter SI.Resistance[2,2] RL_base=
Utilities.Precalculation.baseTrafoRL(
par.puUnits,
par.V_nom,
par.S_nom,
2*pi*par.f_nom);
final parameter SI.Resistance R_n1=par.r_n[1]*RL_base[1,1];
final parameter SI.Resistance R_n2=par.r_n[2]*RL_base[2,1];
SI.AngularFrequency[2] omega;
Real[2] dv_tap_pu = par.dv_tap .* V_base ./ par.V_nom;
Real w1_set = (1 + (tap_1_internal - par.tap_neutral[1]) * dv_tap_pu[1]) * sqrt(scale[1])
"1: set voltage ratio to nominal primary";
Real w2_set = (1 + (tap_2_internal - par.tap_neutral[2])*dv_tap_pu[2]) * sqrt(scale[2])
"2: set voltage ratio to nominal secondary";
initial equation
if dynTC then
w1 = w1_set;
w2 = w2_set;
end if;
equation
connect(tap_1_in, tap_1_internal);
connect(tap_2_in, tap_2_internal);
if not use_tap_1_in then
tap_1_internal = tap_1;
end if;
if not use_tap_2_in then
tap_2_internal = tap_2;
end if;
omega = der(term_p.theta);
if dynType <> Types.Dynamics.SteadyState and dynTC then
der(w1) + (w1 - w1_set)/tc = 0;
der(w2) + (w2 - w2_set)/tc = 0;
else
w1 = w1_set;
w2 = w2_set;
end if;
w2_nom = par.V_nom[2]/par.V_nom[1];
v_n1 = R_n1*i_n1
"1: equation neutral to ground (relevant if Y-topology)";
v_n2 = R_n2*i_n2
"2: equation neutral to ground (relevant if Y-topology)";
end TrafoIdealBase;
partial model TrafoStrayBase
"Base for ideal magnetic coupling transformer, 3-phase dq0"
extends TrafoIdealBase(redeclare replaceable record Data =
PowerSystems.AC3ph.Transformers.Parameters.TrafoStray
constrainedby PowerSystems.AC3ph.Transformers.Parameters.TrafoStray);
protected
SI.Resistance[2] R=par.r.*RL_base[:, 1];
SI.Inductance[2] L=par.x.*RL_base[:, 2];
SI.Inductance[2] L0=par.x0.*RL_base[:, 2];
end TrafoStrayBase;
partial model TrafoMagBase
"Base for magnetic coupling transformer, 3-phase dq0"
extends TrafoStrayBase(redeclare replaceable record Data =
PowerSystems.AC3ph.Transformers.Parameters.TrafoMag
constrainedby PowerSystems.AC3ph.Transformers.Parameters.TrafoMag);
protected
final parameter SI.Resistance[2] RL12_base = sqrt((RL_base[1,:].*RL_base[2,:])/product(scale));
SI.Resistance Redc=par.redc*RL12_base[1];
SI.Inductance Lm=par.xm*RL12_base[2];
SI.Inductance Lm0=par.xm0*RL12_base[2];
end TrafoMagBase;
partial model TrafoSatBase "Base for saturation transformer, 3-phase dq0"
extends TrafoMagBase(redeclare replaceable record Data =
PowerSystems.AC3ph.Transformers.Parameters.TrafoSat
constrainedby PowerSystems.AC3ph.Transformers.Parameters.TrafoSat);
protected
Real xratio=par.xm_sat/par.xm;
Real[3] c_sat={1-xratio,(1-xratio)/(par.psi_sat-xratio),xratio};
final parameter SI.MagneticFlux psi_nom=sqrt(scale[1])*par.V_nom[1]/(2*pi*par.f_nom)
"amplitude!";
end TrafoSatBase;
partial model Trafo3IdealBase
"Base for ideal 3-winding transformer, 3-phase dq0"
extends Ports.YDportTrafo_p_n_n(
final term_p(v(start=PS.map({cos(system.alpha0),sin(system.alpha0),0}*par.V_nom[1]))),
final term_na(v(start=PS.map({cos(system.alpha0),sin(system.alpha0),0}*par.V_nom[2]))),
final term_nb(v(start=PS.map({cos(system.alpha0),sin(system.alpha0),0}*par.V_nom[3]))));
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter Boolean use_tap_1_in = false "= true to enable input tap_1_in"
parameter Integer tap_1 = par.tap_neutral[1] "fixed tap_1 position"
parameter Boolean use_tap_2_in = false "= true to enable input tap_2_in"
parameter Integer[2] tap_2 = par.tap_neutral[2:3] "fixed tap_2 position"
parameter Boolean dynTC=false "enable dynamic tap-changing"
Modelica.Blocks.Interfaces.IntegerInput tap_1_in if use_tap_1_in
"1: index of voltage level"
Modelica.Blocks.Interfaces.IntegerInput[2] tap_2_in if use_tap_2_in
"2: indices of voltage levels"
replaceable record Data =
PowerSystems.AC3ph.Transformers.Parameters.Trafo3Ideal
constrainedby PowerSystems.AC3ph.Transformers.Parameters.Trafo3Ideal
"trafo parameters"
final parameter Data par "trafo parameter record"
protected
Modelica.Blocks.Interfaces.IntegerInput tap_1_internal
"Needed to connect to conditional connector";
Modelica.Blocks.Interfaces.IntegerInput[2] tap_2_internal
"Needed to connect to conditional connector";
outer System system;
constant Real tc=0.01 "time constant tap-chg switching";
final parameter PS.Voltage[3] V_base=Utilities.Precalculation.baseTrafoV(
par.puUnits, par.V_nom);
final parameter SI.Resistance[3,2] RL_base=
Utilities.Precalculation.baseTrafoRL(
par.puUnits,
par.V_nom,
par.S_nom,
2*pi*par.f_nom);
final parameter SI.Resistance R_n1=par.r_n[1]*RL_base[1,1];
final parameter SI.Resistance R_n2a=par.r_n[2]*RL_base[2,1];
final parameter SI.Resistance R_n2b=par.r_n[3]*RL_base[3,1];
SI.AngularFrequency omega[2];
Real[3] dv_tap_pu = par.dv_tap .* V_base ./ par.V_nom;
Real w1_set=(1 + (tap_1_internal - par.tap_neutral[1]) * dv_tap_pu[1]) * sqrt(scale[1])
"1: set voltage ratio to nominal primary";
Real w2a_set = (1 + (tap_2_internal[1] - par.tap_neutral[2]) * dv_tap_pu[2]) * sqrt(scale[2])
"2a: set voltage ratio to nominal secondary";
Real w2b_set = (1 + (tap_2_internal[2] - par.tap_neutral[3]) * dv_tap_pu[3]) * sqrt(scale[3])
"2b: set voltage ratio to nominal secondary";
initial equation
if dynTC then
w1 = w1_set;
w2a = w2a_set;
w2b = w2b_set;
end if;
equation
connect(tap_1_in, tap_1_internal);
connect(tap_2_in, tap_2_internal);
if not use_tap_1_in then
tap_1_internal = tap_1;
end if;
if not use_tap_2_in then
tap_2_internal = tap_2;
end if;
omega = der(term_p.theta);
if dynType <> Types.Dynamics.SteadyState and dynTC then
der(w1) + (w1 - w1_set)/tc = 0;
der(w2a) + (w2a - w2a_set)/tc = 0;
der(w2b) + (w2b - w2b_set)/tc = 0;
else
w1 = w1_set;
w2a = w2a_set;
w2b = w2b_set;
end if;
w2a_nom = par.V_nom[2]/par.V_nom[1];
w2b_nom = par.V_nom[3]/par.V_nom[1];
v_n1 = R_n1*i_n1 "1: equation neutral to ground (relevant if Y-topology)";
v_n2a = R_n2a*i_n2a
"2a: equation neutral to ground (relevant if Y-topology)";
v_n2b = R_n2b*i_n2b
"2b: equation neutral to ground (relevant if Y-topology)";
end Trafo3IdealBase;
partial model Trafo3StrayBase
"Base for ideal magnetic coupling 3-winding transformer, 3-phase dq0"
extends Trafo3IdealBase(redeclare replaceable record Data =
PowerSystems.AC3ph.Transformers.Parameters.Trafo3Stray
constrainedby PowerSystems.AC3ph.Transformers.Parameters.Trafo3Stray);
protected
SI.Resistance[3] R=par.r.*RL_base[:, 1];
SI.Inductance[3] L=par.x.*RL_base[:, 2];
SI.Inductance[3] L0=par.x0.*RL_base[:, 2];
end Trafo3StrayBase;
end Partials;
package Parameters "Parameter data for interactive use"
extends Modelica.Icons.MaterialPropertiesPackage;
record TrafoIdeal "Parameters for ideal transformer, 3-phase"
extends Common.Nominal.NominalDataTrafo;
Integer[2] tap_neutral={0, 0} "{1,2}: neutral tap position"
SIpu.Voltage[2] dv_tap={0, 0} "{1,2}: delta-v per tap change"
SIpu.Resistance[2] r_n={1, 1} "{1,2}: resistance neutral to grd (if Y)"
end TrafoIdeal;
record TrafoStray "Parameters for ideal magnetic coupling transformer, 3-phase"
extends TrafoIdeal;
SIpu.Resistance[2] r={0.05,0.05} "{1,2}: resistance"
SIpu.Reactance[2] x={0.05,0.05} "{1,2}: stray reactance"
SIpu.Reactance[2] x0={x[1],x[2]} "{1,2}: stray reactance zero-comp"
end TrafoStray;
record TrafoMag "Parameters for magnetic coupling transformer, 3-phase"
extends TrafoStray;
SIpu.Resistance redc=500 "resistance eddy current"
SIpu.Reactance xm=500 "mutual reactance"
SIpu.Reactance xm0=1 "mutual reactance zero"
end TrafoMag;
record TrafoSat "Parameters for saturation transformer, 3-phase"
extends TrafoMag;
Real psi_sat(unit="1")=1.5 "saturation flux"
SIpu.Reactance xm_sat=1 "mutual reactance saturated"
end TrafoSat;
record Trafo3Ideal "Parameters for ideal 3-winding transformer, 3-phase"
extends Common.Nominal.NominalDataTrafo(
V_nom={1,1,1}
"{prim,sec_a,sec_b} nom Voltage (= base if pu)");
Integer[3] tap_neutral={0, 0, 0} "{1,2a,2b}: neutral tap position"
SIpu.Voltage[3] dv_tap={0, 0, 0} "{1,2a,2b}: delta-v per tap change"
SIpu.Resistance[3] r_n={1, 1, 1} "{1,2a,2b}: resistance neutral to grd (if Y)"
end Trafo3Ideal;
record Trafo3Stray
"Parameters for ideal magnetic coupling 3-winding transformer, 3-phase"
extends Trafo3Ideal;
SIpu.Resistance[3] r={0.05,0.05,0.05} "{1,2a,2b}: resistance"
SIpu.Reactance[3] x={0.05,0.05,0.05} "{1,2a,2b}: stray reactance"
SIpu.Reactance[3] x0={x[1],x[2],x[3]} "{1,2a,2b}: stray reactance zero-comp"
end Trafo3Stray;
end Parameters;
end Transformers; |
Auxiliary blocks | within PowerSystems.Blocks;
package Math "Auxiliary blocks"
extends Modelica.Icons.VariantsPackage;
block Integrator "Integral of input-signal"
extends Partials.SISO(y(start=y_start, fixed=true));
parameter Real y_start=0 "initial value";
equation
der(y) = u;
end Integrator;
block TimeAverage "Time average of input signal"
extends Partials.MIMO(final nin=n, final nout=n);
parameter Integer n=1 "dim of input/output signal";
parameter SI.Time tcst(min=Modelica.Constants.eps)=1 "memory time constant";
initial equation
y = u;
equation
der(y) = (u - y)/tcst;
end TimeAverage;
block TimeAvInterval "Time average over interval of input signal"
extends Partials.MIMO(final nin=n, final nout=n);
parameter Integer n=1 "dim of input/output signal";
parameter SI.Time tcst(min=1e-9)=1 "average time";
protected
Real[n] U(start=zeros(n), fixed=true, each stateSelect=StateSelect.always);
equation
der(U) = u;
y = (U - delay(U, tcst))/tcst;
end TimeAvInterval;
block ComponentAverage "Component average of input signal"
extends Partials.MISO;
algorithm
y := sum(u)/n;
end ComponentAverage;
block Norm "Norm of input signal"
extends Partials.MISO(n=3);
parameter Integer n_eval(
min=2,
max=3) = 2 "dim of evaluated input signal u[1:n_eval]";
equation
y = sqrt(u[1:n_eval]*u[1:n_eval]);
end Norm;
block ToPolar "Rotation of input signal-vector"
extends Partials.MIMO(final nin=2, final nout=2);
parameter Integer sig(min=-1, max=1)=1 "+u or -u as input"
protected
function atan2=Modelica.Math.atan2;
equation
y[1] = sqrt(u*u);
y[2] = atan2(sig*u[2], sig*u[1]);
end ToPolar;
block ToPolarR "Rotation of input signal-vector"
extends Partials.MIMO(final nin=2, final nout=2);
parameter Integer sig(min=-1, max=1)=1 "+u or -u as input"
protected
SI.Angle alpha(stateSelect=StateSelect.always);
SI.AngularVelocity omega;
function atan2=Modelica.Math.atan2;
function atanV=Utilities.Math.atanVarCut;
function angVelocity=Utilities.Math.angVelocity;
initial equation
alpha = atan2(sig*u[2], sig*u[1]); // leads to troubles with GNU-compiler.
equation
omega = angVelocity(u, der(u));
der(alpha) = omega;
y[1] = sqrt(u*u);
y[2] = atanV(sig*u, alpha);
end ToPolarR;
block FromPolar "Rotation of input signal-vector"
extends Partials.MIMO(final nin=2, final nout=2);
equation
y = u[1]*{cos(u[2]), sin(u[2])};
end FromPolar;
end Math; |
Multiplexer and AD converter | within PowerSystems.Blocks;
package Multiplex "Multiplexer and AD converter"
extends Modelica.Icons.VariantsPackage;
block R2mux "Real multiplexer 2-fold"
extends PowerSystems.Icons.Block0;
Modelica.Blocks.Interfaces.RealInput u1[n[1]] "vector of dimension n[1]"
Modelica.Blocks.Interfaces.RealInput u2[n[2]] "vector of dimension n[2]"
Modelica.Blocks.Interfaces.RealOutput y[sum(n)]
"vector of dimension sum(n)"
parameter Integer n[2]={1,1} "dim of input signals"
equation
y = cat(1, u1, u2);
end R2mux;
block R3mux "Real multiplexer 3-fold"
extends PowerSystems.Icons.Block0;
Modelica.Blocks.Interfaces.RealInput u1[n[1]] "vector of dimension n[1]"
Modelica.Blocks.Interfaces.RealInput u2[n[2]] "vector of dimension n[2]"
Modelica.Blocks.Interfaces.RealInput u3[n[3]] "vector of dimension n[3]"
Modelica.Blocks.Interfaces.RealOutput y[sum(n)]
"vector of dimension sum(n)"
parameter Integer n[3]={1,1,1} "dim of input signals"
equation
y = cat(1,u1, u2, u2);
end R3mux;
block R4mux "Real multiplexer 4-fold"
extends PowerSystems.Icons.Block0;
Modelica.Blocks.Interfaces.RealInput u1[n[1]] "vector of dimension n[1]"
Modelica.Blocks.Interfaces.RealInput u2[n[2]] "vector of dimension n[2]"
Modelica.Blocks.Interfaces.RealInput u3[n[3]] "vector of dimension n[3]"
Modelica.Blocks.Interfaces.RealInput u4[n[4]] "vector of dimension n[4]"
Modelica.Blocks.Interfaces.RealOutput y[sum(n)]
"vector of dimension sum(n)"
parameter Integer n[4]={1,1,1,1} "dim of input signals"
equation
y = cat(1, u1[1:n[1]], u2[1:n[2]], u3[1:n[3]], u4[1:n[4]]);
end R4mux;
block R2demux "Real demultiplexer 2-fold"
extends PowerSystems.Icons.Block0;
Modelica.Blocks.Interfaces.RealInput u[sum(n)] "vector of dimension sum(n)"
Modelica.Blocks.Interfaces.RealOutput y1[n[1]] "vector of dimension n[1]"
Modelica.Blocks.Interfaces.RealOutput y2[n[2]] "vector of dimension n[2]"
parameter Integer n[2]={1,1} "dim of output signals"
equation
u = cat(1, y1, y2);
end R2demux;
block R3demux "Real demultiplexer 3-fold"
extends PowerSystems.Icons.Block0;
Modelica.Blocks.Interfaces.RealInput u[sum(n)] "vector of dimension sum(n)"
Modelica.Blocks.Interfaces.RealOutput y1[n[1]] "vector of dimension n[1]"
Modelica.Blocks.Interfaces.RealOutput y2[n[2]] "vector of dimension n[2]"
Modelica.Blocks.Interfaces.RealOutput y3[n[3]] "vector of dimension n[3]"
parameter Integer n[3]={1,1,1} "dim of output signals"
equation
u = cat(1, y1, y2, y3);
end R3demux;
block R4demux "Real demultiplexer 4-fold"
extends PowerSystems.Icons.Block0;
Modelica.Blocks.Interfaces.RealInput u[sum(n)] "vector of dimension sum(n)"
Modelica.Blocks.Interfaces.RealOutput y1[n[1]] "vector of dimension n[1]"
Modelica.Blocks.Interfaces.RealOutput y2[n[2]] "vector of dimension n[2]"
Modelica.Blocks.Interfaces.RealOutput y3[n[3]] "vector of dimension n[3]"
Modelica.Blocks.Interfaces.RealOutput y4[n[4]] "vector of dimension n[4]"
parameter Integer n[4]={1,1,1,1} "dim of output signals"
equation
u = cat(1, y1, y2, y3, y4);
end R4demux;
block B2mux "Boolean multiplexer 2-fold "
extends PowerSystems.Icons.Block0;
Modelica.Blocks.Interfaces.BooleanInput u1[n[1]] "vector of dimension n[1]"
Modelica.Blocks.Interfaces.BooleanInput u2[n[2]] "vector of dimension n[2]"
Modelica.Blocks.Interfaces.BooleanOutput y[sum(n)]
"vector of dimension sum(n)"
parameter Integer n[2]={1,1} "dim of input signals"
equation
y = cat(1, u1, u2);
end B2mux;
block B2demux "Boolean demultiplexer 2-fold "
extends PowerSystems.Icons.Block0;
Modelica.Blocks.Interfaces.BooleanInput u[sum(n)]
"vector of dimension sum(n)"
Modelica.Blocks.Interfaces.BooleanOutput y1[n[1]]
"vector of dimension n[1]"
Modelica.Blocks.Interfaces.BooleanOutput y2[n[2]]
"vector of dimension n[2]"
parameter Integer n[2]={1,1} "dim of output signals"
equation
u = cat(1, y1, y2);
end B2demux;
block Gate2demux "Boolean demultiplexer 2-fold"
extends PowerSystems.Icons.Block;
Modelica.Blocks.Interfaces.BooleanInput gates[2*n]
"vector of dimension 2*n"
Modelica.Blocks.Interfaces.BooleanOutput gates_1[n] "vector of dimension n"
Modelica.Blocks.Interfaces.BooleanOutput gates_2[n] "vector of dimension n"
parameter Integer n=1 "number of pairs out"
equation
gates_1[1:n] = gates[1:n];
gates_2[1:n] = gates[(n + 1):(n + n)];
end Gate2demux;
block Gate3demux "Boolean demultiplexer 3-fold "
extends PowerSystems.Icons.Block;
Modelica.Blocks.Interfaces.BooleanInput gates[3*n]
"vector of dimension 3*n"
Modelica.Blocks.Interfaces.BooleanOutput gates_a[n] "vector of dimension n"
Modelica.Blocks.Interfaces.BooleanOutput gates_b[n] "vector of dimension n"
Modelica.Blocks.Interfaces.BooleanOutput gates_c[n] "vector of dimension n"
parameter Integer n=1 "number of triples out"
equation
gates_a[1:n] = gates[1:n];
gates_b[1:n] = gates[(n + 1):2*n];
gates_c[1:n] = gates[(2*n + 1):3*n];
end Gate3demux;
block AD1ph "Analog-Digital converter 1-phase"
extends PowerSystems.Icons.Block0;
Modelica.Blocks.Interfaces.RealInput p "scalar analog p-signal"
Modelica.Blocks.Interfaces.RealInput n "scalar analog n-signal"
Modelica.Blocks.Interfaces.BooleanOutput gates[2] "boolean {p, n}-gate"
equation
gates[1] = if p > 0.5 then true else false;
gates[2] = if n > 0.5 then true else false;
end AD1ph;
block DA1ph "Digital-Analog converter 1-phase"
extends PowerSystems.Icons.Block0;
Modelica.Blocks.Interfaces.BooleanInput gates[2] "boolean {p, n}-gate"
Modelica.Blocks.Interfaces.RealOutput p "scalar analog p-signal"
Modelica.Blocks.Interfaces.RealOutput n "scalar analog n-signal"
equation
p = if gates[1] then 1 else 0;
n = if gates[2] then 1 else 0;
end DA1ph;
block AD3ph "Analog-Digital converter 3-phase"
extends PowerSystems.Icons.Block0;
Modelica.Blocks.Interfaces.RealInput a_p "scalar analog p-signal phase a"
Modelica.Blocks.Interfaces.RealInput a_n "scalar analog n-signal phase a"
Modelica.Blocks.Interfaces.RealInput b_p "scalar analog p-signal phase b"
Modelica.Blocks.Interfaces.RealInput b_n "scalar analog n-signal phase b"
Modelica.Blocks.Interfaces.RealInput c_p "scalar analog p-signal phase c"
Modelica.Blocks.Interfaces.RealInput c_n "scalar analog n-signal phase c"
Modelica.Blocks.Interfaces.BooleanOutput gates[6]
"boolean {a_p,a_n, b_p,b_n, c_p,c_n,}-gate"
equation
gates[1] = if a_p > 0.5 then true else false;
gates[2] = if a_n > 0.5 then true else false;
gates[3] = if b_p > 0.5 then true else false;
gates[4] = if b_n > 0.5 then true else false;
gates[5] = if c_p > 0.5 then true else false;
gates[6] = if c_n > 0.5 then true else false;
end AD3ph;
block DA3ph "Digital-Analog converter 3-phase"
extends PowerSystems.Icons.Block0;
Modelica.Blocks.Interfaces.BooleanInput gates[6]
"boolean {a_p,a_n, b_p,b_n, c_p,c_n,}-gate"
Modelica.Blocks.Interfaces.RealOutput a_p "scalar analog p-signal phase a"
Modelica.Blocks.Interfaces.RealOutput a_n "scalar analog n-signal phase a"
Modelica.Blocks.Interfaces.RealOutput b_p "scalar analog p-signal phase b"
Modelica.Blocks.Interfaces.RealOutput b_n "scalar analog n-signal phase b"
Modelica.Blocks.Interfaces.RealOutput c_p "scalar analog p-signal phase c"
Modelica.Blocks.Interfaces.RealOutput c_n "scalar analog n-signal phase c"
equation
a_p = if gates[1] then 1 else 0;
a_n = if gates[2] then 1 else 0;
b_p = if gates[3] then 1 else 0;
b_n = if gates[4] then 1 else 0;
c_p = if gates[5] then 1 else 0;
c_n = if gates[6] then 1 else 0;
end DA3ph;
end Multiplex; |
Blocks | within PowerSystems;
package Blocks "Blocks"
extends Modelica.Icons.Package;
end Blocks; |
Partial models | within PowerSystems.Blocks;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial block SO
extends PowerSystems.Icons.Block0;
Modelica.Blocks.Interfaces.RealOutput y "output signal"
end SO;
partial block MO
extends PowerSystems.Icons.Block0;
Modelica.Blocks.Interfaces.RealOutput[n] y "output signal-vector"
parameter Integer n=1 "dim of output signal-vector";
end MO;
partial block SISO
extends PowerSystems.Icons.Block0;
Modelica.Blocks.Interfaces.RealInput u "input signal"
Modelica.Blocks.Interfaces.RealOutput y "output signal"
end SISO;
partial block MISO
extends PowerSystems.Icons.Block0;
Modelica.Blocks.Interfaces.RealInput[n] u "input signal-vector"
Modelica.Blocks.Interfaces.RealOutput y "output signal"
parameter Integer n=1 "dim of input signal-vector";
end MISO;
partial block MIMO
extends PowerSystems.Icons.Block0;
Modelica.Blocks.Interfaces.RealInput u[nin] "input signal-vector"
Modelica.Blocks.Interfaces.RealOutput y[nout] "output signal vector"
parameter Integer nin=1 "dim of input signal-vector";
parameter Integer nout=1 "dim of output signal-vector";
end MIMO;
end Partials; |
Special signals | within PowerSystems.Blocks;
package Signals "Special signals"
extends Modelica.Icons.VariantsPackage;
block Constant "Constant vector"
extends Partials.SO;
parameter Real c=1 "constant";
equation
y = c;
end Constant;
block Transient "Transient vector"
extends Partials.SO;
parameter SI.Time t_change=0.5 "time when change";
parameter SI.Time t_duration=1 "transition duration";
parameter Real s_start=1 "initial value";
parameter Real s_end=1 "final value";
protected
final parameter SI.Frequency coef=2*exp(1)/t_duration;
equation
y = 0.5*((s_end + s_start) + (s_end - s_start)*tanh(coef*(time - t_change)));
end Transient;
block ConstantPhasor "Constant {norm, phase} of vector"
extends Partials.MO(final n=2);
parameter Real a=1 "norm |y|";
parameter SI.Angle ph=0 "phase (y)";
equation
y= {a, ph};
end ConstantPhasor;
block TransientPhasor "Transient {norm, phase} of vector"
extends Partials.MO(final n=2);
parameter SI.Time t_change=0.5 "time when change";
parameter SI.Time t_duration=1 "transition duration";
parameter Real a_start=1 "initial norm |y|";
parameter Real a_end=1 "final norm |y|";
parameter SI.Angle ph_start=0 "initial phase (y)";
parameter SI.Angle ph_end=0 "final phase (y)";
protected
final parameter SI.Frequency coef=2*exp(1)/t_duration;
equation
y = 0.5*({a_end+a_start, ph_end+ph_start} + {a_end-a_start, ph_end-ph_start}*tanh(coef*(time - t_change)));
end TransientPhasor;
block ConstantFreq "Constant frequency"
extends Constant(final c=2*pi*f);
parameter SI.Frequency f=system.f "frequency";
protected
outer System system;
end ConstantFreq;
block TransientFreq "Transient frequency"
extends Transient(final s_start=omega_start, final s_end=omega_end);
parameter SI.Frequency f_start=system.f "initial frequency";
parameter SI.Frequency f_end=system.f "final frequency";
protected
outer System system;
final parameter SI.AngularFrequency omega_start=2*pi*f_start;
final parameter SI.AngularFrequency omega_end=2*pi*f_end;
end TransientFreq;
block Sin "Sine of n phases"
extends Partials.MO;
parameter Real a=1 "signal amplitude";
parameter SI.Frequency f=50 "frequency";
parameter SI.Angle phComm=0 "common phase angle";
parameter SI.Angle[n] phShift=(0:n-1)*2*pi/n "phase shift";
protected
final parameter SI.AngularFrequency omega=2*pi*f;
final parameter SI.Angle[n] ph=fill(phComm, n) - phShift;
equation
y = a*sin(omega*time*ones(n) + ph);
end Sin;
block VarSin "Sine of n phases with variable amplitude and frequency"
extends Partials.MO;
parameter SI.Angle phComm=0 "common phase angle";
parameter SI.Angle[n] phShift=(0:n-1)*2*pi/n "phase shift";
Modelica.Blocks.Interfaces.RealInput amplitude "signal amplitude"
Modelica.Blocks.Interfaces.RealInput omega "angular frequency"
protected
final parameter SI.Angle[n] ph=fill(phComm, n) - phShift;
SI.Angle theta(start=0, fixed=true, stateSelect=StateSelect.always);
equation
der(theta) = omega;
y = amplitude*sin(fill(theta, n) + ph);
end VarSin;
block VarSinSpec
"Sine + harmonics of n phases with variable amplitude and frequency"
extends Partials.MO;
Modelica.Blocks.Interfaces.RealInput amplitude "common signal amplitude"
Modelica.Blocks.Interfaces.RealInput omega "common angular frequency"
parameter SI.Angle phComm=0 "common phase angle";
parameter SI.Angle phShift[n]=(0:n-1)*2*pi/n "phase shift";
parameter Integer N=3 "1 + number of harmonics";
parameter Integer[N] h={1,3,5} "{1, ...} which harmonics?";
parameter Real[N] a_rel={1,0.3,0.1} "rel amplitudes";
parameter SI.Angle[N] ph_h={0,0,0} "rel phase angles harmonics";
protected
final parameter SI.Angle[n] ph=fill(phComm, n) - phShift;
SI.Angle theta(start=0, fixed=true, stateSelect=StateSelect.always);
equation
der(theta) = omega;
for k in 1:n loop
y[k] = amplitude*(a_rel*sin((theta + ph[k])*h + ph_h));
end for;
end VarSinSpec;
end Signals; |
Auxiliary blocks | within PowerSystems.Blocks;
package Transforms "Auxiliary blocks"
extends Modelica.Icons.VariantsPackage;
block Park "Park-transform of input signal-vector"
extends Partials.MIMO(final nin=3, final nout=3);
Modelica.Blocks.Interfaces.RealInput theta "transformation angle"
protected
constant Real s13=sqrt(1/3);
constant Real s23=sqrt(2/3);
constant Real dph_b=2*pi/3;
constant Real dph_c=4*pi/3;
Real[3] c;
Real[3] s;
equation
c = cos({theta, theta - dph_b, theta - dph_c});
s = sin({theta, theta - dph_b, theta - dph_c});
y = transpose([s23*c, -s23*s, {s13, s13, s13}])*u;
end Park;
block Rotation_dq "Rotation of input signal-vector"
extends Partials.MIMO(final nin=2, final nout=2);
Modelica.Blocks.Interfaces.RealInput theta "rotation angle"
protected
Real c;
Real s;
equation
c = cos(theta);
s = sin(theta);
y = [c, -s; s, c]*u;
end Rotation_dq;
block Rotation_abc "Rotation of input signal-vector"
extends Partials.MIMO(final nin=3, final nout=3);
Modelica.Blocks.Interfaces.RealInput theta "rotation angle"
protected
constant Real q13=1/3;
constant Real q23=2/3;
constant Real dph_b=2*pi/3;
constant Real dph_c=4*pi/3;
Real[3] g;
equation
g = {q13, q13, q13} + q23*cos({theta, theta - dph_b, theta - dph_c});
y = [g[{1,2,3}], g[{3,1,2}], g[{2,3,1}]]*u;
end Rotation_abc;
block RotationPhasor "Rotation of input signal-vector"
extends Partials.MIMO(final nin=2, final nout=2);
Modelica.Blocks.Interfaces.RealInput theta "rotation angle"
equation
y = {u[1], u[2] + theta};
end RotationPhasor;
block PhasorToAlphaBeta "Rotation of input signal-vector"
extends Partials.MIMO(final nin=2, final nout=2);
Modelica.Blocks.Interfaces.RealInput theta "rotation angle"
protected
constant Real s23=sqrt(2/3);
equation
y = sqrt(2/3)*u[1]*{cos(u[2] + theta), sin(u[2] + theta)};
end PhasorToAlphaBeta;
end Transforms; |
Iron saturation properties | within PowerSystems.Common;
package IronSaturation "Iron saturation properties"
extends Modelica.Icons.MaterialPropertiesPackage;
function saturationAnalytic "Analytic iron saturation function"
input Real[:] psi0 "unsaturated flux pu";
input Real[3] c;
output Real[size(psi0,1)] psi
"n=0: saturated flux, n=1: derivative d_psi/d_psi0";
algorithm
for k in 1:size(psi0,1) loop
psi[k] := (c[1]/c[2])*tanh(c[2]*psi0[k]) + c[3]*psi0[k];
end for;
end saturationAnalytic;
function der_saturationAnalytic
"Derivative of analytic iron saturation function"
input Real[:] psi0 "unsaturated flux pu";
input Real[3] c;
output Real[size(psi0,1)] der_psi "derivative d_psi/d_psi0";
algorithm
for k in 1:size(psi0,1) loop
der_psi[k] := c[1]/(cosh(c[2]*psi0[k]))^2 + c[3];
end for;
end der_saturationAnalytic;
record SaturationTab "Saturating flux table"
extends Modelica.Icons.Record;
// psi0: unsaturated flux pu, 1st column
// psi: saturating flux pu, 2nd column
// d_psi/d_psi0: derivative of psi with respect to psi0, 3rd column
//
// psi0 psi d_psi/d_psi0
Real psi[102,3] = [
0.0000000e+000, 0.0000000e+000, 1.0000000e+000;
5.0000000e-002, 4.9981521e-002, 9.9889156e-001;
1.0000000e-001, 9.9852361e-002, 9.9557607e-001;
1.5000000e-001, 1.4950282e-001, 9.9008280e-001;
2.0000000e-001, 1.9882514e-001, 9.8245996e-001;
2.5000000e-001, 2.4771442e-001, 9.7277376e-001;
3.0000000e-001, 2.9606950e-001, 9.6110722e-001;
3.5000000e-001, 3.4379377e-001, 9.4755869e-001;
4.0000000e-001, 3.9079586e-001, 9.3224012e-001;
4.5000000e-001, 4.3699033e-001, 9.1527512e-001;
5.0000000e-001, 4.8229815e-001, 8.9679696e-001;
5.5000000e-001, 5.2664715e-001, 8.7694646e-001;
6.0000000e-001, 5.6997236e-001, 8.5586980e-001;
6.5000000e-001, 6.1221619e-001, 8.3371650e-001;
7.0000000e-001, 6.5332858e-001, 8.1063732e-001;
7.5000000e-001, 6.9326699e-001, 7.8678238e-001;
8.0000000e-001, 7.3199635e-001, 7.6229941e-001;
8.5000000e-001, 7.6948886e-001, 7.3733216e-001;
9.0000000e-001, 8.0572380e-001, 7.1201899e-001;
9.5000000e-001, 8.4068720e-001, 6.8649173e-001;
1.0000000e+000, 8.7437149e-001, 6.6087466e-001;
1.0500000e+000, 9.0677511e-001, 6.3528381e-001;
1.1000000e+000, 9.3790209e-001, 6.0982636e-001;
1.1500000e+000, 9.6776160e-001, 5.8460025e-001;
1.2000000e+000, 9.9636746e-001, 5.5969405e-001;
1.2500000e+000, 1.0237377e+000, 5.3518688e-001;
1.3000000e+000, 1.0498940e+000, 5.1114853e-001;
1.3500000e+000, 1.0748613e+000, 4.8763966e-001;
1.4000000e+000, 1.0986676e+000, 4.6471219e-001;
1.4500000e+000, 1.1213430e+000, 4.4240962e-001;
1.5000000e+000, 1.1429196e+000, 4.2076756e-001;
1.5500000e+000, 1.1634312e+000, 3.9981424e-001;
1.6000000e+000, 1.1829129e+000, 3.7957100e-001;
1.6500000e+000, 1.2014004e+000, 3.6005295e-001;
1.7000000e+000, 1.2189304e+000, 3.4126945e-001;
1.7500000e+000, 1.2355397e+000, 3.2322472e-001;
1.8000000e+000, 1.2512652e+000, 3.0591839e-001;
1.8500000e+000, 1.2661437e+000, 2.8934600e-001;
1.9000000e+000, 1.2802119e+000, 2.7349957e-001;
1.9500000e+000, 1.2935056e+000, 2.5836802e-001;
2.0000000e+000, 1.3060604e+000, 2.4393764e-001;
2.0500000e+000, 1.3179108e+000, 2.3019252e-001;
2.1000000e+000, 1.3290908e+000, 2.1711492e-001;
2.1500000e+000, 1.3396331e+000, 2.0468562e-001;
2.2000000e+000, 1.3495698e+000, 1.9288424e-001;
2.2500000e+000, 1.3589316e+000, 1.8168951e-001;
2.3000000e+000, 1.3677485e+000, 1.7107954e-001;
2.3500000e+000, 1.3760490e+000, 1.6103206e-001;
2.4000000e+000, 1.3838607e+000, 1.5152455e-001;
2.4500000e+000, 1.3912100e+000, 1.4253451e-001;
2.5000000e+000, 1.3981224e+000, 1.3403952e-001;
2.5500000e+000, 1.4046219e+000, 1.2601741e-001;
2.6000000e+000, 1.4107316e+000, 1.1844637e-001;
2.6500000e+000, 1.4164737e+000, 1.1130502e-001;
2.7000000e+000, 1.4218690e+000, 1.0457250e-001;
2.7500000e+000, 1.4269374e+000, 9.8228503e-002;
2.8000000e+000, 1.4316980e+000, 9.2253356e-002;
2.8500000e+000, 1.4361686e+000, 8.6628033e-002;
2.9000000e+000, 1.4403663e+000, 8.1334185e-002;
2.9500000e+000, 1.4443072e+000, 7.6354161e-002;
3.0000000e+000, 1.4480066e+000, 7.1671012e-002;
3.0500000e+000, 1.4514790e+000, 6.7268499e-002;
3.1000000e+000, 1.4547379e+000, 6.3131088e-002;
3.1500000e+000, 1.4577963e+000, 5.9243945e-002;
3.2000000e+000, 1.4606662e+000, 5.5592924e-002;
3.2500000e+000, 1.4633593e+000, 5.2164556e-002;
3.3000000e+000, 1.4658862e+000, 4.8946029e-002;
3.3500000e+000, 1.4682572e+000, 4.5925175e-002;
3.4000000e+000, 1.4704818e+000, 4.3090446e-002;
3.4500000e+000, 1.4725691e+000, 4.0430894e-002;
3.5000000e+000, 1.4745277e+000, 3.7936152e-002;
3.5500000e+000, 1.4763653e+000, 3.5596407e-002;
3.6000000e+000, 1.4780897e+000, 3.3402381e-002;
3.6500000e+000, 1.4797079e+000, 3.1345309e-002;
3.7000000e+000, 1.4812264e+000, 2.9416913e-002;
3.7500000e+000, 1.4826516e+000, 2.7609382e-002;
3.8000000e+000, 1.4839892e+000, 2.5915350e-002;
3.8500000e+000, 1.4852449e+000, 2.4327872e-002;
3.9000000e+000, 1.4864237e+000, 2.2840407e-002;
3.9500000e+000, 1.4875305e+000, 2.1446794e-002;
4.0000000e+000, 1.4885698e+000, 2.0141237e-002;
4.0500000e+000, 1.4895460e+000, 1.8918278e-002;
4.1000000e+000, 1.4904629e+000, 1.7772787e-002;
4.1500000e+000, 1.4913245e+000, 1.6699941e-002;
4.2000000e+000, 1.4921341e+000, 1.5695204e-002;
4.2500000e+000, 1.4928951e+000, 1.4754317e-002;
4.3000000e+000, 1.4936105e+000, 1.3873279e-002;
4.3500000e+000, 1.4942833e+000, 1.3048331e-002;
4.4000000e+000, 1.4949162e+000, 1.2275945e-002;
4.4500000e+000, 1.4955117e+000, 1.1552810e-002;
4.5000000e+000, 1.4960723e+000, 1.0875819e-002;
4.5500000e+000, 1.4966000e+000, 1.0242055e-002;
4.6000000e+000, 1.4970971e+000, 9.6487843e-003;
4.6500000e+000, 1.4975655e+000, 9.0934416e-003;
4.7000000e+000, 1.4980071e+000, 8.5736213e-003;
4.7500000e+000, 1.4984235e+000, 8.0870684e-003;
4.8000000e+000, 1.4988163e+000, 7.6316686e-003;
4.8500000e+000, 1.4991871e+000, 7.2054403e-003;
4.9000000e+000, 1.4995373e+000, 6.8065263e-003;
4.9500000e+000, 1.4998682e+000, 6.4331862e-003;
5.0000000e+000, 1.5001810e+000, 6.0837891e-003;
5.0500000e+000, 1.5005000e+000, 6.0837891e-003];
end SaturationTab;
end IronSaturation; |
Units and nominal values | within PowerSystems.Common;
package Nominal "Units and nominal values"
extends Modelica.Icons.BasesPackage;
partial model Nominal "Units and nominal values"
parameter Boolean puUnits = true
"= true, if scaled with nom. values (pu), else scaled with 1 (SI)"
parameter SI.Voltage V_nom(final min=0)=1 "nominal Voltage (= base for pu)"
parameter SI.ApparentPower S_nom(final min=0)=1
"nominal Power (= base for pu)"
end Nominal;
partial model NominalAC "Units and nominal values AC"
extends Nominal;
parameter SI.Frequency f_nom=system.f_nom "nominal frequency"
protected
outer PowerSystems.System system;
end NominalAC;
partial model NominalDC "Units and nominal values DC"
import PowerSystems;
extends Nominal;
parameter SI.AngularVelocity w_nom=system.w_nom
"nominal r.p.m."
protected
outer PowerSystems.System system;
end NominalDC;
partial model NominalVI "Nominal values"
parameter SI.Voltage V_nom(final min=0)=1 "nom Voltage"
parameter SI.Current I_nom(final min=0)=1 "nom Current"
end NominalVI;
record NominalData "Units and nominal data"
extends Modelica.Icons.Record;
Boolean puUnits = true
"= true, if scaled with nom. values (pu), else scaled with 1 (SI)"
SI.Voltage V_nom(final min=0)=1 "nominal Voltage (= base for pu)"
SI.ApparentPower S_nom(final min=0)=1
"nominal Power (= base for pu)"
end NominalData;
record NominalDataAC "Units and nominal data AC"
extends NominalData;
SI.Frequency f_nom=50 "nominal frequency"
end NominalDataAC;
record NominalDataDC "Units and nominal data DC"
import PowerSystems;
extends NominalData;
SI.AngularVelocity w_nom=314.159265358979323846
"nominal r.p.m."
end NominalDataDC;
record NominalDataVI "Units and nominal data"
extends Modelica.Icons.Record;
SI.Voltage V_nom(final min=0)=1 "nom Voltage"
SI.Current I_nom(final min=0)=1 "nom Current"
end NominalDataVI;
record NominalDataTrafo "Units and nominal data transformer"
extends Modelica.Icons.Record;
Boolean puUnits = true
"= true, if scaled with nom. values (pu), else scaled with 1 (SI)"
SI.Voltage[:] V_nom(each final min=0)={1,1}
"{prim,sec} nom Voltage (= base of pu)"
SI.ApparentPower S_nom(final min=0)=1
"nominal Power (= base of pu)"
SI.Frequency f_nom=50 "nominal frequency"
end NominalDataTrafo;
end Nominal; |
Common components | within PowerSystems;
package Common "Common components"
extends Modelica.Icons.Package;
end Common; |
Plasma arcs | within PowerSystems.Common;
package Plasma "Plasma arcs"
extends Modelica.Icons.Package;
model ArcBreaker "Arc voltage for breakers"
extends Partials.ArcBase;
parameter SI.ElectricFieldStrength E "av electric field arc";
parameter Real r(unit="1/A") "= R0/(d*Earc), R0 small signal resistance";
input SI.Distance d "contact distance";
equation
v = d*E*tanh(r*i);
end ArcBreaker;
model ArcFault "Arc voltage for faults"
extends Partials.ArcBase;
parameter SI.Voltage V "arc voltage";
parameter Real r(unit="1/A") "= R0/V, R0 small signal resistance";
equation
v = V*tanh(r*i);
end ArcFault;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model ArcBase "Arc voltage base"
/*
SI.Voltage v;
SI.Current i;
InputVoltage v;
InputCurrent i;
*/
// Local connector definition, used for equation balancing check
connector InputVoltage = input SI.Voltage;
InputVoltage v;
SI.Current i;
end ArcBase;
end Partials;
end Plasma; |
Common switching components | within PowerSystems.Common;
package Switching "Common switching components"
extends Modelica.Icons.Package;
model Switch "Switch kernel, no terminals"
extends Partials.SwitchBase;
initial equation
pre(open) = not closed;
equation
when {open and i < 0, open and i > 0, closed} then
arc = edge(open);
end when;
{v,i} = if closed or arc then {epsR*s,s} else {s,epsG*s};
end Switch;
model Breaker "Breaker kernel, no terminals"
extends Partials.SwitchBase;
parameter SI.Distance D=50e-3 "contact distance open";
parameter SI.Time t_opening=20e-3 "opening duration";
parameter SI.ElectricFieldStrength Earc=50e3 "electric field arc";
parameter SI.Resistance R0=1 "small signal resistance arc";
replaceable Plasma.ArcBreaker arcBreaker(E=Earc, r=R0/(D*Earc), d=d)
protected
SI.Voltage v_arc;
SI.Current i_arc;
SI.Time t0(start=Modelica.Constants.inf, fixed=true) "start opening";
SI.Distance d "contact distance";
Boolean opening(start=false, fixed=true);
initial equation
pre(open) = not closed;
equation
arcBreaker.v=v_arc;
arcBreaker.i=i_arc;
when {open and i < 0, open and i > 0, closed} then
arc = edge(open) or opening;
end when;
when pre(arc) then
t0 = time;
end when;
opening = t0 < time and time < t0 + t_opening;
d = if opening then ((time - t0)/t_opening)^2*D else D
"d not needed if closed (d=0)";
i_arc = if arc then s else 0;
{v,i} = if closed then {epsR*s,s} else if arc then {v_arc,i_arc} else {s,epsG*s};
end Breaker;
model Short "Short kernel optionally with exponential relaxation, no terminals"
extends Partials.FaultBase;
parameter Boolean relax=false "use relaxation fct"
parameter SI.Time t_c=10e-3 "relaxation time constant"
parameter Real beta(min=2)=4 "power of exponent"
SI.Time t0(start=-Modelica.Constants.inf, fixed=true);
Real[2] r;
function relaxation=Utilities.Math.relaxation;
equation
when edge(on) then
t0 = time;
end when;
if relax then
r = relaxation(time - t0, t_c, beta);
{v,i} = if on then {(r[1] + r[2]*epsR)*s,s} else {s,(r[1]*epsG + r[2])*s};
else
r = {0,0};
{v,i} = if on then {epsR*s,s} else {s,epsG*s};
end if;
end Short;
model Fault "Line fault kernel, no terminals"
extends Partials.FaultBase;
parameter SI.Voltage Varc=100 "arc voltage";
parameter SI.Resistance R0=1 "small-signal resistance";
parameter SI.Current Iclear=10 "self clearing current";
parameter SI.Time t_c=1e-3 "cooling time constant";
Boolean arc(start=false, fixed=true);
protected
final parameter Real r=(R0/Varc);
final parameter Real Qclear=Iclear*Varc*t_c;
final parameter Real Qini=100*Qclear;
SI.Voltage v_arc;
SI.Current i_arc;
Real Q(start=0, fixed=true);
Boolean cleared(start=true, fixed=true);
replaceable Plasma.ArcFault arcFault(
V=Varc,
r=R0/Varc)
equation
arcFault.v = v_arc;
arcFault.i = i_arc;
when edge(on) then
reinit(Q, Qini);
end when;
when {on, cleared} then
arc = edge(on);
end when;
if arc then
i_arc = s;
{v,i} = {v_arc,i_arc};
der(Q) = v_arc*i_arc - Q/t_c;
else
i_arc = 0;
{v,i} = {s,epsG*s};
der(Q) = 0;
end if;
cleared = Q < Qclear;
end Fault;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model SwitchBase "Switch base kernel, no terminals"
parameter SI.Resistance epsR=1e-5 "resistance 'closed'";
parameter SI.Conductance epsG=1e-5 "conductance 'open'";
connector InputVoltage = input SI.Voltage;
InputVoltage v;
SI.Current i;
Boolean arc(start=false, fixed=true) "arc on";
Boolean open(start=true)=not closed;
Modelica.Blocks.Interfaces.BooleanInput closed(start=false)
"true:closed, false:open"
protected
Real s(start = 0.5);
end SwitchBase;
partial model FaultBase "Fault kernel base"
parameter SI.Resistance epsR=1e-5 "resistance 'short'";
parameter SI.Conductance epsG=1e-5 "conductance 'open'";
connector InputVoltage = input SI.Voltage;
InputVoltage v;
SI.Current i;
input Boolean on(start=false, fixed=true);
protected
Real s(start = 0.5);
end FaultBase;
end Partials;
end Switching; |
Thermal boundary and adaptors | within PowerSystems.Common;
package Thermal "Thermal boundary and adaptors"
extends Modelica.Icons.VariantsPackage;
model BdCond "Default (Neumann) boundary condition, scalar port"
extends Partials.BdCondBase;
Interfaces.Thermal_p heat "heat port"
equation
heat.T = T_amb;
end BdCond;
model BdCondV "Default (Neumann) boundary condition, vector port"
parameter Integer m(final min=1)=1 "dimension of heat port";
extends Partials.BdCondBase;
PowerSystems.Interfaces.ThermalV_p heat(
final m=m) "vector heat port"
equation
heat.ports.T = fill(T_amb, heat.m);
end BdCondV;
model Boundary "Boundary model, scalar port"
extends Partials.BoundaryBase;
output SI.HeatFlowRate Q_flow;
output SI.HeatFlowRate Qav_flow=q if av;
PowerSystems.Interfaces.Thermal_p heat "heat port"
protected
SI.HeatFlowRate q;
equation
heat.T = T;
Q_flow = heat.Q_flow;
if ideal then
T = T_amb;
else
C*der(T) = Q_flow - G*(T - T_amb);
end if;
if av then
der(q) = (Q_flow - q)/tcst;
else
q = 0;
end if;
end Boundary;
model BoundaryV "Boundary model, vector port"
parameter Boolean add_up=true "add up Q_flow at equal T";
parameter Integer m(final min=1)=1 "dimension of heat port";
extends Partials.BoundaryBase;
output SI.HeatFlowRate[if add_up then 1 else m] Q_flow;
output SI.HeatFlowRate[if add_up then 1 else m] Qav_flow=q if av;
PowerSystems.Interfaces.ThermalV_p heat(
final m=m) "vector heat port"
protected
SI.HeatFlowRate[if add_up then 1 else m] q;
equation
heat.ports.T = fill(T, heat.m);
if add_up then
Q_flow = {sum(heat.ports.Q_flow)};
else
Q_flow[1:m] = heat.ports.Q_flow;
end if;
if ideal then
T = T_amb;
else
C*der(T) = sum(Q_flow) - G*(T - T_amb);
end if;
if av then
der(q) = (Q_flow - q)/tcst;
else
q = zeros(if add_up then 1 else m);
end if;
end BoundaryV;
model Heat_a_b_ab "Adaptor 2 x Thermal (scalar) to ThermalV (vector)"
PowerSystems.Interfaces.Thermal_p port_a "scalar port a"
PowerSystems.Interfaces.Thermal_p port_b "scalar port b"
PowerSystems.Interfaces.ThermalV_n port_ab(
final m=2) "vector port {a,b}"
equation
{port_a.T, port_b.T} = port_ab.ports.T;
{port_a.Q_flow, port_b.Q_flow} + port_ab.ports.Q_flow = zeros(2);
end Heat_a_b_ab;
model Heat_a_b_c_abc "Adaptor 3 x Thermal (scalar) to ThermalV (vector)"
PowerSystems.Interfaces.Thermal_p port_a "scalar port a"
PowerSystems.Interfaces.Thermal_p port_b "scalar port b"
PowerSystems.Interfaces.Thermal_p port_c "scalar port c"
PowerSystems.Interfaces.ThermalV_n port_abc(
final m=3) "vector port {a,b,c}"
equation
{port_a.T, port_b.T, port_c.T} = port_abc.ports.T;
{port_a.Q_flow, port_b.Q_flow, port_c.Q_flow} + port_abc.ports.Q_flow = zeros(3);
end Heat_a_b_c_abc;
model HeatV_a_b_ab "Adaptor 2 x ThermalV (vector) to ThermalV (vector)"
parameter Integer[2] m={1,1} "dimension {port_a, port_b}";
PowerSystems.Interfaces.ThermalV_p port_a(
final m=m[1]) "vector port a"
PowerSystems.Interfaces.ThermalV_p port_b(
final m=m[2]) "vector port b"
PowerSystems.Interfaces.ThermalV_n port_ab(
final m=sum(m)) "vector port {a,b}"
equation
cat(1, port_a.ports.T, port_b.ports.T) = port_ab.ports.T;
cat(1, port_a.ports.Q_flow, port_b.ports.Q_flow) + port_ab.ports.Q_flow = zeros(sum(m));
end HeatV_a_b_ab;
model HeatV_a_b_c_abc "Adaptor 3 x Thermal (scalar) to ThermalV (vector)"
parameter Integer[3] m={1,1,1} "dimension {port_a, port_b, port_c}";
PowerSystems.Interfaces.ThermalV_p port_a(
final m=m[1]) "scalar port a"
PowerSystems.Interfaces.ThermalV_p port_b(
final m=m[2]) "scalar port b"
PowerSystems.Interfaces.ThermalV_p port_c(
final m=m[3]) "scalar port c"
PowerSystems.Interfaces.ThermalV_n port_abc(
final m=sum(m)) "vector port {a,b,c}"
equation
cat(1, port_a.ports.T, port_b.ports.T, port_c.ports.T) = port_abc.ports.T;
cat(1, port_a.ports.Q_flow, port_b.ports.Q_flow, port_c.ports.Q_flow) + port_abc.ports.Q_flow = zeros(sum(m));
end HeatV_a_b_c_abc;
model HeatV_S "Collector ThermalV (vector) to Thermal (scalar)"
parameter Integer m(final min=1) = 1 "dimension of port_a";
PowerSystems.Interfaces.ThermalV_p port_a(
final m=m) "vector port"
PowerSystems.Interfaces.Thermal_n port_b "scalar port"
equation
port_a.ports.T = fill( port_b.T, port_a.m);
sum(port_a.ports.Q_flow) + port_b.Q_flow = 0;
end HeatV_S;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
model BdCondBase "Default (Neumann) boundary condition base"
parameter SI.Temperature T_amb=300 "ambient temperature";
end BdCondBase;
partial model BoundaryBase "Boundary model base"
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter Boolean av=false "time average heat-flow"
parameter SI.Time tcst(min=1e-9)=1 "average time-constant"
parameter Boolean ideal=true "ideal cooling";
parameter SI.Temperature T_amb=300 "ambient temperature";
parameter SI.HeatCapacity C=1 "heat capacity cp*m"
parameter SI.ThermalConductance G=1 "thermal conductance to ambient"
SI.Temperature T(start=300) "temperature";
protected
outer System system;
initial equation
if not ideal and dynType == Types.Dynamics.SteadyInitial then
der(T) = 0;
end if;
end BoundaryBase;
end Partials;
end Thermal; |
Generator Exciters | within PowerSystems.Control;
package Exciters "Generator Exciters "
extends Modelica.Icons.VariantsPackage;
block ExciterSimple "Simple exciter for constant field voltage"
parameter Boolean par=true "v_f parameter or initialised?"
parameter SIpu.Voltage v_f(unit="1", fixed=par)=1 "exciter voltage"
Modelica.Blocks.Interfaces.RealInput termVoltage[3](each final unit="1")
"terminal voltage pu"
Modelica.Blocks.Interfaces.RealOutput fieldVoltage(final unit="1")
"field voltage pu"
equation
fieldVoltage = v_f;
end ExciterSimple;
block ExciterConst "Exciter for constant field voltage"
extends Partials.ExciterBase;
equation
connect(setptVoltage, limiter.u)
end ExciterConst;
block Exciter1st "Exciter first order"
extends Partials.ExciterBase;
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter Real k=50 "gain";
parameter SI.Time t=0.005 "time constant voltage regulator";
protected
outer System system;
final parameter Modelica.Blocks.Types.Init initType=
if dynType == Types.Dynamics.SteadyInitial then
Modelica.Blocks.Types.Init.SteadyState else
Modelica.Blocks.Types.Init.NoInit;
Blocks.Math.Norm norm(final n=3, n_eval=3)
Modelica.Blocks.Math.Add delta_voltage(k1=+1, k2=-1)
Modelica.Blocks.Continuous.TransferFunction voltageReg(
initType=initType,
a={t,1},
b={k})
equation
connect(setptVoltage, delta_voltage.u1)
connect(termVoltage, norm.u)
connect(norm.y, delta_voltage.u2)
connect(delta_voltage.y, voltageReg.u)
connect(voltageReg.y, limiter.u)
end Exciter1st;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial block ExciterBase "Exciter base"
extends PowerSystems.Icons.Block1;
parameter SIpu.Voltage[2] v_f_minmax(each unit="1")={0, 3}
"{min,max} exciter voltage";
Modelica.Blocks.Interfaces.RealInput setptVoltage(
final unit="1")
"setpoint norm of terminal voltage pu"
Modelica.Blocks.Interfaces.RealInput termVoltage[3](
each final unit="1") "terminal voltage pu"
Modelica.Blocks.Interfaces.RealOutput fieldVoltage(
final unit="1") "field voltage pu"
Modelica.Blocks.Nonlinear.Limiter limiter(uMin=v_f_minmax[1],uMax=v_f_minmax[2])
equation
connect(limiter.y, fieldVoltage)
end ExciterBase;
end Partials;
end Exciters; |
Turbine Governors | within PowerSystems.Control;
package Governors "Turbine Governors "
extends Modelica.Icons.VariantsPackage;
block GovernorSimple "Simple governor for constant turbine power"
parameter Boolean par=true "p parameter or initialised?"
parameter SIpu.Power p(unit="1", fixed=par)=1 "turbine power"
Modelica.Blocks.Interfaces.RealInput speed(
final unit="1") "speed of turbine pu"
Modelica.Blocks.Interfaces.RealOutput power(
final unit="1") "power of turbine pu"
equation
power = p;
end GovernorSimple;
block GovernorConst "Governor for constant turbine power"
extends Partials.GovernorBase;
initial equation
setptSpeed = speed;
equation
connect(setptPower, limiter.u)
end GovernorConst;
block Governor1st "Governor first order"
extends Partials.GovernorBase;
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter Real k=20 "Gain";
parameter Real t=5 "time constant speed regulator";
protected
outer System system;
final parameter Modelica.Blocks.Types.Init initType=
if dynType == Types.Dynamics.SteadyInitial then
Modelica.Blocks.Types.Init.SteadyState else
Modelica.Blocks.Types.Init.NoInit;
Modelica.Blocks.Math.Add delta_speed(k2=-1)
Modelica.Blocks.Continuous.TransferFunction speedReg(
initType=initType,
a={t,1},
b={k})
Modelica.Blocks.Math.Add delta_power
equation
connect(setptSpeed, delta_speed.u1)
connect(speed, delta_speed.u2)
connect(delta_speed.y, speedReg.u)
connect(speedReg.y, delta_power.u1)
connect(setptPower, delta_power.u2)
connect(delta_power.y, limiter.u)
end Governor1st;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial block GovernorBase "Governor base"
extends PowerSystems.Icons.Block1;
parameter SIpu.Power[2] p_minmax(each unit="1")={0,2}
"{min,max} turbine power";
Modelica.Blocks.Interfaces.RealInput setptPower(
final unit="1") "setpoint power pu"
Modelica.Blocks.Interfaces.RealInput setptSpeed(
final unit="1") "setpoint speed pu"
Modelica.Blocks.Interfaces.RealInput speed(
final unit="1") "turbine speed pu"
Modelica.Blocks.Interfaces.RealOutput power(
final unit="1") "turbine power pu"
Modelica.Blocks.Nonlinear.Limiter limiter(uMin=p_minmax[1], uMax=p_minmax[2])
equation
connect(limiter.y, power)
end GovernorBase;
end Partials;
end Governors; |
Ignition tables for inverters | within PowerSystems.Control;
package IgnitionTables "Ignition tables for inverters"
extends Modelica.Icons.VariantsPackage;
record Table_2 "Ignition Table2, 3 pulses/period"
extends Modelica.Icons.Record;
constant Real phiIgn[12, 7]=
[0.0, 0.52360, 1.5708, 2.6180, 3.6652, 4.7124, 5.7596;
0.1, 0.56774, 1.5708, 2.5738, 3.7093, 4.7124, 5.7154;
0.2, 0.60946, 1.5708, 2.5321, 3.7511, 4.7124, 5.6737;
0.3, 0.64876, 1.5708, 2.4928, 3.7904, 4.7124, 5.6344;
0.4, 0.68570, 1.5708, 2.4559, 3.8273, 4.7124, 5.5975;
0.5, 0.72036, 1.5708, 2.4212, 3.8620, 4.7124, 5.5628;
0.6, 0.75285, 1.5708, 2.3887, 3.8944, 4.7124, 5.5303;
0.7, 0.78331, 1.5708, 2.3583, 3.9249, 4.7124, 5.4999;
0.8, 0.81185, 1.5708, 2.3297, 3.9534, 4.7124, 5.4713;
0.9, 0.83862, 1.5708, 2.3030, 3.9802, 4.7124, 5.4446;
1.0, 0.86373, 1.5708, 2.2779, 4.0053, 4.7124, 5.4195;
1.1, 0.86373, 1.5708, 2.2779, 4.0053, 4.7124, 5.4195];
end Table_2;
record Table_3 "Ignition Table3, 5 pulses/period"
extends Modelica.Icons.Record;
constant Real phiIgn[12, 11]=
[0.0, 0.31416, 0.94248, 1.5708, 2.1991, 2.8274, 3.4558, 4.0841, 4.7124, 5.3407, 5.9690;
0.1, 0.34374, 0.92353, 1.5708, 2.2181, 2.7979, 3.4853, 4.0651, 4.7124, 5.3597, 5.9394;
0.2, 0.37268, 0.90360, 1.5708, 2.2380, 2.7689, 3.5143, 4.0452, 4.7124, 5.3796, 5.9105;
0.3, 0.40093, 0.88262, 1.5708, 2.2590, 2.7407, 3.5425, 4.0242, 4.7124, 5.4006, 5.8823;
0.4, 0.42846, 0.86054, 1.5708, 2.2811, 2.7131, 3.5701, 4.0021, 4.7124, 5.4226, 5.8547;
0.5, 0.45524, 0.83732, 1.5708, 2.3043, 2.6864, 3.5968, 3.9789, 4.7124, 5.4459, 5.8279;
0.6, 0.48125, 0.81291, 1.5708, 2.3287, 2.6603, 3.6228, 3.9545, 4.7124, 5.4703, 5.8019;
0.7, 0.50646, 0.78727, 1.5708, 2.3543, 2.6351, 3.6481, 3.9289, 4.7124, 5.4959, 5.7767;
0.8, 0.53089, 0.76037, 1.5708, 2.3812, 2.6107, 3.6725, 3.9020, 4.7124, 5.5228, 5.7523;
0.9, 0.55453, 0.73220, 1.5708, 2.4094, 2.5871, 3.6961, 3.8738, 4.7124, 5.5510, 5.7287;
1.0, 0.57739, 0.70275, 1.5708, 2.4388, 2.5642, 3.7190, 3.8443, 4.7124, 5.5804, 5.7058;
1.1, 0.57739, 0.70275, 1.5708, 2.4388, 2.5642, 3.7190, 3.8443, 4.7124, 5.5804, 5.7058];
end Table_3;
record Table_4 "Ignition Table4, 7 pulses/period"
extends Modelica.Icons.Record;
constant Real phiIgn[12, 15]=
[0.0, 0.22440, 0.67320, 1.1220, 1.5708, 2.0196, 2.4684, 2.9172,
3.3660, 3.8148, 4.2636, 4.7124, 5.1612, 5.6100, 6.0588;
0.1, 0.24616, 0.65541, 1.1315, 1.5708, 2.0101, 2.4862, 2.8954,
3.3878, 3.7970, 4.2731, 4.7124, 5.1516, 5.6278, 6.0370;
0.2, 0.26768, 0.63712, 1.1407, 1.5708, 2.0009, 2.5045, 2.8739,
3.4093, 3.7787, 4.2823, 4.7124, 5.1425, 5.6461, 6.0155;
0.3, 0.28893, 0.61834, 1.1495, 1.5708, 1.9921, 2.5232, 2.8527,
3.4305, 3.7599, 4.2911, 4.7124, 5.1337, 5.6648, 5.9943;
0.4, 0.30988, 0.59907, 1.1580, 1.5708, 1.9836, 2.5425, 2.8317,
3.4515, 3.7407, 4.2996, 4.7124, 5.1252, 5.6841, 5.9733;
0.5, 0.33053, 0.57930, 1.1662, 1.5708, 1.9754, 2.5623, 2.8111,
3.4721, 3.7209, 4.3078, 4.7124, 5.1170, 5.7039, 5.9527;
0.6, 0.35084, 0.55906, 1.1740, 1.5708, 1.9676, 2.5825, 2.7908,
3.4924, 3.7006, 4.3156, 4.7124, 5.1092, 5.7241, 5.9323;
0.7, 0.37080, 0.53834, 1.1816, 1.5708, 1.9600, 2.6033, 2.7708,
3.5124, 3.6799, 4.3232, 4.7124, 5.1016, 5.7448, 5.9124;
0.8, 0.39041, 0.51715, 1.1889, 1.5708, 1.9527, 2.6244, 2.7512,
3.5320, 3.6587, 4.3305, 4.7124, 5.0943, 5.7660, 5.8928;
0.9, 0.40965, 0.49553, 1.1959, 1.5708, 1.9457, 2.6461, 2.7319,
3.5512, 3.6371, 4.3375, 4.7124, 5.0872, 5.7877, 5.8735;
1.0, 0.42851, 0.47349, 1.2027, 1.5708, 1.9389, 2.6681, 2.7131,
3.5701, 3.6151, 4.3443, 4.7124, 5.0804, 5.8097, 5.8547;
1.1, 0.42851, 0.47349, 1.2027, 1.5708, 1.9389, 2.6681, 2.7131,
3.5701, 3.6151, 4.3443, 4.7124, 5.0804, 5.8097, 5.8547];
end Table_4;
record Table_5 "Ignition Table5, 9 pulses/period"
extends Modelica.Icons.Record;
constant Real phiIgn[12, 19]=
[0.0, 0.17453, 0.52360, 0.87266, 1.2217, 1.5708, 1.9199, 2.2689, 2.6180, 2.9671,
3.3161, 3.6652, 4.0143, 4.3633, 4.7124, 5.0615, 5.4105, 5.7596, 6.1087;
0.1, 0.19167, 0.50835, 0.88373, 1.2157, 1.5708, 1.9259, 2.2579, 2.6332, 2.9499,
3.3333, 3.6499, 4.0253, 4.3573, 4.7124, 5.0675, 5.3995, 5.7748, 6.0915;
0.2, 0.20868, 0.49285, 0.89451, 1.2094, 1.5708, 1.9322, 2.2471, 2.6487, 2.9329,
3.3503, 3.6344, 4.0361, 4.3510, 4.7124, 5.0738, 5.3887, 5.7903, 6.0745;
0.3, 0.22557, 0.47709, 0.90501, 1.2029, 1.5708, 1.9387, 2.2366, 2.6645, 2.9160,
3.3672, 3.6187, 4.0466, 4.3445, 4.7124, 5.0803, 5.3782, 5.8061, 6.0576;
0.4, 0.24231, 0.46108, 0.91522, 1.1962, 1.5708, 1.9454, 2.2264, 2.6805, 2.8993,
3.3839, 3.6027, 4.0568, 4.3378, 4.7124, 5.0870, 5.3680, 5.8221, 6.0409;
0.5, 0.25889, 0.44482, 0.92517, 1.1892, 1.5708, 1.9524, 2.2164, 2.6968, 2.8827,
3.4005, 3.5864, 4.0668, 4.3308, 4.7124, 5.0940, 5.3580, 5.8384, 6.0243;
0.6, 0.27531, 0.42834, 0.93486, 1.1820, 1.5708, 1.9596, 2.2067, 2.7133, 2.8663,
3.4169, 3.5699, 4.0765, 4.3236, 4.7124, 5.1011, 5.3483, 5.8548, 6.0079;
0.7, 0.29155, 0.41163, 0.94430, 1.1746, 1.5708, 1.9670, 2.1973, 2.7300, 2.8500,
3.4331, 3.5532, 4.0859, 4.3162, 4.7124, 5.1086, 5.3389, 5.8716, 5.9916;
0.8, 0.30761, 0.39471, 0.95349, 1.1669, 1.5708, 1.9747, 2.1881, 2.7469, 2.8340,
3.4492, 3.5363, 4.0951, 4.3084, 4.7124, 5.1163, 5.3297, 5.8885, 5.9756;
0.9, 0.32347, 0.37758, 0.96244, 1.1588, 1.5708, 1.9828, 2.1792, 2.7640, 2.8181,
3.4651, 3.5192, 4.1040, 4.3004, 4.7124, 5.1244, 5.3207, 5.9056, 5.9597;
1.0, 0.33913, 0.36027, 0.97116, 1.1505, 1.5708, 1.9911, 2.1704, 2.7813, 2.8025,
3.4807, 3.5019, 4.1128, 4.2921, 4.7124, 5.1327, 5.3120, 5.9229, 5.9441;
1.1, 0.33913, 0.36027, 0.97116, 1.1505, 1.5708, 1.9911, 2.1704, 2.7813, 2.8025,
3.4807, 3.5019, 4.1128, 4.2921, 4.7124, 5.1327, 5.3120, 5.9229, 5.9441];
end Table_5;
end IgnitionTables; |
Pulse width modulation | within PowerSystems.Control;
package Modulation "Pulse width modulation"
extends Modelica.Icons.VariantsPackage;
block PWMasyn "Sine PWM asynchronous mode, 3phase"
extends Partials.PWMasynBase(final m=3);
protected
constant SI.Angle[3] phShift=(0:2)*2*pi/3;
Real[3] v_abc;
discrete SI.Time[3] sigdel_t;
discrete SI.Time[3] t0;
initial algorithm
for k in 1:3 loop
if v_abc[k] > -1 then
gates[{pgt[k], ngt[k]}] := {true,false};
sigdel_t[k] := del_t;
else
gates[{pgt[k], ngt[k]}] := {false,true};
sigdel_t[k] := -del_t;
end if;
t0[k] := del_t;
end for;
equation
v_abc = vPhasor [1]*cos(fill(theta +vPhasor [2], 3) - phShift);
/*
for k in 1:3 loop // assumes |v_abc| < 1:
when time > pre(t0[k]) + pre(sigdel_t[k])*v_abc[k] then
gates[{pgt[k], ngt[k]}] = pre(gates[{ngt[k], pgt[k]}]);
sigdel_t[k] = -pre(sigdel_t[k]);
t0[k] = pre(t0[k]) + 2*del_t;
end when;
end for;
*/
for k in 1:3 loop // allows |v_abc| >= 1:
when time > pre(t0[k]) + pre(sigdel_t[k])*v_abc[k] then
if noEvent(time < pre(t0[k]) + delp_t) then
gates[{pgt[k], ngt[k]}] = pre(gates[{ngt[k],pgt[k]}]);
sigdel_t[k] = -pre(sigdel_t[k]);
t0[k] = pre(t0[k]) + 2*del_t;
else
gates[{pgt[k], ngt[k]}] = pre(gates[{pgt[k],ngt[k]}]);
sigdel_t[k] = pre(sigdel_t[k]);
t0[k] = pre(t0[k]) + 4*del_t;
end if;
end when;
end for;
end PWMasyn;
block PWMsyn "Sine PWM synchronous mode, 3phase"
extends Partials.PWMsynBase(final m=3);
protected
constant SI.Angle[3] phShift=(0:2)*2*pi/3;
final parameter SI.Angle[m2] phi0=(1:2:2*m2 - 1)*del_phi;
Integer[3] n;
SI.Angle[3] phi;
Real[3] v_abc;
discrete Real[3] sigdel_phi;
function mod2sign = Utilities.Math.mod2sign;
initial algorithm
n := {1,1,1} + integer(phi/(2*del_phi));
for k in 1:3 loop
if -scalar(mod2sign({n[k]})) > 0 then
if phi[k] <= phi0[n[k]] + del_phi*v_abc[k] then
gates[{pgt[k], ngt[k]}] := {true,false};
sigdel_phi[k] := del_phi;
else
gates[{pgt[k], ngt[k]}] := {false,true};
sigdel_phi[k] := -del_phi;
n[k] := if n[k] < m2 then n[k] + 1 else 1;
end if;
else
if phi[k] <= phi0[n[k]] - del_phi*v_abc[k] then
gates[{pgt[k], ngt[k]}] := {false,true};
sigdel_phi[k] := -del_phi;
else
gates[{pgt[k], ngt[k]}] := {true,false};
sigdel_phi[k] := del_phi;
n[k] := if n[k] < m2 then n[k] + 1 else 1;
end if;
end if;
end for;
equation
phi = mod(fill(theta +vPhasor [2], 3) - phShift, 2*pi);
v_abc =vPhasor [1]*cos(phi);
/*
for k in 1:3 loop // assumes |v_abc| < 1:
when phi[k] > phi0[(pre(n[k]))] + pre(sigdel_phi[k])*v_abc[k] then
gates[{pgt[k], ngt[k]}] = pre(gates[{ngt[k], pgt[k]}]);
sigdel_phi[k] = -pre(sigdel_phi[k]);
n[k] = if pre(n[k]) < m2 then pre(n[k]) + 1 else 1;
end when;
end for;
*/
for k in 1:3 loop // allows |v_abc| >= 1:
when phi[k] > phi0[pre(n[k])] + pre(sigdel_phi[k])*v_abc[k] then
if noEvent(phi[k] < phi0[pre(n[k])] + delp_phi) then
gates[{pgt[k], ngt[k]}] = pre(gates[{ngt[k],pgt[k]}]);
sigdel_phi[k] = -pre(sigdel_phi[k]);
n[k] = if pre(n[k]) < m2 then pre(n[k]) + 1 else 1;
else
gates[{pgt[k], ngt[k]}] = pre(gates[{pgt[k],ngt[k]}]);
sigdel_phi[k] = pre(sigdel_phi[k]);
n[k] = if pre(n[k]) < m2 - 1 then pre(n[k]) + 2 else pre(n[k]) + 2 - m2;
end if;
end when;
end for;
end PWMsyn;
block PWMtab "PWM tabulated, synchronous mode, 3phase"
extends Partials.PWMsynBase(final m=3, final mult=integer((size(table.phiIgn, 2)+1)/4));
replaceable PowerSystems.Control.IgnitionTables.Table_2 table
"table(multiplicity)"
protected
constant SI.Angle[3] phShift=(0:2)*2*pi/3;
discrete SI.Angle[m2] phiIgn1;
discrete SI.Angle[m2] phiIgn2;
discrete SI.Angle[m2] phiIgn3;
// discrete SI.Angle[3,m2] phiIgn; // desired version
Integer[3] n;
SI.Angle[3] phi;
function intpol = Utilities.Math.interpolateTable;
initial algorithm
n := {1,1,1};
phiIgn1 := intpol(vPhasor[1], table.phiIgn);
gates[{pgt[1], ngt[1]}] := {true, false};
while phiIgn1[n[1]] < phi[1] and phi[1] < phiIgn1[end] loop
n[1] := n[1] + 1;
gates[{pgt[1], ngt[1]}] := gates[{ngt[1], pgt[1]}];
end while;
phiIgn2 := intpol(vPhasor[1], table.phiIgn);
gates[{pgt[2], ngt[2]}] := {true, false};
while phiIgn2[n[2]] < phi[2] and phi[2] < phiIgn2[end] loop
n[2] := n[2] + 1;
gates[{pgt[2], ngt[2]}] := gates[{ngt[2], pgt[2]}];
end while;
phiIgn3 := intpol(vPhasor[1], table.phiIgn);
gates[{pgt[3], ngt[3]}] := {true, false};
while phiIgn3[n[3]] < phi[3] and phi[3] < phiIgn3[end] loop
n[3] := n[3] + 1;
gates[{pgt[3], ngt[3]}] := gates[{ngt[3], pgt[3]}];
end while;
equation
phi = mod(fill(theta +vPhasor [2], 3) - phShift, 2*pi);
when phi[1] > pre(phiIgn1[pre(n[1])]) then
gates[{pgt[1], ngt[1]}] = pre(gates[{ngt[1], pgt[1]}]);
n[1] = if pre(n[1]) < m2 then pre(n[1]) + 1 else 1;
end when;
when phi[2] > pre(phiIgn2[pre(n[2])]) then
gates[{pgt[2], ngt[2]}] = pre(gates[{ngt[2], pgt[2]}]);
n[2] = if pre(n[2]) < m2 then pre(n[2]) + 1 else 1;
end when;
when phi[3] > pre(phiIgn3[pre(n[3])]) then
gates[{pgt[3], ngt[3]}] = pre(gates[{ngt[3], pgt[3]}]);
n[3] = if pre(n[3]) < m2 then pre(n[3]) + 1 else 1;
end when;
when n[1]==1 then
phiIgn1 = intpol(vPhasor[1], table.phiIgn);
end when;
when n[2]==1 then
phiIgn2 = intpol(vPhasor[1], table.phiIgn);
end when;
when n[3]==1 then
phiIgn3 = intpol(vPhasor[1], table.phiIgn);
end when;
/* desired version:
initial algorithm
n := {1,1,1};
for k in 1:3 loop
phiIgn[k,:] := intpol(vPhasor[1], table.phiIgn);
gates[{pgt[k], ngt[k]}] := {true, false};
while phiIgn[k, n[k]] < phi[k] and phi[k] < phiIgn[k, end] loop
n[k] := n[k] + 1;
gates[{pgt[k], ngt[k]}] := gates[{ngt[k], pgt[k]}];
end while;
end for;
equation
for k in 1:3 loop
when phi[k] > pre(phiIgn[k, pre(n[k])]) then
gates[{pgt[k], ngt[k]}] := pre(gates[{ngt[k],pgt[k]}]);
n[k] := if pre(n[k]) < m2 then pre(n[k]) + 1 else 1;
end when;
when n[k]==1 then
phiIgn[k,:] := intpol(vPhasor[1], table.phiIgn);
end when;
end for;*/
end PWMtab;
block SVPWMasyn "Space vector PWM asynchronous mode"
extends Partials.SVPWMsynBase;
protected
Real u;
SI.Angle phi;
discrete SI.Angle phi_s;
discrete SI.Angle[m2] phiIgn;
Integer i;
Integer k;
Integer n;
Integer s;
initial algorithm
s := integer(3*phi/pi) + 1;
phi_s := (s - 1)*pi/3;
phiIgn := Phi + u*Dphi;
i := 1;
n := 1;
while phiIgn[n] < phi - phi_s loop
n := n + 1;
i := if i < imax then i + 1 else 1;
end while;
k := K[s, i];
gates[{1,3,5}] := state[k,:];
gates[{2,4,6}] := {not state[k,1], not state[k,2], not state[k,3]};
equation
u = min(vPhasor[1], 0.85); // preliminary (no overmodulation)
phi = mod(theta +vPhasor [2], 2*pi);
when phi > pre(phi_s) + pre(phiIgn[pre(n)]) then
if pre(n) < m2 then
i = if pre(i) < imax then pre(i) + 1 else 1;
n = pre(n) + 1;
s = pre(s);
phi_s = pre(phi_s);
phiIgn = pre(phiIgn);
else
i = 1;
n = 1;
if pre(s) < 6 then
s = pre(s) + 1;
phi_s = pre(phi_s) + pi/3;
phiIgn = pre(phiIgn);
else
s = 1;
phi_s = 0;
phiIgn = Phi + u*Dphi;
end if;
end if;
k = K[s, i];
gates[{1,3,5}] = state[k,:];
gates[{2,4,6}] = {not state[k,1], not state[k,2], not state[k,3]};
end when;
end SVPWMasyn;
block SVPWMsyn "Space vector PWM synchronous mode"
extends Partials.SVPWMsynBase;
protected
Real u;
SI.Angle phi;
discrete SI.Angle phi_s;
discrete SI.Angle[m2] phiIgn;
Integer i;
Integer k;
Integer n;
Integer s;
initial algorithm
s := integer(3*phi/pi) + 1;
phi_s := (s - 1)*pi/3;
phiIgn := Phi + u*Dphi;
i := 1;
n := 1;
while phiIgn[n] < phi - phi_s loop
n := n + 1;
i := if i < imax then i + 1 else 1;
end while;
k := K[s, i];
gates[{1,3,5}] := state[k,:];
gates[{2,4,6}] := {not state[k,1], not state[k,2], not state[k,3]};
equation
u = min(vPhasor[1], 0.85); // preliminary (no overmodulation)
phi = mod(theta +vPhasor [2], 2*pi);
when phi > pre(phi_s) + pre(phiIgn[pre(n)]) then
if pre(n) < m2 then
i = if pre(i) < imax then pre(i) + 1 else 1;
n = pre(n) + 1;
s = pre(s);
phi_s = pre(phi_s);
phiIgn = pre(phiIgn);
else
i = 1;
n = 1;
if pre(s) < 6 then
s = pre(s) + 1;
phi_s = pre(phi_s) + pi/3;
phiIgn = pre(phiIgn);
else
s = 1;
phi_s = 0;
phiIgn = Phi + u*Dphi;
end if;
end if;
k = K[s, i];
gates[{1,3,5}] = state[k,:];
gates[{2,4,6}] = {not state[k,1], not state[k,2], not state[k,3]};
end when;
end SVPWMsyn;
block SVPWM "Space vector PWM"
extends Partials.SVPWMbase;
parameter SI.Frequency f_carr=1e3 "carrier frequency";
Blocks.Transforms.PhasorToAlphaBeta phToAlphaBeta
SpaceVector.SVMlogic logic(T_pwm=1/f_carr)
SpaceVector.SVMpwm pwm(T_pwm=1/f_carr)
Modelica.Blocks.Math.Add phaseCorr
equation
phaseCorr.u2 = der(theta)/(2*f_carr); //d_phi = pi*f/f_carr.
connect(vPhasor, phToAlphaBeta.u)
connect(phToAlphaBeta.y, logic.u_alpha_beta)
connect(logic.trigger, pwm.trigger)
connect(pwm.switch, gates)
connect(logic.dutyRatio, pwm.dutyRatio)
connect(theta, phaseCorr.u1)
connect(phaseCorr.y, phToAlphaBeta.theta)
end SVPWM;
block BlockM "Block modulation, 3phase"
extends Partials.BlockBase(final m=3);
protected
constant SI.Angle[3] phShift=(0:2)*2*pi/3;
SI.Angle alpha;
Real a;
Real[3] v_abc;
equation
alpha = max(min((1 - width)*pi/2, pi/2 - dphimin), 0);
a = sin(alpha);
v_abc = cos(fill(theta +vPhasor [2], 3) - phShift);
for k in 1:3 loop
gates[{pgt[k], ngt[k]}] = {v_abc[k] > a, v_abc[k] < -a};
end for;
end BlockM;
block PWMasyn1ph "Sine PWM asynchronous mode, 1-phase"
extends Partials.PWMasynBase(final m=2);
protected
Real u;
discrete SI.Time sigdel_t;
discrete SI.Time t0;
initial algorithm
if u > -1 then
gates[{pgt[1], ngt[1]}] := {true,false};
gates[{pgt[2], ngt[2]}] := {false,true};
sigdel_t := del_t;
else
gates[{pgt[1], ngt[1]}] := {false,true};
gates[{pgt[2], ngt[2]}] := {true,false};
sigdel_t := -del_t;
end if;
t0 := del_t;
equation
u =vPhasor [1]*cos(theta +vPhasor [2]);
/*
//assumes |u| < 1:
when time > pre(t0) + pre(sigdel_t)*u then
gates[{pgt[1], ngt[1]}] = pre(gates[{ngt[1], pgt[1]}]);
gates[{pgt[2], ngt[2]}] = pre(gates[{ngt[2], pgt[2]}]);
sigdel_t = -pre(sigdel_t);
t0 = pre(t0) + 2*del_t;
end when;
*/
//allows |u| >= 1:
when time > pre(t0) + pre(sigdel_t)*u then
if noEvent(time < pre(t0) + delp_t) then
gates[{pgt[1], ngt[1]}] = pre(gates[{ngt[1], pgt[1]}]);
gates[{pgt[2], ngt[2]}] = pre(gates[{ngt[2], pgt[2]}]);
sigdel_t = -pre(sigdel_t);
t0 = pre(t0) + 2*del_t;
else
gates = pre(gates);
sigdel_t = pre(sigdel_t);
t0 = pre(t0) + 4*del_t;
end if;
end when;
end PWMasyn1ph;
block PWMsyn1ph "Sine PWM synchronous mode, 1-phase"
extends Partials.PWMsynBase(final m=2);
protected
final parameter SI.Angle[m2] phi0=(1:2:2*m2 - 1)*del_phi;
SI.Angle phi;
Real u;
Integer n;
Integer sigma;
discrete Real sigdel_phi;
function mod2sign = Utilities.Math.mod2sign;
initial algorithm
n := 1 + integer(phi/(2*del_phi));
sigma := -scalar(mod2sign({n}));
if sigma > 0 then
if phi <= phi0[n] + del_phi*u then
gates[{pgt[1], ngt[1]}] := {true,false};
gates[{pgt[2], ngt[2]}] := {false,true};
sigdel_phi := del_phi;
else
gates[{pgt[1], ngt[1]}] := {false,true};
gates[{pgt[2], ngt[2]}] := {true,false};
sigdel_phi := -del_phi;
n := if n < m2 then n + 1 else 1;
end if;
else
if phi <= phi0[n] - del_phi*u then
gates[{pgt[1], ngt[1]}] := {false,true};
gates[{pgt[2], ngt[2]}] := {true,false};
sigdel_phi := -del_phi;
else
gates[{pgt[1], ngt[1]}] := {true,false};
gates[{pgt[2], ngt[2]}] := {false,true};
sigdel_phi := del_phi;
n := if n < m2 then n + 1 else 1;
end if;
end if;
equation
sigma = pre(sigma);
phi = mod(theta +vPhasor [2], 2*pi);
u =vPhasor [1]*cos(phi);
/*
// assumes |v_abc| < 1:
when phi > phi0[(pre(n))] + pre(sigdel_phi)*u then
gates[{pgt[1], ngt[1]}] = pre(gates[{ngt[1], pgt[1]}]);
gates[{pgt[2], ngt[2]}] = pre(gates[{ngt[2], pgt[2]}]);
sigdel_phi = -pre(sigdel_phi);
n = if pre(n) < m2 then pre(n) + 1 else 1;
end when;
*/
// allows |v_abc| >= 1:
when phi > phi0[pre(n)] + pre(sigdel_phi)*u then
if noEvent(phi < phi0[pre(n)] + delp_phi) then
gates[{pgt[1], ngt[1]}] = pre(gates[{ngt[1], pgt[1]}]);
gates[{pgt[2], ngt[2]}] = pre(gates[{ngt[2], pgt[2]}]);
sigdel_phi = -pre(sigdel_phi);
n = if pre(n) < m2 then pre(n) + 1 else 1;
else
gates = pre(gates);
sigdel_phi = pre(sigdel_phi);
n = if pre(n) < m2 - 1 then pre(n) + 2 else pre(n) + 2 -
m2;
end if;
end when;
end PWMsyn1ph;
block PWMtab1ph "PWM tabulated, synchronous mode, 1-phase"
extends Partials.PWMsynBase(final m=2, final mult=integer((size(table.phiIgn, 2)+1)/4));
replaceable PowerSystems.Control.IgnitionTables.Table_2 table
"table(multiplicity)"
protected
discrete SI.Angle[m2] phiIgn;
SI.Angle phi;
Integer n;
function intpol = Utilities.Math.interpolateTable;
initial algorithm
n := 1;
phiIgn := intpol(vPhasor[1], table.phiIgn);
gates[{pgt[1], ngt[1]}] := {true, false};
gates[{pgt[2], ngt[2]}] := {false, true};
while phiIgn[n] < phi and phi < phiIgn[end] loop
n := n + 1;
gates[{pgt[1], ngt[1]}] := gates[{ngt[1], pgt[1]}];
gates[{pgt[2], ngt[2]}] := gates[{ngt[2], pgt[2]}];
end while;
equation
phi = mod(theta +vPhasor [2], 2*pi);
when phi > pre(phiIgn[pre(n)]) then
gates[{pgt[1], ngt[1]}] = pre(gates[{ngt[1], pgt[1]}]);
gates[{pgt[2], ngt[2]}] = pre(gates[{ngt[2], pgt[2]}]);
n = if pre(n) < m2 then pre(n) + 1 else 1;
end when;
when n==1 then
phiIgn = intpol(vPhasor[1], table.phiIgn);
end when;
end PWMtab1ph;
block BlockM1ph "Block modulation, 1phase"
extends Partials.BlockBase(final m=2);
protected
SI.Angle alpha;
Real a;
Real u;
equation
alpha = max(min((1 - width)*pi/2, pi/2 - dphimin), 0);
a = sin(alpha);
u = cos(theta +vPhasor [2]);
gates[{pgt[1], ngt[1]}] = {u > a, u < -a};
gates[{pgt[2], ngt[2]}] = {u < -a, u > a};
end BlockM1ph;
block ChopperPWM "Chopper PWM (voltage)"
extends PowerSystems.Icons.BlockS;
parameter SI.Frequency f_carr=500 "carrier frequency";
Modelica.Blocks.Interfaces.RealInput vDC "desired average voltage, pu"
Modelica.Blocks.Interfaces.BooleanOutput gate(start=false) "gate"
protected
final parameter SI.Time del_t=1/f_carr;
discrete SI.Time t0;
discrete SI.Time t1;
equation
when sample(0, del_t) then
t0 = time;
t1 = time +vDC *del_t;
end when;
gate = t0 <= time and time < t1;
end ChopperPWM;
block ChopperPWM_I "Chopper PWM (current)"
extends PowerSystems.Icons.BlockS;
parameter SI.Current iRipple=1 "max ripple current";
Modelica.Blocks.Interfaces.BooleanOutput gate(start=false) "gate"
Modelica.Blocks.Interfaces.RealInput iSet "desired current"
Modelica.Blocks.Interfaces.RealInput iMeas "measured current"
protected
SI.Current di;
equation
di = (iMeas - iSet);
if di > iRipple then
gate = false;
elseif di < -iRipple then
gate = true;
else
gate = pre(gate);
end if;
end ChopperPWM_I;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial block ModulatorBase "Modulator base"
extends PowerSystems.Icons.BlockS;
parameter Integer m(min=2,max=3)=3 "3 for 3-phase, 2 for 1-phase";
Modelica.Blocks.Interfaces.RealInput theta "reference angle"
Modelica.Blocks.Interfaces.RealInput[2] vPhasor
"voltage demand pu {norm(v), phase(v)} (see info)"
Modelica.Blocks.Interfaces.BooleanOutput[2*m] gates(each start=false) "gates"
protected
final parameter Integer[m] pgt=1:2:(2*m-1) "positive gates"
final parameter Integer[m] ngt=2:2:(2*m) "negative gates"
end ModulatorBase;
partial block SVPWMbase "Space vector PWM base"
extends ModulatorBase(final m=3);
parameter Boolean sym=true "'symmetric' or 'antisymmetric'"
protected
Boolean[8,3] state=
[true,false,false;
true,true,false;
false,true,false;
false,true,true;
false,false,true;
true,false,true;
false,false,false;
true,true,true];
end SVPWMbase;
partial block SVPWMasynBase "Space vector PWM asynchronous base"
extends SVPWMbase;
/* asynchronous:
parameter SI.Frequency f_carr=1e3 "carrier frequency" annotation 0;
protected
final parameter SI.Time del_t=1/(2*f_carr) annotation 1;
constant Integer mult=10 "number of stored phase-values";
constant SI.Angle del_phi=pi/(3*mult);
//constant SI.Angle[1+mult] dt=(del_t/sqrt(3))*sin((0:mult)*del_phi);
constant SI.Angle[1+mult] dt_sum=(del_t/sqrt(3))*(sin((mult:-1:0)*del_phi)+sin((0:mult)*del_phi));
constant SI.Angle[1+mult] dt_dif=(del_t/sqrt(3))*(sin((mult:-1:0)*del_phi)-sin((0:mult)*del_phi));
SI.Angle Phi;
SI.Angle[3] Dt;
Integer[6,:] K=if sym then
[7,1,2,8,2,1;
7,3,2,8,2,3;
7,3,4,8,4,3;
7,5,4,8,4,5;
7,5,6,8,6,5;
7,1,6,8,6,1] else
[7,1,2,8;
7,3,2,8;
7,3,4,8;
7,5,4,8;
7,5,6,8;
7,1,6,8];
Integer imax = size(K,2);
*/
parameter Integer mult(min=1)=1 "multiplicity (6m-1 pulses/period)"
protected
final parameter Integer m1=if sym then 2*mult else mult
final parameter Integer m2=if sym then 3*m1-1 else 4*m1-1
final parameter SI.Angle del_phi=pi/(3*m1)
final parameter SI.Angle[m1] dphi=(del_phi/sqrt(3))*sin((1:m1)*del_phi)
SI.Angle[m2] Phi;
SI.Angle[m2] Dphi;
Integer[6,:] K=if sym then
[1,7,1,2,8,2;
2,8,2,3,7,3;
3,7,3,4,8,4;
4,8,4,5,7,5;
5,7,5,6,8,6;
6,8,6,1,7,1] else
[1,7,8,2,0,0;
2,8,7,3,0,0;
3,7,8,4,0,0;
4,8,7,5,0,0;
5,7,8,6,0,0;
6,8,7,1,0,0];
Integer imax = if sym then 6 else 4; // size(K,2);
equation
if sym then
Phi[1] = 0;
Dphi[1] = dphi[m1];
for m in 1:m1-1 loop
Phi[3*m-1:3*m+1] = fill(m*del_phi, 3);
Dphi[3*m-1:3*m+1] = {-dphi[m]-dphi[m1-m], (-1)^m*(dphi[m]-dphi[m1-m]), dphi[m]+dphi[m1-m]};
end for;
Phi[m2] = pi/3;
Dphi[m2] = -dphi[m1];
else
Phi[1:2] = {0, del_phi/2};
Dphi[1:2] = {dphi[m1], 0};
for m in 1:m1-1 loop
Phi[4*m-1:4*m+1] = fill(m*del_phi, 3);
Dphi[4*m-1:4*m+1] = {-dphi[m]-dphi[m1-m], (dphi[m]-dphi[m1-m]), dphi[m]+dphi[m1-m]};
Phi[4*m+2] = (0.5 + m)*del_phi;
Dphi[4*m+2] = 0;
end for;
Phi[m2] = pi/3;
Dphi[m2] = -dphi[m1];
end if;
end SVPWMasynBase;
partial block SVPWMsynBase "Space vector PWM synchronous base"
extends SVPWMbase;
parameter Integer mult(min=1)=1 "multiplicity (6*mult-1 pulses/period)"
protected
parameter Integer m1=if sym then 2*mult else mult
parameter Integer m2=if sym then 3*m1-1 else 4*m1-1
parameter SI.Angle del_phi=pi/(3*m1)
parameter SI.Angle[m1] dphi=(del_phi/sqrt(3))*sin((1:m1)*del_phi)
SI.Angle[m2] Phi;
SI.Angle[m2] Dphi;
Integer[6,:] K=if sym then
[1,7,1,2,8,2;
2,8,2,3,7,3;
3,7,3,4,8,4;
4,8,4,5,7,5;
5,7,5,6,8,6;
6,8,6,1,7,1] else
[1,7,8,2,0,0;
2,8,7,3,0,0;
3,7,8,4,0,0;
4,8,7,5,0,0;
5,7,8,6,0,0;
6,8,7,1,0,0];
Integer imax = if sym then 6 else 4; // size(K,2);
equation
if sym then
Phi[1] = 0;
Dphi[1] = dphi[m1];
for m in 1:m1-1 loop
Phi[3*m-1:3*m+1] = fill(m*del_phi, 3);
Dphi[3*m-1:3*m+1] = {-dphi[m]-dphi[m1-m], (-1)^m*(dphi[m]-dphi[m1-m]), dphi[m]+dphi[m1-m]};
end for;
Phi[m2] = pi/3;
Dphi[m2] = -dphi[m1];
else
Phi[1:2] = {0, del_phi/2};
Dphi[1:2] = {dphi[m1], 0};
for m in 1:m1-1 loop
Phi[4*m-1:4*m+1] = fill(m*del_phi, 3);
Dphi[4*m-1:4*m+1] = {-dphi[m]-dphi[m1-m], (dphi[m]-dphi[m1-m]), dphi[m]+dphi[m1-m]};
Phi[4*m+2] = (0.5 + m)*del_phi;
Dphi[4*m+2] = 0;
end for;
Phi[m2] = pi/3;
Dphi[m2] = -dphi[m1];
end if;
end SVPWMsynBase;
partial block PWMasynBase "Sine PWM asynchronous base"
extends ModulatorBase;
parameter SI.Frequency f_carr=1e3 "carrier frequency"
parameter SI.Time dt_min(min=Modelica.Constants.eps,max=0.1*del_t)=1e-6
"minimal time between on/off"
protected
final parameter SI.Time del_t=1/(4*f_carr)
final parameter SI.Time delp_t=del_t - dt_min/2
end PWMasynBase;
partial block PWMsynBase "Sine PWM synchronous base"
extends ModulatorBase;
parameter Integer mult(min=1)=3 "multiplicity (2*mult-1 pulses/period)"
parameter SI.Angle dphi_min(min=Modelica.Constants.eps,max=0.1*del_phi)=1e-6
"minimal time between on/off"
protected
final parameter Integer m2=2*(2*mult-1)
final parameter SI.Angle del_phi=pi/m2
final parameter SI.Angle delp_phi=del_phi-dphi_min/2
end PWMsynBase;
partial block BlockBase "Block modulator base"
extends PowerSystems.Icons.BlockS;
parameter Integer m(min=2,max=3)=3 "3 for 3-phase, 2 for 1-phase";
parameter SI.Angle width=2/3 "relative width (0 - 1)";
parameter SI.Angle dphimin(min=Modelica.Constants.eps, max=pi)=1e-3
"minimal phase angle on"
Modelica.Blocks.Interfaces.RealInput theta "reference angle"
Modelica.Blocks.Interfaces.RealInput[2] vPhasor
"voltage demand pu {norm(v), phase(v)} (see info)"
Modelica.Blocks.Interfaces.BooleanOutput[2*m] gates(each start=false) "gates"
protected
final parameter Integer[m] pgt=1:2:(2*m-1) "positive gates"
final parameter Integer[m] ngt=2:2:(2*m) "negative gates"
end BlockBase;
end Partials;
package SpaceVector "Space vector logic and control"
extends Modelica.Icons.VariantsPackage;
model SVMlogic "Logical part for SVM"
parameter SI.Time T_pwm "cycle time pwm";
inner Modelica.StateGraph.StateGraphRoot stateGraphRoot
Modelica.StateGraph.Alternative Alternative1
Modelica.Blocks.Interfaces.RealInput u_alpha_beta[2]
Modelica.Blocks.Math.Product norm1
Modelica.Blocks.Sources.Constant n1(k=sqrt(3/2))
Modelica.StateGraph.StepWithSignal sector2(nIn = 1, nOut = 1)
Modelica.StateGraph.TransitionWithSignal t1
Modelica.Blocks.Logical.GreaterEqual GreaterEqual1
Modelica.Blocks.Math.Gain Gain1(k=1/sqrt(3))
Modelica.Blocks.Logical.GreaterEqualThreshold GreaterEqualThreshold1
Modelica.Blocks.Logical.Not Not1
Modelica.Blocks.Math.Product norm2
Modelica.Blocks.Logical.GreaterEqual GreaterEqual2
Modelica.Blocks.Math.Gain Gain3(k=-1/sqrt(3))
Modelica.StateGraph.TransitionWithSignal t2
Modelica.StateGraph.Alternative Alternative2
Modelica.StateGraph.Step Step1(nIn = 1, nOut = 1)
Modelica.StateGraph.Step Step2(nIn = 1, nOut = 1)
Modelica.StateGraph.Alternative Alternative3
Modelica.StateGraph.Alternative Alternative5
Modelica.StateGraph.Alternative Alternative7
Modelica.StateGraph.TransitionWithSignal t3
Modelica.StateGraph.TransitionWithSignal t4
Modelica.StateGraph.Step Step3(nIn = 1, nOut = 1)
Modelica.StateGraph.Step Step4(nIn = 1, nOut = 1)
Modelica.StateGraph.TransitionWithSignal t5
Modelica.StateGraph.TransitionWithSignal t6
Modelica.Blocks.Logical.Not Not2
Modelica.Blocks.Logical.Not Not3
Modelica.StateGraph.TransitionWithSignal t7
Modelica.StateGraph.TransitionWithSignal t8
Modelica.StateGraph.TransitionWithSignal t9
Modelica.StateGraph.TransitionWithSignal t10
Modelica.StateGraph.StepWithSignal sector3(nIn = 1, nOut = 1)
Modelica.StateGraph.StepWithSignal sector1(nIn = 1, nOut = 1)
Modelica.StateGraph.StepWithSignal sector6(nIn = 1, nOut = 1)
Modelica.StateGraph.StepWithSignal sector5(nIn = 1, nOut = 1)
Modelica.StateGraph.StepWithSignal sector4(nIn = 1, nOut = 1)
Modelica.StateGraph.Transition t11(enableTimer=true, waitTime=T_pwm)
Modelica.StateGraph.Transition t12(enableTimer=true, waitTime=T_pwm)
Modelica.StateGraph.Transition t13(enableTimer=true, waitTime=T_pwm)
Modelica.StateGraph.Transition t16(enableTimer=true, waitTime=T_pwm)
Modelica.StateGraph.Transition t15(enableTimer=true, waitTime=T_pwm)
Modelica.StateGraph.Transition t14(enableTimer=true, waitTime=T_pwm)
Modelica.Blocks.Logical.Or s1_4
Modelica.Blocks.Logical.Or s2_5
Modelica.Blocks.Logical.Or s3_6
Modelica.Blocks.Sources.Constant zero[3](each k=0)
SVMsector1p4 sector1p4
SVMsector2p5 sector2p5
SVMsector3p6 sector3p6
Modelica.Blocks.Nonlinear.Limiter Limiter[3]
Modelica.Blocks.Logical.Switch Switch1[3]
Modelica.Blocks.Logical.Switch Switch2[3]
Modelica.Blocks.Logical.Switch Switch3[3]
Modelica.Blocks.Interfaces.RealOutput dutyRatio[3]
Modelica.Blocks.Routing.DeMultiplex2 alpha_beta
Modelica.Blocks.Interfaces.BooleanOutput trigger
Modelica.StateGraph.InitialStep InitialStep1(nIn = 1, nOut = 1)
Modelica.Blocks.Logical.Or Or1
Modelica.Blocks.Logical.Or Or2
TriggeredPulse TriggeredPulse1(T_pulse=1/10*T_pwm)
equation
connect(Gain1.y, GreaterEqual1.u2)
connect(norm2.y, GreaterEqualThreshold1.u)
connect(Gain3.y, GreaterEqual2.u2)
connect(norm1.y, GreaterEqual1.u1)
connect(GreaterEqual2.u1, norm1.y)
connect(norm2.y, Gain3.u)
connect(GreaterEqualThreshold1.y, Not1.u)
connect(GreaterEqualThreshold1.y, t1.condition)
connect(t1.outPort, Step1.inPort[1])
connect(Step1.outPort[1], Alternative2.inPort)
connect(t2.outPort, Step2.inPort[1])
connect(Step2.outPort[1], Alternative3.inPort)
connect(Step3.outPort[1], Alternative5.inPort)
connect(t4.outPort,Step3. inPort[1])
connect(t5.outPort,Step4. inPort[1])
connect(Step4.outPort[1], Alternative7.inPort)
connect(GreaterEqual1.y, t3.condition)
connect(Not1.y, t2.condition)
connect(GreaterEqual1.y, Not2.u)
connect(GreaterEqual2.y, Not3.u)
connect(Not2.y, t4.condition)
connect(GreaterEqual2.y, t6.condition)
connect(Not3.y,t5. condition)
connect(GreaterEqual2.y, t7.condition)
connect(Not3.y, t8.condition)
connect(GreaterEqual1.y, t10.condition)
connect(Not2.y, t9.condition)
connect(t2.inPort, Alternative1.split[2])
connect(t1.inPort, Alternative1.split[1])
connect(t3.inPort, Alternative2.split[1])
connect(t4.inPort, Alternative2.split[2])
connect(t7.inPort, Alternative5.split[1])
connect(t8.inPort, Alternative5.split[2])
connect(t7.outPort, sector2.inPort[1])
connect(sector4.inPort[1], t9.outPort)
connect(sector5.inPort[1], t10.outPort)
connect(t3.outPort, sector1.inPort[1])
connect(t6.outPort, sector6.inPort[1])
connect(t8.outPort, sector3.inPort[1])
connect(Alternative5.outPort, Alternative2.join[2])
connect(Alternative3.outPort, Alternative1.join[2])
connect(Alternative2.outPort, Alternative1.join[1])
connect(sector1.outPort[1], t11.inPort)
connect(sector5.outPort[1], t15.inPort)
connect(sector4.outPort[1],t14. inPort)
connect(sector6.outPort[1], t16.inPort)
connect(sector3.outPort[1], t13.inPort)
connect(sector2.outPort[1], t12.inPort)
connect(t12.outPort, Alternative5.join[1])
connect(t13.outPort, Alternative5.join[2])
connect(t11.outPort, Alternative2.join[1])
connect(sector1.active, s1_4.u1)
connect(sector2.active, s2_5.u1)
connect(sector3.active, s3_6.u1)
connect(sector1p4.u_alpha, sector2p5.u_alpha)
connect(sector2p5.u_alpha, sector3p6.u_alpha)
connect(sector3p6.u_beta, sector2p5.u_beta)
connect(sector2p5.u_beta, sector1p4.u_beta)
connect(Switch3.y, Switch2.u3)
connect(Switch2.y, Switch1.u3)
connect(Switch1.y, Limiter.u)
connect(Limiter.y, dutyRatio)
connect(s1_4.y, Switch1[1].u2)
connect(s1_4.y, Switch1[2].u2)
connect(s1_4.y, Switch1[3].u2)
connect(s2_5.y, Switch2[1].u2)
connect(s2_5.y, Switch2[2].u2)
connect(s2_5.y, Switch2[3].u2)
connect(s3_6.y, Switch3[1].u2)
connect(s3_6.y, Switch3[2].u2)
connect(s3_6.y, Switch3[3].u2)
connect(zero.y, Switch3.u3)
connect(alpha_beta.y1[1], norm1.u2)
connect(alpha_beta.u, u_alpha_beta)
connect(alpha_beta.y2[1], norm2.u2)
connect(norm2.y, Gain1.u)
connect(InitialStep1.outPort[1], Alternative1.inPort)
connect(InitialStep1.inPort[1], Alternative1.outPort)
connect(s1_4.y, Or1.u1)
connect(s2_5.y, Or1.u2)
connect(Or1.y, Or2.u1)
connect(s3_6.y, Or2.u2)
connect(norm1.y, sector1p4.u_alpha)
connect(norm2.y, sector1p4.u_beta)
connect(Alternative3.split[2], t6.inPort)
connect(Alternative3.split[1], t5.inPort)
connect(Alternative7.split[1], t9.inPort)
connect(Alternative7.split[2], t10.inPort)
connect(t14.outPort, Alternative7.join[1])
connect(t15.outPort, Alternative7.join[2])
connect(t16.outPort, Alternative3.join[2])
connect(Alternative7.outPort, Alternative3.join[1])
connect(sector4.active, s1_4.u2)
connect(sector5.active, s2_5.u2)
connect(sector6.active, s3_6.u2)
connect(sector3p6.abc, Switch3.u1)
connect(sector2p5.abc, Switch2.u1)
connect(sector1p4.abc, Switch1.u1)
connect(Or2.y, TriggeredPulse1.u)
connect(trigger, TriggeredPulse1.y)
connect(n1.y, norm1.u1)
connect(n1.y, norm2.u1)
end SVMlogic;
model SVMpwm "Block generating the pwm pulses for SVM"
parameter SI.Time T_pwm;
inner Modelica.StateGraph.StateGraphRoot stateGraphRoot
Modelica.Blocks.Interfaces.BooleanInput trigger
Modelica.Blocks.Interfaces.RealInput dutyRatio[3]
Modelica.Blocks.Interfaces.BooleanOutput switch[6]
Modelica.Blocks.Routing.DeMultiplex3 DeMultiplex3_1
Modelica.Blocks.Sources.Constant one
Modelica.Blocks.Math.Feedback t1
Modelica.Blocks.Math.Gain start_100(k=1/2)
Modelica.Blocks.Logical.GreaterEqual GreaterEqual1
Modelica.Blocks.Math.Gain start_010(k=1/2)
Modelica.Blocks.Math.Feedback t2
Modelica.Blocks.Math.Gain start_001(k=1/2)
Modelica.Blocks.Math.Feedback t3
Modelica.Blocks.Logical.GreaterEqual GreaterEqual2
Modelica.Blocks.Logical.GreaterEqual GreaterEqual3
Modelica.Blocks.Math.Add stop_100
Modelica.Blocks.Math.Add stop_010
Modelica.Blocks.Math.Add stop_001
Modelica.Blocks.Logical.GreaterEqual GreaterEqual4
Modelica.Blocks.Logical.GreaterEqual GreaterEqual5
Modelica.Blocks.Logical.GreaterEqual GreaterEqual6
Modelica.Blocks.Discrete.TriggeredSampler load_data[3]
Modelica.Blocks.Logical.Timer Timer
Modelica.Blocks.Math.Gain time_scaling(k=1/T_pwm)
Modelica.Blocks.Logical.Edge Edge
Modelica.Blocks.Logical.Not Not
DutyRatioToCycle dutyRtoC
Modelica.Blocks.Logical.And And1
Modelica.Blocks.Logical.Not Not1
Modelica.Blocks.Logical.Not Not2
Modelica.Blocks.Logical.And And2
Modelica.Blocks.Logical.Not Not3
Modelica.Blocks.Logical.And And3
Modelica.Blocks.Logical.Not Not4
Modelica.Blocks.Logical.Not Not5
Modelica.Blocks.Logical.Not Not6
equation
connect(one.y, t1.u1)
connect(t1.y, start_100.u)
connect(start_100.y, GreaterEqual1.u2)
connect(t2.y, start_010.u)
connect(t3.y, start_001.u)
connect(one.y, t2.u1)
connect(one.y, t3.u1)
connect(DeMultiplex3_1.y2[1], t2.u2)
connect(DeMultiplex3_1.y3[1], t3.u2)
connect(start_010.y, GreaterEqual2.u2)
connect(start_001.y, GreaterEqual3.u2)
connect(DeMultiplex3_1.y1[1], t1.u2)
connect(start_100.y, stop_100.u1)
connect(start_010.y, stop_010.u1)
connect(stop_010.u2, DeMultiplex3_1.y2[1])
connect(start_001.y, stop_001.u1)
connect(stop_001.u2, DeMultiplex3_1.y3[1])
connect(stop_010.y, GreaterEqual5.u2)
connect(dutyRatio, load_data.u)
connect(stop_001.y, GreaterEqual6.u2)
connect(stop_100.y, GreaterEqual4.u2)
connect(Timer.y, time_scaling.u)
connect(Not.y, Timer.u)
connect(trigger, load_data[1].trigger)
connect(trigger, load_data[2].trigger)
connect(trigger, load_data[3].trigger)
connect(GreaterEqual1.u1, GreaterEqual2.u1)
connect(GreaterEqual2.u1, GreaterEqual3.u1)
connect(GreaterEqual3.u1, GreaterEqual6.u1)
connect(GreaterEqual6.u1, GreaterEqual5.u1)
connect(GreaterEqual5.u1, GreaterEqual4.u1)
connect(Edge.y, Not.u)
connect(stop_100.u2, DeMultiplex3_1.y1[1])
connect(Edge.u, trigger)
connect(time_scaling.y, GreaterEqual1.u1)
connect(GreaterEqual4.y, Not1.u)
connect(GreaterEqual1.y, And1.u1)
connect(Not1.y, And1.u2)
connect(Not2.y, And2.u2)
connect(Not3.y, And3.u2)
connect(GreaterEqual6.y, Not3.u)
connect(GreaterEqual3.y, And3.u1)
connect(GreaterEqual2.y, And2.u1)
connect(GreaterEqual5.y, Not2.u)
connect(And1.y, Not4.u)
connect(And2.y, Not5.u)
connect(And3.y, Not6.u)
connect(And1.y, switch[1])
connect(Not4.y, switch[2])
connect(And2.y, switch[3])
connect(Not5.y, switch[4])
connect(And3.y, switch[5])
connect(Not6.y, switch[6])
connect(load_data.y, dutyRtoC.dutyRatio)
connect(dutyRtoC.dutyCycle, DeMultiplex3_1.u)
end SVMpwm;
model SVMsector1p4 "Sector 1-4"
Modelica.Blocks.Interfaces.RealInput u_alpha
Modelica.Blocks.Interfaces.RealInput u_beta
Modelica.Blocks.Interfaces.RealOutput abc[3]
Modelica.Blocks.Math.Add Add1
Modelica.Blocks.Math.Gain Gain1(k=1/(sqrt(3)))
Modelica.Blocks.Math.Gain Gain2(k=-1)
Modelica.Blocks.Math.Gain Gain3(k=-1)
Modelica.Blocks.Math.Add Add2
Modelica.Blocks.Math.Gain Gain4(k=3/(sqrt(3)))
equation
connect(u_alpha, Add1.u1)
connect(u_beta, Gain1.u)
connect(Gain1.y, Add1.u2)
connect(Add1.y, Gain2.u)
connect(u_alpha, Gain3.u)
connect(Gain3.y, Add2.u1)
connect(u_beta, Gain4.u)
connect(Gain4.y, Add2.u2)
connect(Add1.y, abc[1])
connect(Add2.y, abc[2])
connect(Gain2.y, abc[3])
end SVMsector1p4;
model SVMsector2p5 "Sector 2-5"
Modelica.Blocks.Interfaces.RealInput u_alpha
Modelica.Blocks.Interfaces.RealInput u_beta
Modelica.Blocks.Interfaces.RealOutput abc[3]
Modelica.Blocks.Math.Gain Gain1(k=2)
Modelica.Blocks.Math.Gain Gain2(k=-1)
Modelica.Blocks.Math.Gain Gain4(k=2/(sqrt(3)))
equation
connect(u_beta, Gain4.u)
connect(u_alpha, Gain1.u)
connect(Gain4.y, Gain2.u)
connect(Gain1.y, abc[1])
connect(Gain4.y, abc[2])
connect(Gain2.y, abc[3])
end SVMsector2p5;
model SVMsector3p6 "Sector 3-6"
Modelica.Blocks.Interfaces.RealInput u_alpha
Modelica.Blocks.Interfaces.RealInput u_beta
Modelica.Blocks.Interfaces.RealOutput abc[3]
Modelica.Blocks.Math.Add Add1
Modelica.Blocks.Math.Gain Gain1(k=-1/(sqrt(3)))
Modelica.Blocks.Math.Gain Gain2(k=-1)
Modelica.Blocks.Math.Gain Gain3(k=-1)
Modelica.Blocks.Math.Add Add2
Modelica.Blocks.Math.Gain Gain4(k=-3/(sqrt(3)))
equation
connect(u_alpha, Add1.u1)
connect(u_beta, Gain1.u)
connect(Gain1.y, Add1.u2)
connect(u_alpha, Gain3.u)
connect(Gain3.y, Add2.u1)
connect(u_beta, Gain4.u)
connect(Gain4.y, Add2.u2)
connect(Add1.y, Gain2.u)
connect(Add1.y, abc[1])
connect(Gain2.y, abc[2])
connect(Add2.y, abc[3])
end SVMsector3p6;
model TriggeredPulse "Edge triggered pulse"
parameter SI.Time T_pulse=1e-3 "width of triggered pulse";
Modelica.Blocks.Logical.Timer Timer1(y(start=0))
Modelica.Blocks.Logical.Edge Edge1
Modelica.Blocks.Logical.Or Or1
Modelica.Blocks.Logical.And And1
Modelica.Blocks.Interfaces.BooleanInput u
Modelica.Blocks.Interfaces.BooleanOutput y
Modelica.Blocks.Logical.LessThreshold LessThreshold1(threshold=T_pulse)
Modelica.Blocks.Logical.Pre Pre1
equation
connect(u, Edge1.u)
connect(Timer1.y, LessThreshold1.u)
connect(Edge1.y, Or1.u1)
connect(Or1.y, Timer1.u)
connect(LessThreshold1.y, And1.u1)
connect(Or1.y, y)
connect(Or1.u2, Pre1.y)
connect(Pre1.u, And1.y)
connect(Or1.y, And1.u2)
end TriggeredPulse;
model DutyRatioToCycle "Duty ratio to duty cycle transform"
Modelica.Blocks.Interfaces.RealInput dutyRatio[3]
Modelica.Blocks.Interfaces.RealOutput dutyCycle[3]
Modelica.Blocks.Math.Add Add[3]
Modelica.Blocks.Sources.Constant One[3](each k=1)
Modelica.Blocks.Math.Gain Gain[3](each k=1/2)
Modelica.Blocks.Math.Gain per_cent[3](each k=1)
equation
connect(dutyRatio, Add.u2)
connect(One.y, Add.u1)
connect(per_cent.y, dutyCycle)
connect(Gain.y, per_cent.u)
connect(Add.y, Gain.u)
end DutyRatioToCycle;
end SpaceVector;
end Modulation; |
Control blocks | within PowerSystems;
package Control "Control blocks"
extends Modelica.Icons.Package;
end Control; |
Relays | within PowerSystems.Control;
package Relays "Relays"
extends Modelica.Icons.VariantsPackage;
block SwitchRelay "Relay for sequential switching "
extends PowerSystems.Icons.Block0;
parameter Integer n(min=1)=3 "number of signals";
parameter Integer switched[:]=1:n "switched signals";
parameter Boolean ini_state=true "initial state (closed true, open false)"
parameter SI.Time t_switch[:]={1} "switching time vector";
Modelica.Blocks.Interfaces.BooleanOutput[n] y(start=fill(ini_state, n), each fixed=true)
"boolean state of switch (closed:true, open:false)"
protected
Integer cnt(start=1,fixed=true);
algorithm
when time > t_switch[cnt] then
cnt := min(cnt + 1, size(t_switch, 1));
for k in switched loop
y[k] := not y[k];
end for;
end when;
end SwitchRelay;
block TapChangerRelay "Relay for setting tap-changer "
extends PowerSystems.Icons.Block0;
parameter Integer preset_1[:]={1}
"1: positions tap changer";
parameter Integer preset_2[:]={1}
"2: positions tap changer";
parameter SI.Time t_switch_1[:]={0.5} "1: switching times";
parameter SI.Time t_switch_2[:]={0.5} "2: switching times";
Modelica.Blocks.Interfaces.IntegerOutput tap_1(start = preset_1[1], fixed = true)
"positions of tap changer 1"
Modelica.Blocks.Interfaces.IntegerOutput tap_2(start = preset_2[1], fixed = true)
"positions of tap changer 2"
protected
Integer cnt_1(start=1,fixed=true);
Integer cnt_2(start=1,fixed=true);
algorithm
when time > t_switch_1[min(cnt_1, size(t_switch_1, 1))] then
cnt_1 := cnt_1 + 1;
tap_1 := preset_1[min(cnt_1, size(preset_1, 1))];
end when;
when time > t_switch_2[min(cnt_2, size(t_switch_2, 1))] then
cnt_2 := cnt_2 + 1;
tap_2 := preset_2[min(cnt_2, size(preset_2, 1))];
end when;
end TapChangerRelay;
block TapChanger3Relay "Relay for setting tap-changer 3-winding transformer"
extends PowerSystems.Icons.Block0;
parameter Integer preset_1[:]={1}
"1: positions tap changer";
parameter Integer preset_2a[:]={1}
"2a: positions tap changer";
parameter Integer preset_2b[:]={1}
"2b: positions tap changer";
parameter SI.Time t_switch_1[:]={0.5} "1: switching times";
parameter SI.Time t_switch_2a[:]={0.5} "2a: switching times";
parameter SI.Time t_switch_2b[:]={0.5} "2b: switching times";
Modelica.Blocks.Interfaces.IntegerOutput tap_1(start = preset_1[1], fixed = true)
"positions of tap changer 1"
Modelica.Blocks.Interfaces.IntegerOutput[2] tap_2(
start = {preset_2a[1], preset_2b[1]}, each fixed = true)
"positions of tap changers {2a,2b}"
protected
Integer cnt_1(start=1,fixed=true);
Integer cnt_2a(start=1,fixed=true);
Integer cnt_2b(start=1,fixed=true);
algorithm
when time > t_switch_1[min(cnt_1, size(t_switch_1, 1))] then
cnt_1 := cnt_1 + 1;
tap_1 := preset_1[min(cnt_1, size(preset_1, 1))];
end when;
when time > t_switch_2a[min(cnt_2a, size(t_switch_2a, 1))] then
cnt_2a := cnt_2a + 1;
tap_2[1] := preset_2a[min(cnt_2a, size(preset_2a, 1))];
end when;
when time > t_switch_2b[min(cnt_2b, size(t_switch_2b, 1))] then
cnt_2b := cnt_2b + 1;
tap_2[2] := preset_2b[min(cnt_2b, size(preset_2b, 1))];
end when;
end TapChanger3Relay;
block Y_DeltaControl "Relay for Y-Delta topology switching "
extends PowerSystems.Icons.Block0;
parameter Boolean ini_state=true "initial state (Y true, D false)"
parameter SI.Time t_switch[:]={1} "switching time vector";
Modelica.Blocks.Interfaces.BooleanOutput y(start=ini_state, fixed=true)
"boolean state (Y-top: true, Delta-top: false)"
protected
Integer cnt(start=1,fixed=true);
algorithm
when time > t_switch[cnt] then
cnt := min(cnt + 1, size(t_switch, 1));
y := not y;
end when;
end Y_DeltaControl;
end Relays; |
Setpoints of generators | within PowerSystems.Control;
package Setpoints "Setpoints of generators"
extends Modelica.Icons.VariantsPackage;
block Set_w_p_v "Constant setpoints w, p, v for generation"
Modelica.Blocks.Interfaces.RealOutput[3] setpts
"setpoints {speed, power, voltage} pu"
protected
parameter SIpu.AngularVelocity w_set(unit="1", fixed=false, start=1)
"setpt turbine speed pu";
parameter SIpu.Power p_set(unit="1", fixed=false, start=1)
"setpt turbine power pu";
parameter SIpu.Voltage v_set(unit="1", fixed=false, start=1)
"setpt exciter voltage pu";
equation
setpts[1] = w_set;
setpts[2] = p_set;
setpts[3] = v_set;
end Set_w_p_v;
block SetVariable_w_p_v "Variable setpoints w, p, v for generation"
Modelica.Blocks.Interfaces.RealInput setpt_w "setpoint turbine speed pu"
Modelica.Blocks.Interfaces.RealInput setpt_p "setpoint turbine power pu"
Modelica.Blocks.Interfaces.RealInput setpt_v "setpoint exciter voltage pu"
Modelica.Blocks.Interfaces.RealOutput[3] setpts
"setpoints {speed, power, voltage} pu"
protected
parameter SIpu.AngularVelocity w_set(unit="1", fixed=false, start=1)
"setpt turbine speed pu";
parameter SIpu.Power p_set(unit="1", fixed=false, start=1)
"setpt turbine power pu";
parameter SIpu.Voltage v_set(unit="1", fixed=false, start=1)
"setpt exciter voltage pu";
initial equation
setpts[1] = w_set;
setpts[2] = p_set;
setpts[3] = v_set;
equation
setpts[1] = setpt_w;
setpts[2] = setpt_p;
setpts[3] = setpt_v;
end SetVariable_w_p_v;
block Set_w_p "Set-points for generation"
parameter SIpu.AngularVelocity w_set(unit="1", fixed=true)=1
"setpoint turbine speed pu";
Modelica.Blocks.Interfaces.RealInput setpt_p "setpoint turbine power pu"
Modelica.Blocks.Interfaces.RealOutput[2] setpts "setpoints {speed, power} pu"
equation
setpts[1] = w_set;
setpts[2] = setpt_p;
end Set_w_p;
end Setpoints; |
Tap changers | within PowerSystems.Control;
package TapChange "Tap changers"
extends Modelica.Icons.VariantsPackage;
end TapChange; |
Introductory examples for overall concepts | within PowerSystems.Examples;
package Introductory "Introductory examples for overall concepts"
extends Modelica.Icons.ExamplesPackage;
model Units "SI and pu units"
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.AC3ph.Sources.Voltage voltage_SI(
v0=408)
PowerSystems.AC3ph.Nodes.GroundOne grdV1
PowerSystems.AC3ph.Sources.Voltage voltage_pu(
V_nom=400,
v0=1.02)
PowerSystems.AC3ph.Nodes.GroundOne grdV2
PowerSystems.AC3ph.Sensors.PVImeter meter_SI
PowerSystems.AC3ph.Sensors.PVImeter meter_pu(
V_nom=400,
S_nom=10e3)
PowerSystems.AC3ph.Impedances.Resistor load_SI(
r=20)
PowerSystems.AC3ph.Impedances.Resistor load_pu(
V_nom=400,
S_nom=10e3,
r=1.25)
PowerSystems.AC3ph.Nodes.Ground grd1
PowerSystems.AC3ph.Nodes.Ground grd2
equation
connect(voltage_SI.term, meter_SI.term_p)
connect(meter_SI.term_n, load_SI.term_p)
connect(load_SI.term_n, grd1.term)
connect(voltage_pu.term, meter_pu.term_p)
connect(meter_pu.term_n, load_pu.term_p)
connect(load_pu.term_n, grd2.term)
connect(grdV1.term, voltage_SI.neutral)
connect(grdV2.term, voltage_pu.neutral)
end Units;
model Frequency "System and autonomous frequency"
inner PowerSystems.System system(f_nom=60, refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.Blocks.Signals.TransientFreq theta_dq0(f_end=50, f_start=10)
PowerSystems.AC1ph_DC.Sources.ACvoltage voltage1(v0eff=230)
PowerSystems.AC1ph_DC.Nodes.GroundOne grdV1
PowerSystems.AC1ph_DC.Sources.ACvoltage voltage2(v0eff=230, fType=
PowerSystems.Types.SourceFrequency.Signal)
PowerSystems.AC1ph_DC.Nodes.GroundOne grdV2
PowerSystems.AC1ph_DC.ImpedancesOneTerm.Inductor ind1(
x=0.2,
r=0.5,
f_nom=700)
PowerSystems.AC1ph_DC.ImpedancesOneTerm.Inductor ind2(
x=0.2,
r=0.5)
PowerSystems.AC1ph_DC.Sensors.PVImeter meter1
PowerSystems.AC1ph_DC.Sensors.PVImeter meter2
equation
connect(voltage1.term, meter1.term_p)
connect(meter1.term_n, ind1.term)
connect(voltage2.term, meter2.term_p)
connect(meter2.term_n, ind2.term)
connect(grdV1.term, voltage1.neutral)
connect(grdV2.term, voltage2.neutral)
connect(theta_dq0.y, voltage2.omega_in)
end Frequency;
model ReferenceInertial "Inertial reference system (non rotating)"
inner PowerSystems.System system(dynType=PowerSystems.Types.Dynamics.FixedInitial,
refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.AC3ph.Sources.Voltage voltage_dq0(
V_nom=400,
v0=1.02)
PowerSystems.AC3ph.Nodes.GroundOne grdV_dq0
PowerSystems.AC3ph.Sensors.PVImeter meter_dq0(
V_nom=400,
S_nom=10e3)
PowerSystems.AC3ph.Impedances.Inductor load_dq0(
V_nom=400,
S_nom=10e3,
r=0.1)
PowerSystems.AC3ph.Nodes.Ground grd_dq0
equation
connect(voltage_dq0.term, meter_dq0.term_p)
connect(meter_dq0.term_n, load_dq0.term_p)
connect(load_dq0.term_n, grd_dq0.term)
connect(grdV_dq0.term, voltage_dq0.neutral)
end ReferenceInertial;
model ReferenceSynchron "Synchronous reference system (rotating)"
inner PowerSystems.System system(dynType=PowerSystems.Types.Dynamics.FixedInitial)
PowerSystems.AC3ph.Sources.Voltage voltage_dq0(
V_nom=400,
v0=1.02)
PowerSystems.AC3ph.Nodes.GroundOne grdV_dq0
PowerSystems.AC3ph.Sensors.PVImeter meter_dq0(
V_nom=400,
S_nom=10e3,
abc=true)
PowerSystems.AC3ph.Impedances.Inductor load_dq0(
V_nom=400,
S_nom=10e3,
r=0.1)
PowerSystems.AC3ph.Nodes.Ground grd_dq0
equation
connect(voltage_dq0.term, meter_dq0.term_p)
connect(meter_dq0.term_n, load_dq0.term_p)
connect(load_dq0.term_n, grd_dq0.term)
connect(grdV_dq0.term, voltage_dq0.neutral)
end ReferenceSynchron;
model InitialSteadyState "Steady-state initialisation"
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.AC3ph.Sources.Voltage voltage_dq0(
V_nom=400,
v0=1.02)
PowerSystems.AC3ph.Nodes.GroundOne grdV_dq0
PowerSystems.AC3ph.Sensors.PVImeter meter_dq0(
V_nom=400,
S_nom=10e3,
abc=true)
PowerSystems.AC3ph.Impedances.Inductor load_dq0(
V_nom=400,
S_nom=10e3,
r=0.1)
PowerSystems.AC3ph.Nodes.Ground grd_dq0
equation
connect(voltage_dq0.term, meter_dq0.term_p)
connect(meter_dq0.term_n, load_dq0.term_p)
connect(load_dq0.term_n, grd_dq0.term)
connect(grdV_dq0.term, voltage_dq0.neutral)
end InitialSteadyState;
model SimulationFixedInitial
"Transient simulation with fixed initial conditions"
inner PowerSystems.System system(dynType=PowerSystems.Types.Dynamics.FixedInitial)
PowerSystems.Blocks.Signals.TransientPhasor transPh(
a_start=1.14,
a_end=1.0865,
t_duration=0.8,
ph_start=0.32114058236696,
ph_end=0.16667894356546)
PowerSystems.AC3ph.Sources.Voltage voltageL(V_nom=400e3, use_vPhasor_in=true)
PowerSystems.AC3ph.Nodes.GroundOne grdL
PowerSystems.AC3ph.Sensors.PVImeter meter(V_nom=400e3, S_nom=1000e6)
PowerSystems.AC3ph.Lines.RXline lineR(redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=400e3,
r=0.02e-3,
x=0.25e-3))
PowerSystems.AC3ph.Lines.RXline lineL(redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=400e3,
r=0.02e-3,
x=0.25e-3))
PowerSystems.AC3ph.Sources.Voltage voltageR(V_nom=400e3)
PowerSystems.AC3ph.Nodes.GroundOne grdR
PowerSystems.AC3ph.Breakers.ForcedSwitch switch(V_nom=400e3, I_nom=5e3)
PowerSystems.Control.Relays.SwitchRelay relayNet(n=1,
ini_state=true,
t_switch={0.4,0.6})
PowerSystems.AC3ph.Lines.RXline lineB(redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=400e3,
r=0.02e-3,
x=0.25e-3))
PowerSystems.AC3ph.Sources.Voltage voltageB(V_nom=400e3)
PowerSystems.AC3ph.Nodes.GroundOne grdB
equation
connect(relayNet.y, switch.control)
connect(voltageL.term, meter.term_p)
connect(meter.term_n, lineL.term_p)
connect(lineL.term_n, switch.term_p)
connect(switch.term_p, lineR.term_p)
connect(lineR.term_n, voltageR.term)
connect(switch.term_n, lineB.term_p)
connect(lineB.term_n, voltageB.term)
connect(transPh.y, voltageL.vPhasor_in)
connect(grdL.term, voltageL.neutral)
connect(voltageR.neutral, grdR.term)
connect(grdB.term, voltageB.neutral)
end SimulationFixedInitial;
model SimulationSteadyInitial
extends SimulationFixedInitial(system(dynType=PowerSystems.Types.Dynamics.SteadyInitial));
end SimulationSteadyInitial;
model SimulationSteadyState "Steady-state simulation"
extends SimulationFixedInitial(system(dynType=PowerSystems.Types.Dynamics.SteadyState));
end SimulationSteadyState;
model Display "Display of phasors and power"
inner PowerSystems.System system(f=50)
PowerSystems.Blocks.Signals.TransientPhasor transPh(
a_end=1.2,
ph_start=-pi,
ph_end=pi,
a_start=0.7,
t_change=15,
t_duration=30)
PowerSystems.AC3ph.Sources.Voltage voltageL(
V_nom=400,
use_vPhasor_in=true,
alpha0=0.10035643198967)
PowerSystems.AC3ph.Nodes.GroundOne grdV1
PowerSystems.AC3ph.Sensors.Phasor phasor_ind(V_nom=400, S_nom=10e3)
PowerSystems.AC3ph.Impedances.Inductor ind(
V_nom=400,
S_nom=10e3,
x_m=0.5,
x_s=2,
r=1)
PowerSystems.AC3ph.Sources.Voltage voltageR(V_nom=400)
PowerSystems.AC3ph.Nodes.GroundOne grdV2
PowerSystems.AC3ph.Sensors.Phasor phasor_cap(V_nom=400, S_nom=10e3)
PowerSystems.AC3ph.Impedances.Capacitor cap(
V_nom=400,
S_nom=10e3,
g=0.1,
b=1)
PowerSystems.AC3ph.Nodes.Ground grd
PowerSystems.AC3ph.Impedances.Resistor res(V_nom=400, S_nom=10e3,
r=0.5)
equation
connect(transPh.y, voltageL.vPhasor_in)
connect(voltageL.term, phasor_ind.term_p)
connect(phasor_ind.term_n, ind.term_p)
connect(ind.term_n, voltageR.term)
connect(voltageL.term, phasor_cap.term_p)
connect(phasor_cap.term_n, res.term_p)
connect(res.term_n, cap.term_p)
connect(cap.term_n, grd.term)
connect(grdV1.term, voltageL.neutral)
connect(voltageR.neutral, grdV2.term)
end Display;
model Tables "Using tables"
parameter Integer icol[:]={2,3} "{2nd column, 3rd column}";
Real u "1st column";
Real y[size(icol, 1)] "values of chosen columns";
Modelica.Blocks.Tables.CombiTable1Ds table(
columns=icol,
tableOnFile=true,
tableName="values",
fileName=TableDir + "TableExample.tab")
equation
u = 10*time "for plotting, time = {0, 1}";
table.u = u;
y = table.y;
end Tables;
end Introductory; |
DC drives | within PowerSystems.Examples.AC1ph_DC;
package Drives "DC drives"
extends Modelica.Icons.ExamplesPackage;
model DCmotor_ser "DC motor series excited"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.Blocks.Signals.Transient ramp(
t_change=0,
t_duration=10)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
PowerSystems.AC1ph_DC.Sources.DCvoltage voltage(V_nom=1500, use_vDC_in=true)
PowerSystems.AC1ph_DC.Sensors.Psensor power
PowerSystems.AC1ph_DC.Drives.DCMser dcm_ser(
redeclare model Rotor = PowerSystems.Mechanics.Rotational.ElectricRotor (
J=6.4),
w_start=146.60765716752,
redeclare model Motor = PowerSystems.AC1ph_DC.Machines.DCser (
redeclare record Data =
PowerSystems.Examples.Data.Machines.DCser1500V_1p5MVA))
PowerSystems.Common.Thermal.BdCondV bdCond(m=2)
PowerSystems.Mechanics.Rotational.TabPosSlopeTorque tabLoad(
r=0.4,
gRatio=40/17,
cFrict={50,15},
mass=200e3,
scale=true,
D=1.5e3,
slope_scale=0.025,
tableName="height",
fileName=TableDir + "hNormProfile.tab",
colData=3)
equation
connect(voltage.term, power.term_p)
connect(power.term_n,dcm_ser. term)
connect(grd.term, voltage.neutral)
connect(dcm_ser.flange,tabLoad.flange_a)
connect(dcm_ser.heat, bdCond.heat)
connect(ramp.y, voltage.vDC_in)
end DCmotor_ser;
model DCmotor_par "DC motor parallel excited"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
PowerSystems.AC1ph_DC.Sources.DCvoltage armVoltage(V_nom=1500)
PowerSystems.AC1ph_DC.Sensors.Psensor power
PowerSystems.AC1ph_DC.Sources.DCvoltage excVoltage(V_nom=1500)
PowerSystems.AC1ph_DC.Drives.DCMpar dcm_par(
redeclare model Rotor = PowerSystems.Mechanics.Rotational.ElectricRotor (
J=6.4),
redeclare model Motor = PowerSystems.AC1ph_DC.Machines.DCpar (
redeclare record Data =
PowerSystems.Examples.Data.Machines.DCpar1500V_1p5MVA))
PowerSystems.Common.Thermal.BdCondV bdCond(m=2)
PowerSystems.Mechanics.Rotational.TabPosSlopeTorque tabLoad(
r=0.4,
gRatio=40/17,
scale=true,
D=1.5e3,
tableName="height",
fileName=TableDir + "hNormProfile.tab",
colData=3,
mass=200e3,
slope_scale=0.025,
cFrict={50,15})
equation
connect(armVoltage.term, power.term_p)
connect(power.term_n, dcm_par.term)
connect(excVoltage.term, dcm_par.field)
connect(grd.term, armVoltage.neutral)
connect(excVoltage.neutral, armVoltage.neutral)
connect(dcm_par.flange,tabLoad.flange_a)
connect(dcm_par.heat, bdCond.heat)
end DCmotor_par;
model DCmotor_pm "DC motor permanent magnet excited"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
PowerSystems.AC1ph_DC.Sources.DCvoltage voltage(V_nom=100)
PowerSystems.AC1ph_DC.Sensors.Psensor power
PowerSystems.AC1ph_DC.Sensors.Efficiency efficiency(tcst=0.1, m=2)
PowerSystems.AC1ph_DC.Drives.DCMpm dcm_pm(
redeclare model Rotor = PowerSystems.Mechanics.Rotational.ElectricRotor (
J=0.02),
redeclare model Motor = PowerSystems.AC1ph_DC.Machines.DCpm (
redeclare record Data =
PowerSystems.Examples.Data.Machines.DCpm100V_1kVA))
PowerSystems.Mechanics.Rotational.Rotor loadInertia(J=0.03)
PowerSystems.Mechanics.Rotational.FrictionTorque frictTorq(cFrict={0.01,
0.0002})
Modelica.Mechanics.Rotational.Sources.TorqueStep torqueStep(
stepTorque=-10,
startTime=1.5,
useSupport=false,
offsetTorque=0)
equation
connect(grd.term, voltage.neutral)
connect(voltage.term, power.term_p)
connect(power.term_n, efficiency.term_p)
connect(efficiency.term_n, dcm_pm.term)
connect(dcm_pm.flange,loadInertia.flange_a)
connect(loadInertia.flange_b, frictTorq.flange)
connect(loadInertia.flange_b, torqueStep.flange)
connect(dcm_pm.heat, efficiency.heat)
end DCmotor_pm;
model BLDC "Brushless DC motor"
extends Modelica.Icons.Example;
inner PowerSystems.System system(f_nom=60,
refType=PowerSystems.Types.ReferenceFrame.Inertial,
dynType=PowerSystems.Types.Dynamics.FixedInitial)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
PowerSystems.AC1ph_DC.Sources.DCvoltage voltage( pol=0, V_nom=100)
PowerSystems.AC1ph_DC.Sensors.Psensor power
PowerSystems.AC1ph_DC.Sensors.Efficiency efficiency(
av=true,
tcst=0.1,
m=5)
PowerSystems.AC1ph_DC.Drives.BLDC bldcm(
redeclare model Motor =
PowerSystems.AC1ph_DC.Drives.Partials.Synchron3rd_bldc (
redeclare record Data =
PowerSystems.Examples.Data.Machines.BLDC100V_1kVA),
redeclare model Rotor = PowerSystems.Mechanics.Rotational.ElectricRotor (
J=0.02),
redeclare model Inverter = PowerSystems.AC3ph.Inverters.Inverter (
redeclare final model Modulator =
PowerSystems.Control.Modulation.BlockM
"block modulation (no PWM)",
redeclare model Inverter =
PowerSystems.AC3ph.Inverters.Components.InverterSwitch
"switch, no diode, no losses") "inverter with modulator")
PowerSystems.Mechanics.Rotational.Rotor loadInertia(J=0.03)
PowerSystems.Mechanics.Rotational.FrictionTorque frictTorq(cFrict={0.01,
0.0002})
Modelica.Mechanics.Rotational.Sources.TorqueStep torqueStep(
startTime=1.5, stepTorque=-10,
useSupport=false,
offsetTorque=0)
equation
connect(grd.term, voltage.neutral)
connect(bldcm.heat, efficiency.heat)
connect(voltage.term, power.term_p)
connect(power.term_n, efficiency.term_p)
connect(efficiency.term_n, bldcm.term)
connect(bldcm.flange,loadInertia.flange_a)
connect(loadInertia.flange_b, frictTorq.flange)
connect(loadInertia.flange_b, torqueStep.flange)
end BLDC;
model DCcharSpeed "DC pm: torque - speed characteristic"
extends Modelica.Icons.Example;
inner PowerSystems.System system(f_nom=60, dynType=PowerSystems.Types.Dynamics.SteadyState)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
PowerSystems.AC1ph_DC.Sources.DCvoltage voltage(pol=0, V_nom=100)
PowerSystems.AC1ph_DC.Sensors.Efficiency efficiency(
av=true,
tcst=0.1,
m=2)
PowerSystems.AC1ph_DC.Drives.DCMpm machine(
redeclare model Rotor = PowerSystems.Mechanics.Rotational.ElectricRotor (
J=0.02),
redeclare model Motor = PowerSystems.AC1ph_DC.Machines.DCpm (
redeclare record Data =
PowerSystems.Examples.Data.Machines.DCpm100V_1kVA))
PowerSystems.Blocks.Signals.Transient speedSignal(
s_start=0, s_end=160)
PowerSystems.Mechanics.Rotational.Speed speed(tcst=0.01, use_w_in=true)
equation
connect(grd.term, voltage.neutral)
connect(speedSignal.y, speed.w_in)
connect(voltage.term, efficiency.term_p)
connect(efficiency.term_n, machine.term)
connect(machine.flange, speed.flange)
connect(machine.heat, efficiency.heat)
end DCcharSpeed;
model BLDCcharSpeed "BLDC: torque - speed characteristic"
extends Modelica.Icons.Example;
inner PowerSystems.System system(f_nom=60, dynType=PowerSystems.Types.Dynamics.SteadyState)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
PowerSystems.AC1ph_DC.Sources.DCvoltage voltage(V_nom=100, pol=0)
PowerSystems.AC1ph_DC.Sensors.Efficiency efficiency(
tcst=0.1, m=3)
PowerSystems.AC1ph_DC.Drives.BLDC machine(
redeclare model Rotor = PowerSystems.Mechanics.Rotational.ElectricRotor (
J=0.02),
redeclare model Motor =
PowerSystems.AC1ph_DC.Drives.Partials.Synchron3rd_bldc (
redeclare record Data =
PowerSystems.Examples.Data.Machines.BLDC100V_1kVA),
redeclare model Inverter = PowerSystems.AC3ph.Inverters.InverterAverage (
final modulation=3, redeclare record Data =
PowerSystems.Examples.Data.Semiconductors.IdealSC100V_10A)
"inverter time-average")
PowerSystems.Blocks.Signals.Transient speedSignal(
s_start=0, s_end=160)
PowerSystems.Mechanics.Rotational.Speed speed(tcst=0.01, use_w_in=true)
equation
connect(grd.term, voltage.neutral)
connect(voltage.term, efficiency.term_p)
connect(machine.heat, efficiency.heat)
connect(efficiency.term_n, machine.term)
connect(machine.flange, speed.flange)
connect(speedSignal.y, speed.w_in)
end BLDCcharSpeed;
end Drives; |
AC 1-phase and DC components | within PowerSystems.Examples.AC1ph_DC;
package Elementary "AC 1-phase and DC components"
extends Modelica.Icons.ExamplesPackage;
model Breaker "Breaker"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial,
dynType=PowerSystems.Types.Dynamics.FixedInitial)
PowerSystems.Blocks.Signals.TransientPhasor transPh
PowerSystems.Control.Relays.SwitchRelay relay(
n=1,
ini_state=true,
t_switch={0.1})
PowerSystems.AC1ph_DC.Sources.ACvoltage voltage(V_nom=10e3, use_vPhasor_in=true)
PowerSystems.AC1ph_DC.Impedances.Inductor ind(r={0.1,0.1},
V_nom=10e3,
S_nom=1e6)
PowerSystems.AC1ph_DC.Sensors.PVImeter meter(V_nom=10e3, S_nom=1e6)
replaceable PowerSystems.AC1ph_DC.Breakers.Breaker breaker(V_nom=10e3, I_nom=100)
PowerSystems.AC1ph_DC.Nodes.Ground grd
PowerSystems.AC1ph_DC.Nodes.GroundOne grd1
equation
connect(transPh.y, voltage.vPhasor_in)
connect(voltage.term, ind.term_p)
connect(ind.term_n, meter.term_p)
connect(meter.term_n, breaker.term_p)
connect(breaker.term_n, grd.term)
connect(relay.y[1], breaker.control)
connect(grd1.term, voltage.neutral)
end Breaker;
model Fault "Fault"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial,
dynType=PowerSystems.Types.Dynamics.FixedInitial)
PowerSystems.Control.Relays.SwitchRelay relay1( n=2, t_switch=
{3.5,29.5}/50)
PowerSystems.Control.Relays.SwitchRelay relay2( n=2, t_switch=
{3.6,29.4}/50)
PowerSystems.AC1ph_DC.Sources.ACvoltage voltage1(V_nom=10e3, alpha0=
0.17453292519943)
PowerSystems.AC1ph_DC.Sources.ACvoltage voltage2(V_nom=10e3)
PowerSystems.AC1ph_DC.Breakers.DoubleSwitch switch1(V_nom=10e3,I_nom=100)
PowerSystems.AC1ph_DC.Breakers.DoubleSwitch switch2(V_nom=10e3, I_nom=100)
PowerSystems.AC1ph_DC.Lines.FaultRXline line(redeclare record Data =
PowerSystems.AC1ph_DC.Lines.Parameters.RXline(V_nom = 10e3, S_nom=1e6))
PowerSystems.AC1ph_DC.Sensors.PVImeter meter(V_nom=10e3, S_nom=1e6)
replaceable PowerSystems.AC1ph_DC.Faults.Fault_Ab fault_Ab
PowerSystems.AC1ph_DC.Nodes.GroundOne grd1
PowerSystems.AC1ph_DC.Nodes.GroundOne grd2
equation
connect(voltage1.term, switch1.term_p)
connect(switch1.term_n, line.term_p)
connect(line.term_n, switch2.term_p)
connect(switch2.term_n, voltage2.term)
connect(line.term_f, meter.term_p)
connect(meter.term_n,fault_Ab. term)
connect(relay1.y, switch1.control)
connect(relay2.y, switch2.control)
connect(grd1.term, voltage1.neutral)
connect(voltage2.neutral, grd2.term)
end Fault;
model Impedance "Impedance"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial,
dynType=PowerSystems.Types.Dynamics.FixedInitial)
PowerSystems.Blocks.Signals.TransientPhasor transPh
PowerSystems.AC1ph_DC.Sources.ACvoltage voltage(use_vPhasor_in=true)
PowerSystems.AC1ph_DC.Sensors.PVImeter meter
replaceable PowerSystems.AC1ph_DC.Impedances.Inductor ind(r={0.1,0.1})
PowerSystems.AC1ph_DC.Nodes.GroundOne grd1
PowerSystems.AC1ph_DC.Nodes.Ground grd2
equation
connect(transPh.y, voltage.vPhasor_in)
connect(voltage.term, meter.term_p)
connect(meter.term_n, ind.term_p)
connect(ind.term_n, grd2.term)
connect(grd1.term, voltage.neutral)
end Impedance;
model ImpedanceOneTerm "Impedance One-terminal"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial,
dynType=PowerSystems.Types.Dynamics.FixedInitial)
PowerSystems.Blocks.Signals.TransientPhasor transPh
PowerSystems.AC1ph_DC.Sources.ACvoltage voltage(use_vPhasor_in=true)
PowerSystems.AC1ph_DC.Sensors.PVImeter meter
replaceable PowerSystems.AC1ph_DC.ImpedancesOneTerm.Inductor ind(r=0.1)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
equation
connect(transPh.y, voltage.vPhasor_in)
connect(voltage.term, meter.term_p)
connect(meter.term_n, ind.term)
connect(grd.term, voltage.neutral)
end ImpedanceOneTerm;
model Line "Line"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.Blocks.Signals.TransientPhasor transPh(ph_end=
0.087266462599716)
PowerSystems.AC1ph_DC.Sources.ACvoltage voltage1(
V_nom=132e3,
use_vPhasor_in=true,
alpha0=0.087266462599716)
PowerSystems.AC1ph_DC.Sources.ACvoltage voltage2(V_nom=132e3)
PowerSystems.AC1ph_DC.Sensors.PVImeter meter(V_nom=132e3, S_nom=100e6)
replaceable PowerSystems.AC1ph_DC.Lines.Tline line(redeclare record Data =
PowerSystems.AC1ph_DC.Lines.Parameters.Line ( V_nom=132e3))
PowerSystems.AC1ph_DC.Nodes.GroundOne grd1
PowerSystems.AC1ph_DC.Nodes.GroundOne grd2
equation
connect(transPh.y, voltage1.vPhasor_in)
connect(voltage1.term, meter.term_p)
connect(meter.term_n, line.term_p)
connect(line.term_n, voltage2.term)
connect(grd1.term, voltage1.neutral)
connect(voltage2.neutral, grd2.term)
end Line;
model DoubleLine "Parallel lines, one faulted"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC1ph_DC.Sources.ACvoltage voltage1(V_nom=20e3, alpha0=0.5235987755983)
PowerSystems.AC1ph_DC.Transformers.TrafoStray trafo(redeclare record Data =
PowerSystems.Examples.Data.Transformers.TrafoStray1ph (
V_nom={20e3,132e3},
S_nom=100e6,
f_nom=50))
PowerSystems.AC1ph_DC.Lines.Tline line(len=480000, redeclare record Data =
PowerSystems.AC1ph_DC.Lines.Parameters.Line(V_nom = 132e3))
PowerSystems.AC1ph_DC.Breakers.Switch switch1(V_nom=132e3, I_nom=2500)
PowerSystems.AC1ph_DC.Lines.FaultTline lineF(
redeclare record Data =
PowerSystems.AC1ph_DC.Lines.Parameters.Line(V_nom = 132e3), len=
430000)
PowerSystems.AC1ph_DC.Breakers.Switch switch2(V_nom=132e3, I_nom=2500)
PowerSystems.AC1ph_DC.Faults.Fault_ab ab
PowerSystems.AC1ph_DC.Sources.ACvoltage voltage2(V_nom=132e3, alpha0=0.5235987755983)
PowerSystems.Control.Relays.SwitchRelay relay1(t_switch={0.15,0.2}, n=1)
PowerSystems.Control.Relays.SwitchRelay relay2(t_switch={0.153,0.21}, n=1)
PowerSystems.AC1ph_DC.Sensors.PVImeter meterL(S_nom=1000e6, V_nom=132e3)
PowerSystems.AC1ph_DC.Sensors.PVImeter meterF(S_nom=1000e6, V_nom=132e3)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd1
PowerSystems.AC1ph_DC.Nodes.GroundOne grd2
equation
connect(trafo.term_n, meterL.term_p)
connect(meterL.term_n, line.term_p)
connect(line.term_n, voltage2.term)
connect(trafo.term_n, switch1.term_p)
connect(switch1.term_n, meterF.term_p)
connect(meterF.term_n, lineF.term_p)
connect(lineF.term_n, switch2.term_p)
connect(switch2.term_n, voltage2.term)
connect(lineF.term_f, ab.term)
connect(voltage1.term, trafo.term_p)
connect(grd1.term, voltage1.neutral)
connect(grd2.term, voltage2.neutral)
connect(relay1.y[1], switch1.control)
connect(relay2.y[1], switch2.control)
end DoubleLine;
model LoadAC "AC load"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial,
dynType=PowerSystems.Types.Dynamics.FixedInitial)
PowerSystems.Blocks.Signals.Transient[2] trsSignal(s_start={1,2}, s_end={2,3})
PowerSystems.Blocks.Signals.TransientPhasor transPh(a_end=0.9)
PowerSystems.AC1ph_DC.Sources.ACvoltage voltage(use_vPhasor_in=true)
PowerSystems.AC1ph_DC.Sensors.PVImeter meter
replaceable PowerSystems.AC1ph_DC.Loads.ZloadAC zLoadAC(use_pq_in=true)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
equation
connect(transPh.y, voltage.vPhasor_in)
connect(voltage.term, meter.term_p)
connect(meter.term_n, zLoadAC.term)
connect(grd.term, voltage.neutral)
connect(trsSignal.y,zLoadAC.pq_in)
end LoadAC;
model LoadDC "AC load"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.Blocks.Signals.Transient trsSignalL(s_start=0.5, s_end=1)
PowerSystems.AC1ph_DC.Sources.DCvoltage voltage(use_vDC_in=true)
PowerSystems.AC1ph_DC.Sensors.PVImeter meter
replaceable PowerSystems.AC1ph_DC.Loads.PindLoadDC pLoadDC(use_p_in=true)
PowerSystems.Blocks.Signals.Transient transV(s_end=0.9)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
equation
connect(voltage.term, meter.term_p)
connect(meter.term_n, pLoadDC.term)
connect(grd.term, voltage.neutral)
connect(transV.y, voltage.vDC_in)
connect(trsSignalL.y, pLoadDC.p_in)
end LoadDC;
model Machines "Machines"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.Mechanics.Rotational.Rotor rotor
PowerSystems.Mechanics.Rotational.Torque torq(tau0=-1)
PowerSystems.Blocks.Signals.Transient transTau(s_start=0, s_end=-1)
PowerSystems.AC1ph_DC.Sources.DCvoltage voltage1(use_vDC_in=true, V_nom=
100)
PowerSystems.Blocks.Signals.Transient transV(s_start=0, s_end=1)
PowerSystems.AC1ph_DC.Sensors.Psensor power
replaceable PowerSystems.AC1ph_DC.Machines.DCser motor(redeclare
replaceable record Data =
PowerSystems.AC1ph_DC.Machines.Parameters.DCser(V_nom=100, S_nom=1e3))
"DC machine series"
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
PowerSystems.Common.Thermal.BoundaryV boundary(m=2)
equation
connect(voltage1.term, power.term_p)
connect(power.term_n, motor.term)
connect(motor.airgap,rotor.flange_a)
connect(rotor.flange_b, torq.flange)
connect(grd.term, voltage1.neutral)
connect(transV.y, voltage1.vDC_in)
connect(motor.heat, boundary.heat)
connect(transTau.y, torq.tau_in)
end Machines;
model Sensor "Sensor and meter"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial,
dynType=PowerSystems.Types.Dynamics.FixedInitial)
PowerSystems.Blocks.Signals.TransientPhasor transPh
PowerSystems.AC1ph_DC.ImpedancesOneTerm.Resistor res
replaceable PowerSystems.AC1ph_DC.Sensors.PVImeter meter
PowerSystems.AC1ph_DC.Sources.Vspectrum voltage(use_vPhasor_in=true)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
equation
connect(transPh.y, voltage.vPhasor_in)
connect(voltage.term, meter.term_p)
connect(meter.term_n, res.term)
connect(grd.term, voltage.neutral)
end Sensor;
model Source "Source"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial,
dynType=PowerSystems.Types.Dynamics.FixedInitial)
replaceable PowerSystems.AC1ph_DC.Sources.ACvoltage voltage
PowerSystems.AC1ph_DC.Sensors.PVImeter meter
PowerSystems.AC1ph_DC.ImpedancesOneTerm.Inductor ind
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
equation
connect(voltage.term, meter.term_p)
connect(meter.term_n, ind.term)
connect(grd.term, voltage.neutral)
end Source;
model Transformer "Transformer"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial,
dynType=PowerSystems.Types.Dynamics.FixedInitial)
PowerSystems.Blocks.Signals.TransientPhasor transPh
PowerSystems.Control.Relays.TapChangerRelay tapChanger(
preset_1={1,1,2},
preset_2={1,1,2},
t_switch_1={0.9,1.9},
t_switch_2={1.1,2.1})
PowerSystems.AC1ph_DC.Sources.ACvoltage voltage(use_vPhasor_in=true)
PowerSystems.AC1ph_DC.Sensors.PVImeter meter1
PowerSystems.AC1ph_DC.Sensors.PVImeter meter2(V_nom=10)
replaceable PowerSystems.AC1ph_DC.Transformers.TrafoStray trafo(
redeclare record Data =
PowerSystems.AC1ph_DC.Transformers.Parameters.TrafoStray1ph (
tap_neutral={1,1},
dv_tap = {0.1,0.2},
V_nom = {1,10}),
use_tap_1_in=true,
use_tap_2_in=true)
PowerSystems.AC1ph_DC.ImpedancesOneTerm.Resistor res(V_nom=10, r=100)
PowerSystems.AC1ph_DC.Nodes.PolarityGround polGrd1(pol=0)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
equation
connect(transPh.y, voltage.vPhasor_in)
connect(voltage.term, meter1.term_p)
connect(meter1.term_n, trafo.term_p)
connect(trafo.term_n, meter2.term_p)
connect(meter2.term_n, res.term)
connect(res.term, polGrd1.term)
connect(grd.term, voltage.neutral)
connect(tapChanger.tap_1, trafo.tap_1_in)
connect(tapChanger.tap_2, trafo.tap_2_in)
end Transformer;
model Rectifier "Rectifier"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial,
dynType=PowerSystems.Types.Dynamics.FixedInitial)
PowerSystems.Blocks.Signals.TransientPhasor transPh
PowerSystems.AC1ph_DC.Sources.ACvoltage vAC(V_nom=2, use_vPhasor_in=true)
PowerSystems.AC1ph_DC.Impedances.Inductor ind
PowerSystems.AC1ph_DC.Sensors.PVImeter meterAC(av=true, tcst=0.1)
replaceable PowerSystems.AC1ph_DC.Inverters.Rectifier rectifier
PowerSystems.AC1ph_DC.Sensors.PVImeter meterDC(av=true, tcst=0.1)
PowerSystems.AC1ph_DC.Sources.DCvoltage vDC(pol=0)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd1
PowerSystems.AC1ph_DC.Nodes.GroundOne grd2
PowerSystems.Common.Thermal.BoundaryV boundary(m=2)
equation
connect(transPh.y, vAC.vPhasor_in)
connect(vAC.term, ind.term_p)
connect(ind.term_n, meterAC.term_p)
connect(meterAC.term_n, rectifier.AC)
connect(rectifier.DC, meterDC.term_p)
connect(meterDC.term_n, vDC.term)
connect(grd1.term, vAC.neutral)
connect(vDC.neutral, grd2.term)
connect(rectifier.heat, boundary.heat)
end Rectifier;
model Inverter "Inverter, controlled rectifier"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial,
dynType=PowerSystems.Types.Dynamics.FixedInitial)
PowerSystems.Blocks.Signals.TransientPhasor transPh
PowerSystems.AC1ph_DC.Sources.ACvoltage vAC(use_vPhasor_in=true)
PowerSystems.AC1ph_DC.Impedances.Inductor ind
PowerSystems.AC1ph_DC.Sensors.PVImeter meterAC(av=true, tcst=0.1)
replaceable PowerSystems.AC1ph_DC.Inverters.Inverter dc_ac
PowerSystems.AC1ph_DC.Sensors.PVImeter meterDC(av=true, tcst=0.1)
PowerSystems.AC1ph_DC.Sources.DCvoltage vDC(pol=0, V_nom=2)
PowerSystems.AC1ph_DC.Inverters.Select select(alpha0=0.5235987755983)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd1
PowerSystems.AC1ph_DC.Nodes.GroundOne grd2
PowerSystems.Common.Thermal.BoundaryV boundary(m=2)
equation
connect(transPh.y, vAC.vPhasor_in)
connect(select.theta_out,dc_ac. theta)
connect(select.vPhasor_out,dc_ac.vPhasor)
connect(vDC.term, meterDC.term_p)
connect(meterDC.term_n, dc_ac.DC)
connect(dc_ac.AC, meterAC.term_p)
connect(meterAC.term_n, ind.term_n)
connect(ind.term_p, vAC.term)
connect(grd1.term, vDC.neutral)
connect(grd2.term, vAC.neutral)
connect(dc_ac.heat, boundary.heat)
end Inverter;
end Elementary; |
Inverters 1 phase and DC | within PowerSystems.Examples.AC1ph_DC;
package Inverters "Inverters 1 phase and DC"
extends Modelica.Icons.ExamplesPackage;
model Rectifier "Rectifier"
extends Modelica.Icons.Example;
inner PowerSystems.System system(dynType=PowerSystems.Types.Dynamics.FixedInitial,
refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.Blocks.Signals.TransientPhasor transPh(
t_change=0.1,
t_duration=0.1,
a_start=2,
a_end=1)
PowerSystems.AC1ph_DC.Sources.ACvoltage vAC(use_vPhasor_in=true, V_nom=100,
pol=0)
PowerSystems.AC1ph_DC.Impedances.Inductor ind(r={0.05,0.05},
V_nom=100,
S_nom=1e3)
PowerSystems.AC1ph_DC.Sensors.PVImeter meterAC(av=true, tcst=0.1,
V_nom=100,
S_nom=1e3)
PowerSystems.AC1ph_DC.Inverters.Rectifier rectifier(redeclare model
Rectifier =
PowerSystems.AC1ph_DC.Inverters.Components.RectifierEquation (
redeclare record Data =
PowerSystems.Examples.Data.Semiconductors.IdealSC100V_10A))
PowerSystems.AC1ph_DC.Sensors.PVImeter meterDC(av=true, tcst=0.1,
V_nom=100,
S_nom=1e3)
PowerSystems.AC1ph_DC.Sources.DCvoltage vDC(pol=0, V_nom=100)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd1
PowerSystems.AC1ph_DC.Nodes.GroundOne grd2
PowerSystems.Common.Thermal.BdCondV bdCond(m=2)
equation
connect(vAC.term, ind.term_p)
connect(ind.term_n, meterAC.term_p)
connect(meterDC.term_n, vDC.term)
connect(meterAC.term_n, rectifier.AC)
connect(rectifier.DC, meterDC.term_p)
connect(transPh.y, vAC.vPhasor_in)
connect(grd1.term, vAC.neutral)
connect(vDC.neutral, grd2.term)
connect(rectifier.heat, bdCond.heat)
end Rectifier;
model InverterToLoad "Inverter to load"
extends Modelica.Icons.Example;
inner PowerSystems.System system(dynType=PowerSystems.Types.Dynamics.FixedInitial,
refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.AC1ph_DC.Sources.DCvoltage vDC(V_nom=100)
PowerSystems.AC1ph_DC.Sensors.PVImeter meterDC(av=true, tcst=0.1,
V_nom=100,
S_nom=1e3)
PowerSystems.AC1ph_DC.Inverters.Inverter inverter(redeclare model Inverter =
PowerSystems.AC1ph_DC.Inverters.Components.InverterEquation(redeclare
record Data =
PowerSystems.Examples.Data.Semiconductors.IdealSC100V_10A)
"equation, with losses")
PowerSystems.AC1ph_DC.Inverters.Select select(
fType=PowerSystems.Types.SourceFrequency.Parameter,
f=100,
use_vPhasor_in=true)
PowerSystems.AC1ph_DC.Sensors.PVImeter meterAC(av=true, tcst=0.1,
V_nom=100,
S_nom=1e3)
PowerSystems.AC1ph_DC.ImpedancesOneTerm.Inductor ind(x=0.5, r=0.5,
V_nom=100,
S_nom=1e3)
PowerSystems.Blocks.Signals.TransientPhasor vCtrl(
t_change=0.05,
t_duration=0.05,
a_start=1.05,
a_end=1.05,
ph_end=0.5235987755983)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
PowerSystems.Common.Thermal.BdCondV bdCond(m=2)
equation
connect(vDC.term, meterDC.term_p)
connect(meterDC.term_n, inverter.DC)
connect(inverter.AC, meterAC.term_p)
connect(meterAC.term_n, ind.term)
connect(select.theta_out, inverter.theta)
connect(select.vPhasor_out,inverter.vPhasor)
connect(vCtrl.y,select.vPhasor_in)
connect(grd.term, vDC.neutral)
connect(inverter.heat, bdCond.heat)
end InverterToLoad;
model InverterToGrid "Inverter to grid"
extends Modelica.Icons.Example;
inner PowerSystems.System system(dynType=PowerSystems.Types.Dynamics.FixedInitial,
refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.AC1ph_DC.Sources.DCvoltage vDC(pol=0,
V_nom=100,
v0=2)
PowerSystems.AC1ph_DC.Sensors.PVImeter meterDC(av=true, tcst=0.1,
V_nom=100,
S_nom=1e3)
PowerSystems.AC1ph_DC.Inverters.Inverter inverter(redeclare model Inverter =
PowerSystems.AC1ph_DC.Inverters.Components.InverterEquation (
redeclare record Data =
PowerSystems.Examples.Data.Semiconductors.IdealSC100V_10A)
"equation, with losses")
PowerSystems.AC1ph_DC.Inverters.Select select(use_vPhasor_in=true)
PowerSystems.AC1ph_DC.Sensors.PVImeter meterAC(av=true, tcst=0.1,
V_nom=100,
S_nom=1e3)
PowerSystems.AC1ph_DC.Impedances.Inductor ind(r={0.05,0.05},
V_nom=100,
S_nom=1e3)
PowerSystems.AC1ph_DC.Sources.ACvoltage vAC(V_nom=100)
PowerSystems.Blocks.Signals.TransientPhasor vCtrl(
t_change=0.1,
t_duration=0.1,
a_start=1,
a_end=1,
ph_end=0.5235987755983)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
PowerSystems.Common.Thermal.BdCondV bdCond(m=2)
equation
connect(vAC.term, ind.term_p)
connect(vDC.term, meterDC.term_p)
connect(meterAC.term_n, ind.term_n)
connect(select.theta_out, inverter.theta)
connect(select.vPhasor_out,inverter.vPhasor)
connect(vCtrl.y,select.vPhasor_in)
connect(vAC.neutral, grd.term)
connect(meterDC.term_n, inverter.DC)
connect(inverter.AC, meterAC.term_p)
connect(inverter.heat, bdCond.heat)
end InverterToGrid;
model InverterAvToGrid "Inverter to grid"
extends Modelica.Icons.Example;
inner PowerSystems.System system(dynType=PowerSystems.Types.Dynamics.FixedInitial,
refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.AC1ph_DC.Sources.DCvoltage vDC(pol=0,
V_nom=100,
v0=2)
PowerSystems.AC1ph_DC.Sensors.PVImeter meterDC(av=true, tcst=0.1,
V_nom=100,
S_nom=1e3)
PowerSystems.AC1ph_DC.Inverters.InverterAverage inverter(redeclare record
Data=PowerSystems.Examples.Data.Semiconductors.IdealSC100V_10A)
PowerSystems.AC1ph_DC.Inverters.Select select(use_vPhasor_in=true)
PowerSystems.AC1ph_DC.Sensors.PVImeter meterAC(av=true, tcst=0.1,
V_nom=100,
S_nom=1e3)
PowerSystems.AC1ph_DC.Impedances.Inductor ind(r={0.05,0.05},
V_nom=100,
S_nom=1e3)
PowerSystems.AC1ph_DC.Sources.ACvoltage vAC(V_nom=100)
PowerSystems.Blocks.Signals.TransientPhasor vCtrl(
t_change=0.1,
t_duration=0.1,
ph_end=0.5235987755983)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
PowerSystems.Common.Thermal.BdCondV bdCond(m=1)
equation
connect(vAC.term, ind.term_p)
connect(vDC.term, meterDC.term_p)
connect(meterAC.term_n, ind.term_n)
connect(select.theta_out, inverter.theta)
connect(select.vPhasor_out,inverter.vPhasor)
connect(vCtrl.y,select.vPhasor_in)
connect(vAC.neutral, grd.term)
connect(meterDC.term_n, inverter.DC)
connect(inverter.AC, meterAC.term_p)
connect(inverter.heat, bdCond.heat)
end InverterAvToGrid;
model Chopper "Chopper"
extends Modelica.Icons.Example;
inner PowerSystems.System system(dynType=PowerSystems.Types.Dynamics.FixedInitial,
refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.AC1ph_DC.Sources.DCvoltage vDC(V_nom=100)
PowerSystems.AC1ph_DC.Sensors.PVImeter meterDCin(av=true, tcst=0.1,
V_nom=100,
S_nom=1e3)
PowerSystems.AC1ph_DC.Inverters.Chopper chopper(redeclare model Chopper =
PowerSystems.AC1ph_DC.Inverters.Components.ChopperModular(redeclare
record Data =
PowerSystems.Examples.Data.Semiconductors.IdealSC100V_10A))
PowerSystems.AC1ph_DC.Sensors.PVImeter meterDCout(av=true, tcst=0.1,
V_nom=100,
S_nom=1e3)
PowerSystems.Blocks.Signals.Transient vDCoutCtrl(
t_change=0,
t_duration=0.2,
s_start=0,
s_end=0.7)
PowerSystems.AC1ph_DC.ImpedancesOneTerm.Inductor load(x=0.5, r=0.5,
V_nom=100,
S_nom=1e3)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
PowerSystems.Common.Thermal.BdCondV bdCond(m=2)
equation
connect(grd.term, vDC.neutral)
connect(vDC.term, meterDCin.term_p)
connect(meterDCin.term_n, chopper.DCin)
connect(chopper.DCout, meterDCout.term_p)
connect(meterDCout.term_n, load.term)
connect(vDCoutCtrl.y,chopper.vDC)
connect(chopper.heat, bdCond.heat)
end Chopper;
end Inverters; |
Examples for AC1ph_DC components | within PowerSystems.Examples;
package AC1ph_DC "Examples for AC1ph_DC components"
extends Modelica.Icons.ExamplesPackage;
end AC1ph_DC; |
Transformation 1 phase | within PowerSystems.Examples.AC1ph_DC;
package Transformation "Transformation 1 phase"
extends Modelica.Icons.ExamplesPackage;
model OnePhase "One phase transformer"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.AC1ph_DC.Sources.ACvoltage voltage(pol=-1)
PowerSystems.AC1ph_DC.Sensors.PVImeter meter1
PowerSystems.AC1ph_DC.Nodes.BusBar bus
PowerSystems.AC1ph_DC.Transformers.TrafoStray trafo(
redeclare record Data =
PowerSystems.AC1ph_DC.Transformers.Parameters.TrafoStray1ph(V_nom={1,10}))
PowerSystems.AC1ph_DC.Sensors.PVImeter meter2(V_nom=10)
PowerSystems.AC1ph_DC.ImpedancesOneTerm.Resistor res(V_nom=10, r=1000)
PowerSystems.AC1ph_DC.Nodes.PolarityGround polGrd(pol=0)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
equation
connect(voltage.term, meter1.term_p)
connect(meter1.term_n, bus.term)
connect(bus.term, trafo.term_p)
connect(trafo.term_n, meter2.term_p)
connect(meter2.term_n, res.term)
connect(res.term, polGrd.term)
connect(grd.term, voltage.neutral)
end OnePhase;
model TapChanger "One phase tap changing primary and secondary"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.Control.Relays.TapChangerRelay tapRelay2(
preset_1={0,0},
preset_2={0,-1,0,1},
t_switch_2={1,2,3})
PowerSystems.Control.Relays.TapChangerRelay tapRelay1(
preset_1={0,-1,0,1},
preset_2={0,0},
t_switch_1={1,2,3})
PowerSystems.AC1ph_DC.Sources.ACvoltage voltage(pol=-1)
PowerSystems.AC1ph_DC.Sensors.PVImeter meter1
PowerSystems.AC1ph_DC.Nodes.BusBar bus
PowerSystems.AC1ph_DC.Transformers.TrafoStray trafo1(
redeclare record Data =
PowerSystems.AC1ph_DC.Transformers.Parameters.TrafoStray1ph (
dv_tap={0.1,0.1},
V_nom={1,10}),
use_tap_1_in=true,
use_tap_2_in=true)
PowerSystems.AC1ph_DC.Sensors.PVImeter meter12(V_nom=10)
PowerSystems.AC1ph_DC.ImpedancesOneTerm.Resistor res12(V_nom=10, r=1000)
PowerSystems.AC1ph_DC.Transformers.TrafoStray trafo2(
redeclare record Data =
PowerSystems.AC1ph_DC.Transformers.Parameters.TrafoStray1ph (
dv_tap={0.1,0.1},
V_nom={1,10}),
use_tap_1_in=true,
use_tap_2_in=true)
PowerSystems.AC1ph_DC.Sensors.PVImeter meter22(V_nom=10)
PowerSystems.AC1ph_DC.ImpedancesOneTerm.Resistor res22(V_nom=10, r=1000)
PowerSystems.AC1ph_DC.Nodes.PolarityGround polGrd1(pol=0)
PowerSystems.AC1ph_DC.Nodes.PolarityGround polGrd2(pol=0)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
equation
connect(voltage.term, meter1.term_p)
connect(meter1.term_n, bus.term)
connect(bus.term, trafo1.term_p)
connect(trafo1.term_n, meter12.term_p)
connect(meter12.term_n, res12.term)
connect(bus.term, trafo2.term_p)
connect(trafo2.term_n, meter22.term_p)
connect(meter22.term_n, res22.term)
connect(res12.term, polGrd1.term)
connect(res22.term, polGrd2.term)
connect(grd.term, voltage.neutral)
connect(tapRelay1.tap_1, trafo1.tap_1_in)
connect(tapRelay1.tap_2, trafo1.tap_2_in)
connect(tapRelay2.tap_1, trafo2.tap_1_in)
connect(tapRelay2.tap_2, trafo2.tap_2_in)
end TapChanger;
end Transformation; |
AC drives, dq0 | within PowerSystems.Examples.AC3ph;
package Drives "AC drives, dq0"
extends Modelica.Icons.ExamplesPackage;
model ASMcharacteristic
"AC asynchronous machine: torque - slip characteristic"
extends Modelica.Icons.Example;
inner PowerSystems.System system(dynType=PowerSystems.Types.Dynamics.SteadyState)
PowerSystems.AC3ph.Nodes.GroundOne grd
PowerSystems.AC3ph.Sources.Voltage voltage(V_nom=400)
PowerSystems.AC3ph.Drives.ASM asm(
redeclare model Rotor = PowerSystems.Mechanics.Rotational.ElectricRotor (
J=0.3),
redeclare model Motor = PowerSystems.AC3ph.Machines.Asynchron (
redeclare record Data =
PowerSystems.Examples.Data.Machines.Asynchron400V_30kVA))
PowerSystems.Common.Thermal.BdCondV bdCond(m=2)
PowerSystems.Mechanics.Rotational.Speed speed(
w0=system.omega_nom/2,
use_w_in=true,
tcst=0.01)
PowerSystems.Blocks.Signals.Transient speedSignal(
t_duration=0.5,
s_end=2*system.omega_nom/asm.motor.pp,
s_start=-system.omega_nom/asm.motor.pp)
equation
connect(grd.term, voltage.neutral)
connect(asm.flange, speed.flange)
connect(asm.heat, bdCond.heat)
connect(voltage.term, asm.term)
connect(speedSignal.y, speed.w_in)
end ASMcharacteristic;
model ASM_Y_D "AC asynchronous machine Y-Delta switcheable"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Nodes.GroundOne grd
PowerSystems.AC3ph.Sources.Voltage voltage(V_nom=400, v0=1)
PowerSystems.AC3ph.Sensors.Psensor power
PowerSystems.AC3ph.Drives.ASM_Y_D asm_Y_D(
redeclare model Rotor = PowerSystems.Mechanics.Rotational.ElectricRotor (
J=0.3),
redeclare model Motor = PowerSystems.AC3ph.Machines.AsynchronY_D (
redeclare record Data =
PowerSystems.Examples.Data.Machines.Asynchron400V_30kVA),
w_start=4.1887902047864)
PowerSystems.Common.Thermal.BdCondV bdCond(m=2)
PowerSystems.Mechanics.Rotational.Rotor loadInertia(J=40)
PowerSystems.Mechanics.Rotational.FrictionTorque frictTorq(cFrict={1,0.05})
PowerSystems.Control.Relays.Y_DeltaControl relay1(t_switch={1.5})
equation
connect(relay1.y,asm_Y_D. YDcontrol)
connect(voltage.term, power.term_p)
connect(asm_Y_D.flange,loadInertia.flange_a)
connect(loadInertia.flange_b, frictTorq.flange)
connect(grd.term, voltage.neutral)
connect(power.term_n, asm_Y_D.term)
connect(asm_Y_D.heat, bdCond.heat)
end ASM_Y_D;
model ASMav
"AC asynchronous machine, voltage controlled with average inverter"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Synchron)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
PowerSystems.AC1ph_DC.Sources.DCvoltage voltage(pol=0, V_nom=sqrt(2/3)*6000)
PowerSystems.AC3ph.Inverters.Select select
PowerSystems.AC3ph.Inverters.InverterAverage inverter(redeclare record Data =
PowerSystems.Examples.Data.Semiconductors.IdealSC3kV_500A)
PowerSystems.AC3ph.Sensors.PVImeter power(av=true,
tcst=0.05)
PowerSystems.AC3ph.Drives.ASM asm(
redeclare model Rotor = PowerSystems.Mechanics.Rotational.ElectricRotor (
J=6.4),
redeclare model Motor = PowerSystems.AC3ph.Machines.Asynchron (
redeclare record Data =
PowerSystems.Examples.Data.Machines.Asynchron3kV_1p5MVA),
w_start=157.07963267949)
PowerSystems.Common.Thermal.BdCondV bdCond1(m=2)
PowerSystems.Common.Thermal.BdCondV bdCond2(m=1)
PowerSystems.Mechanics.Rotational.TabPosSlopeTorque tabLoad(
r=0.4,
gRatio=40/17,
cFrict={50,15},
mass=200e3,
scale=true,
D=1.5e3,
slope_scale=0.025,
tableName="height",
fileName=TableDir + "hNormProfile.tab",
colData=3)
equation
connect(select.theta_out, inverter.theta)
connect(select.vPhasor_out,inverter.vPhasor)
connect(voltage.term, inverter.DC)
connect(inverter.AC, power.term_p)
connect(power.term_n, asm.term)
connect(grd.term, voltage.neutral)
connect(asm.flange,tabLoad.flange_a)
connect(asm.heat, bdCond1.heat)
connect(inverter.heat,bdCond2. heat)
end ASMav;
model ASMav_icontrol
"AC asynchronous machine, current controlled with average inverter"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Synchron)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
PowerSystems.AC1ph_DC.Sources.DCvoltage voltage(pol=0, V_nom=sqrt(2/3)*6000)
PowerSystems.AC3ph.Drives.ASM_ctrl asm_ctrl(
redeclare model Rotor = PowerSystems.Mechanics.Rotational.ElectricRotor (
J=0.3),
redeclare model Motor = PowerSystems.AC3ph.Machines.Asynchron_ctrl (
redeclare record Data =
PowerSystems.Examples.Data.Machines.Asynchron3kV_1p5MVA),
redeclare model Inverter = PowerSystems.AC3ph.Inverters.InverterAverage (
redeclare record Data =
PowerSystems.Examples.Data.Semiconductors.IdealSC3kV_500A),
w_start=157.07963267949)
PowerSystems.Common.Thermal.BdCondV bdCond(m=3)
PowerSystems.Mechanics.Rotational.TabPosSlopeTorque tabLoad(
r=0.4,
gRatio=40/17,
cFrict={50,15},
mass=200e3,
scale=true,
D=1.5e3,
slope_scale=0.025,
tableName="height",
fileName=TableDir + "hNormProfile.tab",
colData=3)
PowerSystems.Blocks.Signals.Transient i_q(s_end=0.2, s_start=0)
"phase of modulation signal"
PowerSystems.Blocks.Signals.Transient i_d(
s_start=0.36,
s_end=0.36,
t_change=30,
t_duration=60) "phase of modulation signal"
Modelica.Blocks.Continuous.LimPID PI_i_q(
Td=0.1,
controllerType=Modelica.Blocks.Types.SimpleController.PI,
Ti=0.1,
yMax=1,
initType=Modelica.Blocks.Types.Init.SteadyState,
gainPID(y(start=0.1)))
equation
connect(grd.term, voltage.neutral)
connect(voltage.term, asm_ctrl.term)
connect(asm_ctrl.flange,tabLoad.flange_a)
connect(i_q.y,PI_i_q. u_s)
connect(i_d.y, asm_ctrl.i_act[1])
connect(asm_ctrl.i_meas[2], PI_i_q.u_m)
connect(PI_i_q.y, asm_ctrl.i_act[2])
connect(asm_ctrl.heat, bdCond.heat)
end ASMav_icontrol;
model ASM "AC asynchronous machine, voltage controlled"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
PowerSystems.AC1ph_DC.Sources.DCvoltage voltage(pol=0, V_nom=sqrt(2/3)*6000)
PowerSystems.AC3ph.Inverters.Select select
PowerSystems.AC3ph.Inverters.Inverter inverter
PowerSystems.AC3ph.Sensors.PVImeter power(
av=true,
tcst=0.05,
abc=true)
PowerSystems.AC3ph.Drives.ASM asm(
redeclare model Rotor = PowerSystems.Mechanics.Rotational.ElectricRotor (
J=6.4),
redeclare model Motor = PowerSystems.AC3ph.Machines.Asynchron (
redeclare record Data =
PowerSystems.Examples.Data.Machines.Asynchron3kV_1p5MVA),
w_start=157.07963267949)
PowerSystems.Common.Thermal.BdCondV bdCond1(m=2)
PowerSystems.Common.Thermal.BdCondV bdCond2(m=3)
PowerSystems.Mechanics.Rotational.TabPosSlopeTorque tabLoad(
r=0.4,
gRatio=40/17,
cFrict={50,15},
mass=200e3,
scale=true,
D=1.5e3,
slope_scale=0.025,
tableName="height",
fileName=TableDir + "hNormProfile.tab",
colData=3)
equation
connect(select.theta_out, inverter.theta)
connect(select.vPhasor_out,inverter.vPhasor)
connect(voltage.term, inverter.DC)
connect(inverter.AC, power.term_p)
connect(power.term_n, asm.term)
connect(grd.term, voltage.neutral)
connect(asm.flange,tabLoad.flange_a)
connect(asm.heat, bdCond1.heat)
connect(inverter.heat,bdCond2. heat)
end ASM;
model SM_ctrlAv
"AC synchronous pm machine, current controlled with average inverter"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
PowerSystems.AC1ph_DC.Sources.DCvoltage voltage(pol=0, V_nom=sqrt(2/3)*2*400)
PowerSystems.AC3ph.Drives.SM_ctrl sm_ctrl(
redeclare model Rotor = PowerSystems.Mechanics.Rotational.ElectricRotor (
J=0.3),
redeclare model Inverter = PowerSystems.AC3ph.Inverters.InverterAverage (
redeclare record Data =
PowerSystems.Examples.Data.Semiconductors.IdealSC1kV_100A),
redeclare model Motor = PowerSystems.AC3ph.Machines.Synchron3rd_pm_ctrl (
redeclare record Data =
PowerSystems.Examples.Data.Machines.Synchron3rd_pm400V_30kVA))
PowerSystems.Common.Thermal.BdCondV bdCond(m=3)
PowerSystems.Mechanics.Rotational.Rotor loadInertia(J=0.5)
PowerSystems.Mechanics.Rotational.FrictionTorque frictTorq(cFrict={0.1,0.01})
Modelica.Mechanics.Rotational.Sources.TorqueStep torqueStep(
offsetTorque=0,
startTime=6,
stepTorque=-100,
useSupport=false)
PowerSystems.Blocks.Signals.Transient i_q(t_change=3, s_start=0.1)
"phase of modulation signal"
PowerSystems.Blocks.Signals.Transient i_d(
t_change=3,
s_start=0,
s_end=0) "phase of modulation signal"
Modelica.Blocks.Continuous.LimPID PI_i_q(
Ti=0.2,
Td=0.1,
controllerType=Modelica.Blocks.Types.SimpleController.PI,
initType=Modelica.Blocks.Types.Init.SteadyState,
yMax=1,
gainPID(y(start=0.1)))
equation
connect(sm_ctrl.heat, bdCond.heat)
connect(grd.term, voltage.neutral)
connect(i_q.y, PI_i_q.u_s)
connect(sm_ctrl.flange,loadInertia.flange_a)
connect(loadInertia.flange_b, frictTorq.flange)
connect(loadInertia.flange_b, torqueStep.flange)
connect(voltage.term, sm_ctrl.term)
connect(sm_ctrl.i_meas[2], PI_i_q.u_m)
connect(PI_i_q.y, sm_ctrl.i_act[2])
connect(i_d.y, sm_ctrl.i_act[1])
end SM_ctrlAv;
model SM_ctrl "AC synchronous pm machine, current controlled"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
PowerSystems.AC1ph_DC.Sources.DCvoltage voltage(pol=0, V_nom=sqrt(2/3)*2*400)
PowerSystems.AC3ph.Drives.SM_ctrl sm_ctrl(
redeclare model Rotor = PowerSystems.Mechanics.Rotational.ElectricRotor (
J=0.3),
redeclare model Inverter = PowerSystems.AC3ph.Inverters.Inverter (
redeclare model Inverter =
PowerSystems.AC3ph.Inverters.Components.InverterSwitch
"switch, no diode, no losses") "inverter with modulator",
redeclare model Motor = PowerSystems.AC3ph.Machines.Synchron3rd_pm_ctrl (
redeclare record Data =
PowerSystems.Examples.Data.Machines.Synchron3rd_pm400V_30kVA(r_n=0)))
PowerSystems.Common.Thermal.BdCondV bdCond(m=5)
PowerSystems.Mechanics.Rotational.Rotor loadInertia(J=0.5)
PowerSystems.Mechanics.Rotational.FrictionTorque frictTorq(cFrict={0.1,0.01})
Modelica.Mechanics.Rotational.Sources.TorqueStep torqueStep(
offsetTorque=0,
stepTorque=-100,
startTime=2,
useSupport=false)
PowerSystems.Blocks.Signals.Transient i_q(
s_start=0.1) "phase of modulation signal"
Modelica.Blocks.Continuous.LimPID PI_i_q(
Td=0.05,
controllerType=Modelica.Blocks.Types.SimpleController.PI,
Ti=0.2,
initType=Modelica.Blocks.Types.Init.InitialState,
xi_start=0.1,
yMax=1)
PowerSystems.Blocks.Signals.Transient i_d(
s_start=0,
s_end=0) "phase of modulation signal"
equation
connect(sm_ctrl.heat, bdCond.heat)
connect(grd.term, voltage.neutral)
connect(i_q.y, PI_i_q.u_s)
connect(sm_ctrl.flange,loadInertia.flange_a)
connect(loadInertia.flange_b, frictTorq.flange)
connect(loadInertia.flange_b, torqueStep.flange)
connect(voltage.term, sm_ctrl.term)
connect(sm_ctrl.i_meas[2], PI_i_q.u_m)
connect(PI_i_q.y, sm_ctrl.i_act[2])
connect(i_d.y, sm_ctrl.i_act[1])
end SM_ctrl;
model ASM_ctrlAv
"AC asynchronous machine, current controlled with average inverter"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
PowerSystems.AC1ph_DC.Sources.DCvoltage voltage(pol=0, V_nom=sqrt(2/3)*2*400)
PowerSystems.AC3ph.Drives.ASM_ctrl asm_ctrl(
rotor(J=0.3),
redeclare model Inverter = PowerSystems.AC3ph.Inverters.InverterAverage (
redeclare record Data =
PowerSystems.Examples.Data.Semiconductors.IdealSC1kV_100A),
redeclare model Motor = PowerSystems.AC3ph.Machines.Asynchron_ctrl (
redeclare record Data =
PowerSystems.Examples.Data.Machines.Asynchron400V_30kVA,
i_start={10,10,0}))
PowerSystems.Common.Thermal.BdCondV bdCond(m=3)
PowerSystems.Mechanics.Rotational.Rotor loadInertia(J=0.5)
PowerSystems.Mechanics.Rotational.FrictionTorque frictTorq(cFrict={5,0.5})
Modelica.Mechanics.Rotational.Sources.TorqueStep torqueStep(
offsetTorque=0,
startTime=6,
stepTorque=-200,
useSupport=false)
PowerSystems.Blocks.Signals.Transient i_q(t_change=3,
s_end=0.7,
s_start=0.6) "phase of modulation signal"
PowerSystems.Blocks.Signals.Transient i_d(
t_change=8,
s_end=0.45,
s_start=0.35) "phase of modulation signal"
Modelica.Blocks.Continuous.LimPID PI_i_q(
Td=0.1,
controllerType=Modelica.Blocks.Types.SimpleController.PI,
Ti=0.1,
yMax=1,
gainPID(y(start=0.1)),
initType=Modelica.Blocks.Types.Init.SteadyState)
equation
connect(asm_ctrl.heat, bdCond.heat)
connect(grd.term, voltage.neutral)
connect(i_q.y, PI_i_q.u_s)
connect(asm_ctrl.flange,loadInertia.flange_a)
connect(loadInertia.flange_b, frictTorq.flange)
connect(loadInertia.flange_b, torqueStep.flange)
connect(voltage.term, asm_ctrl.term)
connect(asm_ctrl.i_meas[2], PI_i_q.u_m)
connect(PI_i_q.y, asm_ctrl.i_act[2])
connect(i_d.y, asm_ctrl.i_act[1])
end ASM_ctrlAv;
model ASM_ctrl "AC asynchronous machine, current controlled"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.AC1ph_DC.Nodes.GroundOne grd
PowerSystems.AC1ph_DC.Sources.DCvoltage voltage(pol=0, V_nom=sqrt(2/3)*2*400)
PowerSystems.AC3ph.Drives.ASM_ctrl asm_ctrl(
redeclare model Rotor = PowerSystems.Mechanics.Rotational.ElectricRotor (
J=0.3),
redeclare model Motor = PowerSystems.AC3ph.Machines.Asynchron_ctrl (
redeclare record Data =
PowerSystems.Examples.Data.Machines.Asynchron400V_30kVA(r_n=0)),
redeclare model Inverter = PowerSystems.AC3ph.Inverters.Inverter (
redeclare model Inverter =
PowerSystems.AC3ph.Inverters.Components.InverterSwitch
"switch, no diode, no losses") "inverter with modulator",
w_start=0.10471975511966)
PowerSystems.Common.Thermal.BdCondV bdCond(m=5)
PowerSystems.Mechanics.Rotational.Rotor loadInertia(J=0.5, w_start(
displayUnit="rpm") = 0.10471975511966)
PowerSystems.Mechanics.Rotational.FrictionTorque frictTorq(cFrict={5,0.5})
Modelica.Mechanics.Rotational.Sources.TorqueStep torqueStep(
offsetTorque=0,
startTime=2,
stepTorque=-200,
useSupport=false)
PowerSystems.Blocks.Signals.Transient i_q(s_start=0.6, s_end=0.7)
"phase of modulation signal"
Modelica.Blocks.Continuous.LimPID PI_i_q(
Td=0.05,
controllerType=Modelica.Blocks.Types.SimpleController.PI,
Ti=0.1,
yMax=1)
PowerSystems.Blocks.Signals.Transient i_d(
s_end=0.45,
t_change=2.5,
t_duration=0.5,
s_start=0.35) "phase of modulation signal"
equation
connect(asm_ctrl.heat, bdCond.heat)
connect(grd.term, voltage.neutral)
connect(i_q.y, PI_i_q.u_s)
connect(asm_ctrl.flange,loadInertia.flange_a)
connect(loadInertia.flange_b, frictTorq.flange)
connect(loadInertia.flange_b, torqueStep.flange)
connect(voltage.term, asm_ctrl.term)
connect(asm_ctrl.i_meas[2], PI_i_q.u_m)
connect(PI_i_q.y, asm_ctrl.i_act[2])
connect(i_d.y, asm_ctrl.i_act[1])
end ASM_ctrl;
end Drives; |
AC 3-phase components dq0 | within PowerSystems.Examples.AC3ph;
package Elementary "AC 3-phase components dq0"
extends Modelica.Icons.ExamplesPackage;
model Breaker "Breaker"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Nodes.Ground grd2
PowerSystems.Blocks.Signals.TransientPhasor transPh
PowerSystems.AC3ph.Sources.Voltage voltage(V_nom=10e3, use_vPhasor_in=true)
PowerSystems.AC3ph.Impedances.Inductor ind(
r=0.1,
V_nom=10e3,
S_nom=1e6)
PowerSystems.AC3ph.Sensors.PVImeter meter(V_nom=10e3, S_nom=1e6)
replaceable PowerSystems.AC3ph.Breakers.Breaker breaker(V_nom=10e3, I_nom=100)
PowerSystems.Control.Relays.SwitchRelay relay(t_switch={0.1})
PowerSystems.AC3ph.Nodes.GroundOne grd1
equation
connect(transPh.y, voltage.vPhasor_in)
connect(relay.y, breaker.control)
connect(voltage.term, ind.term_p)
connect(ind.term_n, meter.term_p)
connect(meter.term_n, breaker.term_p)
connect(breaker.term_n, grd2.term)
connect(grd1.term, voltage.neutral)
end Breaker;
model Fault "Fault"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Sources.Voltage voltage1(
V_nom=10e3, alpha0=0.17453292519943)
PowerSystems.AC3ph.Breakers.Switch switch1(V_nom=10e3, I_nom=100)
PowerSystems.AC3ph.Lines.FaultRXline line(redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline(V_nom=10e3, S_nom=1e6))
PowerSystems.AC3ph.Breakers.Switch switch2(V_nom=10e3, I_nom=100)
PowerSystems.AC3ph.Sources.Voltage voltage2(V_nom=10e3)
PowerSystems.Control.Relays.SwitchRelay relay1(t_switch={0.15})
PowerSystems.Control.Relays.SwitchRelay relay2(t_switch={0.153})
PowerSystems.AC3ph.Sensors.PVImeter meter(V_nom=10e3, S_nom=1e6)
replaceable PowerSystems.AC3ph.Faults.Fault_ab fault_ab
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd2
equation
connect(relay1.y, switch1.control)
connect(relay2.y, switch2.control)
connect(voltage1.term, switch1.term_p)
connect(switch1.term_n, line.term_p)
connect(line.term_n, switch2.term_p)
connect(switch2.term_n, voltage2.term)
connect(line.term_f, meter.term_p)
connect(meter.term_n, fault_ab.term)
connect(grd1.term, voltage1.neutral)
connect(voltage2.neutral, grd2.term)
end Fault;
model Impedance "Impedance"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.Blocks.Signals.TransientPhasor transPh
PowerSystems.AC3ph.Sources.Voltage voltage(use_vPhasor_in=true)
PowerSystems.AC3ph.Sensors.PVImeter meter
replaceable PowerSystems.AC3ph.Impedances.Inductor ind(r=0.1)
PowerSystems.AC3ph.Nodes.Ground grd2
PowerSystems.AC3ph.Nodes.GroundOne grd1
equation
connect(transPh.y, voltage.vPhasor_in)
connect(voltage.term, meter.term_p)
connect(meter.term_n, ind.term_p)
connect(ind.term_n, grd2.term)
connect(grd1.term, voltage.neutral)
end Impedance;
model ImpedanceYD "Impedance Y-Delta"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.Blocks.Signals.TransientPhasor transPh
PowerSystems.AC3ph.Sources.Voltage voltage(use_vPhasor_in=true)
PowerSystems.AC3ph.Sensors.PVImeter meter
replaceable PowerSystems.AC3ph.ImpedancesYD.Inductor indYD(r=0.1)
PowerSystems.AC3ph.Nodes.GroundOne grd
equation
connect(transPh.y, voltage.vPhasor_in)
connect(voltage.term, meter.term_p)
connect(meter.term_n, indYD.term)
connect(grd.term, voltage.neutral)
end ImpedanceYD;
model Line "Line"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.Blocks.Signals.TransientPhasor transPh(ph_end=
0.087266462599716)
PowerSystems.AC3ph.Sources.Voltage voltage1(
V_nom=132e3,
use_vPhasor_in=true,
alpha0=0.087266462599716)
PowerSystems.AC3ph.Sensors.PVImeter meter(V_nom=132e3, S_nom=100e6)
PowerSystems.AC3ph.Sources.Voltage voltage2(V_nom=132e3)
replaceable PowerSystems.AC3ph.Lines.Tline line(redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.Line ( V_nom=132e3))
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd2
equation
connect(transPh.y, voltage1.vPhasor_in)
connect(voltage1.term, meter.term_p)
connect(meter.term_n, line.term_p)
connect(line.term_n, voltage2.term)
connect(grd1.term, voltage1.neutral)
connect(voltage2.neutral, grd2.term)
end Line;
model Load "Load"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.Blocks.Signals.TransientPhasor transPh
PowerSystems.AC3ph.Sources.Voltage voltage(use_vPhasor_in=true)
PowerSystems.AC3ph.Sensors.PVImeter meter
replaceable PowerSystems.AC3ph.Loads.PQindLoad load(tcst=0.01, use_pq_in=true)
PowerSystems.Blocks.Signals.Transient[2] trsSignal(s_start={sqrt(3)/2,1/2}, s_end={1,0.2})
PowerSystems.AC3ph.Nodes.GroundOne grd
equation
connect(transPh.y, voltage.vPhasor_in)
connect(trsSignal.y,load.pq_in)
connect(voltage.term, meter.term_p)
connect(meter.term_n, load.term)
connect(grd.term, voltage.neutral)
end Load;
model Machines "Machines"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Synchron)
PowerSystems.Blocks.Signals.TransientPhasor transPh
PowerSystems.AC3ph.Sources.Voltage voltage(
v0=1,
use_vPhasor_in=true,
V_nom=400)
PowerSystems.AC3ph.Sensors.Psensor power
replaceable PowerSystems.AC3ph.Machines.Asynchron asynchron(
redeclare record Data =
PowerSystems.AC3ph.Machines.Parameters.Asynchron_cage(V_nom=400, S_nom=1e3))
PowerSystems.Mechanics.Rotational.Rotor rotor(w_start = 314.1592653589793)
PowerSystems.Mechanics.Rotational.Torque torq
PowerSystems.Blocks.Signals.Transient trsSignal
PowerSystems.AC3ph.Nodes.GroundOne grd
PowerSystems.Common.Thermal.BoundaryV boundary(m=2)
equation
connect(transPh.y, voltage.vPhasor_in)
connect(voltage.term, power.term_p)
connect(power.term_n, asynchron.term)
connect(asynchron.airgap,rotor.flange_a)
connect(rotor.flange_b, torq.flange)
connect(grd.term, voltage.neutral)
connect(asynchron.heat, boundary.heat)
connect(trsSignal.y, torq.tau_in)
end Machines;
model Sensor "Sensor and meter"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Sources.Vspectrum voltage(use_vPhasor_in=true)
PowerSystems.AC3ph.ImpedancesYD.Resistor res
PowerSystems.Blocks.Signals.TransientPhasor transPh
replaceable PowerSystems.AC3ph.Sensors.PVImeter meter(abc=true)
PowerSystems.AC3ph.Nodes.GroundOne grd
equation
connect(transPh.y, voltage.vPhasor_in)
connect(voltage.term, meter.term_p)
connect(meter.term_n, res.term)
connect(grd.term, voltage.neutral)
end Sensor;
model Source "Source"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.ImpedancesYD.Inductor ind(r=0.1)
PowerSystems.AC3ph.Sensors.PVImeter meter(abc=true)
replaceable PowerSystems.AC3ph.Sources.Voltage voltage
PowerSystems.AC3ph.Nodes.GroundOne grd
equation
connect(voltage.term, meter.term_p)
connect(meter.term_n, ind.term)
connect(grd.term, voltage.neutral)
end Source;
model Transformer "Transformer"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.Blocks.Signals.TransientPhasor transPh
PowerSystems.AC3ph.Sources.Voltage voltage(use_vPhasor_in=true)
PowerSystems.AC3ph.Sensors.PVImeter meter1
replaceable PowerSystems.AC3ph.Transformers.TrafoStray trafo(
redeclare record Data =
PowerSystems.AC3ph.Transformers.Parameters.TrafoStray (
tap_neutral={1,1},
dv_tap={0.1, 0.2},
V_nom={1,10}),
redeclare model Topology_p = PowerSystems.AC3ph.Ports.Topology.Y,
redeclare model Topology_n = PowerSystems.AC3ph.Ports.Topology.Delta,
use_tap_1_in=true,
use_tap_2_in=true)
PowerSystems.AC3ph.Sensors.PVImeter meter2(V_nom=10)
PowerSystems.AC3ph.ImpedancesYD.Resistor res(V_nom=10, r=100)
PowerSystems.Control.Relays.TapChangerRelay tapChanger(
preset_1={1,1,2},
preset_2={1,1,2},
t_switch_1={0.9,1.9},
t_switch_2={1.1,2.1})
PowerSystems.AC3ph.Nodes.GroundOne grd
equation
connect(transPh.y, voltage.vPhasor_in)
connect(voltage.term, meter1.term_p)
connect(meter1.term_n, trafo.term_p)
connect(trafo.term_n, meter2.term_p)
connect(meter2.term_n, res.term)
connect(grd.term, voltage.neutral)
connect(tapChanger.tap_1, trafo.tap_1_in)
connect(tapChanger.tap_2, trafo.tap_2_in)
end Transformer;
model Rectifier "Rectifier"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.Blocks.Signals.TransientPhasor transPh
PowerSystems.AC3ph.Sources.Voltage vAC(V_nom=2, use_vPhasor_in=true)
PowerSystems.AC3ph.Impedances.Inductor ind(r=0.05)
PowerSystems.AC3ph.Sensors.PVImeter meterAC(av=true, tcst=0.1)
replaceable PowerSystems.AC3ph.Inverters.Rectifier rectifier
PowerSystems.AC1ph_DC.Sensors.PVImeter meterDC(av=true, tcst=0.1)
PowerSystems.AC1ph_DC.Sources.DCvoltage vDC(pol=0)
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd2
PowerSystems.Common.Thermal.BoundaryV boundary(m=3)
equation
connect(transPh.y, vAC.vPhasor_in)
connect(vAC.term, ind.term_p)
connect(ind.term_n, meterAC.term_p)
connect(meterAC.term_n, rectifier.AC)
connect(rectifier.DC, meterDC.term_p)
connect(meterDC.term_n, vDC.term)
connect(grd1.term, vAC.neutral)
connect(vDC.neutral, grd2.term)
connect(rectifier.heat, boundary.heat)
end Rectifier;
model Inverter "Inverter, controlled rectifier"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.Blocks.Signals.TransientPhasor transPh
PowerSystems.AC3ph.Sources.Voltage vAC(V_nom=2, use_vPhasor_in=true)
PowerSystems.AC3ph.Impedances.Inductor ind(r=0.05)
PowerSystems.AC3ph.Sensors.PVImeter meterAC(av=true, tcst=0.1)
replaceable PowerSystems.AC3ph.Inverters.Inverter ac_dc
PowerSystems.AC1ph_DC.Sensors.PVImeter meterDC(av=true, tcst=0.1)
PowerSystems.AC1ph_DC.Sources.DCvoltage vDC(pol=0)
PowerSystems.AC3ph.Inverters.Select select
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd2
PowerSystems.Common.Thermal.BoundaryV boundary(m=3)
equation
connect(transPh.y, vAC.vPhasor_in)
connect(vAC.term, ind.term_p)
connect(ind.term_n, meterAC.term_p)
connect(meterAC.term_n, ac_dc.AC)
connect(ac_dc.DC, meterDC.term_p)
connect(meterDC.term_n, vDC.term)
connect(select.theta_out, ac_dc.theta)
connect(select.vPhasor_out,ac_dc.vPhasor)
connect(grd1.term, vAC.neutral)
connect(vDC.neutral, grd2.term)
connect(ac_dc.heat, boundary.heat)
end Inverter;
end Elementary; |
AC power generation, dq0 | within PowerSystems.Examples.AC3ph;
package Generation "AC power generation, dq0"
extends Modelica.Icons.ExamplesPackage;
model Vsource "Power transfer from voltage source to slack bus"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Sources.VsourceRX Vsource(
V_nom=20e3,
v_start=1.02,
S_nom=500e6,
pq_start={1,0.428},
alpha_start=0.037545522868902)
PowerSystems.AC3ph.Sensors.Psensor sensor
PowerSystems.AC3ph.Lines.RXline line(
len=40e3, redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline (V_nom=20e3, S_nom=500e6))
PowerSystems.AC3ph.Sources.InfBus infBus(V_nom=20e3)
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd2
equation
connect(Vsource.term, sensor.term_p)
connect(sensor.term_n, line.term_p)
connect(line.term_n, infBus.term)
connect(grd1.term, Vsource.neutral)
connect(infBus.neutral, grd2.term)
end Vsource;
model PVsource "Power transfer from power-voltage source to slack bus"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Sources.PVsource PVsource(
V_nom=20e3,
S_nom=500e6,
v0=1.02,
p0=1)
PowerSystems.AC3ph.Lines.RXline line(redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=20e3,
S_nom=500e6),
len=40e3)
PowerSystems.AC3ph.Sensors.Psensor sensor
PowerSystems.AC3ph.Sources.InfBus infBus(V_nom=20e3)
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd2
equation
connect(PVsource.term, sensor.term_p)
connect(sensor.term_n, line.term_p)
connect(line.term_n, infBus.term)
connect(grd1.term, PVsource.neutral)
connect(infBus.neutral, grd2.term)
end PVsource;
model PQsource "Power transfer from power source to slack bus"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Sources.PQsource PQsource(
S_nom=500e6,
V_nom=20e3,
pq0={1,0.428})
PowerSystems.AC3ph.Sensors.Psensor sensor
PowerSystems.AC3ph.Lines.RXline line(redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=20e3,
S_nom=500e6),
len=40e3)
PowerSystems.AC3ph.Sources.InfBus infBus(V_nom=20e3)
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd2
equation
connect(PQsource.term, sensor.term_p)
connect(sensor.term_n, line.term_p)
connect(line.term_n, infBus.term)
connect(grd1.term, PQsource.neutral)
connect(infBus.neutral, grd2.term)
end PQsource;
model PowerAngle "Generator at fixed power angle"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Machines.Control.PowerAngle powerAngle(delta=
0.78539816339745)
PowerSystems.Control.Exciters.ExciterSimple exciter(v_f=2.258)
PowerSystems.AC3ph.Machines.Control.Excitation excitation(V_nom=20e3, Vf_nom=20e3)
PowerSystems.AC3ph.Machines.Synchron3rd_ee generator(redeclare replaceable
record Data =
PowerSystems.Examples.Data.Machines.SynchronIso20kV_500MVA)
PowerSystems.AC3ph.Sensors.Psensor sensor
PowerSystems.AC3ph.Sources.InfBus infBus(V_nom=20e3)
PowerSystems.AC3ph.Sources.Voltage Vgen1(
V_nom=20e3,
v0=2.258,
alpha0=0.78539816339745)
PowerSystems.AC3ph.Impedances.Inductor RLgen1(
V_nom=20e3,
S_nom=500e6,
r=0.01,
x_m=-0.5,
x_s=1.1)
PowerSystems.AC3ph.Sensors.Psensor sensor1
PowerSystems.AC3ph.Sources.Voltage Vbus1(V_nom=20e3)
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd2
PowerSystems.AC3ph.Nodes.GroundOne grd3
PowerSystems.Common.Thermal.BdCondV bdCond(m=2)
equation
connect(Vgen1.term, RLgen1.term_p)
connect(RLgen1.term_n, sensor1.term_p)
connect(sensor1.term_n, Vbus1.term)
connect(exciter.fieldVoltage, excitation.fieldVoltage)
connect(excitation.termVoltage, exciter.termVoltage)
connect(generator.term, excitation.term)
connect(excitation.field, generator.field)
connect(generator.term, powerAngle.term)
connect(powerAngle.airgap, generator.airgap)
connect(generator.term, sensor.term_p)
connect(sensor.term_n, infBus.term)
connect(grd1.term, Vgen1.neutral)
connect(Vbus1.neutral, grd2.term)
connect(infBus.neutral, grd3.term)
connect(generator.heat, bdCond.heat)
end PowerAngle;
model TurbineGenerator "Turbine with generator"
extends Modelica.Icons.Example;
inner PowerSystems.System system
parameter SI.AngularVelocity w_start=2*pi*generator.par.f_nom/generator.par.pp
"initial angular velocity (start-value if ini='st')";
PowerSystems.Mechanics.TurboGroups.SingleMassTG turboGrp(
w_start=w_start,
H=20,
w_nom=2*pi*generator.par.f_nom/generator.par.pp,
P_nom=generator.par.S_nom)
PowerSystems.AC3ph.Machines.Synchron3rd_ee generator(redeclare replaceable
record Data =
PowerSystems.Examples.Data.Machines.SynchronIso20kV_500MVA)
PowerSystems.Control.Governors.GovernorSimple governor(p=1.0116)
PowerSystems.Control.Exciters.ExciterSimple exciter(v_f=2.258)
PowerSystems.AC3ph.Machines.Control.Excitation excitation(V_nom=20e3, Vf_nom=20e3)
PowerSystems.AC3ph.Sensors.Psensor sensor
PowerSystems.AC3ph.Sources.InfBus infBus(V_nom=20e3)
PowerSystems.AC3ph.Sources.Voltage Vgen1(
V_nom=20e3,
v0=2.258,
alpha0=0.78539816339745)
PowerSystems.AC3ph.Impedances.Inductor RLgen1(
V_nom=20e3,
S_nom=500e6,
x_s=1.1,
x_m=-0.5,
r=0.01)
PowerSystems.AC3ph.Sensors.Psensor sensor1
PowerSystems.AC3ph.Sources.Voltage VBus1(V_nom=20e3)
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd2
PowerSystems.AC3ph.Nodes.GroundOne grd3
PowerSystems.Common.Thermal.BdCondV bdCond(m=2)
equation
connect(Vgen1.term, RLgen1.term_p)
connect(RLgen1.term_n, sensor1.term_p)
connect(sensor1.term_n, VBus1.term)
connect(exciter.fieldVoltage, excitation.fieldVoltage)
connect(excitation.termVoltage, exciter.termVoltage)
connect(turboGrp.airgap, generator.airgap)
connect(generator.term, excitation.term)
connect(excitation.field, generator.field)
connect(generator.term, sensor.term_p)
connect(sensor.term_n, infBus.term)
connect(turboGrp.speed, governor.speed)
connect(governor.power, turboGrp.power)
connect(grd1.term, Vgen1.neutral)
connect(VBus1.neutral, grd2.term)
connect(infBus.neutral, grd3.term)
connect(generator.heat, bdCond.heat)
end TurbineGenerator;
model TurbineGeneratorLine "Turbine with generator and line"
extends Modelica.Icons.Example;
inner PowerSystems.System system
parameter SI.AngularVelocity w_start=2*pi*generator.par.f_nom/generator.par.pp
"initial angular velocity (start-value if ini='st')";
PowerSystems.Mechanics.TurboGroups.SingleMassTG turboGrp(
final w_start=w_start,
H=20,
w_nom=2*pi*generator.par.f_nom/generator.par.pp,
P_nom=generator.par.S_nom)
PowerSystems.AC3ph.Machines.Synchron3rd_ee generator(redeclare replaceable
record Data =
PowerSystems.Examples.Data.Machines.SynchronIso20kV_500MVA)
PowerSystems.Control.Governors.GovernorSimple governor(p=1.0094)
PowerSystems.Control.Exciters.ExciterSimple exciter(v_f=2.245)
PowerSystems.AC3ph.Machines.Control.Excitation excitation(V_nom=20e3, Vf_nom=20e3)
PowerSystems.AC3ph.Nodes.BusBar busbar
PowerSystems.AC3ph.Sensors.Psensor sensor
PowerSystems.AC3ph.Lines.RXline line(
redeclare record Data = PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=20e3,
r=0.02e-3,
x=0.2e-3),
dynType=PowerSystems.Types.Dynamics.FreeInitial,
len=400e3)
PowerSystems.AC3ph.Sources.InfBus infBus(V_nom=20e3)
PowerSystems.AC3ph.Sources.Voltage Vgen1(
V_nom=20e3,
v0=2.245,
alpha0=1.0285225282003)
PowerSystems.AC3ph.Impedances.Inductor RLgen1(
V_nom=20e3,
S_nom=500e6,
x_s=1.1,
x_m=-0.5,
r=0.01)
PowerSystems.AC3ph.Nodes.BusBar busbar1
PowerSystems.AC3ph.Sensors.Psensor sensor1
PowerSystems.AC3ph.Lines.RXline line1(
redeclare record Data = PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=20e3,
r=0.02e-3,
x=0.2e-3),
dynType=PowerSystems.Types.Dynamics.FreeInitial,
len=400e3)
PowerSystems.AC3ph.Sources.Voltage VBus1(V_nom=20e3)
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd2
PowerSystems.AC3ph.Nodes.GroundOne grd3
PowerSystems.Common.Thermal.BdCondV bdCond(m=2)
equation
connect(Vgen1.term, RLgen1.term_p)
connect(RLgen1.term_n, busbar1.term)
connect(busbar1.term, sensor1.term_p)
connect(sensor1.term_n, line1.term_p)
connect(line1.term_n, VBus1.term)
connect(exciter.fieldVoltage, excitation.fieldVoltage)
connect(excitation.termVoltage, exciter.termVoltage)
connect(turboGrp.airgap, generator.airgap)
connect(generator.term, excitation.term)
connect(excitation.field, generator.field)
connect(generator.term, busbar.term)
connect(busbar.term, sensor.term_p)
connect(sensor.term_n, line.term_p)
connect(line.term_n, infBus.term)
connect(turboGrp.speed, governor.speed)
connect(governor.power, turboGrp.power)
connect(grd1.term, Vgen1.neutral)
connect(VBus1.neutral, grd2.term)
connect(infBus.neutral, grd3.term)
connect(generator.heat, bdCond.heat)
end TurbineGeneratorLine;
model TurboGeneratorLine "Turbo-generator with line to infinite bus"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Generation.TurboGenerator turboGen(
H=20,
redeclare model Generator = PowerSystems.AC3ph.Machines.Synchron3rd_ee (
redeclare replaceable record Data =
PowerSystems.Examples.Data.Machines.SynchronIso20kV_500MVA),
v_start=1.12762,
p_start=1,
q_start=0.42729,
alpha_start=0.346481,
redeclare model Exciter = PowerSystems.Control.Exciters.ExciterConst
"constant")
PowerSystems.AC3ph.Nodes.BusBar busbar
PowerSystems.AC3ph.Sensors.Psensor sensor
PowerSystems.AC3ph.Lines.RXline line(
redeclare record Data = PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=20e3,
r=0.02e-3,
x=0.2e-3),
dynType=PowerSystems.Types.Dynamics.FreeInitial,
len=400e3)
PowerSystems.AC3ph.Sources.InfBus infBus(V_nom=20e3)
PowerSystems.Control.Setpoints.Set_w_p_v setpts
PowerSystems.AC3ph.Sources.Voltage Vgen1(
V_nom=20e3,
v0=2.245,
alpha0=1.0285225282003)
PowerSystems.AC3ph.Impedances.Inductor RLgen1(
V_nom=20e3,
S_nom=500e6,
x_s=1.1,
x_m=-0.5,
r=0.01)
PowerSystems.AC3ph.Nodes.BusBar busbar1
PowerSystems.AC3ph.Sensors.Psensor sensor1
PowerSystems.AC3ph.Lines.RXline line1(
redeclare record Data = PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=20e3,
r=0.02e-3,
x=0.2e-3),
dynType=PowerSystems.Types.Dynamics.FreeInitial,
len=400e3)
PowerSystems.AC3ph.Sources.Voltage VBus1(V_nom=20e3)
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd2
PowerSystems.AC3ph.Nodes.GroundOne grd
PowerSystems.Common.Thermal.BdCondV bdCond(m=2)
equation
connect(setpts.setpts, turboGen.setpts)
connect(Vgen1.term, RLgen1.term_p)
connect(RLgen1.term_n, busbar1.term)
connect(busbar1.term, sensor1.term_p)
connect(sensor1.term_n, line1.term_p)
connect(line1.term_n, VBus1.term)
connect(turboGen.term, busbar.term)
connect(busbar.term, sensor.term_p)
connect(sensor.term_n, line.term_p)
connect(line.term_n, infBus.term)
connect(grd1.term, Vgen1.neutral)
connect(VBus1.neutral, grd2.term)
connect(infBus.neutral, grd.term)
connect(turboGen.heat, bdCond.heat)
end TurboGeneratorLine;
model GenOrder3and7 "Generator-models of different order"
extends Modelica.Icons.Example;
inner PowerSystems.System system(f_nom=60)
PowerSystems.AC3ph.Generation.TurboGenerator turboGen1(
dispPA=true,
v_start=1.03,
p_start=0.97,
H=20,
redeclare model Exciter = PowerSystems.Control.Exciters.Exciter1st
"1st order",
redeclare model Generator = PowerSystems.AC3ph.Machines.Synchron3rd_ee (
redeclare record Data =
PowerSystems.Examples.Data.Machines.Synchron3rd_ee60Hz_26kV_720MVA)
"3rd order",
alpha_start=0.5235987755983)
PowerSystems.AC3ph.Breakers.Switch switchGrd1(V_nom=26e3,I_nom=30e6)
PowerSystems.AC3ph.Nodes.Ground grd1f
PowerSystems.AC3ph.Lines.RXline line1(redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=26e3,
f_nom=60,
r=0.02e-3,
x=0.3e-3), len=250e3)
PowerSystems.AC3ph.Sources.InfBus infBus1(V_nom=26e3)
PowerSystems.AC3ph.Generation.TurboGenerator turboGen2(
dispPA=true,
v_start=1.03,
p_start=0.97,
H=20,
redeclare model Exciter = PowerSystems.Control.Exciters.Exciter1st
"1st order",
redeclare model Generator = PowerSystems.AC3ph.Machines.Synchron_ee (
redeclare record Data =
PowerSystems.Examples.Data.Machines.Synchron_ee60Hz_26kV_720MVA)
"nth order",
alpha_start=0.5235987755983)
PowerSystems.AC3ph.Breakers.Switch switchGrd2(V_nom=26e3,I_nom=30e6)
PowerSystems.AC3ph.Nodes.Ground grd2f
PowerSystems.AC3ph.Lines.RXline line2(redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=26e3,
f_nom=60,
r=0.02e-3,
x=0.3e-3), len=250e3)
PowerSystems.AC3ph.Sources.InfBus infBus2(V_nom=26e3)
PowerSystems.Control.Relays.SwitchRelay relayGrd(
ini_state=false,
t_switch={0.1,0.3})
PowerSystems.Control.Setpoints.Set_w_p_v setpts1
PowerSystems.Control.Setpoints.Set_w_p_v setpts2
PowerSystems.AC3ph.Nodes.GroundOne grd2
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.Common.Thermal.BdCondV bdCond1(m=2)
PowerSystems.Common.Thermal.BdCondV bdCond2(m=2)
equation
connect(setpts1.setpts, turboGen1.setpts)
connect(setpts2.setpts, turboGen2.setpts)
connect(relayGrd.y, switchGrd1.control)
connect(relayGrd.y, switchGrd2.control)
connect(turboGen1.term, line1.term_p)
connect(line1.term_n, infBus1.term)
connect(turboGen1.term, switchGrd1.term_p)
connect(switchGrd1.term_n, grd1f.term)
connect(turboGen2.term, line2.term_p)
connect(line2.term_n, infBus2.term)
connect(turboGen2.term, switchGrd2.term_p)
connect(switchGrd2.term_n, grd2f.term)
connect(infBus1.neutral, grd1.term)
connect(infBus2.neutral, grd2.term)
connect(turboGen1.heat, bdCond1.heat)
connect(turboGen2.heat, bdCond2.heat)
end GenOrder3and7;
model TurboGroupGenerator
"Turbogroup with generator, electro-mechanical interaction"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.Control.Setpoints.Set_w_p_v setpts
PowerSystems.AC3ph.Generation.TurboGrpGenerator turboGrpGen(
v_start=1.0156,
redeclare model Exciter = PowerSystems.Control.Exciters.Exciter1st
"1st order",
redeclare model TurboGroup =
PowerSystems.Mechanics.TurboGroups.SteamTurboGroup (
redeclare record Data =
PowerSystems.Examples.Data.Turbines.SteamTurboGroup1200MW),
redeclare model Generator = PowerSystems.AC3ph.Machines.Synchron_ee (
redeclare record Data =
PowerSystems.Examples.Data.Machines.Synchron_ee20kV_1200MVA)
"nth order")
PowerSystems.AC3ph.Lines.RXline line(
len=40e3, redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=20e3,
r=0.02e-3,
x=0.2e-3))
PowerSystems.AC3ph.Sources.InfBus infBus(V_nom=20e3)
PowerSystems.AC3ph.Breakers.ForcedSwitch switchGrd(V_nom=20e3,I_nom=60e3)
PowerSystems.AC3ph.Nodes.Ground grdf
PowerSystems.Control.Relays.SwitchRelay relayGrd(
ini_state=false,
t_switch={0.1,0.3},
n=1)
PowerSystems.AC3ph.Nodes.GroundOne grd
PowerSystems.Common.Thermal.BdCondV bdCond(m=2)
equation
connect(setpts.setpts, turboGrpGen.setpts)
connect(relayGrd.y[1], switchGrd.control[1])
connect(turboGrpGen.term, line.term_p)
connect(line.term_n, infBus.term)
connect(turboGrpGen.term, switchGrd.term_p)
connect(switchGrd.term_n, grdf.term)
connect(infBus.neutral, grd.term)
connect(turboGrpGen.heat, bdCond.heat)
end TurboGroupGenerator;
model TieLine "Generators and power-oscillations"
extends Modelica.Icons.Example;
inner PowerSystems.System system(
f_nom=60,
f_lim={55,65},
fType=PowerSystems.Types.SystemFrequency.Average)
PowerSystems.AC3ph.Generation.TurboGenerator turboGen1(
dispPA=true,
alpha_start=0.316177 + system.alpha0,
v_start=1.05,
H=20,
redeclare model Generator = PowerSystems.AC3ph.Machines.Synchron_ee (
redeclare record Data =
PowerSystems.Examples.Data.Machines.Synchron_ee60Hz_26kV_720MVA)
"nth order",
redeclare model Exciter = PowerSystems.Control.Exciters.Exciter1st
"1st order",
redeclare model Governor = PowerSystems.Control.Governors.Governor1st
"1st order",
p_start=0.9,
q_start=0.24022361,
initType=PowerSystems.Types.Init.p_q)
PowerSystems.AC3ph.Nodes.BusBar bus1
PowerSystems.AC3ph.Sensors.Psensor sensor1(term_p(v(start={20e3,0,0})))
PowerSystems.AC3ph.Lines.RXline line1(redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=26e3,
f_nom=60,
r=0.02e-3,
x=0.3e-3), len=200e3,
dynType=PowerSystems.Types.Dynamics.FreeInitial)
PowerSystems.AC3ph.Generation.TurboGenerator turboGen2(
dispPA=true,
alpha_start=0.0144536 + system.alpha0,
v_start=1.04,
H=20,
redeclare model Exciter = PowerSystems.Control.Exciters.Exciter1st
"1st order",
redeclare model Generator = PowerSystems.AC3ph.Machines.Synchron_ee (
redeclare record Data =
PowerSystems.Examples.Data.Machines.Synchron_ee60Hz_26kV_720MVA)
"nth order",
redeclare model Governor = PowerSystems.Control.Governors.Governor1st
"1st order",
p_start=0.9,
q_start=0.5092972,
initType=PowerSystems.Types.Init.p_q)
PowerSystems.AC3ph.Nodes.BusBar bus2
PowerSystems.AC3ph.Sensors.Psensor sensor2(term_p(v(start={20e3,0,0})))
PowerSystems.AC3ph.Lines.RXline line2(redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=26e3,
f_nom=60,
r=0.02e-3,
x=0.3e-3), len=40e3,
dynType=PowerSystems.Types.Dynamics.FreeInitial)
PowerSystems.AC3ph.Generation.TurboGenerator turboGen3(
dispPA=true,
v_start=1.03,
H=20,
redeclare model Exciter = PowerSystems.Control.Exciters.Exciter1st
"1st order",
redeclare model Governor = PowerSystems.Control.Governors.Governor1st
"1st order",
redeclare model Generator = PowerSystems.AC3ph.Machines.Synchron_ee (
redeclare record Data =
PowerSystems.Examples.Data.Machines.Synchron_ee60Hz_26kV_720MVA,
dynType=PowerSystems.Types.Dynamics.FreeInitial) "nth order",
q_start=0.10292306,
p_start=0.27353)
PowerSystems.AC3ph.Sensors.Psensor sensor3(term_p(v(start={20e3,0,0})))
PowerSystems.AC3ph.Lines.RXline line3(redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=26e3,
f_nom=60,
r=0.02e-3,
x=0.3e-3), len=150e3,
dynType=PowerSystems.Types.Dynamics.FreeInitial)
PowerSystems.AC3ph.Sensors.Psensor sensorLoad
PowerSystems.AC3ph.Loads.Zload load(
pq0={0.95,0.2},
V_nom=26e3,
S_nom=1500e6,
use_pq_in=true)
PowerSystems.Blocks.Signals.Transient[2] pq_change(
each t_duration=0.1,
s_start={0.95,0.2},
s_end={0.2,0.1},
each t_change=2)
PowerSystems.Control.Setpoints.Set_w_p_v setpts1
PowerSystems.Control.Setpoints.Set_w_p_v setpts2
PowerSystems.Control.Setpoints.Set_w_p_v setpts3
PowerSystems.Common.Thermal.BdCondV bdCond1(m=2)
PowerSystems.Common.Thermal.BdCondV bdCond2(m=2)
PowerSystems.Common.Thermal.BdCondV bdCond3(m=2)
equation
connect(pq_change.y,load.pq_in)
connect(setpts1.setpts,turboGen1. setpts)
connect(setpts2.setpts,turboGen2. setpts)
connect(sensorLoad.term_p,line3. term_p)
connect(sensorLoad.term_n,load. term)
connect(turboGen1.term,bus1. term)
connect(bus1.term,sensor1. term_p)
connect(sensor1.term_n,line1. term_p)
connect(turboGen2.term,bus2. term)
connect(bus2.term,sensor2. term_p)
connect(sensor2.term_n,line2. term_n)
connect(line1.term_n,sensorLoad. term_p)
connect(line2.term_p,sensorLoad. term_p)
connect(setpts3.setpts,turboGen3. setpts)
connect(turboGen3.term, sensor3.term_p)
connect(sensor3.term_n, line3.term_n)
connect(turboGen1.heat, bdCond1.heat)
connect(turboGen2.heat, bdCond2.heat)
connect(turboGen3.heat, bdCond3.heat)
end TieLine;
model WindGeneratorLine "Asynchronous generator"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Generation.WindGenerator windGen(
redeclare model Gear =
PowerSystems.Mechanics.TurboGroups.WindTurbineGear (
redeclare record Data =
PowerSystems.Examples.Data.Turbines.WindTurbineGear),
redeclare model Generator = PowerSystems.AC3ph.Machines.Asynchron (
redeclare record Data =
PowerSystems.Examples.Data.Machines.Asynchron400V_30kVA))
PowerSystems.AC3ph.Nodes.BusBar busbar
PowerSystems.AC3ph.Sensors.Psensor sensor
PowerSystems.AC3ph.Lines.RXline line(redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=400,
S_nom=30e3,
r=0.05), len=1.5e3,
dynType=PowerSystems.Types.Dynamics.FreeInitial)
PowerSystems.AC3ph.Sources.InfBus infBus(V_nom=400)
PowerSystems.Blocks.Signals.Transient trsSignal1(
t_change=25,
t_duration=50,
s_start=5,
s_end=15)
PowerSystems.AC3ph.Nodes.GroundOne grd
PowerSystems.Common.Thermal.BdCondV bdCond(m=2)
equation
connect(windGen.term, busbar.term)
connect(busbar.term, sensor.term_p)
connect(sensor.term_n, line.term_p)
connect(line.term_n, infBus.term)
connect(infBus.neutral, grd.term)
connect(windGen.heat, bdCond.heat)
connect(trsSignal1.y, windGen.windSpeed)
end WindGeneratorLine;
model Islanding "AC synchronous generator in islanding configuration"
extends Modelica.Icons.Example;
inner PowerSystems.System system
parameter SI.Voltage vAC_nom=560 "AC nominal voltage";
parameter SI.Voltage vDC_nom=750 "DC nominal voltage";
PowerSystems.Control.Setpoints.Set_w_p setpts
PowerSystems.AC3ph.Generation.TurboPMgenerator turboGen(
redeclare model Governor = PowerSystems.Control.Governors.Governor1st
"1st order",
redeclare model Generator = PowerSystems.AC3ph.Machines.Synchron_pm (
redeclare record Data =
PowerSystems.Examples.Data.Machines.Synchron_pm560V_100kVA)
"nth order")
PowerSystems.AC3ph.Nodes.DefReference reference
PowerSystems.AC3ph.Sensors.Psensor ACpower
PowerSystems.AC3ph.Inverters.RectifierAverage rectifier(redeclare record Data =
PowerSystems.Examples.Data.Semiconductors.IdealSC1kV_100A)
PowerSystems.AC1ph_DC.Impedances.CapacitorSym capSym(
G=1e-4,
C=0.020,
V_start=vDC_nom)
PowerSystems.AC3ph.Nodes.GroundOne grd
PowerSystems.AC1ph_DC.Sensors.VdiffSensor DCvoltage
PowerSystems.AC1ph_DC.Sensors.Psensor DCpower
PowerSystems.AC1ph_DC.Loads.ZloadDC zLoadDC(S_nom=100e3,
use_p_in=true,
V_nom=vDC_nom)
PowerSystems.Blocks.Signals.Transient transSig(
t_duration=2.5,
s_start=1,
s_end=0.7,
t_change=10)
Modelica.Blocks.Continuous.LimPID limPID_DC(
yMin=0,
yMax=2,
xi_start=1,
Td=0.1,
Ti=0.5,
k=1/vDC_nom,
initType=Modelica.Blocks.Types.Init.SteadyState)
Modelica.Blocks.Sources.Constant set_vDC(k=vDC_nom)
PowerSystems.Common.Thermal.BdCondV bdCond1(m=2)
PowerSystems.Common.Thermal.BdCondV bdCond2(m=1)
equation
connect(ACpower.term_n, rectifier.AC)
connect(capSym.term_n, DCpower.term_p)
connect(DCpower.term_n, zLoadDC.term)
connect(setpts.setpts, turboGen.setpts)
connect(set_vDC.y, limPID_DC.u_s)
connect(limPID_DC.y, setpts.setpt_p)
connect(capSym.term_p, DCvoltage.term)
connect(rectifier.DC, capSym.term_p)
connect(turboGen.heat, bdCond1.heat)
connect(rectifier.heat, bdCond2.heat)
connect(transSig.y, zLoadDC.p_in)
connect(capSym.neutral, grd.term)
connect(DCvoltage.v, limPID_DC.u_m)
connect(turboGen.term, reference.term)
connect(reference.term, ACpower.term_p)
connect(turboGen.phiRotor, reference.theta)
end Islanding;
model LocalGeneration
"AC torque controlled synchronous machine as local generator"
extends Modelica.Icons.Example;
inner PowerSystems.System system(f_nom=60)
parameter SI.Voltage vDC_nom=780 "DC nominal voltage";
final parameter SI.Current I_nom=PMgen.generator.par.S_nom/PMgen.generator.par.V_nom
"generator nominal current";
PowerSystems.Blocks.Signals.Transient speedSignal(
t_duration=5,
t_change=20,
s_start=2*pi*180,
s_end=2*pi*150)
PowerSystems.Mechanics.Rotational.Speed speed(use_w_in=true, w0=2*pi*180)
PowerSystems.AC3ph.Generation.PMgenerator PMgen(
redeclare model Generator =
PowerSystems.AC3ph.Machines.Synchron3rd_pm_ctrl (
redeclare record Data =
PowerSystems.Examples.Data.Machines.Synchron3rd_pm560V_100kVA (
neu_iso=true)),
redeclare model Inverter = PowerSystems.AC3ph.Inverters.InverterAverage (
redeclare record Data =
PowerSystems.Examples.Data.Semiconductors.IdealSC1kV_100A(Vf=0)),
w_start=1130.9733552923)
PowerSystems.AC1ph_DC.Impedances.CapacitorSym capSym(
G=1e-4,
V_start=vDC_nom,
C=0.020)
PowerSystems.AC3ph.Nodes.GroundOne grd
PowerSystems.AC1ph_DC.Sensors.VdiffSensor DCvoltage
PowerSystems.AC1ph_DC.Sensors.Psensor DCpower
PowerSystems.AC1ph_DC.Loads.ZloadDC zLoadDC(
use_p_in=true,
V_nom=vDC_nom,
S_nom=100e3)
PowerSystems.Blocks.Signals.Transient transSig(
t_duration=2.5,
t_change=10,
s_start=0.5,
s_end=0.9)
PowerSystems.Common.Thermal.BdCondV bdCond(m=3)
PowerSystems.Blocks.Signals.Transient i_d(
t_duration=5,
s_end=0,
t_change=20,
s_start=-0.1)
Modelica.Blocks.Sources.Constant vDC_set(k=vDC_nom)
Modelica.Blocks.Continuous.LimPID PI_vDC(
Td=0.05,
controllerType=Modelica.Blocks.Types.SimpleController.PI,
initType=Modelica.Blocks.Types.Init.SteadyState,
Ti=0.1,
k=0.3*I_nom/vDC_nom,
yMax=1.4*I_nom)
Modelica.Blocks.Math.Gain gain(k=-1) "generator: negative torque tau_act"
equation
connect(PMgen.heat, bdCond.heat)
connect(PMgen.term, capSym.term_p)
connect(DCpower.term_n, zLoadDC.term)
connect(capSym.term_p, DCvoltage.term)
connect(transSig.y, zLoadDC.p_in)
connect(DCvoltage.v, PI_vDC.u_m)
connect(vDC_set.y, PI_vDC.u_s)
connect(PI_vDC.y, gain.u)
connect(gain.y, PMgen.i_act[2])
connect(speed.flange, PMgen.flange)
connect(capSym.term_n, DCpower.term_p)
connect(capSym.neutral, grd.term)
connect(speedSignal.y, speed.w_in)
connect(i_d.y, PMgen.i_act[1])
end LocalGeneration;
end Generation; |
Inverters dq0 | within PowerSystems.Examples.AC3ph;
package Inverters "Inverters dq0"
extends Modelica.Icons.ExamplesPackage;
model Rectifier "Rectifier"
extends Modelica.Icons.Example;
inner PowerSystems.System system(dynType=PowerSystems.Types.Dynamics.FixedInitial,
refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.Blocks.Signals.TransientPhasor transPh(
t_change=0.1,
t_duration=0.1,
a_start=2,
a_end=1)
PowerSystems.AC3ph.Sources.Voltage vAC(use_vPhasor_in=true, V_nom=100)
PowerSystems.AC3ph.Impedances.Inductor ind(r=0.05,
V_nom=100,
S_nom=1e3)
PowerSystems.AC3ph.Sensors.PVImeter meterAC(abc=true,
av=true,
tcst=0.1,
V_nom=100,
S_nom=1e3)
PowerSystems.AC3ph.Inverters.Rectifier rectifier(redeclare model Rectifier =
PowerSystems.AC3ph.Inverters.Components.RectifierEquation(redeclare
record Data =
PowerSystems.Examples.Data.Semiconductors.IdealSC100V_10A))
PowerSystems.AC1ph_DC.Sensors.PVImeter meterDC(av=true, tcst=0.1,
V_nom=100,
S_nom=1e3)
PowerSystems.AC1ph_DC.Sources.DCvoltage vDC(pol=0, V_nom=100)
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd2
PowerSystems.Common.Thermal.BdCondV bdCond(m=3)
equation
connect(vAC.term, ind.term_p)
connect(ind.term_n, meterAC.term_p)
connect(meterAC.term_n, rectifier.AC)
connect(rectifier.DC, meterDC.term_p)
connect(meterDC.term_n, vDC.term)
connect(transPh.y, vAC.vPhasor_in)
connect(grd1.term, vAC.neutral)
connect(vDC.neutral, grd2.term)
connect(rectifier.heat, bdCond.heat)
end Rectifier;
model InverterToLoad "Inverter to load"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Inertial)
PowerSystems.AC3ph.Nodes.GroundOne grd
PowerSystems.AC1ph_DC.Sources.DCvoltage vDC(pol=0, V_nom=100)
PowerSystems.AC1ph_DC.Sensors.PVImeter meterDC(av=true, tcst=0.1,
V_nom=100,
S_nom=1e3)
PowerSystems.AC3ph.Inverters.Inverter inverter(redeclare model Inverter =
PowerSystems.AC3ph.Inverters.Components.InverterEquation(redeclare
record Data =
PowerSystems.Examples.Data.Semiconductors.IdealSC100V_10A)
"equation, with losses")
PowerSystems.AC3ph.Inverters.Select select(
fType=PowerSystems.Types.SourceFrequency.Parameter,
f=100,
use_vPhasor_in=true)
PowerSystems.AC3ph.Sensors.PVImeter meterAC(
abc=true,
av=true,
tcst=0.1,
V_nom=100,
S_nom=1e3)
PowerSystems.Blocks.Signals.TransientPhasor vCtrl(
t_change=0.05,
t_duration=0.05,
a_start=0)
PowerSystems.AC3ph.Loads.PQindLoad pqLoad(
tcst=0.01, imax=1,
V_nom=100,
S_nom=1e3)
PowerSystems.Common.Thermal.BdCondV bdCond(m=3)
equation
connect(vDC.term, meterDC.term_p)
connect(meterDC.term_n, inverter.DC)
connect(inverter.AC, meterAC.term_p)
connect(select.theta_out, inverter.theta)
connect(select.vPhasor_out,inverter.vPhasor)
connect(vCtrl.y,select.vPhasor_in)
connect(meterAC.term_n, pqLoad.term)
connect(grd.term, vDC.neutral)
connect(inverter.heat, bdCond.heat)
end InverterToLoad;
model InverterToGrid "Inverter to grid"
extends Modelica.Icons.Example;
inner PowerSystems.System system(refType=PowerSystems.Types.ReferenceFrame.Synchron)
PowerSystems.AC1ph_DC.Sources.DCvoltage vDC(pol=0,
V_nom=100,
v0=2)
PowerSystems.AC1ph_DC.Sensors.PVImeter meterDC(tcst=0.1,
V_nom=100,
S_nom=1e3,
av=true)
PowerSystems.AC3ph.Inverters.Inverter inverter(redeclare model Inverter =
PowerSystems.AC3ph.Inverters.Components.InverterEquation(redeclare
record Data =
PowerSystems.Examples.Data.Semiconductors.IdealSC100V_10A)
"equation, with losses")
PowerSystems.AC3ph.Inverters.Select select(use_vPhasor_in=true)
PowerSystems.AC3ph.Sensors.PVImeter meterAC(
V_nom=100,
S_nom=1e3,
av=true,
tcst=0.1,
abc=true)
PowerSystems.AC3ph.Impedances.Inductor ind(r=0.05,
V_nom=100,
S_nom=1e3)
PowerSystems.AC3ph.Sources.Voltage vAC(V_nom=100)
PowerSystems.Blocks.Signals.TransientPhasor vCtrl(
t_change=0.1,
t_duration=0.1,
ph_end=0.5235987755983)
PowerSystems.AC3ph.Nodes.GroundOne grd
PowerSystems.Common.Thermal.BdCondV bdCond(m=3)
equation
connect(vAC.term, ind.term_p)
connect(vDC.term, meterDC.term_p)
connect(meterDC.term_n, inverter.DC)
connect(inverter.AC, meterAC.term_p)
connect(meterAC.term_n, ind.term_n)
connect(select.theta_out, inverter.theta)
connect(select.vPhasor_out,inverter.vPhasor)
connect(vCtrl.y,select.vPhasor_in)
connect(vAC.neutral, grd.term)
connect(inverter.heat, bdCond.heat)
end InverterToGrid;
model InverterAvToGrid "Inverter to grid"
extends Modelica.Icons.Example;
inner PowerSystems.System system(dynType=PowerSystems.Types.Dynamics.FixedInitial)
PowerSystems.AC1ph_DC.Sources.DCvoltage vDC(pol=0,
V_nom=100,
v0=2)
PowerSystems.AC1ph_DC.Sensors.PVImeter meterDC(av=true, tcst=0.1,
V_nom=100,
S_nom=1e3)
PowerSystems.AC3ph.Inverters.InverterAverage inverter(redeclare record Data =
PowerSystems.Examples.Data.Semiconductors.IdealSC100V_10A)
PowerSystems.AC3ph.Inverters.Select select(use_vPhasor_in=true)
PowerSystems.AC3ph.Sensors.PVImeter meterAC(
abc=true,
av=true,
tcst=0.1,
V_nom=100,
S_nom=1e3)
PowerSystems.AC3ph.Impedances.Inductor ind(r=0.05,
V_nom=100,
S_nom=1e3)
PowerSystems.AC3ph.Sources.Voltage vAC(V_nom=100)
PowerSystems.Blocks.Signals.TransientPhasor vCtrl(
t_change=0.1,
t_duration=0.1,
ph_end=0.5235987755983)
PowerSystems.AC3ph.Nodes.GroundOne grd
PowerSystems.Common.Thermal.BdCondV bdCond(m=1)
equation
connect(vAC.term, ind.term_p)
connect(vDC.term, meterDC.term_p)
connect(meterDC.term_n, inverter.DC)
connect(inverter.AC, meterAC.term_p)
connect(meterAC.term_n, ind.term_n)
connect(select.theta_out, inverter.theta)
connect(select.vPhasor_out,inverter.vPhasor)
connect(vCtrl.y,select.vPhasor_in)
connect(vAC.neutral, grd.term)
connect(inverter.heat, bdCond.heat)
end InverterAvToGrid;
end Inverters; |
Examples for AC3ph components | within PowerSystems.Examples;
package AC3ph "Examples for AC3ph components"
extends Modelica.Icons.ExamplesPackage;
end AC3ph; |
Precalculation of machine matrices | within PowerSystems.Examples.AC3ph;
package Precalculation "Precalculation of machine matrices"
extends Modelica.Icons.ExamplesPackage;
model Z_matrixTrDat0 "z-matrix from transient data, n=1, 0"
extends Modelica.Icons.Example;
parameter SI.AngularFrequency omega_nom=2*pi*60 "nom ang frequency";
parameter Boolean use_xtr=true "use t_closed and x_transient?"
parameter SI.Time[:] tc_d={0.684058354104098}
"time constant closed-loop d-axis {tc_d', tc_d'', ..}"
parameter SI.Time[:] tc_q=fill(0,0)
"time constant closed-loop q-axis {tc_q', tc_q'', ..}"
parameter SI.Time[:] to_d={4.17178865983301}
"time constant open-loop d-axis {to_d', to_d'', ..}"
parameter SI.Time[:] to_q=fill(0,0)
"time constant open-loop q-axis {to_q', to_q'', ..}"
parameter SIpu.Reactance[n_d] xtr_d={0.290231213872833}
"trans reactance d-axis {xtr_d', xtr_d'', ..}"
parameter SIpu.Reactance[n_q] xtr_q=fill(0,0)
"trans reactance q-axis {xtr_q', xtr_q'', ..}"
parameter SIpu.Reactance x_d=1.77 "syn reactance d-axis";
parameter SIpu.Reactance x_q=1.77 "syn reactance q-axis";
parameter SIpu.Reactance xsig_s=0.17 "leakage reactance stator";
parameter SIpu.Resistance r_s=0.005 "resistance stator";
parameter SIpu.Current if0=0 "induced field current at v_s=V_nom/0deg"
parameter SI.Angle alpha_if0=0
"angle(if0) at v_s=Vnom/0deg (sign: i_f behind v_s)"
Real[n_d+1] zr_d;
Real[n_d+1, n_d+1] zx_d;
Real[n_q+1] zr_q;
Real[n_q+1, n_q+1] zx_q;
protected
final parameter Boolean use_trans=true;
final parameter Integer n_d=size(tc_d,1);
final parameter Integer n_q=size(tc_q,1);
function T_open = PowerSystems.Utilities.Precalculation.T_open;
function z_matrix = PowerSystems.Utilities.Precalculation.z_fromTransDat;
algorithm
(zr_d, zx_d) := z_matrix(n_d, omega_nom*tc_d, T_open(x_d, xtr_d, omega_nom*tc_d), x_d, xsig_s, r_s, if0, alpha_if0+pi, 0, true);
(zr_q, zx_q) := z_matrix(n_q, omega_nom*tc_q, T_open(x_q, xtr_q, omega_nom*tc_q), x_q, xsig_s, r_s, 0, 0, 0, false);
end Z_matrixTrDat0;
model Z_matrixTrDat1 "z-matrix from transient data, n=1"
extends Modelica.Icons.Example;
parameter SI.AngularFrequency omega_nom=2*pi*60 "nom ang frequency";
parameter Boolean use_xtr=true "use t_closed and x_transient?"
parameter SI.Time[:] tc_d={0.684058354104098}
"time constant closed-loop d-axis {tc_d', tc_d'', ..}"
parameter SI.Time[:] tc_q={0.684058354104098}
"time constant closed-loop q-axis {tc_q', tc_q'', ..}"
parameter SI.Time[:] to_d={4.17178865983301}
"time constant open-loop d-axis {to_d', to_d'', ..}"
parameter SI.Time[:] to_q={4.17178865983301}
"time constant open-loop q-axis {to_q', to_q'', ..}"
parameter SIpu.Reactance[n_d] xtr_d={0.290231213872833}
"trans reactance d-axis {xtr_d', xtr_d'', ..}"
parameter SIpu.Reactance[n_q] xtr_q={0.290231213872833}
"trans reactance q-axis {xtr_q', xtr_q'', ..}"
parameter SIpu.Reactance x_d=1.77 "syn reactance d-axis";
parameter SIpu.Reactance x_q=1.77 "syn reactance q-axis";
parameter SIpu.Reactance xsig_s=0.17 "leakage reactance stator";
parameter SIpu.Resistance r_s=0.005 "resistance stator";
parameter SIpu.Current if0=0 "induced field current at v_s=V_nom/0deg"
parameter SI.Angle alpha_if0=0
"angle(if0) at v_s=Vnom/0deg (sign: i_f behind v_s)"
Real[n_d+1] zr_d;
Real[n_d+1, n_d+1] zx_d;
Real[n_q+1] zr_q;
Real[n_q+1, n_q+1] zx_q;
protected
final parameter Boolean use_trans=true;
final parameter Integer n_d=size(tc_d,1);
final parameter Integer n_q=size(tc_q,1);
function T_open = PowerSystems.Utilities.Precalculation.T_open;
function z_matrix = PowerSystems.Utilities.Precalculation.z_fromTransDat;
algorithm
(zr_d, zx_d) := z_matrix(n_d, omega_nom*tc_d, T_open(x_d, xtr_d, omega_nom*tc_d), x_d, xsig_s, r_s, if0, alpha_if0+pi, 0, true);
(zr_q, zx_q) := z_matrix(n_q, omega_nom*tc_q, T_open(x_q, xtr_q, omega_nom*tc_q), x_q, xsig_s, r_s, 0, 0, 0, false);
end Z_matrixTrDat1;
model Z_matrixTrDat2 "z-matrix from transient data, n=2"
extends Modelica.Icons.Example;
parameter SI.AngularFrequency omega_nom=2*pi*60 "nom ang frequency";
parameter Boolean use_xtr=true "use t_closed and x_transient?"
parameter SI.Time[:] tc_d={0.859012450972537, 0.024700865536969}
"time constant closed-loop d-axis {tc_d', tc_d'', ..}"
parameter SI.Time[:] tc_q={0.703091060761508, 0.0226730319219496}
"time constant closed-loop q-axis {tc_q', tc_q'', ..}"
parameter SI.Time[:] to_d={4.65929627144818, 0.03185596214872}
"time constant open-loop d-axis {to_d', to_d'', ..}"
parameter SI.Time[:] to_q={4.5014019794843, 0.0318010302865584}
"time constant open-loop q-axis {to_q', to_q'', ..}"
parameter SIpu.Reactance[n_d] xtr_d={0.32862524982383, 0.253031064823128}
"trans reactance d-axis {xtr_d', xtr_d'', ..}"
parameter SIpu.Reactance[n_q] xtr_q={0.27962838258275, 0.197108545894619}
"trans reactance q-axis {xtr_q', xtr_q'', ..}"
parameter SIpu.Reactance x_d=1.77 "syn reactance d-axis";
parameter SIpu.Reactance x_q=1.77 "syn reactance q-axis";
parameter SIpu.Reactance xsig_s=0.17 "leakage reactance stator";
parameter SIpu.Resistance r_s=0.005 "resistance stator";
parameter SIpu.Current if0=0.834830547142614
"induced field current at v_s=V_nom/0deg"
parameter SI.Angle alpha_if0=-1.7713318143478
"angle(if0) at v_s=Vnom/0deg (sign: i_f behind v_s)"
parameter Real tol=1e-6 "tolerance precalculation"
Real[n_d+1] zr_d;
Real[n_d+1, n_d+1] zx_d;
Real[n_q+1] zr_q;
Real[n_q+1, n_q+1] zx_q;
protected
final parameter Boolean use_trans=true;
final parameter Integer n_d=size(tc_d,1);
final parameter Integer n_q=size(tc_q,1);
function T_open = PowerSystems.Utilities.Precalculation.T_open;
function z_matrix = PowerSystems.Utilities.Precalculation.z_fromTransDat;
algorithm
(zr_d, zx_d) := z_matrix(n_d, omega_nom*tc_d, T_open(x_d, xtr_d, omega_nom*tc_d), x_d, xsig_s, r_s, if0, alpha_if0+pi, tol, true);
(zr_q, zx_q) := z_matrix(n_q, omega_nom*tc_q, T_open(x_q, xtr_q, omega_nom*tc_q), x_q, xsig_s, r_s, 0, 0, 0, false);
end Z_matrixTrDat2;
model Z_matrixTrDat3 "z-matrix from transient data, n=3"
extends Modelica.Icons.Example;
parameter SI.AngularFrequency omega_nom=2*pi*60 "nom ang frequency";
parameter Boolean use_xtr=true "use t_closed and x_transient?"
parameter SI.Time[:] tc_d={0.869154751730285, 0.028837675377106, 0.00293370131083294}
"time constant closed-loop d-axis {tc_d', tc_d'', ..}"
parameter SI.Time[:] tc_q={0.710852334653427, 0.0267828156988275, 0.00180497772676905}
"time constant closed-loop q-axis {tc_q', tc_q'', ..}"
parameter SI.Time[:] to_d={4.79391852025869, 0.0390156982688014, 0.00331427152151774}
"time constant open-loop d-axis {to_d', to_d'', ..}"
parameter SI.Time[:] to_q={4.63399482930977, 0.0387883296526998, 0.00197933074735668}
"time constant open-loop q-axis {to_q', to_q'', ..}"
parameter SIpu.Reactance[n_d] xtr_d={0.324237799805601, 0.238193407852477, 0.209956053815068}
"trans reactance d-axis {xtr_d', xtr_d'', ..}"
parameter SIpu.Reactance[n_q] xtr_q={0.275669319075036, 0.187924853846143, 0.170964423631031}
"trans reactance q-axis {xtr_q', xtr_q'', ..}"
parameter SIpu.Reactance x_d=1.77 "syn reactance d-axis";
parameter SIpu.Reactance x_q=1.77 "syn reactance q-axis";
parameter SIpu.Reactance xsig_s=0.17 "leakage reactance stator";
parameter SIpu.Resistance r_s=0.005 "resistance stator";
parameter SIpu.Current if0=0.47426409312074
"induced field current at v_s=V_nom/0deg"
parameter SI.Angle alpha_if0=-2.5862242826262
"angle(if0) at v_s=Vnom/0deg (sign: i_f behind v_s)"
parameter Real tol=1e-6 "tolerance precalculation"
Real[n_d + 1] zr_d;
Real[n_d + 1, n_d + 1] zx_d;
Real[n_q + 1] zr_q;
Real[n_q + 1, n_q + 1] zx_q;
protected
final parameter Boolean use_trans=true;
final parameter Integer n_d=size(tc_d,1);
final parameter Integer n_q=size(tc_q,1);
function T_open = PowerSystems.Utilities.Precalculation.T_open;
function z_matrix = PowerSystems.Utilities.Precalculation.z_fromTransDat;
algorithm
(zr_d, zx_d) := z_matrix(n_d, omega_nom*tc_d, T_open(x_d, xtr_d, omega_nom*tc_d), x_d, xsig_s, r_s, if0, alpha_if0+pi, tol, true);
(zr_q, zx_q) := z_matrix(n_q, omega_nom*tc_q, T_open(x_q, xtr_q, omega_nom*tc_q), x_q, xsig_s, r_s, 0, 0, 0, false);
end Z_matrixTrDat3;
model Z_matrixEqCirc0 "z-matrix from equivalent circuit, n=1, 0"
extends Modelica.Icons.Example;
parameter SI.AngularFrequency omega_nom=2*pi*60 "nom ang frequency";
parameter SIpu.Reactance x_d=1.77 "syn reactance d-axis";
parameter SIpu.Reactance x_q=1.77 "syn reactance q-axis";
parameter SIpu.Reactance xsig_s=0.17 "leakage reactance stator";
parameter SIpu.Resistance r_s=0.005 "resistance stator";
parameter SIpu.Reactance[:] xsig_rd={0.13}
"leakage reactance rotor d-axis {f}"
parameter SIpu.Reactance[:] xsig_rq=fill(0,0)
"leakage reactance rotor q-axis{Q}"
parameter SIpu.Reactance[size(xsig_rd,1)-1] xm_d=fill(0,0)
"coupling-reactance d-axis"
parameter SIpu.Resistance[size(xsig_rd,1)] r_rd={0.0011}
"resistance rotor d-axis{f}"
parameter SIpu.Resistance[size(xsig_rq,1)] r_rq=fill(0,0)
"resistance rotor q-axis{Q}"
Real[n_d+1] zr_d;
Real[n_d+1, n_d+1] zx_d;
Real[n_q+1] zr_q;
Real[n_q+1, n_q+1] zx_q;
protected
final parameter Boolean use_trans=false;
final parameter Integer n_d=size(xsig_rd,1);
final parameter Integer n_q=size(xsig_rq,1);
function z_matrix = PowerSystems.Utilities.Precalculation.z_fromEqCirc;
algorithm
(zr_d, zx_d) := z_matrix(n_d, x_d, xsig_s, r_s, xm_d, xsig_rd, r_rd);
(zr_q, zx_q) := z_matrix(n_q, x_q, xsig_s, r_s, zeros(n_q-1), xsig_rq, r_rq);
end Z_matrixEqCirc0;
model Z_matrixEqCirc1 "z-matrix from equivalent circuit, n=1"
extends Modelica.Icons.Example;
parameter SI.AngularFrequency omega_nom=2*pi*60 "nom ang frequency";
parameter SIpu.Reactance x_d=1.77 "syn reactance d-axis";
parameter SIpu.Reactance x_q=1.77 "syn reactance q-axis";
parameter SIpu.Reactance xsig_s=0.17 "leakage reactance stator";
parameter SIpu.Resistance r_s=0.005 "resistance stator";
parameter SIpu.Reactance[:] xsig_rd={0.13}
"leakage reactance rotor d-axis {f}"
parameter SIpu.Reactance[:] xsig_rq={0.13}
"leakage reactance rotor q-axis{Q}"
parameter SIpu.Reactance[size(xsig_rd,1)-1] xm_d=fill(0,0)
"coupling-reactance d-axis"
parameter SIpu.Resistance[size(xsig_rd,1)] r_rd={0.0011}
"resistance rotor d-axis{f}"
parameter SIpu.Resistance[size(xsig_rq,1)] r_rq={0.0011}
"resistance rotor q-axis{Q}"
Real[n_d+1] zr_d;
Real[n_d+1, n_d+1] zx_d;
Real[n_q+1] zr_q;
Real[n_q+1, n_q+1] zx_q;
protected
final parameter Boolean use_trans=false;
final parameter Integer n_d=size(xsig_rd,1);
final parameter Integer n_q=size(xsig_rq,1);
function z_matrix = PowerSystems.Utilities.Precalculation.z_fromEqCirc;
algorithm
(zr_d, zx_d) := z_matrix(n_d, x_d, xsig_s, r_s, xm_d, xsig_rd, r_rd);
(zr_q, zx_q) := z_matrix(n_q, x_q, xsig_s, r_s, zeros(n_q-1), xsig_rq, r_rq);
end Z_matrixEqCirc1;
model Z_matrixEqCirc2 "z-matrix from equivalent circuit, n=2"
extends Modelica.Icons.Example;
parameter SI.AngularFrequency omega_nom=2*pi*60 "nom ang frequency";
parameter SIpu.Reactance x_d=1.77 "syn reactance d-axis";
parameter SIpu.Reactance x_q=1.77 "syn reactance q-axis";
parameter SIpu.Reactance xsig_s=0.17 "leakage reactance stator";
parameter SIpu.Resistance r_s=0.005 "resistance stator";
parameter SIpu.Reactance[:] xsig_rd={0.13, 0.035}
"leakage reactance rotor d-axis {f, D}"
parameter SIpu.Reactance[:] xsig_rq={0.13, 0.035}
"leakage reactance rotor q-axis{Q1, Q2}"
parameter SIpu.Reactance[size(xsig_rd,1)-1] xm_d={0.06}
"coupling-reactance d-axis"
parameter SIpu.Resistance[size(xsig_rd,1)] r_rd={0.0011, 0.012}
"resistance rotor d-axis{f, D}"
parameter SIpu.Resistance[size(xsig_rq,1)] r_rq={0.0011, 0.012}
"resistance rotor q-axis{Q1, Q2}"
Real[n_d+1] zr_d;
Real[n_d+1, n_d+1] zx_d;
Real[n_q+1] zr_q;
Real[n_q+1, n_q+1] zx_q;
protected
final parameter Boolean use_trans=false;
final parameter Integer n_d=size(xsig_rd,1);
final parameter Integer n_q=size(xsig_rq,1);
function z_matrix = PowerSystems.Utilities.Precalculation.z_fromEqCirc;
algorithm
(zr_d, zx_d) := z_matrix(n_d, x_d, xsig_s, r_s, xm_d, xsig_rd, r_rd);
(zr_q, zx_q) := z_matrix(n_q, x_q, xsig_s, r_s, zeros(n_q-1), xsig_rq, r_rq);
end Z_matrixEqCirc2;
model Z_matrixEqCirc3 "z-matrix from equivalent circuit, n=3"
extends Modelica.Icons.Example;
parameter SI.AngularFrequency omega_nom=2*pi*60 "nom ang frequency";
parameter SIpu.Reactance x_d=1.77 "syn reactance d-axis";
parameter SIpu.Reactance x_q=1.77 "syn reactance q-axis";
parameter SIpu.Reactance xsig_s=0.17 "leakage reactance stator";
parameter SIpu.Resistance r_s=0.005 "resistance stator";
parameter SIpu.Reactance[:] xsig_rd={0.13, 0.035, 0.001}
"leakage reactance rotor d-axis {f, D1, D2}"
parameter SIpu.Reactance[:] xsig_rq={0.13, 0.035, 0.001}
"leakage reactance rotor q-axis{Q1, Q2, Q3}"
parameter SIpu.Reactance[size(xsig_rd,1)-1] xm_d={0.02, 0.04}
"coupling-reactance d-axis"
parameter SIpu.Resistance[size(xsig_rd,1)] r_rd={0.0011, 0.012, 0.03}
"resistance rotor d-axis{f, D1, D2}"
parameter SIpu.Resistance[size(xsig_rq,1)] r_rq={0.0011, 0.012, 0.03}
"resistance rotor q-axis{Q1, Q2, Q3}"
Real[n_d+1] zr_d;
Real[n_d+1, n_d+1] zx_d;
Real[n_q+1] zr_q;
Real[n_q+1, n_q+1] zx_q;
protected
final parameter Boolean use_trans=false;
final parameter Integer n_d=size(xsig_rd,1);
final parameter Integer n_q=size(xsig_rq,1);
function z_matrix = PowerSystems.Utilities.Precalculation.z_fromEqCirc;
algorithm
(zr_d, zx_d) := z_matrix(n_d, x_d, xsig_s, r_s, xm_d, xsig_rd, r_rd);
(zr_q, zx_q) := z_matrix(n_q, x_q, xsig_s, r_s, zeros(n_q-1), xsig_rq, r_rq);
end Z_matrixEqCirc3;
model TransDatFromEqCirc "Calculates transient data from equivalent circuit"
extends Modelica.Icons.Example;
parameter SI.AngularFrequency omega_nom=2*pi*60 "nom ang frequency";
parameter SIpu.Reactance x_d=1.77 "syn reactance d-axis";
parameter SIpu.Reactance x_q=1.77 "syn reactance q-axis";
parameter SIpu.Reactance xsig_s=0.17 "leakage reactance stator";
parameter SIpu.Resistance r_s=0.005 "resistance stator";
parameter SIpu.Reactance[:] xsig_rd={0.13, 0.035}
"leakage reactance rotor d-axis {f, D}"
parameter SIpu.Reactance[:] xsig_rq={0.13, 0.035}
"leakage reactance rotor q-axis{Q1, Q2}"
parameter SIpu.Reactance[size(xsig_rd,1)-1] xm_d={0.06}
"coupling-reactance d-axis"
parameter SIpu.Resistance[size(xsig_rd,1)] r_rd={0.0011, 0.012}
"resistance rotor d-axis{f, D}"
parameter SIpu.Resistance[size(xsig_rq,1)] r_rq={0.0011, 0.012}
"resistance rotor q-axis{Q1, Q2}"
output SI.Time[n_d] tc_d "time constant closed-loop d-axis";
output SI.Time[n_d] to_d "time constant open-loop d-axis";
output SIpu.Reactance[n_d] xtr_d(each unit="1") "transient reactance d-axis";
output SI.Time[n_q] tc_q "time constant closed-loop q-axis";
output SI.Time[n_q] to_q "time constant open-loop q-axis";
output SIpu.Reactance[n_q] xtr_q(each unit="1") "transient reactance q-axis";
protected
final parameter Boolean use_trans=false;
final parameter Integer n_d=size(xsig_rd,1);
final parameter Integer n_q=size(xsig_rq,1);
function transientData=PowerSystems.Utilities.Precalculation.transientData;
SI.Angle[n_d] Tc_d "Time constant closed-loop d-axis";
SI.Angle[n_d] To_d "Time constant open-loop d-axis";
SI.Angle[n_q] Tc_q "Time constant closed-loop q-axis";
SI.Angle[n_q] To_q "Time constant open-loop q-axis";
algorithm
(Tc_d, To_d, xtr_d) := transientData(n_d, x_d, xsig_s, r_s, xm_d, xsig_rd, r_rd);
tc_d := Tc_d/omega_nom;
to_d := To_d/omega_nom;
(Tc_q, To_q, xtr_q) := transientData(n_q, x_q, xsig_s, r_s, zeros(n_q-1), xsig_rq, r_rq);
tc_q := Tc_q/omega_nom;
to_q := To_q/omega_nom;
end TransDatFromEqCirc;
model EqCircFromTransDat "Calculates equivalent circuit from transient data"
extends Modelica.Icons.Example;
parameter SI.AngularFrequency omega_nom=2*pi*60 "nom ang frequency";
parameter Boolean use_xtr=true "use t_closed and x_transient?"
parameter SI.Time[:] tc_d={0.859012450972537, 0.024700865536969}
"time constant closed-loop d-axis {tc_d', tc_d'', ..}"
parameter SI.Time[:] tc_q={0.703091060761508, 0.0226730319219496}
"time constant closed-loop q-axis {tc_q', tc_q'', ..}"
parameter SI.Time[:] to_d={4.65929627144818, 0.03185596214872}
"time constant open-loop d-axis {to_d', to_d'', ..}"
parameter SI.Time[:] to_q={4.5014019794843, 0.0318010302865584}
"time constant open-loop q-axis {to_q', to_q'', ..}"
parameter SIpu.Reactance[n_d] xtr_d={0.32862524982383, 0.253031064823128}
"trans reactance d-axis {xtr_d', xtr_d'', ..}"
parameter SIpu.Reactance[n_q] xtr_q={0.27962838258275, 0.197108545894619}
"trans reactance q-axis {xtr_q', xtr_q'', ..}"
parameter SIpu.Reactance x_d=1.77 "syn reactance d-axis";
parameter SIpu.Reactance x_q=1.77 "syn reactance q-axis";
parameter SIpu.Reactance xsig_s=0.17 "leakage reactance stator";
parameter SIpu.Resistance r_s=0.005 "resistance stator";
parameter SIpu.Current if0=0.834830547142614
"induced field current at v_s=V_nom/0deg"
parameter SI.Angle alpha_if0=-1.7713318143478
"angle(if0) at v_s=Vnom/0deg (sign: i_f behind v_s)"
parameter Real tol=1e-6 "tolerance precalculation"
output SIpu.Resistance[n_d] r_rd(each unit="1");
output SIpu.Reactance[n_d] xsig_rd(each unit="1");
output SIpu.Reactance[n_d+1] xm_d(each unit="1");
output SIpu.Resistance[n_q] r_rq(each unit="1");
output SIpu.Reactance[n_q] xsig_rq(each unit="1");
output SIpu.Reactance[n_q+1] xm_q(each unit="1");
protected
final parameter Boolean use_trans=true;
final parameter Integer n_d=size(tc_d,1);
final parameter Integer n_q=size(tc_q,1);
function T_open = PowerSystems.Utilities.Precalculation.T_open;
function equiCircuit = PowerSystems.Utilities.Precalculation.equiCircuit;
algorithm
(r_rd, xsig_rd, xm_d) := equiCircuit(n_d, omega_nom*tc_d, T_open(x_d, xtr_d, omega_nom*tc_d), x_d, xsig_s, r_s, if0, alpha_if0+pi, tol, true);
(r_rq, xsig_rq, xm_q) := equiCircuit(n_q, omega_nom*tc_q, T_open(x_q, xtr_q, omega_nom*tc_q), x_q, xsig_s, r_s, 0, 0, 0, false);
end EqCircFromTransDat;
end Precalculation; |
Transformation dq0 | within PowerSystems.Examples.AC3ph;
package Transformation "Transformation dq0"
extends Modelica.Icons.ExamplesPackage;
model PhaseShifts "Phase shift primary-secondary"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Sources.Voltage voltage
PowerSystems.AC3ph.Sensors.PVImeter meter1
PowerSystems.AC3ph.Nodes.BusBar bus
PowerSystems.AC3ph.Transformers.TrafoStray trafo1(
redeclare record Data =
PowerSystems.AC3ph.Transformers.Parameters.TrafoStray(V_nom={1,10}),
redeclare model Topology_p = PowerSystems.AC3ph.Ports.Topology.Y,
redeclare model Topology_n = PowerSystems.AC3ph.Ports.Topology.Y)
PowerSystems.AC3ph.Sensors.PVImeter meter12(V_nom=10)
PowerSystems.AC3ph.ImpedancesYD.Resistor res12(V_nom=10, r=1000)
PowerSystems.AC3ph.Transformers.TrafoStray trafo2(
redeclare model Topology_p = PowerSystems.AC3ph.Ports.Topology.Y,
redeclare model Topology_n = PowerSystems.AC3ph.Ports.Topology.Delta,
redeclare record Data =
PowerSystems.AC3ph.Transformers.Parameters.TrafoStray(V_nom={1,10}))
PowerSystems.AC3ph.Sensors.PVImeter meter22(V_nom=10)
PowerSystems.AC3ph.ImpedancesYD.Resistor res22(V_nom=10, r=1000)
PowerSystems.AC3ph.Nodes.GroundOne grd
PowerSystems.AC3ph.Transformers.TrafoStray trafo3(
redeclare model Topology_p = PowerSystems.AC3ph.Ports.Topology.PAR,
redeclare record Data =
PowerSystems.AC3ph.Transformers.Parameters.TrafoStray (V_nom={1,10},
dv_tap={0.1,0}),
tap_1=-2)
PowerSystems.AC3ph.Sensors.PVImeter meter32(V_nom=10)
PowerSystems.AC3ph.ImpedancesYD.Resistor res32(V_nom=10, r=1000)
equation
connect(voltage.term,meter1. term_p)
connect(meter1.term_n,bus. term)
connect(bus.term, trafo1.term_p)
connect(trafo1.term_n, meter12.term_p)
connect(meter12.term_n, res12.term)
connect(bus.term, trafo2.term_p)
connect(trafo2.term_n, meter22.term_p)
connect(meter22.term_n, res22.term)
connect(grd.term, voltage.neutral)
connect(trafo3.term_n, meter32.term_p)
connect(meter32.term_n, res32.term)
connect(trafo3.term_p, bus.term)
end PhaseShifts;
model TapChanger "Tap changing primary and secondary"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Sources.Voltage voltage
PowerSystems.AC3ph.Sensors.PVImeter meter1
PowerSystems.AC3ph.Nodes.BusBar bus
PowerSystems.AC3ph.Transformers.TrafoStray trafo1(
redeclare record Data =
PowerSystems.AC3ph.Transformers.Parameters.TrafoStray (
V_nom={1,10},
dv_tap={0.1,0.1}),
use_tap_1_in=true,
use_tap_2_in=true)
PowerSystems.AC3ph.Sensors.PVImeter meter12(V_nom=10)
PowerSystems.AC3ph.ImpedancesYD.Resistor res12(V_nom=10, r=1000)
PowerSystems.AC3ph.Transformers.TrafoStray trafo2(
redeclare record Data =
PowerSystems.AC3ph.Transformers.Parameters.TrafoStray (
V_nom={1,10},
dv_tap={0.1,0.1}),
use_tap_1_in=true,
use_tap_2_in=true)
PowerSystems.AC3ph.Sensors.PVImeter meter22(V_nom=10)
PowerSystems.AC3ph.ImpedancesYD.Resistor res22(V_nom=10, r=1000)
PowerSystems.Control.Relays.TapChangerRelay tapRelay2(
preset_1={0,0},
preset_2={0,-1,0,1},
t_switch_2={1,2,3})
PowerSystems.Control.Relays.TapChangerRelay tapRelay1(
preset_1={0,-1,0,1},
preset_2={0,0},
t_switch_1={1,2,3})
PowerSystems.AC3ph.Nodes.GroundOne grd
equation
connect(voltage.term, meter1.term_p)
connect(meter1.term_n, bus.term)
connect(bus.term, trafo1.term_p)
connect(trafo1.term_n, meter12.term_p)
connect(meter12.term_n, res12.term)
connect(bus.term, trafo2.term_p)
connect(trafo2.term_n, meter22.term_p)
connect(meter22.term_n, res22.term)
connect(grd.term, voltage.neutral)
connect(tapRelay1.tap_1, trafo1.tap_1_in)
connect(tapRelay1.tap_2, trafo1.tap_2_in)
connect(tapRelay2.tap_1, trafo2.tap_1_in)
connect(tapRelay2.tap_2, trafo2.tap_2_in)
end TapChanger;
model ThreeWinding "Three winding transformer"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Sources.Voltage voltage
PowerSystems.AC3ph.Sensors.PVImeter meter1
PowerSystems.AC3ph.Nodes.BusBar bus
PowerSystems.AC3ph.Transformers.Trafo3Stray trafo3Stray
PowerSystems.AC3ph.Sensors.PVImeter meter12(V_nom=10)
PowerSystems.AC3ph.ImpedancesYD.Resistor res12(V_nom=10, r=1000)
PowerSystems.AC3ph.Sensors.PVImeter meter22(V_nom=10)
PowerSystems.AC3ph.ImpedancesYD.Resistor res22(V_nom=10, r=1000)
PowerSystems.AC3ph.Nodes.GroundOne grd
equation
connect(voltage.term,meter1. term_p)
connect(meter1.term_n,bus. term)
connect(meter12.term_n, res12.term)
connect(meter22.term_n, res22.term)
connect(bus.term, trafo3Stray.term_p)
connect(trafo3Stray.term_na, meter12.term_p)
connect(trafo3Stray.term_nb, meter22.term_p)
connect(grd.term, voltage.neutral)
end ThreeWinding;
end Transformation; |
AC transmission, dq0 | within PowerSystems.Examples.AC3ph;
package Transmission "AC transmission, dq0"
extends Modelica.Icons.ExamplesPackage;
model PowerTransfer "Power transfer between two nodes"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.Blocks.Signals.TransientPhasor transPh(
t_change=30,
t_duration=60,
ph_end=2*pi,
ph_start=0)
PowerSystems.AC3ph.Sources.InfBus infBus1(V_nom=130e3, use_vPhasor_in=true)
PowerSystems.AC3ph.Lines.RXline line(redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=130e3,
S_nom=100e6),
len=100e3)
PowerSystems.AC3ph.Sensors.Psensor sensor
PowerSystems.AC3ph.Sources.InfBus infBus2(V_nom=130e3)
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd2
equation
connect(transPh.y,infBus1.vPhasor_in)
connect(infBus1.term, sensor.term_p)
connect(sensor.term_n, line.term_p)
connect(line.term_n, infBus2.term)
connect(grd1.term,infBus1. neutral)
connect(grd2.term, infBus2.neutral)
end PowerTransfer;
model VoltageStability "Voltage stability"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Sources.InfBus Vsource0(V_nom=400e3, alpha0=0)
PowerSystems.AC3ph.Sources.InfBus infBus(V_nom=400e3, use_vPhasor_in=true)
PowerSystems.AC3ph.Sensors.Vmeter Vmeter(V_nom=400e3)
PowerSystems.AC3ph.Sensors.PVImeter meter0(S_nom=100e6)
PowerSystems.AC3ph.Lines.RXline line0(redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=400e3,
r=2e-3,
x=0.25e-3), len=500e3)
PowerSystems.AC3ph.Sources.InfBus Vsource1(V_nom=400e3, alpha0=
0.087266462599716)
PowerSystems.AC3ph.Sensors.PVImeter meter1(S_nom=100e6)
PowerSystems.AC3ph.Lines.RXline line1(redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=400e3,
r=2e-3,
x=0.25e-3), len=500e3)
PowerSystems.AC3ph.Sources.InfBus Vsource2(V_nom=400e3, alpha0=-0.087266462599716)
PowerSystems.AC3ph.Sensors.PVImeter meter2(S_nom=100e6)
PowerSystems.AC3ph.Lines.RXline line2(redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=400e3,
r=2e-3,
x=0.25e-3), len=500e3)
PowerSystems.Blocks.Signals.TransientPhasor transPh(
t_change=90,
t_duration=120,
a_start=1,
a_end=0)
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd4
PowerSystems.AC3ph.Nodes.GroundOne grd2
PowerSystems.AC3ph.Nodes.GroundOne grd3
equation
connect(transPh.y, infBus.vPhasor_in)
connect(Vsource0.term, line0.term_p)
connect(line0.term_n, meter0.term_p)
connect(meter0.term_n, infBus.term)
connect(Vsource1.term, line1.term_p)
connect(line1.term_n, meter1.term_p)
connect(meter1.term_n, infBus.term)
connect(Vsource2.term, line2.term_p)
connect(line2.term_n, meter2.term_p)
connect(meter2.term_n, infBus.term)
connect(infBus.term, Vmeter.term)
connect(grd1.term, Vsource0.neutral)
connect(grd2.term, Vsource1.neutral)
connect(grd3.term, Vsource2.neutral)
connect(infBus.neutral, grd4.term)
end VoltageStability;
model RXline "Single lumped line"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Sources.InfBus infBus1(V_nom=400e3,
v0=1.04,
alpha0=0.5235987755983)
PowerSystems.AC3ph.Breakers.Switch switch1(V_nom=400e3, I_nom=2500)
PowerSystems.AC3ph.Lines.RXline line(redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=400e3,
x=0.25e-3,
r=0.02e-3), len=400e3)
PowerSystems.AC3ph.Breakers.Switch switch2(V_nom=400e3, I_nom=2500)
PowerSystems.AC3ph.Sources.InfBus infBus2(V_nom=400e3)
PowerSystems.Control.Relays.SwitchRelay relay1(
t_switch={0.2,0.65})
PowerSystems.Control.Relays.SwitchRelay relay2(
t_switch={0.3,0.7})
PowerSystems.AC3ph.Sensors.PVImeter meter(V_nom=400e3, S_nom=1000e6)
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd2
equation
connect(relay1.y, switch1.control)
connect(relay2.y, switch2.control)
connect(infBus1.term, meter.term_p)
connect(meter.term_n, switch1.term_p)
connect(switch1.term_n, line.term_p)
connect(line.term_n, switch2.term_p)
connect(switch2.term_n, infBus2.term)
connect(grd1.term,infBus1. neutral)
connect(infBus2.neutral, grd2.term)
end RXline;
model Tline "Single PI-line"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Sources.InfBus infBus1(V_nom=400e3,
v0=1.04,
alpha0=0.5235987755983)
PowerSystems.AC3ph.Breakers.Breaker breaker1(V_nom=400e3, I_nom=2500)
PowerSystems.AC3ph.Lines.Tline line(len=400e3, redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.Line (
V_nom=400e3,
x=0.25e-3,
r=0.02e-3))
PowerSystems.AC3ph.Breakers.Breaker breaker2(V_nom=400e3, I_nom=2500)
PowerSystems.AC3ph.Sources.InfBus infBus2(V_nom=400e3)
PowerSystems.Control.Relays.SwitchRelay relay1(
t_switch={0.2,0.65})
PowerSystems.Control.Relays.SwitchRelay relay2(
t_switch={0.3,0.7})
PowerSystems.AC3ph.Sensors.PVImeter meter(V_nom=400e3, S_nom=1000e6)
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd2
equation
connect(relay1.y, breaker1.control)
connect(relay2.y, breaker2.control)
connect(infBus1.term, meter.term_p)
connect(meter.term_n, breaker1.term_p)
connect(breaker1.term_n, line.term_p)
connect(line.term_n, breaker2.term_p)
connect(breaker2.term_n, infBus2.term)
connect(grd1.term,infBus1. neutral)
connect(infBus2.neutral, grd2.term)
end Tline;
model FaultRXline "Faulted lumped line"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Sources.InfBus infBus1(V_nom=400e3,
v0=1.04,
alpha0=0.5235987755983)
PowerSystems.AC3ph.Breakers.Switch switch1(V_nom=400e3, I_nom=2500)
PowerSystems.AC3ph.Lines.FaultRXline line(redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.RXline (
V_nom=400e3,
x=0.25e-3,
r=0.02e-3), len=400e3)
PowerSystems.AC3ph.Breakers.Switch switch2(V_nom=400e3, I_nom=2500)
PowerSystems.AC3ph.Sources.InfBus infBus2(V_nom=400e3)
PowerSystems.Control.Relays.SwitchRelay relay1(
t_switch={0.2,0.65})
PowerSystems.Control.Relays.SwitchRelay relay2(
t_switch={0.3,0.7})
PowerSystems.AC3ph.Sensors.PVImeter meter(V_nom=400e3, S_nom=1000e6)
PowerSystems.AC3ph.Faults.Fault_abc abc
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd2
equation
connect(relay1.y, switch1.control)
connect(relay2.y, switch2.control)
connect(infBus1.term, meter.term_p)
connect(meter.term_n, switch1.term_p)
connect(switch1.term_n, line.term_p)
connect(line.term_n, switch2.term_p)
connect(switch2.term_n, infBus2.term)
connect(line.term_f, abc.term)
connect(grd1.term,infBus1. neutral)
connect(infBus2.neutral, grd2.term)
end FaultRXline;
model FaultTline "Faulted PI-line"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Sources.InfBus infBus1(V_nom=400e3,
v0=1.04,
alpha0=0.5235987755983)
PowerSystems.AC3ph.Breakers.Breaker breaker1(V_nom=400e3, I_nom=2500)
PowerSystems.AC3ph.Lines.FaultTline line(len=400e3, redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.Line (
V_nom=400e3,
x=0.25e-3,
r=0.02e-3))
PowerSystems.AC3ph.Breakers.Breaker breaker2(V_nom=400e3, I_nom=2500)
PowerSystems.AC3ph.Sources.InfBus infBus2(V_nom=400e3)
PowerSystems.Control.Relays.SwitchRelay relay1(
t_switch={0.2,0.65})
PowerSystems.Control.Relays.SwitchRelay relay2(
t_switch={0.3,0.7})
PowerSystems.AC3ph.Sensors.PVImeter meter(V_nom=400e3, S_nom=1000e6)
PowerSystems.AC3ph.Faults.Fault_abc abc
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd2
equation
connect(relay1.y, breaker1.control)
connect(relay2.y, breaker2.control)
connect(infBus1.term, meter.term_p)
connect(meter.term_n, breaker1.term_p)
connect(breaker1.term_n, line.term_p)
connect(line.term_n, breaker2.term_p)
connect(breaker2.term_n, infBus2.term)
connect(line.term_f, abc.term)
connect(grd1.term,infBus1. neutral)
connect(infBus2.neutral, grd2.term)
end FaultTline;
model DoubleRXline "Parallel lumped lines, one faulted"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Sources.InfBus infBus1(V_nom=20e3, alpha0=
0.5235987755983)
PowerSystems.AC3ph.Transformers.TrafoStray trafo(
redeclare record Data =
PowerSystems.Examples.Data.Transformers.TrafoStray,
redeclare model Topology_p = PowerSystems.AC3ph.Ports.Topology.Delta,
redeclare model Topology_n = PowerSystems.AC3ph.Ports.Topology.Y)
PowerSystems.AC3ph.Lines.RXline line(len=480000, redeclare record Data =
PowerSystems.Examples.Data.Lines.OHline400kV)
PowerSystems.AC3ph.Breakers.Switch switch1(V_nom=400e3, I_nom=2500)
PowerSystems.AC3ph.Lines.FaultRXline lineF(
redeclare record Data = PowerSystems.Examples.Data.Lines.OHline400kV,
len=430000)
PowerSystems.AC3ph.Breakers.Switch switch2(V_nom=400e3, I_nom=2500)
PowerSystems.AC3ph.Faults.Fault_abc abc
PowerSystems.AC3ph.Sources.InfBus InfBus2(V_nom=400e3, alpha0=
0.5235987755983)
PowerSystems.Control.Relays.SwitchRelay relay1(t_switch={0.15,0.2})
PowerSystems.Control.Relays.SwitchRelay relay2(t_switch={0.153,0.21})
PowerSystems.AC3ph.Sensors.PVImeter meterL(S_nom=1000e6, V_nom=400e3)
PowerSystems.AC3ph.Sensors.PVImeter meterF(S_nom=1000e6, V_nom=400e3)
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd2
equation
connect(relay1.y, switch1.control)
connect(relay2.y, switch2.control)
connect(trafo.term_n, meterL.term_p)
connect(meterL.term_n, line.term_p)
connect(line.term_n, InfBus2.term)
connect(trafo.term_n, switch1.term_p)
connect(switch1.term_n, meterF.term_p)
connect(meterF.term_n, lineF.term_p)
connect(lineF.term_n, switch2.term_p)
connect(switch2.term_n, InfBus2.term)
connect(lineF.term_f, abc.term)
connect(infBus1.term, trafo.term_p)
connect(grd1.term,infBus1. neutral)
connect(InfBus2.neutral, grd2.term)
end DoubleRXline;
model DoubleLine "Parallel lines, one faulted"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Sources.InfBus infBus1(V_nom=20e3, alpha0=
0.5235987755983)
PowerSystems.AC3ph.Transformers.TrafoStray trafo(
redeclare record Data =
PowerSystems.Examples.Data.Transformers.TrafoStray,
redeclare model Topology_p = PowerSystems.AC3ph.Ports.Topology.Delta,
redeclare model Topology_n = PowerSystems.AC3ph.Ports.Topology.Y)
PowerSystems.AC3ph.Lines.PIline line(
len=480000, redeclare record Data =
PowerSystems.Examples.Data.Lines.OHline_400kV)
PowerSystems.AC3ph.Breakers.Switch switch1(V_nom=400e3, I_nom=2500)
PowerSystems.AC3ph.Lines.FaultTline lineF(
redeclare record Data =
PowerSystems.Examples.Data.Lines.OHline_400kV, len=430000)
PowerSystems.AC3ph.Breakers.Switch switch2(V_nom=400e3, I_nom=2500)
PowerSystems.AC3ph.Faults.Fault_abc abc
PowerSystems.AC3ph.Sources.InfBus InfBus2(V_nom=400e3, alpha0=
0.5235987755983)
PowerSystems.Control.Relays.SwitchRelay relay1(t_switch={0.15,0.2})
PowerSystems.Control.Relays.SwitchRelay relay2(t_switch={0.153,0.21})
PowerSystems.AC3ph.Sensors.PVImeter meterL(S_nom=1000e6, V_nom=400e3)
PowerSystems.AC3ph.Sensors.PVImeter meterF(S_nom=1000e6, V_nom=400e3)
PowerSystems.AC3ph.Nodes.GroundOne grd1
PowerSystems.AC3ph.Nodes.GroundOne grd2
equation
connect(relay1.y, switch1.control)
connect(relay2.y, switch2.control)
connect(trafo.term_n, meterL.term_p)
connect(meterL.term_n, line.term_p)
connect(line.term_n, InfBus2.term)
connect(trafo.term_n, switch1.term_p)
connect(switch1.term_n, meterF.term_p)
connect(meterF.term_n, lineF.term_p)
connect(lineF.term_n, switch2.term_p)
connect(switch2.term_n, InfBus2.term)
connect(lineF.term_f, abc.term)
connect(infBus1.term, trafo.term_p)
connect(grd1.term, infBus1.neutral)
connect(grd2.term, InfBus2.neutral)
end DoubleLine;
model DoubleRXlineTG
"Parallel lumped lines with turbo generator, one line faulted"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Generation.TurboGenerator turbGen(
p_start=0.762922,
redeclare model Generator = PowerSystems.AC3ph.Machines.Synchron_ee (
redeclare replaceable record Data =
PowerSystems.AC3ph.Machines.Parameters.Synchron_ee (
V_nom=20e3,
S_nom=1000e6,
If_nom=2000), dynType=PowerSystems.Types.Dynamics.FreeInitial) "nth order",
initType=PowerSystems.Types.Init.v_alpha,
alpha_start=0.5235987755983)
PowerSystems.AC3ph.Transformers.TrafoStray trafo(
redeclare record Data =
PowerSystems.Examples.Data.Transformers.TrafoStray,
redeclare model Topology_p = PowerSystems.AC3ph.Ports.Topology.Delta,
redeclare model Topology_n = PowerSystems.AC3ph.Ports.Topology.Y)
PowerSystems.AC3ph.Lines.RXline line(
len=480000,
redeclare record Data = PowerSystems.Examples.Data.Lines.OHline400kV)
PowerSystems.AC3ph.Breakers.Switch switch1(V_nom=400e3, I_nom=2500)
PowerSystems.AC3ph.Lines.FaultRXline lineF(
redeclare record Data = PowerSystems.Examples.Data.Lines.OHline400kV,
len=430000)
PowerSystems.AC3ph.Breakers.Switch switch2(V_nom=400e3, I_nom=2500)
PowerSystems.AC3ph.Faults.Fault_abc abc(epsG=1e-5)
PowerSystems.AC3ph.Sources.InfBus InfBus(V_nom=400e3, alpha0=
0.5235987755983)
PowerSystems.Control.Relays.SwitchRelay relay1(t_switch={0.15,0.2})
PowerSystems.Control.Relays.SwitchRelay relay2(t_switch={0.153,0.21})
PowerSystems.AC3ph.Sensors.PVImeter meterL(S_nom=1000e6, V_nom=400e3)
PowerSystems.AC3ph.Sensors.PVImeter meterF(S_nom=1000e6, V_nom=400e3)
PowerSystems.Control.Setpoints.Set_w_p_v cst_set
PowerSystems.AC3ph.Nodes.GroundOne grd2
PowerSystems.Common.Thermal.BoundaryV boundary(m=2)
equation
connect(relay1.y, switch1.control)
connect(relay2.y, switch2.control)
connect(cst_set.setpts, turbGen.setpts)
connect(turbGen.term, trafo.term_p)
connect(trafo.term_n, meterL.term_p)
connect(meterL.term_n, line.term_p)
connect(line.term_n, InfBus.term)
connect(trafo.term_n, switch1.term_p)
connect(switch1.term_n, meterF.term_p)
connect(meterF.term_n, lineF.term_p)
connect(lineF.term_n, switch2.term_p)
connect(switch2.term_n, InfBus.term)
connect(lineF.term_f, abc.term)
connect(InfBus.neutral, grd2.term)
connect(turbGen.heat, boundary.heat)
end DoubleRXlineTG;
model DoubleLineTG "Parallel lines with turbo generator, one line faulted"
extends Modelica.Icons.Example;
inner PowerSystems.System system
PowerSystems.AC3ph.Generation.TurboGenerator turbGen(
p_start=0.761825,
redeclare model Generator = PowerSystems.AC3ph.Machines.Synchron_ee (
redeclare replaceable record Data =
PowerSystems.AC3ph.Machines.Parameters.Synchron_ee (
V_nom=20e3,
S_nom=1000e6,
If_nom=2000), dynType=PowerSystems.Types.Dynamics.FreeInitial) "nth order",
alpha_start=0.5235987755983)
PowerSystems.AC3ph.Transformers.TrafoStray trafo(
redeclare record Data =
PowerSystems.Examples.Data.Transformers.TrafoStray,
redeclare model Topology_p = PowerSystems.AC3ph.Ports.Topology.Delta,
redeclare model Topology_n = PowerSystems.AC3ph.Ports.Topology.Y)
PowerSystems.AC3ph.Lines.PIline line(
len=480e3, redeclare record Data =
PowerSystems.Examples.Data.Lines.OHline_400kV)
PowerSystems.AC3ph.Breakers.Switch switch1(V_nom=400e3, I_nom=2500)
PowerSystems.AC3ph.Lines.FaultTline lineF(
redeclare record Data =
PowerSystems.Examples.Data.Lines.OHline_400kV, len=430000)
PowerSystems.AC3ph.Breakers.Switch switch2(V_nom=400e3, I_nom=2500)
PowerSystems.AC3ph.Faults.Fault_abc abc(epsG=1e-5)
PowerSystems.AC3ph.Sources.InfBus InfBus(V_nom=400e3, alpha0=
0.5235987755983)
PowerSystems.Control.Relays.SwitchRelay relay1(t_switch={0.15,0.2})
PowerSystems.Control.Relays.SwitchRelay relay2(t_switch={0.153,0.21})
PowerSystems.AC3ph.Sensors.PVImeter meterL(S_nom=1000e6, V_nom=400e3)
PowerSystems.AC3ph.Sensors.PVImeter meterF(S_nom=1000e6, V_nom=400e3)
PowerSystems.Control.Setpoints.Set_w_p_v cst_set
PowerSystems.AC3ph.Nodes.GroundOne grd2
PowerSystems.Common.Thermal.BoundaryV boundary(m=2)
equation
connect(relay1.y, switch1.control)
connect(relay2.y, switch2.control)
connect(cst_set.setpts, turbGen.setpts)
connect(turbGen.term, trafo.term_p)
connect(trafo.term_n, meterL.term_p)
connect(meterL.term_n, line.term_p)
connect(line.term_n, InfBus.term)
connect(trafo.term_n, switch1.term_p)
connect(switch1.term_n, meterF.term_p)
connect(meterF.term_n, lineF.term_p)
connect(lineF.term_n, switch2.term_p)
connect(switch2.term_n, InfBus.term)
connect(lineF.term_f, abc.term)
connect(InfBus.neutral, grd2.term)
connect(turbGen.heat, boundary.heat)
end DoubleLineTG;
end Transmission; |
Breaker example data | within PowerSystems.Examples.Data;
package Breakers "Breaker example data"
extends Modelica.Icons.MaterialPropertiesPackage;
end Breakers; |
Line example data | within PowerSystems.Examples.Data;
package Lines "Line example data"
extends Modelica.Icons.MaterialPropertiesPackage;
record OHline15kV1ph "Overhead RX-line 15kV 1-phase rail, example"
extends PowerSystems.AC1ph_DC.Lines.Parameters.RXline(
puUnits=true,
V_nom=15e3,
S_nom=100e6,
f_nom=50/3,
r={3e-3,3e-3},
x=2e-3,
x0=5e-3);
end OHline15kV1ph;
record OHline_15kV1ph "Overhead PI-line 15kV 1-phase rail, example"
extends PowerSystems.AC1ph_DC.Lines.Parameters.Line(
puUnits=true,
V_nom=132e3,
S_nom=100e6,
f_nom=50/3,
r={3e-3,3e-3},
x=2e-3,
x0=5e-3,
g_pg=1e-10,
g_pp=1e-10,
b_pg=0.02e-3,
b_pp=0.02e-3);
end OHline_15kV1ph;
record OHline132kV1ph "Overhead RX-line 132kV 1-phase rail, example"
extends PowerSystems.AC1ph_DC.Lines.Parameters.RXline(
puUnits=true,
V_nom=132e3,
S_nom=100e6,
f_nom=50/3,
r={1.2e-3,1.2e-3},
x=1e-3,
x0=3e-3);
end OHline132kV1ph;
record OHline_132kV1ph "Overhead PI-line 132kV 1-phase rail, example"
extends PowerSystems.AC1ph_DC.Lines.Parameters.Line(
puUnits=true,
V_nom=132e3,
S_nom=100e6,
f_nom=50/3,
r={1.2e-3,1.2e-3},
x=1e-3,
x0=3e-3,
g_pg=1e-10,
g_pp=1e-10,
b_pg=0.05e-3,
b_pp=0.05e-3);
end OHline_132kV1ph;
record Cable132kVDC "Cable RX-line 132kV DC, example"
extends PowerSystems.AC1ph_DC.Lines.Parameters.RXline(
puUnits=true,
V_nom=132e3,
S_nom=100e6,
f_nom=50,
r={0.65e-3,0.65e-3},
x=0.8e-3,
x0=3e-3);
end Cable132kVDC;
record Cable_132kVDC "Cable PI-line 132kV DC, example"
extends PowerSystems.AC1ph_DC.Lines.Parameters.Line(
puUnits=true,
V_nom=132e3,
S_nom=100e6,
f_nom=50,
r={0.65e-3,0.65e-3},
x=0.08e-3,
x0=3e-3,
g_pg=1e-10,
g_pp=1e-10,
b_pg=0.003,
b_pp=0.003);
end Cable_132kVDC;
record OHline132kV "Overhead RX-line 132kV 3-phase, example"
extends PowerSystems.AC3ph.Lines.Parameters.RXline(
puUnits=true,
V_nom=132e3,
S_nom=100e6,
f_nom=50,
r=1.2e-3,
x=3e-3,
x0=9e-3);
end OHline132kV;
record OHline_132kV "Overhead PI-line 132kV 3-phase, example"
extends PowerSystems.AC3ph.Lines.Parameters.Line(
puUnits=true,
V_nom=132e3,
S_nom=100e6,
f_nom=50,
r=1.2e-3,
x=3e-3,
x0=9e-3,
g_pg=1e-10,
g_pp=1e-10,
b_pg=0.05e-3,
b_pp=0.05e-3);
end OHline_132kV;
record OHline400kV "Overhead RX-line 400kV 3-phase, example"
extends PowerSystems.AC3ph.Lines.Parameters.RXline(
puUnits=true,
V_nom=400e3,
S_nom=100e6,
f_nom=50,
r=0.02e-3,
x=0.25e-3,
x0=0.75e-3);
end OHline400kV;
record OHline_400kV "Overhead PI-line 400kV 3-phase, example"
extends PowerSystems.AC3ph.Lines.Parameters.Line(
puUnits=true,
V_nom=400e3,
S_nom=100e6,
f_nom=50,
r=0.02e-3,
x=0.25e-3,
x0=0.75e-3,
g_pg=1e-10,
g_pp=1e-10,
b_pg=0.003e-3,
b_pp=0.003e-3);
end OHline_400kV;
record Cable132kV "Cable RX-line 132kV 3-phase, example"
extends PowerSystems.AC3ph.Lines.Parameters.RXline(
puUnits=true,
V_nom=132e3,
S_nom=100e6,
f_nom=50,
r=0.65e-3,
x=0.8e-3,
x0=3e-3);
end Cable132kV;
record Cable_132kV "Cable PI-line 132kV 3-phase, example"
extends PowerSystems.AC3ph.Lines.Parameters.Line(
puUnits=true,
V_nom=132e3,
S_nom=100e6,
f_nom=50,
r=0.65e-3,
x=0.08e-3,
x0=3e-3,
g_pg=1e-10,
g_pp=1e-10,
b_pg=0.003,
b_pp=0.003);
end Cable_132kV;
record Cable400kV "Cable RX-line 400kV 3-phase, example"
extends PowerSystems.AC3ph.Lines.Parameters.RXline(
puUnits=true,
V_nom=400e3,
S_nom=100e6,
f_nom=50,
r=0.05e-3,
x=0.085e-3,
x0=3e-3);
end Cable400kV;
record Cable_400kV "Cable PI-line 400kV 3-phase, example"
extends PowerSystems.AC3ph.Lines.Parameters.Line(
puUnits=true,
V_nom=400e3,
S_nom=100e6,
f_nom=50,
r=0.05e-3,
x=0.085e-3,
x0=3e-3,
g_pg=1e-10,
g_pp=1e-10,
b_pg=0.025,
b_pp=0.025);
end Cable_400kV;
end Lines; |
Machine example data | within PowerSystems.Examples.Data;
package Machines "Machine example data"
extends Modelica.Icons.MaterialPropertiesPackage;
record DCser1500V_1p5MVA "DC machine series excited, example"
extends PowerSystems.AC1ph_DC.Machines.Parameters.DCser(
pp=2,
l_fd=0.15,
r_fd=0.01,
l_q=0.5,
r_q=0.05,
puUnits=true,
V_nom=1500,
S_nom=1.5e6,
w_nom=157.079632679489661923);
end DCser1500V_1p5MVA;
record DCpar1500V_1p5MVA "DC machine parallel excited, example"
extends PowerSystems.AC1ph_DC.Machines.Parameters.DCpar(
pp=2,
l_fd=100*pi,
r_fd=100,
l_q=0.5,
r_q=0.05,
puUnits=true,
V_nom=1500,
S_nom=1.5e6,
w_nom=157.079632679489661923,
Vf_nom=1500);
end DCpar1500V_1p5MVA;
record DCpm100V_1kVA "DC machine permanent magnet excited, example"
extends PowerSystems.AC1ph_DC.Machines.Parameters.DCpm(
pp=2,
l_aq=0.5,
r_aq=0.05,
puUnits=true,
V_nom(displayUnit="V")=100,
S_nom(displayUnit="kVA")=1e3,
w_nom=157.079632679489661923);
end DCpm100V_1kVA;
record BLDC100V_1kVA
"BLDC machine (= synchronous pm, 3rd order model), example pu-units"
extends PowerSystems.AC3ph.Machines.Parameters.Synchron3rd(
puUnits=true,
V_nom(displayUnit="V")=100*sqrt(3/2)/2,
S_nom(displayUnit="kVA")=1e3,
f_nom=60,
neu_iso=false,
pp=2,
final excite=2,
psi_pm(unit="1")=1.2,
x_d=0.4,
x_q=0.4,
x_0=0.1,
r_s=0.05,
r_n=1);
end BLDC100V_1kVA;
record BLDC100V_1kVA_SI
"BLDC machine (= synchronous pm, 3rd order model), example SI-units"
extends PowerSystems.AC3ph.Machines.Parameters.Synchron3rd(
puUnits=false,
V_nom(displayUnit="V")=100*sqrt(3/2)/2,
S_nom(displayUnit="kVA")=1e3,
f_nom=60,
neu_iso=false,
pp=2,
final excite=2,
psi_pm(unit="1")=1.2,
x_d=1.5,
x_q=1.5,
x_0=0.375,
r_s=0.1875,
r_n=1);
end BLDC100V_1kVA_SI;
record Asynchron400V_30kVA "Asynchronous machine, example"
extends PowerSystems.AC3ph.Machines.Parameters.Asynchron(
neu_iso=false,
pp=8,
x=3,
x_0=0.1,
r_s=0.04,
r_n=1,
n_r=1,
transDat=true,
use_xtr=true,
xtr={0.196667},
tc={0.0130419},
to={0.198944},
xsig_s=0.1,
xsig_r={0.1},
r_r={0.04},
puUnits=true,
V_nom(displayUnit="V")=400,
S_nom(displayUnit="kVA")=30e3,
f_nom=50);
end Asynchron400V_30kVA;
record Asynchron3kV_1p5MVA "Asynchronous machine, example"
extends PowerSystems.AC3ph.Machines.Parameters.Asynchron(
neu_iso=false,
pp=2,
x=2.8,
x_0=0.1,
r_s=0.02,
r_n=1,
n_r=2,
transDat=true,
use_xtr=true,
xtr={0.1, 0.075},
tc={0.014, 0.4e-3},
to={0.4, 2.8e-3},
xsig_s=0.05,
xsig_r={0.0529633, 0.0481803},
r_r={0.0234304, 0.580595},
puUnits=true,
V_nom=3000,
S_nom=1.5e6,
f_nom=50);
end Asynchron3kV_1p5MVA;
record Synchron3rd_pm400V_30kVA
"Synchronous machine pm, 3rd order model, example"
extends PowerSystems.AC3ph.Machines.Parameters.Synchron3rd_pm(
neu_iso=false,
pp=2,
psi_pm=1.1,
x_d=0.4,
x_q=0.4,
x_0=0.1,
r_s=0.03,
r_n=1,
puUnits=true,
V_nom(displayUnit="V")=400,
S_nom(displayUnit="kVA")=30e3,
f_nom=50);
end Synchron3rd_pm400V_30kVA;
record Synchron_pm400V_30kVA "Synchronous machine pm, example"
extends PowerSystems.AC3ph.Machines.Parameters.Synchron_pm(
neu_iso=false,
pp=2,
psi_pm=1.1,
x_d=0.4,
x_q=0.4,
x_0=0.1,
r_s=0.03,
r_n=1,
transDat=true,
use_xtr=true,
xtr_d={0.142857},
xtr_q={0.142857},
tc_d={0.00994718},
tc_q={0.00994718},
to_d={0.0278521},
to_q={0.0278521},
use_if0=false,
if0=0,
alpha_if0=0,
tol=1e-6,
xsig_s=0.1,
xsig_rd={0.05},
xsig_rq={0.05},
xm_d=fill(0, 0),
r_rd={0.04},
r_rq={0.04},
puUnits=true,
V_nom(displayUnit="V")=400,
S_nom(displayUnit="kVA")=30e3,
f_nom=50,
If_nom=0);
end Synchron_pm400V_30kVA;
record Synchron3rd_pm560V_100kVA "Synchronous machine 3rd order pm, example"
extends PowerSystems.AC3ph.Machines.Parameters.Synchron3rd_pm(
neu_iso=false,
pp=2,
psi_pm=1.1,
x_d=0.4,
x_q=0.4,
x_0=0.1,
r_s=0.03,
r_n=1,
puUnits=true,
V_nom(displayUnit="V")=560,
S_nom(displayUnit="kVA")=100e3,
f_nom=400);
end Synchron3rd_pm560V_100kVA;
record Synchron_pm560V_100kVA "Synchronous machine pm, example"
extends PowerSystems.AC3ph.Machines.Parameters.Synchron_pm(
neu_iso=false,
pp=2,
psi_pm=1.1,
x_d=0.4,
x_q=0.4,
x_0=0.1,
r_s=0.03,
r_n=1,
transDat=true,
use_xtr=true,
xtr_d={0.142857},
xtr_q={0.142857},
tc_d={0.0132629},
tc_q={0.0132629},
to_d={0.0371362},
to_q={0.0371362},
use_if0=false,
if0=0,
alpha_if0=0,
tol=1e-6,
xsig_s=0.1,
xsig_rd={0.05},
xsig_rq={0.05},
xm_d=fill(0, 0),
r_rd={0.03},
r_rq={0.03},
puUnits=true,
V_nom(displayUnit="V")=560,
S_nom(displayUnit="kVA")=100e3,
f_nom=400,
If_nom=0);
end Synchron_pm560V_100kVA;
record Synchron3rd_ee20kV_1200MVA
"Synchronous machine, 3rd order model, example"
extends PowerSystems.AC3ph.Machines.Parameters.Synchron3rd_ee(
neu_iso=false,
pp=1,
x_d=2.29,
x_q=1.95,
x_0=0.1,
r_s=0.004,
r_n=1,
puUnits=true,
V_nom=20e3,
S_nom=1200e6,
f_nom=50);
end Synchron3rd_ee20kV_1200MVA;
record Synchron_ee20kV_1200MVA "Synchronous machine, example"
extends PowerSystems.AC3ph.Machines.Parameters.Synchron_ee(
neu_iso=false,
pp=1,
x_d=2.29,
x_q=1.95,
x_0=0.1,
r_s=0.004,
r_n=1,
transDat=true,
use_xtr=true,
xtr_d={0.361123, 0.283696},
xtr_q={0.464817, 0.303593},
tc_d={0.93133, 0.0253919},
tc_q={0.270197, 0.041458},
to_d={5.94309, 0.0321197},
to_q={1.207780, 0.0595723},
use_if0=true,
if0=0.286,
alpha_if0=-0.97738438111682,
tol=1e-6,
xsig_s=0.2,
xsig_rd={0.1294, 0.03498},
xsig_rq={0.3948, 0.1527},
xm_d={0.05965},
r_rd={1.321e-3, 14.38e-3},
r_rq={7.037e-3, 20.38e-3},
puUnits=true,
V_nom=20e3,
S_nom=1200e6,
f_nom=50,
If_nom=8000);
end Synchron_ee20kV_1200MVA;
record Synchron3rd_ee60Hz_26kV_720MVA
"Synchronous machine, 3rd order model, example"
extends PowerSystems.AC3ph.Machines.Parameters.Synchron3rd_ee(
neu_iso=false,
pp=1,
x_d=1.9,
x_q=1.77,
x_0=0.1,
r_s=0.005,
r_n=1,
puUnits=true,
V_nom=26e3,
S_nom=720e6,
f_nom=60);
end Synchron3rd_ee60Hz_26kV_720MVA;
record Synchron_ee60Hz_26kV_720MVA "Synchronous machine, example"
extends PowerSystems.AC3ph.Machines.Parameters.Synchron_ee(
neu_iso=false,
pp=1,
x_d=1.9,
x_q=1.77,
x_0=0.1,
r_s=0.005,
r_n=1,
transDat=true,
use_xtr=true,
xtr_d={0.3290, 0.253},
xtr_q={0.436, 0.2730},
tc_d={0.7158, 0.02058},
tc_q={0.2134, 0.03320},
to_d={4.164, 0.02658},
to_q={0.9307, 0.04936},
use_if0=true,
if0=0.835428,
alpha_if0=-1.7910219718115,
tol=1e-6,
xsig_s=0.17,
xsig_rd={0.1294, 0.03498},
xsig_rq={0.3948, 0.1527},
xm_d={0.05965},
r_rd={1.321e-3, 14.38e-3},
r_rq={7.037e-3, 20.38e-3},
puUnits=true,
V_nom=26e3,
S_nom=720e6,
f_nom=60,
If_nom=1800);
end Synchron_ee60Hz_26kV_720MVA;
record SynchronIso20kV_500MVA
"Synchronous machine (isotropic), 3rd order model"
extends PowerSystems.AC3ph.Machines.Parameters.Synchron3rd_ee(
neu_iso=false,
pp=1,
x_d=1.6,
x_q=1.6,
x_0=0.1,
r_s=0.01,
r_n=1,
puUnits=true,
V_nom=20e3,
S_nom=500e6,
f_nom=50);
end SynchronIso20kV_500MVA;
end Machines; |
Data | within PowerSystems.Examples;
package Data "Data"
extends Modelica.Icons.MaterialPropertiesPackage;
end Data; |
Breaker example data | within PowerSystems.Examples.Data;
package Semiconductors "Breaker example data"
extends Modelica.Icons.MaterialPropertiesPackage;
record IdealSC100V_10A "Ideal semiconductor parameters, example"
extends PowerSystems.Semiconductors.Ideal.SCparameter(
V_nom=100,
I_nom=10,
eps={1e-4,1e-4},
Vf=1,
Hsw_nom=2e-3,
cT_loss=fill(0,0),
T0_loss=300);
end IdealSC100V_10A;
record IdealSC1kV_100A "Ideal semiconductor parameters, example"
extends PowerSystems.Semiconductors.Ideal.SCparameter(
V_nom=100,
I_nom=10,
eps={1e-4,1e-4},
Vf=2.5,
Hsw_nom=0.25,
cT_loss=fill(0,0),
T0_loss=300);
end IdealSC1kV_100A;
record IdealSC3kV_500A "Ideal semiconductor parameters, example"
extends PowerSystems.Semiconductors.Ideal.SCparameter(
V_nom=3e3,
I_nom=500,
eps={1e-4,1e-4},
Vf=3,
Hsw_nom=5,
cT_loss={0.005},
T0_loss=300);
end IdealSC3kV_500A;
end Semiconductors; |
Transformer example data | within PowerSystems.Examples.Data;
package Transformers "Transformer example data"
extends Modelica.Icons.MaterialPropertiesPackage;
record TrafoIdeal1ph "Ideal trafo, 1-phase, example"
extends PowerSystems.AC1ph_DC.Transformers.Parameters.TrafoIdeal1ph(
puUnits=true,
V_nom={15000,1400},
S_nom=5e6,
f_nom=50/3,
tap_neutral={3,3},
dv_tap={0.025,0.025});
end TrafoIdeal1ph;
record TrafoStray1ph "Trafo with ideal magnetic coupling, 1-phase, example"
extends PowerSystems.AC1ph_DC.Transformers.Parameters.TrafoStray1ph(
puUnits=true,
V_nom={15000,1400},
S_nom=5e6,
f_nom=50/3,
tap_neutral={3,3},
dv_tap={0.025,0.025},
r={0.03,0.03},
x={0.05,0.05});
end TrafoStray1ph;
record TrafoMag1ph "Trafo with magnetic coupling, 1-phase, example"
extends PowerSystems.AC1ph_DC.Transformers.Parameters.TrafoMag1ph(
puUnits=true,
V_nom={15000,1400},
S_nom=5e6,
f_nom=50/3,
tap_neutral={3,3},
dv_tap={0.025,0.025},
r={0.03,0.03},
x={0.05,0.05},
redc=500,
xm=500);
end TrafoMag1ph;
record TrafoSat1ph "Trafo with saturation, 1-phase, example"
extends PowerSystems.AC1ph_DC.Transformers.Parameters.TrafoSat1ph(
puUnits=true,
V_nom={15000,1400},
S_nom=5e6,
f_nom=50/3,
tap_neutral={3,3},
dv_tap={0.025,0.025},
r={0.03,0.03},
x={0.05,0.05},
redc=500,
xm=500,
psi_sat(unit="1")=1.5,
xm_sat=1);
end TrafoSat1ph;
record TrafoIdeal "Ideal trafo, 3-phase, example"
extends PowerSystems.AC3ph.Transformers.Parameters.TrafoIdeal(
puUnits=true,
V_nom={20,400}*1e3,
S_nom=1000e6,
f_nom=50,
tap_neutral={3,3},
dv_tap={0.025,0.025},
r_n={1,1});
end TrafoIdeal;
record TrafoStray "Trafo with ideal magnetic coupling, 3-phase, example"
extends PowerSystems.AC3ph.Transformers.Parameters.TrafoStray(
puUnits=true,
V_nom={20,400}*1e3,
S_nom=1000e6,
f_nom=50,
tap_neutral={3,3},
dv_tap={0.025,0.025},
r_n={1,1},
r={0.005,0.005},
x={0.05,0.05},
x0={x[1],x[2]});
end TrafoStray;
record TrafoMag "Trafo with magnetic coupling, 3-phase, example"
extends PowerSystems.AC3ph.Transformers.Parameters.TrafoMag(
puUnits=true,
V_nom={20,400}*1e3,
S_nom=1000e6,
f_nom=50,
tap_neutral={3,3},
dv_tap={0.025,0.025},
r_n={1,1},
r={0.005,0.005},
x={0.05,0.05},
x0={x[1],x[2]},
redc=500,
xm=500,
xm0=50);
end TrafoMag;
record TrafoSat "Trafo with saturation, 3-phase, example"
extends PowerSystems.AC3ph.Transformers.Parameters.TrafoSat(
puUnits=true,
V_nom={20,400}*1e3,
S_nom=1000e6,
f_nom=50,
tap_neutral={3,3},
dv_tap={0.025,0.025},
r_n={1,1},
r={0.005,0.005},
x={0.05,0.05},
x0={x[1],x[2]},
redc=500,
xm=500,
xm0=50,
psi_sat(unit="1")=1.5,
xm_sat=1);
end TrafoSat;
end Transformers; |
Turbine example data | within PowerSystems.Examples.Data;
package Turbines "Turbine example data"
extends Modelica.Icons.MaterialPropertiesPackage;
record SteamTurboGroup1200MW "Steam turbo-group, example"
extends PowerSystems.Mechanics.TurboGroups.Parameters.SteamTurboGroup(
w_nom(displayUnit="rpm")=314.15926535898,
P_nom={480e6,240e6,240e6,240e6},
J_turb={20000,200000,200000,200000},
J_gen=62000,
J_aux={460,830},
stiff={260,355,750,750,750,220}*1e6);
end SteamTurboGroup1200MW;
record GasTurbineGear "Small GT with gear, example"
extends PowerSystems.Mechanics.TurboGroups.Parameters.GasTurbineGear(
w_nom=1576.7653528367,
P_nom={12, -2}*1e6,
J_turb=40,
J_comp=50,
J_gear1={0.6,12},
J_gear2={5,200},
J_acc=6,
J_cpl=40,
J_gen=2500,
ratio={15057,5067,1500},
stiff_sh={3,5.5,100,2500,250,200}*1e6,
stiff_cpl=130*1e6);
end GasTurbineGear;
record HydroTurbine "Hydro turbine, example"
extends PowerSystems.Mechanics.TurboGroups.Parameters.HydroTurbine(
w_nom=314.15926535898,
P_nom=20e6,
J_turb=1000,
J_shaft=5,
J_gen=500,
stiff=300e6);
end HydroTurbine;
record Diesel "Diesel, example"
extends PowerSystems.Mechanics.TurboGroups.Parameters.Diesel(
w_nom=157.07963267949,
P_nom=100e3,
J_turb=20,
J_gen=20,
stiff=1e6);
end Diesel;
record WindTurbineGear "Wind turbine with gear, example"
extends PowerSystems.Mechanics.TurboGroups.Parameters.WindTurbineGear(
w_nom=1.0471975511966,
P_nom=30e3,
J_turb=10,
J_gear={0.3,0.1,0.03},
J_gen=0.5,
ratio={1,6,42},
stiff_sh={16,1}*1e4);
end WindTurbineGear;
end Turbines; |
Text book example and variants of it | within PowerSystems.Examples.Generic;
package Network "Text book example and variants of it"
extends Modelica.Icons.ExamplesPackage;
model NetworkLoop
"Simple textbook example for a steady-state power flow calculation"
extends Modelica.Icons.Example;
replaceable package PhaseSystem =
PhaseSystems.ThreePhase_dq "Default phase system"
PowerSystems.Generic.FixedVoltageSource
fixedVoltageSource1(V=10e3, redeclare package PhaseSystem=PhaseSystem)
PowerSystems.Generic.Impedance impedance1(R=2, L=0,
redeclare package PhaseSystem = PhaseSystem)
PowerSystems.Generic.Impedance impedance2(R=4, L=0,
redeclare package PhaseSystem = PhaseSystem)
PowerSystems.Generic.Impedance impedance3(R=2, L=0,
redeclare package PhaseSystem = PhaseSystem)
PowerSystems.Generic.Impedance impedance4(L=0, R=1,
redeclare package PhaseSystem = PhaseSystem)
PowerSystems.Generic.Impedance impedance5(L=0, R=3,
redeclare package PhaseSystem = PhaseSystem)
PowerSystems.Generic.FixedCurrent fixedCurrent3(I=50,
redeclare package PhaseSystem = PhaseSystem)
PowerSystems.Generic.FixedCurrent fixedCurrent1(I=55,
redeclare package PhaseSystem = PhaseSystem)
PowerSystems.Generic.FixedCurrent fixedCurrent2(I=45,
redeclare package PhaseSystem = PhaseSystem)
PowerSystems.Generic.FixedCurrent fixedCurrent4(I=60,
redeclare package PhaseSystem = PhaseSystem)
PowerSystems.Generic.Transformer transformer1(ratio=10/10.4156,
redeclare package PhaseSystem = PhaseSystem)
PowerSystems.Generic.Transformer transformer2(ratio=10/10, redeclare
package PhaseSystem=PhaseSystem)
inner System system
equation
connect(impedance1.terminal_n, impedance2.terminal_p)
connect(impedance2.terminal_n, impedance3.terminal_p)
connect(impedance4.terminal_p, impedance5.terminal_n)
connect(fixedCurrent1.terminal, impedance1.terminal_n)
connect(fixedCurrent2.terminal, impedance3.terminal_p)
connect(fixedCurrent4.terminal, impedance5.terminal_n)
connect(fixedVoltageSource1.terminal, transformer1.terminal_p)
connect(transformer1.terminal_n, impedance1.terminal_p)
connect(transformer2.terminal_n, impedance5.terminal_p)
connect(transformer2.terminal_p, fixedVoltageSource1.terminal)
connect(impedance3.terminal_n, fixedCurrent3.terminal)
connect(impedance4.terminal_n, impedance3.terminal_n)
end NetworkLoop;
model NetworkLoop_d "NetworkLoop example with phase system ThreePhase_d"
extends NetworkLoop(
redeclare replaceable package PhaseSystem =
PowerSystems.PhaseSystems.ThreePhase_d);
end NetworkLoop_d;
model NetworkLoop_dq "NetworkLoop example with phase system ThreePhase_dq"
extends NetworkLoop(
redeclare replaceable package PhaseSystem =
PowerSystems.PhaseSystems.ThreePhase_dq);
end NetworkLoop_dq;
model NetworkLoop_dq0 "NetworkLoop example with phase system ThreePhase_dq0"
extends NetworkLoop(
redeclare replaceable package PhaseSystem =
PowerSystems.PhaseSystems.ThreePhase_dq0);
end NetworkLoop_dq0;
model NetworkOpened
"Steady-state power flow calculation with two voltage sources"
extends Modelica.Icons.Example;
PowerSystems.Generic.FixedVoltageSource fixedVoltageSource1(V=10e3)
PowerSystems.Generic.FixedVoltageSource fixedVoltageSource2(V=10e3)
PowerSystems.Generic.Impedance impedance1(R=2, L=0)
PowerSystems.Generic.Impedance impedance2(L=0, R=4)
PowerSystems.Generic.Impedance impedance3(R=2, L=0)
PowerSystems.Generic.Impedance impedance4(L=0, R=1)
PowerSystems.Generic.Impedance impedance5(L=0, R=3)
PowerSystems.Generic.FixedCurrent
fixedCurrent3(I=50)
PowerSystems.Generic.FixedCurrent
fixedCurrent1(I=55)
PowerSystems.Generic.FixedCurrent
fixedCurrent2(I=45)
PowerSystems.Generic.FixedCurrent
fixedCurrent4(I=60)
PowerSystems.Generic.Transformer transformer1(ratio=10/10.4156)
PowerSystems.Generic.Transformer transformer2(ratio=10/10)
inner System system
equation
connect(impedance1.terminal_n, impedance2.terminal_p)
connect(impedance2.terminal_n, impedance3.terminal_p)
connect(impedance3.terminal_n, impedance4.terminal_n)
connect(impedance4.terminal_p, impedance5.terminal_n)
connect(impedance3.terminal_n, fixedCurrent3.terminal)
connect(fixedCurrent1.terminal, impedance1.terminal_n)
connect(fixedCurrent2.terminal, impedance3.terminal_p)
connect(fixedCurrent4.terminal, impedance5.terminal_n)
connect(fixedVoltageSource1.terminal, transformer1.terminal_p)
connect(transformer1.terminal_n, impedance1.terminal_p)
connect(fixedVoltageSource2.terminal, transformer2.terminal_p)
connect(transformer2.terminal_n, impedance5.terminal_p)
end NetworkOpened;
model NetworkControlled "Dynamic power flow calculation with two generators"
extends Modelica.Icons.Example;
PowerSystems.Generic.Impedance impedance1(R=2, L=0)
PowerSystems.Generic.Impedance impedance2(L=0, R=4)
PowerSystems.Generic.Impedance impedance3(R=2, L=0)
PowerSystems.Generic.Impedance impedance4(L=0, R=1)
PowerSystems.Generic.Impedance impedance5(L=0, R=3)
PowerSystems.Generic.FixedCurrent
fixedCurrent3(I=50)
PowerSystems.Generic.FixedCurrent
fixedCurrent1(I=55)
PowerSystems.Generic.FixedCurrent
fixedCurrent2(I=45)
PowerSystems.Generic.FixedCurrent
fixedCurrent4(I=60)
PowerSystems.Generic.Transformer transformer1(ratio=10/10.4156)
PowerSystems.Generic.Transformer transformer2(ratio=10/10)
PowerSystems.Generic.Generator generator1
Modelica.Mechanics.Rotational.Components.Inertia inertia1(
J=1e3,
w(start=system.w_nom/generator1.pp),
a(start=0))
PowerSystems.Generic.Generator generator2(pp=8)
Modelica.Mechanics.Rotational.Components.Inertia inertia2(
J=1e3,
w(start=system.w_nom/generator2.pp),
a(start=0))
Modelica.Mechanics.Rotational.Sources.Torque turbine1(useSupport=false)
Modelica.Mechanics.Rotational.Sensors.SpeedSensor angularVelocity
Modelica.Mechanics.Rotational.Sources.Torque turbine2(useSupport=false)
Modelica.Blocks.Sources.Trapezoid disturbance(
width=30,
rising=0,
falling=0,
period=60,
amplitude=2e3,
offset=2e3)
Modelica.Blocks.Sources.Constant const(k=system.f_nom)
Modelica.Blocks.Continuous.LimPID frequencyPowerControl(
controllerType=Modelica.Blocks.Types.SimpleController.PI,
Td=0,
yMax=1e5,
k=1e6/50,
Ti=10)
Modelica.Blocks.Math.Gain frequency(k=1/(2*pi))
inner System system(fType=PowerSystems.Types.SystemFrequency.Average)
Interfaces.Sender sender1(H=0.5*inertia1.J*inertia1.w^2/1e6, w=generator1.w)
Interfaces.Sender sender2(H=0.5*inertia2.J*inertia2.w^2/1e6, w=generator2.w)
initial equation
if system.dynType == Types.Dynamics.SteadyInitial then
inertia1.a = 0;
else
inertia1.w = system.omega/generator1.pp;
end if;
inertia1.phi = system.theta/generator1.pp;
equation
connect(impedance1.terminal_n, impedance2.terminal_p)
connect(impedance2.terminal_n, impedance3.terminal_p)
connect(impedance3.terminal_n, impedance4.terminal_n)
connect(impedance4.terminal_p, impedance5.terminal_n)
connect(impedance3.terminal_n, fixedCurrent3.terminal)
connect(fixedCurrent1.terminal, impedance1.terminal_n)
connect(fixedCurrent2.terminal, impedance3.terminal_p)
connect(fixedCurrent4.terminal, impedance5.terminal_n)
connect(transformer1.terminal_n, impedance1.terminal_p)
connect(transformer2.terminal_n, impedance5.terminal_p)
connect(inertia1.flange_b, generator1.flange)
connect(generator1.terminal, transformer1.terminal_p)
connect(inertia2.flange_b, generator2.flange)
connect(generator2.terminal, transformer2.terminal_p)
connect(turbine1.flange, inertia1.flange_a)
connect(turbine2.flange, inertia2.flange_a)
connect(disturbance.y, turbine2.tau)
connect(angularVelocity.flange, inertia1.flange_b)
connect(frequencyPowerControl.y, turbine1.tau)
connect(const.y, frequencyPowerControl.u_s)
connect(angularVelocity.w, frequency.u)
connect(frequency.y, frequencyPowerControl.u_m)
connect(system.receiveFreq, sender1.sendFreq)
connect(system.receiveFreq, sender2.sendFreq)
end NetworkControlled;
end Network; |
Examples for Generic components | within PowerSystems.Examples;
package Generic "Examples for Generic components"
extends Modelica.Icons.ExamplesPackage;
end Generic; |
Small examples with Generic components | within PowerSystems.Examples.Generic;
package Test "Small examples with Generic components"
extends Modelica.Icons.ExamplesPackage;
model ImpedanceTest
extends Modelica.Icons.Example;
PowerSystems.Generic.FixedVoltageSource source
PowerSystems.Generic.Impedance
load(R=30, L=10/314)
PowerSystems.Generic.Ground ground
inner PowerSystems.System system
equation
connect(source.terminal, load.terminal_p)
connect(load.terminal_n, ground.terminal)
end ImpedanceTest;
model AdmittanceTest
extends Modelica.Icons.Example;
PowerSystems.Generic.FixedVoltageSource source
PowerSystems.Generic.Admittance
load(G=30/(30*30 + 10*10), C=10/(30*30 + 10*10)/314)
PowerSystems.Generic.Ground ground
inner PowerSystems.System system
equation
connect(source.terminal, load.terminal_p)
connect(load.terminal_n, ground.terminal)
end AdmittanceTest;
model InductiveLoadTest
extends Modelica.Icons.Example;
PowerSystems.Generic.FixedVoltageSource source
PowerSystems.Generic.Impedance
line(R=1.2, L=1.6/314)
PowerSystems.Generic.Impedance
load(R=30, L=10/314)
PowerSystems.Generic.Ground ground
inner PowerSystems.System system
equation
connect(source.terminal, line.terminal_p)
connect(load.terminal_n, ground.terminal)
connect(line.terminal_n, load.terminal_p)
end InductiveLoadTest;
model FixedCurrentTest
extends Modelica.Icons.Example;
PowerSystems.Generic.FixedVoltageSource source
PowerSystems.Generic.Impedance
line(R=1.2, L=1.6/314)
PowerSystems.Generic.FixedCurrent load(I=173.448, phi=-0.356)
inner PowerSystems.System system
equation
connect(line.terminal_n, load.terminal)
connect(source.terminal, line.terminal_p)
end FixedCurrentTest;
model FixedLoadTest
extends Modelica.Icons.Example;
PowerSystems.Generic.FixedVoltageSource source
PowerSystems.Generic.Impedance
line(R=1.2, L=1.6/314)
PowerSystems.Generic.FixedLoad load(P=2.7076e6, phi=atan(1000/3000))
inner PowerSystems.System system
equation
connect(source.terminal, line.terminal_p)
connect(line.terminal_n, load.terminal)
end FixedLoadTest;
model PMeterTest
extends Modelica.Icons.Example;
PowerSystems.Generic.FixedVoltageSource source
PowerSystems.Generic.Sensors.PMeter pMeter
PowerSystems.Generic.FixedLoad load(P=2.7076e6, phi=atan(1000/3000))
inner PowerSystems.System system
equation
connect(source.terminal, pMeter.terminal_p)
connect(pMeter.terminal_n, load.terminal)
end PMeterTest;
model GeneratorTest
extends Modelica.Icons.Example;
PowerSystems.Generic.Generator generator
Modelica.Mechanics.Rotational.Components.Inertia inertia(J=1e3,
phi(start=0, fixed=true),
w(start=2*pi*50, fixed=true))
Modelica.Mechanics.Rotational.Sources.ConstantTorque constantTorque(useSupport=false, tau_constant=3e6/50/2/pi)
PowerSystems.Generic.FixedLoad fixedLoad(P=3e6,phi=0.3)
inner PowerSystems.System system
equation
connect(inertia.flange_b, generator.flange)
connect(constantTorque.flange, inertia.flange_a)
connect(generator.terminal, fixedLoad.terminal)
end GeneratorTest;
model GeneratorTest2
extends Modelica.Icons.Example;
PowerSystems.Generic.Generator generator
Modelica.Mechanics.Rotational.Components.Inertia inertia(J=1e3,
phi(start=0, fixed=true),
w(start=50*2*pi, fixed=true))
Modelica.Mechanics.Rotational.Sources.ConstantTorque constantTorque(useSupport=false, tau_constant=3e6/50/2/2/pi)
PowerSystems.Generic.FixedLoad fixedLoad(P=3e6,phi=0.3)
PowerSystems.Generic.Generator generator1(synchronous=false)
Modelica.Mechanics.Rotational.Components.Inertia inertia1(J=1e3,
phi(start=0, fixed=true),
w(start=50*2*pi, fixed=true))
Modelica.Mechanics.Rotational.Sources.ConstantTorque constantTorque1(useSupport=false, tau_constant=3e6/50/2/pi)
PowerSystems.Generic.Impedance impedance
PowerSystems.Generic.Impedance impedance1
inner PowerSystems.System system
equation
connect(inertia.flange_b, generator.flange)
connect(constantTorque.flange, inertia.flange_a)
connect(inertia1.flange_b, generator1.flange)
connect(constantTorque1.flange, inertia1.flange_a)
connect(generator.terminal, impedance.terminal_p)
connect(impedance.terminal_n, fixedLoad.terminal)
connect(generator1.terminal, impedance1.terminal_p)
connect(impedance1.terminal_n, fixedLoad.terminal)
end GeneratorTest2;
end Test; |
Demonstrate stabilization of wind power in Eurosyslib work package 5.3 | within PowerSystems.Examples;
package PowerWorld "Demonstrate stabilization of wind power in Eurosyslib work package 5.3"
extends Modelica.Icons.ExamplesPackage;
model PowerWorld "Interoperation of wind power and thermal power"
extends Modelica.Icons.Example;
Components.WindFarm windFarm(redeclare package PhaseSystem =
PowerSystems.PhaseSystems.DirectCurrent)
Components.City city
Components.LoadDispatcher dispatcher
Components.PowerPlant powerPlant(primaryControlMax=40)
PowerSystems.Generic.Transformer trafoPlant(ratio=10/380)
PowerSystems.Generic.Transformer distribution(ratio=380/50)
PowerSystems.Generic.Inverter HVDC(potentialReference=false)
Components.HydroPlant hydroPlant(primaryControlMax=200)
PowerSystems.Generic.Transformer trafoHydro(ratio=380/10)
PowerSystems.Generic.Impedance linePlant(R=1, L=1/314)
PowerSystems.Generic.Impedance lineWind(R=1, L=1/314)
PowerSystems.Generic.Impedance lineHydro(R=1, L=1/314)
Modelica.Blocks.Sources.RealExpression frequency(y=system.omega/2/pi)
"Average frequency"
inner System system(dynType=PowerSystems.Types.Dynamics.FixedInitial,
fType=PowerSystems.Types.SystemFrequency.Average)
equation
connect(powerPlant.terminal, trafoPlant.terminal_p)
connect(distribution.terminal_n, city.terminal)
connect(windFarm.terminal, HVDC.terminal_dc)
connect(dispatcher.plantDispatch, powerPlant.plantDispatch)
connect(dispatcher.hydroDispatch, hydroPlant.hydroDispatch)
connect(trafoPlant.terminal_n, linePlant.terminal_p)
connect(linePlant.terminal_n, distribution.terminal_p)
connect(HVDC.terminal, lineWind.terminal_p)
connect(lineWind.terminal_n, distribution.terminal_p)
connect(lineHydro.terminal_n, distribution.terminal_p)
connect(frequency.y, dispatcher.frequency)
connect(hydroPlant.terminal, trafoHydro.terminal_n)
connect(trafoHydro.terminal_p, lineHydro.terminal_p)
end PowerWorld;
package Components "Aggregated components for PowerWorld example"
extends Modelica.Icons.VariantsPackage;
model PowerPlant "Thermal Power Plant with primary and secondary control"
extends PowerSystems.Generic.Ports.PartialSource(
final potentialReference=true);
parameter Boolean Modakond = false "Install Modakond for condensate stop"
parameter Real primaryControlMax(unit="MW") = 40
"Maximum power for primary frequency control"
Real P_generator(unit="MW") = -generator.p[1]/1e6;
Real P_control(unit="MW") = -(P_generator - plantDispatch[1]);
PowerSystems.Generic.Generator generator(redeclare package PhaseSystem =
PhaseSystem, definiteReference=definiteReference)
Modelica.Mechanics.Rotational.Components.Inertia rotor(
J=10e6,
a(start=0),
w(fixed=false, start=system.w_nom/generator.pp))
Modelica.Mechanics.Rotational.Sources.Torque turbine
Modelica.Mechanics.Rotational.Sensors.SpeedSensor angularVelocity
Modelica.Blocks.Sources.Constant reference(k=system.f_nom)
Modelica.Blocks.Continuous.LimPID primaryControl(
k=0.05*800/0.2,
controllerType=Modelica.Blocks.Types.SimpleController.P,
yMax=primaryControlMax) "UCTE: df of 200 mHz corresponds to 5% of load"
Modelica.Blocks.Interfaces.RealInput[3] plantDispatch(each unit="MW")
Modelica.Blocks.Math.Add loadControl(k1=1e6/50/2/pi, k2=1e6/50/2/pi)
Modelica.Blocks.Continuous.FirstOrder evaporator(T=60, y_start=490,
initType=Modelica.Blocks.Types.Init.InitialState)
Modelica.Blocks.Continuous.FirstOrder superheater1(T=60, y_start=490,
initType=Modelica.Blocks.Types.Init.InitialState)
Modelica.Blocks.Continuous.FirstOrder superheater2(T=60, y_start=490,
initType=Modelica.Blocks.Types.Init.InitialState)
Modelica.Blocks.Math.Add fuel
Modelica.Blocks.Continuous.TransferFunction transferFunction(b={180,1}, a=
{60,1},
initType=Modelica.Blocks.Types.Init.SteadyState)
"achieve a power ramp of 2% per minute, minus 0.8% tolerance"
Modelica.Blocks.Math.Add add
Modelica.Blocks.Continuous.LimIntegrator hotwellLevel(
k=1,
outMax=10,
outMin=0,
y(unit="m")) "level of hotwell"
Modelica.Blocks.Math.Max on
Modelica.Blocks.Math.Sign condStop
Modelica.Blocks.Math.Min off
Modelica.Blocks.Math.Add accumulation(k2=1e-2, k1=if Modakond then 5e-4 else
0)
Modelica.Blocks.Sources.Constant zero(k=0)
Modelica.Blocks.Continuous.FirstOrder throttleDynamics(T=120, k=-300/800,
initType=Modelica.Blocks.Types.Init.SteadyState)
Modelica.Blocks.Math.Add pressure(k1=300/800)
Modelica.Blocks.Math.Min throttling
Modelica.Blocks.Sources.Constant throttleMin(k=if Modakond then 0 else
Modelica.Constants.inf)
Modelica.Blocks.Sources.Constant throttleReserve(k=if Modakond then 0 else
5)
Modelica.Blocks.Math.Add pressureLoss
Modelica.Blocks.Continuous.Integrator throttleCosts(k=1/365)
Modelica.Blocks.Math.Gain frequency(k=1/(2*pi))
protected
outer System system;
public
Interfaces.Sender sender(w=generator.w, H=0.5*rotor.J*rotor.w^2/800e6)
initial equation
if Connections.isRoot(generator.terminal.theta) then
if system.dynType == Types.Dynamics.SteadyInitial then
rotor.a = 0;
else
rotor.w = system.omega/generator.pp;
end if;
rotor.phi = system.theta/generator.pp;
end if;
equation
connect(sender.sendFreq, system.receiveFreq);
connect(rotor.flange_b, angularVelocity.flange)
connect(primaryControl.y, loadControl.u1)
connect(evaporator.y, superheater1.u)
connect(superheater1.y, superheater2.u)
connect(superheater2.y, loadControl.u2)
connect(loadControl.y, turbine.tau)
connect(turbine.flange, rotor.flange_a)
connect(rotor.flange_b, generator.flange)
connect(fuel.y, evaporator.u)
connect(transferFunction.y, fuel.u2)
connect(add.y, transferFunction.u)
connect(loadControl.u1, add.u2)
connect(accumulation.y, hotwellLevel.u)
connect(loadControl.u1, condStop.u)
connect(condStop.y, on.u1)
connect(condStop.y, off.u2)
connect(zero.y, on.u2)
connect(zero.y, off.u1)
connect(on.y, accumulation.u1)
connect(off.y, accumulation.u2)
connect(primaryControl.y, throttling.u2)
connect(throttleMin.y, throttling.u1)
connect(throttling.y, throttleDynamics.u)
connect(superheater2.y, pressure.u1)
connect(throttleDynamics.y, pressureLoss.u2)
connect(throttleReserve.y, pressureLoss.u1)
connect(pressureLoss.y, pressure.u2)
connect(pressureLoss.y, throttleCosts.u)
connect(plantDispatch[2], add.u1)
connect(plantDispatch[1], fuel.u1)
connect(reference.y, primaryControl.u_s)
connect(angularVelocity.w, frequency.u)
connect(frequency.y, primaryControl.u_m)
connect(generator.terminal, terminal)
end PowerPlant;
model HydroPlant
extends PowerSystems.Generic.Ports.PartialSource(
final potentialReference=true);
parameter Real primaryControlMax(unit="MW") = 200
"Maximum power for primary frequency control"
Real P_generator(unit="MW") = -generator.p[1]/1e6;
Real P_control(unit="MW") = -(P_generator - hydroDispatch[1]);
Modelica.Blocks.Interfaces.RealInput[3] hydroDispatch(each unit="MW")
Modelica.Blocks.Continuous.Integrator reservoirLevel(y_start=10, k=-1/5e4,
y(unit="m"))
Modelica.Mechanics.Rotational.Sources.Torque reservoirTurbine
Modelica.Mechanics.Rotational.Components.Inertia rotor(J=1e6,
a(start=0),
w(fixed=false, start=system.w_nom/generator.pp))
PowerSystems.Generic.Generator generator(redeclare package PhaseSystem =
PhaseSystem, definiteReference=definiteReference)
Modelica.Mechanics.Rotational.Sensors.SpeedSensor angularVelocity
Modelica.Blocks.Sources.Constant reference(k=system.f_nom)
Modelica.Blocks.Continuous.LimPID primaryControl(
k=50/0.2,
controllerType=Modelica.Blocks.Types.SimpleController.P,
yMax=primaryControlMax) "200 mHz corresponds to 50 MW"
Modelica.Blocks.Math.Gain powerControl(k=1e6/50/2/pi)
Modelica.Blocks.Continuous.TransferFunction controlDynamics(a={1,1}, b={1},
initType=Modelica.Blocks.Types.Init.InitialState)
Modelica.Blocks.Math.Add add
Modelica.Blocks.Math.Gain riverControl(k=1e6/50/2/pi)
Modelica.Mechanics.Rotational.Sources.Torque riverTurbine
Modelica.Mechanics.Rotational.Components.Inertia rotorRiver(
J=0.5e6,
a(start=0),
w(fixed=false, start=system.w_nom/generator.pp))
Modelica.Blocks.Math.Gain frequency(k=1/(2*pi))
protected
outer System system;
public
Interfaces.Sender sender(w=generator.w, H=0.5*rotor.J*rotor.w^2/200e6)
initial equation
if Connections.isRoot(generator.terminal.theta) then
if system.dynType == Types.Dynamics.SteadyInitial then
rotor.a = 0;
else
rotor.w = system.omega/generator.pp;
end if;
rotor.phi = system.theta/generator.pp;
end if;
equation
connect(sender.sendFreq, system.receiveFreq);
connect(rotor.flange_b, angularVelocity.flange)
connect(reservoirTurbine.flange, rotor.flange_a)
connect(rotor.flange_b, generator.flange)
connect(powerControl.y, reservoirTurbine.tau)
connect(controlDynamics.y, reservoirLevel.u)
connect(controlDynamics.y, powerControl.u)
connect(add.y, controlDynamics.u)
connect(hydroDispatch[2], add.u2)
connect(hydroDispatch[1], riverControl.u)
connect(riverControl.y, riverTurbine.tau)
connect(reference.y, primaryControl.u_s)
connect(primaryControl.y, add.u1)
connect(riverTurbine.flange, rotorRiver.flange_a)
connect(rotorRiver.flange_b, generator.flange)
connect(angularVelocity.w, frequency.u)
connect(frequency.y, primaryControl.u_m)
connect(generator.terminal, terminal)
end HydroPlant;
model WindFarm
extends PowerSystems.Generic.Ports.PartialSource(
final potentialReference=false, final definiteReference=false);
parameter Boolean cut_out = false
"stop producing energy as wind exceeds cut-out speed of 20-25 m/s"
Modelica.Blocks.Sources.CombiTimeTable wind(
tableName="tab",
fileName=PowerWorldResources + "LoadData.txt",
tableOnFile=true,
table=fill(
0.0,
0,
10))
PowerSystems.Generic.PrescribedPowerSource mills(
redeclare package PhaseSystem = PhaseSystem,
definiteReference = definiteReference)
Modelica.Blocks.Sources.Trapezoid disturbance(
rising=120,
period=86400,
offset=1,
width=1800,
falling=1800,
startTime=20040,
amplitude=if cut_out then -1 else 0)
Modelica.Blocks.Math.Product product
Modelica.Blocks.Math.Gain MW2W(k=1e6)
equation
connect(wind.y[4], product.u2)
connect(disturbance.y, product.u1)
connect(mills.terminal, terminal)
connect(product.y, MW2W.u)
connect(MW2W.y, mills.P)
end WindFarm;
model LoadDispatcher
Modelica.Blocks.Sources.CombiTimeTable data(
tableName="tab",
fileName=PowerWorldResources + "LoadData.txt",
tableOnFile=true,
table=fill(
0.0,
0,
10))
Modelica.Blocks.Interfaces.RealOutput[3] plantDispatch(each unit="MW")
Modelica.Blocks.Interfaces.RealOutput loadForcast(unit="MW")
Modelica.Blocks.Interfaces.RealOutput windForcast(unit="MW")
Modelica.Blocks.Sources.Constant hydroBase(k=25)
Modelica.Blocks.Sources.Constant primaryControl(k=40)
Modelica.Blocks.Interfaces.RealOutput[3] hydroDispatch(each unit="MW")
Modelica.Blocks.Sources.Constant controlHydro(k=200)
Modelica.Blocks.Interfaces.RealInput frequency(unit="Hz")
Modelica.Blocks.Continuous.LimPID secondaryControl( k=60/0.4,
controllerType=Modelica.Blocks.Types.SimpleController.PI,
Ti=600,
yMax=60) "400 mHz corresponds to 60 MW"
Modelica.Blocks.Sources.Constant reference(k=system.f_nom)
Modelica.Blocks.Math.Add3 plantSchedule(k2=-1, k3=-1,
y(unit="MW"))
Modelica.Blocks.Sources.Trapezoid hydroDaily(
rising=86400/4,
width=86400/4,
falling=86400/4,
period=86400,
startTime=86400/8,
amplitude=50,
offset=-25,
y(unit="MW"))
Modelica.Blocks.Math.Add add
Modelica.Blocks.Math.Gain distributionLoss(k=1)
protected
outer System system;
equation
connect(primaryControl.y, plantDispatch[3])
connect(hydroBase.y, hydroDispatch[1])
connect(controlHydro.y, hydroDispatch[3])
connect(data.y[3], windForcast)
connect(secondaryControl.y, plantDispatch[2])
connect(windForcast, plantSchedule.u2)
connect(plantSchedule.y, plantDispatch[1])
connect(hydroDaily.y, hydroDispatch[2])
connect(hydroDaily.y, add.u1)
connect(hydroBase.y, add.u2)
connect(add.y, plantSchedule.u3)
connect(frequency, secondaryControl.u_m)
connect(reference.y, secondaryControl.u_s)
connect(data.y[1], loadForcast)
connect(loadForcast, distributionLoss.u)
connect(distributionLoss.y, plantSchedule.u1)
end LoadDispatcher;
model City
extends PowerSystems.Generic.Ports.PartialLoad;
Modelica.Blocks.Sources.CombiTimeTable data(
tableName="tab",
fileName=PowerWorldResources + "LoadData.txt",
tableOnFile=true,
table=fill(
0.0,
0,
10))
PowerSystems.Generic.PrescribedPowerLoad load(phi=0.34906585039887)
Modelica.Blocks.Math.Gain MW2W(k=1e6)
equation
connect(terminal, load.terminal)
connect(data.y[2], MW2W.u)
connect(MW2W.y, load.P)
end City;
end Components;
package Test "Component tests for PowerWorld example"
extends Modelica.Icons.ExamplesPackage;
model PowerPlantTest1 "Test primary control"
extends Modelica.Icons.Example;
Components.PowerPlant powerPlant
Modelica.Blocks.Sources.Constant schedule(k=450)
PowerSystems.Generic.PrescribedPowerLoad prescribedLoad(phi=
0.34906585039887)
Modelica.Blocks.Sources.Step step(startTime=10,
height=-40,
offset=490)
Modelica.Blocks.Sources.Constant secondary(k=40)
Modelica.Blocks.Sources.Constant primary(k=40)
Modelica.Blocks.Math.Gain MW2W(k=1e6)
inner PowerSystems.System system
equation
connect(powerPlant.terminal, prescribedLoad.terminal)
connect(secondary.y, powerPlant.plantDispatch[2])
connect(schedule.y, powerPlant.plantDispatch[1])
connect(primary.y, powerPlant.plantDispatch[3])
connect(step.y, MW2W.u)
connect(MW2W.y, prescribedLoad.P)
end PowerPlantTest1;
model PowerPlantTest2 "Test secondary control"
extends Modelica.Icons.Example;
Components.PowerPlant powerPlant
Modelica.Blocks.Sources.Constant schedule(k=490)
PowerSystems.Generic.PrescribedPowerLoad prescribedLoad(phi=
0.34906585039887)
Modelica.Blocks.Sources.Ramp ramp(offset=490,
height=48,
duration=180,
startTime=100)
Modelica.Blocks.Sources.Step secondary(height=48, startTime=100)
Modelica.Blocks.Sources.Constant primary(k=40)
Modelica.Blocks.Math.Gain MW2W(k=1e6)
inner PowerSystems.System system
equation
connect(powerPlant.terminal, prescribedLoad.terminal)
connect(schedule.y, powerPlant.plantDispatch[1])
connect(secondary.y, powerPlant.plantDispatch[2])
connect(primary.y, powerPlant.plantDispatch[3])
connect(ramp.y, MW2W.u)
connect(MW2W.y, prescribedLoad.P)
end PowerPlantTest2;
model PowerPlantTest3 "Test connection to a large net"
extends Modelica.Icons.Example;
Components.PowerPlant powerPlant
Modelica.Blocks.Sources.Constant schedule(k=490)
PowerSystems.Generic.FixedVoltageSource largeGrid
Modelica.Blocks.Sources.Ramp secondary(startTime=100,
height=300,
duration=0)
PowerSystems.Generic.Impedance
line(R=1, L=1/314)
Modelica.Blocks.Sources.Constant primary(k=40)
inner PowerSystems.System system
equation
connect(schedule.y, powerPlant.plantDispatch[1])
connect(secondary.y, powerPlant.plantDispatch[2])
connect(powerPlant.terminal, line.terminal_p)
connect(line.terminal_n, largeGrid.terminal)
connect(primary.y, powerPlant.plantDispatch[3])
end PowerPlantTest3;
model HydroPlantTest1 "Test primary control"
extends Modelica.Icons.Example;
Components.HydroPlant hydroPlant(primaryControlMax=310)
Modelica.Blocks.Sources.Constant schedule(k=50)
PowerSystems.Generic.PrescribedPowerLoad prescribedLoad
Modelica.Blocks.Sources.Trapezoid trapezoid(startTime=100,
offset=50,
amplitude=300,
width=300,
falling=300,
nperiod=1,
rising=60,
period=900)
Modelica.Blocks.Sources.Constant primary(k=400)
Modelica.Blocks.Sources.Constant secondary(k=0)
Modelica.Blocks.Math.Gain MW2W(k=1e6)
inner PowerSystems.System system
equation
connect(schedule.y, hydroPlant.hydroDispatch[1])
connect(hydroPlant.terminal, prescribedLoad.terminal)
connect(primary.y, hydroPlant.hydroDispatch[3])
connect(secondary.y, hydroPlant.hydroDispatch[2])
connect(trapezoid.y, MW2W.u)
connect(MW2W.y, prescribedLoad.P)
end HydroPlantTest1;
model HydroPlantTest2 "Test secondary control"
extends Modelica.Icons.Example;
Components.HydroPlant hydroPlant
Modelica.Blocks.Sources.Constant schedule(k=50)
Modelica.Blocks.Sources.Constant primary(k=400)
Modelica.Blocks.Sources.Trapezoid secondary(amplitude=100,
offset=-50,
rising=86400/4,
width=86400/4,
falling=86400/4,
period=86400,
startTime=86400/8)
PowerSystems.Generic.FixedVoltageSource largeGrid
PowerSystems.Generic.Impedance
line(R=1, L=1/314)
inner PowerSystems.System system
equation
connect(schedule.y, hydroPlant.hydroDispatch[1])
connect(primary.y, hydroPlant.hydroDispatch[3])
connect(secondary.y, hydroPlant.hydroDispatch[2])
connect(line.terminal_n, largeGrid.terminal)
connect(hydroPlant.terminal, line.terminal_p)
end HydroPlantTest2;
model WindFarmGridTest "WindFarm connected to a large net"
extends Modelica.Icons.Example;
Components.WindFarm windFarm
PowerSystems.Generic.FixedVoltageSource largeGrid
inner PowerSystems.System system
equation
connect(windFarm.terminal, largeGrid.terminal)
end WindFarmGridTest;
model WindFarmHVDCTest "WindFarm connected to a large net via HVDC"
extends Modelica.Icons.Example;
Components.WindFarm windFarm(redeclare package PhaseSystem =
PowerSystems.PhaseSystems.DirectCurrent)
PowerSystems.Generic.FixedVoltageSource largeGrid
PowerSystems.Generic.Inverter
inverter
inner PowerSystems.System system
equation
connect(windFarm.terminal, inverter.terminal_dc)
connect(inverter.terminal, largeGrid.terminal)
end WindFarmHVDCTest;
model CityTest
extends Modelica.Icons.Example;
PowerSystems.Generic.FixedVoltageSource largeGrid
Components.City city
inner PowerSystems.System system
equation
connect(largeGrid.terminal, city.terminal)
end CityTest;
model LoadDispatcherTest
extends Modelica.Icons.Example;
Components.LoadDispatcher loadDispatcher
Modelica.Blocks.Sources.Trapezoid frequency(amplitude=2,
rising=15,
falling=15,
period=60,
offset=49,
width=15)
inner System system
equation
connect(frequency.y, loadDispatcher.frequency)
end LoadDispatcherTest;
end Test;
constant String PowerWorldResources = Modelica.Utilities.Files.loadResource("modelica://PowerSystems.Examples.PowerWorld/Resources/");
end PowerWorld; |
Different wind turbine concepts | within PowerSystems.Examples;
package Wind "Different wind turbine concepts"
extends Modelica.Icons.ExamplesPackage;
model WindTurbine_IG
"Wind turbine with Induction Generator (asynchronous) -- fixed speed"
extends Modelica.Icons.Example;
PowerSystems.AC3ph.Machines.Asynchron generator(redeclare record Data =
Data.Machines.Asynchron400V_30kVA (
V_nom=690,
S_nom=3e6,
pp=4))
PowerSystems.Common.Thermal.BdCondV bdCond(m=2)
inner System system
PowerSystems.AC3ph.Nodes.BusBar busbar
PowerSystems.AC3ph.Sensors.PVImeter meter(
V_nom(displayUnit="kV") = 1000,
S_nom(displayUnit="MVA") = 1000000)
PowerSystems.AC3ph.Lines.PIline line(len=1000, redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.Line (V_nom=15e3, S_nom=3e6))
PowerSystems.AC3ph.Sources.InfBus infBus(V_nom=15e3)
PowerSystems.AC3ph.Nodes.GroundOne grd
Modelica.Blocks.Sources.Ramp windSpeed(
duration=80,
startTime=10,
offset=3,
height=12)
Components.Rotor rotor(R=40)
PowerSystems.Mechanics.Rotational.Rotor inertia(
J=300, w_start=314/generator.par.pp)
Modelica.Mechanics.Rotational.Components.IdealGear gear(ratio=generator.par.pp
/200)
PowerSystems.AC3ph.Transformers.TrafoIdeal trafo(redeclare record Data =
PowerSystems.AC3ph.Transformers.Parameters.TrafoIdeal (V_nom={690,15e3}, S_nom=3e6))
equation
connect(generator.heat,bdCond. heat)
connect(busbar.term, meter.term_p)
connect(line.term_n,infBus. term)
connect(infBus.neutral,grd. term)
connect(generator.term, busbar.term)
connect(windSpeed.y, rotor.v)
connect(rotor.flange, gear.flange_a)
connect(gear.flange_b,inertia.flange_a)
connect(inertia.flange_b, generator.airgap)
connect(meter.term_n, trafo.term_p)
connect(trafo.term_n, line.term_p)
end WindTurbine_IG;
model WindTurbine_DFIG
"Wind turbine with Doubly Fed Induction Generator (asynchronous) -- variable speed"
extends Modelica.Icons.Example;
PowerSystems.AC3ph.Machines.Asynchron_dfig generator(redeclare record Data =
Data.Machines.Asynchron400V_30kVA (
V_nom=690,
S_nom=3e6,
pp=4))
PowerSystems.Common.Thermal.BdCondV bdCond(m=2)
inner System system
PowerSystems.AC3ph.Nodes.BusBar busbar
PowerSystems.AC3ph.Sensors.PVImeter meter(
V_nom(displayUnit="kV") = 1000,
S_nom(displayUnit="MVA") = 1000000)
PowerSystems.AC3ph.Lines.PIline line(len=1000, redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.Line (V_nom=15e3, S_nom=3e6))
PowerSystems.AC3ph.Sources.InfBus infBus(V_nom=15e3)
PowerSystems.AC3ph.Nodes.GroundOne grd
Modelica.Blocks.Sources.Ramp windSpeed(
duration=80,
startTime=10,
height=12,
offset=3)
Components.Rotor rotor(R=40)
PowerSystems.Mechanics.Rotational.Rotor inertia(J=300, w_start=314/generator.par.pp)
Modelica.Mechanics.Rotational.Components.IdealGear gear(ratio=generator.par.pp
/200)
PowerSystems.AC3ph.Inverters.InverterAverage inverter1
PowerSystems.Common.Thermal.BdCondV bdCond1(m=1)
PowerSystems.AC1ph_DC.Sensors.PVImeter meterDC(av=true, tcst=0.1)
PowerSystems.AC3ph.Inverters.InverterAverage inverter2
PowerSystems.AC3ph.Inverters.Select select2
PowerSystems.Common.Thermal.BdCondV bdCond2(m=1)
Modelica.Blocks.Sources.RealExpression vPhasor_set[2](y={0.5 - min(
windSpeed.y, 15)/20,0.25*windSpeed.y/15})
PowerSystems.AC3ph.Transformers.TrafoIdeal trafo(redeclare record Data =
PowerSystems.AC3ph.Transformers.Parameters.TrafoIdeal (V_nom={690,15e3}, S_nom=3e6))
equation
connect(generator.heat,bdCond. heat)
connect(busbar.term, meter.term_p)
connect(line.term_n,infBus. term)
connect(infBus.neutral,grd. term)
connect(generator.term, busbar.term)
connect(windSpeed.y, rotor.v)
connect(rotor.flange, gear.flange_a)
connect(gear.flange_b, inertia.flange_a)
connect(inertia.flange_b, generator.airgap)
connect(inverter1.heat, bdCond1.heat)
connect(inverter1.AC, generator.term_r)
connect(generator.phiRotor, inverter1.theta)
connect(bdCond2.heat,inverter2. heat)
connect(select2.vPhasor_out,inverter2. vPhasor)
connect(select2.theta_out,inverter2. theta)
connect(inverter2.AC, busbar.term)
connect(inverter1.DC, meterDC.term_p)
connect(meterDC.term_n, inverter2.DC)
connect(meter.term_n, trafo.term_p)
connect(trafo.term_n, line.term_p)
connect(vPhasor_set.y, inverter1.vPhasor)
end WindTurbine_DFIG;
model WindTurbine_PSGR
"Wind turbine with Permanent magnet Synchronous Generator and generator side Rectifier"
extends Modelica.Icons.Example;
Modelica.Blocks.Sources.Ramp windSpeed(
duration=80,
startTime=10,
height=12,
offset=3)
Components.Rotor rotor(R=40)
inner System system
PowerSystems.Mechanics.Rotational.Rotor inertia(J=300, w_start=314/generator.par.pp)
Modelica.Mechanics.Rotational.Components.IdealGear gear(ratio=generator.par.pp
/200)
PowerSystems.AC3ph.Machines.Synchron_pm generator(redeclare record Data =
Data.Machines.Synchron_pm400V_30kVA (
V_nom=690,
S_nom=3e6,
pp=4))
PowerSystems.Common.Thermal.BdCondV bdCond(m=2)
PowerSystems.AC3ph.Inverters.RectifierAverage rectifier1(redeclare record Data =
Semiconductors.Ideal.SCparameter)
PowerSystems.Common.Thermal.BdCondV bdCond1(m=1)
PowerSystems.AC1ph_DC.Sensors.PVImeter meterDC(av=true, tcst=0.1)
PowerSystems.AC3ph.Inverters.InverterAverage inverter2
PowerSystems.AC3ph.Inverters.Select select2
PowerSystems.Common.Thermal.BdCondV bdCond2(m=1)
PowerSystems.AC3ph.Sensors.PVImeter meter(
V_nom(displayUnit="kV") = 1000,
S_nom(displayUnit="MVA") = 1000000)
PowerSystems.AC3ph.Lines.PIline line(len=1000, redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.Line (V_nom=15e3, S_nom=3e6))
PowerSystems.AC3ph.Sources.InfBus infBus(V_nom=15e3)
PowerSystems.AC3ph.Nodes.GroundOne grd
PowerSystems.AC3ph.Nodes.BusBar busbar
PowerSystems.AC3ph.Transformers.TrafoIdeal trafo(redeclare record Data =
PowerSystems.AC3ph.Transformers.Parameters.TrafoIdeal(V_nom={690,15e3}, S_nom=3e6))
PowerSystems.AC3ph.Nodes.DefReference reference
equation
connect(windSpeed.y, rotor.v)
connect(rotor.flange, gear.flange_a)
connect(gear.flange_b,inertia.flange_a)
connect(generator.heat,bdCond.heat)
connect(rectifier1.heat, bdCond1.heat)
connect(inertia.flange_b, generator.airgap)
connect(rectifier1.DC, meterDC.term_p)
connect(meterDC.term_n, inverter2.DC)
connect(bdCond2.heat, inverter2.heat)
connect(select2.vPhasor_out, inverter2.vPhasor)
connect(select2.theta_out, inverter2.theta)
connect(line.term_n,infBus. term)
connect(infBus.neutral,grd. term)
connect(busbar.term, meter.term_p)
connect(inverter2.AC, busbar.term)
connect(meter.term_n, trafo.term_p)
connect(trafo.term_n, line.term_p)
connect(generator.term, reference.term)
connect(reference.term, rectifier1.AC)
connect(generator.phiRotor, reference.theta)
end WindTurbine_PSGR;
model WindTurbine_PSGI
"Wind turbine with Permanent magnet Synchronous Generator and generator side Inverter"
extends Modelica.Icons.Example;
Modelica.Blocks.Sources.Ramp windSpeed(
duration=80,
startTime=10,
height=12,
offset=3)
Components.Rotor rotor(R=40)
inner System system
PowerSystems.Mechanics.Rotational.Rotor inertia(J=300, w_start=314/generator.par.pp)
Modelica.Mechanics.Rotational.Components.IdealGear gear(ratio=generator.par.pp
/200)
PowerSystems.AC1ph_DC.Sensors.PVImeter meterDC(av=true, tcst=0.1)
PowerSystems.AC3ph.Machines.Synchron_pm_ctrl generator(redeclare record Data =
Data.Machines.Synchron_pm400V_30kVA (
V_nom=690,
S_nom=3e6,
pp=4))
PowerSystems.Common.Thermal.BdCondV bdCond(m=2)
PowerSystems.AC3ph.Inverters.InverterAverage inverter1
PowerSystems.Common.Thermal.BdCondV bdCond1(m=1)
PowerSystems.AC3ph.Inverters.InverterAverage inverter2
PowerSystems.AC3ph.Inverters.Select select2
PowerSystems.Common.Thermal.BdCondV bdCond2(m=1)
PowerSystems.AC3ph.Sensors.PVImeter meter(
V_nom(displayUnit="kV") = 1000,
S_nom(displayUnit="MVA") = 1000000)
PowerSystems.AC3ph.Lines.PIline line(len=1000, redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.Line (V_nom=15e3, S_nom=3e6))
PowerSystems.AC3ph.Sources.InfBus infBus(V_nom=15e3)
PowerSystems.AC3ph.Nodes.GroundOne grd
PowerSystems.AC3ph.Nodes.BusBar busbar
PowerSystems.AC3ph.Transformers.TrafoIdeal trafo(redeclare record Data =
PowerSystems.AC3ph.Transformers.Parameters.TrafoIdeal(V_nom={690,15e3}, S_nom=3e6))
Modelica.Blocks.Continuous.PI PI(T=0.5, initType=Modelica.Blocks.Types.Init.SteadyState)
Modelica.Blocks.Sources.RealExpression i_q_err(y=(0.75 + min(windSpeed.y,
15)/12) - inertia.w*generator.par.pp/200)
Modelica.Blocks.Sources.RealExpression i_d_set(y=0)
equation
connect(windSpeed.y, rotor.v)
connect(rotor.flange, gear.flange_a)
connect(gear.flange_b, inertia.flange_a)
connect(generator.heat,bdCond.heat)
connect(generator.term, inverter1.AC)
connect(inverter1.heat, bdCond1.heat)
connect(inverter1.DC, meterDC.term_p)
connect(inertia.flange_b, generator.airgap)
connect(bdCond2.heat,inverter2. heat)
connect(select2.vPhasor_out,inverter2. vPhasor)
connect(select2.theta_out,inverter2. theta)
connect(line.term_n,infBus. term)
connect(infBus.neutral,grd. term)
connect(meterDC.term_n,inverter2. DC)
connect(busbar.term, meter.term_p)
connect(inverter2.AC, busbar.term)
connect(meter.term_n, trafo.term_p)
connect(trafo.term_n, line.term_p)
connect(generator.vPhasor, inverter1.vPhasor)
connect(generator.phiRotor, inverter1.theta)
connect(PI.y, generator.i_act[2])
connect(i_d_set.y, generator.i_act[1])
connect(i_q_err.y, PI.u)
end WindTurbine_PSGI;
model WindFarm "Multiple wind turbines connected together"
extends Modelica.Icons.Example;
inner System system
PowerSystems.AC3ph.Lines.PIline line(len=500, redeclare record Data =
PowerSystems.AC3ph.Lines.Parameters.Line (V_nom=15e3, S_nom=15e6))
PowerSystems.AC3ph.Sources.InfBus infBus(V_nom=15e3)
PowerSystems.AC3ph.Nodes.GroundOne grd
Modelica.Blocks.Sources.Ramp windSpeed(
duration=80,
startTime=10,
height=12,
offset=3)
Components.WindTurbine wt1
Components.WindTurbine wt2
Components.WindTurbine wt3
PowerSystems.AC3ph.Sensors.PVImeter meter(
V_nom(displayUnit="kV") = 1000,
S_nom(displayUnit="MVA") = 1000000)
PowerSystems.AC3ph.Nodes.BusBar busbar
PowerSystems.AC3ph.Lines.PIline line1(
ne=1,
len=100,
redeclare record Data = PowerSystems.AC3ph.Lines.Parameters.Line (V_nom=15e3, S_nom=3e6))
PowerSystems.AC3ph.Lines.PIline line2(
ne=1,
len=100,
redeclare record Data = PowerSystems.AC3ph.Lines.Parameters.Line (V_nom=15e3, S_nom=3e6))
PowerSystems.AC3ph.Lines.PIline line3(
ne=1,
len=100,
redeclare record Data = PowerSystems.AC3ph.Lines.Parameters.Line (V_nom=15e3, S_nom=3e6))
Components.WindTurbine wt4
PowerSystems.AC3ph.Lines.PIline line4(
ne=1,
len=100,
redeclare record Data = PowerSystems.AC3ph.Lines.Parameters.Line (V_nom=15e3, S_nom=3e6))
Components.WindTurbine wt5
PowerSystems.AC3ph.Lines.PIline line5(
ne=1,
len=100,
redeclare record Data = PowerSystems.AC3ph.Lines.Parameters.Line (V_nom=15e3, S_nom=3e6))
equation
connect(line.term_n,infBus. term)
connect(infBus.neutral,grd. term)
connect(windSpeed.y, wt1.windSpeed)
connect(windSpeed.y, wt2.windSpeed)
connect(windSpeed.y, wt3.windSpeed)
connect(busbar.term, meter.term_p)
connect(meter.term_n, line.term_p)
connect(wt2.term, line2.term_p)
connect(line2.term_n, busbar.term)
connect(line1.term_n, busbar.term)
connect(line3.term_n, busbar.term)
connect(wt3.term, line3.term_p)
connect(wt1.term, line1.term_p)
connect(wt4.term, line4.term_p)
connect(wt5.term, line5.term_p)
connect(windSpeed.y, wt4.windSpeed)
connect(windSpeed.y, wt5.windSpeed)
connect(line4.term_n, busbar.term)
connect(line5.term_n, busbar.term)
end WindFarm;
package Components
extends Modelica.Icons.VariantsPackage;
model Rotor "Transformation of wind to mechanical power. See S. Heier, Grid Integration of Wind Energy Conversion Systems, John Wiley & Sons Ltd.,
1998"
parameter Real c1=0.5176;
parameter Real c2=116;
parameter Real c3=0.4;
parameter Real c4=5;
parameter Real c5=21;
parameter Real c6=0.0068;
parameter SI.Angle beta = 0 "Pitch angle of blades (0..20deg)";
parameter SI.Density rho = 1.29 "Density of air";
parameter SI.Radius R = 17 "Rotor length (radius)";
parameter SI.Power P_nom = 1e6 "Nominal power"
SI.Area A = pi*R^2 "Area swept by rotor";
Real Cp "power coefficient";
Real lambda "tip speed ratio";
Real lambdai;
SI.AngularVelocity w = der(flange.phi);
SIpu.Power P(start = 1);
Modelica.Mechanics.Rotational.Interfaces.Flange_b flange(tau(start=-P_nom/10))
Modelica.Blocks.Interfaces.RealInput v(unit="m/s") "wind speed"
equation
0 = P*P_nom + w*flange.tau;
P*P_nom = 0.5*rho*A*v^3*Cp;
Cp=c1*(c2*lambdai-c3*beta-c4)*exp(-c5*lambdai)+c6*lambda;
lambdai = 1/(lambda+0.08*beta) - 0.035/(beta^3 + 1);
lambda = w*R/v;
end Rotor;
model WindTurbine
inner outer System system;
Modelica.Blocks.Interfaces.RealInput windSpeed
PowerSystems.AC3ph.Machines.Asynchron_dfig generator(redeclare record Data =
Data.Machines.Asynchron400V_30kVA (
V_nom=690,
S_nom=3e6,
pp=4))
PowerSystems.Common.Thermal.BdCondV bdCond(m=2)
PowerSystems.AC3ph.Nodes.BusBar busbar
PowerSystems.AC3ph.Sensors.Psensor sensor
Rotor rotor(R=40)
PowerSystems.Mechanics.Rotational.Rotor inertia(J=300, w_start=314/generator.par.pp)
Modelica.Mechanics.Rotational.Components.IdealGear gear(ratio=generator.par.pp
/200)
PowerSystems.AC3ph.Inverters.InverterAverage inverter1
PowerSystems.Common.Thermal.BdCondV bdCond1(m=1)
PowerSystems.AC1ph_DC.Sensors.PVImeter meterDC(av=true, tcst=0.1)
PowerSystems.AC3ph.Inverters.InverterAverage inverter2
PowerSystems.AC3ph.Inverters.Select select2
PowerSystems.Common.Thermal.BdCondV bdCond2(m=1)
PowerSystems.AC3ph.Transformers.TrafoIdeal trafo(redeclare record Data =
PowerSystems.AC3ph.Transformers.Parameters.TrafoIdeal(V_nom={690,15e3}, S_nom=3e6))
PowerSystems.AC3ph.Ports.ACdq0_p term
Modelica.Blocks.Sources.RealExpression vPhasor_set[2](y={0.5 - min(
windSpeed, 15)/20,0.25*windSpeed/15})
equation
connect(generator.heat,bdCond.heat)
connect(busbar.term,sensor.term_p)
connect(generator.term,busbar.term)
connect(rotor.flange,gear.flange_a)
connect(gear.flange_b,inertia.flange_a)
connect(inertia.flange_b,generator.airgap)
connect(inverter1.heat,bdCond1.heat)
connect(inverter1.AC,generator.term_r)
connect(generator.phiRotor,inverter1.theta)
connect(bdCond2.heat,inverter2.heat)
connect(select2.vPhasor_out,inverter2.vPhasor)
connect(select2.theta_out,inverter2.theta)
connect(inverter2.AC,busbar.term)
connect(inverter1.DC,meterDC.term_p)
connect(meterDC.term_n,inverter2.DC)
connect(sensor.term_n,trafo.term_p)
connect(windSpeed, rotor.v)
connect(trafo.term_n, term)
connect(vPhasor_set.y, inverter1.vPhasor)
end WindTurbine;
end Components;
package Test
extends Modelica.Icons.ExamplesPackage;
model RotorTest
extends Modelica.Icons.Example;
Components.Rotor rotor(R=17)
Modelica.Blocks.Sources.Ramp ramp(
duration=80,
startTime=10,
height=15,
offset=10)
Modelica.Mechanics.Rotational.Sources.ConstantSpeed constantSpeed(w_fixed(
displayUnit="rpm") = 6.2831853071796, phi(start=0, fixed=true))
equation
connect(ramp.y, rotor.v)
connect(rotor.flange, constantSpeed.flange)
end RotorTest;
end Test;
end Wind; |
Mechanical components | within PowerSystems;
package Mechanics "Mechanical components"
extends Modelica.Icons.Package;
end Mechanics; |
Rotating parts | within PowerSystems.Mechanics;
package Rotational "Rotating parts "
extends Modelica.Icons.VariantsPackage;
model Speed "Rotation with given angular velocity"
extends Ports.Flange_b;
parameter SI.Time tcst(min=1e-9)=0.1 "time-constant";
parameter Boolean use_w_in = false
"= true if speed defined by input w_in, otherwise by parameter w0"
parameter SI.AngularVelocity w0=1 "angular velocity"
Modelica.Blocks.Interfaces.RealInput w_in(final unit="rad/s") if use_w_in
"(signal ang-velocity)"
protected
SI.AngularVelocity phi_dot;
Modelica.Blocks.Interfaces.RealInput w_internal
"Needed to connect to conditional connector";
equation
connect(w_in, w_internal);
if not use_w_in then
w_internal = w0;
end if;
der(flange.phi) = phi_dot;
der(phi_dot) = (w_internal - phi_dot)/tcst;
end Speed;
model Torque "Driving torque"
extends Ports.Flange_b;
parameter Boolean use_tau_in = false
"= true if torque defined by input tau_in, otherwise by parameter tau0"
parameter SI.Torque tau0=1 "torque"
Modelica.Blocks.Interfaces.RealInput tau_in(final unit="N.m") if use_tau_in
"(signal torque)"
protected
Modelica.Blocks.Interfaces.RealInput tau_internal
"Needed to connect to conditional connector";
equation
connect(tau_in, tau_internal);
if not use_tau_in then
tau_internal = tau0;
end if;
flange.tau = -tau_internal;
end Torque;
model TabTimeTorque "Torque using table (time... torque)"
extends Partials.TabTorque;
parameter SI.Time t_unit=1 "unit of 'time' in tab";
parameter SI.Torque tau_unit=1 "unit of 'torque' in tab";
parameter Real[2] t_bd(unit="s")={0,1} "{first, last} time in tab";
parameter Integer drive_load=1 "driving or load"
parameter Integer direction(min=-1,max=1)=1 "forward or backward in time"
parameter Boolean scale=false "scale time and torque";
parameter SI.Time T=1 "scale duration to T"
parameter SI.Percent tau_scale = 1 "scale tab torque to tau_scale"
protected
SI.Time t;
final parameter SI.Time t_factor=if scale then T/abs(t_bd[2]-t_bd[1]) else t_unit;
final parameter SI.Torque tau_factor=if scale then drive_load*tau_scale*tau_unit else drive_load*tau_unit;
equation
if direction == 1 then
t = t_factor*t_bd[1] + time;
elseif direction == -1 then
t = t_factor*t_bd[2] - time;
else
t = 0;
end if;
table.u = t/t_factor;
tau = tau_factor*table.y[1];
when t > t_factor*t_bd[2] or t < t_factor*t_bd[1] then
terminate("BOUNDARY TIME REACHED!");
end when;
end TabTimeTorque;
model TabPosSlopeTorque "Torque using table (position... slope)"
extends Partials.TabTorque;
constant SI.Force g_n=Modelica.Constants.g_n;
parameter SI.Distance s_unit=1 "unit of 'position' in tab";
parameter Real[2] s_bd(each unit="m")={0,1} "{first, last} position in tab";
parameter Integer dirTrack(min=-1,max=1)=+1 "forward or backward track"
parameter Integer dirVehicle(min=-1,max=1)=+1
"vehicle forward or backward driving"
parameter Boolean scale=false "scale position and slope";
parameter SI.Distance D=1 "scale distance to D"
parameter SI.Percent slope_scale=1 "scale slope to slope_scale"
parameter SI.Mass mass=1 "mass";
parameter Real[2] cFrict(each min=0)={0,0}
"friction cst {lin, quadr} (translation) in {[N.s/m], [N.s2/m2]}";
parameter SI.Radius r=1 "radius wheel";
parameter Real gRatio=1 "gear-ratio";
SI.Distance s;
SI.Velocity vVehicle(start=0) "vehicle horizontal velocity";
protected
final parameter Real s_factor=if scale then D/abs(s_bd[2]-s_bd[1]) else s_unit;
final parameter Real slope_factor=if scale then slope_scale else 1;
final parameter Integer sig=dirTrack*dirVehicle;
Real slope;
Real sin_gam;
SI.Angle phi;
SI.Force f;
constant Real cFrictUnit1(unit="N.s/m") = 1
constant Real cFrictUnit2(unit="N.s2/m2") = 1
initial equation
s = if dirTrack == 1 then s_factor*s_bd[1] else s_factor*s_bd[2];
equation
phi =flange_a.phi;
gRatio*vVehicle = r*der(phi);
r*f = gRatio*tau;
table.u = s/s_factor;
slope = slope_factor*table.y[1];
sin_gam = slope/sqrt(1 + slope*slope); // = sin(atan(slope))
der(s) = sig*vVehicle;
mass*der(vVehicle) = -(f + sig*mass*g_n*sin_gam +
(cFrict[1]*cFrictUnit1 + cFrict[2]*cFrictUnit2*abs(vVehicle))*vVehicle);
when s > s_factor*s_bd[2] or s < s_factor*s_bd[1] then
terminate("BOUNDARY POSITION REACHED!");
end when;
end TabPosSlopeTorque;
model FrictionTorque "Friction torque"
extends Ports.Flange_a;
parameter Real[2] cFrict(each min=0)={0,0}
"friction cst {lin, quadr} in {[N.s/m], [N.s2/m2]}";
SI.Angle phi;
SI.AngularVelocity w;
protected
constant Real cFrictUnit1(unit="N.s/m") = 1
constant Real cFrictUnit2(unit="N.s2/m2") = 1
equation
phi = flange.phi;
w = der(phi);
flange.tau = (cFrict[1]*cFrictUnit1 + cFrict[2]*cFrictUnit2*noEvent(abs(w)))*w;
end FrictionTorque;
model FixedAngle "Flange at fixed angular position"
parameter SI.Angle phi0=0 "angle";
Interfaces.Rotation_p flange
equation
flange.phi = phi0;
end FixedAngle;
model Rotor "Rigid rotating mass"
extends Partials.RigidRotorBase;
equation
J*a =flange_a.tau +flange_b.tau;
end Rotor;
model ThermalTurbineRotor "Thermal turbine rotor"
extends Partials.RigidRotorCase;
end ThermalTurbineRotor;
model HydroTurbineRotor "Hydro turbine rotor"
extends Partials.RigidRotorCase;
end HydroTurbineRotor;
model DieselRotor "Diesel rotor"
extends Partials.RigidRotorCase;
end DieselRotor;
model WindTurbineRotor "Wind turbine rotor"
extends Partials.RigidRotorCase;
end WindTurbineRotor;
model ElectricRotor "Electric generator/motor rotor, mechanical"
extends Partials.RigidRotorCase;
end ElectricRotor;
model ShaftNoMass "Elastic massless shaft"
extends Ports.Compliant;
parameter SI.TorsionStiffness stiff=1e6 "torsion stiffness";
equation
flange_a.tau
+flange_b.tau = 0;
d_tau = stiff*d_phi;
end ShaftNoMass;
model Shaft "Elastic massive shaft"
extends Ports.Compliant;
parameter SI.Inertia J=1 "inertia";
parameter SI.TorsionStiffness stiff=1e6 "torsion stiffness";
SI.Angle phi(stateSelect=StateSelect.prefer) "rotation angle center";
SI.AngularVelocity w(stateSelect=StateSelect.prefer);
SI.AngularAcceleration a;
equation
flange_a.phi
+flange_b.phi = 2*phi;
w = der(phi);
a = der(w);
J*a =flange_a.tau +flange_b.tau;
d_tau = stiff*d_phi;
end Shaft;
model GearNoMass "Massless gear"
extends Ports.Flange_a_b;
parameter Real[:] ratio={1,1}
"gear-ratio {p, .., n}, (speeds in arbitrary units)";
protected
final parameter Real ratio_pn=ratio[1]/ratio[end];
equation
flange_a.phi
= ratio_pn*flange_b.phi;
ratio_pn*flange_a.tau +flange_b.tau = 0;
end GearNoMass;
model Gear "Massive gear"
extends Ports.Flange_a_b;
parameter Real[:] ratio={1,1}
"gear-ratio {p, .., n}, (speeds in arbitrary units)";
parameter SI.Inertia[:] J={1,1} "inertias {p, .., n}, (not reduced)";
SI.Angle phi(stateSelect=StateSelect.prefer);
SI.AngularVelocity w(stateSelect=StateSelect.prefer);
SI.AngularAcceleration a;
protected
final parameter Real ratio_pn=ratio[1]/ratio[end];
final parameter Real[size(ratio,1)] ratio2=diagonal(ratio)*ratio/(ratio[end]*ratio[end]);
equation
flange_a.phi
= ratio_pn*flange_b.phi;
phi =flange_b.phi;
w = der(phi);
a = der(w);
(ratio2*J)*a = ratio_pn*flange_a.tau +flange_b.tau;
end Gear;
model NoGear "Placeholder for gear"
extends Ports.Flange_a_b;
equation
flange_a.phi = flange_b.phi;
flange_a.tau + flange_b.tau = 0;
end NoGear;
model AngleSensor "Angle and angular velocity sensor (mechanical)"
extends Ports.Flange_a;
Modelica.Blocks.Interfaces.RealOutput phi "angle"
Modelica.Blocks.Interfaces.RealOutput w "angular velocity"
equation
flange.tau = 0;
phi = flange.phi;
w = der(flange.phi);
end AngleSensor;
model PowerSensor "Power and torque sensor (mechanical)"
extends Ports.Rigid;
Modelica.Blocks.Interfaces.RealOutput p "power, flange_a to flange_b"
Modelica.Blocks.Interfaces.RealOutput tau "torque, flange_a to flange_b"
equation
flange_a.tau + flange_b.tau = 0;
tau = flange_a.tau;
p = der(flange_a.phi)*flange_a.tau;
end PowerSensor;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model TabTorque "Table data to torque"
extends Ports.Flange_a_b;
parameter String tableName="" "table name in file";
parameter String fileName=TableDir + "" "name of file containing table";
parameter Integer colData=2 "column # used data";
SI.Torque tau;
Modelica.Blocks.Tables.CombiTable1Ds table(
final tableName=tableName,
final fileName=fileName,
final columns={colData},
tableOnFile=true) "{time t .. force f ..}"
equation
flange_a.phi =flange_b.phi;
flange_a.tau +flange_b.tau + tau = 0;
end TabTorque;
partial model RigidRotorBase "Rigid rotor base"
extends Ports.Rigid;
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter SI.Inertia J=1 "inertia";
parameter SI.AngularVelocity w_start = 0
"start value of angular velocity"
SI.Angle phi "rotation angle absolute";
SI.AngularVelocity w(start = w_start);
SI.AngularAcceleration a;
protected
outer System system;
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(w) = 0;
else
w = w_start;
end if;
equation
phi =flange_a.phi;
w = der(phi);
a = der(w);
end RigidRotorBase;
partial model RigidRotorCase "Rigid rotor with case"
extends RigidRotorBase;
Interfaces.Rotation_p rotor
"connector to turbine (mech) or airgap (el) torque"
Interfaces.Rotation_p stator "access for stator reaction moment"
Interfaces.Rotation_n friction "access for friction model"
equation
if cardinality(stator) == 0 then
stator.phi = 0;
else
rotor.tau + stator.tau + friction.tau = 0;
end if;
rotor.phi = phi - stator.phi;
friction.phi = rotor.phi;
J*a = rotor.tau +flange_a.tau +flange_b.tau + friction.tau;
end RigidRotorCase;
end Partials;
package Ports "One- and two-flange base for rotating mechanical components."
extends Modelica.Icons.InterfacesPackage;
partial model Flange_a "One flange, side a"
Interfaces.Rotation_p flange "positive flange"
end Flange_a;
partial model Flange_b "One flange, side b"
Interfaces.Rotation_n flange "negative flange"
end Flange_b;
partial model Flange_a_b "Two flange"
Interfaces.Rotation_p flange_a "flange side a"
Interfaces.Rotation_n flange_b "flange side b"
end Flange_a_b;
partial model Rigid "Rigid two-flange"
extends Flange_a_b;
equation
flange_a.phi
=flange_b.phi;
end Rigid;
partial model Compliant "Compliant two-flange"
extends Flange_a_b;
SI.Angle d_phi "difference angle (twist)";
SI.Torque d_tau "twisting torque";
equation
flange_b.phi
-flange_a.phi = d_phi;
flange_b.tau
-flange_a.tau = 2*d_tau;
end Compliant;
end Ports;
end Rotational; |
Turbines including generator-rotor | within PowerSystems.Mechanics;
package TurboGroups "Turbines including generator-rotor"
extends Modelica.Icons.VariantsPackage;
model FixedSpeedTG "Fixed speed turbo-generator rotor"
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter SI.AngularVelocity w_start=0 "initial rotor angular velocity"
parameter SI.AngularVelocity w_nom=1 "nominal angular velocity"
Interfaces.Rotation_n airgap "to airgap electric machine"
Modelica.Blocks.Interfaces.RealInput power(
final unit="1") "turbine power pu"
Modelica.Blocks.Interfaces.RealOutput speed(
final unit="1") "turbine speed pu"
protected
outer System system;
SI.Angle phi(stateSelect=StateSelect.prefer);
SI.AngularVelocity w(start=w_start, stateSelect=StateSelect.prefer);
initial equation
if dynType <> Types.Dynamics.SteadyInitial then
w = w_start;
end if;
equation
phi = airgap.phi;
w = der(phi);
0 = der(w);
speed = w/w_nom;
end FixedSpeedTG;
model SingleMassTG "Single mass turbo-generator rotor"
parameter Types.Dynamics dynType=system.dynType "transient or steady-state model"
parameter SIpu.AngularVelocity speed_thr(unit="1")=0.5
"threshold: torque ctrl \\ power ctrl";
parameter SI.Time H=1 "inertia constant turbine + generator";
parameter SI.AngularVelocity w_start=0 "initial rotor angular velocity"
parameter SI.AngularVelocity w_nom=1 "nominal angular velocity"
parameter SI.Power P_nom=1 "nominal power turbine"
Interfaces.Rotation_n airgap "to airgap electric machine"
Modelica.Blocks.Interfaces.RealInput power(
final unit="1") "turbine power pu"
Modelica.Blocks.Interfaces.RealOutput speed(
final unit="1") "turbine speed pu"
protected
outer System system;
final parameter SI.Inertia J=2*H*P_nom/(w_nom*w_nom)
"inertia turbine + generator";
final parameter SI.Torque tau_nom=P_nom/w_nom;
SI.Angle phi(stateSelect=StateSelect.prefer);
SI.AngularVelocity w(start=w_start, stateSelect=StateSelect.prefer);
SI.AngularAcceleration a(start=0);
Real tau_pu(unit="1");
initial equation
if dynType == Types.Dynamics.SteadyInitial then
der(w) = 0;
else
w = w_start;
end if;
equation
max(speed_thr, speed)*tau_pu = power;
phi = airgap.phi;
w = der(phi);
a = der(w);
J*a = tau_pu*tau_nom + airgap.tau;
speed = w/w_nom;
end SingleMassTG;
model SteamTurboGroup "Steam turbo-group with generator-rotor"
extends Partials.TurboBase1(final n=size(par.P_nom,1));
replaceable record Data =
PowerSystems.Mechanics.TurboGroups.Parameters.SteamTurboGroup
"turbo-group par"
final parameter Data par "turbo-group par"
Rotational.ElectricRotor genRotor(
J=par.J_gen,
w(start=w_start),
a(start=0))
SI.Angle[n] delta "difference angles";
protected
Rotational.Rotor aux1(J=par.J_aux[1])
Rotational.ShaftNoMass shaft1(stiff=par.stiff[1])
Rotational.ThermalTurbineRotor turbine1(J=par.J_turb[1])
Rotational.ShaftNoMass shaft2(stiff=par.stiff[2])
Rotational.ThermalTurbineRotor turbine2(J=par.J_turb[2])
Rotational.ShaftNoMass shaft3(stiff=par.stiff[3])
Rotational.ThermalTurbineRotor turbine3(J=par.J_turb[3])
Rotational.ShaftNoMass shaft4(stiff=par.stiff[4])
Rotational.ThermalTurbineRotor turbine4(J=par.J_turb[4])
Rotational.ShaftNoMass shaft5(stiff=par.stiff[5])
Rotational.ShaftNoMass shaft6(stiff=par.stiff[6])
Rotational.Rotor aux2(J=par.J_aux[2])
initial equation
aux1.w = turbine1.w;
aux1.a = turbine1.a;
turbine1.w = turbine2.w;
turbine1.a = turbine2.a;
turbine2.w = turbine3.w;
turbine2.a = turbine3.a;
turbine3.w = turbine4.w;
turbine3.a = turbine4.a;
turbine4.w = genRotor.w;
turbine4.a = genRotor.a;
genRotor.w = aux2.w;
genRotor.a = aux2.a;
equation
delta = {turbine2.flange_a.phi-turbine1.flange_b.phi,turbine3.flange_a.phi -turbine2.flange_b.phi,
turbine4.flange_a.phi-turbine3.flange_b.phi,genRotor.flange_a.phi -turbine4.flange_b.phi};
connect(aux1.flange_b,shaft1.flange_a)
connect(shaft1.flange_b,turbine1.flange_a)
connect(turbine1.flange_b,shaft2.flange_a)
connect(shaft2.flange_b,turbine2.flange_a)
connect(turbine2.flange_b,shaft3.flange_a)
connect(shaft3.flange_b,turbine3.flange_a)
connect(turbine3.flange_b,shaft4.flange_a)
connect(shaft4.flange_b,turbine4.flange_a)
connect(turbine4.flange_b,shaft5.flange_a)
connect(shaft5.flange_b,genRotor.flange_a)
connect(genRotor.flange_b,shaft6.flange_a)
connect(shaft6.flange_b,aux2.flange_a)
connect(blades[1], turbine1.rotor)
connect(blades[2], turbine2.rotor)
connect(blades[3], turbine3.rotor)
connect(blades[4], turbine4.rotor)
connect(airgap, genRotor.rotor)
end SteamTurboGroup;
model GasTurbineGear "Gas turbine with gear and generator-rotor"
extends Partials.TurboBase1(final n=size(par.P_nom,1));
replaceable record Data =
PowerSystems.Mechanics.TurboGroups.Parameters.GasTurbineGear
"turbo-group par"
final parameter Data par "turbo-group par"
Rotational.ElectricRotor genRotor(
J=par.J_gen,
w(start=w_start*par.ratio[end]/par.ratio[1]),
a(start=0))
protected
Rotational.ThermalTurbineRotor turbine(J=par.J_turb)
Rotational.ShaftNoMass shaft1(stiff=par.stiff_sh[1])
Rotational.ThermalTurbineRotor compressor(J=par.J_comp)
Rotational.ShaftNoMass shaft2(stiff=par.stiff_sh[2])
Rotational.Gear gear1(ratio=par.ratio[1:2], J=par.J_gear1)
Rotational.ShaftNoMass shaft3(stiff=par.stiff_sh[3])
Rotational.Gear gear2(ratio=par.ratio[2:3], J=par.J_gear2)
Rotational.ShaftNoMass shaft4(stiff=par.stiff_sh[4])
Rotational.Rotor accessory(J=par.J_acc)
Rotational.ShaftNoMass shaft5(stiff=par.stiff_sh[5])
Rotational.Shaft coupling(J=par.J_cpl, stiff=par.stiff_cpl)
Rotational.ShaftNoMass shaft6(stiff=par.stiff_sh[6])
initial equation
turbine.w = compressor.w;
turbine.a = compressor.a;
compressor.w = (par.ratio[1]/par.ratio[2])*gear1.w;
compressor.a = (par.ratio[1]/par.ratio[2])*gear1.a;
gear1.w = (par.ratio[2]/par.ratio[3])*gear2.w;
gear1.a = (par.ratio[2]/par.ratio[3])*gear2.a;
gear2.w = accessory.w;
gear2.a = accessory.a;
accessory.w = coupling.w;
accessory.a = coupling.a;
coupling.w = genRotor.w;
coupling.a = genRotor.a;
equation
connect(turbine.flange_b,shaft1.flange_a)
connect(compressor.flange_b,shaft1.flange_b)
connect(compressor.flange_a,shaft2.flange_a)
connect(shaft2.flange_b,gear1.flange_a)
connect(gear1.flange_b,shaft3.flange_a)
connect(shaft3.flange_b,gear2.flange_a)
connect(gear2.flange_b,shaft4.flange_a)
connect(shaft4.flange_b,accessory.flange_a)
connect(accessory.flange_b,shaft5.flange_a)
connect(shaft5.flange_b,coupling.flange_a)
connect(coupling.flange_b,shaft6.flange_a)
connect(shaft6.flange_b,genRotor.flange_a)
connect(blades[1], turbine.rotor)
connect(blades[2], compressor.rotor)
connect(airgap, genRotor.rotor)
end GasTurbineGear;
model HydroTurbine "Hydro turbine with generator-rotor"
extends Partials.TurboBase2(final n=1);
replaceable record Data =
PowerSystems.Mechanics.TurboGroups.Parameters.HydroTurbine
"hydro-turbine par"
final parameter Data par "hydro-turbine par"
Rotational.ElectricRotor genRotor(
J=par.J_gen,
w(start=w_start),
a(start=0))
protected
Rotational.HydroTurbineRotor turbine(J=par.J_turb)
Rotational.Shaft shaft(J=par.J_shaft, stiff=par.stiff)
initial equation
turbine.w = shaft.w;
der(turbine.w) = der(shaft.w);
shaft.w = genRotor.w;
der(shaft.w) = der(genRotor.w);
equation
connect(turbine.flange_b,shaft.flange_a)
connect(shaft.flange_b,genRotor.flange_a)
connect(blades[1], turbine.rotor)
connect(airgap, genRotor.rotor)
end HydroTurbine;
model Diesel "Diesel with generator-rotor"
extends Partials.TurboBase3(final n=1); // annotation 0;
replaceable record Data =
PowerSystems.Mechanics.TurboGroups.Parameters.Diesel "Diesel par"
final parameter Data par "Diesel par"
Rotational.ElectricRotor genRotor(
J=par.J_gen,
w(start=w_start),
a(start=0))
protected
Rotational.DieselRotor diesel(J=par.J_turb)
Rotational.ShaftNoMass shaft(stiff=par.stiff)
initial equation
diesel.w = genRotor.w;
der(diesel.w) = der(genRotor.w);
equation
connect(diesel.flange_b,shaft.flange_a)
connect(shaft.flange_b,genRotor.flange_a)
connect(blades[1], diesel.rotor)
connect(airgap, genRotor.rotor)
end Diesel;
model WindTurbineGear "Wind turbine with gear and generator-rotor"
extends Partials.TurboBase4(final n=1);
replaceable record Data =
PowerSystems.Mechanics.TurboGroups.Parameters.WindTurbineGear
"turbine par"
final parameter Data par "turbine par"
Rotational.ElectricRotor genRotor(
J=par.J_gen,
w(start=w_start*par.ratio[end]/par.ratio[1]),
a(start=0))
protected
final parameter Real[3] gr2=diagonal(par.ratio)*par.ratio/par.ratio[end]^2;
final parameter SI.Inertia J_red=par.J_turb*gr2[1] + par.J_gear*gr2 + par.J_gen
"gear reduced inertia";
Rotational.WindTurbineRotor turbine(J=par.J_turb)
Rotational.ShaftNoMass shaft1(stiff=par.stiff_sh[1])
Rotational.Gear gear(J=par.J_gear, ratio=par.ratio)
Rotational.ShaftNoMass shaft2(stiff=par.stiff_sh[2])
initial equation
turbine.w = (par.ratio[1]/par.ratio[end])*gear.w;
der(turbine.w) = (par.ratio[1]/par.ratio[end])*der(gear.w);
gear.w = genRotor.w;
der(gear.w) = der(genRotor.w);
equation
connect(turbine.flange_b,shaft1.flange_a)
connect(shaft1.flange_b,gear.flange_a)
connect(gear.flange_b,shaft2.flange_a)
connect(airgap, genRotor.rotor)
connect(blades[1], turbine.rotor)
connect(shaft2.flange_b,genRotor.flange_a)
end WindTurbineGear;
model PcontrolTorque "Turbine torque from power control"
parameter SI.AngularVelocity w_nom = 314.159265358979323846
"nom r.p.m. turbine"
parameter SI.Power[:] P_nom={1} "nom power turbines"
parameter SIpu.AngularVelocity speed_thr(unit="1")=0.5
"threshold torque ctrl \\ power ctrl";
SI.Angle phi;
SIpu.Torque tau_pu(unit="1");
Modelica.Blocks.Interfaces.RealInput power(
final unit="1") "power pu"
Modelica.Blocks.Interfaces.RealOutput speed(
final unit="1") "angular velocity pu"
Interfaces.Rotation_n[ n] blades "to turbine model"
protected
final parameter Integer n=size(P_nom,1) "number of turbines"
final parameter SI.Torque[n] tau_nom=P_nom/w_nom "nom torque"
equation
max(speed_thr, speed)*tau_pu = power;
phi=blades[end].phi;
for k in 1:n loop
blades[k].tau = -tau_pu*tau_nom[k];
end for;
speed = der(phi)/w_nom;
end PcontrolTorque;
model WindTabTorque "Turbine torque, table {speed, torque pu}"
parameter SI.AngularVelocity w_nom = 314.159265358979323846
"nom r.p.m. turbine"
parameter SI.Power P_nom=1 "nom power turbine"
parameter String tableName="torque" "table name in file";
parameter String fileName=TableDir+"WindTorque.tab"
"name of file containing table";
Modelica.Blocks.Tables.CombiTable1Ds table(table=[0,0,1; 0,1,1],
final tableName=tableName,
final fileName=fileName,
columns={2},
final tableOnFile=true) "{wind speed m/s, torque pu}"
Interfaces.Rotation_n blades "to turbine model"
Modelica.Blocks.Interfaces.RealInput windSpeed "wind speed"
protected
final parameter SI.Torque tau_nom=P_nom/w_nom "nom torque"
equation
blades.tau = -table.y[1]*tau_nom;
connect(windSpeed, table.u)
end WindTabTorque;
package Parameters "Parameter data for interactive use"
extends Modelica.Icons.BasesPackage;
record SteamTurboGroup "Steam turbo-group parameters"
extends Modelica.Icons.Record;
parameter SI.AngularVelocity w_nom = 314.159265358979323846
"nom r.p.m. turbines"
parameter SI.Power[:] P_nom={500e6,250e6,250e6,250e6} "nom power turbines"
parameter SI.Inertia[size(P_nom,1)] J_turb={20000,200000,200000,200000}
"inertia turbines";
parameter SI.Inertia J_gen=70000 "inertia generator";
parameter SI.Inertia[:] J_aux={500,1000} "inertia auxiliaries";
parameter SI.Stiffness[size(J_turb,1)+size(J_aux,1)] stiff={250,350,750,750,750,250}*1e6
"stiffness shafts";
end SteamTurboGroup;
record GasTurbineGear "Turbo-group parameters"
extends Modelica.Icons.Record;
parameter SI.AngularVelocity w_nom = 1576.7653528367 "nom r.p.m. turbine"
parameter SI.Power[:] P_nom={12, -2}*1e6 "nom power {turbine, compressor}"
parameter SI.Inertia J_turb=40 "inertia turbine";
parameter SI.Inertia J_comp=50 "inertia compressor";
parameter SI.Inertia[2] J_gear1={0.6,12} "inertias gear1";
parameter SI.Inertia[2] J_gear2={5,200} "inertias gear2";
parameter SI.Inertia J_acc=6 "inertia accessory";
parameter SI.Inertia J_cpl=40 "inertia coupling";
parameter SI.Inertia J_gen=2500 "inertia generator";
parameter Real[3] ratio={15057,5067,1500} "gear ratio";
parameter SI.Stiffness[6] stiff_sh={3,5.5,100,2500,250,200}*1e6
"stiffness shafts";
parameter SI.TorsionStiffness stiff_cpl=130*1e6 "stiffness coupling";
end GasTurbineGear;
record HydroTurbine "Turbo-group parameters"
extends Modelica.Icons.Record;
parameter SI.AngularVelocity w_nom = 314.159265358979323846
"nom r.p.m. turbine"
parameter SI.Power P_nom=20e6 "nom power turbine"
parameter SI.Inertia J_turb=1000 "inertia turbines";
parameter SI.Inertia J_shaft=5 "inertia shaft";
parameter SI.Inertia J_gen=500 "inertia generator";
parameter SI.TorsionStiffness stiff=300e6 "stiffness shaft";
end HydroTurbine;
record Diesel "Turbo-group parameters"
extends Modelica.Icons.Record;
parameter SI.AngularVelocity w_nom = 157.07963267949 "nom r.p.m. Diesel"
parameter SI.Power P_nom=100e3 "nom power diesel"
parameter SI.Inertia J_turb=20 "inertia diesel";
parameter SI.Inertia J_gen=20 "inertia generator";
parameter SI.TorsionStiffness stiff=1e6 "stiffness shaft";
end Diesel;
record WindTurbineGear "Turbo-group parameters"
extends Modelica.Icons.Record;
parameter SI.AngularVelocity w_nom=1.0471975511966 "nom r.p.m. turbine"
parameter SI.Power P_nom=1e6 "nom power turbine"
parameter SI.Inertia J_turb=30 "inertia turbine";
parameter SI.Inertia[3] J_gear={30,2,0.1} "inertias gear";
parameter SI.Inertia J_gen=450 "inertia generator";
parameter Real ratio[3]={10,100,1000} "gear ratio";
parameter SI.TorsionStiffness[2] stiff_sh={16,1}*1e6 "stiffness shafts";
end WindTurbineGear;
end Parameters;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model TurboBase "Turbine-generator rotor base "
parameter SI.AngularVelocity w_start=0 "initial rotor angular velocity";
parameter Integer n=1 "number of turbines";
Interfaces.Rotation_p[ n] blades "to turbine torque model"
Interfaces.Rotation_n airgap "to airgap electric machine"
protected
outer System system;
end TurboBase;
partial model TurboBase1 "Turbine-generator rotor base "
extends Partials.TurboBase;
end TurboBase1;
partial model TurboBase2 "Turbine-generator rotor base "
extends Partials.TurboBase;
end TurboBase2;
partial model TurboBase3 "Turbine-generator rotor base "
extends Partials.TurboBase;
end TurboBase3;
partial model TurboBase4 "Turbine-generator rotor base "
extends Partials.TurboBase;
end TurboBase4;
end Partials;
end TurboGroups; |
Custom models | within PowerSystems.Semiconductors;
package Custom "Custom models"
extends Modelica.Icons.VariantsPackage;
record SCparameter "Custom semiconductor parameters"
extends Common.Nominal.NominalDataVI;
end SCparameter;
model Diode "Diode"
extends Partials.ComponentBase;
parameter SCparameter par "parameters"
protected
constant Real unitAmperePerVolt(unit="A/V") = 1
equation
i = v*unitAmperePerVolt; // replace!
end Diode;
model SCswitch "IGBT"
extends Partials.ComponentBase;
parameter SCparameter par "parameters"
Modelica.Blocks.Interfaces.BooleanInput gate "true:on, false: off"
protected
constant Real unitAmperePerVolt(unit="A/V") = 1
equation
i = v*unitAmperePerVolt; // replace!
end SCswitch;
model Thyristor "Thyristor"
extends Partials.ComponentBase;
parameter SCparameter par "parameters"
Modelica.Blocks.Interfaces.BooleanInput gate "true:on, false: off"
protected
constant Real unitAmperePerVolt(unit="A/V") = 1
equation
i = v*unitAmperePerVolt; // replace!
end Thyristor;
end Custom; |
Custom models | within PowerSystems.Semiconductors;
package Ideal "Custom models"
extends Modelica.Icons.VariantsPackage;
record SCparameter "Ideal semiconductor parameters"
extends Common.Nominal.NominalDataVI;
parameter Real[2] eps(final min={0,0}, each final unit="1")={1e-4,1e-4}
"{resistance 'on', conductance 'off'}";
parameter SI.Voltage Vf(final min=0)=0 "forward threshold-voltage"
parameter SI.Heat Hsw_nom=0 "switching loss at V_nom, I_nom (av on off)"
parameter Real[:] cT_loss=fill(0,0) "{cT1,cT2,...} T-coef thermal losses"
parameter SI.Temperature T0_loss=300 "reference T for cT_loss expansion"
end SCparameter;
partial model IdealCharacteristic "Ideal diode characteristic"
extends Partials.ComponentBase;
parameter Ideal.SCparameter par "ideal with forward Vf"
protected
constant Real unitAmperePerVolt(unit="A/V") = 1
Boolean on(start = false);
Real s(start = 0.5) "auxiliary variable";
SI.Voltage V "forward threshold voltage";
SI.Current i_sc = i*par.V_nom/par.I_nom*unitAmperePerVolt
"current scaled to voltage";
function loss = Utilities.Math.taylor
"spec loss function of temperature";
equation
V = if size(par.cT_loss,1)==0 then par.Vf else par.Vf*loss(T - par.T0_loss, par.cT_loss);
{v,i_sc} = if on then {par.eps[1]*s + (1 - par.eps[1])*V,s - (1 - par.eps[2])*V} else {s,par.eps[2]*s};
end IdealCharacteristic;
model Diode "Diode"
extends IdealCharacteristic;
equation
on = s > V;
end Diode;
model Thyristor "Thyristor"
extends IdealCharacteristic;
extends Partials.GateInput;
equation
on = s > V and (pre(on) or gate);
end Thyristor;
model SCswitch "Semiconductor switch"
extends IdealCharacteristic;
extends Partials.GateInput;
equation
on = s > V and gate;
end SCswitch;
model SCswitch_Diode "Semiconductor switch with reverse Diode"
extends Partials.ComponentBase;
extends Partials.GateInput;
parameter SCparameter par "ideal with forward Vf"
protected
constant Real unitAmperePerVolt(unit="A/V") = 1
Real s(start = 0.5) "auxiliary variable";
SI.Voltage V "forward threshold voltage";
SI.Current i_sc = i*par.V_nom/par.I_nom*unitAmperePerVolt
"current scaled to voltage";
function loss = Utilities.Math.taylor
"spec loss function of temperature";
equation
V = if size(par.cT_loss,1)>0 then par.Vf*loss(T -par.T0_loss, par.cT_loss) else par.Vf;
if gate then
if s > V then
{v, i_sc} = {par.eps[1]*s + (1 - par.eps[1])*V,s - (1 - par.eps[2])*V};
elseif s < -V then
{v, i_sc} = {par.eps[1]*s - (1 - par.eps[1])*V,s + (1 - par.eps[2])*V};
else
{v, i_sc} = {s,par.eps[2]*s};
end if;
else
{v, i_sc} = if s < - V then {par.eps[1]*s - (1 - par.eps[1])*V, s + (1 - par.eps[2])*V} else {s,par.eps[2]*s};
end if;
end SCswitch_Diode;
end Ideal; |
Semiconductors | within PowerSystems;
package Semiconductors "Semiconductors"
extends Modelica.Icons.Package;
end Semiconductors; |
Partial models | within PowerSystems.Semiconductors;
package Partials "Partial models"
extends Modelica.Icons.BasesPackage;
partial model ComponentBase "Semiconductor component base"
SI.Voltage v "voltage";
SI.Current i "current";
Interfaces.Electric_p term_p "positive terminal"
Interfaces.Electric_n term_n "negative terminal"
Interfaces.Thermal_n heat "source dissipated heat power"
protected
SI.Temperature T "component temperature";
equation
term_p.i + term_n.i = 0;
v = term_p.v - term_n.v;
i = term_p.i;
T = heat.T;
heat.Q_flow = -v*i;
end ComponentBase;
partial model GateInput "Provide gate input for active components"
Modelica.Blocks.Interfaces.BooleanInput gate "true:on, false: off"
end GateInput;
partial model AC1ph_DC_base "AC(scalar)-DC base"
extends PowerSystems.Icons.Inverter;
Interfaces.Electric_n AC "AC scalar connection"
AC1ph_DC.Ports.TwoPin_p DC "DC connection"
Interfaces.Thermal_n heat
end AC1ph_DC_base;
end Partials; |
Phase modules | within PowerSystems.Semiconductors;
package PhaseModules "Phase modules"
extends Modelica.Icons.VariantsPackage;
model DiodeModule "Diode module"
extends Partials.AC1ph_DC_base;
/*replaceable package SCpackage=Semiconductors.Ideal "SC package"*/
parameter Semiconductors.Ideal/*SCpackage*/.SCparameter par "SC parameters"
PowerSystems.AC1ph_DC.Nodes.Electric_pn_p_n pn_p_n
Semiconductors.Ideal/*SCpackage*/.Diode diode1(final par=par) "diode DC_p"
Semiconductors.Ideal/*SCpackage*/.Diode diode2(final par=par) "diode DC_n"
equation
connect(AC,diode1. term_p)
connect(diode1.term_n, pn_p_n.term_p)
connect(pn_p_n.term_n,diode2. term_p)
connect(diode2.term_n, AC)
connect(pn_p_n.term_pn, DC)
connect(diode1.heat, heat)
connect(diode2.heat, heat)
end DiodeModule;
model SwitchModule "Switch module"
extends Partials.AC1ph_DC_base;
/*replaceable package SCpackage=Semiconductors.Ideal "SC package"*/
replaceable model Switch = PowerSystems.Semiconductors.Ideal/*SCpackage*/.SCswitch_Diode
constrainedby PowerSystems.Semiconductors.Partials.GateInput
parameter Semiconductors.Ideal/*SCpackage*/.SCparameter par "SC parameters"
Modelica.Blocks.Interfaces.BooleanInput[2] gates "gate-pair p and n"
Blocks.Multiplex.Gate2demux gate2demux(final n=1)
PowerSystems.AC1ph_DC.Nodes.Electric_pn_p_n pn_p_n
Switch switch1(final par=par) "switch DC_p"
Switch switch2(final par=par) "switch DC_n"
equation
connect(AC, switch1.term_n)
connect(switch1.term_p, pn_p_n.term_p)
connect(AC, switch2.term_p)
connect(switch2.term_n, pn_p_n.term_n)
connect(gates, gate2demux.gates)
connect(gate2demux.gates_1[1], switch1.gate)
connect(gate2demux.gates_2[1], switch2.gate)
connect(pn_p_n.term_pn, DC)
connect(switch1.heat, heat)
connect(switch2.heat, heat)
end SwitchModule;
end PhaseModules; |
Parameter f | within PowerSystems;
package Types
extends Modelica.Icons.TypesPackage;
type SourceFrequency = enumeration(
Parameter "Parameter f",
Signal "Signal omega_in",
System "System defined") "Options for specification of frequency"
type SystemFrequency = enumeration(
Parameter "Parameter f",
Signal "Signal omega_in",
Average "Average generators")
"Options for specification of frequency in system object"
type ReferenceFrame = enumeration(
Synchron "Synchronously rotating",
Inertial "Inertial (signals oscillate)")
"Options for specification of reference frame"
type Dynamics = enumeration(
FreeInitial "Free initial conditions",
FixedInitial "Fixed initial conditions",
SteadyInitial "Steady-state initial conditions",
SteadyState "Steady-state (quasi-stationary)") "Options for specification of simulation"
type Init = enumeration(
v_alpha "v, alpha: voltage and phase angle, 'slack' (steady init)",
v_p "v, p: voltage and active power (steady init)",
v_q "v, q: voltage and reactive power (steady init)",
p_q "p, q: active and reactive power (steady init)",
phi_w_el "phi_el, w_el: machine angle and angular velocity electric",
none "none: no initial condition") "Initialization type"
type ReferenceAngle "Reference angle"
extends SI.Angle;
function equalityConstraint
input ReferenceAngle theta1[:];
input ReferenceAngle theta2[:];
output Real[0] residue "No constraints";
algorithm
for i in 1:size(theta1, 1) loop
assert(abs(theta1[i] - theta2[i]) < Modelica.Constants.eps, "angles theta1 and theta2 not equal over connection!");
end for;
end equalityConstraint;
end ReferenceAngle;
type Color = Integer[3] (each min=0, each max=255) "RGB color"
end Types; |
SI types with custom attributes, like display units | within PowerSystems.Types;
package SI "SI types with custom attributes, like display units"
extends Modelica.Icons.Package;
import MSI = Modelica.Units.SI;
type Time = MSI.Time;
type Frequency = MSI.Frequency;
type Length = MSI.Length(displayUnit = "km");
type Distance = MSI.Distance;
type Radius = MSI.Radius;
type Area = MSI.Area;
type Velocity = MSI.Velocity;
type Angle = MSI.Angle;
type AngularVelocity = MSI.AngularVelocity(displayUnit = "rpm");
type AngularAcceleration = MSI.AngularAcceleration;
type AngularFrequency = MSI.AngularFrequency;
type Force = MSI.Force;
type Mass = MSI.Mass;
type Density = MSI.Density;
type Inertia = MSI.Inertia;
type Torque = MSI.Torque;
type Stiffness = Real (
final quantity = "Stiffness",
final unit = "N",
final min=0);
type TorsionStiffness = Real (
final quantity="TorsionStiffness",
final unit="N.m/rad",
final min=0);
type Voltage = MSI.Voltage(displayUnit = "kV");
type Current = MSI.Current;
type Resistance = MSI.Resistance;
type Conductance = MSI.Conductance;
type Inductance = MSI.Inductance;
type Capacitance = MSI.Capacitance;
type Admittance = MSI.Admittance;
type Reactance = MSI.Reactance;
type Impedance = MSI.Impedance;
type Power = MSI.Power(displayUnit = "MW");
type ActivePower = MSI.ActivePower(displayUnit = "MW");
type ApparentPower = MSI.ApparentPower(displayUnit = "MVA");
type ReactivePower = MSI.ReactivePower(displayUnit = "Mvar");
type ElectricFieldStrength = MSI.ElectricFieldStrength;
type MagneticFlux = MSI.MagneticFlux;
type ElectricCharge = MSI.ElectricCharge;
type Temperature = MSI.Temperature;
type Heat = MSI.Heat;
type HeatFlowRate = MSI.HeatFlowRate;
type HeatCapacity = MSI.HeatCapacity;
type ThermalConductance = MSI.ThermalConductance;
type Percent = Real (
final quantity="Percent",
final unit="1",
final displayUnit="1/100");
end SI; |
Additional types for power systems | within PowerSystems.Types;
package SIpu "Additional types for power systems"
extends Modelica.Icons.Package;
type AngularVelocity = Real(final quantity="AngularVelocity", unit="rad.s/(rad.s)");
type Voltage = Real (final quantity="ElectricPotential", unit="V/V");
type Current = Real (final quantity="ElectricCurrent", unit="A/A");
type Power = Real (final quantity="Power", unit="W/W");
type ActivePower = Real (final quantity="Power", unit="W/W");
type ApparentPower = Real (final quantity="ApparentPower", unit="VA/VA");
type ReactivePower = Real (final quantity="ReactivePower", unit="var/var");
type Resistance = Real (
final quantity="Resistance",
unit="Ohm/(V.V/VA)",
final min=0);
type Reactance = Real (final quantity="Reactance", unit="Ohm/Ohm");
type Impedance = Real (final quantity="Impedance", unit="Ohm/Ohm");
type Inductance = Real (final quantity="Inductance", unit="H/H");
type Conductance = Real (
final quantity="Conductance",
unit="S/S",
final min=0);
type Susceptance = Real (
final quantity="Susceptance",
unit="S/S");
type Admittance = Real (
final quantity="Admittance",
unit="S/S",
min=0);
type Resistance_km = Real (
final quantity="Resistance",
unit="Ohm/(Ohm.km)",
min=0);
type Reactance_km = Real (final quantity="Reactance_per_km",
unit="Ohm/(Ohm.km)",
min=0);
type Conductance_km = Real (
final quantity="Conductance",
unit="S/(S.km)",
min=0);
type Susceptance_km = Real (
final quantity="Susceptance",
unit="S/(S.km)",
min=0);
type MagneticFlux = Real (final quantity="MagneticFlux", unit="Wb/Wb");
type Energy = Real (final quantity="Energy", unit="J/J");
type Torque = Real (final quantity="Torque", unit="N.m/(N.m)");
end SIpu; |
Complex functions (auxiliary sub-package) | within PowerSystems.Utilities;
package Complex "Complex functions (auxiliary sub-package)"
extends Modelica.Icons.Package;
type ComplexType = Real[2, 2] "matrix representation of complex number";
constant ComplexType re = [1,0;0,1] "matrix representation of real unit";
constant ComplexType im = [0,-1;1,0]
"matrix representation of imaginary unit";
function conjC "Conjugate value of complex number"
extends Modelica.Icons.Function;
input ComplexType z "complex argument";
output ComplexType conj_z "conjugate value of z";
algorithm
conj_z := transpose(z);
end conjC;
function absC "Absolute value of complex number"
extends Modelica.Icons.Function;
input ComplexType z "complex argument";
output Real abs_z "absolute value of z";
algorithm
abs_z := sqrt(detC(z));
end absC;
function detC "Determinant of complex number matrix"
extends Modelica.Icons.Function;
input ComplexType z "complex argument";
output Real det_z "determinant of z";
algorithm
det_z := z[1,1]*z[2,2] - z[1,2]*z[2,1];
end detC;
function invC "Inverse of complex number"
extends Modelica.Icons.Function;
input ComplexType z "complex argument";
output ComplexType inv_z "inverse of z";
algorithm
inv_z := transpose(z)/detC(z);
end invC;
function sumC "Sum of complex numbers"
extends Modelica.Icons.Function;
input ComplexType[ :] z "complex vector";
output ComplexType s "sum of components of z";
algorithm
s := z[1, :, :];
for k in 2:size(z,1) loop
s := s + z[k,:,:];
end for;
end sumC;
function prodC "Product of complex numbers"
extends Modelica.Icons.Function;
input ComplexType[ :] z "complex vector";
output ComplexType p "product of components of z";
algorithm
p := z[1, :, :];
for k in 2:size(z,1) loop
p := p*z[k,:,:];
end for;
end prodC;
function expI "Exponential of imaginary number"
extends Modelica.Icons.Function;
input Real phi "real argument";
output ComplexType exp_jphi "exponential of j*phi";
protected
Real c;
Real s;
algorithm
c := cos(phi);
s := sin(phi);
exp_jphi := [c, -s; s, c];
end expI;
function expC "Exponential of complex number"
extends Modelica.Icons.Function;
input ComplexType z "complex argument";
output ComplexType exp_z "exponential of z";
algorithm
exp_z := exp(z[1,1])*expI(z[2,1]);
end expC;
function powerC "Power of complex number"
extends Modelica.Icons.Function;
input ComplexType z "complex argument";
input Real alpha "exponent";
output ComplexType pow_z "power of z";
protected
function atan2=Modelica.Math.atan2;
algorithm
pow_z := detC(z)^(0.5*alpha)*expI(alpha*atan2(z[2,1], z[1,1]));
end powerC;
function sqrtC "Square-root of complex number"
extends Modelica.Icons.Function;
input ComplexType z "complex argument";
output ComplexType sqrt_z "square-root of z";
protected
function atan2=Modelica.Math.atan2;
algorithm
sqrt_z := sqrt(absC(z))*expI(0.5*atan2(z[2,1], z[1,1]));
end sqrtC;
function logC "Logarithm of complex number"
extends Modelica.Icons.Function;
input ComplexType z "complex argument";
output ComplexType log_z "logarithm of z";
protected
Real re;
Real im;
function atan2=Modelica.Math.atan2;
function log=Modelica.Math.log;
algorithm
re := 0.5*log(detC(z));
im := atan2(z[2,1], z[1,1]);
log_z := [re, -im; im, re];
end logC;
function cosC "Cosine of complex number"
extends Modelica.Icons.Function;
input ComplexType z "complex argument";
output ComplexType cos_z "cosine of z";
protected
Real re;
Real im;
algorithm
re := cos(z[1,1])*cosh(z[2,1]);
im := -sin(z[1,1])*sinh(z[2,1]);
cos_z := [re, -im; im, re];
end cosC;
function sinC "Sine of complex number"
extends Modelica.Icons.Function;
input ComplexType z "complex argument";
output ComplexType sin_z "sine of z";
protected
Real re;
Real im;
algorithm
re := sin(z[1,1])*cosh(z[2,1]);
im := cos(z[1,1])*sinh(z[2,1]);
sin_z := [re, -im; im, re];
end sinC;
function tanC "Tangens of complex number"
extends Modelica.Icons.Function;
input ComplexType z "complex argument";
output ComplexType tan_z "tangens of z";
algorithm
tan_z := sinC(z)*invC(cosC(z));
end tanC;
function atanC "Arc-tangens of complex number"
extends Modelica.Icons.Function;
input ComplexType z "complex argument";
output ComplexType atan_z "arc-tangens of z";
protected
Real a;
algorithm
a := 0.5*(1 - detC(z));
atan_z := 0.5*logC([a, -z[1,1]; z[1,1], a]/(1 - a + z[2,1]));
atan_z := [atan_z[2,1], atan_z[2,2]; -atan_z[1,1], -atan_z[1,2]];
end atanC;
function coshC "Hyperbolic cosine of complex number"
extends Modelica.Icons.Function;
input ComplexType z "complex argument";
output ComplexType cosh_z "hyp cosine of z";
protected
Real re;
Real im;
algorithm
re := cosh(z[1,1])*cos(z[2,1]);
im := sinh(z[1,1])*sin(z[2,1]);
cosh_z := [re, -im; im, re];
end coshC;
function sinhC "Hyperbolic sine of complex number"
extends Modelica.Icons.Function;
input ComplexType z "complex argument";
output ComplexType sinh_z "hyp sine of z";
protected
Real re;
Real im;
algorithm
re := sinh(z[1,1])*cos(z[2,1]);
im := cosh(z[1,1])*sin(z[2,1]);
sinh_z := [re, -im; im, re];
end sinhC;
function tanhC "Hyperbolic tangens of complex number"
extends Modelica.Icons.Function;
input ComplexType z "complex argument";
output ComplexType tanh_z "hyp tangens of z";
algorithm
tanh_z := sinhC(z)*invC(coshC(z));
end tanhC;
function atanhC "Area-tangens-hyp of complex number"
extends Modelica.Icons.Function;
input ComplexType z "complex argument";
output ComplexType atan_z "area-tangens-hyp of z";
protected
Real a;
algorithm
a := 0.5*(1 - detC(z));
atan_z := 0.5*logC([a, -z[2,1]; z[2,1], a]/(1 - a - z[1,1]));
end atanhC;
end Complex; |
Mathematical functions | within PowerSystems.Utilities;
package Math "Mathematical functions"
extends Modelica.Icons.Package;
function atanVarCut "arc-tangens with variable cut"
extends Modelica.Icons.Function;
input Real[2] x "2-dimensional vector";
input SI.Angle alpha "angle";
output SI.Angle phi
"arc(x) with range (alpha-pi) < phi <= (alpha+pi)";
protected
Real c;
Real s;
import Modelica.Math.atan2;
algorithm
c := cos(-alpha);
s := sin(-alpha);
phi := atan2({s, c}*x, {c, -s}*x) + alpha;
end atanVarCut;
function angVelocity "Angular velocity of 2dim vector"
extends Modelica.Icons.Function;
input Real[2] x "2-dimensional vector";
input Real[2] x_dot "time-derivative of x";
output Real omega "angular velocity of x";
import Modelica.Constants.eps;
algorithm
omega :=(x[1]*x_dot[2] - x_dot[1]*x[2])/(x*x + eps);
end angVelocity;
function mod2sign "Modulo-two sign"
extends Modelica.Icons.Function;
input Integer[:] n "integer vector";
output Integer[size(n, 1)] sign_n "(-1)^n_k, k=1:size(n)";
algorithm
for k in 1:size(n, 1) loop
if n[k] == 2*integer(n[k]/2) then
sign_n[k] := 1;
else
sign_n[k] := -1;
end if;
end for;
end mod2sign;
function interpolateTable
"Interpolation of tables with equidistant arguments"
extends Modelica.Icons.Function;
input Real x "table argument";
input Real[:, :] xy_tab "table, [argument, values]";
output Real[size(xy_tab, 2) - 1] y "interpolated table values";
protected
Integer N1=size(xy_tab, 1);
Integer N2=size(xy_tab, 2);
Real x0=xy_tab[1, 1];
Real del_x=xy_tab[2, 1] - xy_tab[1, 1];
Real x_rel;
Integer nx;
Integer n;
algorithm
x_rel := (x - x0)/del_x;
nx := max(min(integer(x_rel), N1 - 2), 0);
n := nx + 1;
y := xy_tab[n, 2:N2] + (x_rel - nx)*(xy_tab[n + 1, 2:N2] - xy_tab[n, 2:N2]);
end interpolateTable;
function polyCoefReal "Coefficients of a polynomial from real roots"
extends Modelica.Icons.Function;
input Real[:] r "root vector";
output Real[size(r,1)+1] c "coefficient vector";
protected
parameter Integer n=size(r,1);
algorithm
c := cat(1, zeros(n), {1});
for k in n:-1:1 loop
c[n:-1:k] := c[n:-1:k] - r[k]*c[n+1:-1:k+1];
end for;
</blockquote></pre>
<p>The resulting n+1 = 4 coefficients are:</p>
<pre><blockquote>
c = {-6, 11, -6, 1};
</blockquote><pre>
<p>See also
<a href=\"modelica://PowerSystems.Utilities.Math.polyCoef\">polyCoef</a>, <a href=\"modelica://PowerSystems.Utilities.Math.polyRoots\">polyRoots</a></p>
</html>
"));
end polyCoefReal;
function polyCoef "Coefficients of a polynomial from roots"
extends Modelica.Icons.Function;
input Real[:,2] r "root vector, 2nd index=1:2, real and imaginary part";
output Real[size(r,1)+1,2] c
"coefficient vector, 2nd index=1:2, real and imaginary part";
protected
parameter Integer n=size(r,1);
algorithm
c := zeros(n+1,2);
c[n+1,1] := 1;
for k in n:-1:1 loop
c[n:-1:k,:] := c[n:-1:k,:] - cat(2, r[k,1]*c[n+1:-1:k+1,1:1] - r[k,2]*c[n+1:-1:k+1,2:2], r[k,1]*c[n+1:-1:k+1,2:2] + r[k,2]*c[n+1:-1:k+1,1:1]);
end for;
</blockquote></pre>
<p>The resulting n+1 = 4 coefficients are:</p>
<pre><blockquote>
c = [-6, 0; 11, 0; -6, 0; 1, 0];
</blockquote></pre>
<p>See also
<a href=\"modelica://PowerSystems.Utilities.Math.polyCoefReal\">polyCoefReal</a>, <a href=\"modelica://PowerSystems.Utilities.Math.polyRoots\">polyRoots</a></p>
</html>
"));
end polyCoef;
function polyRoots "Roots of a polynomial"
extends Modelica.Icons.Function;
input Real[:] c "coefficient vector";
output Real[size(c,1)-1,2] r
"root vector, 2nd index=1:2, real and imaginary part";
output Integer N0
"true deg of polynomial = number of valid roots (r[1:N0,:])";
protected
parameter Integer N=size(c,1)-1 "formal degree of polynome";
Integer n;
Integer n0;
Real[N, N] A;
Real[N+1] C;
import Modelica.Math.Matrices.eigenValues;
algorithm
N0 := N "determine true degree of polymomial";
// while c[N0+1] == 0 and N0 > 0 loop
while abs(c[N0+1])/max(abs(c)) < Modelica.Constants.eps and N0 > 0 loop
N0 := N0 - 1;
end while;
if N0 == 0 then
r := zeros(N,2);
else
n0 := 0;
while c[n0+1] == 0 loop
n0 := n0 + 1;
end while;
n := N0-n0;
for k in 1:n+1 loop
C[k] := c[n0+k];
end for;
A[1, 1:n] := -C[n:-1:1]/C[n+1];
A[2:n,1:n-1] := diagonal(ones(n-1));
A[2:n,n] := zeros(n-1);
r[1:n0,:] := zeros(n0,2);
r[n0+1:n0+n,:] := eigenValues(A[1:n, 1:n]);
end if;
</blockquote></pre>
<p>The resulting n = 2 roots are:</p>
<pre><blockquote>
r[1,:] = {-0.333333 +0.471405};
r[2,:] = {-0.333333 -0.471405};
</blockquote></pre>
<p>See also
<a href=\"modelica://PowerSystems.Utilities.Math.polyCoefReal\">polyCoefReal</a>, <a href=\"modelica://PowerSystems.Utilities.Math.polyCoef\">polyCoef</a>, <a href=\"Modelica:Modelica.Math.Matrices.eigenValues\">eigenValues</a></p>
</html>
"));
end polyRoots;
function fminSearch
"Determines minimum of a scalar function with vector-argument x"
extends Modelica.Icons.Function;
input Real[:] x0 "start value, fcn(x0) is approximate min";
input Real[:] x_opt "optional further arguments of function fcn";
output Real[size(x0,1)] x "argument where function value is minimal";
output Real y "value of function at x";
protected
replaceable function fcn = PowerSystems.Utilities.Precalculation.i_field
"function to be minimised around x0";
Integer n = size(x,1);
Integer max_fun = 200*n;
Integer max_iter = 200*n;
constant Real tol_x = 1e-4;
constant Real tol_f = 1e-4;
constant Real rho = 1;
constant Real chi = 2;
constant Real psi = 0.5;
constant Real sigma = 0.5;
constant Real delta=0.05; //for non-zero terms
constant Real delta0=0.00025; //for zero elements of x
Integer funcount;
Integer itercount;
Integer ifv[n+1];
Real[n,n+1] v;
Real fv[n+1];
Real[n] x1;
Real[n] xbar;
Real[n] xr;
Real fxr;
Real[n] xe;
Real fxe;
Real[n] xc;
Real fxc;
Real[n] xcc;
Real fxcc;
Boolean shrink;
String msg;
algorithm
// Set up a simplex near the initial guess.
v := zeros(n,n+1);
fv := zeros(n+1);
v[:,1] := x0; //Place input guess in the simplex
fv[1] := fcn(x0, x_opt);
funcount := 1;
itercount := 0;
// Following improvement suggested by L.Pfeffer at Stanford
for j in 1:n loop
x1 := x0;
x1[j] := if abs(x1[j]) > Modelica.Constants.small then (1 + delta)*x1[j] else delta0;
v[:,j+1] := x1;
fv[j+1] := fcn(x1, x_opt);
end for;
// Sort so v(1,:) has the lowest function value
(fv, ifv) := sortUp(fv);
v := v[:, ifv];
itercount := itercount + 1;
funcount := n + 1;
// Main algorithm
while (funcount < max_fun and itercount < max_iter) and
(max(abs(fv[ones(n)] - fv[2:n+1])) > tol_f or
max(abs(v[:,ones(n)] - v[:,2:n+1])) > tol_x) loop
// Compute the reflection point
xbar := sum(v[:,k] for k in 1:n)/n; //average of the n (NOT n+1) best points
xr := (1 + rho)*xbar - rho*v[:,end];
fxr := fcn(xr, x_opt);
funcount := funcount+1;
if fxr < fv[1] then // Calculate the expansion point
xe := (1 + rho*chi)*xbar - rho*chi*v[:,end];
fxe := fcn(xe, x_opt);
funcount := funcount + 1;
if fxe < fxr then
v[:,end] := xe;
fv[end] := fxe;
else v[:,end] := xr;
fv[end] := fxr;
end if;
else
if fxr < fv[n] then
v[:,end] := xr;
fv[end] := fxr;
else //perform contraction
if fxr < fv[end] then //outside contraction
xc := (1 + psi*rho)*xbar - psi*rho*v[:,end];
fxc := fcn(xc, x_opt);
funcount := funcount + 1;
if fxc <= fxr then
v[:,end] := xc;
fv[end] := fxc;
shrink := false;
else //perform a shrink
shrink := true;
end if;
else //inside contraction
xcc := (1-psi)*xbar + psi*v[:,end];
fxcc := fcn(xcc, x_opt);
funcount := funcount + 1;
if fxcc < fv[end] then
v[:,end] := xcc;
fv[end] := fxcc;
shrink := false;
else //perform a shrink
shrink := true;
end if;
end if;
if shrink then
for j in 2:n+1 loop
v[:,j] := v[:,1] + sigma*(v[:,j] - v[:,1]);
fv[j] := fcn(v[:,j], x_opt);
end for;
funcount := funcount + n;
end if;
end if;
end if;
(fv, ifv) := sortUp(fv);
v := v[:, ifv];
itercount := itercount + 1;
end while;
x := v[:,1];
//if isPresent(y) then
y := fv[1];
//end if;
if funcount >= max_fun then
msg := "fminSearch: max number of function evaluations EXCEEDED";
elseif itercount >= max_iter then
msg := "fminSearch: max number of iterations EXCEEDED";
else
msg := "fminSearch: terminated successfully";
end if;
end fminSearch;
function sortUp "Sorts components of x in increasing order"
extends Modelica.Icons.Function;
input Real[:] x "x unsorted";
output Real[size(x,1)] y "x sorted increasing";
output Integer[size(x,1)] i "indizes of sorted x";
protected
Integer n = size(x,1);
Integer itemp;
Real ytemp;
algorithm
y := x;
i := 1:n;
for j in 1:n-1 loop
for k in j+1:n loop
if y[j] > y[k] then
ytemp := y[j];
y[j] := y[k];
y[k] := ytemp;
itemp := i[j];
i[j] := i[k];
i[k] := itemp;
end if;
end for;
end for;
end sortUp;
function sortDown "Sorts components of x in decreasing order"
extends Modelica.Icons.Function;
input Real[:] x "x unsorted";
output Real[size(x,1)] y "x sorted decreasing";
output Integer[size(x,1)] i "indizes of sorted x";
protected
Integer n = size(x,1);
Integer itemp;
Real ytemp;
algorithm
y := x;
i := 1:n;
for j in 1:n-1 loop
for k in j+1:n loop
if y[j] < y[k] then
ytemp := y[j];
y[j] := y[k];
y[k] := ytemp;
itemp := i[j];
i[j] := i[k];
i[k] := itemp;
end if;
end for;
end for;
end sortDown;
function relaxation "Exponential relaxation function"
extends Modelica.Icons.Function;
input Real t "relative time";
input Real t_char "characteristic time";
input Real beta(min=2) "power of exponent";
output Real[2] y "relaxation function {decreasing, increasing}";
protected
final parameter Real gamma=exp(-0.5);
Real dt=1-t/t_char;
algorithm
y[2] := if t < 0 then 1 else if t < t_char then (exp(-0.5*dt^beta) - gamma)/(1 - gamma) else 1;
y[1] := 1 - y[2];
end relaxation;
function taylor "Taylor series"
extends Modelica.Icons.Function;
input Real x "argument";
input Real[:] c "coefficients";
output Real y "sum(c[n]*x^n)";
protected
Real x_k;
algorithm
y :=1;
x_k := 1;
for k in 1:size(c, 1) loop
x_k := x*x_k;
y := y + c[k]*x_k;
end for;
end taylor;
function sign_gtlt "Characteristic function abs(x)>b"
extends Modelica.Icons.Function;
input Real[:] x "argument";
input Real b(min=0) "threshold value";
output Real[size(x,1)] y "characteristic function of abs(x) > b";
algorithm
for k in 1:size(x,1) loop
y[k] := if x[k] > b then 1 else if x[k] < -b then -1 else 0;
end for;
end sign_gtlt;
function sign_gt "Sign function x>b"
extends Modelica.Icons.Function;
input Real[:] x "argument";
input Real b(min=0) "threshold value";
output Real[size(x,1)] y "characteristic function of x > b";
algorithm
for k in 1:size(x,1) loop
y[k] := if x[k] > b then 1 else 0;
end for;
end sign_gt;
function sign_lt "Sign function x<b"
extends Modelica.Icons.Function;
input Real[:] x "argument";
input Real b(min=0) "threshold value";
output Real[size(x,1)] y "characteristic function of x < b";
algorithm
for k in 1:size(x,1) loop
y[k] := if x[k] < b then -1 else 0;
end for;
end sign_lt;
end Math; |
Basic utilities | within PowerSystems;
package Utilities "Basic utilities"
extends Modelica.Icons.UtilitiesPackage;
end Utilities; |
Precalculation functions | within PowerSystems.Utilities;
package Precalculation "Precalculation functions"
extends Modelica.Icons.Package;
function baseV "Base voltage"
extends Modelica.Icons.Function;
input Boolean puUnits "= true if pu else SI units";
input SI.Voltage V_nom "nom voltage";
output SI.Voltage V_base "base voltage";
algorithm
if puUnits then
V_base := V_nom;
else
V_base := 1;
end if;
end baseV;
function baseI "Base current"
extends Modelica.Icons.Function;
input Boolean puUnits "= true if pu else SI units";
input SI.Voltage V_nom "nom voltage";
input SI.ApparentPower S_nom "apparent power";
output SI.Current I_base "base current";
algorithm
if puUnits then
I_base := S_nom/V_nom;
else
I_base := 1;
end if;
end baseI;
function baseS "Base power"
extends Modelica.Icons.Function;
input Boolean puUnits "= true if pu else SI units";
input SI.ApparentPower S_nom "apparent power";
output SI.ApparentPower S_base "base power";
algorithm
if puUnits then
S_base := S_nom;
else
S_base := 1;
end if;
end baseS;
function baseR "Base resistance"
extends Modelica.Icons.Function;
input Boolean puUnits "= true if pu else SI units";
input SI.Voltage V_nom "nom voltage";
input SI.ApparentPower S_nom "apparent power";
input Integer scale=1 "scaling factor topology (Y:1, Delta:3)";
output SI.Resistance R_base "base resistance";
algorithm
if puUnits then
R_base := scale*V_nom*V_nom/S_nom;
else
R_base := scale;
end if;
end baseR;
function baseL "Base inductance"
extends Modelica.Icons.Function;
input Boolean puUnits "= true if pu else SI units";
input SI.Voltage V_nom "nom voltage";
input SI.ApparentPower S_nom "apparent power";
input SI.AngularFrequency omega_nom "angular frequency";
output SI.Inductance L_base "base inductance";
algorithm
if puUnits then
L_base := V_nom*V_nom/(S_nom*omega_nom);
else
L_base := 1;
end if;
end baseL;
function baseRL "Base resistance and inductance"
extends Modelica.Icons.Function;
input Boolean puUnits "= true if pu else SI units";
input SI.Voltage V_nom "nom voltage";
input SI.ApparentPower S_nom "apparent power";
input SI.AngularFrequency omega_nom "angular frequency";
input Integer scale=1 "scaling factor topology (Y:1, Delta:3)";
output Real[2] RL_base "base {resistance, inductance}";
algorithm
if puUnits then
RL_base := scale*(V_nom*V_nom/S_nom)*{1, 1/omega_nom};
else
RL_base := scale*({1, 1/omega_nom});
end if;
end baseRL;
function baseGC "Base conductance and capacitance"
extends Modelica.Icons.Function;
input Boolean puUnits "= true if pu else SI units";
input SI.Voltage V_nom "nom voltage";
input SI.ApparentPower S_nom "apparent power";
input SI.AngularFrequency omega_nom "angular frequency";
input Integer scale=1 "scaling factor topology (Y:1, Delta:3)";
output Real[2] GC_base "base {conductance, capacitance}";
algorithm
if puUnits then
GC_base := (S_nom/(V_nom*V_nom))*{1, 1/omega_nom}/scale;
else
GC_base := {1, 1/omega_nom}/scale;
end if;
end baseGC;
function baseTrafoV "Base voltage transformers"
extends Modelica.Icons.Function;
input Boolean puUnits "= true if pu else SI units";
input SI.Voltage[:] V_nom "nom voltage {prim, sec} or {prim, sec1, sec2}";
output SI.Voltage[size(V_nom,1)] V_base
"base voltage {prim,sec} or {prim, sec1, sec2}";
algorithm
if puUnits then
V_base := V_nom;
else
V_base := ones(size(V_nom,1));
end if;
end baseTrafoV;
function baseTrafoRL "Base resistance and inductance transformers"
extends Modelica.Icons.Function;
input Boolean puUnits "= true if pu else SI units";
input SI.Voltage[:] V_nom "nom voltage {prim, sec} or {prim, sec1, sec2}";
input SI.ApparentPower S_nom "apparent power";
input SI.AngularFrequency omega_nom "angular frequency";
output Real[size(V_nom,1), 2] RL_base "base [prim res, prim ind; sec res, sec ind] or
[prim res, prim ind; sec1 res, sec1 ind; sec2 res, sec2 ind]";
algorithm
if puUnits then
RL_base := fill(V_nom[1]^2/S_nom, size(V_nom,1), 1)*[1, 1/omega_nom];
else
RL_base := [(fill(V_nom[1],size(V_nom,1))./ V_nom).^2]*[1, 1/omega_nom];
end if;
end baseTrafoRL;
function machineDCser "Calculates coefficients of DC-machine series excited"
extends Modelica.Icons.Function;
input AC1ph_DC.Machines.Parameters.DCser p "parameters DC machine series";
output AC1ph_DC.Machines.Coefficients.DCser c
"coefficients DC machine series";
protected
final parameter SI.AngularVelocity w_el_nom=p.pp*p.w_nom;
final parameter SI.Resistance R_base=Utilities.Precalculation.baseR(
p.puUnits, p.V_nom, p.S_nom)
"base resistance";
final parameter SI.Inductance L_base=Utilities.Precalculation.baseL(
p.puUnits, p.V_nom, p.S_nom, w_el_nom)
"base resistance";
algorithm
c.L := (p.l_fd + p.l_q)*L_base;
c.R := {p.r_fd, p.r_q}*R_base;
c.L_md := (p.V_nom^2/p.S_nom - sum(c.R))/w_el_nom;
end machineDCser;
function machineDCpar
"Calculates coefficients of DC-machine parallel excited"
extends Modelica.Icons.Function;
input AC1ph_DC.Machines.Parameters.DCpar p "parameters DC machine parallel";
output AC1ph_DC.Machines.Coefficients.DCpar c
"coefficients DC machine parallel";
protected
final parameter SI.AngularVelocity w_el_nom=p.pp*p.w_nom;
final parameter SI.Resistance R_base=Utilities.Precalculation.baseR(
p.puUnits, p.V_nom, p.S_nom)
"base resistance";
final parameter SI.Inductance L_base=Utilities.Precalculation.baseL(
p.puUnits, p.V_nom, p.S_nom, w_el_nom)
"base resistance";
SI.AngularFrequency w_el_lim;
algorithm
c.L := {p.l_fd, p.l_q}*L_base;
c.R := {p.r_fd, p.r_q}*R_base;
w_el_lim := w_el_nom/(1 - c.R[2]*p.S_nom/p.V_nom^2);
c.L_md := (c.R[1]/w_el_lim)*(p.V_nom/p.Vf_nom);
end machineDCpar;
function machineDCpm "Calculates coefficients of DC-machine permanent magnet"
extends Modelica.Icons.Function;
input AC1ph_DC.Machines.Parameters.DCpm p "parameters DC machine pm";
output AC1ph_DC.Machines.Coefficients.DCpm c "coefficients DC machine pm";
protected
final parameter SI.AngularVelocity w_el_nom=p.pp*p.w_nom;
final parameter SI.Resistance R_base=Utilities.Precalculation.baseR(
p.puUnits, p.V_nom, p.S_nom)
"base resistance";
final parameter SI.Inductance L_base=Utilities.Precalculation.baseL(
p.puUnits, p.V_nom, p.S_nom, w_el_nom)
"base resistance";
algorithm
c.L := p.l_aq*L_base;
c.R := p.r_aq*R_base;
c.Psi_pm := (p.V_nom - c.R*p.S_nom/p.V_nom)/w_el_nom;
end machineDCpm;
function machineAsyn
"Calculates coefficient matrices of asynchronous machine"
extends Modelica.Icons.Function;
input AC3ph.Machines.Parameters.Asynchron p
"parameters asynchronous machine";
input Integer scale=1 "scaling factor topology (Y:1, Delta:3)";
output AC3ph.Machines.Coefficients.Asynchron c(n_r=p.n_r)
"coefficient matrices asynchronous machine";
protected
final parameter Integer n_r=p.n_r "number of rotor circuits";
final parameter SI.AngularFrequency omega_nom=2*pi*p.f_nom;
final parameter Real[2] RL_base=Utilities.Precalculation.baseRL(
p.puUnits, p.V_nom, p.S_nom, omega_nom, scale)
"base resistance inductance";
SI.Angle[n_r] Tc "time constant closed-loop";
SI.Angle[n_r] To "time constant open-loop";
SI.Resistance[n_r+1] zr;
SI.Reactance[n_r+1,n_r+1] zx;
import Modelica.Math.Matrices.solve;
algorithm
if p.transDat then
if p.use_xtr then
assert(size(p.tc,1) == size(p.xtr,1), "size of tc and xtr must be equal!");
else
assert(size(p.tc,1) == size(p.to,1), "size of tc and to must be equal!");
end if;
Tc := omega_nom*p.tc;
To := if p.use_xtr then T_open(p.x, p.xtr, Tc) else omega_nom*p.to;
(zr, zx) := z_fromTransDat(n_r, Tc, To, p.x, p.xsig_s, p.r_s, 0, 0, 0, false);
else
(zr, zx) := z_fromEqCirc(n_r, p.x, p.xsig_s, p.r_s, zeros(n_r-1), p.xsig_r, p.r_r);
end if;
// c.L_s := {p.x, p.x, p.x_0}*RL_base[2];
c.L_s := {zx[n_r+1,n_r+1], zx[n_r+1,n_r+1], p.x_0}*RL_base[2];
c.L_r := zx[1:n_r,1:n_r]*RL_base[2];
c.L_m := zx[n_r+1,1:n_r]*RL_base[2];
c.R_s := p.r_s*RL_base[1];
c.R_r := zr[1:end-1]*RL_base[1];
c.R_n := p.r_n*RL_base[1];
if n_r == 1 then
c.R_m := c.R_r[1] / c.L_r[1,1] * c.L_m;
else
c.R_m := c.R_r .* solve(c.L_r, c.L_m);
end if;
end machineAsyn;
function machineSyn3rd
"Calculates coefficient matrices of synchronous machine, 3rd order"
extends Modelica.Icons.Function;
input AC3ph.Machines.Parameters.Synchron3rd p
"parameters synchronous machine 3rd order";
input Integer scale=1 "scaling factor topology (Y:1, Delta:3)";
output AC3ph.Machines.Coefficients.Synchron3rd c
"coefficient matrices synchronous machine 3rd order";
protected
final parameter SI.AngularFrequency omega_nom=2*pi*p.f_nom;
final parameter Real[2] RL_base=Utilities.Precalculation.baseRL(
p.puUnits, p.V_nom, p.S_nom, omega_nom, scale)
"base resistance inductance";
algorithm
c.L_s := {p.x_d, p.x_q, p.x_0}*RL_base[2];
c.R_s := p.r_s*RL_base[1];
c.R_n := p.r_n*RL_base[1];
c.Psi_pm := p.psi_pm*(p.V_nom/omega_nom);
c.omega_nom := omega_nom;
end machineSyn3rd;
function machineSyn "Calculates coefficient matrices of synchronous machine"
extends Modelica.Icons.Function;
input AC3ph.Machines.Parameters.Synchron p "parameters synchronous machine";
input Integer scale=1 "scaling factor topology (Y:1, Delta:3)";
output AC3ph.Machines.Coefficients.Synchron c(n_d=p.n_d, n_q=p.n_q)
"coefficient matrices synchronous machine";
protected
final parameter Integer n_d=p.n_d "number of rotor circuits d-axis";
final parameter Integer n_q=p.n_q "number of rotor circuits q-axis";
final parameter SI.AngularFrequency omega_nom=2*pi*p.f_nom;
final parameter Real[2] RL_base=Utilities.Precalculation.baseRL(
p.puUnits, p.V_nom, p.S_nom, omega_nom, scale)
"base resistance inductance";
final parameter SI.Current If_base=(p.x_d - p.xsig_s)*p.If_nom;
final parameter Real if0_pu= if p.puUnits then p.if0 else p.if0/If_base;
final parameter SI.Angle alpha_if0=(p.alpha_if0 + pi)
"mathematical sign convention";
SI.Angle[n_d] Tc_d "time constant closed-loop d-axis";
SI.Angle[n_q] Tc_q "time constant closed-loop q-axis";
SI.Angle[n_d] To_d "time constant open-loop d-axis";
SI.Angle[n_q] To_q "time constant open-loop q-axis";
SI.Resistance[n_d+1] zr_d;
SI.Resistance[n_q+1] zr_q;
SI.Reactance[n_d+1,n_d+1] zx_d;
SI.Reactance[n_q+1,n_q+1] zx_q;
algorithm
c.Psi_pm := p.psi_pm*(p.V_nom/omega_nom);
if p.transDat then
if p.use_xtr then
assert(size(p.tc_d,1) == size(p.xtr_d,1), "size of tc_d and xtr_d must be equal!");
assert(size(p.tc_q,1) == size(p.xtr_q,1), "size of tc_q and xtr_q must be equal!");
else
assert(size(p.tc_d,1) == size(p.to_d,1), "size of tc_d and to_d must be equal!");
assert(size(p.tc_q,1) == size(p.to_q,1), "size of tc_q and to_q must be equal!");
end if;
Tc_d := omega_nom*p.tc_d;
Tc_q := omega_nom*p.tc_q;
To_d := if p.use_xtr then T_open(p.x_d, p.xtr_d, Tc_d) else omega_nom*p.to_d;
To_q := if p.use_xtr then T_open(p.x_q, p.xtr_q, Tc_q) else omega_nom*p.to_q;
if p.use_if0 and p.excite==1 then
(zr_d, zx_d) := z_fromTransDat(n_d, Tc_d, To_d, p.x_d, p.xsig_s, p.r_s, if0_pu, alpha_if0, p.tol, true);
else
(zr_d, zx_d) := z_fromTransDat(n_d, Tc_d, To_d, p.x_d, p.xsig_s, p.r_s, 0, 0, p.tol, false);
end if;
(zr_q, zx_q) := z_fromTransDat(n_q, Tc_q, To_q, p.x_q, p.xsig_s, p.r_s, 0, 0, p.tol, false);
else
if p.use_if0 and p.excite==1 then
(zr_d, zx_d) := z_fromEqCirc(n_d, p.x_d, p.xsig_s, p.r_s, p.xm_d, p.xsig_rd, p.r_rd);
else
(zr_d, zx_d) := z_fromEqCirc(n_d, p.x_d, p.xsig_s, p.r_s, zeros(n_d-1), p.xsig_rd, p.r_rd);
end if;
(zr_q, zx_q) := z_fromEqCirc(n_q, p.x_q, p.xsig_s, p.r_s, zeros(n_q-1), p.xsig_rq, p.r_rq);
end if;
// c.L_s := {p.x_d, p.x_q, p.x_0}*RL_base[2];
c.L_s := {zx_d[n_d+1,n_d+1], zx_q[n_q+1,n_q+1], p.x_0}*RL_base[2];
c.L_rd := zx_d[1:n_d,1:n_d]*RL_base[2];
c.L_rq := zx_q[1:n_q,1:n_q]*RL_base[2];
c.L_md := zx_d[n_d+1,1:n_d]*RL_base[2];
c.L_mq := zx_q[n_q+1,1:n_q]*RL_base[2];
c.R_s := p.r_s*RL_base[1];
c.R_rd := zr_d[1:end-1]*RL_base[1];
c.R_rq := zr_q[1:end-1]*RL_base[1];
c.R_n := p.r_n*RL_base[1];
c.wf := omega_nom*c.L_md[1]*p.If_nom/p.V_nom;
c.Vf_nom := if p.excite==1 then (c.R_rd[1]/(c.wf*c.wf))*p.If_nom else 0;
c.omega_nom := omega_nom;
end machineSyn;
function polyCoef "Calculates polynome coefficients from time constants"
extends Modelica.Icons.Function;
input SI.Angle[:] T "time constant";
output Real[size(T,1)] a "coefficients of polynome";
protected
parameter Integer n=size(T,1);
algorithm
a := fill(0, n);
for k in 1:n loop
a[1:k] := cat(1, {a[1] + T[k]}, a[2:k] + a[1:k-1]*T[k]);
end for;
end polyCoef;
function polyTime "Calculates time constants from polynome coefficients"
extends Modelica.Icons.Function;
input Real[:] a "coefficients of polynome";
output SI.Angle[size(a,1)] T "time constant";
output Boolean Tisreal "true if all time constants real";
import Modelica.Constants.eps;
protected
parameter Integer n=size(a,1);
Real[n, n] A;
Real[n,2] lam "2nd index=1:2, real and imaginary part";
import Modelica.Math.Matrices.eigenValues;
import PowerSystems.Utilities.Math.sortDown;
algorithm
A[1, 1:n] := -cat(1, a[n-1:-1:1], {1})/a[n];
A[2:n,1:n-1] := diagonal(ones(n-1));
A[2:n,n] := zeros(n-1);
lam := eigenValues(A);
Tisreal := max(abs(lam[:, 2])) < eps;
T := -ones(n)./lam[n:-1:1,1];
T := sortDown(T);
end polyTime;
function x_transient
"Calculates x_transient from x, T_closed, and T_open, forward transform"
extends Modelica.Icons.Function;
input Real x(unit="1") "total or syn reactance";
input SI.Angle[:] Tc "time constant closed-loop";
input SI.Angle[size(Tc,1)] To "time constant open-loop";
output SIpu.Reactance[size(Tc,1)] xtr(each unit="1") "transient reactance";
protected
parameter Integer n=size(Tc,1);
Real[n] y;
Real[n-1] Tc_p;
algorithm
if n==0 then
xtr := fill(0, n);
elseif n==1 then
y[1] := -(Tc[1] - To[1])/Tc[1];
xtr[1] := x/(1 + y[1]);
else
for j in 1:n loop
Tc_p := fill(Tc[j], n - 1) - cat(1, Tc[1:j - 1], Tc[j + 1:n]);
y[j] := -product(fill(Tc[j], n) - To)/(Tc[j]*product(Tc_p));
end for;
xtr[1] := x/(1 + y[1]);
end if;
for j in 2:n loop
xtr[j] := x*xtr[j - 1]/(x + xtr[j - 1]*y[j]);
end for;
end x_transient;
function T_closed
"Calculates T_closed from x, x_transient, and T_open, backward transform"
extends Modelica.Icons.Function;
input SIpu.Reactance x(unit="1") "total or syn reactance";
input SIpu.Reactance[:] xtr(each unit="1") "transient reactance";
input SI.Angle[size(xtr,1)] To "time constant open-loop";
output SI.Angle[size(xtr,1)] Tc "time constant closed-loop";
protected
parameter Integer n=size(xtr,1);
Real[n] y;
Real[n] ac;
Real[n-1,n] A;
algorithm
// not implemented
end T_closed;
function T_open
"Calculates T_open from x, x_transient, and T_closed, backward transform"
extends Modelica.Icons.Function;
input SIpu.Reactance x(unit="1") "total or syn reactance";
input SIpu.Reactance[:] xtr(each unit="1") "transient reactance";
input SI.Angle[size(xtr,1)] Tc "time constant closed-loop";
output SI.Angle[size(xtr,1)] To "time constant open-loop";
protected
parameter Integer n=size(xtr,1);
Real[n] y;
Real[n] ac;
Real[n-1,n] A;
Boolean Treal;
algorithm
if n == 0 then
To := fill(0, n);
else
y := x./xtr;
y := y - cat(1, {1}, y[1:end-1]);
ac := polyCoef(Tc);
for j in 1:n loop
A[:,j] := polyCoef(cat(1, Tc[1:j-1], Tc[j+1:n]));
end for;
(To, Treal) := polyTime(ac*x/xtr[n] - cat(1, A*y, {0}));
end if;
end T_open;
function i_field "Calculates complex field current"
extends Modelica.Icons.Function;
import PowerSystems.Utilities.Complex.ComplexType;
import PowerSystems.Utilities.Complex.re;
import PowerSystems.Utilities.Complex.im;
input SIpu.Reactance[:] xm2_n(each unit="1") "approximate value of xm[2:n]";
input Real[:] x_opt "additional input arguments";
output Real di_f2 "i_f*conjugate(i_f)";
output Boolean result "true if Tsig real and convergence tol-ok";
protected
Integer n=size(xm2_n,1) + 1;
//x_opt collects the following 9 variables:
Real[n] ac = x_opt[1:n];
Real[n] ao = x_opt[n+1:2*n];
Real[n] Tc = x_opt[2*n+1:3*n];
Real[n] To = x_opt[3*n+1:4*n];
Real xsig_s = x_opt[4*n+1];
Real xm_s = x_opt[4*n+2];
Real r_s = x_opt[4*n+3];
Real[2] i_f0 = x_opt[4*n+4:4*n+5];
Real tol = x_opt[4*n+6];
Real qs;
Real Tsig_s;
Real[n] Tsig;
Real[n] xsig;
ComplexType[n] Qsig;
ComplexType[n] Qo;
ComplexType[n] Qc;
ComplexType di_f;
algorithm
qs :=xsig_s/(xm_s);
Tsig_s := xsig_s/r_s;
(Tsig, xsig, result) := Tsig_xsig(n, ac, ao, xsig_s, cat(1, {0}, xm2_n, {xm_s}), true, tol);
for k in 1:n loop
Qsig[k,:,:] := re + im*Tsig[k];
Qc[k,:,:] := re + im*Tc[k];
Qo[k,:,:] := re + im*To[k];
end for;
di_f := -im*Tsig_s*Tsig[1]*Complex.prodC(Qsig[2:n,:,:])*
Complex.invC(xsig[1]*(qs*Complex.prodC(Qo) + (1 + qs)*im*Tsig_s*Complex.prodC(Qc))) -
(re*i_f0[1] + im*i_f0[2]);
di_f2 := Complex.detC(di_f);
end i_field;
function Tsig_xsig "Calculates Tsig and xsig"
extends Modelica.Icons.Function;
input Integer n "transient order";
input Real[n] ac "polynome coefficient closed loop";
input Real[n] ao "polynome coefficient open loop";
input SIpu.Reactance xsig_s(unit="1") "leakage reactance stator";
input SIpu.Reactance[n+1] xm(each unit="1") "coupling reactance";
input Boolean field "field winding yes/no";
input Real tol "tolerance, iterative solution";
output SI.Angle[n] Tsig "sig-time constants";
output SIpu.Reactance[n] xsig(each unit="1") "leakage reactance rotor";
output Boolean result "true if Tsig real and convergence tol-ok";
protected
final parameter Integer n1=n-1;
constant Integer maxiter=10;
Integer iter;
Real qs;
Real qm;
Real qsm;
Real[n] asig;
Real[n] asig0;
Real[n] bsig;
Real[n] gsig;
Real[n,n] A;
Real[n,n] B;
Real[n,n] C;
Real[n] asig_prx;
Real[n] gsig_prx;
Real dasig;
Real dgsig;
import Modelica.Math.Matrices.inv;
algorithm
iter := 0;
qs := xsig_s/xm[n+1];
qm := xm[n]/xm[n+1];
qsm :=(xsig_s + xm[n+1])/(xm[n+1]*xm[n+1]);
bsig := qsm*(ao - ac);
if not field then
asig := ac - qs*(ao - ac);
(Tsig, result) := polyTime(asig);
for j in 1:n loop
B[j,1] := Tsig[j];
B[j,2:n] := polyCoef(cat(1, Tsig[1:j-1], Tsig[j+1:n]))*Tsig[j];
end for;
gsig := bsig*inv(B);
elseif field then
asig := ac - (qs + qm + qs*qm)*(ao - ac);
(Tsig, result) :=polyTime(asig);
if n < 3 then
for j in 1:n loop
B[j,1] := Tsig[j];
B[j,2:n] := polyCoef(cat(1, Tsig[1:j-1], Tsig[j+1:n]))*Tsig[j];
end for;
gsig := bsig*inv(B);
else
dgsig := 1 + tol;
dasig := 1 + tol;
asig0 := asig;
gsig :=zeros(n);
while (dgsig > tol or dasig > tol) and iter < maxiter and result loop
iter := iter + 1;
gsig_prx := gsig;
asig_prx := asig;
for j in 1:n loop
B[j,1] := Tsig[j];
B[j,2:n] := polyCoef(cat(1, Tsig[1:j-1], Tsig[j+1:n]))*Tsig[j];
end for;
for j in 1:n1 loop
C[j,1:2] := Tsig[j]*Tsig[n]*{0, 1};
C[j,3:n] := polyCoef(cat(1, Tsig[1:j-1], Tsig[j+1:n1]))*Tsig[j]*Tsig[n];
end for;
C[n,1:n] :=zeros(n);
A := B + xm[n1]*gsig[n]*C;
A[n,:] := A[n, :] + xm[n1]*gsig*C;
gsig :=(bsig + xm[n1]*gsig[n]*gsig*C)*inv(A);
asig := asig0 - xm[n1]*gsig[1:n1]*B[1:n1,:];
(Tsig, result) := polyTime(asig);
dgsig := sum(abs(gsig - gsig_prx))/sum(abs(gsig));
dasig := sum(abs(asig - asig_prx))/sum(abs(asig));
end while;
if iter == maxiter then
result := false;
end if;
end if;
end if;
xsig := ones(n)./gsig;
end Tsig_xsig;
function z_fromTransDat "Calculates impedance matrix z from transient data"
extends Modelica.Icons.Function;
input Integer n "transient order";
input SI.Angle[n] Tc "time constant closed-loop";
input SI.Angle[n] To "time constant open-loop";
input SIpu.Reactance x(unit="1") "total or syn reactance";
input SIpu.Reactance xsig_s(unit="1") "leakage reactance stator";
input SIpu.Resistance r_s "resistance stator";
input SIpu.Current if0(unit="1") "field current";
input SI.Angle alpha_if0
"angle field current (sign: mathematical convention)";
input Real tol "tolerance, iterative solution";
input Boolean field "field winding yes/no";
output SIpu.Resistance[n+1] zr(each unit="1") "impedance matrix resistive";
output SIpu.Reactance[n+1,n+1] zx(each unit="1")
"impedance matrix reactive";
protected
Real[n] ac;
Real[n] ao;
Real[n+1] xm;
Real[n] Tsig;
Real[n] xsig;
Boolean result;
import PowerSystems.Utilities.Math.fminSearch;
algorithm
if n==0 then
zr := {r_s};
zx := [x];
else
ac := polyCoef(Tc);
ao := polyCoef(To);
xm := cat(1, zeros(n), {x - xsig_s});
if field and n>1 then //minimises deviation from desired i_f
///// possible start-values:
if n==2 then
xm[n] := 0.06;
elseif n>2 then
xm[n-1:n] := {0.02,0.04};
end if;
///// may be eliminated after modification of fminSearch!
(xm[2:n],) := fminSearch(xm[2:n],
cat(1, ac, ao, Tc, To, {xsig_s}, {xm[n+1]}, {r_s}, if0*{cos(alpha_if0),sin(alpha_if0)}, {tol}));
end if;
(Tsig, xsig, result) := Tsig_xsig(n, ac, ao, xsig_s, xm, field, tol);
assert(result, "Tsig and xsig may be false, no convergence, or complex time-constants");
zr := cat(1, xsig./Tsig, {r_s});
zx := diagonal(cat(1, xsig, {xsig_s}));
for k in 2:n+1 loop
zx[1:k,1:k] := zx[1:k,1:k] + fill(xm[k], k, k);
end for;
end if;
end z_fromTransDat;
function z_fromEqCirc "Calculates impedance matrix z from equivalent circuit"
extends Modelica.Icons.Function;
input Integer n "transient order";
input SIpu.Reactance x(unit="1") "total or syn reactance";
input SIpu.Reactance xsig_s(unit="1") "leakage reactance stator";
input SIpu.Resistance r_s(unit="1") "resistance stator";
input SIpu.Reactance[n-1] xm2_n(each unit="1") "coupling reactance";
input SIpu.Reactance[n] xsig_r(each unit="1") "leakage reactance rotor";
input SIpu.Resistance[n] r_r(each unit="1") "resistance rotor";
output SIpu.Resistance[n+1] zr(each unit="1") "impedance matrix resistive";
output SIpu.Reactance[n+1,n+1] zx(each unit="1")
"impedance matrix reactive";
algorithm
zr := cat(1, r_r, {r_s});
zx := diagonal(cat(1, xsig_r, {xsig_s}));
for k in 2:n loop
zx[1:k,1:k] := zx[1:k,1:k] + fill(xm2_n[k-1], k, k);
end for;
zx := zx + fill(x - xsig_s, n+1, n+1);
end z_fromEqCirc;
function equiCircuit "Calculates equivalent circuit from transient data"
extends Modelica.Icons.Function;
input Integer n "transient order";
input SI.Angle[n] Tc "time constant closed-loop";
input SI.Angle[n] To "time constant open-loop";
input SIpu.Reactance x(unit="1") "total or syn reactance";
input SIpu.Reactance xsig_s(unit="1") "leakage reactance stator";
input SIpu.Resistance r_s(unit="1") "resistance stator";
input SIpu.Current if0(unit="1") "field current";
input SI.Angle alpha_if0
"angle field current (sign: mathematical convention)";
input Real tol "tolerance, iterative solution";
input Boolean field "field winding yes/no";
output SIpu.Resistance[n] r_r(each unit="1") "resistance rotor";
output SIpu.Reactance[n] xsig_r(each unit="1") "leakage reactance rotor";
output SIpu.Reactance[n+1] xm(each unit="1") "coupling reactance";
protected
Real[n] ac;
Real[n] ao;
Real[n] Tsig;
Real dif;
Boolean result;
import PowerSystems.Utilities.Math.fminSearch;
algorithm
xm := cat(1, zeros(n), {x - xsig_s});
if n==0 then
r_r := fill(0, n);
xsig_r := fill(0, n);
else
ac := polyCoef(Tc);
ao := polyCoef(To);
if field and n>1 then //minimises deviation from desired i_f
///// possible start-values:
if n==2 then
xm[n] := 0.06;
elseif n>2 then
xm[n-1:n] := {0.02,0.04};
end if;
///// may be eliminated after modification of fminSearch!
(xm[2:n], dif) := fminSearch(xm[2:n],
cat(1, ac, ao, Tc, To, {xsig_s}, {xm[n+1]}, {r_s}, if0*{cos(alpha_if0),sin(alpha_if0)}, {tol}));
end if;
(Tsig, xsig_r, result) := Tsig_xsig(n, ac, ao, xsig_s, xm, field, tol);
assert(result, "Tsig and xsig may be false, no convergence, or complex time-constants");
for k in 1:n loop
r_r[k] := xsig_r[k]/Tsig[k];
end for;
end if;
end equiCircuit;
function transientData "Calculates transient data from equivalent circuit"
extends Modelica.Icons.Function;
input Integer n "transient order";
input SIpu.Reactance x(unit="1") "total or syn reactance";
input SIpu.Reactance xsig_s(unit="1") "leakage reactance stator";
input SIpu.Resistance r_s(unit="1") "resistance stator";
input SIpu.Reactance[n-1] xm2_n(each unit="1") "coupling reactance";
input SIpu.Reactance[n] xsig_r(each unit="1") "leakage reactance rotor";
input SIpu.Resistance[n] r_r(each unit="1") "resistance rotor";
output SI.Angle[n] Tc "time constant closed-loop";
output SI.Angle[n] To "time constant open-loop";
output SIpu.Reactance[n] xtr(each unit="1") "transient reactance";
import Modelica.Constants.eps;
protected
Real[n+1] xm;
Real[n+1,n+1] X;
Real[n,n] X11;
Real[n,n] X11ac;
Real[n] sRinv;
Real[n,2] lam "2nd index=1:2, real and imaginary part";
import Modelica.Math.Matrices.eigenValues;
import PowerSystems.Utilities.Math.sortDown;
algorithm
xm := cat(1, {0}, xm2_n, {x - xsig_s});
X := diagonal(cat(1, xsig_r, {xsig_s}));
for k in 2:n+1 loop
X[1:k,1:k] := X[1:k,1:k] + xm[k]*ones(k,k);
end for;
X11 := diagonal(xsig_r);
for k in 2:n loop
X11[1:k,1:k] := X11[1:k,1:k] + xm[k]*ones(k,k);
end for;
X11 := X11 + xm[n+1]*ones(n,n);
X11ac := transpose(X[n+1:n+1, 1:n])*transpose(X[1:n, n+1:n+1])/X[n + 1, n + 1];
sRinv := ones(n)./sqrt(r_r);
lam := eigenValues(diagonal(sRinv)*X11*diagonal(sRinv));
To := sortDown(lam[:,1]);
assert(max(abs(lam[:,2])) < eps, "spectrum open-loop is not real!");
lam := eigenValues(diagonal(sRinv)*(X11 - X11ac)*diagonal(sRinv));
Tc := sortDown(lam[:,1]);
assert(max(abs(lam[:,2])) < eps, "spectrum closed-loop is not real!");
xtr := x_transient(x, Tc, To);
end transientData;
end Precalculation; |
Transform functions | within PowerSystems.Utilities;
package Transforms "Transform functions"
extends Modelica.Icons.Package;
constant Real[3, 3] Park0=[[2, -1, -1]/sqrt(6); [0, 1, -1]/sqrt(2); [1, 1, 1]/sqrt(3)]
"Orthogonal transform = Park(theta=0)";
constant Real[3, 3] J_abc=[0,-1,1; 1,0,-1; -1,1,0]/sqrt(3)
"Rotation (pi/2) around {1,1,1} and projection on orth plane";
//constant Real[3, 3] J_abc=skew(fill(sqrt(1/3), 3))/ "alternative";
//J_abc = P0'*J_dq0*P0 = Park'*J_dq0*Park
constant Real[3, 3] J_dq0=[0,-1,0; 1,0,0; 0,0,0]
"Rotation (pi/2) around {0,0,1} and projection on orth plane";
//J_dq0 = P0*J_abc*P0' = Park*J_abc*Park'
function j_abc
"Rotation(pi/2) of vector around {1,1,1} and projection on orth plane"
extends Modelica.Icons.Function;
input Real[3] u "vector (voltage, current)";
output Real[3] y "rotated vector (voltage, current)";
protected
constant Real s13=sqrt(1/3);
algorithm
y := s13*{u[3]-u[2], u[1]-u[3], u[2]-u[1]};
end j_abc;
function jj_abc
"Rotation(pi/2) of vector around {1,1,1} and projection on orth plane"
extends Modelica.Icons.Function;
input Real[3,:] u "array of 3-vectors (voltage, current)";
output Real[3,size(u,2)] y "array of rotated vectors (voltage, current)";
protected
constant Real s13=sqrt(1/3);
algorithm
y := s13*{u[3,:]-u[2,:], u[1,:]-u[3,:], u[2,:]-u[1,:]};
end jj_abc;
function j_dq0
"Rotation(pi/2) of vector around {0,0,1} and projection on orth plane"
extends Modelica.Icons.Function;
input Real[:] u "vector (voltage, current)";
output Real[size(u,1)] y "rotated vector (voltage, current)";
algorithm
y := cat(1, {-u[2], u[1]}, zeros(size(u,1)-2));
end j_dq0;
function jj_dq0
"Rotation(pi/2) of vector around {0,0,1} and projection on orth plane"
extends Modelica.Icons.Function;
input Real[:,:] u "array of 3- (or 2-) vectors (voltage, current)";
output Real[size(u,1),size(u,2)] y
"array of rotated vectors (voltage, current)";
algorithm
y := cat(1, {-u[2,:], u[1,:]}, zeros(size(u,1)-2, size(u,2))); // Dymola implementation now ok?
// y := cat(1, {-u[2,1:size(u,2)], u[1,1:size(u,2)]}, zeros(size(u,1)-2, size(u,2))); // preliminary until bug removed
end jj_dq0;
function park "Park transform"
extends Modelica.Icons.Function;
input SI.Angle theta "transformation angle";
output Real[3,3] P "Park transformation matrix";
protected
constant Real s13=sqrt(1/3);
constant Real s23=sqrt(2/3);
constant Real dph_b=2*Modelica.Constants.pi/3;
constant Real dph_c=4*Modelica.Constants.pi/3;
Real[3] c;
Real[3] s;
algorithm
c := cos({theta, theta - dph_b, theta - dph_c});
s := sin({theta, theta - dph_b, theta - dph_c});
P := transpose([s23*c, -s23*s, {s13, s13, s13}]);
end park;
function der_park "Derivative of Park transform"
extends Modelica.Icons.Function;
input SI.Angle theta "transformation angle";
input SI.AngularFrequency omega "d/dt theta";
output Real[3, 3] der_P "d/dt park";
protected
constant Real s23=sqrt(2/3);
constant Real dph_b=2*Modelica.Constants.pi/3;
constant Real dph_c=4*Modelica.Constants.pi/3;
Real[3] c;
Real[3] s;
Real s23omega;
algorithm
s23omega := s23*omega;
c := cos({theta, theta - dph_b, theta - dph_c});
s := sin({theta, theta - dph_b, theta - dph_c});
der_P := transpose([-s23omega*s, -s23omega*c, {0, 0, 0}]);
end der_park;
function der2_park "2nd derivative of Park transform"
extends Modelica.Icons.Function;
input SI.Angle theta "transformation angle";
input SI.AngularFrequency omega "d/dt theta";
input SI.AngularAcceleration omega_dot "d/dt omega";
output Real[3, 3] der2_P "d2/dt2 park";
protected
constant Real s23=sqrt(2/3);
constant Real dph_b=2*Modelica.Constants.pi/3;
constant Real dph_c=4*Modelica.Constants.pi/3;
Real[3] c;
Real[3] s;
Real s23omega_dot;
Real s23omega2;
algorithm
s23omega_dot := s23*omega_dot;
s23omega2 := s23*omega*omega;
c := cos({theta, theta - dph_b, theta - dph_c});
s := sin({theta, theta - dph_b, theta - dph_c});
der2_P := transpose([-s23omega_dot*s - s23omega2*c, -s23omega_dot*c + s23omega2*s, {0, 0, 0}]);
end der2_park;
function rotation_dq "Rotation matrix dq"
extends Modelica.Icons.Function;
input SI.Angle theta "rotation angle";
output Real[2, 2] R_dq "rotation matrix";
protected
Real c;
Real s;
algorithm
c := cos(theta);
s := sin(theta);
R_dq := [c, -s; s, c];
end rotation_dq;
function der_rotation_dq "Derivative of rotation matrix dq"
extends Modelica.Icons.Function;
input SI.Angle theta;
input SI.AngularFrequency omega "d/dt theta";
output Real[2, 2] der_R_dq "d/dt rotation_dq";
protected
Real dc;
Real ds;
algorithm
dc := -omega*sin(theta);
ds := omega*cos(theta);
der_R_dq := [dc, -ds; ds, dc];
end der_rotation_dq;
function der2_rotation_dq "2nd derivative of rotation matrix dq"
extends Modelica.Icons.Function;
input SI.Angle theta;
input SI.AngularFrequency omega "d/dt theta";
input SI.AngularAcceleration omega_dot "d/dt omega";
output Real[2, 2] der2_R_dq "d/2dt2 rotation_dq";
protected
Real c;
Real s;
Real d2c;
Real d2s;
Real omega2=omega*omega;
algorithm
c := cos(theta);
s := sin(theta);
d2c := -omega_dot*s - omega2*c;
d2s := omega_dot*c - omega2*s;
der2_R_dq := [d2c, -d2s; d2s, d2c];
end der2_rotation_dq;
function rotation_abc "Rotation matrix abc"
extends Modelica.Icons.Function;
input SI.Angle theta "rotation angle";
output Real[3,3] R_abc "rotation matrix";
protected
constant Real q13=1/3;
constant Real s13=1/sqrt(3);
Real c;
Real ac;
Real bs;
Real[3] g;
algorithm
c := cos(theta);
ac := q13*(1 - c);
bs := s13*sin(theta);
g := {ac + c, ac + bs, ac - bs};
R_abc := [g[{1,2,3}], g[{3,1,2}], g[{2,3,1}]];
end rotation_abc;
function der_rotation_abc "Derivative of rotation matrix abc"
extends Modelica.Icons.Function;
input SI.Angle theta;
input SI.AngularFrequency omega "d/dt theta";
output Real[3, 3] der_R_abc "d/dt rotation_abc";
protected
constant Real q13=1/3;
constant Real s13=1/sqrt(3);
Real s;
Real as;
Real bc;
Real[3] dg;
algorithm
s := sin(theta);
as := q13*s;
bc := s13*cos(theta);
dg := omega*{as - s, as + bc, as - bc};
der_R_abc := [dg[{1,2,3}], dg[{3,1,2}], dg[{2,3,1}]];
end der_rotation_abc;
function der2_rotation_abc "2nd derivative of rotation matrix abc"
extends Modelica.Icons.Function;
input SI.Angle theta;
input SI.AngularFrequency omega "d/dt theta";
input SI.AngularAcceleration omega_dot "d/dt omega";
output Real[3, 3] der2_R_abc "d2/dt2 rotation_abc";
protected
constant Real q13=1/3;
constant Real s13=1/sqrt(3);
Real c;
Real s;
Real ac;
Real as;
Real bc;
Real bs;
Real[3] d2g;
algorithm
c := cos(theta);
s := sin(theta);
ac := q13*c;
as := q13*s;
bc := s13*cos(theta);
bs := s13*sin(theta);
d2g := omega*omega*{ac - c, ac - bs, ac + bs} + omega_dot*{as - s, as + bc, as - bc};
der2_R_abc := [d2g[{1,2,3}], d2g[{3,1,2}], d2g[{2,3,1}]];
end der2_rotation_abc;
function permutation "Permutation of vector components"
extends Modelica.Icons.Function;
input Integer s(min=-1,max=1) "(-1, 0, 1), numbers permutation";
input Real[3] u "vector";
output Real[3] v "permuted vector";
algorithm
if s == 1 then
v := u[{2,3,1}];
elseif s == -1 then
v := u[{3,1,2}];
else
v := u;
end if;
end permutation;
function der_permutation "Derivative of permutation of vector components"
extends Modelica.Icons.Function;
input Integer s(min=-1,max=1) "(-1, 0, 1), numbers permutation";
input Real[3] u "vector";
input Real[3] der_u "d/dt u";
output Real[3] der_v "d/dt permutation";
algorithm
if s == 1 then
der_v := der_u[{2,3,1}];
elseif s == -1 then
der_v := der_u[{3,1,2}];
else
der_v := der_u;
end if;
end der_permutation;
function der2_permutation
"2nd derivative of permutation of vector components"
extends Modelica.Icons.Function;
input Integer s(min=-1,max=1) "(-1, 0, 1), numbers permutation";
input Real[3] u "vector";
input Real[3] der_u "d/dt u";
input Real[3] der2_u "d2/dt2 u";
output Real[3] der2_v "d2/dt2 permutation";
algorithm
if s == 1 then
der2_v := der2_u[{2,3,1}];
elseif s == -1 then
der2_v := der2_u[{3,1,2}];
else
der2_v := der2_u;
end if;
end der2_permutation;
end Transforms; |
Components | within PhotoVoltaics;
package Components "Components"
extends Modelica.Icons.Package;
end Components; |
Sampling maximum power tracker. This is a simple model of sampling maximum power tracker. The initial output of this tracker is maximum power voltage
<code>VmpRef</code>. After that, the sensed input power in sampled by a fixed sampling period. The output voltage is decreased by
a voltage step of <code>VmpRef/n</code>. If then then actual power is greater than the previous power, the sign of of voltage change
does not change. If the actual power is less than the previous power, the direction of the voltage change is swiched. This way
the sampling maximum power tracker is permanently searching for a local maximum. | within PhotoVoltaics.Components.Blocks;
block MPTrackerSample "Sampling maximum power tracker"
extends Modelica.Blocks.Icons.Block;
parameter Modelica.Units.SI.Time startTime=0 "Start time";
parameter Modelica.Units.SI.Time samplePeriod=1 "Sample period";
parameter Modelica.Units.SI.Voltage VmpRef
"Reference maximum power power of plant";
parameter Modelica.Units.SI.Current ImpRef
"Reference maximum power current of plant";
parameter Integer n = 100 "Number of voltage and power discretizations";
final parameter Modelica.Units.SI.Voltage dv=VmpRef/n
"Voltage change and maximum deviation";
final parameter Modelica.Units.SI.Power dpower=VmpRef*ImpRef/n
"Power change and maximum deviation";
Boolean firstTrigger(start = false, fixed = true) "First boolean sample trigger signal";
// Boolean secondTrigger "Second boolean sample trigger signal";
Boolean sampleTrigger "Boolean sample trigger signal";
discrete Integer counter(final start = 0, fixed = true) "Sample counter";
discrete Real signv(final start = -1, fixed = true) "Sign of voltage change";
Modelica.Blocks.Interfaces.RealInput power(final unit = "W") "Power"
Modelica.Blocks.Interfaces.RealOutput vRef(final unit = "V", final start = VmpRef, fixed = true) "Reference DC voltage"
algorithm
sampleTrigger := sample(startTime, samplePeriod);
when sampleTrigger then
counter := pre(counter) + 1;
firstTrigger := time <= startTime + samplePeriod / 2;
vRef := pre(vRef) + signv * dv;
if not firstTrigger and power < pre(power) then
signv := -pre(signv);
end if;
if vRef <= 3 * dv then
signv := 1;
end if;
end when;
// Change direction of voltage derivative
// Do not allow negative voltages
end MPTrackerSample; |
Blocks | within PhotoVoltaics.Components;
package Blocks "Blocks"
extends Modelica.Icons.Package;
end Blocks; |
Calculates to the power of 10. | within PhotoVoltaics.Components.Blocks;
model Power10 "Calculates to the power of 10"
extends Modelica.Blocks.Interfaces.SISO;
parameter Real k "Gain";
equation
y = k * 10 ^ u;
end Power10; |
DC controlled single phase DC/AC converter. This is an ideal DC/DC converter. | within PhotoVoltaics.Components.Converters;
model DCConverter "DC controlled single phase DC/AC converter"
extends Modelica.Electrical.PowerConverters.Interfaces.DCDC.DCtwoPin1;
extends Modelica.Electrical.PowerConverters.Interfaces.DCDC.DCtwoPin2;
extends .PhotoVoltaics.Icons.Converter;
parameter Modelica.Units.SI.Voltage VRef=48
"Reference DC source voltage";
parameter Modelica.Units.SI.Time Ti=1E-6
"Internal integration time constant";
Modelica.Blocks.Interfaces.RealInput vDCRef(final unit = "V") "DC voltage"
Modelica.Electrical.Analog.Sources.SignalVoltage signalVoltage
Modelica.Electrical.Analog.Sensors.CurrentSensor currentSensor
Modelica.Blocks.Math.Product product
Modelica.Blocks.Math.Feedback feedback
Modelica.Electrical.Analog.Sources.SignalCurrent variableCurrentSource
Modelica.Electrical.Analog.Sensors.PowerSensor powerSensor
Modelica.Blocks.Continuous.Integrator integrator(k=1/VRef/Ti)
Modelica.Blocks.Math.Gain gain(final k = -1)
equation
connect(currentSensor.n, signalVoltage.p)
connect(signalVoltage.v, vDCRef)
connect(currentSensor.i, product.u1)
connect(vDCRef, product.u2)
connect(product.y, feedback.u1)
connect(feedback.y, integrator.u)
connect(gain.y, feedback.u2)
connect(gain.u, powerSensor.power)
connect(powerSensor.nc, variableCurrentSource.n)
connect(integrator.y, variableCurrentSource.i)
connect(powerSensor.pv, powerSensor.pc)
connect(currentSensor.p, dc_p1)
connect(signalVoltage.n, dc_n1)
connect(powerSensor.pc, dc_p2)
connect(variableCurrentSource.p, dc_n2)
connect(dc_n2, powerSensor.nv)
end DCConverter; |