Basic interface for an energy storage device. This partial model defines the interfaces required for an electrical energy
storage subsystem. Additionally, the ground is connected to the connector
pin_n. It can be disabled when includeGround=false.

within VehicleInterfaces.EnergyStorage.Interfaces;
partial model Base "Basic interface for an energy storage device"
  parameter Boolean includeGround=false
    "Include inner electrical ground at pin_n"
  parameter Boolean includeHeatPort = false "Include the battery heat port"
  parameter Boolean usingMultiBodyChassis=false
    "Include secondary ground node on the right port"

  VehicleInterfaces.Interfaces.ControlBus controlBus if not usingMultiBodyChassis
    "Control signal bus"
  Modelica.Electrical.Analog.Interfaces.PositivePin pin_p
    "Positive electrical pin"
  Modelica.Electrical.Analog.Interfaces.NegativePin pin_n
    "Negative electrical pin"
  Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort if includeHeatPort
    "Conditional port for exhaust heat flow"
protected
  Modelica.Electrical.Analog.Basic.Ground ground if includeGround
    "Conditional electrical ground"

equation
  connect(ground.p, pin_n)
end Base;


within VehicleInterfaces.EnergyStorage;
package Interfaces "Collection of interface definitions for energy storage"
  extends Modelica.Icons.InterfacesPackage;
end Interfaces;


Simple engine model with torque proportional to accelerator pedal position. A simple engine model with flywheel and where the torque output is
proportional to the accelerator pedal position. This engine model uses
a drive-by-wire accelerator, i.e. the accelerator pedal position
is read from the control bus.

within VehicleInterfaces.Engines;
model MinimalEngine
  "Simple engine model with torque proportional to accelerator pedal position"

  extends VehicleInterfaces.Icons.Engine;
  extends Interfaces.Base(
    includeMount=world.driveTrainMechanics3D,
    includeAccessoriesBearing=world.driveTrainMechanics3D);

  parameter SI.AngularVelocity engineSpeed_start(displayUnit="rev/min") = 104.7197551196598
    "Initial engine speed";
  parameter SI.Torque requestedTorque=50
    "Engine torque = requested_torque*accelerator_pedal_position";
  parameter SI.Inertia flywheelInertia=0.08
    "Flywheel inertia";
  parameter Modelica.Mechanics.MultiBody.Types.Axis axisOfRotation={1,0,0}
    "Axis of rotation of engine resolved in engineMount";

  Modelica.Mechanics.MultiBody.Parts.Rotor1D flywheel(
    J=flywheelInertia,
    n=axisOfRotation,
    a(fixed=false),
    phi(fixed=false),
    w(fixed=true, start=engineSpeed_start))
  Modelica.Mechanics.Rotational.Sources.Torque engine(useSupport=true)
  Modelica.Mechanics.Rotational.Sensors.SpeedSensor engineSpeed
  Modelica.Mechanics.Rotational.Sensors.TorqueSensor engineTorque
  Modelica.Mechanics.Rotational.Sensors.PowerSensor enginePower
  Modelica.Blocks.Math.Gain gain(k=requestedTorque)
  Modelica.Mechanics.MultiBody.Parts.Mounting1D mounting1D(n=axisOfRotation)
protected
  VehicleInterfaces.Interfaces.EngineBus engineBus
  VehicleInterfaces.Interfaces.DriverBus driverBus
  outer Modelica.Mechanics.MultiBody.World world;
equation
  connect(engine.flange,   flywheel.flange_a)
  connect(flywheel.flange_b,engineSpeed.flange)
  connect(flywheel.flange_b, engineTorque.flange_a)
  connect(engineTorque.flange_b, enginePower.flange_a)
  connect(controlBus.engineBus, engineBus)
  connect(controlBus.driverBus, driverBus)
  connect(gain.y, engine.tau)
  connect(flywheel.frame_a, engineMount)
  connect(mounting1D.flange_b,engine.support)
  connect(mounting1D.frame_a, engineMount)
  connect(gain.u, driverBus.acceleratorPedalPosition)
  connect(enginePower.flange_b, transmissionFlange.flange)
  connect(flywheel.flange_a, accessoryFlange.flange)
  connect(accessoryFlange.bearingFrame, mounting1D.frame_a)
  connect(engineSpeed.w, engineBus.speed)
end MinimalEngine;


Simple engine model with torque proportional to accelerator pedal position, uses accelerator pedal connection. A simple engine model with flywheel and where the torque output
is proportional to the accelerator pedal position. This engine model
uses the physical connection between the driver and the engine for
the accelerator pedal.

within VehicleInterfaces.Engines;
model MinimalEngineUsingPedal
  "Simple engine model with torque proportional to accelerator pedal position, uses accelerator pedal connection"

  extends VehicleInterfaces.Icons.Engine;
  extends Interfaces.Base(
    includeMount=world.driveTrainMechanics3D,
    includeAcceleratorPedal=true,
    includeAccessoriesBearing=world.driveTrainMechanics3D);

  parameter SI.AngularVelocity engineSpeed_start(displayUnit="rev/min") = 104.7197551196598
    "Initial engine speed";
  parameter SI.Force pedalPositionToTorque = 50
    "Engine torque = pedalPositionToTorque*accelerator_pedal_position";
  parameter SI.Inertia flywheelInertia = 0.08 "Flywheel inertia";
  parameter Modelica.Mechanics.MultiBody.Types.Axis axisOfRotation = {1,0,0}
    "Axis of rotation resolved in engineMount";

  Modelica.Mechanics.MultiBody.Parts.Rotor1D flywheel(
    J=flywheelInertia,
    n=axisOfRotation,
    a(fixed=false),
    phi(fixed=false),
    w(fixed=true, start=engineSpeed_start))
  Modelica.Mechanics.Rotational.Sources.Torque engine(useSupport=true)
  Modelica.Mechanics.Rotational.Sensors.SpeedSensor engineSpeed
  Modelica.Mechanics.Rotational.Sensors.TorqueSensor engineTorque
  Modelica.Mechanics.Rotational.Sensors.PowerSensor enginePower
  Modelica.Blocks.Math.Gain gain(k(unit="N")=pedalPositionToTorque)
  Modelica.Mechanics.MultiBody.Parts.Mounting1D mounting1D(n=axisOfRotation)
  Modelica.Mechanics.Translational.Sensors.PositionSensor
    acceleratorPedalPosition
protected
  VehicleInterfaces.Interfaces.EngineBus engineBus
  outer Modelica.Mechanics.MultiBody.World world;
equation
  connect(engine.flange, flywheel.flange_a)
  connect(flywheel.flange_b, engineSpeed.flange)
  connect(flywheel.flange_b, engineTorque.flange_a)
  connect(engineTorque.flange_b, enginePower.flange_a)
  connect(gain.y, engine.tau)
  connect(flywheel.frame_a, engineMount)
  connect(mounting1D.flange_b, engine.support)
  connect(mounting1D.frame_a, engineMount)
  connect(acceleratorPedalPosition.flange, acceleratorPedal)
  connect(acceleratorPedalPosition.s, gain.u)
  connect(controlBus.engineBus, engineBus)
  connect(flywheel.flange_a, accessoryFlange.flange)
  connect(enginePower.flange_b, transmissionFlange.flange)
  connect(accessoryFlange.bearingFrame, mounting1D.frame_a)
  connect(engineSpeed.w, engineBus.speed)
end MinimalEngineUsingPedal;


Empty engine. Empty engine model (just rigid connection between accessory and transmission
flange). Using this empty model in overall vehicle architecture the
functionality of engine can be eliminated.

within VehicleInterfaces.Engines;
model NullEngine "Empty engine"
  extends VehicleInterfaces.Icons.Engine;
  extends VehicleInterfaces.Icons.Empty;
  extends Interfaces.Base;
equation
  connect(accessoryFlange, transmissionFlange)
end NullEngine;


within VehicleInterfaces;
package Engines "Collection of combustion engine subsystem definitions"
  extends Modelica.Icons.VariantsPackage;
end Engines;


Engines Tutorial.

within VehicleInterfaces.Engines;
class Tutorial "Engines Tutorial"
  extends Modelica.Icons.Information;
end Tutorial;


Basic interface definition for an engine. This partial model defines the interfaces required for an engine subsystem.
This class should be extended to form a particular engine model. See the
documentation and
tutorial
for more information.

