diff --git a/VirtualFCS/Control/BatteryManagementSystem.mo b/VirtualFCS/Control/BatteryManagementSystem.mo index ceaa588..7653def 100644 --- a/VirtualFCS/Control/BatteryManagementSystem.mo +++ b/VirtualFCS/Control/BatteryManagementSystem.mo @@ -2,8 +2,8 @@ within VirtualFCS.Control; model BatteryManagementSystem "Implement algorithms for the control of battery systems." parameter Real N_s "Number of Cells in Series"; - parameter Real lowerVoltageLimit = N_s * 2; - parameter Real upperVoltageLimit = N_s * 3.6; + parameter Modelica.Units.SI.Voltage lowerVoltageLimit = N_s * 2; + parameter Modelica.Units.SI.Voltage upperVoltageLimit = N_s * 3.6; VirtualFCS.Control.ChargeCounter chargeCounter annotation( Placement(visible = true, transformation(origin = {25, -1}, extent = {{25, -25}, {-25, 25}}, rotation = 0))); Modelica.Electrical.Analog.Interfaces.NegativePin pin_n_battery annotation( @@ -47,4 +47,4 @@ equation Icon(graphics = {Rectangle(fillColor = {50, 50, 50}, fillPattern = FillPattern.Solid, extent = {{-100, 100}, {100, -100}}), Text(origin = {2, 72}, lineColor = {255, 255, 255}, extent = {{-26, 22}, {26, -22}}, textString = "Load"), Text(origin = {0, -52}, lineColor = {255, 255, 255}, extent = {{-44, 34}, {48, -36}}, textString = "Battery"), Text(origin = {104, 146}, lineColor = {0, 0, 255}, extent = {{-26, 22}, {84, -80}}, textString = "%name"), Text(origin = {62, 24}, lineColor = {255, 255, 255}, extent = {{-44, 34}, {26, -24}}, textString = "SOC_init"), Text(origin = {106, -52}, lineColor = {255, 255, 255}, extent = {{-44, 34}, {-8, 10}}, textString = "Q")}, coordinateSystem(extent = {{-150, -100}, {150, 100}}, initialScale = 0.1)), Diagram(coordinateSystem(extent = {{-150, -100}, {150, 100}})), Documentation(info = "The BatteryManagementSystem component is responsible for protecting the battery pack. It ensures that the pack is not overcharged or overdischarged to dangerous state-of-charge levels. It also limits the maximum charging and discharging current the battery pack can support.")); -end BatteryManagementSystem; \ No newline at end of file +end BatteryManagementSystem; diff --git a/VirtualFCS/Control/EMS_FC.mo b/VirtualFCS/Control/EMS_FC.mo index 5d6bc40..dafff76 100644 --- a/VirtualFCS/Control/EMS_FC.mo +++ b/VirtualFCS/Control/EMS_FC.mo @@ -1,7 +1,7 @@ within VirtualFCS.Control; block EMS_FC - parameter Real ramp_up(unit = "1/s") = 20 "FC stack current ramp up rate"; + parameter Modelica.Units.SI.TimeAging ramp_up = 20 "FC stack current ramp up rate"; Modelica.Blocks.Math.Abs abs1 annotation( Placement(visible = true, transformation(origin = {70, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Blocks.Sources.Constant OFF(k = 0) annotation( diff --git a/VirtualFCS/Control/EnergyManagementSystem.mo b/VirtualFCS/Control/EnergyManagementSystem.mo index 985c07c..f441015 100644 --- a/VirtualFCS/Control/EnergyManagementSystem.mo +++ b/VirtualFCS/Control/EnergyManagementSystem.mo @@ -1,11 +1,13 @@ within VirtualFCS.Control; block EnergyManagementSystem "Implement algorithms to control the energy and power distribution in a hybrid system." - parameter Real I_nom_FC_stack(unit = "A") = 100 "FC stack nominal operating current"; - parameter Real ramp_up(unit = "1/s") = 20 "FC stack current ramp up rate"; + parameter Modelica.Units.SI.Current I_nom_FC_stack = 100 "FC stack nominal operating current"; + parameter Modelica.Units.SI.TimeAging ramp_up = 20 "FC stack current ramp up rate"; + parameter Real SOC_lower_limit(unit = "1") = 0.2 "SOC lower limit"; + parameter Real SOC_higher_limit(unit = "1") = 0.8 "SOC lower limit"; Modelica.Blocks.Sources.Constant shut_down(k = 0) annotation( Placement(visible = true, transformation(origin = {-70, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); - Modelica.Blocks.Logical.Hysteresis hysteresis(pre_y_start = true, uHigh = 0.8, uLow = 0.2) annotation( + Modelica.Blocks.Logical.Hysteresis hysteresis(pre_y_start = true, uHigh = SOC_higher_limit, uLow = SOC_lower_limit) annotation( Placement(visible = true, transformation(origin = {-70, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Blocks.Sources.Constant setFuelCellCurrent(k = -I_nom_FC_stack) annotation( Placement(visible = true, transformation(origin = {-70, -40}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); @@ -37,4 +39,4 @@ equation annotation( Icon(graphics = {Rectangle(fillColor = {50, 50, 50}, fillPattern = FillPattern.Solid, extent = {{-100, 100}, {100, -100}}), Text(origin = {-8, 121}, lineColor = {0, 0, 255}, extent = {{-54, 17}, {54, -17}}, textString = "%name")}, coordinateSystem(initialScale = 0.1)), Documentation(info = "
The EnergyManagementSystem component is designed to manage the flow of power between the fuel cell stack, battery, vehicle load, and balance-of-plant load. It splits the load according to pre-defined energy management rules, which are implemented within the bounds of the battery management system and the fuel cell control unit.

This model implements a simple energy management algorithm for a hybrid fuel cell & battery system. The model reads the state-of-charge (SOC) of the battery. If it is less than a lower threshold value, then a signal is sent to activate the fuel cell with a given electric current. The rate at which current can be demanded from the fuel cell is limited by a slew rate. ")); -end EnergyManagementSystem; \ No newline at end of file +end EnergyManagementSystem; diff --git a/VirtualFCS/Control/PumpSpeedControl.mo b/VirtualFCS/Control/PumpSpeedControl.mo index 8b5cf61..e8e5ecd 100644 --- a/VirtualFCS/Control/PumpSpeedControl.mo +++ b/VirtualFCS/Control/PumpSpeedControl.mo @@ -2,9 +2,7 @@ within VirtualFCS.Control; block PumpSpeedControl parameter Real k = 1 "Control Gain"; - parameter Real Td = 0.1 "Time Constant of Derivative Block"; - //parameter Real k = 1 "Control Gain"; - //parameter Real Td = 1 "Time Constant of Derivative Block"; + parameter Modelica.Units.SI.Time Td = 0.1 "Time Constant of Derivative Block"; Modelica.Blocks.Continuous.LimPID limPID(Td = Td, initType = Modelica.Blocks.Types.Init.InitialOutput, k = k, yMax = 1, yMin = 0) annotation( Placement(visible = true, transformation(origin = {-30, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Blocks.Interfaces.RealInput setMassFlow annotation( diff --git a/VirtualFCS/Control/PumpSpeedControlCooling.mo b/VirtualFCS/Control/PumpSpeedControlCooling.mo index d2cbe8a..025d8ba 100644 --- a/VirtualFCS/Control/PumpSpeedControlCooling.mo +++ b/VirtualFCS/Control/PumpSpeedControlCooling.mo @@ -2,8 +2,8 @@ within VirtualFCS.Control; block PumpSpeedControlCooling parameter Real k = 1 "Control Gain"; - parameter Real Td = 0.1 "Time Constant of Derivative Block"; - parameter Real Ti = 0.1 "Time Constant of Integral Block"; + parameter Modelica.Units.SI.Time Td = 0.1 "Time Constant of Derivative Block"; + parameter Modelica.Units.SI.Time Ti = 0.1 "Time Constant of Integral Block"; Modelica.Blocks.Interfaces.RealInput setMassFlow annotation( Placement(visible = true, transformation(origin = {-100, 40}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-110, 50}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Blocks.Interfaces.RealInput getMassFlow annotation( diff --git a/VirtualFCS/Control/VoltageLimiter.mo b/VirtualFCS/Control/VoltageLimiter.mo index 8893aae..fe65b8a 100644 --- a/VirtualFCS/Control/VoltageLimiter.mo +++ b/VirtualFCS/Control/VoltageLimiter.mo @@ -1,8 +1,8 @@ within VirtualFCS.Control; model VoltageLimiter "Enforce voltage limits on battery cells." - parameter Real upperVoltageLimit(unit = "V") = 3.6 "Upper Voltage Limit"; - parameter Real lowerVoltageLimit(unit = "V") = 2.0 "Lower Voltage Limit"; + parameter Modelica.Units.SI.Voltage upperVoltageLimit = 3.6 "Upper Voltage Limit"; + parameter Modelica.Units.SI.Voltage lowerVoltageLimit = 2.0 "Lower Voltage Limit"; Modelica.Electrical.Analog.Interfaces.PositivePin pin_p_battery annotation( Placement(visible = true, transformation(origin = {196, 0}, extent = {{10, -10}, {-10, 10}}, rotation = 0), iconTransformation(origin = {110, 190}, extent = {{10, -10}, {-10, 10}}, rotation = 0))); Modelica.Electrical.Analog.Interfaces.NegativePin pin_n_battery annotation( @@ -68,4 +68,4 @@ equation Icon(graphics = {Rectangle(origin = {-100, 100}, fillColor = {50, 50, 50}, fillPattern = FillPattern.Solid, extent = {{-100, 100}, {300, -300}}), Text(origin = {2, 137}, lineColor = {255, 255, 255}, extent = {{-74, 31}, {74, -31}}, textString = "Battery"), Text(origin = {-4, -101}, lineColor = {255, 255, 255}, extent = {{-74, 31}, {74, -31}}, textString = "Load"), Text(origin = {-7, 253}, lineColor = {0, 0, 255}, extent = {{-181, 45}, {181, -45}}, textString = "%name")}, coordinateSystem(extent = {{-200, -200}, {200, 200}}, initialScale = 0.1)), Diagram(coordinateSystem(extent = {{-200, -200}, {200, 200}})), Documentation(info = "The voltage limiter block enforces user-defined upper and lower voltage limits for battery cells and packs. ")); -end VoltageLimiter; \ No newline at end of file +end VoltageLimiter; diff --git a/VirtualFCS/Electrical/DCConverterSwitch.mo b/VirtualFCS/Electrical/DCConverterSwitch.mo index 48657bf..97ca314 100644 --- a/VirtualFCS/Electrical/DCConverterSwitch.mo +++ b/VirtualFCS/Electrical/DCConverterSwitch.mo @@ -101,4 +101,4 @@ The DC/DC converter is characterized by: where underlined voltages and currents represent complex phasors ")); -end DCConverterSwitch; \ No newline at end of file +end DCConverterSwitch; diff --git a/VirtualFCS/Electrochemical/Battery/BatterySystem.mo b/VirtualFCS/Electrochemical/Battery/BatterySystem.mo index a831ac4..dd5f5ff 100644 --- a/VirtualFCS/Electrochemical/Battery/BatterySystem.mo +++ b/VirtualFCS/Electrochemical/Battery/BatterySystem.mo @@ -1,22 +1,23 @@ within VirtualFCS.Electrochemical.Battery; model BatterySystem + import SI = Modelica.Units.SI; // System outer Modelica.Fluid.System system "System properties"; // Battery Pack Parameters - parameter Real m_bat_pack(unit = "kg") = 100 "Mass of the pack"; - parameter Real L_bat_pack(unit = "m") = 0.6 "Battery pack length"; - parameter Real W_bat_pack(unit = "m") = 0.45 "Battery pack width"; - parameter Real H_bat_pack(unit = "m") = 0.1 "Battery pack height"; - parameter Real Cp_bat_pack(unit = "J/(kg.K)") = 1000 "Specific Heat Capacity"; - parameter Real V_min_bat_pack(unit = "V") = 240 "Battery pack minimum voltage"; - parameter Real V_nom_bat_pack(unit = "V") = 336 "Battery pack nominal voltage"; - parameter Real V_max_bat_pack(unit = "V") = 403.2 "Battery pack maximum voltage"; - parameter Real C_bat_pack(unit = "A.h") = 200 "Battery pack nominal capacity"; + parameter SI.Mass m_bat_pack = 100 "Mass of the pack"; + parameter SI.Length L_bat_pack = 0.6 "Battery pack length"; + parameter SI.Breadth W_bat_pack = 0.45 "Battery pack width"; + parameter SI.Height H_bat_pack = 0.1 "Battery pack height"; + parameter SI.SpecificHeatCapacity Cp_bat_pack = 1000 "Specific Heat Capacity"; + parameter SI.Voltage V_min_bat_pack = 240 "Battery pack minimum voltage"; + parameter SI.Voltage V_nom_bat_pack = 336 "Battery pack nominal voltage"; + parameter SI.Voltage V_max_bat_pack = 403.2 "Battery pack maximum voltage"; + parameter Modelica.Units.NonSI.ElectricCharge_Ah C_bat_pack = 200 "Battery pack nominal capacity"; parameter Real SOC_init = 0.5 "Battery pack initial state of charge"; // Power & efficiencies - Real Power(unit = "W") "Battery delivered power"; - Real eta_batt(unit = "100") "Battery efficiency, calculated by assuming loss in terms of heat"; + SI.Power Power "Battery delivered power"; + SI.Efficiency eta_batt "Battery efficiency, calculated by assuming loss in terms of heat"; VirtualFCS.Control.BatteryManagementSystem batteryManagementSystem(N_s = batteryPack.N_s) annotation( Placement(visible = true, transformation(origin = {0, 30}, extent = {{-30, -20}, {30, 20}}, rotation = 0))); Modelica.Electrical.Analog.Interfaces.PositivePin pin_p annotation( @@ -35,7 +36,7 @@ model BatterySystem Placement(visible = true, transformation(origin = {0.369106, -30.5794}, extent = {{-24.8691, -14.9215}, {24.8691, 16.5794}}, rotation = 0))); equation Power = pin_n.i*pin_p.v; - eta_batt = max((abs(Power)-(batteryPack.heatSource.Q_flow))/(max(abs(Power), 0.00001)) * 100, 90); + eta_batt = max((abs(Power)-(batteryPack.heatSource.Q_flow))/(max(abs(Power), 0.00001)), 0.9); connect(pin_n, batteryManagementSystem.pin_n_load) annotation( Line(points = {{-44, 96}, {-44, 96}, {-44, 80}, {-10, 80}, {-10, 48}, {-10, 48}}, color = {0, 0, 255})); connect(pin_p, batteryManagementSystem.pin_p_load) annotation( diff --git a/VirtualFCS/Electrochemical/Battery/LiIonBatteryPack_Composite.mo b/VirtualFCS/Electrochemical/Battery/LiIonBatteryPack_Composite.mo index 2bbdb10..c340612 100644 --- a/VirtualFCS/Electrochemical/Battery/LiIonBatteryPack_Composite.mo +++ b/VirtualFCS/Electrochemical/Battery/LiIonBatteryPack_Composite.mo @@ -6,9 +6,9 @@ model LiIonBatteryPack_Composite "A Li-ion battery pack comprised of individual parameter Real SOC_init(unit = "1") = 0.5 "Initial State of Charge"; parameter Integer p = 5 "Number of Cells in Parallel"; parameter Integer s = 10 "Number of Cells in Series"; - parameter Real coolingArea = p * s * liIonCell[1].coolingArea "Cooling Area"; - parameter Real heatTransferCoefficient(unit = "W/(m2.K)") = 7.8 * 10 ^ 0.78; - Real chargeCapacity; + parameter Modelica.Units.SI.Area coolingArea = p * s * liIonCell[1].coolingArea "Cooling Area"; + parameter Modelica.Units.SI.CoefficientOfHeatTransfer heatTransferCoefficient = 7.8 * 10 ^ 0.78 "HeatTransferCoefficient (W/(m2.K))"; + Modelica.Units.NonSI.ElectricCharge_Ah chargeCapacity; VirtualFCS.Electrochemical.Battery.LiIonCell liIonCell[s * p](each SOC_init = SOC_init) annotation( Placement(visible = true, transformation(origin = {0, 50.3333}, extent = {{-37, -24.6667}, {37, 24.6667}}, rotation = 0))); Modelica.Electrical.Analog.Interfaces.PositivePin pin_p annotation( @@ -95,4 +95,4 @@ This class automatically generates instances of the LiIonCell model based on the
Convective Heat Transfer
Qconv = hAcool(T  T0)

Radiative Heat Transfer
Qrad = 0.95Acoolσ(T4  (T0)4)
")); -end LiIonBatteryPack_Composite; \ No newline at end of file +end LiIonBatteryPack_Composite; diff --git a/VirtualFCS/Electrochemical/Battery/LiIonBatteryPack_Lumped.mo b/VirtualFCS/Electrochemical/Battery/LiIonBatteryPack_Lumped.mo index 3566668..343ff97 100644 --- a/VirtualFCS/Electrochemical/Battery/LiIonBatteryPack_Lumped.mo +++ b/VirtualFCS/Electrochemical/Battery/LiIonBatteryPack_Lumped.mo @@ -1,25 +1,26 @@ within VirtualFCS.Electrochemical.Battery; model LiIonBatteryPack_Lumped "A Li-ion battery pack model comprising a single lumped battery model." + import SI = Modelica.Units.SI; // DECLARE PARAMETERS // // Pack-level parameters - parameter Real m_bat_pack(unit = "kg") = 100 "Mass of the pack"; - parameter Real L_bat_pack(unit = "m") = 0.6 "Battery pack length"; - parameter Real W_bat_pack(unit = "m") = 0.45 "Battery pack width"; - parameter Real H_bat_pack(unit = "m") = 0.1 "Battery pack height"; - parameter Real Cp_bat_pack(unit = "J/(kg.K)") = 1000 "Specific Heat Capacity"; - parameter Real V_min_bat_pack(unit = "V") = 37.5 "Battery pack minimum voltage"; - parameter Real V_nom_bat_pack(unit = "V") = 48 "Battery pack nominal voltage"; - parameter Real V_max_bat_pack(unit = "V") = 54.75 "Battery pack maximum voltage"; - parameter Real C_bat_pack(unit = "A.h") = 200 "Battery pack nominal capacity"; + parameter SI.Mass m_bat_pack = 100 "Mass of the pack"; + parameter SI.Length L_bat_pack = 0.6 "Battery pack length"; + parameter SI.Breadth W_bat_pack = 0.45 "Battery pack width"; + parameter SI.Height H_bat_pack = 0.1 "Battery pack height"; + parameter SI.SpecificHeatCapacity Cp_bat_pack = 1000 "Specific Heat Capacity"; + parameter SI.Voltage V_min_bat_pack = 37.5 "Battery pack minimum voltage"; + parameter SI.Voltage V_nom_bat_pack = 48 "Battery pack nominal voltage"; + parameter SI.Voltage V_max_bat_pack = 54.75 "Battery pack maximum voltage"; + parameter Modelica.Units.NonSI.ElectricCharge_Ah C_bat_pack = 200 "Battery pack nominal capacity"; parameter Real SOC_init = 0.5 "Battery pack initial state of charge"; - parameter Real heatTransferCoefficient(unit = "W/(m2.K)") = 7.8 * 10 ^ 0.78; + parameter SI.CoefficientOfHeatTransfer heatTransferCoefficient = 7.8 * 10 ^ 0.78 "HeatTransferCoefficient (W/(m2.K))"; parameter Real N_s = ceil(V_max_bat_pack / V_chem_max); - Real vol_bat_pack = L_bat_pack * W_bat_pack * H_bat_pack; + SI.Volume vol_bat_pack = L_bat_pack * W_bat_pack * H_bat_pack; // ADD dropdown menu for selecting chemistry type // Coefficients for open-circuit voltage calculation // LFP - parameter Real V_chem_max = 3.65; + parameter Modelica.Units.SI.Voltage V_chem_max = 3.65; Real a1 = 3.25; Real b1 = -1e-4; Real c1 = -0.08; @@ -70,12 +71,12 @@ model LiIonBatteryPack_Lumped "A Li-ion battery pack model comprising a single l Modelica.Thermal.HeatTransfer.Components.BodyRadiation bodyRadiation(Gr = 0.95 * A_cool_bat_pack) annotation( Placement(visible = true, transformation(origin = {-90, -50}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); protected - parameter Real R_O(unit = "Ohm") = 0.02 "Ohmic Resistance"; - parameter Real R1_0(unit = "Ohm") = 0.01 "First RC Resistance"; - parameter Real R2_0(unit = "Ohm") = 0.005 "Second RC Resistance"; - parameter Real C1_0(unit = "F") = 5000 "First RC Capacitance"; - parameter Real C2_0(unit = "F") = 20000 "Second RC Capacitance"; - parameter Real A_cool_bat_pack = L_bat_pack * W_bat_pack; + parameter SI.Resistance R_O = 0.02 "Ohmic Resistance"; + parameter SI.Resistance R1_0 = 0.01 "First RC Resistance"; + parameter SI.Resistance R2_0 = 0.005 "Second RC Resistance"; + parameter SI.Capacitance C1_0 = 5000 "First RC Capacitance"; + parameter SI.Capacitance C2_0 = 20000 "Second RC Capacitance"; + parameter SI.Area A_cool_bat_pack = L_bat_pack * W_bat_pack; equation // ***DEFINE EQUATIONS ***// // Calculate the open-circuit voltage at given temperature and state of charge diff --git a/VirtualFCS/Electrochemical/Battery/LiIonCell.mo b/VirtualFCS/Electrochemical/Battery/LiIonCell.mo index 2762519..45be867 100644 --- a/VirtualFCS/Electrochemical/Battery/LiIonCell.mo +++ b/VirtualFCS/Electrochemical/Battery/LiIonCell.mo @@ -1,20 +1,20 @@ within VirtualFCS.Electrochemical.Battery; model LiIonCell "An equivalent circuit model for a Li-ion battery cell." + import SI = Modelica.Units.SI; // DECLARE PARAMETERS // // Physical parameters - parameter Real mass(unit = "kg") = 0.045 "Mass of the pack"; - parameter Real coolingArea(unit = "m2") = 0.003675 "Surface area for cooling"; - // parameter Real vol(unit = "L") = 0.016 "Volume of the pack"; - parameter Real specificHeatCapacity(unit = "J/(kg.K)") = 1000 "Specific Heat Capacity"; + parameter SI.Mass mass = 0.045 "Mass of the cell"; + parameter SI.Area coolingArea = 0.003675 "Surface area for cooling"; + parameter SI.SpecificHeatCapacity specificHeatCapacity = 1000 "Specific Heat Capacity"; // Pack design parameters parameter Real SOC_init(unit = "1") = 0.5 "Initial State of Charge"; - parameter Real chargeCapacity(unit = "Ah") = 2.2 "Battery Cell Capacity"; - parameter Real R_O(unit = "Ohm") = 0.02 "Ohmic Resistance"; - parameter Real R1_0(unit = "Ohm") = 0.01 "First RC Resistance"; - parameter Real R2_0(unit = "Ohm") = 0.005 "Second RC Resistance"; - parameter Real C1_0(unit = "F") = 5000 "First RC Capacitance"; - parameter Real C2_0(unit = "F") = 20000 "Second RC Capacitance"; + parameter Modelica.Units.NonSI.ElectricCharge_Ah chargeCapacity = 2.2 "Battery Cell Capacity"; + parameter SI.Resistance R_O = 0.02 "Ohmic Resistance"; + parameter SI.Resistance R1_0 = 0.01 "First RC Resistance"; + parameter SI.Resistance R2_0 = 0.005 "Second RC Resistance"; + parameter SI.Capacitance C1_0 = 5000 "First RC Capacitance"; + parameter SI.Capacitance C2_0 = 20000 "Second RC Capacitance"; // DECLARE VARIABLES // // Coefficients for open-circuit voltage calculation // LFP diff --git a/VirtualFCS/Electrochemical/Hydrogen/FuelCell.mo b/VirtualFCS/Electrochemical/Hydrogen/FuelCell.mo index 37750f8..beec058 100644 --- a/VirtualFCS/Electrochemical/Hydrogen/FuelCell.mo +++ b/VirtualFCS/Electrochemical/Hydrogen/FuelCell.mo @@ -1,6 +1,7 @@ within VirtualFCS.Electrochemical.Hydrogen; model FuelCell "Model for a single PEM fuel cell" + import SI = Modelica.Units.SI; //*** DEFINE REPLACEABLE PACKAGES ***// // Medium models replaceable package Cathode_Medium = Modelica.Media.Air.MoistAir; @@ -8,33 +9,33 @@ model FuelCell "Model for a single PEM fuel cell" replaceable package Coolant_Medium = Modelica.Media.Water.ConstantPropertyLiquidWater; //*** DECLARE PARAMETERS ***// // Physical parameters - parameter Real mass(unit = "kg") = 1 "Mass of the cell"; - parameter Real volume(unit = "m3") = 0.001 "Volume of the cell"; + parameter SI.Mass mass = 1 "Mass of the cell"; + parameter SI.Volume volume = 0.001 "Volume of the cell"; // Thermal parameters - parameter Real heatCapacity(unit = "J/(kg.K)") = 800 "Specific Heat Capacity"; + parameter SI.SpecificHeatCapacity heatCapacity = 800 "Specific Heat Capacity"; // Stack design parameters parameter Real N_cell(unit = "1") = 1 "Number of Cells"; - parameter Real A_cell(unit = "m2") = 0.0237 "Active Area of the Cell"; + parameter SI.Area A_cell = 0.0237 "Active Area of the Cell"; // Electrochemical parameters - parameter Real i_0(unit = "A") = 0.0002 "Exchange Current"; - parameter Real i_L(unit = "A") = 520 "Maximum Current Limit"; - parameter Real i_x(unit = "A") = 0.001 "Cross-over Current"; + parameter SI.Current i_0 = 0.0002 "Exchange Current"; + parameter SI.Current i_L = 520 "Maximum Current Limit"; + parameter SI.Current i_x = 0.001 "Cross-over Current"; parameter Real b_1(unit = "V/dec") = 0.025 "Tafel Slope"; parameter Real b_2(unit = "V/dec") = 0.25 "Transport Limitation Factor"; - parameter Real R_0(unit = "Ohm") = 0.02 "Ohmic Resistance"; - parameter Real R_1(unit = "Ohm") = 0.01 "Charge Transfer Resistance"; - parameter Real C_1(unit = "F") = 3e-3 "Double Layer Capacitance"; + parameter SI.Resistance R_0 = 0.02 "Ohmic Resistance"; + parameter SI.Resistance R_1 = 0.01 "Charge Transfer Resistance"; + parameter SI.Capacitance C_1 = 3e-3 "Double Layer Capacitance"; //*** DECLARE VARIABLES ***// // Physical constants - Real R = 8.314; - Real F = 96485; + import R = Modelica.Constants.R; + import F = Modelica.Constants.F; // Fuel cell variables - Real V_cell; - Real j; - Real P_th; - Real p_H2(min = 0); - Real p_O2(min = 0); - Real p_0 = 100000; + SI.Voltage V_cell; + SI.CurrentDensity j; + SI.Power P_th; + SI.Pressure p_H2(min = 0); + SI.Pressure p_O2(min = 0); + SI.Pressure p_0 = 100000; //*** INSTANTIATE COMPONENTS ***// //System inner Modelica.Fluid.System system(energyDynamics = Modelica.Fluid.Types.Dynamics.FixedInitial) annotation( diff --git a/VirtualFCS/Electrochemical/Hydrogen/FuelCellStack.mo b/VirtualFCS/Electrochemical/Hydrogen/FuelCellStack.mo index cf75250..baf9008 100644 --- a/VirtualFCS/Electrochemical/Hydrogen/FuelCellStack.mo +++ b/VirtualFCS/Electrochemical/Hydrogen/FuelCellStack.mo @@ -1,6 +1,7 @@ within VirtualFCS.Electrochemical.Hydrogen; model FuelCellStack + import SI = Modelica.Units.SI; //*** DEFINE REPLACEABLE PACKAGES ***// // System outer Modelica.Fluid.System system "System properties"; @@ -11,36 +12,36 @@ model FuelCellStack //*** DECLARE PARAMETERS ***// // Physical parameters // Fuel Cell Stack Paramters - parameter Real m_FC_stack(unit = "kg") = 42 "FC stack mass"; - parameter Real L_FC_stack(unit = "m") = 0.420 "FC stack length"; - parameter Real W_FC_stack(unit = "m") = 0.582 "FC stack width"; - parameter Real H_FC_stack(unit = "m") = 0.156 "FC stack height"; - parameter Real vol_FC_stack(unit = "m3") = L_FC_stack*W_FC_stack*H_FC_stack "FC stack volume"; - parameter Real I_rated_FC_stack(unit = "A") = 450 "FC stack rated current"; - parameter Real i_L_FC_stack(unit = "A") = 760 "FC stack cell maximum limiting current"; + parameter SI.Mass m_FC_stack = 42 "FC stack mass"; + parameter SI.Length L_FC_stack = 0.420 "FC stack length"; + parameter SI.Breadth W_FC_stack = 0.582 "FC stack width"; + parameter SI.Height H_FC_stack = 0.156 "FC stack height"; + parameter SI.Volume vol_FC_stack = L_FC_stack*W_FC_stack*H_FC_stack "FC stack volume"; + parameter SI.Current I_rated_FC_stack = 450 "FC stack rated current"; + parameter SI.Current i_L_FC_stack = 760 "FC stack cell maximum limiting current"; parameter Real N_FC_stack(unit = "1") = 455 "FC stack number of cells"; - parameter Real A_FC_surf(unit = "m2") = 2*(L_FC_stack*W_FC_stack) + 2*(L_FC_stack*H_FC_stack) + 2*(W_FC_stack*H_FC_stack) "FC stack surface area"; + parameter SI.Area A_FC_surf = 2*(L_FC_stack*W_FC_stack) + 2*(L_FC_stack*H_FC_stack) + 2*(W_FC_stack*H_FC_stack) "FC stack surface area"; // Electrochemical parameters - parameter Real i_0_FC_stack(unit = "A") = 0.0091 "FC stack cell exchange current"; - parameter Real i_x_FC_stack(unit = "A") = 0.001 "FC stack cell cross-over current"; + parameter SI.Current i_0_FC_stack = 0.0091 "FC stack cell exchange current"; + parameter SI.Current i_x_FC_stack = 0.001 "FC stack cell cross-over current"; parameter Real b_1_FC_stack(unit = "V/dec") = 0.0985 "FC stack cell Tafel slope"; parameter Real b_2_FC_stack(unit = "V/dec") = 0.0985 "FC stack cell trasport limitation factor"; - parameter Real R_O_FC_stack(unit = "Ohm") = 0.00022*N_FC_stack "FC stack cell ohmic resistance"; + parameter SI.Resistance R_O_FC_stack = 0.00022*N_FC_stack "FC stack cell ohmic resistance"; // Thermal parameters - parameter Real Cp_FC_stack(unit = "J/(kg.K)") = 110.0 "FC stack specific heat capacity"; + parameter SI.SpecificHeatCapacity Cp_FC_stack = 110.0 "FC stack specific heat capacity"; //*** DECLARE VARIABLES ***// // Physical constants - Real R = 8.314; - Real F = 96485; + import R = Modelica.Constants.R; + import F = Modelica.Constants.F; // Fuel cell variables - Real V_cell; - Real P_th; - Real p_H2(min = 0); - Real p_O2(min = 0); - Real p_0 = 100000; + SI.Voltage V_cell; + SI.Power P_th; + SI.Pressure p_H2(min = 0); + SI.Pressure p_O2(min = 0); + SI.Pressure p_0 = 100000; //*** INSTANTIATE COMPONENTS ***// // Efficiencies - Real eta_FC_LHV(unit = "100") "Lower heating value efficiency of fuel cell stack"; + SI.Efficiency eta_FC_LHV "Lower heating value efficiency of fuel cell stack"; // Electrical Components // Fluid Components Modelica.Fluid.Fittings.TeeJunctionIdeal qH2(redeclare package Medium = Anode_Medium) annotation( @@ -108,7 +109,7 @@ equation // Assign the thermal power value to the heat flow component prescribedHeatFlow.Q_flow = P_th; // Efficiencies - eta_FC_LHV = (V_cell / 1.254) * 100; + eta_FC_LHV = V_cell / 1.254; //*** DEFINE CONNECTIONS ***// connect(pipeCoolant.port_b, port_b_Coolant) annotation( Line(points = {{10, -40}, {130, -40}}, color = {255, 0, 0}, thickness = 1)); diff --git a/VirtualFCS/Electrochemical/Hydrogen/FuelCellSystem.mo b/VirtualFCS/Electrochemical/Hydrogen/FuelCellSystem.mo index 4494dec..89a52b6 100644 --- a/VirtualFCS/Electrochemical/Hydrogen/FuelCellSystem.mo +++ b/VirtualFCS/Electrochemical/Hydrogen/FuelCellSystem.mo @@ -1,35 +1,36 @@ within VirtualFCS.Electrochemical.Hydrogen; model FuelCellSystem + import SI = Modelica.Units.SI; // System outer Modelica.Fluid.System system "System properties"; - parameter Real m_FC_system(unit = "kg") = fuelCellStack.m_FC_stack + fuelCellSubSystems.m_FC_subsystems; + parameter SI.Mass m_FC_system = fuelCellStack.m_FC_stack + fuelCellSubSystems.m_FC_subsystems; // Fuel Cell Stack Paramters - parameter Real m_FC_stack(unit = "kg") = 42 "FC stack mass"; - parameter Real L_FC_stack(unit = "m") = 0.420 "FC stack length"; - parameter Real W_FC_stack(unit = "m") = 0.582 "FC stack width"; - parameter Real H_FC_stack(unit = "m") = 0.156 "FC stack height"; - parameter Real vol_FC_stack(unit = "m3") = L_FC_stack * W_FC_stack * H_FC_stack "FC stack volume"; + parameter SI.Mass m_FC_stack = 42 "FC stack mass"; + parameter SI.Length L_FC_stack = 0.420 "FC stack length"; + parameter SI.Breadth W_FC_stack = 0.582 "FC stack width"; + parameter SI.Height H_FC_stack = 0.156 "FC stack height"; + parameter SI.Volume vol_FC_stack = L_FC_stack * W_FC_stack * H_FC_stack "FC stack volume"; // parameter Real V_rated_FC_stack(unit="V") = 57.9 "Maximum stack operating voltage"; - parameter Real I_rated_FC_stack(unit = "A") = 450 "FC stack rated current"; - parameter Real i_L_FC_stack(unit = "A") = 760 "FC stack cell maximum limiting current"; + parameter SI.Current I_nom_FC_stack = 300 "FC stack nominal current"; + parameter SI.Current I_rated_FC_stack = 1.7 * I_nom_FC_stack "FC stack maximum operating current"; parameter Real N_FC_stack(unit = "1") = 455 "FC stack number of cells"; // H2 Subsystem Paramters - parameter Real V_tank_H2(unit = "m3") = 0.13 "H2 tank volume"; - parameter Real p_tank_H2(unit = "Pa") = 35000000 "H2 tank initial pressure"; - parameter Real heatTransferCoefficient(unit = "W/(m2.K)") = 12; + parameter SI.Volume V_tank_H2 = 0.13 "H2 tank volume"; + parameter SI.Pressure p_tank_H2 = 35000000 "H2 tank initial pressure"; + parameter SI.CoefficientOfHeatTransfer heatTransferCoefficient = 12 "HeatTransferCoefficient (W/(m2.K))"; // Power and efficiency calculations - Real Power_system(unit = "W") "Power delivered from the FC system (Stack - BOP)"; - Real Power_stack(unit = "W") "Power delivered from the FC stack"; - Real Power_BOP(unit = "W") "Power consumed by the BOP components"; - Real eta_FC_sys(unit = "100") "Fuel cell system efficiency"; - VirtualFCS.Electrochemical.Hydrogen.FuelCellStack fuelCellStack(H_FC_stack = H_FC_stack, I_rated_FC_stack = I_rated_FC_stack, L_FC_stack = L_FC_stack, W_FC_stack = W_FC_stack, m_FC_stack = m_FC_stack, vol_FC_stack = vol_FC_stack) annotation( + SI.Power Power_system "Power delivered from the FC system (Stack - BOP)"; + SI.Power Power_stack "Power delivered from the FC stack"; + SI.Power Power_BOP "Power consumed by the BOP components"; + SI.Efficiency eta_FC_sys "Fuel cell system efficiency"; + VirtualFCS.Electrochemical.Hydrogen.FuelCellStack fuelCellStack(H_FC_stack = H_FC_stack, I_rated_FC_stack = I_nom_FC_stack, L_FC_stack = L_FC_stack, N_FC_stack = N_FC_stack, W_FC_stack = W_FC_stack, i_L_FC_stack = I_rated_FC_stack, m_FC_stack = m_FC_stack, vol_FC_stack = vol_FC_stack) annotation( Placement(visible = true, transformation(origin = {-1, 10}, extent = {{-26, -26}, {26, 26}}, rotation = 0))); Modelica.Electrical.Analog.Interfaces.PositivePin pin_p annotation( Placement(visible = true, transformation(origin = {20, 96}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {50, 90}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Electrical.Analog.Interfaces.NegativePin pin_n annotation( Placement(visible = true, transformation(origin = {-40, 96}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-50, 90}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); - VirtualFCS.SubSystems.FuelCellSubSystems fuelCellSubSystems(V_tank_H2 = V_tank_H2, p_tank_H2 = p_tank_H2) annotation( + VirtualFCS.SubSystems.FuelCellSubSystems fuelCellSubSystems(N_FC_stack = N_FC_stack,V_tank_H2 = V_tank_H2, p_tank_H2 = p_tank_H2) annotation( Placement(visible = true, transformation(origin = {-1, -60}, extent = {{-25, -25}, {25, 25}}, rotation = 0))); Modelica.Blocks.Routing.Multiplex2 multiplex2 annotation( Placement(visible = true, transformation(origin = {-54, -60}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); @@ -45,13 +46,13 @@ model FuelCellSystem Placement(visible = true, transformation(origin = {52, 42}, extent = {{10, -10}, {-10, 10}}, rotation = -90))); Modelica.Thermal.HeatTransfer.Sources.FixedTemperature fixedTemperature(T = 293.15) annotation( Placement(visible = true, transformation(origin = {70, 86}, extent = {{10, -10}, {-10, 10}}, rotation = 90))); - Modelica.Blocks.Nonlinear.Limiter limiter(uMax = i_L_FC_stack, uMin = 0) annotation( + Modelica.Blocks.Nonlinear.Limiter limiter(uMax = I_rated_FC_stack, uMin = 0) annotation( Placement(visible = true, transformation(origin = {-80, 0}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); equation Power_stack = fuelCellStack.pin_n.i * fuelCellStack.pin_p.v; Power_BOP = fuelCellSubSystems.batterySystem.pin_n.i * fuelCellSubSystems.batterySystem.pin_p.v; Power_system = Power_stack - Power_BOP; - eta_FC_sys = max((Power_system) / (286000 * (N_FC_stack * (fuelCellStack.pin_n.i + 0.000001) / (2 * 96485.3321))), 0.00001) * 100; + eta_FC_sys = max((Power_system) / (286000 * (N_FC_stack * (fuelCellStack.pin_n.i + 0.000001) / (2 * 96485.3321))), 0.001); connect(pin_p, fuelCellStack.pin_p) annotation( Line(points = {{20, 96}, {20, 36}, {9, 36}}, color = {0, 0, 255})); connect(fuelCellStack.port_b_Air, fuelCellSubSystems.air_port_a) annotation( diff --git a/VirtualFCS/Examples/ElectrochemicalComponents/PolarizeFuelCellStack.mo b/VirtualFCS/Examples/ElectrochemicalComponents/PolarizeFuelCellStack.mo index 563f975..2512564 100644 --- a/VirtualFCS/Examples/ElectrochemicalComponents/PolarizeFuelCellStack.mo +++ b/VirtualFCS/Examples/ElectrochemicalComponents/PolarizeFuelCellStack.mo @@ -9,7 +9,7 @@ model PolarizeFuelCellStack "Generate a polarization curve for a fuel cell stack Placement(visible = true, transformation(origin = {-90, -90}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Electrical.Analog.Sources.RampCurrent rampCurrent(I = 750, duration = 500, startTime = 100) annotation( Placement(visible = true, transformation(origin = {0, 60}, extent = {{10, -10}, {-10, 10}}, rotation = 0))); - VirtualFCS.Electrochemical.Hydrogen.FuelCellSystem fuelCellSystem annotation( + VirtualFCS.Electrochemical.Hydrogen.FuelCellSystem fuelCellSystem(I_nom_FC_stack = 450) annotation( Placement(visible = true, transformation(origin = {0, -2}, extent = {{-22, -22}, {22, 22}}, rotation = 0))); equation connect(rampCurrent.n, fuelCellSystem.pin_n) annotation( diff --git a/VirtualFCS/Examples/SubsystemExamples/TestHydrogenSubsystem.mo b/VirtualFCS/Examples/SubsystemExamples/TestHydrogenSubsystem.mo index a3206a9..51b5b6f 100644 --- a/VirtualFCS/Examples/SubsystemExamples/TestHydrogenSubsystem.mo +++ b/VirtualFCS/Examples/SubsystemExamples/TestHydrogenSubsystem.mo @@ -1,40 +1,45 @@ within VirtualFCS.Examples.SubsystemExamples; - model TestHydrogenSubsystem "Example to evaluate the performance of the hydrogen subsystem." extends Modelica.Icons.Example; - inner Modelica.Fluid.System system annotation( + inner Modelica.Fluid.System system annotation ( Placement(visible = true, transformation(origin = {-90, -90}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); replaceable package Anode_Medium = Modelica.Media.IdealGases.SingleGases.H2(Temperature(start = system.T_start), AbsolutePressure(start = system.p_start)); - Modelica.Blocks.Math.Gain gain(k = -0.00202 * 1 / (96485 * 2)) annotation( + Modelica.Blocks.Math.Gain gain(k = -0.00202 * 1 / (96485 * 2)) annotation ( Placement(visible = true, transformation(origin = {-34, 80}, extent = {{-8, -8}, {8, 8}}, rotation = 0))); - SubSystems.Hydrogen.SubSystemHydrogen subSystemHydrogen annotation( + SubSystems.Hydrogen.SubSystemHydrogen subSystemHydrogen annotation ( Placement(visible = true, transformation(origin = {-0.999964, -0.666637}, extent = {{-30, -20}, {30, 20}}, rotation = 0))); - Modelica.Fluid.Sources.MassFlowSource_T boundary(redeclare package Medium = Anode_Medium, nPorts = 1, use_m_flow_in = true) annotation( + Modelica.Fluid.Sources.MassFlowSource_T boundary(redeclare package Medium = + Anode_Medium, nPorts = 1, use_m_flow_in = true) annotation ( Placement(visible = true, transformation(origin = {0, 70}, extent = {{10, -10}, {-10, 10}}, rotation = 90))); - Modelica.Fluid.Fittings.TeeJunctionIdeal teeJunctionIdeal(redeclare package Medium = Anode_Medium) annotation( + Modelica.Fluid.Fittings.TeeJunctionIdeal teeJunctionIdeal(redeclare package Medium = + Anode_Medium) annotation ( Placement(visible = true, transformation(origin = {0, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); - VirtualFCS.Electrochemical.Battery.BatterySystem batterySystem(SOC_init = 0.9, V_max_bat_pack = 27, V_min_bat_pack = 23, V_nom_bat_pack = 25, m_bat_pack = 1) annotation( + VirtualFCS.Electrochemical.Battery.BatterySystem batterySystem(SOC_init = 0.9, V_max_bat_pack = 27, V_min_bat_pack = 23, V_nom_bat_pack = 25, m_bat_pack = 1) annotation ( Placement(visible = true, transformation(origin = {1.9984e-15, -60}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); - Modelica.Blocks.Sources.Trapezoid trapezoid(amplitude = 750, falling = 50, period = 500, rising = 50, startTime = 100, width = 200) annotation( + Modelica.Blocks.Sources.Trapezoid trapezoid(amplitude = 750, falling = 50, period = 500, rising = 50, startTime = 100, width = 200) annotation ( Placement(visible = true, transformation(origin = {-76, 80}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); equation - connect(gain.y, boundary.m_flow_in) annotation( - Line(points = {{-26, 80}, {-18, 80}, {-18, 92}, {-8, 92}, {-8, 80}}, color = {0, 0, 127})); - connect(subSystemHydrogen.port_H2ToStack, teeJunctionIdeal.port_1) annotation( - Line(points = {{-12, 24}, {-12, 40}, {-10, 40}}, color = {0, 170, 0}, thickness = 1)); - connect(subSystemHydrogen.port_StackToH2, teeJunctionIdeal.port_2) annotation( - Line(points = {{10, 24}, {12, 24}, {12, 40}, {10, 40}}, color = {0, 170, 0}, thickness = 1)); - connect(boundary.ports[1], teeJunctionIdeal.port_3) annotation( + connect(gain.y, boundary.m_flow_in) annotation ( + Line(points={{-25.2,80},{-18,80},{-18,92},{-8,92},{-8,80}}, color = {0, 0, 127})); + connect(subSystemHydrogen.port_H2ToStack, teeJunctionIdeal.port_1) annotation ( + Line(points={{-11.8,23.1334},{-11.8,40},{-10,40}}, + color = {0, 170, 0}, thickness = 1)); + connect(subSystemHydrogen.port_StackToH2, teeJunctionIdeal.port_2) annotation ( + Line(points={{9.80004,23.1334},{12,23.1334},{12,40},{10,40}}, + color = {0, 170, 0}, thickness = 1)); + connect(boundary.ports[1], teeJunctionIdeal.port_3) annotation ( Line(points = {{0, 60}, {0, 50}}, color = {0, 170, 0}, thickness = 1)); - connect(batterySystem.pin_p, subSystemHydrogen.pin_p) annotation( - Line(points = {{8, -40}, {10, -40}, {10, -18}}, color = {0, 0, 255})); - connect(batterySystem.pin_n, subSystemHydrogen.pin_n) annotation( - Line(points = {{-8, -40}, {-6, -40}, {-6, -18}}, color = {0, 0, 255})); - connect(trapezoid.y, gain.u) annotation( - Line(points = {{-64, 80}, {-44, 80}}, color = {0, 0, 127})); - connect(trapezoid.y, subSystemHydrogen.control) annotation( - Line(points = {{-64, 80}, {-56, 80}, {-56, 12}, {-22, 12}}, color = {0, 0, 127})); - annotation( + connect(batterySystem.pin_p, subSystemHydrogen.pin_p) annotation ( + Line(points={{8.8,-40.8},{9.00004,-40.8},{9.00004,-18.6666}}, + color = {0, 0, 255})); + connect(batterySystem.pin_n, subSystemHydrogen.pin_n) annotation ( + Line(points={{-8.8,-40.8},{-6.99996,-40.8},{-6.99996,-18.6666}}, + color = {0, 0, 255})); + connect(trapezoid.y, gain.u) annotation ( + Line(points={{-65,80},{-43.6,80}}, color = {0, 0, 127})); + connect(trapezoid.y, subSystemHydrogen.control) annotation ( + Line(points={{-65,80},{-56,80},{-56,11.3334},{-23,11.3334}},color = {0, 0, 127})); + annotation ( Diagram, Icon, Documentation(info = "This example is intended as a means to evaluate the performance of the hydrogen subsystem both for optimization and troubleshooting purposes.


Description

The model has three parts (1) input (includes fuel cell current and its conversion to hydrogen mass flow rate), (2) hydrogen subsystem (includes hydrogen tank, pressure regulator, recirculation blower, purge valve and control system), and (3) power supply (battery system). 


References to base model/related packages

 Subsystem Hydrogen ControlRecirculation BlowerPressure RegulatorPurge Valve and Battery System

 


@@ -673,28 +678,28 @@ equation diff --git a/VirtualFCS/Examples/VehicleExamples/BatteryElectricVehicle.mo b/VirtualFCS/Examples/VehicleExamples/BatteryElectricVehicle.mo index 021e55e..474d458 100644 --- a/VirtualFCS/Examples/VehicleExamples/BatteryElectricVehicle.mo +++ b/VirtualFCS/Examples/VehicleExamples/BatteryElectricVehicle.mo @@ -10,17 +10,17 @@ model BatteryElectricVehicle Placement(visible = true, transformation(origin = {60, -3.55271e-15}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); Vehicles.VehicleProfile vehicleProfile(VN = VirtualFCS.Vehicles.VehicleProfile.vehicle_name.Mirai) annotation( Placement(visible = true, transformation(origin = {4.44089e-16, -7.54952e-15}, extent = {{-21, -21}, {21, 21}}, rotation = 0))); - Real eta_vehicle(unit = "100") "Vehicle efficiency"; + Modelica.Units.SI.Efficiency eta_vehicle "Vehicle efficiency"; equation if vehicleProfile.useRegenerativeBreaking then if vehicleProfile.P > 0 then - eta_vehicle = max(((vehicleProfile.P) / max((vehicleProfile.P + (batteryPowerTrain.Power_del_DC_DC * (1 - (batteryPowerTrain.eta_drivetrain * 0.01))) + (vehicleProfile.F_drag * vehicleProfile.v) + (vehicleProfile.F_accel * vehicleProfile.v) + (vehicleProfile.F_roll * vehicleProfile.v) + (vehicleProfile.P * (1 - vehicleProfile.eff_drivetrain))), 0.00001)) * 100, 0); + eta_vehicle = max(((vehicleProfile.P) / max((vehicleProfile.P + (batteryPowerTrain.Power_del_DC_DC * (1 - (batteryPowerTrain.eta_drivetrain))) + (vehicleProfile.F_drag * vehicleProfile.v) + (vehicleProfile.F_accel * vehicleProfile.v) + (vehicleProfile.F_roll * vehicleProfile.v) + (vehicleProfile.P * (1 - vehicleProfile.eff_drivetrain))), 0.00001)), 0); else - eta_vehicle = max(((abs(vehicleProfile.P)) / max(abs(vehicleProfile.P) + (abs(batteryPowerTrain.Power_del_DC_DC) * (1 - (batteryPowerTrain.eta_drivetrain * 0.01))) + (vehicleProfile.F_drag * vehicleProfile.v) + (abs(vehicleProfile.F_accel) * vehicleProfile.v) + (vehicleProfile.F_roll * vehicleProfile.v) + (abs(vehicleProfile.P) * (1 - vehicleProfile.eff_brake)), 0.00001)) * 100, 0); + eta_vehicle = max(((abs(vehicleProfile.P)) / max(abs(vehicleProfile.P) + (abs(batteryPowerTrain.Power_del_DC_DC) * (1 - (batteryPowerTrain.eta_drivetrain))) + (vehicleProfile.F_drag * vehicleProfile.v) + (abs(vehicleProfile.F_accel) * vehicleProfile.v) + (vehicleProfile.F_roll * vehicleProfile.v) + (abs(vehicleProfile.P) * (1 - vehicleProfile.eff_brake)), 0.00001)), 0); end if; else if vehicleProfile.P > 0 then - eta_vehicle = max(((vehicleProfile.P) / max((vehicleProfile.P + (batteryPowerTrain.Power_del_DC_DC * (1 - (batteryPowerTrain.eta_drivetrain * 0.01))) + (vehicleProfile.F_drag * vehicleProfile.v) + (vehicleProfile.F_accel * vehicleProfile.v) + (vehicleProfile.F_roll * vehicleProfile.v) + (vehicleProfile.P * (1 - vehicleProfile.eff_drivetrain))), 0.00001)) * 100, 0); + eta_vehicle = max(((vehicleProfile.P) / max((vehicleProfile.P + (batteryPowerTrain.Power_del_DC_DC * (1 - (batteryPowerTrain.eta_drivetrain))) + (vehicleProfile.F_drag * vehicleProfile.v) + (vehicleProfile.F_accel * vehicleProfile.v) + (vehicleProfile.F_roll * vehicleProfile.v) + (vehicleProfile.P * (1 - vehicleProfile.eff_drivetrain))), 0.00001)), 0); else eta_vehicle = 0; end if; diff --git a/VirtualFCS/Examples/VehicleExamples/RangeExtenderHybridVehicle.mo b/VirtualFCS/Examples/VehicleExamples/RangeExtenderHybridVehicle.mo index 382344f..7d6bf50 100644 --- a/VirtualFCS/Examples/VehicleExamples/RangeExtenderHybridVehicle.mo +++ b/VirtualFCS/Examples/VehicleExamples/RangeExtenderHybridVehicle.mo @@ -11,8 +11,8 @@ model RangeExtenderHybridVehicle VirtualFCS.Vehicles.DriveCycle driveCycle(v = VirtualFCS.Vehicles.DriveCycle.speed_profile.NEDC) annotation( Placement(visible = true, transformation(origin = {-60, -6.66134e-16}, extent = {{-21, -21}, {21, 21}}, rotation = 0))); Real fuel_consumption(unit = "kg/100km", start = 0) "The total fuel consumption at the end of simulation"; - Real hydrogen_mass_init(unit = "kg", start = 0) "Initial value of hydrogen mass in tank"; - Real eta_vehicle(unit = "100") "Vehicle efficiency"; + Modelica.Units.SI.Mass hydrogen_mass_init(start = 0) "Initial value of hydrogen mass in tank"; + Modelica.Units.SI.Efficiency eta_vehicle "Vehicle efficiency"; equation when time > 0.1 then hydrogen_mass_init = rangeExtenderPowerTrain.fuelCellSystem.fuelCellSubSystems.subSystemHydrogen.tankHydrogen.m; @@ -22,13 +22,13 @@ equation end when; if vehicleProfile.useRegenerativeBreaking then if vehicleProfile.P > 0 then - eta_vehicle = max(((vehicleProfile.P) / max((vehicleProfile.P + (rangeExtenderPowerTrain.Power_del_DC_DC * (1 - (rangeExtenderPowerTrain.eta_drivetrain * 0.01))) + (vehicleProfile.F_drag * vehicleProfile.v) + (vehicleProfile.F_accel * vehicleProfile.v) + (vehicleProfile.F_roll * vehicleProfile.v) + (vehicleProfile.P * (1 - vehicleProfile.eff_drivetrain))), 0.00001)) * 100,0); + eta_vehicle = max(((vehicleProfile.P) / max((vehicleProfile.P + (rangeExtenderPowerTrain.Power_del_DC_DC * (1 - (rangeExtenderPowerTrain.eta_drivetrain))) + (vehicleProfile.F_drag * vehicleProfile.v) + (vehicleProfile.F_accel * vehicleProfile.v) + (vehicleProfile.F_roll * vehicleProfile.v) + (vehicleProfile.P * (1 - vehicleProfile.eff_drivetrain))), 0.00001)),0); else - eta_vehicle = max(((abs(vehicleProfile.P)) / max(abs(vehicleProfile.P) + (abs(rangeExtenderPowerTrain.Power_del_DC_DC) * (1 - (rangeExtenderPowerTrain.eta_drivetrain * 0.01))) + (vehicleProfile.F_drag * vehicleProfile.v) + (abs(vehicleProfile.F_accel) * vehicleProfile.v) + (vehicleProfile.F_roll * vehicleProfile.v) + (abs(vehicleProfile.P) * (1 - vehicleProfile.eff_brake)), 0.00001)) * 100, 0); + eta_vehicle = max(((abs(vehicleProfile.P)) / max(abs(vehicleProfile.P) + (abs(rangeExtenderPowerTrain.Power_del_DC_DC) * (1 - (rangeExtenderPowerTrain.eta_drivetrain))) + (vehicleProfile.F_drag * vehicleProfile.v) + (abs(vehicleProfile.F_accel) * vehicleProfile.v) + (vehicleProfile.F_roll * vehicleProfile.v) + (abs(vehicleProfile.P) * (1 - vehicleProfile.eff_brake)), 0.00001)), 0); end if; else if vehicleProfile.P > 0 then - eta_vehicle = max(((vehicleProfile.P) / max((vehicleProfile.P + (rangeExtenderPowerTrain.Power_del_DC_DC * (1 - (rangeExtenderPowerTrain.eta_drivetrain * 0.01))) + (vehicleProfile.F_drag * vehicleProfile.v) + (vehicleProfile.F_accel * vehicleProfile.v) + (vehicleProfile.F_roll * vehicleProfile.v) + (vehicleProfile.P * (1 - vehicleProfile.eff_drivetrain))), 0.00001)) * 100, 0); + eta_vehicle = max(((vehicleProfile.P) / max((vehicleProfile.P + (rangeExtenderPowerTrain.Power_del_DC_DC * (1 - (rangeExtenderPowerTrain.eta_drivetrain))) + (vehicleProfile.F_drag * vehicleProfile.v) + (vehicleProfile.F_accel * vehicleProfile.v) + (vehicleProfile.F_roll * vehicleProfile.v) + (vehicleProfile.P * (1 - vehicleProfile.eff_drivetrain))), 0.00001)), 0); else eta_vehicle = 0; end if; diff --git a/VirtualFCS/Fluid/Compressor.mo b/VirtualFCS/Fluid/Compressor.mo index f31353c..d713b74 100644 --- a/VirtualFCS/Fluid/Compressor.mo +++ b/VirtualFCS/Fluid/Compressor.mo @@ -43,7 +43,7 @@ model Compressor Modelica.Blocks.Math.Gain gain(k = 9.5493) annotation( Placement(visible = true, transformation(origin = {67, -16}, extent = {{-6, -6}, {6, 6}}, rotation = 0))); // Power & Efficiencies - Real Power_Compressor(unit = "W") "The power consumed by the Compressor"; + Modelica.Units.SI.Power Power_Compressor "The power consumed by the Compressor"; equation torque.tau = -9.5488*pump.W_total/pump.N; Power_Compressor = pin_p.i*pin_p.v; diff --git a/VirtualFCS/Fluid/PumpElectricDC.mo b/VirtualFCS/Fluid/PumpElectricDC.mo index a0ce8f7..46123aa 100644 --- a/VirtualFCS/Fluid/PumpElectricDC.mo +++ b/VirtualFCS/Fluid/PumpElectricDC.mo @@ -47,11 +47,9 @@ model PumpElectricDC Modelica.Blocks.Math.Gain gain(k = 9.5493) annotation( Placement(visible = true, transformation(origin = {20, -28}, extent = {{-8, -8}, {8, 8}}, rotation = -90))); // Power & Efficiency - Real eta_PumpElectricDC(unit = "100") "The efficiency of the PumpElectricDC calculated by eta = P_water/P_shaft"; - Real Power_PumpElectricDC(unit = "W") "The power consumed by the PumpElectricDC"; + Modelica.Units.SI.Power Power_PumpElectricDC "The power consumed by the PumpElectricDC"; equation torque.tau = -9.5488*pump.W_total/pump.N; - eta_PumpElectricDC = (((Output.p - (Input.p))*volumeFlowRate.V_flow)/(max(dcpm.pin_ap.v*dcpm.pin_ap.i, 1e-10))) * 100; Power_PumpElectricDC = pin_p.i * pin_p.v; //*** DEFINE CONNECTIONS ***// connect(multiplex2.y, sensors) annotation( diff --git a/VirtualFCS/Fluid/RecirculationBlower.mo b/VirtualFCS/Fluid/RecirculationBlower.mo index 28713ba..86971ad 100644 --- a/VirtualFCS/Fluid/RecirculationBlower.mo +++ b/VirtualFCS/Fluid/RecirculationBlower.mo @@ -43,7 +43,7 @@ model RecirculationBlower VirtualFCS.Control.DCMotorControlRecirculationBlower dCMotorControlRecirculationBlower annotation( Placement(visible = true, transformation(origin = {-50, 42}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); // Power & Efficiencies - Real Power_RecirculationBlower(unit = "W") "The power consumed by the RecirculationBlower"; + Modelica.Units.SI.Power Power_RecirculationBlower "The power consumed by the RecirculationBlower"; equation torque.tau = -9.5488*pump.W_total/pump.N; Power_RecirculationBlower = pin_p.i * pin_p.v; diff --git a/VirtualFCS/Powertrains/BatteryPowerTrain.mo b/VirtualFCS/Powertrains/BatteryPowerTrain.mo index 3ef4b72..2272bef 100644 --- a/VirtualFCS/Powertrains/BatteryPowerTrain.mo +++ b/VirtualFCS/Powertrains/BatteryPowerTrain.mo @@ -1,33 +1,20 @@ within VirtualFCS.Powertrains; model BatteryPowerTrain + import SI = Modelica.Units.SI; outer Modelica.Fluid.System system "System properties"; - parameter Real m_powertrain(unit = "kg") = 100 + 50; - parameter Real V_HV_Bus(unit = "V") = 343 "Voltage of the HV Bus"; - // H2 Subsystem Paramters - parameter Real V_tank_H2(unit = "m3") = 0.13 "H2 tank volume"; - parameter Real p_tank_H2(unit = "Pa") = 3500000 "H2 tank initial pressure"; - // Fuel Cell Stack Paramters - parameter Real m_FC_stack(unit = "kg") = 14.3 "FC stack mass"; - parameter Real L_FC_stack(unit = "m") = 0.255 "FC stack length"; - parameter Real W_FC_stack(unit = "m") = 0.760 "FC stack length"; - parameter Real H_FC_stack(unit = "m") = 0.060 "FC stack length"; - parameter Real vol_FC_stack(unit = "m3") = L_FC_stack * W_FC_stack * H_FC_stack "FC stack volume"; - parameter Real V_rated_FC_stack(unit = "V") = 57.9 "FC stack maximum operating voltage"; - parameter Real I_rated_FC_stack(unit = "A") = 300 "FC stack minimum operating voltage"; - parameter Real i_L_FC_stack(unit = "A") = 3 * I_rated_FC_stack "FC stack maximum limiting current"; - parameter Real I_nom_FC_stack(unit = "A") = 0.25 * I_rated_FC_stack "FC stack maximum limiting current"; - parameter Real N_FC_stack(unit = "1") = floor(V_rated_FC_stack / 0.6433) "FC stack number of cells"; + parameter SI.Mass m_powertrain = m_bat_pack + 50; + parameter SI.Voltage V_HV_Bus = 343 "Voltage of the HV Bus"; // Battery Pack Parameters - parameter Real m_bat_pack(unit = "kg") = 100 "Mass of the pack"; - parameter Real L_bat_pack(unit = "m") = 0.6 "Battery pack length"; - parameter Real W_bat_pack(unit = "m") = 0.45 "Battery pack width"; - parameter Real H_bat_pack(unit = "m") = 0.1 "Battery pack height"; - parameter Real Cp_bat_pack(unit = "J/(kg.K)") = 1000 "Specific Heat Capacity"; - parameter Real V_min_bat_pack(unit = "V") = 37.5 "Battery pack minimum voltage"; - parameter Real V_nom_bat_pack(unit = "V") = 48 "Battery pack nominal voltage"; - parameter Real V_max_bat_pack(unit = "V") = 54.75 "Battery pack maximum voltage"; - parameter Real C_bat_pack(unit = "A.h") = 2700 "Battery pack nominal capacity"; + parameter SI.Mass m_bat_pack = 100 "Mass of the pack"; + parameter SI.Length L_bat_pack = 0.6 "Battery pack length"; + parameter SI.Breadth W_bat_pack = 0.45 "Battery pack width"; + parameter SI.Height H_bat_pack = 0.1 "Battery pack height"; + parameter SI.SpecificHeatCapacity Cp_bat_pack = 1000 "Specific Heat Capacity"; + parameter SI.Voltage V_min_bat_pack = 37.5 "Battery pack minimum voltage"; + parameter SI.Voltage V_nom_bat_pack = 48 "Battery pack nominal voltage"; + parameter SI.Voltage V_max_bat_pack = 54.75 "Battery pack maximum voltage"; + parameter Modelica.Units.NonSI.ElectricCharge_Ah C_bat_pack = 2700 "Battery pack nominal capacity"; parameter Real SOC_init = 0.5 "Battery pack initial state of charge"; Modelica.Electrical.Analog.Interfaces.PositivePin pin_p annotation( Placement(visible = true, transformation(origin = {40, 96}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-90, 50}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); @@ -35,21 +22,21 @@ model BatteryPowerTrain Placement(visible = true, transformation(origin = {-40, 96}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-90, -50}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Electrical.Analog.Basic.Ground ground annotation( Placement(visible = true, transformation(origin = {-68, 4}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); - VirtualFCS.Electrochemical.Battery.BatterySystem batterySystem(C_bat_pack = 200, SOC_init = 0.99, V_max_bat_pack = 300, V_min_bat_pack = 0) annotation( + VirtualFCS.Electrochemical.Battery.BatterySystem batterySystem(C_bat_pack = C_bat_pack, Cp_bat_pack = Cp_bat_pack, H_bat_pack = H_bat_pack, L_bat_pack = L_bat_pack, SOC_init = SOC_init, V_max_bat_pack = V_max_bat_pack, V_min_bat_pack = V_min_bat_pack, V_nom_bat_pack = V_nom_bat_pack, W_bat_pack = W_bat_pack, m_bat_pack = m_bat_pack) annotation( Placement(visible = true, transformation(origin = {0, -70}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); VirtualFCS.Electrical.DCConverter converter(vDCref = V_HV_Bus) annotation( Placement(visible = true, transformation(origin = {0, 8}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); - Real Power_batt(unit = "W") "Power delivered from the batt system"; - Real Power_del_DC_DC(unit = "W") "Power delivered from the DC/DC converter"; - Real eta_drivetrain(unit = "100") "Efficiency of the drivetrain"; - Real eta_DC_DC(unit = "1") = 100 "Efficiency of the DC/DC converter"; + SI.Power Power_batt "Power delivered from the batt system"; + SI.Power Power_del_DC_DC "Power delivered from the DC/DC converter"; + SI.Efficiency eta_drivetrain "Efficiency of the drivetrain"; + SI.Efficiency eta_DC_DC = 1 "Efficiency of the DC/DC converter"; equation Power_batt = batterySystem.pin_n.i * batterySystem.pin_p.v; Power_del_DC_DC = converter.dc_p1.i * converter.dc_p1.v; if Power_del_DC_DC > 0 then - eta_drivetrain = min(max(((Power_del_DC_DC)/max((Power_batt + ((Power_batt * (1-(batterySystem.eta_batt*0.01)))+ (Power_del_DC_DC * (1-(eta_DC_DC*0.01))))), 0.000001)) * 100, 0),100); + eta_drivetrain = min(max(((Power_del_DC_DC)/max((Power_batt + ((Power_batt * (1-(batterySystem.eta_batt)))+ (Power_del_DC_DC * (1-(eta_DC_DC))))), 0.000001)), 0),1); else - eta_drivetrain = min(max(((-Power_del_DC_DC)/max(( -Power_batt + ( - (Power_batt * (1-(batterySystem.eta_batt*0.01))) - (Power_del_DC_DC * (1-(eta_DC_DC*0.01))))), 0.000001)) * 100, 0), 100); + eta_drivetrain = min(max(((-Power_del_DC_DC)/max(( -Power_batt + ( - (Power_batt * (1-(batterySystem.eta_batt))) - (Power_del_DC_DC * (1-(eta_DC_DC))))), 0.000001)), 0), 1); end if; connect(pin_n, ground.p) annotation( Line(points = {{-40, 96}, {-68, 96}, {-68, 14}}, color = {0, 0, 255})); diff --git a/VirtualFCS/Powertrains/ParallelHybridPowerTrain.mo b/VirtualFCS/Powertrains/ParallelHybridPowerTrain.mo index e7b2977..5489be8 100644 --- a/VirtualFCS/Powertrains/ParallelHybridPowerTrain.mo +++ b/VirtualFCS/Powertrains/ParallelHybridPowerTrain.mo @@ -1,32 +1,33 @@ within VirtualFCS.Powertrains; model ParallelHybridPowerTrain - parameter Real m_powertrain(unit = "kg") = 100 + 50; - parameter Real V_HV_Bus(unit = "V") = 343 "Voltage of the HV Bus"; + import SI = Modelica.Units.SI; + parameter SI.Mass m_powertrain = m_FC_stack + m_bat_pack; + parameter SI.Voltage V_HV_Bus = 343 "Voltage of the HV Bus"; // H2 Subsystem Paramters - parameter Real V_tank_H2(unit = "m3") = 0.13 "H2 tank volume"; - parameter Real p_tank_H2(unit = "Pa") = 3500000 "H2 tank initial pressure"; + parameter SI.Volume V_tank_H2 = 0.13 "H2 tank volume"; + parameter SI.Pressure p_tank_H2 = 3500000 "H2 tank initial pressure"; // Fuel Cell Stack Paramters - parameter Real m_FC_stack(unit = "kg") = 14.3 "FC stack mass"; - parameter Real L_FC_stack(unit = "m") = 0.255 "FC stack length"; - parameter Real W_FC_stack(unit = "m") = 0.760 "FC stack length"; - parameter Real H_FC_stack(unit = "m") = 0.060 "FC stack length"; - parameter Real vol_FC_stack(unit = "m3") = L_FC_stack * W_FC_stack * H_FC_stack "FC stack volume"; - parameter Real V_rated_FC_stack(unit = "V") = 57.9 "FC stack maximum operating voltage"; - parameter Real I_rated_FC_stack(unit = "A") = 300 "FC stack minimum operating voltage"; - parameter Real i_L_FC_stack(unit = "A") = 3 * I_rated_FC_stack "FC stack maximum limiting current"; - parameter Real I_nom_FC_stack(unit = "A") = 0.25 * I_rated_FC_stack "FC stack maximum limiting current"; + parameter SI.Mass m_FC_stack = 14.3 "FC stack mass"; + parameter SI.Length L_FC_stack = 0.255 "FC stack length"; + parameter SI.Breadth W_FC_stack = 0.760 "FC stack breadth"; + parameter SI.Height H_FC_stack = 0.060 "FC stack height"; + parameter SI.Volume vol_FC_stack = L_FC_stack * W_FC_stack * H_FC_stack "FC stack volume"; + parameter SI.Voltage V_rated_FC_stack = 57.9 "FC stack maximum operating voltage"; + parameter SI.Current I_rated_FC_stack = 300 "FC stack minimum operating voltage"; + parameter SI.Current i_L_FC_stack = 1.7 * I_rated_FC_stack "FC stack maximum limiting current"; + parameter SI.Current I_nom_FC_stack = 0.25 * I_rated_FC_stack "FC stack maximum limiting current"; parameter Real N_FC_stack(unit = "1") = floor(V_rated_FC_stack / 0.6433) "FC stack number of cells"; // Battery Pack Parameters - parameter Real m_bat_pack(unit = "kg") = 100 "Mass of the pack"; - parameter Real L_bat_pack(unit = "m") = 0.6 "Battery pack length"; - parameter Real W_bat_pack(unit = "m") = 0.45 "Battery pack width"; - parameter Real H_bat_pack(unit = "m") = 0.1 "Battery pack height"; - parameter Real Cp_bat_pack(unit = "J/(kg.K)") = 1000 "Specific Heat Capacity"; - parameter Real V_min_bat_pack(unit = "V") = 37.5 "Battery pack minimum voltage"; - parameter Real V_nom_bat_pack(unit = "V") = 48 "Battery pack nominal voltage"; - parameter Real V_max_bat_pack(unit = "V") = 54.75 "Battery pack maximum voltage"; - parameter Real C_bat_pack(unit = "A.h") = 2700 "Battery pack nominal capacity"; + parameter SI.Mass m_bat_pack = 100 "Mass of the pack"; + parameter SI.Length L_bat_pack = 0.6 "Battery pack length"; + parameter SI.Breadth W_bat_pack = 0.45 "Battery pack width"; + parameter SI.Height H_bat_pack = 0.1 "Battery pack height"; + parameter SI.SpecificHeatCapacity Cp_bat_pack = 1000 "Specific Heat Capacity"; + parameter SI.Voltage V_min_bat_pack = 37.5 "Battery pack minimum voltage"; + parameter SI.Voltage V_nom_bat_pack = 48 "Battery pack nominal voltage"; + parameter SI.Voltage V_max_bat_pack = 54.75 "Battery pack maximum voltage"; + parameter Modelica.Units.NonSI.ElectricCharge_Ah C_bat_pack = 2700 "Battery pack nominal capacity"; parameter Real SOC_init = 0.5 "Battery pack initial state of charge"; Modelica.Electrical.Analog.Interfaces.PositivePin pin_p annotation( Placement(visible = true, transformation(origin = {40, 96}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-90, 50}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); diff --git a/VirtualFCS/Powertrains/RangeExtenderPowerTrain.mo b/VirtualFCS/Powertrains/RangeExtenderPowerTrain.mo index 061d0a2..8c38ef2 100644 --- a/VirtualFCS/Powertrains/RangeExtenderPowerTrain.mo +++ b/VirtualFCS/Powertrains/RangeExtenderPowerTrain.mo @@ -1,45 +1,70 @@ within VirtualFCS.Powertrains; model RangeExtenderPowerTrain + import SI = Modelica.Units.SI; // System outer Modelica.Fluid.System system "System properties"; - // Powertraom parameters - parameter Real m_powertrain(unit = "kg") = fuelCellSystem.m_FC_system + batterySystem.m_bat_pack; - parameter Real V_HV_Bus(unit = "V") = 343 "Voltage of the HV Bus"; + // Powertrain parameters + parameter SI.Mass m_powertrain = fuelCellSystem.m_FC_system + batterySystem.m_bat_pack annotation( + Dialog(group = "Powertrain Parameters")); + parameter SI.Voltage V_HV_Bus = 343 "Voltage of the HV Bus" annotation( + Dialog(group = "Powertrain Parameters")); // H2 Subsystem Paramters - parameter Real V_tank_H2(unit = "m3") = 0.13 "H2 tank volume"; - parameter Real p_tank_H2(unit = "Pa") = 35000000 "H2 tank initial pressure"; + parameter SI.Volume V_tank_H2 = 0.13 "H2 tank volume" annotation( + Dialog(group = "Subsystem Parameters")); + parameter SI.Pressure p_tank_H2 = 35000000 "H2 tank initial pressure" annotation( + Dialog(group = "Subsystem Parameters")); // Fuel Cell Stack Paramters - parameter Real m_FC_stack(unit = "kg") = 14.3 "FC stack mass"; - parameter Real L_FC_stack(unit = "m") = 0.255 "FC stack length"; - parameter Real W_FC_stack(unit = "m") = 0.760 "FC stack width"; - parameter Real H_FC_stack(unit = "m") = 0.060 "FC stack height"; - parameter Real vol_FC_stack(unit = "m3") = L_FC_stack * W_FC_stack * H_FC_stack "FC stack volume"; - parameter Real V_rated_FC_stack(unit = "V") = 57.9 "FC stack maximum operating voltage"; - parameter Real I_rated_FC_stack(unit = "A") = 300 "FC stack minimum operating current"; - parameter Real i_L_FC_stack(unit = "A") = 1.7 * I_rated_FC_stack "FC stack limiting current (max)"; - parameter Real I_nom_FC_stack(unit = "A") = 0.25 * I_rated_FC_stack "FC stack nominal current"; - parameter Real N_FC_stack(unit = "1") = floor(V_rated_FC_stack / 0.6433) "FC stack number of cells"; + parameter SI.Mass m_FC_stack = 14.3 "FC stack mass" annotation( + Dialog(group = "Fuel Cell Stack Parameters")); + parameter SI.Length L_FC_stack = 0.255 "FC stack length" annotation( + Dialog(group = "Fuel Cell Stack Parameters")); + parameter SI.Breadth W_FC_stack = 0.760 "FC stack width" annotation( + Dialog(group = "Fuel Cell Stack Parameters")); + parameter SI.Height H_FC_stack = 0.060 "FC stack height" annotation( + Dialog(group = "Fuel Cell Stack Parameters")); + parameter SI.Volume vol_FC_stack = L_FC_stack * W_FC_stack * H_FC_stack "FC stack volume" annotation( + Dialog(group = "Fuel Cell Stack Parameters")); + parameter SI.Voltage V_rated_FC_stack = 57.9 "FC stack maximum operating voltage" annotation( + Dialog(group = "Fuel Cell Stack Parameters")); + parameter SI.ElectricCurrent I_min_FC_stack = 0.25 * I_nom_FC_stack "FC stack minimum current" annotation( + Dialog(group = "Fuel Cell Stack Parameters")); + parameter SI.ElectricCurrent I_nom_FC_stack = 300 "FC stack nominal current" annotation( + Dialog(group = "Fuel Cell Stack Parameters")); + parameter SI.ElectricCurrent I_rated_FC_stack = 1.7 * I_nom_FC_stack "FC stack maximum operating current" annotation( + Dialog(group = "Fuel Cell Stack Parameters")); + parameter Real N_FC_stack(unit = "1") = floor(V_rated_FC_stack / 0.6433) "FC stack number of cells" annotation( + Dialog(group = "Fuel Cell Stack Parameters")); // Battery Pack Parameters - parameter Real m_bat_pack(unit = "kg") = 100 "Mass of the pack"; - parameter Real L_bat_pack(unit = "m") = 0.6 "Battery pack length"; - parameter Real W_bat_pack(unit = "m") = 0.45 "Battery pack width"; - parameter Real H_bat_pack(unit = "m") = 0.1 "Battery pack height"; - parameter Real Cp_bat_pack(unit = "J/(kg.K)") = 1000 "Specific Heat Capacity"; - parameter Real V_min_bat_pack(unit = "V") = 240 "Battery pack minimum voltage"; - parameter Real V_nom_bat_pack(unit = "V") = 336 "Battery pack nominal voltage"; - parameter Real V_max_bat_pack(unit = "V") = 403.2 "Battery pack maximum voltage"; - parameter Real C_bat_pack(unit = "A.h") = 200 "Battery pack nominal capacity"; - parameter Real SOC_init = 0.5 "Battery pack initial state of charge"; + parameter SI.Mass m_bat_pack = 100 "Mass of the pack" annotation( + Dialog(group = "Battery Pack Parameters")); + parameter SI.Length L_bat_pack = 0.6 "Battery pack length" annotation( + Dialog(group = "Battery Pack Parameters")); + parameter SI.Breadth W_bat_pack = 0.45 "Battery pack width" annotation( + Dialog(group = "Battery Pack Parameters")); + parameter SI.Height H_bat_pack = 0.1 "Battery pack height" annotation( + Dialog(group = "Battery Pack Parameters")); + parameter SI.SpecificHeatCapacity Cp_bat_pack = 1000 "Specific Heat Capacity" annotation( + Dialog(group = "Battery Pack Parameters")); + parameter SI.Voltage V_min_bat_pack = 240 "Battery pack minimum voltage" annotation( + Dialog(group = "Battery Pack Parameters")); + parameter SI.Voltage V_nom_bat_pack = 336 "Battery pack nominal voltage" annotation( + Dialog(group = "Battery Pack Parameters")); + parameter SI.Voltage V_max_bat_pack = 403.2 "Battery pack maximum voltage" annotation( + Dialog(group = "Battery Pack Parameters")); + parameter Modelica.Units.NonSI.ElectricCharge_Ah C_bat_pack = 200 "Battery pack nominal capacity" annotation( + Dialog(group = "Battery Pack Parameters")); + parameter Real SOC_init = 0.5 "Battery pack initial state of charge" annotation( + Dialog(group = "Battery Pack Parameters")); Modelica.Electrical.Analog.Interfaces.PositivePin pin_p annotation( Placement(visible = true, transformation(origin = {40, 96}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-90, 50}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Electrical.Analog.Interfaces.NegativePin pin_n annotation( Placement(visible = true, transformation(origin = {-40, 96}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-90, -50}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Electrical.Analog.Basic.Ground ground annotation( Placement(visible = true, transformation(origin = {-68, 4}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); - VirtualFCS.Electrochemical.Hydrogen.FuelCellSystem fuelCellSystem(H_FC_stack = H_FC_stack, I_rated_FC_stack = I_rated_FC_stack, L_FC_stack = L_FC_stack, V_tank_H2 = V_tank_H2, W_FC_stack = W_FC_stack, m_FC_stack = m_FC_stack, p_tank_H2 = p_tank_H2) annotation( + VirtualFCS.Electrochemical.Hydrogen.FuelCellSystem fuelCellSystem(H_FC_stack = H_FC_stack, I_nom_FC_stack = I_nom_FC_stack, I_rated_FC_stack = I_rated_FC_stack,L_FC_stack = L_FC_stack, N_FC_stack = N_FC_stack, V_tank_H2 = V_tank_H2, W_FC_stack = W_FC_stack, m_FC_stack = m_FC_stack, p_tank_H2 = p_tank_H2) annotation( Placement(visible = true, transformation(origin = {72, -72}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); - VirtualFCS.Electrochemical.Battery.BatterySystem batterySystem(C_bat_pack = C_bat_pack, Cp_bat_pack = Cp_bat_pack, H_bat_pack = H_bat_pack, L_bat_pack = L_bat_pack, SOC_init = SOC_init, V_max_bat_pack = V_max_bat_pack, V_min_bat_pack = V_min_bat_pack, V_nom_bat_pack = V_nom_bat_pack, W_bat_pack = W_bat_pack) annotation( + VirtualFCS.Electrochemical.Battery.BatterySystem batterySystem(C_bat_pack = C_bat_pack, Cp_bat_pack = Cp_bat_pack, H_bat_pack = H_bat_pack, L_bat_pack = L_bat_pack, SOC_init = SOC_init, V_max_bat_pack = V_max_bat_pack, V_min_bat_pack = V_min_bat_pack, V_nom_bat_pack = V_nom_bat_pack, W_bat_pack = W_bat_pack, m_bat_pack = m_bat_pack) annotation( Placement(visible = true, transformation(origin = {-28, -72}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); VirtualFCS.Electrical.DCConverter converter(vDCref = V_HV_Bus) annotation( Placement(visible = true, transformation(origin = {0, 30}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); @@ -48,19 +73,19 @@ model RangeExtenderPowerTrain VirtualFCS.Control.EnergyManagementSystem energyManagementSystem annotation( Placement(visible = true, transformation(origin = {-66, -72}, extent = {{10, -10}, {-10, 10}}, rotation = 0))); // Power & Efficiencies - Real Power_del_DC_DC(unit = "W") "Power delivered from the DC/DC converter"; - Real Power_FC(unit = "W") "Power delivered from the FC system"; - Real Power_batt(unit = "W") "Power delivered from the batt system"; - Real eta_drivetrain(unit = "100") "Efficiency of the drivetrain"; - Real eta_DC_DC(unit = "100") = 100 "Efficiency of the DC/DC converter"; + SI.Power Power_del_DC_DC "Power delivered from the DC/DC converter"; + SI.Power Power_FC "Power delivered from the FC system"; + SI.Power Power_batt "Power delivered from the batt system"; + SI.Efficiency eta_drivetrain "Efficiency of the drivetrain"; + SI.Efficiency eta_DC_DC = 1 "Efficiency of the DC/DC converter"; equation Power_del_DC_DC = converter.dc_p1.i * converter.dc_p1.v; Power_FC = fuelCellSystem.pin_n.i * fuelCellSystem.pin_p.v; Power_batt = batterySystem.pin_n.i * batterySystem.pin_p.v; if Power_del_DC_DC > 0 then - eta_drivetrain = min(max(((Power_del_DC_DC)/max((Power_FC + Power_batt + ((Power_FC * (1-(fuelCellSystem.eta_FC_sys*0.01)))+ (Power_batt * (1-(batterySystem.eta_batt*0.01)))+ (Power_del_DC_DC * (1-(eta_DC_DC*0.01))))), 0.000001)) * 100, 0),100); + eta_drivetrain = min(max(((Power_del_DC_DC)/max((Power_FC + Power_batt + ((Power_FC * (1-(fuelCellSystem.eta_FC_sys)))+ (Power_batt * (1-(batterySystem.eta_batt)))+ (Power_del_DC_DC * (1-(eta_DC_DC))))), 0.000001)), 0),1); else - eta_drivetrain = min(max(((-Power_del_DC_DC)/max((Power_FC -Power_batt + ((Power_FC * (1-(fuelCellSystem.eta_FC_sys*0.01))) - (Power_batt * (1-(batterySystem.eta_batt*0.01))) - (Power_del_DC_DC * (1-(eta_DC_DC*0.01))))), 0.000001)) * 100, 0), 100); + eta_drivetrain = min(max(((-Power_del_DC_DC)/max((Power_FC -Power_batt + ((Power_FC * (1-(fuelCellSystem.eta_FC_sys))) - (Power_batt * (1-(batterySystem.eta_batt))) - (Power_del_DC_DC * (1-(eta_DC_DC))))), 0.000001)), 0), 1); end if; connect(pin_n, ground.p) annotation( Line(points = {{-40, 96}, {-68, 96}, {-68, 14}}, color = {0, 0, 255})); diff --git a/VirtualFCS/SubSystems/Air/SubSystemAir.mo b/VirtualFCS/SubSystems/Air/SubSystemAir.mo index c1910a8..0d9bb0d 100644 --- a/VirtualFCS/SubSystems/Air/SubSystemAir.mo +++ b/VirtualFCS/SubSystems/Air/SubSystemAir.mo @@ -7,7 +7,8 @@ model SubSystemAir // Medium declaration replaceable package Medium = Modelica.Media.Air.MoistAir(Temperature(start = system.T_start), AbsolutePressure(start = system.p_start)); // Parameter definition - parameter Real m_system_air(unit = "kg") = 61 "Air system mass"; + parameter Modelica.Units.SI.Mass m_system_air = 61 "Air system mass"; + parameter Real N_FC_stack(unit = "1") = 455 "FC stack number of cells"; //*** INSTANTIATE COMPONENTS ***// // Interfaces and boundaries Modelica.Fluid.Sources.FixedBoundary airSink(redeclare package Medium = Medium, nPorts = 2) annotation( @@ -31,7 +32,7 @@ model SubSystemAir Placement(visible = true, transformation(origin = {-36, -94}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Blocks.Sources.RealExpression setCompressorSpeed(y = deMultiplexControl.y2[1]) annotation( Placement(visible = true, transformation(origin = {-38, 46}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); - VirtualFCS.SubSystems.Air.SubSystemAirControl subSystemAirControl annotation( + VirtualFCS.SubSystems.Air.SubSystemAirControl subSystemAirControl(N_FC_stack = N_FC_stack) annotation( Placement(visible = true, transformation(origin = {-45, 79}, extent = {{-15, -15}, {15, 15}}, rotation = 0))); // Machines VirtualFCS.Fluid.Compressor compressor annotation( diff --git a/VirtualFCS/SubSystems/Air/SubSystemAirControl.mo b/VirtualFCS/SubSystems/Air/SubSystemAirControl.mo index ba35075..ad5f8af 100644 --- a/VirtualFCS/SubSystems/Air/SubSystemAirControl.mo +++ b/VirtualFCS/SubSystems/Air/SubSystemAirControl.mo @@ -1,8 +1,8 @@ within VirtualFCS.SubSystems.Air; block SubSystemAirControl - parameter Real pressure_Air_set(unit = "Pa") = 150000 "Set air Pressure"; - parameter Real massFlow_Air_set(unit = "kg/s") = 4e-3 "Set air Recirculation Mass Flow"; + parameter Modelica.Units.SI.Pressure pressure_Air_set = 150000 "Set air Pressure"; + parameter Modelica.Units.SI.MassFlowRate massFlow_Air_set = 4e-3 "Set air Recirculation Mass Flow"; parameter Real N_FC_stack(unit = "1") = 455 "FC stack number of cells"; VirtualFCS.Control.PumpSpeedControl pumpSpeedControl annotation( Placement(visible = true, transformation(origin = {0, -7.10543e-15}, extent = {{-58, -58}, {58, 58}}, rotation = 0))); diff --git a/VirtualFCS/SubSystems/Cooling/SubSystemCooling.mo b/VirtualFCS/SubSystems/Cooling/SubSystemCooling.mo index 642bb03..be21e3c 100644 --- a/VirtualFCS/SubSystems/Cooling/SubSystemCooling.mo +++ b/VirtualFCS/SubSystems/Cooling/SubSystemCooling.mo @@ -8,7 +8,7 @@ model SubSystemCooling // Medium declaration replaceable package Coolant_Medium = Modelica.Media.Water.ConstantPropertyLiquidWater constrainedby Modelica.Media.Interfaces.PartialMedium; // Parameter definition - parameter Real m_system_coolant(unit = "kg") = 44 "Coolant system mass"; + parameter Modelica.Units.SI.Mass m_system_coolant = 44 "Coolant system mass"; //*** INSTANTIATE COMPONENTS ***// // Interfaces and boundaries Modelica.Fluid.Interfaces.FluidPort_b port_b(redeclare package Medium = Coolant_Medium) annotation( diff --git a/VirtualFCS/SubSystems/Cooling/SubSystemCoolingControl.mo b/VirtualFCS/SubSystems/Cooling/SubSystemCoolingControl.mo index b024202..5ed7f0e 100644 --- a/VirtualFCS/SubSystems/Cooling/SubSystemCoolingControl.mo +++ b/VirtualFCS/SubSystems/Cooling/SubSystemCoolingControl.mo @@ -1,7 +1,7 @@ within VirtualFCS.SubSystems.Cooling; model SubSystemCoolingControl - parameter Real temperature_Cooling_set(unit = "K") = 80 + 273.15 "Set Fuel cell Temperature"; + parameter Modelica.Units.SI.Temperature temperature_Cooling_set = 80 + 273.15 "Set Fuel cell Temperature"; Modelica.Blocks.Interfaces.RealInput sensorInterface annotation( Placement(visible = true, transformation(origin = {-220, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-220, 0}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); Modelica.Blocks.Sources.Constant setCoolingTemperature(k = temperature_Cooling_set) annotation( diff --git a/VirtualFCS/SubSystems/FuelCellSubSystems.mo b/VirtualFCS/SubSystems/FuelCellSubSystems.mo index 3d6501c..435a3fa 100644 --- a/VirtualFCS/SubSystems/FuelCellSubSystems.mo +++ b/VirtualFCS/SubSystems/FuelCellSubSystems.mo @@ -1,6 +1,7 @@ within VirtualFCS.SubSystems; model FuelCellSubSystems + import SI = Modelica.Units.SI; // System outer Modelica.Fluid.System system "System properties"; // Medium decleration @@ -8,9 +9,10 @@ model FuelCellSubSystems replaceable package Anode_Medium = Modelica.Media.IdealGases.SingleGases.H2 constrainedby Modelica.Media.Interfaces.PartialSimpleIdealGasMedium; replaceable package Coolant_Medium = Modelica.Media.Water.ConstantPropertyLiquidWater constrainedby Modelica.Media.Interfaces.PartialMedium; // H2 Subsystem Paramters - parameter Real m_FC_subsystems(unit = "kg") = subSystemHydrogen.m_system_H2 + subSystemAir.m_system_air + subSystemCooling.m_system_coolant + batterySystem.m_bat_pack; - parameter Real V_tank_H2(unit = "m3") = 0.13 "H2 tank volume"; - parameter Real p_tank_H2(unit = "Pa") = 35000000 "H2 tank initial pressure"; + parameter SI.Mass m_FC_subsystems = subSystemHydrogen.m_system_H2 + subSystemAir.m_system_air + subSystemCooling.m_system_coolant + batterySystem.m_bat_pack; + parameter SI.Volume V_tank_H2 = 0.13 "H2 tank volume"; + parameter SI.Pressure p_tank_H2 = 35000000 "H2 tank initial pressure"; + parameter Real N_FC_stack(unit = "1") = 455 "FC stack number of cells"; Modelica.Fluid.Interfaces.FluidPort_a H2_port_a(redeclare package Medium = Anode_Medium) annotation( Placement(visible = true, transformation(origin = {-66, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-70, 90}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Fluid.Interfaces.FluidPort_b H2_port_b(redeclare package Medium = Anode_Medium) annotation( @@ -25,9 +27,9 @@ model FuelCellSubSystems Placement(visible = true, transformation(origin = {-6, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {10, 90}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Fluid.Interfaces.FluidPort_b coolant_port_b(redeclare package Medium = Coolant_Medium) annotation( Placement(visible = true, transformation(origin = {6, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-10, 90}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); - Hydrogen.SubSystemHydrogen subSystemHydrogen annotation( + Hydrogen.SubSystemHydrogen subSystemHydrogen(N_FC_stack = N_FC_stack,V_tank_H2 = V_tank_H2, p_tank_H2 = p_tank_H2) annotation( Placement(visible = true, transformation(origin = {-60, 0}, extent = {{-15, -10}, {15, 10}}, rotation = 0))); - VirtualFCS.SubSystems.Air.SubSystemAir subSystemAir annotation( + VirtualFCS.SubSystems.Air.SubSystemAir subSystemAir(N_FC_stack = N_FC_stack) annotation( Placement(visible = true, transformation(origin = {60, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Cooling.SubSystemCooling subSystemCooling annotation( Placement(visible = true, transformation(origin = {0, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); diff --git a/VirtualFCS/SubSystems/Hydrogen/SubSystemHydrogen.mo b/VirtualFCS/SubSystems/Hydrogen/SubSystemHydrogen.mo index 4defadb..cf9b8ec 100644 --- a/VirtualFCS/SubSystems/Hydrogen/SubSystemHydrogen.mo +++ b/VirtualFCS/SubSystems/Hydrogen/SubSystemHydrogen.mo @@ -1,15 +1,17 @@ within VirtualFCS.SubSystems.Hydrogen; model SubSystemHydrogen + import SI = Modelica.Units.SI; // System outer Modelica.Fluid.System system "System properties"; // Medium declaration replaceable package Anode_Medium = Modelica.Media.IdealGases.SingleGases.H2(Temperature(start = system.T_start), AbsolutePressure(start = system.p_start)) constrainedby Modelica.Media.Interfaces.PartialSimpleIdealGasMedium; // Parameter definition - parameter Real m_system_H2(unit = "kg") = 61 "H2 system mass"; - parameter Real V_tank_H2(unit = "m3") = 0.13 "H2 tank volume"; - parameter Real A_tank_H2(unit = "m2") = 2 "H2 tank surface area"; - parameter Real p_tank_H2(unit = "Pa") = 35000000 "H2 tank initial pressure"; + parameter SI.Mass m_system_H2 = 61 "H2 system mass"; + parameter SI.Volume V_tank_H2 = 0.13 "H2 tank volume"; + parameter SI.Area A_tank_H2 = 2 "H2 tank surface area"; + parameter SI.Pressure p_tank_H2 = 35000000 "H2 tank initial pressure"; + parameter Real N_FC_stack(unit = "1") = 455 "FC stack number of cells"; //*** INSTANTIATE COMPONENTS ***// // Interfaces and boundaries Modelica.Fluid.Sources.Boundary_pT exhaustHydrogen(redeclare package Medium = Anode_Medium, T = system.T_start, nPorts = 1, p = system.p_start, use_T_in = false) annotation( @@ -42,7 +44,7 @@ model SubSystemHydrogen Placement(visible = true, transformation(origin = {-62, -50}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Modelica.Blocks.Sources.RealExpression setBlowerSpeed(y = controlSignals.y3[1]) annotation( Placement(visible = true, transformation(origin = {72, -6}, extent = {{10, -10}, {-10, 10}}, rotation = 0))); - VirtualFCS.SubSystems.Hydrogen.SubSystemHydrogenControl subSystemHydrogenControl(pressure_H2_set = 200000) annotation( + VirtualFCS.SubSystems.Hydrogen.SubSystemHydrogenControl subSystemHydrogenControl(N_FC_stack = N_FC_stack, pressure_H2_set = 200000) annotation( Placement(visible = true, transformation(origin = {-98, -12}, extent = {{-20, -20}, {20, 20}}, rotation = 0))); Modelica.Blocks.Routing.DeMultiplex3 controlSignals annotation( Placement(visible = true, transformation(origin = {-56, -12}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); diff --git a/VirtualFCS/SubSystems/Hydrogen/SubSystemHydrogenControl.mo b/VirtualFCS/SubSystems/Hydrogen/SubSystemHydrogenControl.mo index 0ee2379..6907939 100644 --- a/VirtualFCS/SubSystems/Hydrogen/SubSystemHydrogenControl.mo +++ b/VirtualFCS/SubSystems/Hydrogen/SubSystemHydrogenControl.mo @@ -1,8 +1,8 @@ within VirtualFCS.SubSystems.Hydrogen; model SubSystemHydrogenControl - parameter Real pressure_H2_set(unit = "Pa") = 200000 "Set H2 Pressure"; - parameter Real massFlow_H2_set(unit = "kg/s") = 1e-2 "Set H2 Recirculation Mass Flow"; + parameter Modelica.Units.SI.Pressure pressure_H2_set = 200000 "Set H2 Pressure"; + parameter Modelica.Units.SI.MassFlowRate massFlow_H2_set = 1e-2 "Set H2 Recirculation Mass Flow"; parameter Real N_FC_stack(unit = "1") = 455 "FC stack number of cells"; Modelica.Blocks.Routing.Multiplex3 multiplexSignalsH2Subsystem annotation( Placement(visible = true, transformation(origin = {124, 40}, extent = {{-16, -16}, {16, 16}}, rotation = 0))); diff --git a/VirtualFCS/Thermal/PreHeater.mo b/VirtualFCS/Thermal/PreHeater.mo index c2c3317..119cdf9 100644 --- a/VirtualFCS/Thermal/PreHeater.mo +++ b/VirtualFCS/Thermal/PreHeater.mo @@ -5,10 +5,10 @@ model PreHeater // Medium models replaceable package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater; //*** DECLARE PARAMETERS ***// - parameter Real R_eq(unit = "ohm") = 1.75 "Equivalent Resistance"; - parameter Real D_pipe(unit = "m") = 0.015 "Pipe Diameter"; - parameter Real L_pipe(unit = "m") = 1 "Pipe Length"; - parameter Real N_pipe(unit = "-") = 10 "Number of Parallel Pipes"; + parameter Modelica.Units.SI.Resistance R_eq = 1.75 "Equivalent Resistance"; + parameter Modelica.Units.SI.Diameter D_pipe = 0.015 "Pipe Diameter"; + parameter Modelica.Units.SI.Length L_pipe = 1 "Pipe Length"; + parameter Real N_pipe(unit = "1") = 10 "Number of Parallel Pipes"; //*** INSTANTIATE COMPONENTS ***// Modelica.Fluid.Pipes.DynamicPipe pipe(redeclare package Medium = Medium, diameter = D_pipe, length = L_pipe, modelStructure = Modelica.Fluid.Types.ModelStructure.a_vb, nNodes = 1, nParallel = N_pipe, p_a_start = 102502, use_HeatTransfer = true) annotation( Placement(visible = true, transformation(origin = {0, -80}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); diff --git a/VirtualFCS/Vehicles/JoystickDriveInput.mo b/VirtualFCS/Vehicles/JoystickDriveInput.mo index d73190f..aabed48 100644 --- a/VirtualFCS/Vehicles/JoystickDriveInput.mo +++ b/VirtualFCS/Vehicles/JoystickDriveInput.mo @@ -3,8 +3,8 @@ within VirtualFCS.Vehicles; model JoystickDriveInput parameter Real R_accel = 6; parameter Real R_decel = -4.5; - parameter Real maxVelocity = 200; - parameter Real minVelocity = 0; + parameter Modelica.Units.SI.Velocity maxVelocity = 200; + parameter Modelica.Units.SI.Velocity minVelocity = 0; VirtualFCS.XInTheLoop.UserInTheLoop.JoystickRoadElectricVehicleControl joystickRoadElectricVehicleControl annotation( Placement(visible = true, transformation(origin = {-80, -9}, extent = {{-15, -15}, {15, 15}}, rotation = 0))); Modelica.Blocks.Math.Gain gain(k = R_decel) annotation( diff --git a/VirtualFCS/Vehicles/VehicleProfile.mo b/VirtualFCS/Vehicles/VehicleProfile.mo index 01af8d0..54e394c 100644 --- a/VirtualFCS/Vehicles/VehicleProfile.mo +++ b/VirtualFCS/Vehicles/VehicleProfile.mo @@ -2,40 +2,42 @@ within VirtualFCS.Vehicles; model VehicleProfile "Calculates the driving power for a vehicle that corresponds to a given speed profile." import Modelica.Blocks.Tables.Internal; + import SI = Modelica.Units.SI; + import NonSI = Modelica.Units.NonSI; type vehicle_name = enumeration(Default "Default", Mirai "Mirai", UserDefined "User Defined") annotation( Evaluate = true); parameter vehicle_name VN = VirtualFCS.Vehicles.VehicleProfile.vehicle_name.Default "Vehicle name"; //parameter - Real m(unit = "kg") "mass of the vehicle"; + SI.Mass m "mass of the vehicle"; //////////////////////////////////////////////////////////////////////////////////////////////////// // *** DECLARE PARAMETERS *** // // Parameters of the vehicle and the air //parameter Real m(unit = "kg") = 1850 "Mass of the vehicle"; - parameter Real rho_air(unit = "kg/m3") = 1.2 "Volumic mass of the air"; - parameter Real A_front(unit = "m2") = 2.7 "Front area of the vehicle"; + parameter SI.Density rho_air = 1.2 "Volumic mass of the air"; + parameter SI.Area A_front = 2.7 "Front area of the vehicle"; parameter Real C_D(unit = "1") = 0.26 "Drag coefficient"; - parameter Real D_tire(unit = "m") = 0.4318 "Tire Diameter"; + parameter SI.Diameter D_tire = 0.4318 "Tire Diameter"; parameter Real R_gear(unit = "1") = 3.478 "Reduction Gear Ratio"; - parameter Real V_load(unit = "V") = 343 "Load Voltage"; + parameter SI.Voltage V_load = 343 "Load Voltage"; parameter Boolean useRegenerativeBreaking = true annotation( choices(checkBox = true)); // Efficiency coefficients - parameter Real eff_drivetrain(unit = "1") = 0.9 "Efficiency of the drivetrain"; - parameter Real eff_brake(unit = "1") = 0.5 "Efficiency of the regenerative breaking"; + parameter SI.Efficiency eff_drivetrain = 0.9 "Efficiency of the drivetrain"; + parameter SI.Efficiency eff_brake = 0.5 "Efficiency of the regenerative breaking"; // --- Class Outputs --- // // Derived Quantities - Real V(unit = "km/h") "Vehicle Speed"; - Real v(unit = "m/s") "Speed of the vehicle in m/s"; - Real a(unit = "m/s2") "Vehicle acceleration"; - Real F_accel(unit = "N") "Vehicle acceleration force"; - Real F_drag(unit = "N") "Vehicle drag force"; - Real F_roll(unit = "N") "Vehicle rolling force"; - Real F_T(unit = "N") "Vehicle total force"; - Real omega_engine(unit = "rad/s") "Motor Rotation, rad/s"; - Real N_engine(unit = "rpm") "Motor Rotation, rpm"; + NonSI.Velocity_kmh V "Vehicle Speed"; + SI.Velocity v "Speed of the vehicle in m/s"; + SI.Acceleration a "Vehicle acceleration"; + SI.Force F_accel "Vehicle acceleration force"; + SI.Force F_drag "Vehicle drag force"; + SI.Force F_roll "Vehicle rolling force"; + SI.Force F_T "Vehicle total force"; + SI.AngularVelocity omega_engine "Motor Rotation, rad/s"; + NonSI.AngularVelocity_rpm N_engine "Motor Rotation, rpm"; // Real tau(unit = "N.m") "Motor Torque"; - Real x(unit = "m") "Position"; - Real P(unit = "W"); + SI.Position x(fixed = true) "Position"; + SI.Power P; // *** INSTANTIATE COMPONENTS *** // Modelica.Electrical.Analog.Interfaces.NegativePin pin_n annotation( Placement(visible = true, transformation(origin = {72, -46}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(extent = {{80, -60}, {100, -40}}, rotation = 0))); @@ -57,7 +59,7 @@ equation // Redeclare variables V = vehicleVelocity; // Change of units (from km/h to m/s) - v = V / 3.6; + v = Modelica.Units.Conversions.from_kmh(V); // Calculate position der(x) = v; der(v) = a;