text
stringlengths
1
4.74k
code
stringlengths
69
637k
Check that road functions can be differentiated. Model to check that the road functions can be differentiated correctly
within VehicleInterfaces.Roads.Examples; model CheckFunctionDifferentiation_CircleRoads "Check that road functions can be differentiated" import Modelica.Mechanics.MultiBody.Frames; extends Modelica.Icons.Example; parameter SI.AngularAcceleration k=0.8 "Constant acceleration"; SI.Angle phi; SI.PathLength s; SI.Position r[3]; Real e_s[3]; Real e_n[3]; Real e_y[3]; Real T[3, 3]; SI.Velocity v[3]; SI.Acceleration a[3]; SI.AngularVelocity w[3]; SI.AngularAcceleration z[3]; Frames.Orientation R; inner Modelica.Mechanics.MultiBody.World world( enableAnimation=true, n={0,0,-1}) inner CircleRoad road( radius=1, width=0.2, mu=0.5) equation phi = (k/2)*time*time; s = road.radius*phi; r = road.position(s, 0); e_s = road.headingDirection(s, 0); e_n = road.normal(s, 0); e_y = cross(e_n, e_s); T = transpose([e_s, e_y, e_n]); R = Frames.from_T2(T, der(T)); // Velocity and acceleration v = der(r); a = der(v); // Angular velocity and angular acceleration w = Frames.angularVelocity2(R); z = der(w); end CheckFunctionDifferentiation_CircleRoads;
Check that road functions can be differentiated. Model to check that the road functions can be differentiated correctly.
within VehicleInterfaces.Roads.Examples; model CheckFunctionDifferentiation_FlatRoads "Check that road functions can be differentiated" import Modelica.Mechanics.MultiBody.Frames; extends Modelica.Icons.Example; parameter SI.Acceleration k=0.8 "Constant acceleration"; SI.PathLength s; SI.Position r[3]; Real e_s[3]; Real e_n[3]; Real e_y[3]; Real T[3, 3]; SI.Velocity v[3]; SI.Acceleration a[3]; SI.AngularVelocity w[3]; SI.AngularAcceleration z[3]; Frames.Orientation R; inner Modelica.Mechanics.MultiBody.World world( enableAnimation=true, n={0,0,-1}) inner FlatRoad road equation s = (k/2)*time*time; r = road.position(s, 0); e_s = road.headingDirection(s, 0); e_n = road.normal(s, 0); e_y = cross(e_n, e_s); T = transpose([e_s, e_y, e_n]); R = Frames.from_T2(T, der(T)); // Velocity and acceleration v = der(r); a = der(v); // Angular velocity and angular acceleration w = Frames.angularVelocity2(R); z = der(w); end CheckFunctionDifferentiation_FlatRoads;
Examples that demonstrate the usage of road models
within VehicleInterfaces.Roads; package Examples "Examples that demonstrate the usage of road models" extends Modelica.Icons.ExamplesPackage; end Examples;
Dummy wheel model to test contact point calculation of wheel within model CheckContactCalculation. A&nbsp;dummy wheel model used in test models to check the road definitions. Within this model, no tire force calculation is performed. Only kinematic relationships between wheel input <code>e_axis</code> (unit vector in direction of wheel axis) and <code>r_wheel</code> (wheel center position) and road definition are given.
within VehicleInterfaces.Roads.Examples.Utilities; model DummyTyre "Dummy wheel model to test contact point calculation of wheel within model CheckContactCalculation" import Modelica.Math.Vectors.normalize; parameter SI.Radius wheelRadius=1 "Radius of wheel"; input Real[3] e_axis "Unit vector in direction of wheel axis" input SI.Position[3] r_wheel "Position of center of wheel" output SI.Position[3] r_CP(start={0,-wheelRadius,0}) "Position vector to contact point of wheel with road, resolved in world frame"; output SI.Length penetrationDepth "Penetration depth of wheel with respect to road"; output Real mu "Friction coefficient"; // Auxiliary variables Real s(start=0); Real w(start=0); outer VehicleInterfaces.Roads.Interfaces.Base road; protected Real e_n[3] "Unit vector along road normal"; Real e_s[3] "Unit vector along road heading direction"; Real e_w[3] "Unit vector along road \"lateral\" direction"; Real e_CP[3] "Unit vector from wheel center to contact point, resolved in world frame"; SI.Position d_CP[3]; SI.Radius reducedRadius; equation r_CP = road.position(s, w); e_n = road.normal(s, w); e_s = road.headingDirection(s, w); e_w = cross(e_n, e_s); e_CP = normalize(e_n - (e_n*e_axis)*e_axis); d_CP = r_wheel - r_CP; /* The equation r_CP = r_wheel + (wheelRadius - penetrationDepth)*e_CP; or d_CP = reducedRadius*e_CP; is projected along e_n, e_s, e_w in order to eliminate the unknown penetrationDepth thus reducing the set of 3 non-linear equations to 2 non-linear equations. */ reducedRadius = e_n*d_CP/(e_n*e_CP); penetrationDepth = wheelRadius - reducedRadius; 0 = e_s*d_CP - reducedRadius*(e_s*e_CP); 0 = e_w*d_CP - reducedRadius*(e_w*e_CP); // Friction coefficient at contact point mu = road.frictionCoefficient(s, w); end DummyTyre;
Utility models for road examples
within VehicleInterfaces.Roads.Examples; package Utilities "Utility models for road examples" extends Modelica.Icons.UtilitiesPackage; end Utilities;
Base model for all roads. This function returns the road position vector w.r.t world at the road location (s,w).
within VehicleInterfaces.Roads.Interfaces; partial model Base "Base model for all roads" replaceable function position = Roads.Interfaces.positionBase "Get position vector at a road location" replaceable function trackOffset = Roads.Interfaces.trackOffsetBase "Get track offset at a road location" replaceable function normal = Roads.Interfaces.normalBase "Get road normal at a road location" replaceable function headingDirection = Roads.Interfaces.headingDirectionBase "Get heading direction at a road location" replaceable function frictionCoefficient = Roads.Interfaces.frictionCoefficientBase "Get friction coefficient at a road location" end Base;
Determine friction coefficient on road. Partial base model for friction coefficient at point on road. Extend this model appropriately to define final user model.
within VehicleInterfaces.Roads.Interfaces; partial function frictionCoefficientBase "Determine friction coefficient on road" extends Modelica.Icons.Function; input Real s=0 "Roads surface parameter 1 (usually arc length along road)"; input Real w=0 "Roads surface parameter 2 (usually lateral direction)"; output Real mu=1 "Roads friction coefficient at (s,w)"; end frictionCoefficientBase;
Determine unit heading direction on road. Partial base model for unit heading direction on road. Extend this model appropriately to define final user model.
within VehicleInterfaces.Roads.Interfaces; partial function headingDirectionBase "Determine unit heading direction on road" extends Modelica.Icons.Function; input Real s=0 "Roads surface parameter 1 (usually arc length along road)"; input Real w=0 "Roads surface parameter 2 (usually lateral direction)"; output Real e_s_0[3]={1,0,0} "Unit vector in direction of road heading at (s,w), resolved in world frame"; end headingDirectionBase;
Determine unit normal on road. Partial base model for unit normal on road. Extend this model appropriately to define final user model.
within VehicleInterfaces.Roads.Interfaces; partial function normalBase "Determine unit normal on road" extends Modelica.Icons.Function; input Real s=0 "Roads surface parameter 1 (usually arc length along road)"; input Real w=0 "Roads surface parameter 2 (usually lateral direction)"; output Real e_n_0[3]={0,0,1} "Unit normal of road at (s,w), resolved in world frame"; end normalBase;
Collection of interface definitions for roads
within VehicleInterfaces.Roads; package Interfaces "Collection of interface definitions for roads" extends Modelica.Icons.InterfacesPackage; end Interfaces;
Determine road position. Partial base model for road position. Extend this model appropriately to define final user model.
within VehicleInterfaces.Roads.Interfaces; partial function positionBase "Determine road position" extends Modelica.Icons.Function; input Real s=0 "Roads surface parameter 1 (usually arc length along road)"; input Real w=0 "Roads surface parameter 2 (usually lateral direction)"; output SI.Position r_0[3]=zeros(3) "Position vector from world frame to point on road at (s,w), resolved in world frame"; end positionBase;
Determine track offset from road centre line. Partial base model for track offset from road centre line. Extend this model appropriately to define final user model.
within VehicleInterfaces.Roads.Interfaces; partial function trackOffsetBase "Determine track offset from road centre line" extends Modelica.Icons.Function; input Real s=0 "Roads surface parameter 1 (usually arc length along road)"; input Real w=0 "Roads surface parameter 2 (usually lateral direction)"; output SI.Position trackOffset[3]=zeros(3) "Track offset vector from road centre line to desired trajectory point"; end trackOffsetBase;
Collection of internal material involving roads
within VehicleInterfaces.Roads; package Internal "Collection of internal material involving roads" extends Modelica.Icons.InternalPackage; end Internal;
Simple visualization of a road as parameterized surface. Object used for visualization of road surface. Road position evaluation is performed internally to enable correct visualization of the road surface. The road length and width can be given via parameters (see list below). The road visualization object consists of segments. Their number is dependent on the number of points along <em>s</em> and <em>w</em>.
within VehicleInterfaces.Roads.Internal; model VisualizeSimpleRoads "Simple visualization of a road as parameterized surface" parameter Integer ns(min=2) = 2 "Number of points along surface parameter 1"; parameter Integer nw(min=2) = 2 "Number of points along surface parameter 2"; extends Modelica.Mechanics.MultiBody.Visualizers.Advanced.Surface( final nu=ns, final nv=nw, redeclare final function surfaceCharacteristic = roadSurfaceCharacteristic ( final position=road.position, final s_min=s_min, final s_max=s_max, final w_min=w_min, final w_max=w_max)); parameter SI.Length s_min=0 "Minimum value of s"; parameter SI.Length s_max=1 "Maximum value of s"; parameter SI.Length w_min=-1 "Minimum value of w"; parameter SI.Length w_max=1 "Maximum value of w"; protected outer VehicleInterfaces.Roads.Interfaces.Base road; encapsulated function roadSurfaceCharacteristic import Modelica; import VehicleInterfaces; extends Modelica.Mechanics.MultiBody.Interfaces.partialSurfaceCharacteristic( final multiColoredSurface=false); input VehicleInterfaces.Roads.Interfaces.positionBase position; input Real s_min=0 "Minimum value of s"; input Real s_max=1 "Maximum value of s"; input Real w_min=-1 "Minimum value of w"; input Real w_max=1 "Maximum value of w"; protected Real s; Real w; Real r[3]; parameter Real ds = s_max - s_min "Length of one segment in s-direction"; parameter Real dw = w_max - w_min "Length of one segment in w-direction"; algorithm for j in 1:nv loop w := w_min + (j - 1)*dw/(nv - 1); for i in 1:nu loop s := s_min + (i - 1)*ds/(nu - 1); r := position(s, w); X[i, j] := r[1]; Y[i, j] := r[2]; Z[i, j] := r[3]; end for; end for; end roadSurfaceCharacteristic; end VisualizeSimpleRoads;
Empty transmission. Empty transmission model (just rigid connection between engine and driveline flange). Using this empty model in overall vehicle architecture the functionality of transmission can be eliminated.
within VehicleInterfaces.Transmissions; model NoTransmissions "Empty transmission" extends VehicleInterfaces.Icons.Transmission; extends VehicleInterfaces.Icons.Empty; extends Interfaces.Base; equation connect(engineFlange, drivelineFlange) end NoTransmissions;
Collection of transmission subsystem definitions
within VehicleInterfaces; package Transmissions "Collection of transmission subsystem definitions" extends Modelica.Icons.VariantsPackage; end Transmissions;
Simple power split device based on an ideal epicyclic gear. Simple power-split device based on an ideal epicyclic gear. No losses are included in this model.
within VehicleInterfaces.Transmissions; model PowerSplitDevice "Simple power split device based on an ideal epicyclic gear" extends Interfaces.BaseTwoInputTransmission; parameter Real ratio=100/50 "Number of ring_teeth/sun_teeth (e.g. ratio=100/50)"; Modelica.Mechanics.Rotational.Sensors.SpeedSensor outputSpeed Modelica.Mechanics.Rotational.Components.IdealPlanetary idealPlanetary( ratio=ratio) Modelica.Blocks.Sources.IntegerConstant currentGear(k=1) protected VehicleInterfaces.Interfaces.TransmissionBus transmissionBus VehicleInterfaces.Interfaces.TransmissionControlBus transmissionControlBus outer Modelica.Mechanics.MultiBody.World world; equation connect(outputSpeed.flange, drivelineFlange.flange) connect(controlBus.transmissionBus, transmissionBus) connect(idealPlanetary.ring, drivelineFlange.flange) connect(idealPlanetary.sun, engineFlange.flange) connect(idealPlanetary.carrier, motorFlange.flange) connect(controlBus.transmissionControlBus, transmissionControlBus) connect(currentGear.y, transmissionControlBus.currentGear) connect(outputSpeed.w, transmissionBus.outputSpeed) end PowerSplitDevice;
Simple fixed gear ratio, automatic transmission, no torque converter. A&nbsp;single gear transmission without a&nbsp;launch device that is based on the automatic transmission model interface definition.
within VehicleInterfaces.Transmissions; model SingleGearAutomaticTransmission "Simple fixed gear ratio, automatic transmission, no torque converter" extends VehicleInterfaces.Icons.Transmission; extends Interfaces.BaseAutomaticTransmission(includeMount=world.driveTrainMechanics3D); parameter Real gearRatio=4 "Gear ratio"; Modelica.Mechanics.Rotational.Components.IdealGear gear( ratio=gearRatio, useSupport=true) Modelica.Mechanics.MultiBody.Parts.Mounting1D mounting1D Modelica.Mechanics.Rotational.Sensors.SpeedSensor outputSpeed Modelica.Blocks.Sources.IntegerConstant currentGear(k=1) protected VehicleInterfaces.Interfaces.TransmissionBus transmissionBus VehicleInterfaces.Interfaces.TransmissionControlBus transmissionControlBus outer Modelica.Mechanics.MultiBody.World world; equation connect(mounting1D.flange_b,gear.support) connect(mounting1D.frame_a, transmissionMount) connect(gear.flange_b,outputSpeed.flange) connect(controlBus.transmissionBus, transmissionBus) connect(transmissionControlBus, controlBus.transmissionControlBus) connect(currentGear.y, transmissionControlBus.currentGear) connect(gear.flange_a, engineFlange.flange) connect(gear.flange_b, drivelineFlange.flange) connect(outputSpeed.w, transmissionBus.outputSpeed) end SingleGearAutomaticTransmission;
Simple fixed gear ratio, manual transmission, uses physical connectors. A&nbsp;single gear transmission based on the manual transmission model interface definition. Includes a clutch model and uses physical connections between the driver and transmission system for the clutch position and current gear number (although the gear number is ignored in this model.
within VehicleInterfaces.Transmissions; model SingleGearManualTransmission "Simple fixed gear ratio, manual transmission, uses physical connectors" extends VehicleInterfaces.Icons.Transmission; extends Interfaces.BaseManualTransmission( includeMount=world.driveTrainMechanics3D, includeManualShiftConnector=true, includeClutchPedal=true); parameter Real gearRatio=4 "Gear ratio"; Modelica.Mechanics.Rotational.Components.IdealGear gear( ratio=gearRatio, useSupport=true) Modelica.Mechanics.MultiBody.Parts.Mounting1D mounting1D Modelica.Mechanics.Rotational.Sensors.SpeedSensor outputSpeed VehicleInterfaces.Interfaces.ShiftOutput shiftOutput Modelica.Mechanics.Rotational.Components.Clutch clutch(fn_max=1) Modelica.Mechanics.Translational.Components.Fixed fixed Modelica.Mechanics.Translational.Sensors.ForceSensor forceSensor Modelica.Mechanics.Translational.Components.SpringDamper pedalSpring(c=1, d=1) Modelica.Blocks.Sources.BooleanExpression clutchLocked(y=clutch.locked) protected VehicleInterfaces.Interfaces.TransmissionBus transmissionBus VehicleInterfaces.Interfaces.TransmissionControlBus transmissionControlBus outer Modelica.Mechanics.MultiBody.World world; public Modelica.Blocks.Math.Gain normalise(k=1/clutch.fn_max) equation connect(mounting1D.flange_b,gear.support) connect(mounting1D.frame_a, transmissionMount) connect(gear.flange_b,outputSpeed.flange) connect(shiftConnector, shiftOutput.shiftConnector) connect(clutch.flange_b, gear.flange_a) connect(forceSensor.flange_a,fixed.flange) connect(clutchPedal, pedalSpring.flange_b) connect(pedalSpring.flange_a, forceSensor.flange_b) connect(clutchLocked.y, transmissionBus.clutchLocked) connect(controlBus.transmissionBus, transmissionBus) connect(clutch.flange_a, engineFlange.flange) connect(gear.flange_b, drivelineFlange.flange) connect(transmissionControlBus, controlBus.transmissionControlBus) connect(shiftOutput.gear, transmissionControlBus.currentGear) connect(forceSensor.f, normalise.u) connect(normalise.y, clutch.f_normalized) connect(outputSpeed.w, transmissionBus.outputSpeed) end SingleGearManualTransmission;
Transmissions Tutorial.
within VehicleInterfaces.Transmissions; class Tutorial "Transmissions Tutorial" extends Modelica.Icons.Information; end Tutorial;
Basic interface definition for a transmission. This partial model defines the common interfaces required for a&nbsp;transmission subsystem. See the <a href=\"modelica://VehicleInterfaces.Transmissions\">documentation</a> and <a href=\"modelica://VehicleInterfaces.Transmissions.Tutorial\">tutorial</a> for more information.
within VehicleInterfaces.Transmissions.Interfaces; partial model Base "Basic interface definition for a transmission" parameter Boolean usingMultiBodyEngine=false "= true, if connecting to a MultiBody engine" parameter Boolean usingMultiBodyDriveline=false "= true, if connecting to a MultiBody driveline" protected parameter Boolean includeMount=false "Include the transmission mount connection"; parameter Boolean includeDrivelineBearing=false "Include the driveline bearing"; parameter Boolean includeEngineBearing=false "Include the engine bearing"; public Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing engineFlange( final includeBearingConnector=includeEngineBearing or usingMultiBodyEngine) "Connection to the engine" Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing drivelineFlange( final includeBearingConnector=includeDrivelineBearing or usingMultiBodyDriveline) "Connection to the driveline" Modelica.Mechanics.MultiBody.Interfaces.Frame_a transmissionMount if includeMount "Transmission mount connection (optional)" VehicleInterfaces.Interfaces.ControlBus controlBus "Control signal bus" Mechanics.MultiBody.MultiBodyEnd end_1( final includeBearingConnector=includeEngineBearing or usingMultiBodyEngine) Mechanics.MultiBody.MultiBodyEnd end_2( final includeBearingConnector=includeDrivelineBearing or usingMultiBodyDriveline) equation connect(end_1.flange, engineFlange) connect(end_2.flange, drivelineFlange) end Base;
Interface definition for an automatic transmission. This partial model defines the interfaces required for an automatic transmission model within the VehicleInterfaces package. See the <a href=\"modelica://VehicleInterfaces.Transmissions\">documentation</a> and <a href=\"modelica://VehicleInterfaces.Transmissions.Tutorial\">tutorial</a> for more information.
within VehicleInterfaces.Transmissions.Interfaces; partial model BaseAutomaticTransmission "Interface definition for an automatic transmission" extends Base; end BaseAutomaticTransmission;
Interface definition for a manual transmission. This partial model defines the interfaces required for a&nbsp;manual transmission model within the VehicleInterfaces package. See the <a href=\"modelica://VehicleInterfaces.Transmissions\">documentation</a> and <a href=\"modelica://VehicleInterfaces.Transmissions.Tutorial\">tutorial</a> for more information.
within VehicleInterfaces.Transmissions.Interfaces; partial model BaseManualTransmission "Interface definition for a manual transmission" extends Base; protected parameter Boolean includeManualShiftConnector=false "Include the manual shift connection"; parameter Boolean includeClutchPedal=false "Include the clutch pedal connection"; public Modelica.Mechanics.Translational.Interfaces.Flange_b clutchPedal if includeClutchPedal "Clutch pedal connection (optional)" VehicleInterfaces.Interfaces.ShiftConnector shiftConnector if includeManualShiftConnector "Manual shift selector connection (optional)" end BaseManualTransmission;
Interface definition for a transmission with two input shafts. This partial model defines the interfaces required for a transmission model that has two input shafts (such as a power-split device) within the VehicleInterfaces package. See the <a href=\"modelica://VehicleInterfaces.Transmissions\">documentation</a> and <a href=\"modelica://VehicleInterfaces.Transmissions.Tutorial\">tutorial</a> for more information.
within VehicleInterfaces.Transmissions.Interfaces; model BaseTwoInputTransmission "Interface definition for a transmission with two input shafts" extends Base; parameter Boolean usingMultiBodyMotor=false "= true, if connecting to a MultiBody motor" protected parameter Boolean includeMotorBearing=false "Include the motor bearing connection"; public Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing motorFlange( final includeBearingConnector=includeMotorBearing or usingMultiBodyMotor) "Connection to the electric machine" Mechanics.MultiBody.MultiBodyEnd end_3( final includeBearingConnector=includeMotorBearing or usingMultiBodyMotor) equation connect(end_3.flange, motorFlange) end BaseTwoInputTransmission;
Collection of interface definitions for transmission
within VehicleInterfaces.Transmissions; package Interfaces "Collection of interface definitions for transmission" extends Modelica.Icons.InterfacesPackage; end Interfaces;
Collection of internal material involving transmission
within VehicleInterfaces.Transmissions; package Internal "Collection of internal material involving transmission" extends Modelica.Icons.InternalPackage; end Internal;