within VehicleInterfaces.Engines.Interfaces;
partial model Base "Basic interface definition for an engine"

  parameter Boolean usingMultiBodyAccessories=false
    "= true, if connecting to a MultiBody accessories"
  parameter Boolean usingMultiBodyTransmission=false
    "= true, if connecting to a MultiBody transmission"
protected
  parameter Boolean includeAcceleratorPedal=false "Include the accelerator pedal connection";
  parameter Boolean includeMount=false "Include the engine mount connection";
  parameter Boolean includeTransmissionBearing=false "Include the transmission bearing";
  parameter Boolean includeAccessoriesBearing=false "Include the accessories bearing";

public
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing accessoryFlange(
    final includeBearingConnector=includeAccessoriesBearing or usingMultiBodyAccessories)
    "Connection for the engine accessories"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing transmissionFlange(
    final includeBearingConnector=includeTransmissionBearing or usingMultiBodyTransmission)
    "Connection to the transmission"
  Modelica.Mechanics.MultiBody.Interfaces.Frame_a engineMount
    if includeMount "Engine mount connection (optional)"
  Modelica.Mechanics.Translational.Interfaces.Flange_a acceleratorPedal
   if includeAcceleratorPedal "Accelerator pedal connection (optional)"
  VehicleInterfaces.Interfaces.ControlBus controlBus "Control signal bus"
  Mechanics.MultiBody.MultiBodyEnd end_1(final includeBearingConnector=
        includeAccessoriesBearing or usingMultiBodyAccessories)
  Mechanics.MultiBody.MultiBodyEnd end_2(final includeBearingConnector=
        includeTransmissionBearing or usingMultiBodyTransmission)
equation
  connect(end_2.flange, transmissionFlange)
  connect(end_1.flange, accessoryFlange)
end Base;


within VehicleInterfaces.Engines;
package Interfaces "Collection of interface definitions for engine"
  extends Modelica.Icons.InterfacesPackage;
end Interfaces;


within VehicleInterfaces.Engines;
package Internal "Collection of internal material involving engine"
  extends Modelica.Icons.InternalPackage;
end Internal;


Conventional automatic transmission vehicle. Example model architecture of a passenger car with an automatic transmission.
In this architecture variant the PowerTrain systems are rigidly mounted
to the chassis when MultiBody effects are included.

within VehicleInterfaces.Examples;
model ConventionalAutomaticVehicle
  "Conventional automatic transmission vehicle"
  extends Modelica.Icons.Example;

  replaceable Engines.MinimalEngine engine
    constrainedby VehicleInterfaces.Engines.Interfaces.Base
    "Engine subsystem"
  replaceable Transmissions.SingleGearAutomaticTransmission transmission
    constrainedby VehicleInterfaces.Transmissions.Interfaces.BaseAutomaticTransmission
    "Transmission subsystem"
  replaceable Chassis.MinimalChassis chassis
    constrainedby VehicleInterfaces.Chassis.Interfaces.TwoAxleBase
    "Chassis subsystem"
  replaceable Drivelines.MinimalDriveline driveline
    constrainedby VehicleInterfaces.Drivelines.Interfaces.TwoAxleBase
    "Driveline subsystem"
  replaceable Brakes.MinimalBrakes brakes
    constrainedby VehicleInterfaces.Brakes.Interfaces.TwoAxleBase
    "Brakes subsystem"
  replaceable Accessories.MinimalAccessories accessories
    constrainedby VehicleInterfaces.Accessories.Interfaces.Base
    "Accessories subsystem"
  replaceable DriverEnvironments.DriveByWireAutomatic driverEnvironment
    constrainedby VehicleInterfaces.DriverEnvironments.Interfaces.BaseAutomaticTransmission
    "Driver environment"
  inner replaceable Roads.FlatRoad road
    constrainedby VehicleInterfaces.Roads.Interfaces.Base
    "Road model"
  inner replaceable Atmospheres.ConstantAtmosphere atmosphere
    constrainedby VehicleInterfaces.Atmospheres.Interfaces.Base
    "Atmospheric model"
  inner replaceable Modelica.Mechanics.MultiBody.World world(
    enableAnimation=false,
    n={0,0,-1},
    driveTrainMechanics3D=false)
    constrainedby Modelica.Mechanics.MultiBody.World
    "Global co-ordinate system"
protected
  Interfaces.ControlBus controlBus "Control bus connector"
equation
  connect(accessories.engineFlange, engine.accessoryFlange)
  connect(engine.transmissionFlange, transmission.engineFlange)
  connect(transmission.drivelineFlange, driveline.transmissionFlange)
  connect(chassis.wheelHub_2, driveline.wheelHub_2)
  connect(driveline.wheelHub_4, chassis.wheelHub_4)
  connect(chassis.wheelHub_4, brakes.wheelHub_4)
  connect(brakes.wheelHub_2, chassis.wheelHub_2)
  connect(driveline.wheelHub_3, chassis.wheelHub_3)
  connect(chassis.wheelHub_1, driveline.wheelHub_1)
  connect(chassis.wheelHub_3, brakes.wheelHub_3)
  connect(chassis.wheelHub_1, brakes.wheelHub_1)
  connect(controlBus, engine.controlBus)
  connect(controlBus, transmission.controlBus)
  connect(controlBus, driveline.controlBus)
  connect(controlBus, chassis.controlBus)
  connect(controlBus, brakes.controlBus)
  connect(accessories.controlBus, controlBus)
  connect(controlBus, driverEnvironment.controlBus)
  connect(driveline.drivelineMount, chassis.chassisFrame)
  connect(transmission.transmissionMount, chassis.chassisFrame)
  connect(engine.engineMount, chassis.chassisFrame)
  connect(driverEnvironment.acceleratorPedal, engine.acceleratorPedal)
  connect(driverEnvironment.brakePedal, brakes.brakePedal)
  connect(driverEnvironment.steeringWheel, chassis.steeringWheel)
  connect(driverEnvironment.chassisFrame, chassis.chassisFrame)
end ConventionalAutomaticVehicle;


Conventional automatic transmission vehicle using separate driver and driver-interface components. Example model architecture of a passenger car with an automatic
transmission and a driver model that is defined separately from
the driverEnvironment. In this architecture variant the PowerTrain
systems are rigidly mounted to the chassis when MultiBody effects
are included.

within VehicleInterfaces.Examples;
model ConventionalAutomaticVehicleExternalDriver
  "Conventional automatic transmission vehicle using separate driver and driver-interface components"
  extends Modelica.Icons.Example;

  replaceable Engines.MinimalEngine engine
    constrainedby VehicleInterfaces.Engines.Interfaces.Base
    "Engine subsystem"
  replaceable Transmissions.SingleGearAutomaticTransmission transmission
    constrainedby VehicleInterfaces.Transmissions.Interfaces.BaseAutomaticTransmission
    "Transmission subsystem"
  replaceable Chassis.MinimalChassis chassis
    constrainedby VehicleInterfaces.Chassis.Interfaces.TwoAxleBase
    "Chassis subsystem"
  replaceable Drivelines.MinimalDriveline driveline
    constrainedby VehicleInterfaces.Drivelines.Interfaces.TwoAxleBase
    "Driveline subsystem"
  replaceable Brakes.MinimalBrakes brakes
    constrainedby VehicleInterfaces.Brakes.Interfaces.TwoAxleBase
    "Brakes subsystem"
  replaceable Accessories.MinimalAccessories accessories
    constrainedby VehicleInterfaces.Accessories.Interfaces.Base
    "Accessories subsystem"
  replaceable
    VehicleInterfaces.DriverEnvironments.DriveByWireAutomaticExternalDriver
    driverEnvironment constrainedby VehicleInterfaces.DriverEnvironments.Interfaces.BaseAutomaticTransmissionExternalDriver
    "Driver environment"
  replaceable Drivers.MinimalDriver driver
    constrainedby Drivers.Interfaces.Base
    "Driver model"
  inner replaceable Roads.FlatRoad road
    constrainedby VehicleInterfaces.Roads.Interfaces.Base
    "Road model"
  inner replaceable Atmospheres.ConstantAtmosphere atmosphere
    constrainedby VehicleInterfaces.Atmospheres.Interfaces.Base
    "Atmospheric model"
  inner replaceable Modelica.Mechanics.MultiBody.World world(
    enableAnimation=false,
    n={0,0,-1},
    driveTrainMechanics3D=false)
    constrainedby Modelica.Mechanics.MultiBody.World
    "Global co-ordinate system"
protected
  Interfaces.ControlBus controlBus "Control bus connector"
