text
stringlengths
1
4.74k
code
stringlengths
69
637k
DC DC converter
within AixLib.Electrical.DC.Conversion; model DCDCConverter "DC DC converter" extends AixLib.Electrical.Interfaces.PartialConversion( redeclare package PhaseSystem_p = PhaseSystems.TwoConductor, redeclare package PhaseSystem_n = PhaseSystems.TwoConductor, redeclare Interfaces.Terminal_n terminal_n, redeclare Interfaces.Terminal_p terminal_p); parameter Modelica.Units.SI.Voltage VHigh "DC voltage on side 1 of the transformer (primary side)"; parameter Modelica.Units.SI.Voltage VLow "DC voltage on side 2 of the transformer (secondary side)"; parameter Modelica.Units.SI.Efficiency eta(max=1) "Converter efficiency"; parameter Boolean ground_1 = true "Connect side 1 of converter to ground" parameter Boolean ground_2 = true "Connect side 2 of converter to ground" Modelica.Units.SI.Power LossPower "Loss power"; protected parameter Real conversionFactor = VLow/VHigh "Ratio of high versus low voltage"; Modelica.Units.SI.Current i1; Modelica.Units.SI.Current i2; Modelica.Units.SI.Voltage v1; Modelica.Units.SI.Voltage v2; Modelica.Units.SI.Power P_p "Power at terminal p"; Modelica.Units.SI.Power P_n "Power at terminal n"; equation Connections.potentialRoot(terminal_n.theta); Connections.potentialRoot(terminal_p.theta); if not ground_1 then i1 = 0; else v1 = 0; end if; if not ground_2 then i2 = 0; else v2 = 0; end if; P_p = PhaseSystem_p.activePower(terminal_p.v, terminal_p.i); P_n = PhaseSystem_n.activePower(terminal_n.v, terminal_n.i); v1 = terminal_n.v[2]; v2 = terminal_p.v[2]; sum(terminal_n.i) + i1 = 0; sum(terminal_p.i) + i2 = 0; // Voltage relation v_p = v_n*conversionFactor; // OLD equations that take into account the power at the secondary // power balance // LossPower = (1-eta) * abs(P_p); // P_n + P_p - LossPower = 0; // Symmetric and linear version LossPower = P_p + P_n; if i_n >=0 then i_p = i_n/conversionFactor/(eta - 2); else i_n = conversionFactor*i_p/(eta - 2); end if; end DCDCConverter;
Package with models for DC/DC conversion
within AixLib.Electrical.DC; package Conversion "Package with models for DC/DC conversion" extends Modelica.Icons.Package; end Conversion;
Test model DC to DC converter. This model illustrates the use of a model that converts between DC voltages.
within AixLib.Electrical.DC.Conversion.Examples; model DCDCConverter "Test model DC to DC converter" extends Modelica.Icons.Example; AixLib.Electrical.DC.Loads.Conductor resistor( mode=AixLib.Electrical.Types.Load.FixedZ_steady_state, P_nominal=-2000, V_nominal=60) "Resistive load" AixLib.Electrical.DC.Sources.ConstantVoltage sou(V=120) "Voltage source" AixLib.Electrical.DC.Conversion.DCDCConverter conDCDC( VHigh=120, VLow=60, eta=0.9, i_n(start=0)) "DC/DC transformer" AixLib.Electrical.DC.Loads.Conductor conductor(mode=AixLib.Electrical.Types.Load.VariableZ_P_input, V_nominal=60, P_nominal=10e3) "Variable resistive load" Modelica.Blocks.Sources.Ramp varLoad_P( duration=0.5, startTime=0.3, offset=-1000, height=10000) AixLib.Electrical.DC.Sensors.GeneralizedSensor sen "Power sensor" equation connect(varLoad_P.y, conductor.Pow) connect(conDCDC.terminal_p, resistor.terminal) connect(conDCDC.terminal_p, conductor.terminal) connect(sou.terminal, sen.terminal_n) connect(sen.terminal_p, conDCDC.terminal_n) end DCDCConverter;
Package with example models
within AixLib.Electrical.DC.Conversion; package Examples "Package with example models" extends Modelica.Icons.ExamplesPackage; end Examples;
Package with interfaces for DC electrical systems
within AixLib.Electrical.DC; package Interfaces "Package with interfaces for DC electrical systems" extends Modelica.Icons.InterfacesPackage; end Interfaces;
Terminal n for DC electrical systems
within AixLib.Electrical.DC.Interfaces; connector Terminal_n "Terminal n for DC electrical systems" extends AixLib.Electrical.Interfaces.Terminal( redeclare package PhaseSystem = AixLib.Electrical.PhaseSystems.TwoConductor); end Terminal_n;
Terminal p for DC electrical systems
within AixLib.Electrical.DC.Interfaces; connector Terminal_p "Terminal p for DC electrical systems" extends AixLib.Electrical.Interfaces.Terminal( redeclare package PhaseSystem = AixLib.Electrical.PhaseSystems.TwoConductor); end Terminal_p;
Model of a DC electrical line
within AixLib.Electrical.DC.Lines; model Line "Model of a DC electrical line" extends AixLib.Electrical.Transmission.BaseClasses.PartialLine( redeclare package PhaseSystem_p = PhaseSystems.TwoConductor, redeclare package PhaseSystem_n = PhaseSystems.TwoConductor, redeclare Interfaces.Terminal_n terminal_n, redeclare Interfaces.Terminal_p terminal_p, final modelMode=Types.Load.FixedZ_steady_state, commercialCable = AixLib.Electrical.Transmission.Functions.selectCable_low(P_nominal, V_nominal)); TwoPortRCLine lineRC( final useHeatPort=true, final R=R, final V_nominal=V_nominal, final T_ref=T_ref, final M=M, final C=C, final use_C=use_C) equation connect(terminal_n, lineRC.terminal_n) connect(lineRC.terminal_p, terminal_p) connect(cableTemp.port, lineRC.heatPort) end Line;
Package with models for DC electrical lines
within AixLib.Electrical.DC; package Lines "Package with models for DC electrical lines" extends Modelica.Icons.Package; end Lines;
Model of a two port DC resistance and capacity (T-model)
within AixLib.Electrical.DC.Lines; model TwoPortRCLine "Model of a two port DC resistance and capacity (T-model)" extends AixLib.Electrical.Transmission.BaseClasses.PartialTwoPortRLC( redeclare package PhaseSystem_p = PhaseSystems.TwoConductor, redeclare package PhaseSystem_n = PhaseSystems.TwoConductor, redeclare Interfaces.Terminal_n terminal_n, redeclare Interfaces.Terminal_p terminal_p, final L=0); parameter Boolean use_C = false "Set to true to add a capacitance in the center of the line" parameter Modelica.Units.SI.Voltage Vc_start=V_nominal "Initial value of the voltage of the capacitance in the middle of the line"; Modelica.Units.SI.Voltage Vc(start=Vc_start, stateSelect=StateSelect.prefer) "Voltage of the capacitor"; initial equation if C>0 and use_C then Vc = Vc_start; end if; equation terminal_p.v[1] - (Vc+terminal_p.v[2]) = terminal_p.i[1]*R_actual/2; terminal_n.v[1] - (Vc+terminal_p.v[2]) = terminal_n.i[1]*R_actual/2; if C>0 and use_C then C*der(Vc) = terminal_p.i[1] + terminal_n.i[1]; else Vc = 0.5*(terminal_p.v[1] - terminal_p.v[2] + terminal_n.v[1] - terminal_n.v[2]); end if; terminal_p.v[2] = terminal_n.v[2]; terminal_p.i[2] + terminal_n.i[2] = 0; // Joule losses LossPower = R_actual/2*terminal_p.i[1]^2 + R_actual/2*terminal_n.i[1]^2; end TwoPortRCLine;
Model of a two port DC resistance
within AixLib.Electrical.DC.Lines; model TwoPortResistance "Model of a two port DC resistance" extends AixLib.Electrical.Transmission.BaseClasses.PartialTwoPortResistance( redeclare package PhaseSystem_p = PhaseSystems.TwoConductor, redeclare package PhaseSystem_n = PhaseSystems.TwoConductor, redeclare Interfaces.Terminal_n terminal_n, redeclare Interfaces.Terminal_p terminal_p); equation // Voltage drop on the resistance lumped on connection between terminals // p.v[1] and n.v[1] terminal_p.v[1] - terminal_n.v[1] = terminal_p.i[1]*R_actual; terminal_p.v[2] = terminal_n.v[2]; // Joule losses LossPower = R_actual*terminal_p.i[1]^2; end TwoPortResistance;
Example model to test the DC lines. This model is a simple test case that show how to use a line model and parametrize it using a commercial cable.
within AixLib.Electrical.DC.Lines.Examples; model DCLine "Example model to test the DC lines" extends Modelica.Icons.Example; Line line( P_nominal=500, V_nominal=50, mode=Types.CableMode.commercial, commercialCable=Transmission.LowVoltageCables.PvcAl16(), l=100) "Transmission line" Sources.ConstantVoltage E(V=50) "Voltage source" Line line1( P_nominal=500, V_nominal=50, mode=Types.CableMode.commercial, commercialCable=Transmission.LowVoltageCables.PvcAl16(), l=100) "Transmission line" Line line2( P_nominal=500, V_nominal=50, mode=Types.CableMode.commercial, commercialCable=Transmission.LowVoltageCables.PvcAl16(), l=100) "Transmission line" Modelica.Electrical.Analog.Basic.Ground ground Loads.Conductor load1(mode=Types.Load.VariableZ_y_input, V_nominal=50, linearized=false, P_nominal=-50) "Variable load" Loads.Conductor load2( V_nominal=50, linearized=false, P_nominal=-150) "Load" Loads.Conductor load3( V_nominal=50, linearized=false, P_nominal=-200) "Load" Modelica.Blocks.Sources.Ramp varLoad( height=0.8, duration=0.5, offset=0.2, startTime=0.3) "Load consumption profile" equation connect(E.terminal, line.terminal_n) connect(E.terminal, line1.terminal_n) connect(E.terminal, line2.terminal_n) connect(load1.terminal, line.terminal_p) connect(line1.terminal_p, load2.terminal) connect(line2.terminal_p, load3.terminal) connect(varLoad.y, load1.y) connect(E.n, ground.p) end DCLine;
Example model to test the possible combinations between line and load models. This model shows a DC grid with 10 loads and 16 cables. Each cable is of length <i>l = 10</i> meters, a parameter that can be modified. Each load can be either be a full nonlinear model, or be replaced by the linearized version. The parameter <code>linearLoads = false</code> can be used to switch between linear and nonlinear implementation.
within AixLib.Electrical.DC.Lines.Examples; model DCLines "Example model to test the possible combinations between line and load models" extends Modelica.Icons.Example; parameter Boolean linearLoads = false "Flag that selects between linearized or nonlinear load models"; parameter Real L = 10 "Length of each cable"; Modelica.Units.SI.Power Sloads=load1.S[1] + load2.S[1] + load3.S[1] + load4.S[ 1] + load5.S[1] + load6.S[1] + load7.S[1] + load8.S[1] + load9.S[1] + load10.S[1] "Sum of the power consumed by the loads"; Line line( P_nominal=500, V_nominal=50, mode=Types.CableMode.commercial, commercialCable=Transmission.LowVoltageCables.PvcAl16(), l=L, terminal_n(v(each start=0))) "Transmission line" Sources.ConstantVoltage E(V=50) "Voltage source" Line line1( P_nominal=500, V_nominal=50, mode=Types.CableMode.commercial, commercialCable=Transmission.LowVoltageCables.PvcAl16(), l=L) "Transmission line" Line line2( P_nominal=500, V_nominal=50, mode=Types.CableMode.commercial, commercialCable=Transmission.LowVoltageCables.PvcAl16(), l=L) "Transmission line" Modelica.Electrical.Analog.Basic.Ground ground Loads.Conductor load1(mode=Types.Load.VariableZ_y_input, V_nominal=50, linearized=linearLoads, P_nominal=-150) "Load" Loads.Conductor load2( V_nominal=50, mode=Types.Load.VariableZ_y_input, linearized=linearLoads, P_nominal=-120) "Load" Loads.Conductor load3( V_nominal=50, mode=Types.Load.VariableZ_y_input, linearized=linearLoads, P_nominal=-200) "Load" Modelica.Blocks.Sources.Trapezoid varLoad1( offset=0.4, amplitude=0.6, rising=600, width=1000, falling=800, period=3600, startTime=1800) "Power consumption profile" Loads.Conductor load4( V_nominal=50, mode=Types.Load.VariableZ_y_input, linearized=linearLoads, P_nominal=-120) "Load" Line line3( P_nominal=500, V_nominal=50, mode=Types.CableMode.commercial, commercialCable=Transmission.LowVoltageCables.PvcAl16(), l=L) "Transmission line" Line line4( P_nominal=500, V_nominal=50, mode=Types.CableMode.commercial, commercialCable=Transmission.LowVoltageCables.PvcAl16(), l=L) "Transmission line" Line line5( P_nominal=500, V_nominal=50, mode=Types.CableMode.commercial, commercialCable=Transmission.LowVoltageCables.PvcAl16(), l=L) "Transmission line" Line line0( P_nominal=500, V_nominal=50, mode=Types.CableMode.commercial, commercialCable=Transmission.LowVoltageCables.PvcAl16(), l=L) "Transmission line" Modelica.Blocks.Sources.Trapezoid varLoad2( startTime=1800, amplitude=0.8, rising=400, width=1300, falling=900, period=4000, offset=0.1) "Power consumption profile" Line line6( P_nominal=500, V_nominal=50, mode=Types.CableMode.commercial, commercialCable=Transmission.LowVoltageCables.PvcAl16(), l=L) "Transmission line" Loads.Conductor load5( V_nominal=50, mode=Types.Load.VariableZ_y_input, linearized=linearLoads, P_nominal=-200) "Load" Modelica.Blocks.Sources.Trapezoid varLoad3( amplitude=0.7, rising=660, width=900, falling=300, period=3700, offset=0.3, startTime=200) "Power consumption profile" Loads.Conductor load6( V_nominal=50, mode=Types.Load.VariableZ_y_input, linearized=linearLoads, P_nominal=-120) "Load" Line line7( P_nominal=500, V_nominal=50, mode=Types.CableMode.commercial, commercialCable=Transmission.LowVoltageCables.PvcAl16(), l=L) "Transmission line" Line line8( P_nominal=500, V_nominal=50, mode=Types.CableMode.commercial, commercialCable=Transmission.LowVoltageCables.PvcAl16(), l=L) "Transmission line" Line line9( P_nominal=500, V_nominal=50, mode=Types.CableMode.commercial, commercialCable=Transmission.LowVoltageCables.PvcAl16(), l=L) "Transmission line" Loads.Conductor load7( V_nominal=50, mode=Types.Load.VariableZ_y_input, linearized=linearLoads, P_nominal=-200) "Load" Modelica.Blocks.Sources.Trapezoid varLoad4( rising=600, width=1000, falling=800, period=3600, amplitude=0.1, offset=0.8, startTime=3300) "Power consumption profile" Loads.Conductor load8( V_nominal=50, mode=Types.Load.VariableZ_y_input, linearized=linearLoads, P_nominal=-120) "Load" Line line10( P_nominal=500, V_nominal=50, mode=Types.CableMode.commercial, commercialCable=Transmission.LowVoltageCables.PvcAl16(), l=L) "Transmission line" Line line11( P_nominal=500, V_nominal=50, mode=Types.CableMode.commercial, commercialCable=Transmission.LowVoltageCables.PvcAl16(), l=L) "Transmission line" Line line12( P_nominal=500, V_nominal=50, mode=Types.CableMode.commercial, commercialCable=Transmission.LowVoltageCables.PvcAl16(), l=L) "Transmission line" Loads.Conductor load9( V_nominal=50, mode=Types.Load.VariableZ_y_input, linearized=linearLoads, P_nominal=-200) "Load" Modelica.Blocks.Sources.Trapezoid varLoad5( falling=800, amplitude=0.5, rising=800, width=800, period=3000, offset=0.5, startTime=0) "Power consumption profile" Loads.Conductor load10( V_nominal=50, mode=Types.Load.VariableZ_y_input, linearized=linearLoads, P_nominal=-120) "Load" Line line13( P_nominal=500, V_nominal=50, mode=Types.CableMode.commercial, commercialCable=Transmission.LowVoltageCables.PvcAl16(), l=L) "Transmission line" Line line14( P_nominal=500, V_nominal=50, mode=Types.CableMode.commercial, commercialCable=Transmission.LowVoltageCables.PvcAl16(), l=100) "Transmission line" equation connect(load1.terminal, line.terminal_p) connect(line1.terminal_p, line.terminal_n) connect(line2.terminal_p, line3.terminal_n) connect(line3.terminal_p, load3.terminal) connect(line1.terminal_p, line4.terminal_n) connect(line4.terminal_p, load2.terminal) connect(load4.terminal, line5.terminal_p) connect(line5.terminal_n, line3.terminal_n) connect(E.terminal, line0.terminal_n) connect(line0.terminal_p, line1.terminal_n) connect(varLoad1.y, load3.y) connect(varLoad1.y, load4.y) connect(varLoad2.y, load1.y) connect(varLoad2.y, load2.y) connect(line6.terminal_p,line7. terminal_n) connect(line7.terminal_p,load5. terminal) connect(load6.terminal,line8. terminal_p) connect(line8.terminal_n,line7. terminal_n) connect(varLoad3.y,load5. y) connect(varLoad3.y,load6. y) connect(line9.terminal_p, line10.terminal_n) connect(line10.terminal_p, load7.terminal) connect(load8.terminal, line11.terminal_p) connect(line11.terminal_n, line10.terminal_n) connect(varLoad4.y,load7. y) connect(varLoad4.y,load8. y) connect(line12.terminal_p, line13.terminal_n) connect(line13.terminal_p, load9.terminal) connect(load10.terminal, line14.terminal_p) connect(line14.terminal_n, line13.terminal_n) connect(varLoad5.y,load9. y) connect(varLoad5.y, load10.y) connect(line2.terminal_n, line4.terminal_n) connect(line6.terminal_n, line3.terminal_n) connect(line9.terminal_n, line7.terminal_n) connect(line12.terminal_n, line10.terminal_n) connect(E.n, ground.p) end DCLines;
Example model to test the possible combinations between line and load models. This model is the linearized version of the model <a href=\"modelica://AixLib.Electrical.DC.Lines.Examples.DCLines\"> AixLib.Electrical.DC.Lines.Examples.DCLines</a> and can be used to test how the linearized loads are affected by the voltage drop caused by the lines. The longer the distance between the load and the source, the bigger is the voltage drop and thus the error introduced by the linearization.
within AixLib.Electrical.DC.Lines.Examples; model DCLinesLinearized "Example model to test the possible combinations between line and load models" extends AixLib.Electrical.DC.Lines.Examples.DCLines(linearLoads = true); end DCLinesLinearized;
Package with example models
within AixLib.Electrical.DC.Lines; package Examples "Package with example models" extends Modelica.Icons.ExamplesPackage; end Examples;
Example model to test for the DC RC two port model. This model shows how to use a two port resistance-capacitance model. The example also shows a comparison between the dynamic and steady state version model that can be selected by changing the boolean flag <code>use_C</code>.
within AixLib.Electrical.DC.Lines.Examples; model RCModel "Example model to test for the DC RC two port model" extends Modelica.Icons.Example; TwoPortRCLine RC_ss( C=1, V_nominal=50, R=8) "Line resistance" Sources.ConstantVoltage constantVoltage(V=50) "Voltage source" Modelica.Electrical.Analog.Basic.Ground ground Loads.Resistor sc_ss(V_nominal=50, R=0) "Short circuit load" Sensors.GeneralizedSensor sen_ss "Sensor" TwoPortRCLine RC_dyn( C=1, V_nominal=50, use_C=true, R=8) "Line resistance" Loads.Resistor sc_dyn(V_nominal=50, R=0) "Load" Sensors.GeneralizedSensor sen_dyn "Sensor" equation connect(ground.p, constantVoltage.n) connect(constantVoltage.terminal, RC_ss.terminal_n) connect(RC_ss.terminal_p, sen_ss.terminal_n) connect(sen_ss.terminal_p, sc_ss.terminal) connect(RC_dyn.terminal_p, sen_dyn.terminal_n) connect(sen_dyn.terminal_p, sc_dyn.terminal) connect(constantVoltage.terminal, RC_dyn.terminal_n) end RCModel;
Example model to test for the DC resistance two port model. This model shows how to use a two port resistance. In this example the resistance connects an ideal constant voltage source with a short circuit. The current flowing through the circuit depends just on the value of the two port resistance.
within AixLib.Electrical.DC.Lines.Examples; model Resistance "Example model to test for the DC resistance two port model" extends Modelica.Icons.Example; TwoPortResistance lineR(R=10) "Line resistance" Sources.ConstantVoltage constantVoltage(V=50) "Voltage source" Modelica.Electrical.Analog.Basic.Ground ground Loads.Resistor short_circuit(V_nominal=50, R=0) "Short circuit load" Sensors.GeneralizedSensor sen "Power sensor" equation connect(ground.p, constantVoltage.n) connect(constantVoltage.terminal, lineR.terminal_n) connect(lineR.terminal_p, sen.terminal_n) connect(sen.terminal_p, short_circuit.terminal) end Resistance;
Model of a generic DC load
within AixLib.Electrical.DC.Loads; model Conductor "Model of a generic DC load" extends AixLib.Electrical.Interfaces.ResistiveLoad( redeclare package PhaseSystem = PhaseSystems.TwoConductor, redeclare Interfaces.Terminal_n terminal); protected Modelica.Units.SI.Voltage absDV "Absolute value of the voltage difference between the two conductors (used by the linearized model)"; equation absDV = abs(terminal.v[1]-terminal.v[2]); if linearized then // Linearized version of the model if absDV <= (8/9)*V_nominal then terminal.i[1] + P*(2/(0.8*V_nominal) - (terminal.v[1]-terminal.v[2])/(0.8*V_nominal)^2) = 0; elseif absDV >= (12/11)*V_nominal then terminal.i[1] + P*(2/(1.2*V_nominal) - (terminal.v[1]-terminal.v[2])/(1.2*V_nominal)^2) = 0; else terminal.i[1] + P*(2/V_nominal - (terminal.v[1]-terminal.v[2])/V_nominal^2) = 0; end if; else // Full nonlinear version of the model // PhaseSystem.activePower(terminal.v, terminal.i) + P = 0; if initMode == AixLib.Electrical.Types.InitMode.zero_current then i[1] = - homotopy(actual= P/(v[1] - v[2]), simplified= 0); else i[1] = - homotopy(actual= P/(v[1] - v[2]), simplified= P*(2/V_nominal - (v[1]-v[2])/V_nominal^2)); end if; end if; // Since the connector is a two conductor, the sum of the currents at the terminal // is null sum(i) = 0; end Conductor;
Package with models for DC electrical loads
within AixLib.Electrical.DC; package Loads "Package with models for DC electrical loads" extends Modelica.Icons.VariantsPackage; end Loads;
Ideal linear electrical resistor
within AixLib.Electrical.DC.Loads; model Resistor "Ideal linear electrical resistor" extends AixLib.Electrical.Interfaces.ResistiveLoad( redeclare package PhaseSystem = PhaseSystems.TwoConductor, redeclare Interfaces.Terminal_n terminal, final mode=AixLib.Electrical.Types.Load.FixedZ_steady_state, final P_nominal=V_nominal^2/max(R, Modelica.Constants.small)); extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(T = T_ref); parameter Modelica.Units.SI.Resistance R(start=1) "Resistance at temperature T_ref"; parameter Modelica.Units.SI.Temperature T_ref=300.15 "Reference temperature"; parameter Modelica.Units.SI.LinearTemperatureCoefficient alpha=0 "Temperature coefficient of resistance (R_actual = R*(1 + alpha*(T_heatPort - T_ref))"; Modelica.Units.SI.Resistance R_actual "Actual resistance = R*(1 + alpha*(T_heatPort - T_ref))"; equation assert((1 + alpha*(T_heatPort - T_ref)) >= Modelica.Constants.eps, "Temperature outside of scope of model"); R_actual = R*(1 + alpha*(T_heatPort - T_ref)); PhaseSystem.systemVoltage(v) = R_actual*PhaseSystem.systemCurrent(i); LossPower = PhaseSystem.activePower(v,i); sum(i) = 0; end Resistor;
Example model to check the linearized load model. This example demonstrates the use of a linealized load model <a href=\"modelica://AixLib.Electrical.DC.Loads.Conductor\">AixLib.Electrical.DC.Loads.Conductor</a>.
within AixLib.Electrical.DC.Loads.Examples; model LinearizedLoad "Example model to check the linearized load model" extends Modelica.Icons.Example; Real error = (sen_nlin.P - sen_lin.P)*100/sen_nlin.P "Percentage of error between the linearized and actual power consumption"; Real deltaV = LinearLoad.V_nominal - sen_lin.V "Voltage distance between nominal condition and actual voltage"; AixLib.Electrical.DC.Loads.Conductor NonlinearLoad( linearized=false, mode=AixLib.Electrical.Types.Load.VariableZ_P_input, V_nominal=100, P_nominal=0) "Nonlinear load model" Sources.ConstantVoltage sou(V=100) "Voltage source" Modelica.Electrical.Analog.Basic.Ground gro "Ground" Lines.TwoPortResistance Rline1(R=2) "Line resistance" Sensors.GeneralizedSensor sen_nlin "Sensor" AixLib.Electrical.DC.Loads.Conductor LinearLoad( mode=AixLib.Electrical.Types.Load.VariableZ_P_input, V_nominal=100, linearized=true, P_nominal=0) "Linearized load model" Sensors.GeneralizedSensor sen_lin "Sensor" Lines.TwoPortResistance Rline2(R=2) "Line resistance" Modelica.Blocks.Sources.Ramp ramp( duration=0.5, startTime=0.2, offset=-50, height=-950) "Power consumption" equation connect(sou.terminal, Rline1.terminal_n) connect(Rline1.terminal_p, sen_nlin.terminal_n) connect(sen_nlin.terminal_p, NonlinearLoad.terminal) connect(LinearLoad.terminal, sen_lin.terminal_p) connect(sou.n, gro.p) connect(sou.terminal, Rline2.terminal_n) connect(Rline2.terminal_p, sen_lin.terminal_n) connect(LinearLoad.Pow, ramp.y) connect(NonlinearLoad.Pow, ramp.y) end LinearizedLoad;
Package with example models
within AixLib.Electrical.DC.Loads; package Examples "Package with example models" extends Modelica.Icons.ExamplesPackage; end Examples;
Example model for resistor. This example demonstrates the use of the resistor model.
within AixLib.Electrical.DC.Loads.Examples; model Resistor "Example model for resistor" extends Modelica.Icons.Example; AixLib.Electrical.DC.Loads.Resistor res2(R=2, V_nominal=12) "Resistor" Sources.ConstantVoltage sou(V=12) "Voltage source" Modelica.Electrical.Analog.Basic.Ground gro "Ground" Lines.TwoPortResistance res(R=2) "Line resistance" Sensors.GeneralizedSensor sen "Sensor" AixLib.Electrical.DC.Loads.Resistor res1(R=2, V_nominal=12) "Resistor" Sensors.GeneralizedSensor sen1 "Sensor" equation connect(sou.terminal, res.terminal_n) connect(res.terminal_p, sen.terminal_n) connect(sen.terminal_p,res2. terminal) connect(res1.terminal, sen1.terminal_p) connect(sen1.terminal_n, res.terminal_n) connect(sou.n, gro.p) end Resistor;
Example using variable loads models. This example shows how to use three different types of load models. Each load is of type <a href=\"modelica://AixLib.Electrical.DC.Loads.Conductor\"> AixLib.Electrical.DC.Loads.Conductor</a>.
within AixLib.Electrical.DC.Loads.Examples; model VariableLoad "Example using variable loads models" extends Modelica.Icons.Example; Conductor loa1( V_nominal=12, linearized=false, P_nominal=-50) "Load" Sources.ConstantVoltage sou(V=12) "Voltage source" Modelica.Electrical.Analog.Basic.Ground gro "Ground" Conductor loa2( mode=Types.Load.VariableZ_y_input, V_nominal=12, P_nominal=-50) "Load" Modelica.Blocks.Sources.Ramp varLoad_y( height=0.8, duration=0.5, startTime=0.3, offset=0) "Power signal" Conductor loa3( V_nominal=12, P_nominal=0, mode=AixLib.Electrical.Types.Load.VariableZ_P_input) "Load" Modelica.Blocks.Sources.Ramp varLoad_P( duration=0.5, startTime=0.3, height=120, offset=-20) "Power signal" Lines.TwoPortResistance res(R=0.1) "Line resistance" Sensors.GeneralizedSensor sen "Sensor" equation connect(sou.terminal, loa2.terminal) connect(varLoad_y.y, loa2.y) connect(sou.terminal, loa3.terminal) connect(varLoad_P.y, loa3.Pow) connect(sou.terminal, res.terminal_n) connect(res.terminal_p, sen.terminal_n) connect(sen.terminal_p, loa1.terminal) connect(sou.n, gro.p) end VariableLoad;
Sensor for power, voltage and current
within AixLib.Electrical.DC.Sensors; model GeneralizedSensor "Sensor for power, voltage and current" extends AixLib.Electrical.Icons.GeneralizedSensor; extends AixLib.Electrical.Interfaces.PartialTwoPort( redeclare package PhaseSystem_p = PhaseSystems.TwoConductor, redeclare package PhaseSystem_n = PhaseSystems.TwoConductor, redeclare Interfaces.Terminal_n terminal_n, redeclare Interfaces.Terminal_p terminal_p); Modelica.Blocks.Interfaces.RealOutput V(final quantity="ElectricPotential", final unit="V") "Voltage" Modelica.Blocks.Interfaces.RealOutput I(final quantity="ElectricCurrent", final unit="A") "Current" Modelica.Blocks.Interfaces.RealOutput P( final quantity="Power", final unit="W") "Power" equation Connections.branch(terminal_p.theta, terminal_n.theta); terminal_p.theta = terminal_n.theta; V = AixLib.Electrical.PhaseSystems.TwoConductor.systemVoltage(terminal_n.v); I = AixLib.Electrical.PhaseSystems.TwoConductor.systemCurrent(terminal_n.i); P = AixLib.Electrical.PhaseSystems.TwoConductor.activePower(v=terminal_n.v, i=terminal_n.i); connect(terminal_n, terminal_p) end GeneralizedSensor;
Package with sensors for DC electrical systems
within AixLib.Electrical.DC; package Sensors "Package with sensors for DC electrical systems" extends Modelica.Icons.SensorsPackage; end Sensors;
Example model for generalized sensor. This example illustrates the use of the generalized sensor.
within AixLib.Electrical.DC.Sensors.Examples; model GeneralizedSensor "Example model for generalized sensor" extends Modelica.Icons.Example; AixLib.Electrical.DC.Sensors.GeneralizedSensor sen "Power sensor" AixLib.Electrical.DC.Loads.Conductor loa(V_nominal=120, P_nominal=120) "Constant load" AixLib.Electrical.DC.Sources.ConstantVoltage sou(V=120) "Voltage source" Modelica.Electrical.Analog.Basic.Ground ground equation connect(sen.terminal_p, loa.terminal) connect(sen.terminal_n, sou.terminal) connect(sou.n, ground.p) end GeneralizedSensor;
Collection of models that illustrate model use and test models
within AixLib.Electrical.DC.Sensors; package Examples "Collection of models that illustrate model use and test models" extends Modelica.Icons.ExamplesPackage; end Examples;
Model of a constant DC voltage source
within AixLib.Electrical.DC.Sources; model ConstantVoltage "Model of a constant DC voltage source" extends AixLib.Electrical.Interfaces.Source( redeclare package PhaseSystem = PhaseSystems.TwoConductor, redeclare Interfaces.Terminal_p terminal, final potentialReference=true, final definiteReference=false); parameter Modelica.Units.SI.Voltage V(start=1) "Value of constant voltage"; Modelica.Electrical.Analog.Interfaces.NegativePin n "Negative pin" equation terminal.v[1] = V; terminal.v[2] = n.v; sum(terminal.i) + n.i = 0; end ConstantVoltage;
Package with models for DC sources
within AixLib.Electrical.DC; package Sources "Package with models for DC sources" extends Modelica.Icons.SourcesPackage; end Sources;
Model of a generoic DC voltage source
within AixLib.Electrical.DC.Sources; model VoltageSource "Model of a generoic DC voltage source" extends AixLib.Electrical.Interfaces.VariableVoltageSource( V(start = 1), redeclare package PhaseSystem = PhaseSystems.TwoConductor, redeclare Interfaces.Terminal_p terminal, final potentialReference=true, final definiteReference=false); Modelica.Electrical.Analog.Interfaces.NegativePin n "Negative pin" equation terminal.v[1] = V_in_internal; terminal.v[2] = n.v; sum(terminal.i) + n.i = 0; end VoltageSource;
Package with base classes for DC sources
within AixLib.Electrical.DC.Sources; package BaseClasses "Package with base classes for DC sources" extends Modelica.Icons.BasesPackage; end BaseClasses;
Block for wind correction. This model calculates the wind velocity at the location as a function of the height over ground. The equation is based on Gash (1991). The model computes the wind velocity <i>vLoc</i> as
within AixLib.Electrical.DC.Sources.BaseClasses; block WindCorrection "Block for wind correction" extends Modelica.Blocks.Icons.Block; parameter Modelica.Units.SI.Height h "Height over ground"; parameter Modelica.Units.SI.Height hRef "Reference height for wind measurement"; parameter Real n(min=0) = 0.4 "Height exponent for wind profile calculation"; Modelica.Blocks.Interfaces.RealOutput vLoc( unit="m/s") "Wind velocity at the location" Modelica.Blocks.Interfaces.RealInput vRef(unit="m/s") "Wind velocity at the reference height" equation vLoc=vRef * (h / hRef)^n; end WindCorrection;
Package with example models
within AixLib.Electrical.DC.Sources; package Examples "Package with example models" extends Modelica.Icons.ExamplesPackage; end Examples;
Example for the variable voltage source model. This model illustrates the use of the variable voltage source model.
within AixLib.Electrical.DC.Sources.Examples; model VoltageSource "Example for the variable voltage source model" extends Modelica.Icons.Example; Modelica.Electrical.Analog.Basic.Ground ground AixLib.Electrical.DC.Loads.Resistor res(R=0.5, V_nominal=12) "Resistance" AixLib.Electrical.DC.Sources.VoltageSource sou "Voltage source" AixLib.Electrical.DC.Lines.TwoPortResistance lin(R=0.5) "Transmission line" AixLib.Electrical.DC.Sensors.GeneralizedSensor sen "Sensor" Modelica.Blocks.Sources.Sine cosine( phase=0, f=1, offset=12, amplitude=3) "Variable voltage signal" equation connect(lin.terminal_p, sen.terminal_n) connect(sou.n, ground.p) connect(sen.terminal_p, res.terminal) connect(sou.terminal, lin.terminal_n) connect(cosine.y, sou.V_in) end VoltageSource;
This package contains icons used by the electric models
within AixLib.Electrical; package Icons "This package contains icons used by the electric models" extends Modelica.Icons.IconsPackage; end Icons;
Icon that represents if the angle symble should be displayed or not. This is the icon that conditionally draws the angle symbol for a conversion model (e.g., a transformer).
within AixLib.Electrical.Icons; partial model RefAngleConversion "Icon that represents if the angle symble should be displayed or not" end RefAngleConversion;
Partial model of a capacitive load. This is a model of a generic capacitive load. This model is an extension of the base load model <a href=\"modelica://AixLib.Electrical.Interfaces.Load\">AixLib.Electrical.Interfaces.Load</a>.
within AixLib.Electrical.Interfaces; partial model CapacitiveLoad "Partial model of a capacitive load" extends Load; parameter Boolean use_pf_in = false "If true, the power factor is defined by an input" parameter Real pf(min=0, max=1) = 0.8 "Power factor" Modelica.Blocks.Interfaces.RealInput pf_in( min=0, max=1, unit="1") if (use_pf_in) "Power factor" protected function j = PhaseSystem.j "J operator that rotates of 90 degrees"; Modelica.Blocks.Interfaces.RealInput pf_internal "Hidden value of the input load for the conditional connector"; Modelica.Units.SI.ElectricCharge q[2](each stateSelect=StateSelect.prefer) "Electric charge"; Modelica.Units.SI.Admittance[2] Y "Admittance"; Modelica.Units.SI.AngularVelocity omega "Angular velocity"; Modelica.Units.SI.Power Q=P*tan(-acos(pf_internal)) "Reactive power (negative because capacitive load)"; equation connect(pf_in, pf_internal); if not use_pf_in then pf_internal = pf; end if; end CapacitiveLoad;
Generalized model of a ground connection.
within AixLib.Electrical.Interfaces; model Ground "Generalized model of a ground connection." replaceable package PhaseSystem = AixLib.Electrical.PhaseSystems.PartialPhaseSystem constrainedby AixLib.Electrical.PhaseSystems.PartialPhaseSystem "Phase system" replaceable AixLib.Electrical.Interfaces.Terminal terminal( redeclare package PhaseSystem = PhaseSystem) "Generalized terminal" equation terminal.v = zeros(PhaseSystem.n); end Ground;
Partial model representing a generalized impedance. This model represents a generalized interface for an impedance.
within AixLib.Electrical.Interfaces; model Impedance "Partial model representing a generalized impedance" extends AixLib.Electrical.Interfaces.Load( final linearized = false, final mode=AixLib.Electrical.Types.Load.FixedZ_steady_state, final P_nominal(fixed = true)=0, final V_nominal(fixed = true)=1); parameter Boolean inductive=true "If true, the load is inductive, otherwise it is capacitive" parameter Modelica.Units.SI.Resistance R( start=1, min=0) = 1 "Resistance" parameter Modelica.Units.SI.Inductance L( start=0, min=0) = 0 "Inductance" parameter Modelica.Units.SI.Capacitance C( start=0, min=0) = 0 "Capacitance" parameter Boolean use_R_in = false "If true, R is specified by an input" parameter Modelica.Units.SI.Resistance RMin( start=R, min=Modelica.Constants.eps) = 1e-4 "Minimum value of the resistance" parameter Modelica.Units.SI.Resistance RMax( start=R, min=Modelica.Constants.eps) = 1e2 "Maximum value of the resistance" parameter Boolean use_C_in = false "If true, C is specified by an input" parameter Modelica.Units.SI.Capacitance CMin( start=C, min=Modelica.Constants.eps) = 1e-4 "Minimum value of the capacitance" parameter Modelica.Units.SI.Capacitance CMax( start=C, min=Modelica.Constants.eps) = 1e2 "Maximum value of the capacitance" parameter Boolean use_L_in = false "If true, L is specified by an input" parameter Modelica.Units.SI.Inductance LMin( start=L, min=Modelica.Constants.eps) = 1e-4 "Minimum value of the inductance" parameter Modelica.Units.SI.Inductance LMax( start=L, min=Modelica.Constants.eps) = 1e2 "Maximum value of the inductance" Modelica.Blocks.Interfaces.RealInput y_R(min=0, max=1) if use_R_in "Input that sepecify variable R" Modelica.Blocks.Interfaces.RealInput y_C(min=0, max=1) if use_C_in "Input that sepecify variable C" Modelica.Blocks.Interfaces.RealInput y_L(min=0, max=1) if use_L_in "Input that sepecify variable L" protected Modelica.Blocks.Interfaces.RealOutput y_R_internal "Internal signal used to compute the variable R_internal"; Modelica.Blocks.Interfaces.RealOutput y_C_internal "Internal signal used to compute the variable C_internal"; Modelica.Blocks.Interfaces.RealOutput y_L_internal "Internal signal used to compute the variable L_internal"; Modelica.Units.SI.Resistance R_internal "Actual resistance used to compute the impedance"; Modelica.Units.SI.Inductance L_internal "Actual inductance used to compute the impedance"; Modelica.Units.SI.Capacitance C_internal "Actual capacitance used to compute the impedance"; equation // These assertions ensures that if the variable R, L or C is computed using the inputs // the parameters min and max are sorted assert((not use_R_in) or RMin < RMax, "The value of RMin has to be lower than RMax"); assert((not use_L_in) or LMin < LMax, "The value of Lmin has to be lower than Lmax"); assert((not use_C_in) or CMin < CMax, "The value of Cmin has to be lower than Cmax"); // Connections to internal connectors connect(y_R, y_R_internal); connect(y_C, y_C_internal); connect(y_L, y_L_internal); // Default assignment when connectors are conditionally removed if not use_R_in then y_R_internal = 0; end if; if not use_C_in then y_C_internal = 0; end if; if not use_L_in then y_L_internal = 0; end if; // Retrieve the value of the R,L,C either if fixed or // varying if not use_R_in then R_internal = R; else R_internal = RMin + y_R_internal*(RMax - RMin); end if; if not use_C_in then C_internal = C; else C_internal = CMin + y_C_internal*(CMax - CMin); end if; if not use_L_in then L_internal = L; else L_internal = LMin + y_L_internal*(LMax - LMin); end if; end Impedance;
Partial model of an inductive load. This is a model of a generic inductive load. This model is an extension of the base load model <a href=\"modelica://AixLib.Electrical.Interfaces.Load\"> AixLib.Electrical.Interfaces.Load</a>.
within AixLib.Electrical.Interfaces; partial model InductiveLoad "Partial model of an inductive load" extends Load; parameter Boolean use_pf_in = false "If true, the power factor is defined by an input" parameter Real pf(min=0, max=1) = 0.8 "Power factor" Modelica.Blocks.Interfaces.RealInput pf_in( min=0, max=1, unit="1") if (use_pf_in) "Power factor" protected function j = PhaseSystem.j "J operator that rotates of 90 degrees"; Modelica.Blocks.Interfaces.RealInput pf_internal "Hidden value of the input load for the conditional connector"; Modelica.Units.SI.MagneticFlux psi[2](each stateSelect=StateSelect.prefer) "Magnetic flux"; Modelica.Units.SI.Impedance Z[2] "Impedance of the load"; Modelica.Units.SI.AngularVelocity omega "Angular frequency"; Modelica.Units.SI.Power Q=P*tan(acos( AixLib.Utilities.Math.Functions.smoothMin( x1=pf_internal, x2=0.99999, deltaX=0.0000025))) "Reactive power (positive because inductive load)"; equation connect(pf_in, pf_internal); if not use_pf_in then pf_internal = pf; end if; end InductiveLoad;
Partial model for a generic load
within AixLib.Electrical.Interfaces; model Load "Partial model for a generic load" replaceable package PhaseSystem = AixLib.Electrical.PhaseSystems.PartialPhaseSystem constrainedby AixLib.Electrical.PhaseSystems.PartialPhaseSystem "Phase system" parameter Boolean linearized = false "If true, the load model is linearized" parameter AixLib.Electrical.Types.Load mode( min=AixLib.Electrical.Types.Load.FixedZ_steady_state, max=AixLib.Electrical.Types.Load.VariableZ_y_input) = AixLib.Electrical.Types.Load.FixedZ_steady_state "Type of load model (e.g., steady state, dynamic, prescribed power consumption, etc.)" parameter Modelica.Units.SI.Power P_nominal=0 "Nominal power (negative if consumed, positive if generated). Used if mode <> AixLib.Electrical.Types.Load.VariableZ_P_input" parameter Modelica.Units.SI.Voltage V_nominal(min=0, start=110) "Nominal voltage (V_nominal >= 0)" parameter AixLib.Electrical.Types.InitMode initMode( min=AixLib.Electrical.Types.InitMode.zero_current, max=AixLib.Electrical.Types.InitMode.linearized) = AixLib.Electrical.Types.InitMode.zero_current "Initialization mode for homotopy operator" Modelica.Units.SI.Voltage v[:](start=PhaseSystem.phaseVoltages(V_nominal)) = terminal.v "Voltage vector"; Modelica.Units.SI.Current i[:](each start=0) = terminal.i "Current vector"; Modelica.Units.SI.Power S[PhaseSystem.n]=PhaseSystem.phasePowers_vi(v, -i) "Phase powers"; Modelica.Units.SI.Power P(start=0) "Power of the load (negative if consumed, positive if fed into the electrical grid)"; Modelica.Blocks.Interfaces.RealInput y(min=0, max=1, unit="1") if (mode == AixLib.Electrical.Types.Load.VariableZ_y_input) "Fraction of the nominal power consumed" Modelica.Blocks.Interfaces.RealInput Pow(unit="W") if (mode == AixLib.Electrical.Types.Load.VariableZ_P_input) "Power consumed" replaceable AixLib.Electrical.Interfaces.Terminal terminal( redeclare replaceable package PhaseSystem = PhaseSystem) "Generalized electric terminal" protected Modelica.Blocks.Interfaces.RealInput y_internal "Hidden value of the input load for the conditional connector"; Modelica.Blocks.Interfaces.RealInput P_internal "Hidden value of the input power for the conditional connector"; Real load(min=eps, max=1) "Internal representation of control signal, used to avoid singularity"; constant Real eps = 1E-10 "Small number used to avoid a singularity if the power is zero"; constant Real oneEps = 1-eps "Small number used to avoid a singularity if the power is zero"; initial equation if mode == AixLib.Electrical.Types.Load.VariableZ_P_input then assert(abs(P_nominal) < 1E-10, "*** Warning: P_nominal = " + String(P_nominal) + ", but this value will be ignored.", AssertionLevel.warning); end if; equation assert(y_internal>=0 and y_internal<=1+eps, "The power load fraction P (input of the model) must be within [0,1]"); // Connection between the conditional and inner connector connect(y,y_internal); connect(Pow,P_internal); // If the power is fixed, inner connector value is equal to 1 if mode==AixLib.Electrical.Types.Load.FixedZ_steady_state or mode==AixLib.Electrical.Types.Load.FixedZ_dynamic then y_internal = 1; P_internal = 0; elseif mode==AixLib.Electrical.Types.Load.VariableZ_y_input then P_internal = 0; elseif mode==AixLib.Electrical.Types.Load.VariableZ_P_input then y_internal = 1; end if; // Value of the load, depending on the type: fixed or variable if mode==AixLib.Electrical.Types.Load.VariableZ_y_input then load = eps + oneEps*y_internal; else load = 1; end if; // Power consumption if mode==AixLib.Electrical.Types.Load.FixedZ_steady_state or mode==AixLib.Electrical.Types.Load.FixedZ_dynamic then P = P_nominal; elseif mode==AixLib.Electrical.Types.Load.VariableZ_P_input then P = P_internal; else P = P_nominal*load; end if; end Load;
This package contains interfaces and partial models that are inherited by other components
within AixLib.Electrical; package Interfaces "This package contains interfaces and partial models that are inherited by other components" extends Modelica.Icons.InterfacesPackage; end Interfaces;
Partial model that contains basic parameters for a DC/AC conversion system. This model contains the minimum set of parameters necessary to describe an AC/DC converter.
within AixLib.Electrical.Interfaces; record PartialAcDcParameters "Partial model that contains basic parameters for a DC/AC conversion system" parameter Real pf(min=0, max=1) = 0.9 "Power factor" parameter Real eta_DCAC(min=0, max=1) = 0.9 "Efficiency of DC/AC conversion" end PartialAcDcParameters;
Model of a generic two port component. This model declares connectors for electrical components with two terminals.
within AixLib.Electrical.Interfaces; model PartialBaseTwoPort "Model of a generic two port component" replaceable AixLib.Electrical.Interfaces.BaseTerminal terminal_n "Electric terminal side p" replaceable AixLib.Electrical.Interfaces.BaseTerminal terminal_p "Electric terminal side n" end PartialBaseTwoPort;
Model representing a generic two port system for conversion. This model extends the base class <a href=\"modelica://AixLib.Electrical.Interfaces.PartialTwoPort\"> AixLib.Electrical.Interfaces.PartialTwoPort</a> model and declares the variables <code>v_p</code> and <code>i_p</code> that represents the voltage and the current at the <code>terminal_p</code>, and the variables <code>v_n</code> and <code>i_n</code> that represents the voltage and the current at the <code>terminal_n</code>. These variables are used in conversion models such as transformers and AC/DC converters.
within AixLib.Electrical.Interfaces; model PartialConversion "Model representing a generic two port system for conversion" extends AixLib.Electrical.Interfaces.PartialTwoPort; Modelica.Units.SI.Voltage v_p "Voltage drop between the two positive pins"; Modelica.Units.SI.Voltage v_n "Voltage drop between the two negative pins"; Modelica.Units.SI.Current i_p "Current flowing through the positive pins"; Modelica.Units.SI.Current i_n "Current flowing through the negative pins"; equation i_p = PhaseSystem_p.systemCurrent(terminal_p.i); i_n = PhaseSystem_n.systemCurrent(terminal_n.i); v_p = PhaseSystem_p.systemVoltage(terminal_p.v); v_n = PhaseSystem_n.systemVoltage(terminal_n.v); end PartialConversion;
Model of a generic two port component with phase systems
within AixLib.Electrical.Interfaces; model PartialTwoPort "Model of a generic two port component with phase systems" replaceable package PhaseSystem_p = AixLib.Electrical.PhaseSystems.PartialPhaseSystem constrainedby AixLib.Electrical.PhaseSystems.PartialPhaseSystem "Phase system of terminal p" replaceable package PhaseSystem_n = AixLib.Electrical.PhaseSystems.PartialPhaseSystem constrainedby AixLib.Electrical.PhaseSystems.PartialPhaseSystem "Phase system of terminal n" extends AixLib.Electrical.Interfaces.PartialBaseTwoPort( redeclare replaceable AixLib.Electrical.Interfaces.Terminal terminal_n constrainedby AixLib.Electrical.Interfaces.Terminal( redeclare replaceable package PhaseSystem = PhaseSystem_n), redeclare replaceable AixLib.Electrical.Interfaces.Terminal terminal_p constrainedby AixLib.Electrical.Interfaces.Terminal( redeclare replaceable package PhaseSystem=PhaseSystem_p)); end PartialTwoPort;
Partial model of a resistive load. This is a model of a generic resistive load. This model is an extension of the base load model <a href=\"modelica://AixLib.Electrical.Interfaces.Load\"> AixLib.Electrical.Interfaces.Load</a>.
within AixLib.Electrical.Interfaces; partial model ResistiveLoad "Partial model of a resistive load" extends Load; end ResistiveLoad;
Partial model of a generic source.
within AixLib.Electrical.Interfaces; model Source "Partial model of a generic source." replaceable package PhaseSystem = AixLib.Electrical.PhaseSystems.OnePhase constrainedby AixLib.Electrical.PhaseSystems.PartialPhaseSystem "Phase system" parameter Boolean potentialReference = true "Serve as potential root for the reference angle theta" parameter Boolean definiteReference = false "Serve as definite root for the reference angle theta" Modelica.Units.SI.Power S[PhaseSystem.n]=PhaseSystem.phasePowers_vi(terminal.v, terminal.i) "Complex power S[1] = P, S[2]= Q"; Modelica.Units.SI.Angle phi=PhaseSystem.phase(terminal.v) - PhaseSystem.phase( -terminal.i) "Phase shift with respect to reference angle"; replaceable AixLib.Electrical.Interfaces.Terminal terminal( redeclare final replaceable package PhaseSystem = PhaseSystem) "Generalized terminal" protected function j = PhaseSystem.j; equation if potentialReference then if definiteReference then Connections.root(terminal.theta); else Connections.potentialRoot(terminal.theta); end if; end if; end Source;
Generalized electric terminal
within AixLib.Electrical.Interfaces; connector Terminal "Generalized electric terminal" extends AixLib.Electrical.Interfaces.BaseTerminal; replaceable package PhaseSystem = PhaseSystems.PartialPhaseSystem "Phase system" PhaseSystem.Voltage v[PhaseSystem.n] "Voltage vector"; flow PhaseSystem.Current i[PhaseSystem.n](each start=0) "Current vector"; PhaseSystem.ReferenceAngle theta[PhaseSystem.m] "Optional vector of phase angles"; end Terminal;
Partial model of a generic variable voltage source.. This model represents a generic variable voltage source. The model has a boolean flag <code>use_V_in</code>, when this flag is equal to <code>true</code> the voltage of the source is imposed by the input variable <code>V_in</code>. When the flag is equal to <code>false</code> the voltage source is equal to the parameter <code>V</code>.
within AixLib.Electrical.Interfaces; model VariableVoltageSource "Partial model of a generic variable voltage source." extends AixLib.Electrical.Interfaces.Source; parameter Boolean use_V_in = true "If true, the voltage is an input"; parameter Modelica.Units.SI.Voltage V=1 "Value of constant voltage" Modelica.Blocks.Interfaces.RealInput V_in(unit="V", min=0, start = 1) if use_V_in "Input voltage" protected Modelica.Blocks.Interfaces.RealInput V_in_internal(unit="V") "Hidden value of the input voltage for the conditional connector"; equation // Connection between the conditional and inner connector connect(V_in,V_in_internal); // If the voltage is fixed, inner connector value is equal to parameter V if use_V_in == false then V_in_internal = V; end if; end VariableVoltageSource;
Model of a general induction machine working as generator or electric motor. Model of an electric induction machine that includes the calculation of:
within AixLib.Electrical.Machines; model InductionMachine "Model of a general induction machine working as generator or electric motor" import AixLib; extends Modelica.Electrical.Machines.Icons.TransientMachine; parameter Modelica.Units.SI.Frequency n0=f_1/p "Idling speed of the electric machine" parameter Modelica.Units.SI.Frequency n_nominal=1530/60 "Rated rotor speed" parameter Modelica.Units.SI.Frequency f_1=50 "Frequency" parameter Modelica.Units.SI.Voltage U_1=400 "Rated voltage" parameter Modelica.Units.SI.Current I_elNominal=P_elNominal/(sqrt(3)*U_1* cosPhi) "Rated current" parameter Modelica.Units.SI.Current I_1_start=if P_Mec_nominal <= 15000 then 7.2*I_elNominal else 8*I_elNominal "Motor start current (realistic factors used from DIN VDE 2650/2651)" parameter Modelica.Units.SI.Power P_elNominal=15000 "Nominal electrical power of electric machine" parameter Modelica.Units.SI.Power P_Mec_nominal=P_elNominal*(1 + s_nominal/ 0.22) "Nominal mechanical power of electric machine" parameter Modelica.Units.SI.Torque M_nominal=P_Mec_nominal/(2*Modelica.Constants.pi *n_nominal) "Nominal torque of electric machine" parameter Modelica.Units.SI.Torque M_til=2*M_nominal "Tilting torque of electric machine (realistic factor used from DIN VDE 2650/2651)" parameter Modelica.Units.SI.Torque M_start=if P_Mec_nominal <= 4000 then 1.6* M_nominal elseif P_Mec_nominal >= 22000 then 1*M_nominal else 1.25* M_nominal "Starting torque of electric machine (realistic factor used from DIN VDE 2650/2651)" parameter Modelica.Units.SI.Inertia J_Gen=1 "Moment of inertia of the electric machine (default=0.5kg.m2)" parameter Real s_nominal=abs(1-n_nominal*p/f_1) "Nominal slip of electric machine" parameter Real s_til=abs((s_nominal*(M_til/M_nominal)+s_nominal*sqrt(abs(((M_til/M_nominal)^2)-1+2*s_nominal*((M_til/M_nominal)-1))))/(1-2*s_nominal*((M_til/M_nominal)-1))) "Tilting slip of electric machine" parameter Real p=2 "Number of pole pairs" parameter Real cosPhi=0.8 "Power factor of electric machine (default=0.8)" parameter Real calFac=1 "Calibration factor for electric power outuput (default=1)" parameter Real gearRatio=1 "Transmission ratio (engine speed / generator speed)" Modelica.Units.SI.Frequency n=inertia.w/(2*Modelica.Constants.pi) "Speed of machine rotor [1/s]"; Modelica.Units.SI.Current I_1 "Electric current of machine stator"; Modelica.Units.SI.Power P_E "Electrical power at the electric machine"; Modelica.Units.SI.Power P_Mec "Mechanical power at the electric machine"; Modelica.Units.SI.Power CalQ_Loss "Calculated heat flow from electric machine"; Modelica.Units.SI.Torque M "Torque at electric machine"; Real s=1-n*p/f_1 "Current slip of electric machine"; Real eta "Total efficiency of the electric machine (as motor)"; Real calI_1 = 1/(1+((k-1)/((s_nominal^2)-k))*((s^2)+rho1*abs(s)+rho0)); Boolean OpMode = (n<=n0) "Operation mode (true=motor, false=generator)"; Boolean SwitchOnOff = isOn "Operation of electric machine (true=On, false=Off)"; Modelica.Mechanics.Rotational.Components.Inertia inertia( w(fixed=false), J=J_Gen) Modelica.Blocks.Sources.RealExpression electricTorque(y=M) Modelica.Mechanics.Rotational.Sources.Torque torque Modelica.Mechanics.Rotational.Interfaces.Flange_a flange_Machine Modelica.Mechanics.Rotational.Components.IdealGear transmission(ratio= gearRatio) Modelica.Blocks.Interfaces.BooleanInput isOn Modelica.Blocks.Interfaces.RealOutput electricCurrent Modelica.Blocks.Interfaces.RealOutput electricPower Modelica.Blocks.Interfaces.RealOutput rotationalSpeed Modelica.Blocks.Sources.RealExpression current(y=I_1) Modelica.Blocks.Sources.RealExpression power(y=P_E) Modelica.Blocks.Sources.RealExpression speed(y=n) protected parameter Real rho0=s_til^2 "Calculation variable for analytical approach (Aree, 2017)" parameter Real rho1=(M_start*(1+s_til^2)-2*s_til*M_til)/(M_til-M_start) "Calculation variable for analytical approach (Aree, 2017)" parameter Real rho3=(M_til*M_start*(1-s_til)^2)/(M_til-M_start) "Calculation variable for analytical approach (Aree, 2017)" parameter Real k=((I_elNominal/I_1_start)^2)*(((s_nominal^2)+rho1*s_nominal+rho0)/(1+rho1+rho0)) "Calculation variable for analytical approach (Aree, 2017)" equation if noEvent(SwitchOnOff) then I_1=sign(s)*I_1_start*sqrt(abs((1+((k-1)/((s_nominal^2)-k))*(s^2)*(1+rho1+rho0))*calI_1)); P_E=if noEvent(s>0) then sqrt(3)*I_1*U_1*cosPhi elseif noEvent(s<0) then calFac*(P_Mec+CalQ_Loss) else 1; P_Mec=2*Modelica.Constants.pi*M*n; CalQ_Loss= (calFac-1)*P_E + 2*Modelica.Constants.pi*M*(s*n0)/0.22; M=sign(s)*(rho3*abs(s))/((s^2)+rho1*abs(s)+rho0); eta=if noEvent(s>0) then abs(P_Mec/(P_E+1)) elseif noEvent(s<0) then abs(P_E/(P_Mec-1)) else 0; else I_1=0; P_E=0; P_Mec=0; CalQ_Loss=0; M=if noEvent(s<0) then sign(s)*(rho3*abs(s))/((s^2)+rho1*abs(s)+rho0) else 0; eta=0; end if; connect(electricTorque.y, torque.tau) connect(torque.flange, inertia.flange_a) connect(inertia.flange_b, transmission.flange_b) connect(transmission.flange_a, flange_Machine) connect(current.y, electricCurrent) connect(power.y, electricPower) connect(speed.y, rotationalSpeed) end InductionMachine;
Inverter model including system management.
within AixLib.Electrical.Machines; model PVInverterRMS "Inverter model including system management" parameter Modelica.Units.SI.Power uMax2=3800 "Upper limits of input signals (MaxOutputPower)"; Modelica.Blocks.Interfaces.RealOutput PVPowerRmsW( final quantity="Power", final unit="W") "Output power of the PV system including the inverter" Modelica.Blocks.Interfaces.RealInput DCPowerInput( final quantity="Power", final unit="W") "DC output power of PV panels as input for the inverter" Modelica.Blocks.Nonlinear.Limiter MaxOutputPower( uMax( final quantity="Power", final displayUnit="Nm/s")=uMax2, uMin=0) "Limitier for maximum output power" Modelica.Blocks.Tables.CombiTable1Ds EfficiencyConverterSunnyBoy3800( tableOnFile=false, table=[0,0.798700;100,0.848907;200,0.899131;250,0.911689;300,0.921732;350,0.929669;400,0.935906;450,0.940718;500,0.943985;550,0.946260;600,0.947839;700,0.950638;800,0.952875;900,0.954431;1000,0.955214;1250,0.956231;1500,0.956449;2000,0.955198;2500,0.952175;3000,0.948659;3500,0.944961;3800,0.942621]) "Efficiency of the inverter for different operating points" Modelica.Blocks.Math.Product Product2 "Multiplies the output power of the PV cell with the efficiency of the inverter " equation connect(Product2.u2,EfficiencyConverterSunnyBoy3800.y[1]) connect(Product2.y,MaxOutputPower.u) connect(MaxOutputPower.y,PVPowerRmsW) connect(Product2.u1,DCPowerInput) connect(EfficiencyConverterSunnyBoy3800.u,DCPowerInput) end PVInverterRMS;
rpm.
within AixLib.Electrical.Machines.Examples; model InductionMotor extends Modelica.Icons.Example; InductionMachine inductionMachine(inertia(phi(fixed=true, start=0), w( fixed=true, start=0))) Modelica.Mechanics.Rotational.Sources.QuadraticSpeedDependentTorque quadraticSpeedDependentTorque(tau_nominal=-100, w_nominal(displayUnit="rpm")= inductionMachine.n0) Modelica.Blocks.Sources.BooleanPulse booleanPulse(period=100, startTime=0) equation connect(quadraticSpeedDependentTorque.flange, inductionMachine.flange_Machine) connect(booleanPulse.y, inductionMachine.isOn) end InductionMotor;
<html><p> This package contains test examples for the use of induction machine models. </p> </html>
within AixLib.Electrical.Machines; package Examples extends Modelica.Icons.ExamplesPackage; end Examples;
DC system
within AixLib.Electrical.PhaseSystems; package DirectCurrent "DC system" extends PartialPhaseSystem(phaseSystemName="DirectCurrent", n=1, m=0); redeclare function extends j "Direct current has no complex component" algorithm y := zeros(n); end j; redeclare function extends rotate "Rotate a vector of an angle theta (anti-counterclock)" algorithm y[n] := x[n]; end rotate; redeclare function extends thetaRel "Return absolute angle of rotating system as offset to thetaRef" algorithm thetaRel := 0; end thetaRel; redeclare function extends thetaRef "Return absolute angle of rotating reference system" algorithm thetaRef := 0; end thetaRef; redeclare function extends phase "Return phase" algorithm phase := 0; end phase; redeclare replaceable function extends phaseVoltages "Return phase to neutral voltages" algorithm v := {V}; end phaseVoltages; redeclare function extends phaseCurrents "Return phase currents" algorithm i := {I}; end phaseCurrents; redeclare function extends phasePowers "Return phase powers" algorithm p := {P}; end phasePowers; redeclare function extends phasePowers_vi "Return phase powers" algorithm p := {v*i}; end phasePowers_vi; redeclare replaceable function extends systemVoltage "Return system voltage as function of phase voltages" algorithm V := v[1]; end systemVoltage; redeclare function extends systemCurrent "Return system current as function of phase currents" algorithm I := i[1]; end systemCurrent; redeclare function extends activePower "Return total power as function of phase powers" algorithm P := v*i; end activePower; end DirectCurrent;
Single phase two connectors AC system
within AixLib.Electrical.PhaseSystems; package OnePhase "Single phase two connectors AC system" extends PartialPhaseSystem(phaseSystemName="OnePhase", n=2, m=1); redeclare function extends j "Return vector rotated by 90 degrees" algorithm y := {-x[2], x[1]}; end j; redeclare function extends rotate "Rotate a vector of an angle theta (anti-counterclock)" algorithm y[1] := cos(theta)*x[1] - sin(theta)*x[2]; y[2] := sin(theta)*x[1] + cos(theta)*x[2]; end rotate; redeclare function extends product "Multiply two complex numbers represented by vectors x[2] and y[2]" algorithm z := {x[1]*y[1] - x[2]*y[2], x[1]*y[2] + x[2]*y[1]}; end product; redeclare function extends divide "Divide two complex numbers represented by vectors x[2] and y[2]" algorithm z := {x[1]*y[1] + x[2]*y[2], x[2]*y[1] - x[1]*y[2]}/(y[1]^2 + y[2]^2); end divide; redeclare function extends thetaRel "Return absolute angle of rotating system as offset to thetaRef" algorithm thetaRel := 0; end thetaRel; redeclare function extends thetaRef "Return absolute angle of rotating reference system" algorithm thetaRef := theta[1]; end thetaRef; redeclare function extends phase "Return phase" algorithm phase := atan2(x[2], x[1]); end phase; redeclare function extends phaseVoltages "Return phase to neutral voltages" algorithm v := {V*cos(phi), V*sin(phi)}; end phaseVoltages; redeclare function extends phaseCurrents "Return phase currents" algorithm i := {I*cos(phi), I*sin(phi)}; end phaseCurrents; redeclare function extends phasePowers "Return phase powers" algorithm p := {P, P*tan(phi)}; end phasePowers; redeclare function extends phasePowers_vi "Return phase powers" algorithm p := {v[1]*i[1] + v[2]*i[2], v[2]*i[1] - v[1]*i[2]}; end phasePowers_vi; redeclare function extends systemVoltage "Return system voltage as function of phase voltages" algorithm V := Modelica.Fluid.Utilities.regRoot(v*v, delta = 1e-5); end systemVoltage; redeclare function extends systemCurrent "Return system current as function of phase currents" algorithm I := Modelica.Fluid.Utilities.regRoot(i*i, delta = 1e-5); end systemCurrent; redeclare function extends activePower "Return total power as function of phase powers" algorithm // P = v[1]*i[1] + v[2]*i[2] P := v*i; end activePower; end OnePhase;
Phase systems used in power connectors
within AixLib.Electrical; package PhaseSystems "Phase systems used in power connectors" extends Modelica.Icons.Package; import Modelica.Units.SI; import Modelica.Constants.pi; end PhaseSystems;
Base package of all phase systems
within AixLib.Electrical.PhaseSystems; package PartialPhaseSystem "Base package of all phase systems" extends Modelica.Icons.Package; constant String phaseSystemName = "UnspecifiedPhaseSystem" "Name of the phase system represented by the package"; constant Integer n "Number of independent voltage and current components"; constant Integer m "Number of reference angles"; type Current = Real(unit = "A", quantity = "Current." + phaseSystemName) "Current for connector" type Voltage = Real(unit = "V", quantity = "Voltage." + phaseSystemName) "Voltage for connector" type ReferenceAngle "Reference angle for connector" extends Modelica.Units.SI.Angle; function equalityConstraint "Assert that angles are equal" extends Modelica.Icons.Function; input ReferenceAngle theta1[:]; input ReferenceAngle theta2[:]; output Real residue[0]; algorithm for i in 1:size(theta1, 1) loop assert(abs(theta1[i] - theta2[i]) < Modelica.Constants.eps, "Angles theta1 and theta2 are not equal over the connection."); end for; end equalityConstraint; end ReferenceAngle; replaceable partial function j "Return vector rotated by 90 degrees" extends Modelica.Icons.Function; input Real x[n]; output Real y[n]; end j; replaceable partial function jj "Vectorized version of j" extends Modelica.Icons.Function; input Real[:,:] xx "array of voltage or current vectors"; output Real[size(xx,1),size(xx,2)] yy "array of rotated vectors"; algorithm //yy := {j(xx[:,k]) for k in 1:size(xx,2)}; // Note: Dymola 2013 fails to expand for k in 1:size(xx,2) loop yy[:,k] := j(xx[:,k]); end for; end jj; replaceable partial function rotate "Rotate a vector of an angle theta (anti-counterclock)" extends Modelica.Icons.Function; input Real x[n]; input Modelica.Units.SI.Angle theta; output Real y[n]; end rotate; replaceable partial function product "Multiply two vectors" extends Modelica.Icons.Function; input Real x[n]; input Real y[n]; output Real z[n]; end product; replaceable partial function divide "Divide two vectors" extends Modelica.Icons.Function; input Real x[n]; input Real y[n]; output Real z[n]; end divide; replaceable partial function thetaRel "Return absolute angle of rotating system as offset to thetaRef" extends Modelica.Icons.Function; input Modelica.Units.SI.Angle theta[m]; output Modelica.Units.SI.Angle thetaRel; end thetaRel; replaceable partial function thetaRef "Return absolute angle of rotating reference system" extends Modelica.Icons.Function; input Modelica.Units.SI.Angle theta[m]; output Modelica.Units.SI.Angle thetaRef; end thetaRef; replaceable partial function phase "Return phase" extends Modelica.Icons.Function; input Real x[n]; output Modelica.Units.SI.Angle phase; end phase; replaceable partial function phaseVoltages "Return phase to neutral voltages" extends Modelica.Icons.Function; input Modelica.Units.SI.Voltage V "system voltage"; input Modelica.Units.SI.Angle phi=0 "phase angle"; output Modelica.Units.SI.Voltage v[n] "phase to neutral voltages"; end phaseVoltages; replaceable partial function phaseCurrents "Return phase currents" extends Modelica.Icons.Function; input Modelica.Units.SI.Current I "system current"; input Modelica.Units.SI.Angle phi=0 "phase angle"; output Modelica.Units.SI.Current i[n] "phase currents"; end phaseCurrents; replaceable partial function phasePowers "Return phase powers" extends Modelica.Icons.Function; input Modelica.Units.SI.ActivePower P "active system power"; input Modelica.Units.SI.Angle phi=0 "phase angle"; output Modelica.Units.SI.Power p[n] "phase powers"; end phasePowers; replaceable partial function phasePowers_vi "Return phase powers" extends Modelica.Icons.Function; input Modelica.Units.SI.Voltage v[n] "phase voltages"; input Modelica.Units.SI.Current i[n] "phase currents"; output Modelica.Units.SI.Power p[n] "phase powers"; end phasePowers_vi; replaceable partial function systemVoltage "Return system voltage as function of phase voltages" extends Modelica.Icons.Function; input Modelica.Units.SI.Voltage v[n]; output Modelica.Units.SI.Voltage V; end systemVoltage; replaceable partial function systemCurrent "Return system current as function of phase currents" extends Modelica.Icons.Function; input Modelica.Units.SI.Current i[n]; output Modelica.Units.SI.Current I; end systemCurrent; replaceable partial function activePower "Return total power as function of phase powers" extends Modelica.Icons.Function; input Modelica.Units.SI.Voltage v[n] "phase voltages"; input Modelica.Units.SI.Current i[n] "phase currents"; output Modelica.Units.SI.ActivePower P "active system power"; end activePower; end PartialPhaseSystem;
AC system covering only resistive loads with three symmetric phases
within AixLib.Electrical.PhaseSystems; package ThreePhase_d "AC system covering only resistive loads with three symmetric phases" extends DirectCurrent(phaseSystemName="ThreePhase_d"); redeclare function phaseVoltages "Return phase to neutral voltages" extends Modelica.Icons.Function; input SI.Voltage V "system voltage"; input SI.Angle phi = 0 "phase angle"; output SI.Voltage v[n] "phase to neutral voltages"; algorithm v := {V}/sqrt(3); end phaseVoltages; redeclare function systemVoltage "Return system voltage as function of phase voltages" extends Modelica.Icons.Function; input SI.Voltage v[n]; output SI.Voltage V; algorithm V := sqrt(3)*v[1]; end systemVoltage; end ThreePhase_d;
AC system, symmetrically loaded three-phase
within AixLib.Electrical.PhaseSystems; package ThreePhase_dq "AC system, symmetrically loaded three-phase" extends PartialPhaseSystem(phaseSystemName="ThreePhase_dq", n=2, m=1); redeclare function extends j "Return vector rotated by 90 degrees" algorithm y := {-x[2], x[1]}; end j; redeclare function extends thetaRel "Return absolute angle of rotating system as offset to thetaRef" algorithm thetaRel := 0; end thetaRel; redeclare function extends thetaRef "Return absolute angle of rotating reference system" algorithm thetaRef := theta[1]; end thetaRef; redeclare function extends phase "Return phase" algorithm phase := atan2(x[2], x[1]); end phase; redeclare function extends phaseVoltages "Return phase to neutral voltages" algorithm v := {V*cos(phi), V*sin(phi)}/sqrt(3); end phaseVoltages; redeclare function extends phaseCurrents "Return phase currents" algorithm i := {I*cos(phi), I*sin(phi)}; end phaseCurrents; redeclare function extends phasePowers "Return phase powers" algorithm p := {P, P*tan(phi)}; end phasePowers; redeclare function extends phasePowers_vi "Return phase powers" algorithm p := {v*i, -j(v)*i}; end phasePowers_vi; redeclare function extends systemVoltage "Return system voltage as function of phase voltages" algorithm V := Modelica.Fluid.Utilities.regRoot(3*v*v, delta = 1e-5); end systemVoltage; redeclare function extends systemCurrent "Return system current as function of phase currents" algorithm I := Modelica.Fluid.Utilities.regRoot(i*i, delta = 1e-5); end systemCurrent; redeclare function extends activePower "Return total power as function of phase powers" algorithm P := v[1]*i[1]; end activePower; end ThreePhase_dq;
AC system in dqo representation
within AixLib.Electrical.PhaseSystems; package ThreePhase_dq0 "AC system in dqo representation" extends PartialPhaseSystem(phaseSystemName="ThreePhase_dqo", n=3, m=2); redeclare function extends j "Rotation(pi/2) of vector around {0,0,1} and projection on North plane" algorithm y := cat(1, {-x[2], x[1]}, zeros(size(x,1)-2)); end j; redeclare function extends rotate "Rotate a vector of an angle theta (anti-counterclock)" algorithm y[1] := cos(theta)*x[1] - sin(theta)*x[2]; y[2] := sin(theta)*x[1] + cos(theta)*x[2]; y[3] := x[3]; end rotate; redeclare function jj "Vectorized version of j" extends Modelica.Icons.Function; input Real[:,:] xx "array of voltage or current vectors"; output Real[size(xx,1),size(xx,2)] yy "array of rotated vectors"; algorithm yy := cat(1, {-xx[2,:], xx[1,:]}, zeros(size(xx,1)-2, size(xx,2))); end jj; redeclare function extends thetaRel "Return absolute angle of rotating system as offset to thetaRef" algorithm thetaRel := theta[1]; end thetaRel; redeclare function extends thetaRef "Return absolute angle of rotating reference system" algorithm thetaRef := theta[2]; end thetaRef; redeclare function extends phase "Return phase" algorithm phase := atan2(x[2], x[1]); end phase; redeclare function extends phaseVoltages "Return phase to neutral voltages" protected Voltage neutral_v = 0; algorithm v := {V*cos(phi), V*sin(phi), sqrt(3)*neutral_v}/sqrt(3); end phaseVoltages; redeclare function extends phaseCurrents "Return phase currents" algorithm i := {I*cos(phi), I*sin(phi), 0}; end phaseCurrents; redeclare function extends phasePowers "Return phase powers" algorithm p := {P, P*tan(phi), 0}; end phasePowers; redeclare function extends phasePowers_vi "Return phase powers" algorithm p := {v[1:2]*i[1:2], -j(v[1:2])*i[1:2], v[3]*i[3]}; end phasePowers_vi; redeclare function extends systemVoltage "Return system voltage as function of phase voltages" algorithm V := Modelica.Fluid.Utilities.regRoot(v*v, delta = 1e-5); end systemVoltage; redeclare function extends systemCurrent "Return system current as function of phase currents" algorithm I := Modelica.Fluid.Utilities.regRoot(i*i, delta = 1e-5); end systemCurrent; redeclare function extends activePower "Return total power as function of phase powers" algorithm P := v[1]*i[1]; end activePower; end ThreePhase_dq0;
Two conductors for DC components
within AixLib.Electrical.PhaseSystems; package TwoConductor "Two conductors for DC components" extends PartialPhaseSystem(phaseSystemName="TwoConductor", n=2, m=0); redeclare function extends j "Direct current has no complex component" algorithm y := zeros(n); end j; redeclare function extends rotate "Rotate a vector of an angle theta (anti-counterclock)" algorithm y[n] := x[n]; end rotate; redeclare function extends thetaRel "Return absolute angle of rotating system as offset to thetaRef" algorithm thetaRel := 0; end thetaRel; redeclare function extends thetaRef "Return absolute angle of rotating reference system" algorithm thetaRef := 0; end thetaRef; redeclare function extends phase "Return phase" algorithm phase := 0; end phase; redeclare replaceable function extends phaseVoltages "Return phase to neutral voltages" algorithm v := 0.5*{V, -V}; end phaseVoltages; redeclare function extends phaseCurrents "Return phase currents" algorithm i := {I, -I}; end phaseCurrents; redeclare function extends phasePowers "Return phase powers" algorithm p := {P, 0}; end phasePowers; redeclare function extends phasePowers_vi "Return phase powers" algorithm p := v.*i; end phasePowers_vi; redeclare replaceable function extends systemVoltage "Return system voltage as function of phase voltages" algorithm V := v[1] - v[2]; end systemVoltage; redeclare function extends systemCurrent "Return system current as function of phase currents" algorithm I := (i[1] - i[2])/2; end systemCurrent; redeclare function extends activePower "Return total power as function of phase powers" algorithm P := v*i; end activePower; end TwoConductor;
Model that determines the DC performance of a Silicium-based PV array.
within AixLib.Electrical.PVSystem; model PVSystem "Model that determines the DC performance of a Silicium-based PV array" replaceable parameter AixLib.DataBase.SolarElectric.PVBaseDataDefinition data constrainedby AixLib.DataBase.SolarElectric.PVBaseDataDefinition "PV Panel data definition" replaceable model IVCharacteristics = AixLib.Electrical.PVSystem.BaseClasses.PartialIVCharacteristics "Model for determining the I-V characteristics of a PV array" replaceable model CellTemperature = AixLib.Electrical.PVSystem.BaseClasses.PartialCellTemperature "Model for determining the cell temperature of a PV array" parameter Real n_mod "Number of connected PV modules"; parameter Modelica.Units.SI.Angle til "Surface's tilt angle (0:flat)" parameter Modelica.Units.SI.Angle azi "Surface's azimut angle (0:South)" parameter Modelica.Units.SI.Angle lat "Location's Latitude" parameter Modelica.Units.SI.Angle lon "Location's Longitude" parameter Real alt(final quantity="Length", final unit="m") "Site altitude in Meters, default= 1" parameter Modelica.Units.SI.Time timZon(displayUnit="h") "Time zone. Should be equal with timZon in ReaderTMY3, if PVSystem and ReaderTMY3 are used together." parameter Real groRef(final unit="1") = 0.2 "Ground reflectance (default=0.2) Urban environment: 0.14 - 0.22 Grass: 0.15 - 0.25 Fresh grass: 0.26 Fresh snow: 0.82 Wet snow: 0.55-0.75 Dry asphalt: 0.09-0.15 Wet Asphalt: 0.18 Concrete: 0.25-0.35 Red tiles: 0.33 Aluminum: 0.85 Copper: 0.74 New galvanized steel: 0.35 Very dirty galvanized steel: 0.08" parameter Boolean use_ParametersGlaz=false "= false if standard values for glazing can be used" parameter Real glaExtCoe(final unit="1/m") = 4 "Glazing extinction coefficient (for glass = 4)" parameter Real glaThi(final unit="m") = 0.002 "Glazing thickness (for most cells = 0.002 m)" parameter Real refInd(final unit="1", min=0) = 1.526 "Effective index of refraction of the cell cover (glass = 1.526)" IVCharacteristics iVCharacteristics(final n_mod=n_mod, final data=data) "Model for determining the I-V characteristics of a PV array" CellTemperature cellTemperature(final data=data) "Model for determining the cell temperature of a PV array" Modelica.Blocks.Interfaces.RealOutput DCOutputPower( final quantity="Power", final unit="W") "DC output power of the PV array" BaseClasses.PVRadiationHorizontal pVRadiationHorizontalTRY( final lat = lat, final lon = lon, final alt = alt, final til = til, final azi = azi, final groRef = groRef, final timZon = timZon, final glaExtCoe=glaExtCoe, final glaThi=glaThi, final refInd=refInd) "Radiation and absorptance model for PV simulations" BoundaryConditions.WeatherData.Bus weaBus equation connect(pVRadiationHorizontalTRY.radTil, iVCharacteristics.radTil) connect(pVRadiationHorizontalTRY.absRadRat, iVCharacteristics.absRadRat) connect(pVRadiationHorizontalTRY.radTil, cellTemperature.radTil) connect(iVCharacteristics.eta, cellTemperature.eta) connect(cellTemperature.T_c, iVCharacteristics.T_c) connect(iVCharacteristics.DCOutputPower, DCOutputPower) connect(weaBus.winSpe, cellTemperature.winVel) connect(weaBus.TDryBul, cellTemperature.T_a) connect(weaBus.HGloHor, pVRadiationHorizontalTRY.radHor) end PVSystem;
Empirical model for determining the cell temperature of a PV module mounted with the module backsite close to the ground.
within AixLib.Electrical.PVSystem.BaseClasses; model CellTemperatureMountingCloseToGround "Empirical model for determining the cell temperature of a PV module mounted with the module backsite close to the ground" extends AixLib.Electrical.PVSystem.BaseClasses.PartialCellTemperature; equation T_c = if noEvent(radTil >= Modelica.Constants.eps) then radTil*(exp(-2.98-0.0471*winVel))+(T_a)+radTil/1000*1 else (T_a); end CellTemperatureMountingCloseToGround;
Empirical model for determining the cell temperature of a PV module mounted with the module backsite in contact with the ground.
within AixLib.Electrical.PVSystem.BaseClasses; model CellTemperatureMountingContactToGround "Empirical model for determining the cell temperature of a PV module mounted with the module backsite in contact with the ground" extends AixLib.Electrical.PVSystem.BaseClasses.PartialCellTemperature; equation T_c = if noEvent(radTil >= Modelica.Constants.eps) then radTil*(exp(-2.81-0.0455*winVel))+(T_a) else (T_a); end CellTemperatureMountingContactToGround;
Empirical model for determining the cell temperature of a PV module mounted on an open rack.
within AixLib.Electrical.PVSystem.BaseClasses; model CellTemperatureOpenRack "Empirical model for determining the cell temperature of a PV module mounted on an open rack" extends AixLib.Electrical.PVSystem.BaseClasses.PartialCellTemperature; final parameter Modelica.Units.SI.Temperature T_a_0=293.15 "Reference ambient temperature"; final parameter Real coeff_trans_abs = 0.9 "Module specific coefficient as a product of transmission and absorption. It is usually unknown and set to 0.9 in literature"; equation T_c = if noEvent(radTil >= Modelica.Constants.eps) then (T_a)+(T_NOCT-T_a_0)*radTil/radNOCT*9.5/(5.7+3.8*winVel)*(1-eta/coeff_trans_abs) else (T_a); end CellTemperatureOpenRack;
Analytical 5-p model for PV I-V characteristics (Batzelis et al.,2016) with temp. dependency of the 5 parameters based on (DeSoto et al.,2006).
within AixLib.Electrical.PVSystem.BaseClasses; model IVCharacteristics5pAnalytical "Analytical 5-p model for PV I-V characteristics (Batzelis et al.,2016) with temp. dependency of the 5 parameters based on (DeSoto et al.,2006)" extends PartialIVCharacteristics; // Main parameters under standard conditions Modelica.Units.SI.ElectricCurrent I_ph0 "Photo current under standard conditions"; Modelica.Units.SI.ElectricCurrent I_s0 "Saturation current under standard conditions"; Modelica.Units.SI.Resistance R_s0 "Series resistance under standard conditions"; Modelica.Units.SI.Resistance R_sh0 "Shunt resistance under standard conditions"; Real a_0(unit = "V") "Modified diode ideality factor under standard conditions"; Real w_0(final unit = "1") "MPP auxiliary correlation coefficient under standard conditions"; // Additional parameters and constants constant Real e=Modelica.Math.exp(1.0) "Euler's constant"; constant Real pi=Modelica.Constants.pi "Pi"; constant Real k(final unit="J/K") = 1.3806503e-23 "Boltzmann's constant"; constant Real q( unit = "A.s")= 1.602176620924561e-19 "Electron charge"; parameter Modelica.Units.SI.Energy E_g0=1.79604e-19 "Band gap energy under standard conditions for Si"; parameter Real C=0.0002677 "Band gap temperature coefficient for Si"; Modelica.Units.SI.ElectricCurrent I_mp(start=0.5*I_mp0) "MPP current"; Modelica.Units.SI.Voltage V_mp "MPP voltage"; Modelica.Units.SI.Energy E_g "Band gap energy"; Modelica.Units.SI.ElectricCurrent I_s "Saturation current"; Modelica.Units.SI.ElectricCurrent I_ph "Photo current"; Modelica.Units.SI.Resistance R_s "Series resistance"; Modelica.Units.SI.Resistance R_sh "Shunt resistance"; Real a(final unit = "V", start = 1.3) "Modified diode ideality factor"; Modelica.Units.SI.Power P_mod "Output power of one PV module"; Real w(final unit = "1", start = 0) "MPP auxiliary correlation coefficient"; Modelica.Units.SI.Voltage V_oc "Open circuit voltage under operating conditions"; equation // Analytical parameter extraction equations under standard conditions (Batzelis et al., 2016) a_0 = V_oc0*(1-T_c0*beta_Voc)/(50.1-T_c0*alpha_Isc); w_0 = AixLib.Electrical.PVSystem.BaseClasses.Wsimple(exp(1/(a_0/V_oc0)+1)); R_s0 = (a_0*(w_0-1)-V_mp0)/I_mp0; R_sh0 = a_0*(w_0-1)/(I_sc0*(1-1/w_0)-I_mp0); I_ph0 = (1+R_s0/R_sh0)*I_sc0; I_s0 = I_ph0*exp(-1/(a_0/V_oc0)); // Parameter extrapolation equations to operating conditions (DeSoto et al.,2006) a/a_0 = T_c/T_c0; I_s/I_s0 = (T_c/T_c0)^3*exp(1/k*(E_g0/T_c0-E_g/T_c)); E_g/E_g0 = 1-C*(T_c-T_c0); R_s = R_s0; I_ph = if absRadRat > 0 then absRadRat*(I_ph0+TCoeff_Isc*(T_c-T_c0)) else 0; R_sh/R_sh0 = if noEvent(absRadRat > 0.001) then 1/absRadRat else 0; //Simplified Power correlations at MPP using lambert W function (Batzelis et al., 2016) I_mp = if noEvent(absRadRat <= 0.0011 or w<=0.001) then 0 else I_ph*(1-1/w)-a*(w-1)/R_sh; V_mp = if absRadRat <= 0 then 0 else a*(w-1)-R_s*I_mp; V_oc = if I_ph >= 0.01 then a*log(abs((I_ph/I_s+1))) else 0; w = if noEvent(V_oc >= 0.001) then AixLib.Electrical.PVSystem.BaseClasses.Wsimple(exp(1/(a/V_oc)+1)) else 0; //I-V curve equation - use if P at a given V is needed (e.g. battery loading scenarios without MPP tracker) //I = I_ph - I_s*(exp((V+I*R_s)/(a))-1) - (V + I*R_s)/(R_sh); // Efficiency and Performance eta= if noEvent(radTil <= 0.01) then 0 else P_mod/(radTil*A_pan); P_mod = V_mp*I_mp; DCOutputPower=max(0, min(P_Max*n_mod, P_mod*n_mod)); end IVCharacteristics5pAnalytical;
Partial model for determining the cell temperature of a PV moduleConnector for PV record data.
within AixLib.Electrical.PVSystem.BaseClasses; partial model PartialCellTemperature "Partial model for determining the cell temperature of a PV moduleConnector for PV record data" // Parameters from module data sheet replaceable parameter AixLib.DataBase.SolarElectric.PVBaseDataDefinition data constrainedby AixLib.DataBase.SolarElectric.PVBaseDataDefinition "PV Panel data definition" final parameter Modelica.Units.SI.Efficiency eta_0=data.eta_0 "Efficiency under standard conditions"; final parameter Modelica.Units.SI.Temperature T_NOCT=data.T_NOCT "Cell temperature under NOCT conditions"; final parameter Real radNOCT(final quantity="Irradiance", final unit="W/m2")= 800 "Irradiance under NOCT conditions"; Modelica.Blocks.Interfaces.RealInput T_a(final quantity= "Temp_C", final unit="K") "Ambient temperature" Modelica.Blocks.Interfaces.RealInput winVel(final quantity= "Velocity", final unit= "m/s") "Wind velocity" Modelica.Blocks.Interfaces.RealInput eta(final quantity="Efficiency", final unit="1", min=0) "Efficiency of the PV module under operating conditions" Modelica.Blocks.Interfaces.RealInput radTil(final quantity="Irradiance", final unit="W/m2") "Total solar irradiance on the tilted surface" Modelica.Blocks.Interfaces.RealOutput T_c(final quantity= "ThermodynamicTemperature", final unit="K") "Cell temperature" end PartialCellTemperature;
Partial model for IV Characteristic of a PV module.
within AixLib.Electrical.PVSystem.BaseClasses; partial model PartialIVCharacteristics "Partial model for IV Characteristic of a PV module" replaceable parameter AixLib.DataBase.SolarElectric.PVBaseDataDefinition data constrainedby AixLib.DataBase.SolarElectric.PVBaseDataDefinition "PV Panel data definition" // Adjustable input parameters parameter Real n_mod(final quantity= "NumberOfModules", final unit="1") "Number of connected PV modules" // Parameters from module data sheet final parameter Modelica.Units.SI.Efficiency eta_0=data.eta_0 "Efficiency under standard conditions"; final parameter Real n_ser=data.n_ser "Number of cells connected in series on the PV panel"; final parameter Modelica.Units.SI.Area A_pan=data.A_pan "Area of one Panel, must not be confused with area of the whole module"; final parameter Modelica.Units.SI.Area A_mod=data.A_mod "Area of one module (housing)"; final parameter Modelica.Units.SI.Voltage V_oc0=data.V_oc0 "Open circuit voltage under standard conditions"; final parameter Modelica.Units.SI.ElectricCurrent I_sc0=data.I_sc0 "Short circuit current under standard conditions"; final parameter Modelica.Units.SI.Voltage V_mp0=data.V_mp0 "MPP voltage under standard conditions"; final parameter Modelica.Units.SI.ElectricCurrent I_mp0=data.I_mp0 "MPP current under standard conditions"; final parameter Modelica.Units.SI.Power P_Max=data.P_mp0*1.05 "Maximal power of one PV module under standard conditions. P_MPP with 5 % tolerance. This is used to limit DCOutputPower."; final parameter Real TCoeff_Isc(unit = "A/K")=data.TCoeff_Isc "Temperature coefficient for short circuit current, >0"; final parameter Real TCoeff_Voc(unit = "V/K")=data.TCoeff_Voc "Temperature coefficient for open circuit voltage, <0"; final parameter Modelica.Units.SI.LinearTemperatureCoefficient alpha_Isc=data.alpha_Isc "Normalized temperature coefficient for short circuit current, >0"; final parameter Modelica.Units.SI.LinearTemperatureCoefficient beta_Voc=data.beta_Voc "Normalized temperature coefficient for open circuit voltage, <0"; final parameter Modelica.Units.SI.LinearTemperatureCoefficient gamma_Pmp=data.gamma_Pmp "Normalized temperature coefficient for power at MPP"; final parameter Modelica.Units.SI.Temperature T_c0=25 + 273.15 "Thermodynamic cell temperature under standard conditions"; Modelica.Blocks.Interfaces.RealOutput DCOutputPower( final quantity="Power", final unit="W") "DC output power of the PV array" Modelica.Blocks.Interfaces.RealOutput eta( final quantity="Efficiency", final unit="1", min=0) "Efficiency of the PV module under operating conditions" Modelica.Blocks.Interfaces.RealInput T_c(final quantity= "ThermodynamicTemperature", final unit="K") "Cell temperature" Modelica.Blocks.Interfaces.RealInput absRadRat(final unit= "1") "Ratio of absorbed radiation under operating conditions to standard conditions" Modelica.Blocks.Interfaces.RealInput radTil(final unit="W/m2") "Total solar irradiance on the tilted surface" end PartialIVCharacteristics;
PV radiation and absorptance model - input: total irradiance on horizontal plane.
within AixLib.Electrical.PVSystem.BaseClasses; model PVRadiationHorizontal "PV radiation and absorptance model - input: total irradiance on horizontal plane" parameter Real lat(final quantity = "Angle", final unit = "rad", displayUnit = "deg") "Latitude" parameter Real lon(final quantity = "Angle", final unit = "rad", displayUnit = "deg") "Longitude" parameter Real alt(final quantity="Length", final unit="m") "Site altitude in Meters, default= 1" parameter Real til(final quantity = "Angle", final unit = "rad", displayUnit = "deg") "Surface tilt. til=90 degree for walls; til=0 for ceilings; til=180 for roof" parameter Real azi(final quantity = "Angle", final unit = "rad", displayUnit = "deg") "Module surface azimuth. azi=-90 degree if normal of surface outward unit points towards east; azi=0 if it points towards south" parameter Real timZon(final quantity="Time", final unit="s", displayUnit="h") "Time zone in seconds relative to GMT" parameter Real groRef(final unit="1") "Ground refelctance" // Air mass parameters for mono-SI parameter Real b_0=0.935823; parameter Real b_1=0.054289; parameter Real b_2=-0.008677; parameter Real b_3=0.000527; parameter Real b_4=-0.000011; parameter Real radTil0(final quantity="Irradiance", final unit= "W/m2") = 1000 "total solar radiation on the horizontal surface under standard conditions"; parameter Real G_sc(final quantity="Irradiance", final unit = "W/m2") = 1376 "Solar constant"; parameter Real glaExtCoe(final unit="1/m") = 4 "Glazing extinction coefficient for glass"; parameter Real glaThi(final unit="m") = 0.002 "Glazing thickness for most PV cell panels"; parameter Real refInd(final unit="1", min=0) = 1.526 "Effective index of refraction of the cell cover (glass)"; parameter Real tau_0(final unit="1", min=0)= exp(-(glaExtCoe*glaThi))*(1 - ((refInd - 1)/(refInd + 1)) ^2) "Transmittance at standard conditions (incAng=refAng=0)"; Real cloTim(final quantity="Time", final unit="s", displayUnit="h") "Local clock time"; Real nDay(final quantity="Time",final unit="s") "Day number with units of seconds"; Real radHorBea(final quantity="Irradiance", final unit= "W/m2") "Beam solar radiation on the horizontal surface"; Real radHorDif(final quantity="Irradiance", final unit= "W/m2") "Diffuse solar radiation on the horizontal surface"; Real k_t(final unit="1", start=0.5) "Clearness index"; Real airMas(final unit="1", min=0) "Air mass"; Real airMasMod(final unit="1", min=0) "Air mass modifier"; Modelica.Units.SI.Angle incAngGro "Incidence angle for ground reflection"; Modelica.Units.SI.Angle incAngDif "Incidence angle for diffuse radiation"; Real incAngMod(final unit="1", min=0) "Incidence angle modifier"; Real incAngModGro(final unit="1", min=0) "Incidence angle modifier for ground refelction"; Real incAngModDif(final unit="1", min=0) "Incidence angle modifier for diffuse radiation"; Modelica.Units.SI.Angle refAng "Angle of refraction"; Modelica.Units.SI.Angle refAngGro "Angle of refraction for ground reflection"; Modelica.Units.SI.Angle refAngDif "Angle of refraction for diffuse irradiation"; Real tau(final unit="1", min=0) "Transmittance of the cover system"; Real tau_ground(final unit="1", min=0) "Transmittance of the cover system for ground reflection"; Real tau_diff(final unit="1", min=0) "Transmittance of the cover system for diffuse radiation"; Real R_b(final unit="1", min=0) "Ratio of irradiance on tilted surface to horizontal surface"; Modelica.Units.SI.Angle zen "Zenith angle"; AixLib.BoundaryConditions.SolarGeometry.BaseClasses.SolarHourAngle solHouAng "Solar hour angle"; AixLib.BoundaryConditions.WeatherData.BaseClasses.LocalCivilTime locTim( timZon=timZon, lon=lon) "Block that computes the local civil time"; AixLib.BoundaryConditions.WeatherData.BaseClasses.SolarTime solTim "Block that computes the solar time"; AixLib.BoundaryConditions.WeatherData.BaseClasses.EquationOfTime eqnTim "Block that computes the equation of time"; AixLib.BoundaryConditions.SolarGeometry.BaseClasses.Declination decAng "Declination angle"; AixLib.BoundaryConditions.SolarGeometry.BaseClasses.IncidenceAngle incAng( azi=azi, til=til, lat=lat) "Incidence angle"; AixLib.BoundaryConditions.SolarGeometry.BaseClasses.ZenithAngle zenAng( lat=lat) "Zenith angle"; AixLib.Utilities.Time.ModelTime modTim "Block that outputs simulation time"; Modelica.Blocks.Interfaces.RealOutput radTil(final quantity="Irradiance", final unit= "W/m2") "Total solar radiation on the tilted surface" Modelica.Blocks.Interfaces.RealOutput absRadRat(final unit= "1", min=0) "Ratio of absorbed radiation under operating conditions to standard conditions" Modelica.Blocks.Interfaces.RealInput radHor(final quantity="Irradiance", final unit= "W/m2") "Total solar irradiance on the horizontal surface" equation connect(solTim.solTim, solHouAng.solTim); connect(locTim.locTim, solTim.locTim); connect(eqnTim.eqnTim, solTim.equTim); connect(decAng.decAng, incAng.decAng); connect(solHouAng.solHouAng, incAng.solHouAng); connect(decAng.decAng, zenAng.decAng); connect(solHouAng.solHouAng, zenAng.solHouAng); nDay = floor(modTim.y/86400)*86400 "Zero-based day number in seconds (January 1=0, January 2=86400)"; cloTim= modTim.y-nDay; eqnTim.nDay= nDay; locTim.cloTim=cloTim; decAng.nDay= nDay; zen = if zenAng.zen <= Modelica.Constants.pi/2 then zenAng.zen else Modelica.Constants.pi/2 "Restriction for zenith angle"; refAng = if noEvent(incAng.incAng >= 0.0001 and incAng.incAng <= Modelica.Constants.pi /2*0.999) then asin(sin(incAng.incAng)/refInd) else 0; refAngGro = if noEvent(incAngGro >= 0.0001 and incAngGro <= Modelica.Constants.pi/2* 0.999) then asin(sin(incAngGro)/refInd) else 0; refAngDif = if noEvent(incAngDif >= 0.0001 and incAngDif <= Modelica.Constants.pi/2* 0.999) then asin(sin(incAngDif)/refInd) else 0; tau = if noEvent(incAng.incAng >= 0.0001 and incAng.incAng <= Modelica.Constants.pi/ 2*0.999 and refAng >= 0.0001) then exp(-(glaExtCoe*glaThi/cos(refAng)))*(1 - 0.5*((sin(refAng - incAng.incAng)^2)/(sin(refAng + incAng.incAng)^2) + ( tan(refAng - incAng.incAng)^2)/(tan(refAng + incAng.incAng)^2))) else 0; tau_ground = if noEvent(incAngGro >= 0.0001 and refAngGro >= 0.0001) then exp(-( glaExtCoe*glaThi/cos(refAngGro)))*(1 - 0.5*((sin(refAngGro - incAngGro)^2)/ (sin(refAngGro + incAngGro)^2) + (tan(refAngGro - incAngGro)^2)/(tan( refAngGro + incAngGro)^2))) else 0; tau_diff = if noEvent(incAngDif >= 0.0001 and refAngDif >= 0.0001) then exp(-( glaExtCoe*glaThi/cos(refAngDif)))*(1 - 0.5*((sin(refAngDif - incAngDif)^2)/ (sin(refAngDif + incAngDif)^2) + (tan(refAngDif - incAngDif)^2)/(tan( refAngDif + incAngDif)^2))) else 0; incAngMod = tau/tau_0; incAngModGro = tau_ground/tau_0; incAngModDif = tau_diff/tau_0; airMasMod = if (b_0 + b_1*(airMas^1) + b_2*(airMas^2) + b_3*( airMas^3) + b_4*(airMas^4)) <= 0 then 0 else b_0 + b_1*(airMas^1) + b_2*(airMas^2) + b_3*(airMas^3) + b_4*(airMas^4); airMas = exp(-0.0001184*alt)/(cos(zen) + 0.5057*(96.080 - zen* 180/Modelica.Constants.pi)^(-1.634)); incAngGro = (90 - 0.5788*til*180/Modelica.Constants.pi + 0.002693*(til*180/ Modelica.Constants.pi)^2)*Modelica.Constants.pi/180; incAngDif = (59.7 - 0.1388*til*180/Modelica.Constants.pi + 0.001497*(til*180/ Modelica.Constants.pi)^2)*Modelica.Constants.pi/180; R_b = if noEvent((zen >= Modelica.Constants.pi/2*0.999) or (cos(incAng.incAng) > cos(zen)*4)) then 4 else (cos(incAng.incAng)/cos(zen)); radHor = radHorBea + radHorDif; radTil = if noEvent(radHor <= 0.1) then 0 else radHorBea*R_b + radHorDif*(0.5*(1 + cos( til)*(1 + (1 - (radHorDif/radHor)^2)*sin(til/2)^3)*(1 + (1 - (radHorDif/ radHor)^2)*(cos(incAng.incAng)^2)*(cos(til)^3)))) + radHor*groRef*(1 - cos( til))/2; k_t = if noEvent(radHor <=0.001) then 0 else min(1,max(0,(radHor)/(G_sc*(1.00011+0.034221*cos(2*Modelica.Constants.pi*nDay/24/60/60/365)+0.00128*sin(2*Modelica.Constants.pi*nDay/24/60/60/365) +0.000719*cos(2*2*Modelica.Constants.pi*nDay/24/60/60/365)+0.000077*sin(2*2*Modelica.Constants.pi*nDay/24/60/60/365))*cos(zenAng.zen)))) "after (Iqbal,1983)"; // Erb´s diffuse fraction relation radHorDif = if radHor <=0.001 then 0 elseif k_t <= 0.22 then (radHor)*(1.0-0.09*k_t) elseif k_t > 0.8 then (radHor)*0.165 else (radHor)*(0.9511-0.1604*k_t+4.388*k_t^2-16.638*k_t^3+12.336*k_t^4); absRadRat = if noEvent(radHor <=0.1) then 0 else airMasMod*(radHorBea/radTil0*R_b*incAngMod +radHorDif/radTil0*incAngModDif*(0.5*(1+cos(til)*(1+(1-(radHorDif/radHor)^2)*sin(til/2)^3)*(1+(1-(radHorDif/radHor)^2)*(cos(incAng.incAng)^2)*(cos(til)^3)))) +radHor/radTil0*groRef*incAngModGro*(1-cos(til))/2); end PVRadiationHorizontal;
Example of a model for determining the DC output Power of a PV array; Modules mounted close to the ground. Simulation to test the <a href= \"AixLib.Electrical.PVSystem.PVSystem\">PVSystem</a> model.
within AixLib.Electrical.PVSystem.Examples; model ExamplePVSystem "Example of a model for determining the DC output Power of a PV array; Modules mounted close to the ground" import ModelicaServices; extends Modelica.Icons.Example; PVSystem pVSystem( redeclare DataBase.SolarElectric.QPlusBFRG41285 data, n_mod=20, lat(displayUnit="deg") = 0.91664692314742, lon(displayUnit="deg") = 0.23387411976724, alt=10, til(displayUnit="deg") = 0.26179938779915, azi(displayUnit="deg") = 0, redeclare model CellTemperature = BaseClasses.CellTemperatureMountingCloseToGround, redeclare model IVCharacteristics = BaseClasses.IVCharacteristics5pAnalytical, timZon(displayUnit="s") = weaDat.timZon) "Model for determining the DC output Power of a PV array; Modules mounted close to the ground (adjust to different mounting via cellTemp)" AixLib.BoundaryConditions.WeatherData.ReaderTMY3 weaDat(filNam= ModelicaServices.ExternalReferences.loadResource( "modelica://AixLib/Resources/weatherdata/Weather_TRY_Berlin_winter.mos"), calTSky=AixLib.BoundaryConditions.Types. SkyTemperatureCalculation.HorizontalRadiation) Modelica.Blocks.Interfaces.RealOutput DCOutputPower( final quantity="Power", final unit="W") "DC output power of the PV array" equation connect(pVSystem.DCOutputPower, DCOutputPower) connect(weaDat.weaBus, pVSystem.weaBus) end ExamplePVSystem;
Collection of validation models
within AixLib.Electrical.PVSystem; package Validation "Collection of validation models" extends Modelica.Icons.ExamplesPackage; end Validation;
Validation with empirical data from NIST for the date of 14.06.2016. The PVSystem model is validaded with empirical data from: <a href= \"https://pvdata.nist.gov/\">https://pvdata.nist.gov/</a>
within AixLib.Electrical.PVSystem.Validation; model ValidationPVSystem "Validation with empirical data from NIST for the date of 14.06.2016" extends Modelica.Icons.Example; PVSystem pVSystem( redeclare DataBase.SolarElectric.SharpNUU235F2 data, redeclare model IVCharacteristics = BaseClasses.IVCharacteristics5pAnalytical, redeclare model CellTemperature = BaseClasses.CellTemperatureMountingCloseToGround, n_mod=312, til=0.17453292519943, azi=0, lat=0.68304158408499, lon=-1.3476664539029, alt=0.08, timZon=-18000) "PV System according to measurements taken from https://pvdata.nist.gov/ " Modelica.Blocks.Interfaces.RealOutput DCOutputPower( final quantity="Power", final unit="W") "DC output power of the PV array" BoundaryConditions.WeatherData.Bus weaBus Modelica.Blocks.Sources.CombiTimeTable NISTdata( tableOnFile=true, tableName="Roof2016", fileName=ModelicaServices.ExternalReferences.loadResource( "modelica://AixLib/Resources/weatherdata/NIST_onemin_Roof_2016.txt"), columns={3,5,2,4}, smoothness=Modelica.Blocks.Types.Smoothness.ContinuousDerivative) "The PVSystem model is validaded with measurement data from: https://pvdata.nist.gov/ " Modelica.Blocks.Math.UnitConversions.From_degC from_degC Modelica.Blocks.Interfaces.RealOutput DCOutputPower_Measured( final quantity="Power", final unit="W") "Measured DC output power of the PV array" Modelica.Blocks.Math.Gain kiloWattToWatt(k=1000) equation connect(pVSystem.DCOutputPower, DCOutputPower) connect(pVSystem.weaBus, weaBus) connect(NISTdata.y[2], weaBus.winSpe) connect(NISTdata.y[3], weaBus.HGloHor) connect(NISTdata.y[1], from_degC.u) connect(from_degC.y, weaBus.TDryBul) connect(NISTdata.y[4], kiloWattToWatt.u) connect(kiloWattToWatt.y, DCOutputPower_Measured) end ValidationPVSystem;
Package with models for transmission lines
within AixLib.Electrical; package Transmission "Package with models for transmission lines" extends Modelica.Icons.Package; end Transmission;
Package that contains partial models for lines and cables
within AixLib.Electrical.Transmission; package BaseClasses "Package that contains partial models for lines and cables" extends Modelica.Icons.BasesPackage; end BaseClasses;
Partial cable line dispersion model. This partial model contains parameters and variables needed to parametrize a generic cable. The resistance, inductance and capacitance are computed by the functions associated to the type of cable selected. The type of cable is specified using a record that inherits from <a href=\"modelica://AixLib.Electrical.Transmission.BaseClasses.BaseCable\"> AixLib.Electrical.Transmission.BaseClasses.BaseCable</a> such as ( <a href=\"modelica://AixLib.Electrical.Transmission.LowVoltageCables.Generic\"> AixLib.Electrical.Transmission.LowVoltageCables.Generic</a> or <a href=\"modelica://AixLib.Electrical.Transmission.MediumVoltageCables.Generic\"> AixLib.Electrical.Transmission.MediumVoltageCables.Generic</a>). The record contains functions that depending on the properties of cable compute its resistance, inductance or capacitance.
within AixLib.Electrical.Transmission.BaseClasses; partial model PartialBaseLine "Partial cable line dispersion model" parameter Modelica.Units.SI.Length l(min=0) "Length of the line"; parameter Modelica.Units.SI.Power P_nominal(min=0) "Nominal power of the line"; parameter Modelica.Units.SI.Voltage V_nominal(min=0, start=220) "Nominal voltage of the line"; final parameter Modelica.Units.SI.Frequency f_n=50 "Frequency considered in the definition of cables properties"; parameter Boolean use_C = false "Set to true to add a capacitance in the center of the line" parameter AixLib.Electrical.Types.Load modelMode=AixLib.Electrical.Types.Load.FixedZ_steady_state "Select between steady state and dynamic model" parameter Boolean use_T = false "If true, enables the input for the temperature of the cable" parameter Modelica.Units.SI.Temperature TCable=T_ref "Fixed temperature of the cable" parameter AixLib.Electrical.Types.CableMode mode=AixLib.Electrical.Types.CableMode.automatic "Select if choosing the cable automatically or between a list of commercial options" replaceable parameter AixLib.Electrical.Transmission.LowVoltageCables.Generic commercialCable constrainedby AixLib.Electrical.Transmission.BaseClasses.BaseCable "Commercial cables options" final parameter Modelica.Units.SI.Temperature T_ref=commercialCable.T_ref "Reference temperature of the line" final parameter Modelica.Units.SI.Temperature M=commercialCable.M "Temperature constant (R_actual = R*(M + T_heatPort)/(M + T_ref))"; final parameter Modelica.Units.SI.Resistance R=commercialCable.lineResistance( l, f_n, commercialCable) "Resistance of the cable" final parameter Modelica.Units.SI.Inductance L=commercialCable.lineInductance( l, f_n, commercialCable) "Inductance of the cable due to mutual and self inductance" final parameter Modelica.Units.SI.Capacitance C= commercialCable.lineCapacitance( l, f_n, commercialCable) "Capacitance of the cable" Modelica.Thermal.HeatTransfer.Sources.PrescribedTemperature cableTemp "Temperature of the cable" Modelica.Blocks.Interfaces.RealInput T if use_T "Temperature of the cable" Modelica.Blocks.Sources.RealExpression cableTemperature(y=T_in) "Temperature of the cable" protected Modelica.Blocks.Interfaces.RealInput T_in "Internal variable for conditional temperature"; equation assert(L>=0 and R>=0 and C>=0, "The parameters R,L,C must be positive. Check cable properties and size."); connect(T_in, T); if not use_T then T_in = TCable; end if; connect(cableTemperature.y, cableTemp.T) end PartialBaseLine;
Partial cable line dispersion model. This partial model extends the model <a href=\"modelica://AixLib.Electrical.Transmission.BaseClasses.PartialBaseLine\"> AixLib.Electrical.Transmission.BaseClasses.PartialBaseLine</a>. It adds two generalized electric connectors.
within AixLib.Electrical.Transmission.BaseClasses; partial model PartialLine "Partial cable line dispersion model" extends AixLib.Electrical.Interfaces.PartialTwoPort; extends AixLib.Electrical.Transmission.BaseClasses.PartialBaseLine; Real VoltageLosses(unit = "1") = abs(PhaseSystem_p.systemVoltage(terminal_p.v) - PhaseSystem_n.systemVoltage(terminal_n.v))/ AixLib.Utilities.Math.Functions.smoothMax( PhaseSystem_p.systemVoltage(terminal_p.v), PhaseSystem_n.systemVoltage(terminal_n.v), 1.0) "Percentage of voltage losses across the line"; protected parameter Integer n_ = size(terminal_n.i,1) "Number of cables"; parameter Real nominal_i_ = P_nominal / V_nominal "Nominal current flowing through the line"; parameter Real nominal_v_ = V_nominal "Nominal voltage of the line"; end PartialLine;
Partial model that represent an electric network. This partial model represents a generalized electrical network.
within AixLib.Electrical.Transmission.BaseClasses; partial model PartialNetwork "Partial model that represent an electric network" parameter Modelica.Units.SI.Voltage V_nominal(min=0, start=110) "Nominal voltage of the lines in the network"; replaceable parameter AixLib.Electrical.Transmission.Grids.PartialGrid grid "Record that describe the grid with the number of nodes, links, connections, etc." replaceable AixLib.Electrical.Interfaces.BaseTerminal terminal[grid.nNodes] "Electric terminals for each node of the network" replaceable AixLib.Electrical.Transmission.BaseClasses.PartialBaseLine lines[grid.nLinks]( each mode=AixLib.Electrical.Types.CableMode.commercial, l={grid.l[i, 1] for i in 1:grid.nLinks}, each P_nominal=1000, each V_nominal=V_nominal) "Array of line models, each line connecting two nodes of the grid"; end PartialNetwork;
Partial model of an inductive element that links two electrical connectors. Partial model of an inductance that links two generalized electrical connectors.
within AixLib.Electrical.Transmission.BaseClasses; partial model PartialTwoPortInductance "Partial model of an inductive element that links two electrical connectors" extends Interfaces.PartialTwoPort; parameter Modelica.Units.SI.Inductance L "Inductance" equation Connections.branch(terminal_p.theta, terminal_n.theta); terminal_p.theta = terminal_n.theta; terminal_p.i = - terminal_n.i; end PartialTwoPortInductance;
Partial model of a resistive element that links two electrical connectors. Partial model of a resistance that links two generalized electrical connectors.
within AixLib.Electrical.Transmission.BaseClasses; partial model PartialTwoPortResistance "Partial model of a resistive element that links two electrical connectors" extends Interfaces.PartialTwoPort; extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(T = T_ref); parameter Modelica.Units.SI.Resistance R "Resistance at temperature T_ref"; parameter Modelica.Units.SI.Temperature T_ref=298.15 "Reference temperature"; parameter Modelica.Units.SI.Temperature M=507.65 "Temperature constant (R_actual = R*(M + T_heatPort)/(M + T_ref))"; Modelica.Units.SI.Resistance R_actual "Actual resistance = R*(M + T_heatPort)/(M + T_ref) "; equation Connections.branch(terminal_p.theta, terminal_n.theta); terminal_p.theta = terminal_n.theta; assert(R_actual>=0, "The value of R_actual must be positive, check reference and actual temperatures."); R_actual =R*(M + Modelica.Units.Conversions.to_degC(T_heatPort))/(M + Modelica.Units.Conversions.to_degC(T_ref)); terminal_p.i = - terminal_n.i; end PartialTwoPortResistance;
Partial model of an RLC element that links two electrical connectors. Partial model of a resistance that links two generalized electrical connectors.
within AixLib.Electrical.Transmission.BaseClasses; partial model PartialTwoPortRLC "Partial model of an RLC element that links two electrical connectors" extends AixLib.Electrical.Interfaces.PartialTwoPort; extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(T = T_ref); parameter Modelica.Units.SI.Resistance R "Resistance at temperature T_ref" parameter Modelica.Units.SI.Temperature T_ref=298.15 "Reference temperature"; parameter Modelica.Units.SI.Temperature M=507.65 "Temperature constant (R_actual = R*(M + T_heatPort)/(M + T_ref))"; parameter Modelica.Units.SI.Capacitance C "Capacity"; parameter Modelica.Units.SI.Inductance L "Inductance"; parameter Modelica.Units.SI.Voltage V_nominal(min=0, start=110) "Nominal voltage (V_nominal >= 0)" Modelica.Units.SI.Resistance R_actual "Actual resistance = R*(M + T_heatPort)/(M + T_ref) "; equation Connections.branch(terminal_p.theta, terminal_n.theta); terminal_p.theta = terminal_n.theta; assert(R_actual>=0, "The value of R_actual must be positive, check reference and actual temperatures"); R_actual =R*(M + Modelica.Units.Conversions.to_degC(T_heatPort))/(M + Modelica.Units.Conversions.to_degC(T_ref)); end PartialTwoPortRLC;
Package that contains functions to compute cable properties
within AixLib.Electrical.Transmission; package Functions "Package that contains functions to compute cable properties" extends Modelica.Icons.Package; end Functions;
<html> <p> This package contains validation models for the classes in <a href=\
within AixLib.Electrical.Transmission.Functions; package Validation extends Modelica.Icons.ExamplesPackage; end Validation;
Validation model for the function that selects the cable. This model validates <a href=\"modelica://AixLib.Electrical.Transmission.Functions.selectCable_low\"> AixLib.Electrical.Transmission.Functions.selectCable_low</a> for a different range of currents.
within AixLib.Electrical.Transmission.Functions.Validation; model SelectCable_low "Validation model for the function that selects the cable" extends Modelica.Icons.Example; parameter Modelica.Units.SI.Voltage V_nominal=480 "Rated voltage"; parameter Modelica.Units.SI.Power[:] P_nominal=I_nominal*V_nominal/ safety_factor "Rated power"; parameter Modelica.Units.SI.Current[:] I_nominal={65,95,110,130,170,220,230} .- 10 "Nominal current"; parameter Real safety_factor = 1.2 "Safety factor"; parameter AixLib.Electrical.Transmission.LowVoltageCables.Generic[:] cab = AixLib.Electrical.Transmission.Functions.selectCable_low( P_nominal = P_nominal, V_nominal = V_nominal) "Selected cable"; end SelectCable_low;
Validation model for the function that selects the cable. This model validates <a href=\"modelica://AixLib.Electrical.Transmission.Functions.selectCable_med\"> AixLib.Electrical.Transmission.Functions.selectCable_med</a> for a different range of currents.
within AixLib.Electrical.Transmission.Functions.Validation; model SelectCable_med "Validation model for the function that selects the cable" extends Modelica.Icons.Example; parameter Modelica.Units.SI.Voltage V_nominal=25e3 "Rated voltage"; parameter Modelica.Units.SI.Power[:] P_nominal=I_nominal*V_nominal/ safety_factor "Rated power"; parameter Modelica.Units.SI.Current[:] I_nominal={195,250,285,375,450,640,800} .- 10 "Nominal current"; parameter Real safety_factor = 1.2 "Safety factor"; parameter AixLib.Electrical.Transmission.MediumVoltageCables.Generic[:] cab = AixLib.Electrical.Transmission.Functions.selectCable_med( P_nominal = P_nominal, V_nominal = V_nominal) "Selected cable"; end SelectCable_med;
Grid model inspired to the IEEE 34 Node test feeder. This model represents a grid inspired by the IEEE 34 node test feeder. In this example, the cable types and lengths have been modified in order to represent a typical distribution feeder.
within AixLib.Electrical.Transmission.Grids; record IEEE_34_AL120 "Grid model inspired to the IEEE 34 Node test feeder" extends AixLib.Electrical.Transmission.Grids.PartialGrid( nNodes=34, nLinks=33, l=[48;16;16;40;32;16;16;16;16;16;16;32;32;16;32;32;32;48;48;32;32;16;16;16; 16;16;32;32;16;32;16;16;16], fromTo=[[1,2]; [2,3]; [3,4]; [4,5]; [4,6]; [6,7]; [7,8]; [9,26]; [10,26]; [ 11,9]; [12,11]; [13,10]; [14,10]; [15,14]; [16,15]; [17,27]; [18,27]; [ 19,31]; [20,31]; [21,32]; [22,32]; [23,20]; [24,23]; [25,24]; [26,8]; [ 27,29]; [28,16]; [29,16]; [30,17]; [31,17]; [32,19]; [33,22]; [34,18]], redeclare AixLib.Electrical.Transmission.LowVoltageCables.Generic cables= {LowVoltageCables.PvcAl120(),LowVoltageCables.PvcAl120(), LowVoltageCables.PvcAl120(),LowVoltageCables.PvcAl120(), LowVoltageCables.PvcAl120(),LowVoltageCables.PvcAl120(), LowVoltageCables.PvcAl120(),LowVoltageCables.PvcAl120(), LowVoltageCables.PvcAl120(),LowVoltageCables.PvcAl120(), LowVoltageCables.PvcAl120(),LowVoltageCables.PvcAl120(), LowVoltageCables.PvcAl120(),LowVoltageCables.PvcAl120(), LowVoltageCables.PvcAl120(),LowVoltageCables.PvcAl70(), LowVoltageCables.PvcAl70(),LowVoltageCables.PvcAl35(), LowVoltageCables.PvcAl35(),LowVoltageCables.PvcAl35(), LowVoltageCables.PvcAl35(),LowVoltageCables.PvcAl35(), LowVoltageCables.PvcAl35(),LowVoltageCables.PvcAl35(), LowVoltageCables.PvcAl120(),LowVoltageCables.PvcAl70(), LowVoltageCables.PvcAl70(),LowVoltageCables.PvcAl70(), LowVoltageCables.PvcAl70(),LowVoltageCables.PvcAl70(), LowVoltageCables.PvcAl35(),LowVoltageCables.PvcAl35(), LowVoltageCables.PvcAl70()}); /* LEFT HERE TO CHECK CONSISTENCY LenVec={ 0,48,16,16,40, 32,16,16,16,16, 16,16,32,32,16, 32,32,32,48,48, 32,32,16,16,16, 16,16,32,32,16, 32,16,16,16}, CabTyp={ ,.PvcAl120(),.PvcAl120(),.PvcAl120(),.PvcAl120(), .PvcAl120(),.PvcAl120(),.PvcAl120(),.PvcAl120(),.PvcAl120(), .PvcAl120(),.PvcAl120(),.PvcAl120(),.PvcAl120(),.PvcAl120(), .PvcAl120(),.PvcAl70(),.PvcAl70(),.PvcAl35(),.PvcAl35(), .PvcAl35(),.PvcAl35(),.PvcAl35(),.PvcAl35(),.PvcAl35(), .PvcAl120(),.PvcAl70(),.PvcAl70(),.PvcAl70(),.PvcAl70(), .PvcAl70(),.PvcAl35(),.PvcAl35(),.PvcAl70()}); */ end IEEE_34_AL120;
Package that contains different types of grids
within AixLib.Electrical.Transmission; package Grids "Package that contains different types of grids" extends Modelica.Icons.MaterialPropertiesPackage; end Grids;
Partial model that represents a generalized grid. This abstract grid model specifies the topology of the network by
within AixLib.Electrical.Transmission.Grids; record PartialGrid "Partial model that represents a generalized grid" extends Modelica.Icons.MaterialProperty; parameter Integer nNodes "Number of nodes of the grid"; parameter Integer nLinks "Number of links connecting the nodes"; parameter Integer fromTo[nLinks,2] "Indexes [i,1]->[i,2] of the nodes connected by link i"; parameter Modelica.Units.SI.Length l[nLinks,1](each min=0) "Length of the cable"; replaceable AixLib.Electrical.Transmission.BaseClasses.BaseCable cables[nLinks] "Array that contains the characteristics of each cable"; end PartialGrid;
Simple model of a grid with 2 nodes and 1 link. This model represents a simple grid with two nodes and a single link between them.
within AixLib.Electrical.Transmission.Grids; record TestGrid2Nodes "Simple model of a grid with 2 nodes and 1 link" extends AixLib.Electrical.Transmission.Grids.PartialGrid( nNodes=2, nLinks=1, fromTo=[[1,2]], l=[200], redeclare AixLib.Electrical.Transmission.LowVoltageCables.Generic cables = {LowVoltageCables.Cu35()}); end TestGrid2Nodes;
Simple model of a grid with 2 nodes and 1 link for medium voltage. This model represents a simple grid with two nodes and a single link between them. This model differs from <a href=\"modelica://AixLib.Electrical.Transmission.Grids.TestGrid2Nodes\"> AixLib.Electrical.Transmission.Grids.TestGrid2Nodes</a> because it defines a medium voltage cable instead of a low voltage cable.
within AixLib.Electrical.Transmission.Grids; record TestGrid2NodesMedium "Simple model of a grid with 2 nodes and 1 link for medium voltage" extends AixLib.Electrical.Transmission.Grids.PartialGrid( nNodes=2, nLinks=1, fromTo=[[1,2]], l=[200], redeclare AixLib.Electrical.Transmission.MediumVoltageCables.Generic cables = {MediumVoltageCables.Annealed_Al_30()}); end TestGrid2NodesMedium;
Package of low voltage electricity cables used in distribution grid
within AixLib.Electrical.Transmission; package LowVoltageCables "Package of low voltage electricity cables used in distribution grid" extends Modelica.Icons.MaterialPropertiesPackage; end LowVoltageCables;
Package of medium voltage electricity cables used in distribution grid
within AixLib.Electrical.Transmission; package MediumVoltageCables "Package of medium voltage electricity cables used in distribution grid" extends Modelica.Icons.MaterialPropertiesPackage; end MediumVoltageCables;
Package that contains cables materials
within AixLib.Electrical.Transmission; package Types "Package that contains cables materials" extends Modelica.Icons.TypesPackage; end Types;
Select automatically the size of the cable.
within AixLib.Electrical.Types; type CableMode = enumeration( automatic "Select automatically the size of the cable", commercial "Select the cable from a list of commercial options") "Enumeration that defines how a cable can be parameterized"
Assume i=0 during homotopy initialization.
within AixLib.Electrical.Types; type InitMode = enumeration( zero_current "Assume i=0 during homotopy initialization", linearized "Uses linear model during homotopy initialization") "Enumeration that defines the type of initialization assumption can be used for a load model"
Fixed Z, steady-state.
within AixLib.Electrical.Types; type Load = enumeration( FixedZ_steady_state "Fixed Z, steady-state", FixedZ_dynamic "Fixed Z, dynamic", VariableZ_P_input "Variable Z, P input", VariableZ_y_input "Variable Z, y input") "Enumeration that defines the modeling assumption of the load."
This package contains new types used within the Electrical package
within AixLib.Electrical; package Types "This package contains new types used within the Electrical package" extends Modelica.Icons.TypesPackage; end Types;
Package with models and functions that are used by other models
within AixLib.Electrical; package Utilities "Package with models and functions that are used by other models" extends Modelica.Icons.Package; end Utilities;
Voltage controller
within AixLib.Electrical.Utilities; model VoltageControl "Voltage controller" replaceable package PhaseSystem = AixLib.Electrical.PhaseSystems.PartialPhaseSystem constrainedby AixLib.Electrical.PhaseSystems.PartialPhaseSystem "Phase system" parameter Modelica.Units.SI.Voltage V_nominal "Nominal voltage of the node to be controlled"; parameter Real vThresh(min=0.0, max=1.0) = 0.1 "Threshold that activates voltage ctrl (ratio of nominal voltage)"; parameter Modelica.Units.SI.Time tDelay=300 "Time to wait before plugging the load back"; parameter Modelica.Units.SI.Time T=0.01 "Time constant representing the switching time"; parameter Real y_start = 1.0 "Initial value of the control output signal"; final parameter Modelica.Units.SI.Voltage Vmin=V_nominal*(1 - vThresh) "Low threshold"; final parameter Modelica.Units.SI.Voltage Vmax=V_nominal*(1 + vThresh) "High threshold"; Modelica.Blocks.Interfaces.RealOutput y(start = y_start, stateSelect = StateSelect.prefer) "Control signal" replaceable AixLib.Electrical.Interfaces.Terminal terminal( redeclare replaceable package PhaseSystem = PhaseSystem) "Generalized terminal" AixLib.Electrical.Utilities.Controllers.StateMachineVoltCtrl ctrl( V_nominal=V_nominal, vThresh=vThresh, tDelay=tDelay) "Model that implements the state machines voltage controller"; initial equation y = y_start; equation // Output of the control block y + T*der(y) = ctrl.y; // Voltage measurements ctrl.V = terminal.PhaseSystem.systemVoltage(terminal.v); // The controller does not consume current terminal.i = zeros(PhaseSystem.n); end VoltageControl;