Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions BobLib/Controllers/VCU.mo
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ model VCU
"Multiplier mapping sensed motor speed to drive-positive speed" annotation(
Dialog(tab = "Controllers", group = "Electric Drive Mapping"));
parameter Real finalDriveRatio = 1
"Final-drive ratio used to convert rear-axle torque command to motor torque" annotation(
"Fallback ratio used before the transmission publishes an engaged ratio" annotation(
Dialog(tab = "Controllers", group = "Electric Drive Mapping"));

// Longitudinal speed controller
Expand Down Expand Up @@ -90,6 +90,8 @@ protected
SI.Voltage sens_hv_bus_voltage;
SI.Current sens_hv_bus_current;
SI.Velocity sens_vehicle_speed;
Real sens_gear_ratio "Engaged transmission ratio sensed from the transmission bus";
Real effectiveDriveRatio "Ratio used for axle/motor torque conversion";

Modelica.Blocks.Interfaces.RealInput steeringAngleBusTap(
quantity = "Angle",
Expand Down Expand Up @@ -132,6 +134,10 @@ protected
"Vehicle speed from chassisBus" annotation(
Placement(transformation(origin = {-100, 54}, extent = {{-6, -6}, {6, 6}})));

Modelica.Blocks.Interfaces.RealInput gearRatioBusTap
"Engaged transmission ratio from transmissionBus" annotation(
Placement(transformation(origin = {-100, 46}, extent = {{-6, -6}, {6, 6}})));

Modelica.Blocks.Sources.RealExpression powerRequestBusSignal(
y = P_req) "Power request published to electricMotorControlBus" annotation(
Placement(transformation(origin = {54, 42}, extent = {{-8, -4}, {8, 4}})));
Expand Down Expand Up @@ -176,7 +182,7 @@ protected
Placement(transformation(origin = {-70, -90}, extent = {{-10, -10}, {10, 10}})));

Modelica.Blocks.Sources.RealExpression motorTorqueRequest(
y = driveTorqueCmd / max(finalDriveRatio, 1e-6)) annotation(
y = driveTorqueCmd / effectiveDriveRatio) annotation(
Placement(transformation(origin = {-44, 16}, extent = {{-5, -2}, {5, 2}})));

Modelica.Blocks.Sources.RealExpression regenLimitRequest(
Expand All @@ -200,10 +206,10 @@ protected

equation
rearAxleTorqueCapacity =
tau_max * max(finalDriveRatio, 1e-6);
tau_max * effectiveDriveRatio;

rearAxleRegenTorqueCapacity =
regenTorqueLimit * max(finalDriveRatio, 1e-6);
regenTorqueLimit * effectiveDriveRatio;

cmd_steering_angle = steeringAngleBusTap;
cmd_accelerator_pedal = acceleratorPedalBusTap;
Expand All @@ -213,6 +219,11 @@ equation
sens_hv_bus_voltage = hvBusVoltageBusTap;
sens_hv_bus_current = hvBusCurrentBusTap;
sens_vehicle_speed = vehicleSpeedBusTap;
sens_gear_ratio = gearRatioBusTap;
// Prefer the live engaged ratio published by the transmission; fall back to
// the fixed parameter only if the bus signal is not yet meaningful.
effectiveDriveRatio =
noEvent(if abs(sens_gear_ratio) > 1e-6 then sens_gear_ratio else max(finalDriveRatio, 1e-6));

speedControlTorqueCmd =
if enablePTNDriveSpeedControl or
Expand Down Expand Up @@ -306,6 +317,8 @@ equation
Line(points = {{0, -100}, {-96, -100}, {-96, 20}}, color = {0, 0, 127}));
connect(controlBus.chassisBus.vehicleSpeed, vehicleSpeedBusTap) annotation(
Line(points = {{0, -100}, {-100, -100}, {-100, 54}}, color = {0, 0, 127}));
connect(controlBus.transmissionBus.gearRatio, gearRatioBusTap) annotation(
Line(points = {{0, -100}, {-100, -100}, {-100, 46}}, color = {0, 0, 127}));

connect(powerRequestBusSignal.y, controlBus.electricMotorControlBus.powerRequest) annotation(
Line(points = {{62.8, 42}, {94, 42}, {94, -100}, {0, -100}}, color = {0, 0, 127}));
Expand Down
12 changes: 11 additions & 1 deletion BobLib/ElectricDrives/Internal/PowerLimitedMotor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ model PowerLimitedMotor
parameter SI.Power P_cont_high = 75e3 "High end continuous power band [W]";
parameter Real eta_mot = 0.96 "Constant motoring efficiency approximation";
parameter Real eta_reg = 0.95 "Constant regen efficiency approximation";
parameter Boolean useTorqueTable = false
"Use a torque-vs-rpm curve as an additional peak-torque cap";
parameter Real torqueTable[:, 2] = [0.0, 1e9; 1.0, 1e9]
"Peak torque vs speed (rpm, Nm); applied as an extra cap when useTorqueTable";
parameter Real lossTable[:, 2] = [
0, 0;
1000, 200;
Expand Down Expand Up @@ -77,6 +81,7 @@ protected

Real peakFactor "1 -> allow peak, 0 -> only continuous";
SI.Torque T_allow;
SI.Torque T_table_cap "Torque-vs-rpm curve cap (large when table disabled)";
SI.Current I_allow;

Real P_allow;
Expand Down Expand Up @@ -109,6 +114,11 @@ equation
T_allow = peakFactor*T_peak + (1 - peakFactor)*T_cont;
I_allow = peakFactor*I_peak_2min + (1 - peakFactor)*I_cont;

// Optional torque-vs-rpm curve, applied as an additional cap. Disabled by
// default (returns a large value) so scalar-only motors are unchanged.
T_table_cap =
if useTorqueTable then interp1(torqueTable, rpm) else Modelica.Constants.inf;

// Continuous power envelope vs speed
P_cont_env =

Expand Down Expand Up @@ -144,7 +154,7 @@ equation

// Combined torque limit
tau_lim =
noEvent(min(T_allow,
noEvent(min(min(T_allow, T_table_cap),
min(tau_lim_from_power,
tau_lim_from_current)));

Expand Down
6 changes: 6 additions & 0 deletions BobLib/ElectricDrives/Motor.mo
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ model Motor
"Select reverse torque direction when starting exactly from standstill";
parameter SI.Inertia rotorJ = 0.02521
"Motor rotor inertia";
parameter Boolean useTorqueTable = false
"Use a torque-vs-rpm curve as an additional peak-torque cap";
parameter Real torqueTable[:, 2] = [0.0, 1e9; 1.0, 1e9]
"Peak torque vs speed (rpm, Nm); applied as an extra cap when useTorqueTable";

Modelica.Electrical.Analog.Interfaces.PositivePin pin_p
"Motor-side DC positive pin" annotation(
Expand All @@ -64,6 +68,8 @@ model Motor
P_cont_high = P_cont_high,
eta_mot = eta_mot,
eta_reg = eta_reg,
useTorqueTable = useTorqueTable,
torqueTable = torqueTable,
w_eps = w_eps,
reverseLaunch = reverseLaunch) annotation(
Placement(transformation(origin = {-20, 0}, extent = {{-30, -30}, {30, 30}})));
Expand Down
11 changes: 2 additions & 9 deletions BobLib/Experiments/Standards/FourPostSim.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ within BobLib.Experiments.Standards;

model FourPostSim

extends Templates.FourPost.FourPostSim_DWBCStabar_DWBCStabar;
extends Templates.FourPost.FourPostSim_EVBatInvMotDiff_DWBCStabar_DWBCStabar;
extends BobLib.Icons.SimulationIcon;

annotation(
Expand All @@ -13,12 +13,5 @@ model FourPostSim
lv = "LOG_STDOUT,LOG_ASSERT,LOG_STATS",
s = "dassl",
variableFilter = ".*"),
Documentation(info = "<html>
<p>
Model <code>FourPostSim</code> is the front-facing standard four-post simulation entry point.
</p>
<p>
It extends the selected four-post architecture template, applies the standard experiment setup, and is intended for suspension and chassis response studies.
</p>
</html>"));
Documentation(info = "<html><p>Generated standard four-post simulation entry point.</p></html>"));
end FourPostSim;
11 changes: 9 additions & 2 deletions BobLib/Experiments/Standards/Templates/FMI/BaseVehicleFMI.mo
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,20 @@ partial model BaseVehicleFMI
eta_reg = pVehicle.pMotor.eta_reg,
w_eps = pVehicle.pMotor.w_eps,
reverseLaunch = pVehicle.pMotor.reverseLaunch,
useTorqueTable = pVehicle.pMotor.useTorqueTable,
torqueTable = pVehicle.pMotor.torqueTable,
rotorJ = pVehicle.pMotor.rotorJ) annotation(
choicesAllMatching = true,
Dialog(group = "Plant Models"),
Placement(transformation(origin = {-79, -10.3334}, extent = {{-10, -10}, {10, 10}}, rotation = -180))) constrainedby VehicleInterfaces.ElectricDrives.Interfaces.Base "Traction motor subsystem";

replaceable BobLib.Transmissions.FixedRatioTransmission transmission(
gearRatio = pVehicle.pDriveline.finalDriveRatio) annotation(
replaceable BobLib.Transmissions.SpeedScheduledTransmission transmission(
nGears = pVehicle.pTransmission.nGears,
gearRatios = pVehicle.pTransmission.gearRatios,
upshiftSpeeds = pVehicle.pTransmission.upshiftSpeeds,
downshiftSpeeds = pVehicle.pTransmission.downshiftSpeeds,
initialGear = pVehicle.pTransmission.initialGear,
wheelRadius = pVehicle.pRrPartialWheel.R0) annotation(
choicesAllMatching = true,
Dialog(group = "Plant Models"),
Placement(transformation(origin = {-40, -10}, extent = {{-10, -10}, {10, 10}}))) constrainedby VehicleInterfaces.Transmissions.Interfaces.Base "Transmission subsystem";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
within BobLib.Experiments.Standards.Templates.FourPost;

model FourPostSim_EVBatInvMotDiff_DWBCStabar_DWBCStabar

extends BaseFourPostSim(
redeclare record VehicleRecord = BobLib.Records.VehicleDefn.EVBatInvMotDiff_DWBCStabar_DWBCStabarRecord,
redeclare model FrAxleModel = BobLib.Chassis.Suspension.FrAxleDW_BC_Stabar,
redeclare model RrAxleModel = BobLib.Chassis.Suspension.RrAxleDW_BC_Stabar,
frAxleDW(
pStabar = pFrStabar
),
pFrStabar(
leftArmEnd = pVehicle.pFrStabar.leftArmEnd,
leftBarEnd = pVehicle.pFrStabar.leftBarEnd,
barRate = 0
),
rrAxleDW(
pStabar = pRrStabar
),
pRrStabar(
leftArmEnd = pVehicle.pRrStabar.leftArmEnd,
leftBarEnd = pVehicle.pRrStabar.leftBarEnd,
barRate = 0
)
);
annotation(
Documentation(info = "<html>
<p>
Generated four-post template <code>FourPostSim_EVBatInvMotDiff_DWBCStabar_DWBCStabar</code> binds the selected vehicle record and axle architecture.
</p>
</html>"));
end FourPostSim_EVBatInvMotDiff_DWBCStabar_DWBCStabar;
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ FourPostSim_DWBC_DWBCStabar
FourPostSim_DWBCStabar_DWDirect
FourPostSim_DWBCStabar_DWBC
FourPostSim_DWBCStabar_DWBCStabar
FourPostSim_EVBatInvMotDiff_DWBCStabar_DWBCStabar
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,20 @@ partial model BaseVehicleSim
eta_reg = pVehicle.pMotor.eta_reg,
w_eps = pVehicle.pMotor.w_eps,
reverseLaunch = pVehicle.pMotor.reverseLaunch,
useTorqueTable = pVehicle.pMotor.useTorqueTable,
torqueTable = pVehicle.pMotor.torqueTable,
rotorJ = pVehicle.pMotor.rotorJ) annotation(
choicesAllMatching = true,
Dialog(tab = "Subsystems", group = "Plant Models"),
Placement(transformation(origin = {-79, -10.3334}, extent = {{-10, -10}, {10, 10}}, rotation = -180))) constrainedby VehicleInterfaces.ElectricDrives.Interfaces.Base "Traction motor subsystem";

replaceable BobLib.Transmissions.FixedRatioTransmission transmission(gearRatio = pVehicle.pDriveline.finalDriveRatio) annotation(
replaceable BobLib.Transmissions.SpeedScheduledTransmission transmission(
nGears = pVehicle.pTransmission.nGears,
gearRatios = pVehicle.pTransmission.gearRatios,
upshiftSpeeds = pVehicle.pTransmission.upshiftSpeeds,
downshiftSpeeds = pVehicle.pTransmission.downshiftSpeeds,
initialGear = pVehicle.pTransmission.initialGear,
wheelRadius = pVehicle.pRrPartialWheel.R0) annotation(
choicesAllMatching = true,
Dialog(tab = "Subsystems", group = "Plant Models"),
Placement(transformation(origin = {-40, -10}, extent = {{-10, -10}, {10, 10}}))) constrainedby VehicleInterfaces.Transmissions.Interfaces.Base "Transmission subsystem";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ model VehicleSim_EVBatInvMotDiff_DWBCStabar_DWBCStabar
pFrStabar(
leftArmEnd = pVehicle.pFrStabar.leftArmEnd,
leftBarEnd = pVehicle.pFrStabar.leftBarEnd,
barRate = pVehicle.pFrStabar.barRate),
barRate = pVehicle.pFrStabar.barRate
),
pRrStabar(
leftArmEnd = pVehicle.pRrStabar.leftArmEnd,
leftBarEnd = pVehicle.pRrStabar.leftBarEnd,
barRate = pVehicle.pRrStabar.barRate),
barRate = pVehicle.pRrStabar.barRate
),
headless = headless,
initialLongitudinalVelocity = initialVel,
pVehicle = pVehicle));
pVehicle = pVehicle
)
);
end VehicleSim_EVBatInvMotDiff_DWBCStabar_DWBCStabar;
Loading