equation
  connect(accessories.engineFlange, engine.accessoryFlange)
  connect(engine.transmissionFlange, transmission.engineFlange)
  connect(transmission.drivelineFlange, driveline.transmissionFlange)
  connect(chassis.wheelHub_2, driveline.wheelHub_2)
  connect(driveline.wheelHub_4, chassis.wheelHub_4)
  connect(chassis.wheelHub_4, brakes.wheelHub_4)
  connect(brakes.wheelHub_2, chassis.wheelHub_2)
  connect(driveline.wheelHub_3, chassis.wheelHub_3)
  connect(chassis.wheelHub_1, driveline.wheelHub_1)
  connect(chassis.wheelHub_3, brakes.wheelHub_3)
  connect(chassis.wheelHub_1, brakes.wheelHub_1)
  connect(controlBus, engine.controlBus)
  connect(controlBus, transmission.controlBus)
  connect(controlBus, driveline.controlBus)
  connect(controlBus, chassis.controlBus)
  connect(controlBus, brakes.controlBus)
  connect(accessories.controlBus, controlBus)
  connect(controlBus, driverEnvironment.controlBus)
  connect(driveline.drivelineMount, chassis.chassisFrame)
  connect(transmission.transmissionMount, chassis.chassisFrame)
  connect(engine.engineMount, chassis.chassisFrame)
  connect(driverEnvironment.acceleratorPedal, engine.acceleratorPedal)
  connect(driverEnvironment.brakePedal, brakes.brakePedal)
  connect(driverEnvironment.steeringWheel, chassis.steeringWheel)
  connect(driverEnvironment.chassisFrame, chassis.chassisFrame)

  connect(driverEnvironment.driverInterface, driver.driverInterface)
end ConventionalAutomaticVehicleExternalDriver;


Conventional manual transmission vehicle. Example model architecture of a passenger car with a manual
transmission. In this architecture variant the PowerTrain systems are
rigidly mounted to the chassis when MultiBody effects are included.

within VehicleInterfaces.Examples;
model ConventionalManualVehicle "Conventional manual transmission vehicle"
  extends Modelica.Icons.Example;

  replaceable Engines.MinimalEngineUsingPedal engine
    constrainedby VehicleInterfaces.Engines.Interfaces.Base
    "Engine subsystem"
  replaceable Transmissions.SingleGearManualTransmission transmission(
    clutch(
      phi_rel(fixed=true, start=0)))
    constrainedby VehicleInterfaces.Transmissions.Interfaces.BaseManualTransmission
    "Transmission subsystem"
  replaceable Chassis.MinimalChassis chassis(
    body(v(fixed=true)))
    constrainedby VehicleInterfaces.Chassis.Interfaces.TwoAxleBase
    "Chassis subsystem"
  replaceable Drivelines.MinimalDriveline driveline
    constrainedby VehicleInterfaces.Drivelines.Interfaces.TwoAxleBase
    "Driveline subsystem"
  replaceable Brakes.MinimalBrakesUsingPedal brakes
    constrainedby VehicleInterfaces.Brakes.Interfaces.TwoAxleBase
    "Brakes subsystem"
  replaceable Accessories.MinimalAccessories accessories
    constrainedby VehicleInterfaces.Accessories.Interfaces.Base
    "Accessory subsystem"
  replaceable DriverEnvironments.ConventionalManual driverEnvironment(
    acceleratorPosition(v(fixed=true)),
    brakePosition(v(fixed=true)),
    clutchPosition(v(fixed=true)))
    constrainedby VehicleInterfaces.DriverEnvironments.Interfaces.BaseManualTransmission
    "Driver environment"
  inner replaceable Roads.FlatRoad road
    constrainedby VehicleInterfaces.Roads.Interfaces.Base
    "Road model"
  inner replaceable Atmospheres.ConstantAtmosphere atmosphere
    constrainedby VehicleInterfaces.Atmospheres.Interfaces.Base
    "Atmospheric model"
  inner replaceable Modelica.Mechanics.MultiBody.World world(
    enableAnimation=false,
    n={0,0,-1},
    driveTrainMechanics3D=false)
    constrainedby Modelica.Mechanics.MultiBody.World
    "Global co-ordinate system"
protected
  Interfaces.ControlBus controlBus "Control bus connector"
equation
  connect(accessories.engineFlange, engine.accessoryFlange)
  connect(engine.transmissionFlange, transmission.engineFlange)
  connect(transmission.drivelineFlange, driveline.transmissionFlange)
  connect(chassis.wheelHub_2, driveline.wheelHub_2)
  connect(driveline.wheelHub_4, chassis.wheelHub_4)
  connect(chassis.wheelHub_4, brakes.wheelHub_4)
  connect(brakes.wheelHub_2, chassis.wheelHub_2)
  connect(driveline.wheelHub_3, chassis.wheelHub_3)
  connect(chassis.wheelHub_1, driveline.wheelHub_1)
  connect(chassis.wheelHub_3, brakes.wheelHub_3)
  connect(chassis.wheelHub_1, brakes.wheelHub_1)
  connect(controlBus, engine.controlBus)
  connect(controlBus, transmission.controlBus)
  connect(controlBus, driveline.controlBus)
  connect(controlBus, chassis.controlBus)
  connect(controlBus, brakes.controlBus)
  connect(accessories.controlBus, controlBus)
  connect(controlBus, driverEnvironment.controlBus)
  connect(driveline.drivelineMount, chassis.chassisFrame)
  connect(transmission.transmissionMount, chassis.chassisFrame)
  connect(engine.engineMount, chassis.chassisFrame)
  connect(driverEnvironment.acceleratorPedal, engine.acceleratorPedal)
  connect(driverEnvironment.brakePedal, brakes.brakePedal)
  connect(driverEnvironment.steeringWheel, chassis.steeringWheel)
  connect(driverEnvironment.chassisFrame, chassis.chassisFrame)
  connect(driverEnvironment.shiftConnector, transmission.shiftConnector)
  connect(driverEnvironment.clutchPedal, transmission.clutchPedal)
end ConventionalManualVehicle;


Extension of ConventionalAutomaticVehicle demonstrating the data dictionary. Example model architecture of a passenger car with an automatic
transmission. Based on
ConventionalAutomaticVehicle
this example shows how the DataDictionary can be used.

within VehicleInterfaces.Examples;
model ConventionalVehicle_AltNames
  "Extension of ConventionalAutomaticVehicle demonstrating the data dictionary"
  extends ConventionalAutomaticVehicle;
  replaceable DataDictionaries.MinimalExample dataDictionary
    constrainedby DataDictionaries.Interfaces.Base
    "Data dictionary"
equation
  connect(dataDictionary.controlBus, controlBus)
end ConventionalVehicle_AltNames;


A conventional front-wheel drive manual transmission vehicle including the powertrain mounting systems. Example model architecture of a front wheel drive passenger car with
an automatic transmission. In this architecture variant the PowerTrain
systems can be elastically mounted in the chassis when MultiBody effects
are included.

within VehicleInterfaces.Examples;
model FrontWheelDriveManualVehicle
  "A conventional front-wheel drive manual transmission vehicle including the powertrain mounting systems"
  extends Modelica.Icons.Example;

  replaceable Engines.MinimalEngineUsingPedal engine
    constrainedby VehicleInterfaces.Engines.Interfaces.Base
    "Engine subsystem"
  replaceable Transmissions.SingleGearManualTransmission transmission(
    clutch(
      phi_rel(fixed=true)))
    constrainedby VehicleInterfaces.Transmissions.Interfaces.BaseManualTransmission
    "Transmission subsystem"
  replaceable Chassis.MinimalChassis3 chassis(
    constraint(v(fixed=true)))
    constrainedby VehicleInterfaces.Chassis.Interfaces.TwoAxleBase
    "Chassis subsystem"
  replaceable Drivelines.MinimalDriveline driveline(
    usingMultiBodyChassis=true)
    constrainedby VehicleInterfaces.Drivelines.Interfaces.TwoAxleBase
    "Driveline subsystem"
  replaceable Brakes.MinimalBrakesUsingPedal brakes(
    usingMultiBodyChassis=true)
    constrainedby VehicleInterfaces.Brakes.Interfaces.TwoAxleBase
    "Brakes subsystem"
  replaceable Accessories.MinimalAccessories accessories
    constrainedby VehicleInterfaces.Accessories.Interfaces.Base
    "Accessories subsystem"
  replaceable DriverEnvironments.ConventionalManual driverEnvironment(
    acceleratorPosition(v(fixed=true)),
    clutchPosition(v(fixed=true)),
    brakePosition(v(fixed=true)))
    constrainedby VehicleInterfaces.DriverEnvironments.Interfaces.BaseManualTransmission
    "Driver environment"
  replaceable PowertrainMounts.ThreeSystemRigidMount powertrainMounts
    constrainedby PowertrainMounts.Interfaces.TripleSystemMount
    "Powertrain mounting system"
  inner replaceable Roads.FlatRoad road
    constrainedby VehicleInterfaces.Roads.Interfaces.Base
    "Road models"
  inner replaceable Atmospheres.ConstantAtmosphere atmosphere
    constrainedby VehicleInterfaces.Atmospheres.Interfaces.Base
    "Atmospheric model"
  inner replaceable Modelica.Mechanics.MultiBody.World world(
    enableAnimation=false,
    n={0,0,-1},
    driveTrainMechanics3D=true)
    constrainedby Modelica.Mechanics.MultiBody.World
    "Global co-ordinate system"
protected
  Interfaces.ControlBus controlBus "Control bus connector"
equation
  connect(accessories.engineFlange, engine.accessoryFlange)
  connect(engine.transmissionFlange, transmission.engineFlange)
  connect(transmission.drivelineFlange, driveline.transmissionFlange)
  connect(chassis.wheelHub_2, driveline.wheelHub_2)
  connect(driveline.wheelHub_4, chassis.wheelHub_4)
  connect(chassis.wheelHub_4, brakes.wheelHub_4)
  connect(brakes.wheelHub_2, chassis.wheelHub_2)
  connect(driveline.wheelHub_3, chassis.wheelHub_3)
  connect(chassis.wheelHub_1, driveline.wheelHub_1)
  connect(chassis.wheelHub_3, brakes.wheelHub_3)
  connect(chassis.wheelHub_1, brakes.wheelHub_1)
  connect(controlBus, engine.controlBus)
  connect(controlBus, transmission.controlBus)
  connect(controlBus, driveline.controlBus)
  connect(controlBus, chassis.controlBus)
  connect(controlBus, brakes.controlBus)
  connect(accessories.controlBus, controlBus)
  connect(controlBus, driverEnvironment.controlBus)
  connect(driverEnvironment.acceleratorPedal, engine.acceleratorPedal)
  connect(driverEnvironment.clutchPedal, transmission.clutchPedal)
  connect(driverEnvironment.shiftConnector, transmission.shiftConnector)
  connect(driverEnvironment.brakePedal, brakes.brakePedal)
  connect(driverEnvironment.steeringWheel, chassis.steeringWheel)
  connect(driverEnvironment.chassisFrame, chassis.chassisFrame)
  connect(powertrainMounts.chassisFrame, chassis.chassisFrame)
  connect(engine.engineMount, powertrainMounts.mount_1)
  connect(transmission.transmissionMount, powertrainMounts.mount_2)
  connect(driveline.drivelineMount, powertrainMounts.mount_3)
end FrontWheelDriveManualVehicle;


Collection of vehicle model examples

within VehicleInterfaces;
package Examples "Collection of vehicle model examples"
  extends Modelica.Icons.ExamplesPackage;
end Examples;


Basic model for a four wheeled vehicle, requires powertrain components. Base model architecture of a passenger car that can be extended to
add any type of powertrain. In this architecture variant the Driveline
subsystem is rigidly mounted to the chassis when MultiBody effects are
included.

within VehicleInterfaces.Examples;
partial model PartialVehicle
  "Basic model for a four wheeled vehicle, requires powertrain components"
  extends Modelica.Icons.Example;

  replaceable Chassis.MinimalChassis chassis
    constrainedby VehicleInterfaces.Chassis.Interfaces.TwoAxleBase
    "Chassis subsystem"
  replaceable Drivelines.MinimalDriveline driveline
    constrainedby VehicleInterfaces.Drivelines.Interfaces.TwoAxleBase
    "Driveline subsystem"
  replaceable Brakes.MinimalBrakes brakes
    constrainedby VehicleInterfaces.Brakes.Interfaces.TwoAxleBase
    "Brakes subsystem"
  replaceable DriverEnvironments.DriveByWireAutomatic driverEnvironment
    constrainedby VehicleInterfaces.DriverEnvironments.Interfaces.BaseAutomaticTransmission
    "Driver environment"
  inner replaceable Roads.FlatRoad road
    constrainedby VehicleInterfaces.Roads.Interfaces.Base
    "Road model"
  inner replaceable Atmospheres.ConstantAtmosphere atmosphere
    constrainedby VehicleInterfaces.Atmospheres.Interfaces.Base
    "Atmospheric model"
  inner replaceable Modelica.Mechanics.MultiBody.World world(
    enableAnimation=false,
    n={0,0,-1},
    driveTrainMechanics3D=false)
    constrainedby Modelica.Mechanics.MultiBody.World
    "Global co-ordinate system"
protected
  Interfaces.ControlBus controlBus "Control bus connector"
equation
  connect(chassis.wheelHub_2, driveline.wheelHub_2)
  connect(driveline.wheelHub_4, chassis.wheelHub_4)
  connect(chassis.wheelHub_4, brakes.wheelHub_4)
  connect(brakes.wheelHub_2, chassis.wheelHub_2)
  connect(driveline.wheelHub_3, chassis.wheelHub_3)
  connect(chassis.wheelHub_1, driveline.wheelHub_1)
  connect(chassis.wheelHub_3, brakes.wheelHub_3)
  connect(chassis.wheelHub_1, brakes.wheelHub_1)
  connect(controlBus, driveline.controlBus)
  connect(controlBus, chassis.controlBus)
  connect(controlBus, brakes.controlBus)
  connect(controlBus, driverEnvironment.controlBus)
  connect(driveline.drivelineMount, chassis.chassisFrame)
  connect(driverEnvironment.brakePedal, brakes.brakePedal)
  connect(driverEnvironment.steeringWheel, chassis.steeringWheel)
  connect(driverEnvironment.chassisFrame, chassis.chassisFrame)
end PartialVehicle;


Power-split hybrid vehicle model. Example model architecture of a passenger car with a power-split
hybrid powertrain. In this architecture variant the PowerTrain systems are
rigidly mounted to the chassis when MultiBody effects are included.

within VehicleInterfaces.Examples;
model PowerSplitHybrid "Power-split hybrid vehicle model"
  extends VehicleInterfaces.Examples.PartialVehicle(chassis(body(v(fixed=true))));
  replaceable Engines.MinimalEngine engine(
    flywheel(phi(fixed=true)))
    constrainedby VehicleInterfaces.Engines.Interfaces.Base
    "Engine subsystem"
  replaceable Accessories.MinimalAccessories accessories
    constrainedby VehicleInterfaces.Accessories.Interfaces.Base
    "Accessories subsystem"
  replaceable VehicleInterfaces.ElectricDrives.SimpleMotorDC motor1(
    inductor(
      i(start=0, fixed=true)))
    constrainedby ElectricDrives.Interfaces.BaseDCMachine "Electric Motor 1"
  replaceable VehicleInterfaces.ElectricDrives.SimpleMotorDC motor2(
    inductor(
      i(start=0, fixed=true)))
    constrainedby ElectricDrives.Interfaces.BaseDCMachine "Electric Motor 2"
  replaceable Transmissions.PowerSplitDevice powerSplitDevice
    constrainedby Transmissions.Interfaces.BaseTwoInputTransmission
    "Power-split device"
  replaceable EnergyStorage.Battery battery(V=1)
    constrainedby EnergyStorage.Interfaces.Base "Energy storage subsystem"
  Modelica.Electrical.Analog.Basic.Ground ground
equation
  connect(accessories.engineFlange, engine.accessoryFlange)
  connect(controlBus, engine.controlBus)
  connect(accessories.controlBus, controlBus)
  connect(driverEnvironment.acceleratorPedal, engine.acceleratorPedal)
  connect(motor2.shaft_b, driveline.transmissionFlange)
  connect(motor1.controlBus, controlBus)
  connect(motor2.controlBus, controlBus)
  connect(powerSplitDevice.drivelineFlange, driveline.transmissionFlange)
  connect(powerSplitDevice.motorFlange, motor1.shaft_b)
  connect(powerSplitDevice.engineFlange, engine.transmissionFlange)
  connect(powerSplitDevice.controlBus, controlBus)
  connect(battery.pin_p, motor1.pin_p)
  connect(battery.pin_n, motor1.pin_n)
  connect(battery.pin_p, motor2.pin_p)
  connect(battery.pin_n, motor2.pin_n)
  connect(ground.p, battery.pin_n)
  connect(battery.controlBus, controlBus.batteryBus)
  connect(engine.engineMount, chassis.chassisFrame)
  connect(powerSplitDevice.transmissionMount, chassis.chassisFrame)
end PowerSplitHybrid;


A conventional front-wheel drive automatic transmission vehicle with separate powertrain mounting system for the front axle and engine-transmission systems. Example model architecture of a rear wheel drive passenger car with
an automatic transmission. In this architecture variant the PowerTrain
systems can be elastically mounted in the chassis when MultiBody effects
are included.

within VehicleInterfaces.Examples;
model RearWheelDriveAutomaticVehicle
  "A conventional front-wheel drive automatic transmission vehicle with separate powertrain mounting system for the front axle and engine-transmission systems"
  extends Modelica.Icons.Example;

  replaceable Engines.MinimalEngine engine
    constrainedby VehicleInterfaces.Engines.Interfaces.Base
    "Engine subsystem"
  replaceable Transmissions.SingleGearAutomaticTransmission transmission
    constrainedby VehicleInterfaces.Transmissions.Interfaces.BaseAutomaticTransmission
    "Transmission subsystem"
  replaceable Chassis.MinimalChassis3 chassis
    constrainedby VehicleInterfaces.Chassis.Interfaces.TwoAxleBase
    "Chassis subsystem"
  replaceable Drivelines.MinimalDriveline driveline(
    usingMultiBodyChassis=true)
    constrainedby VehicleInterfaces.Drivelines.Interfaces.TwoAxleBase
    "Driveline subsystem"
  replaceable Brakes.MinimalBrakes brakes(usingMultiBodyChassis=true)
    constrainedby VehicleInterfaces.Brakes.Interfaces.TwoAxleBase
    "Brakes subsystem"
  replaceable Accessories.MinimalAccessories accessories
    constrainedby VehicleInterfaces.Accessories.Interfaces.Base
    "Accessories subsystem"
  replaceable DriverEnvironments.DriveByWireAutomaticExternalDriver driverEnvironment
    constrainedby VehicleInterfaces.DriverEnvironments.Interfaces.BaseAutomaticTransmissionExternalDriver
    "Driver environment"
  replaceable PowertrainMounts.TwoSystemRigidMount engineTransmissionMount
    constrainedby PowertrainMounts.Interfaces.DualSystemMount
    "Engine and Transmission mounting system"
  replaceable PowertrainMounts.SingleSystemRigidMount diffMount
    constrainedby PowertrainMounts.Interfaces.SingleSystemMount
    "Differential mounting system"
  replaceable Drivers.MinimalDriver driver
    constrainedby Drivers.Interfaces.Base
    "Driver model"
  inner replaceable Roads.FlatRoad road
    constrainedby VehicleInterfaces.Roads.Interfaces.Base
    "Road model"
  inner replaceable Atmospheres.ConstantAtmosphere atmosphere
    constrainedby VehicleInterfaces.Atmospheres.Interfaces.Base
    "Atmospheric model"
  inner replaceable Modelica.Mechanics.MultiBody.World world(
    enableAnimation=false,
    n={0,0,-1},
    driveTrainMechanics3D=false)
    constrainedby Modelica.Mechanics.MultiBody.World
    "Global co-ordinate system"
protected
  Interfaces.ControlBus controlBus "Control bus connector"
equation
  connect(accessories.engineFlange, engine.accessoryFlange)
  connect(engine.transmissionFlange, transmission.engineFlange)
  connect(transmission.drivelineFlange, driveline.transmissionFlange)
  connect(chassis.wheelHub_2, driveline.wheelHub_2)
  connect(driveline.wheelHub_4, chassis.wheelHub_4)
  connect(chassis.wheelHub_4, brakes.wheelHub_4)
  connect(brakes.wheelHub_2, chassis.wheelHub_2)
  connect(driveline.wheelHub_3, chassis.wheelHub_3)
  connect(chassis.wheelHub_1, driveline.wheelHub_1)
  connect(chassis.wheelHub_3, brakes.wheelHub_3)
  connect(chassis.wheelHub_1, brakes.wheelHub_1)
  connect(controlBus, engine.controlBus)
  connect(controlBus, transmission.controlBus)
  connect(controlBus, driveline.controlBus)
  connect(controlBus, chassis.controlBus)
  connect(controlBus, brakes.controlBus)
  connect(accessories.controlBus, controlBus)
  connect(controlBus, driverEnvironment.controlBus)
  connect(driverEnvironment.acceleratorPedal, engine.acceleratorPedal)
  connect(driverEnvironment.brakePedal, brakes.brakePedal)
  connect(driverEnvironment.steeringWheel, chassis.steeringWheel)
  connect(driverEnvironment.chassisFrame, chassis.chassisFrame)
  connect(engineTransmissionMount.chassisFrame, chassis.chassisFrame)
  connect(diffMount.chassisFrame, chassis.chassisFrame)
  connect(engineTransmissionMount.mount_2, transmission.transmissionMount)
  connect(engineTransmissionMount.mount_1, engine.engineMount)
  connect(diffMount.mount_1, driveline.drivelineMount)

  connect(driverEnvironment.driverInterface, driver.driverInterface)
end RearWheelDriveAutomaticVehicle;


Series hybrid vehicle model. Example model architecture of a passenger car with a series hybrid
powertrain. In this architecture variant the PowerTrain systems are
rigidly mounted to the chassis when MultiBody effects are included.

within VehicleInterfaces.Examples;
model SeriesHybrid "Series hybrid vehicle model"
  extends VehicleInterfaces.Examples.PartialVehicle(
    redeclare DriverEnvironments.DriveByWireAutomatic driverEnvironment(
      initialAccelRequest=0,
      finalAccelRequest=0.9,
      accelTime=2),
    chassis(
      body(v(fixed=true))));
  replaceable Engines.MinimalEngine engine(
    flywheel(phi(fixed=true)))
    constrainedby VehicleInterfaces.Engines.Interfaces.Base "Engine model"
  replaceable Accessories.MinimalAccessories accessories
    constrainedby VehicleInterfaces.Accessories.Interfaces.Base
    "Accessories model"
  replaceable VehicleInterfaces.ElectricDrives.SimpleMotorDC generator(
    inductor(i(start=0, fixed=true)))
    constrainedby ElectricDrives.Interfaces.BaseDCMachine
    "Generator subsystem"
  replaceable VehicleInterfaces.ElectricDrives.SimpleMotorDC driveMotor(
    inductor(i(start=0, fixed=true)))
    constrainedby ElectricDrives.Interfaces.BaseDCMachine
    "Traction motor subsystem"
  replaceable EnergyStorage.Battery battery(V=1)
    constrainedby EnergyStorage.Interfaces.Base
    "Energy storage subsystem"
  Modelica.Electrical.Analog.Basic.Ground ground
equation
  connect(controlBus, engine.controlBus)
  connect(accessories.controlBus, controlBus)
  connect(driverEnvironment.acceleratorPedal, engine.acceleratorPedal)
  connect(driveMotor.shaft_b, driveline.transmissionFlange)
  connect(generator.controlBus, controlBus)
  connect(driveMotor.controlBus, controlBus)
  connect(generator.shaft_b, engine.transmissionFlange)
  connect(battery.pin_p, generator.pin_p)
  connect(battery.pin_p, driveMotor.pin_p)
  connect(battery.pin_n, driveMotor.pin_n)
  connect(battery.pin_n, generator.pin_n)
  connect(battery.pin_n, ground.p)
  connect(battery.controlBus, controlBus.batteryBus)
  connect(accessories.engineFlange, engine.accessoryFlange)
  connect(engine.engineMount, chassis.chassisFrame)
end SeriesHybrid;


within VehicleInterfaces;
package Interfaces "Collection of general interface definitions"
  extends Modelica.Icons.InterfacesPackage;
end Interfaces;


Convert an integer signal to a position in the manual shift connector. Converts an integer signal in to positions on the intoGear
and crossGate sub-connectors of the ShiftConnector.

within VehicleInterfaces.Interfaces;
model ShiftInput
  "Convert an integer signal to a position in the manual shift connector"
  parameter Integer numberOfGears=5 "Number of forward gears";
  parameter SI.Distance crossGateDisplacement=0.1
    "Total distance across the gate";
  parameter SI.Distance intoGearDisplacement=0.1
    "Distance to move in to gear";
  ShiftConnector shiftConnector "Gear shift connection"
  Modelica.Blocks.Interfaces.IntegerInput gear "Gear number"
equation
  if gear == 0 then
    shiftConnector.crossGate.s = 0;
    shiftConnector.intoGear.s = 0;
  elseif gear == 1 then
    shiftConnector.crossGate.s = -crossGateDisplacement/2;
    shiftConnector.intoGear.s = intoGearDisplacement;
  elseif gear == 2 then
    shiftConnector.crossGate.s = -crossGateDisplacement/2;
    shiftConnector.intoGear.s = -intoGearDisplacement;
  elseif gear == 3 then
    shiftConnector.crossGate.s = 0;
    shiftConnector.intoGear.s = intoGearDisplacement;
  elseif gear == 4 then
    shiftConnector.crossGate.s = 0;
    shiftConnector.intoGear.s = -intoGearDisplacement;
  elseif gear == 5 then
    shiftConnector.crossGate.s = crossGateDisplacement/2;
    shiftConnector.intoGear.s = intoGearDisplacement;
  else
    //Reverse gear
    shiftConnector.crossGate.s = crossGateDisplacement/2;
    shiftConnector.intoGear.s = -intoGearDisplacement;
  end if;
end ShiftInput;


Convert a position in the manual shift connector to an integer value. Converts positions on the intoGear and crossGate
sub-connectors of the ShiftConnector into an integer gear signal.

within VehicleInterfaces.Interfaces;
model ShiftOutput
  "Convert a position in the manual shift connector to an integer value"
  parameter Integer numberOfGears=5 "Number of forward gears";
  parameter SI.Distance crossGateDisplacement=0.1
    "Total distance across the gate";
  parameter SI.Distance intoGearDisplacement=0.1
    "Distance to move in to gear";
  ShiftConnector shiftConnector "Gear shift connection"
  Modelica.Blocks.Interfaces.IntegerOutput gear "Gear number"
equation
  shiftConnector.crossGate.f = 0;
  shiftConnector.intoGear.f = 0;
  if shiftConnector.crossGate.s <= -0.9*crossGateDisplacement/2 then
    if shiftConnector.intoGear.s >= 0.9*intoGearDisplacement then
      gear = 1;
    else
      gear = 2;
    end if;
  elseif shiftConnector.crossGate.s >= 0.9*crossGateDisplacement/2 then
    if shiftConnector.intoGear.s >= 0.9*intoGearDisplacement then
      gear = 5;
    else
      gear = -1;
    end if;
  else
    if shiftConnector.intoGear.s >= 0.9*intoGearDisplacement then
      gear = 3;
    elseif shiftConnector.intoGear.s <= 0.9*intoGearDisplacement then
      gear = 4;
    else
      gear = 0;
    end if;
  end if;
end ShiftOutput;


within VehicleInterfaces.Interfaces;
package Internal "Internal class declarations - should not be used directly in any models (used to built up default menus for buses)"
  extends Modelica.Icons.InternalPackage;
end Internal;


within VehicleInterfaces;
package Mechanics "Collection of additional mechanical components"
  extends Modelica.Icons.Package;
end Mechanics;


Ends a MultiBody chain. This component is used to end a chain of multi-body components by applying
zero force and torque to the end of the chain. Uses the
FlangeWithBearing
connector where the flange connector has zero torque
applied to it and the bearingFrame can be optionally
included through the parameter includeBearingConnector.
If includeBearingConnector=true then zero force and torque
is applied to the bearingFrame.

within VehicleInterfaces.Mechanics.MultiBody;
model MultiBodyEnd "Ends a MultiBody chain"
  parameter Boolean includeBearingConnector=false
    "= true, if bearing frame connector is present, otherwise not present";

  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing flange(
      includeBearingConnector=includeBearingConnector)
    "Flange with zero force and torque applied"
protected
  Modelica.Mechanics.MultiBody.Forces.Internal.ZeroForceAndTorque
    zeroForceAndTorque if includeBearingConnector

public
  Modelica.Mechanics.Rotational.Sources.ConstantTorque zeroTorque1D(
    final tau_constant=0)
equation
  connect(zeroTorque1D.flange, flange.flange)
  connect(zeroForceAndTorque.frame_a, flange.bearingFrame)
end MultiBodyEnd;


within VehicleInterfaces.Mechanics;
package MultiBody "Collection of additional MultiBody components"
  extends Modelica.Icons.Package;
end MultiBody;


Ideal sensor to measure the rotation of a Flange. Measures a normalized angle in a 1D normalized rotational system.
Cannot be connected to components from the Modelica.Mechanics.Rotational library.

within VehicleInterfaces.Mechanics.NormalisedRotational;
model AngleSensor "Ideal sensor to measure the rotation of a Flange"
  extends Modelica.Icons.RoundSensor;

  Interfaces.Flange flange_a "flange to be measured"
  Modelica.Blocks.Interfaces.RealOutput phi
    "Absolute angle of flange as output signal"

equation
  phi = flange_a.phi;
  0 = flange_a.tau;
end AngleSensor;


within VehicleInterfaces.Mechanics;
package NormalisedRotational "Collection of normalized rotational mechanics"
  extends Modelica.Icons.Package;
end NormalisedRotational;


Applies a rotation to a Flange. Applies a normalized angle to a 1D normalized rotational system.
Cannot be connected to components from the Modelica.Mechanics.Rotational library.

within VehicleInterfaces.Mechanics.NormalisedRotational;
model Position "Applies a rotation to a Flange"

  parameter Boolean exact=true
    "True/false exact treatment/filtering the input signal";
  parameter SI.Frequency f_crit=50
    "If exact=false: critical frequency of filter to filter input signal"

  Interfaces.Flange flange_b "flange to be rotated"
  Modelica.Blocks.Interfaces.RealInput phi_ref "position to be applied"
  Types.NormalizedReal phi;
protected
  parameter Real w_crit=2*Modelica.Constants.pi*f_crit
    "critical frequency in [1/s]";
  constant Real af=1.3617 "Coefficient s   of Bessel filter";
  constant Real bf=0.6180 "Coefficient s*s of Bessel filter";

  Real w;
  Real a;
equation
  phi = flange_b.phi;

  w = der(phi);
  a = der(w);

  if exact then
    phi = phi_ref;
  else
    a = ((phi_ref - phi)*w_crit - af*w)*(w_crit/bf);
  end if;

initial equation
  if not exact then
    phi = phi_ref;
  end if;
end Position;


Applies a torque to a Flange. Applies a torque to a 1D normalized rotational system.
Cannot be connected to components from the Modelica.Mechanics.Rotational library.

within VehicleInterfaces.Mechanics.NormalisedRotational;
model Torque "Applies a torque to a Flange"

  Interfaces.Flange flange_b "Flange to be turned"
  Modelica.Blocks.Interfaces.RealInput tau "Torque to be applied"

equation
  tau = -flange_b.tau;
end Torque;


Collection of connector definitions

within VehicleInterfaces.Mechanics.NormalisedRotational;
package Interfaces "Collection of connector definitions"
  extends Modelica.Icons.InterfacesPackage;
end Interfaces;


Applies a force to a Flange. Applies a force to a 1D normalized translational system. Cannot be connected
to components from the Modelica.Mechanics.Translational library.

within VehicleInterfaces.Mechanics.NormalisedTranslational;
model Force "Applies a force to a Flange"

  Interfaces.Flange flange_b "Flange to be forced"
  Modelica.Blocks.Interfaces.RealInput force "Force to be applied"

equation
  force = -flange_b.f;
end Force;


within VehicleInterfaces.Mechanics;
package NormalisedTranslational "Collection of normalized translational mechanics"
  extends Modelica.Icons.Package;
end NormalisedTranslational;


Applies a position to a Flange. Applies a normalized position to a 1D normalized translational system.
Cannot be connected to components from the Modelica.Mechanics.Translational library.

within VehicleInterfaces.Mechanics.NormalisedTranslational;
model Position "Applies a position to a Flange"

  parameter Boolean exact=true
    "True/false exact treatment/filtering the input signal";
  parameter SI.Frequency f_crit=50
    "If exact=false: critical frequency of filter to filter input signal"

  Interfaces.Flange flange_b "flange to be positioned"
  Modelica.Blocks.Interfaces.RealInput position "position to be applied"

  Types.NormalizedReal s "Normalized position";
protected
  parameter Real w_crit=2*Modelica.Constants.pi*f_crit
    "Critical frequency in [1/s]";
  constant Real af=1.3617 "Coefficient s   of Bessel filter";
  constant Real bf=0.6180 "Coefficient s*s of Bessel filter";

  Real v;
  Real a;
equation
  s = flange_b.s;

  if exact then
    s = position;
    v = 0;
    a = 0;
  else
    v = der(s);
    a = der(v);
    a = ((position - s)*w_crit - af*v)*(w_crit/bf);
  end if;

initial equation
  if not exact then
    s = position;
  end if;
end Position;


Ideal sensor to measure the position of a Flange. Measures a normalized position in a 1D normalized translational system.
Cannot be connected to components from the Modelica.Mechanics.Translational library.

within VehicleInterfaces.Mechanics.NormalisedTranslational;
model PositionSensor "Ideal sensor to measure the position of a Flange"
  extends Modelica.Icons.RectangularSensor;

  Interfaces.Flange flange_a "Flange to be measured"
  Modelica.Blocks.Interfaces.RealOutput position
    "Absolute position of flange as output signal"

equation
  position = flange_a.s;
  0 = flange_a.f;
end PositionSensor;


Collection of connector definitions

within VehicleInterfaces.Mechanics.NormalisedTranslational;
package Interfaces "Collection of connector definitions"
  extends Modelica.Icons.InterfacesPackage;
end Interfaces;


within VehicleInterfaces;
package PowertrainMounts "Collection of powertrain mounts subsystem definition"
  extends Modelica.Icons.VariantsPackage;
end PowertrainMounts;


1 system rigid mount. Rigidly mounts one power train system such as the engine or transmission on
one supporting system, usually the chassis.

within VehicleInterfaces.PowertrainMounts;
model SingleSystemRigidMount "1 system rigid mount"
  extends Interfaces.SingleSystemMount;
  extends VehicleInterfaces.Icons.SingleMount;
  parameter SI.Position r_ChassisToMount1[3]={0,0,0}
    "Vector from chassis frame to mount_1 frame"

  Modelica.Mechanics.MultiBody.Parts.FixedTranslation chassisFrameToMount1(r=
        r_ChassisToMount1)
equation
  connect(chassisFrameToMount1.frame_a, chassisFrame)
  connect(chassisFrameToMount1.frame_b, mount_1)
end SingleSystemRigidMount;


3 system rigid mount. Rigidly mounts three power train systems such as the engine, transmission
and driveline on one supporting system, usually the chassis.

within VehicleInterfaces.PowertrainMounts;
model ThreeSystemRigidMount "3 system rigid mount"
  extends Interfaces.TripleSystemMount;
  extends VehicleInterfaces.Icons.MultipleMounts;
  parameter SI.Position r_ChassisToMount1[3]={0,0,0}
    "Vector from chassis frame to mount_1 frame"
  parameter SI.Position r_ChassisToMount2[3]={0,0,0}
    "Vector from chassis frame to mount_2 frame"
  parameter SI.Position r_ChassisToMount3[3]={0,0,0}
    "Vector from chassis frame to mount_3 frame"

  Modelica.Mechanics.MultiBody.Parts.FixedTranslation chassisFrameToMount1(r=
        r_ChassisToMount1, animation=false)
  Modelica.Mechanics.MultiBody.Parts.FixedTranslation chassisFrameToMount2(
      animation=false, r=r_ChassisToMount2)
  Modelica.Mechanics.MultiBody.Parts.FixedTranslation chassisFrameToMount3(
      animation=false, r=r_ChassisToMount3)
equation
  connect(chassisFrameToMount1.frame_a, chassisFrame)
  connect(chassisFrameToMount1.frame_b, mount_1)
  connect(chassisFrameToMount2.frame_b, mount_2)
  connect(chassisFrameToMount3.frame_b, mount_3)
  connect(chassisFrameToMount2.frame_a, chassisFrame)
  connect(chassisFrameToMount3.frame_a, chassisFrame)
end ThreeSystemRigidMount;


Powertrain Mounts Tutorial.

within VehicleInterfaces.PowertrainMounts;
class Tutorial "Powertrain Mounts Tutorial"
  extends Modelica.Icons.Information;
end Tutorial;


2 system rigid mount. Rigidly mounts two power train systems such as the engine and transmission
on one supporting system, usually the chassis.

within VehicleInterfaces.PowertrainMounts;
model TwoSystemRigidMount "2 system rigid mount"
  extends Interfaces.DualSystemMount;
  extends VehicleInterfaces.Icons.TwoMounts;
  parameter SI.Position r_ChassisToMount1[3]={0,0,0}
    "Vector from chassis frame to mount_1 frame"
  parameter SI.Position r_ChassisToMount2[3]={0,0,0}
    "Vector from chassis frame to mount_2 frame"

  Modelica.Mechanics.MultiBody.Parts.FixedTranslation chassisFrameToMount1(
    r=r_ChassisToMount1)
  Modelica.Mechanics.MultiBody.Parts.FixedTranslation chassisFrameToMount2(
    r=r_ChassisToMount2)
equation
  connect(chassisFrameToMount1.frame_a, chassisFrame)
  connect(chassisFrameToMount2.frame_b, mount_2)
  connect(chassisFrameToMount1.frame_b, mount_1)
  connect(chassisFrameToMount2.frame_a, chassisFrame)
end TwoSystemRigidMount;


Basic interface definition for a mounting system. This partial model defines the common interfaces required for
a mounting subsystem. See the
documentation
and
tutorial
for more information.

within VehicleInterfaces.PowertrainMounts.Interfaces;
partial model Base "Basic interface definition for a mounting system"

  Modelica.Mechanics.MultiBody.Interfaces.Frame_a chassisFrame
    "Chassis frame"
end Base;


Two powertrain subsystem mounting interface definition. This partial model defines the interfaces required for two powertrain
system mounting subsystem. This class should be extended to form
a particular powertrain mounting model. See the
documentation
and
tutorial
for more information.

within VehicleInterfaces.PowertrainMounts.Interfaces;
partial model DualSystemMount
  "Two powertrain subsystem mounting interface definition"
  extends Base;
  Modelica.Mechanics.MultiBody.Interfaces.Frame_b mount_1
    "Powertrain system 1"
  Modelica.Mechanics.MultiBody.Interfaces.Frame_b mount_2
    "Powertrain system 2"
end DualSystemMount;


within VehicleInterfaces.PowertrainMounts;
package Interfaces "Collection of interface definitions for powertrain mounting system"
  extends Modelica.Icons.InterfacesPackage;
end Interfaces;


Single powertrain subsystem mounting interface definition. This partial model defines the interfaces required for a single
powertrain system mounting subsystem. This class should be extended to
form a particular powertrain mounting model. See the
documentation
and
tutorial
for more information.

within VehicleInterfaces.PowertrainMounts.Interfaces;
partial model SingleSystemMount
  "Single powertrain subsystem mounting interface definition"
  extends Base;
  Modelica.Mechanics.MultiBody.Interfaces.Frame_b mount_1
    "Powertrain system 1"
end SingleSystemMount;


Three powertrain subsystem mounting interface definition. This partial model defines the interfaces required for three powertrain
system mounting subsystem. This class should be extended to form
a particular powertrain mounting model. See the
documentation
and
tutorial
for more information.

within VehicleInterfaces.PowertrainMounts.Interfaces;
partial model TripleSystemMount
  "Three powertrain subsystem mounting interface definition"
  extends Base;
  Modelica.Mechanics.MultiBody.Interfaces.Frame_b mount_1
    "Powertrain system 1"
  Modelica.Mechanics.MultiBody.Interfaces.Frame_b mount_2
    "Powertrain system 2"
  Modelica.Mechanics.MultiBody.Interfaces.Frame_b mount_3
    "Powertrain system 3"

end TripleSystemMount;


Circular road (perpendicular to world z-axis). The road is a circle described by "radius" and "width".
The road surface parameters are defined as:

within VehicleInterfaces.Roads;
model CircleRoad "Circular road (perpendicular to world z-axis)"
  extends VehicleInterfaces.Roads.Interfaces.Base(
    redeclare final function position = circlePosition (radius=radius, width=width),
    redeclare final function trackOffset = constantOffset,
    redeclare final function normal = circleNormal,
    redeclare final function headingDirection = circleHeadingDirection (radius=radius),
    redeclare final function frictionCoefficient = circleFrictionCoefficient (mu_fixed=mu));

  parameter Boolean animation=true "= true, if road shall be visualized";
  parameter SI.Radius radius "Radius of road";
  parameter SI.Length width "Width of road";
  parameter Real mu "Friction coefficient of road";
  parameter Modelica.Mechanics.MultiBody.Types.Color roadColor={255,0,0}
    "Color of road";
  constant Real pi=Modelica.Constants.pi;
protected
  outer Modelica.Mechanics.MultiBody.World world;
  VehicleInterfaces.Roads.Internal.VisualizeSimpleRoads roadShape(
    ns=100,
    nw=10,
    s_min=0,
    s_max=2*pi*radius,
    w_min=-width/2,
    w_max=width/2,
    color=roadColor) if animation and world.enableAnimation;

  function r_middle
    "Determine point on road in the middle of the circle (w=0"
    extends Modelica.Icons.Function;
    input Real s=0
      "Roads surface parameter 1 (usually arc length along road)";
    input Real radius=1 "Radius of circle";
    output Real r_0[3]={radius*sin(s/radius),-radius*cos(s/radius),0};
  algorithm
    r_0 := {radius*sin(s/radius),-radius*cos(s/radius),0};
  end r_middle;

  function circlePosition "Determine point on road"
    import Modelica.Math.Vectors.normalize;
    extends VehicleInterfaces.Roads.Interfaces.positionBase;
    input SI.Radius radius=1 "Radius of circle";
    input SI.Length width=1 "Width of road";
  algorithm
    r_0 := r_middle(s, radius) + w*normalize(r_middle(s, radius));
  end circlePosition;

  function constantOffset "Determine offset from road centre line"
    extends VehicleInterfaces.Roads.Interfaces.trackOffsetBase;
  algorithm
    trackOffset := {0,0,0};
  end constantOffset;

  function circleNormal
    "Determine unit normal on road, given road surface parameters"
    extends VehicleInterfaces.Roads.Interfaces.normalBase;
  algorithm
    e_n_0 := {0,0,1};
  end circleNormal;

  function circleHeadingDirection "Determine unit heading direction on road"
    extends VehicleInterfaces.Roads.Interfaces.headingDirectionBase;
    input SI.Radius radius=1 "Radius of circle";
  algorithm
    e_s_0 := {cos(s/radius),sin(s/radius),0};
  end circleHeadingDirection;

  function circleFrictionCoefficient
    "Determine friction coefficient at point on road"
    extends VehicleInterfaces.Roads.Interfaces.frictionCoefficientBase;
    input Real mu_fixed=1 "Friction coefficient";
  algorithm
    mu := mu_fixed;
  end circleFrictionCoefficient;
end CircleRoad;


Straight road along x-axis (perpendicular to world z-axis). The road is a line along the x-axis of the world system.
The road surface parameters are defined as:

within VehicleInterfaces.Roads;
model FlatRoad "Straight road along x-axis (perpendicular to world z-axis)"
  extends VehicleInterfaces.Icons.Road;
  extends VehicleInterfaces.Roads.Interfaces.Base(
    redeclare final function position = linePosition,
    redeclare final function trackOffset = constantOffset (offset=offset),
    redeclare final function normal = lineNormal,
    redeclare final function headingDirection = lineHeadingDirection,
    redeclare final function frictionCoefficient = lineFrictionCoefficient (mu_fixed=mu));

  parameter Boolean animation=true "= true, if road shall be visualized";
  parameter Real mu=0.5 "Friction coefficient of road";
  parameter Modelica.Mechanics.MultiBody.Types.Color roadColor={255,0,0}
    "Color of road"
  parameter SI.Length width=8 "Width of road"
  parameter SI.Position x_min=-100
    "Roads is visualized in the range [x_min .. x_max]"
  parameter SI.Position x_max=100
    "Roads is visualized in the range [x_min .. x_max]"
  parameter SI.Distance offset=0
    "Offset from the road centre line";
protected
  outer Modelica.Mechanics.MultiBody.World world;
  VehicleInterfaces.Roads.Internal.VisualizeSimpleRoads roadShape(
    ns=2,
    nw=2,
    s_min=x_min,
    s_max=x_max,
    w_min=-width/2,
    w_max=width/2,
    color=roadColor) if animation and world.enableAnimation;

  function linePosition "Determine point on road"
    extends VehicleInterfaces.Roads.Interfaces.positionBase;
  algorithm
    r_0 := {s,w,0};
  end linePosition;

  function constantOffset "Determine offset from road centre line"
    extends VehicleInterfaces.Roads.Interfaces.trackOffsetBase;
    input SI.Distance offset=0;
  algorithm
    trackOffset := {0,offset,0};
  end constantOffset;

  function lineNormal "Determine unit normal on road"
    extends VehicleInterfaces.Roads.Interfaces.normalBase;
  algorithm
    e_n_0 := {0,0,1};
  end lineNormal;

  function lineHeadingDirection "Determine unit heading direction on road"
    extends VehicleInterfaces.Roads.Interfaces.headingDirectionBase;
  algorithm
    e_s_0 := {1,0,0};
  end lineHeadingDirection;

  function lineFrictionCoefficient
    "Determine friction coefficient at point on road"
    extends VehicleInterfaces.Roads.Interfaces.frictionCoefficientBase;
    input Real mu_fixed=1 "Friction coefficient";
  algorithm
    mu := mu_fixed;
  end lineFrictionCoefficient;
end FlatRoad;


Collection of road definitions

within VehicleInterfaces;
package Roads "Collection of road definitions"
  extends Modelica.Icons.VariantsPackage;
end Roads;


Roads Tutorial

within VehicleInterfaces.Roads;
class Tutorial "Roads Tutorial"
  extends Modelica.Icons.Information;

  //rest of definition
  ...
end FlatRoad;

In redeclaring the functions we have also introduced new parameters
      mu and offset that need to be added
      to the model to define the friction coefficient of the road and
      the track offset from the road centre line.

The FlatRoad model included in this package also
      includes animation of the road surface but this is not essential
      to the definition of the road and will not be described in this
      tutorial.

The road model is complete and can now be used.

"));
end Tutorial;


Check that wheel contact point calculation is properly working with road model. Model to check that the tire contact patch calculation is working
correctly with the road models.

within VehicleInterfaces.Roads.Examples;
model CheckContactCalculation "Check that wheel contact point calculation is properly working with road model"
  extends Modelica.Icons.Example;

  parameter SI.Radius wheelRadius=1 "Radius of wheel";
  SI.Angle phi;
  SI.Radius radius_wheel;
  Real axis_wheel[3];
  SI.Position r_circle[3]={road.radius*sin(phi),-road.radius*cos(phi),0};
  VehicleInterfaces.Roads.Examples.Utilities.DummyTyre tyre(
    wheelRadius=wheelRadius,
    e_axis=Modelica.Math.Vectors.normalize(axis_wheel),
    r_wheel={radius_wheel*sin(phi),-radius_wheel*cos(phi),1 + sin(phi)/20})
  inner VehicleInterfaces.Roads.CircleRoad road(
    radius=50,
    width=8,
    mu=0.5,
    roadColor={100,100,100})
  inner Modelica.Mechanics.MultiBody.World world(
    enableAnimation=true,
    axisLength=20,
    n={0,0,-1})

protected
  constant SI.AngularVelocity w = 1;
equation
  // Define movement of center of wheel r_wheel and of wheel axis axis_wheel
  phi = w*time;
  radius_wheel = road.radius + (road.radius/20)*sin(20*phi);
  axis_wheel = {sin(phi),-cos(phi),sin(10*phi)/10};
end CheckContactCalculation;


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;


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 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 e_axis (unit vector in
direction of wheel axis) and r_wheel (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;


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;


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 s and w.

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;


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 single gear transmission without a 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 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 transmission subsystem. See the
documentation
and
tutorial
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
documentation
and
tutorial
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 manual
transmission model within the VehicleInterfaces package. See the
documentation
and
tutorial
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
documentation and
tutorial
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;


within VehicleInterfaces.Transmissions;
package Interfaces "Collection of interface definitions for transmission"
  extends Modelica.Icons.InterfacesPackage;
end Interfaces;


within VehicleInterfaces.Transmissions;
package Internal "Collection of internal material involving transmission"
  extends Modelica.Icons.InternalPackage;
end Internal;