Diode with one exponential function. This partial model of the diode does not yet contain any current versus voltage characteristic. In this model the
temperature dependencies of the temperature voltage, the saturation current, etc. are defined.

within PhotoVoltaics.Interfaces;
partial model PartialDiode "Diode with one exponential function"
  extends Modelica.Electrical.Analog.Interfaces.OnePort(v(start = 0));
  extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(T = 298.15);
  constant Modelica.Units.SI.Charge Q=1.6021766208E-19
    "Elementary charge of electron";
  parameter Real m = 1 "Ideality factor of diode";
  parameter Modelica.Units.SI.Resistance R=1E8 "Parallel ohmic resistance";
  parameter Modelica.Units.SI.Temperature TRef=298.15
    "Reference temperature"
  parameter Modelica.Units.SI.Voltage VRef(min=Modelica.Constants.small) = 0.6292
    "Reference voltage > 0, i.e. open circuit voltage, at TRef"
  parameter Modelica.Units.SI.Current IRef(min=Modelica.Constants.small) = 8.540
    "Reference current > 0, i.e. short circuit current, at TRef"
  parameter Modelica.Units.SI.LinearTemperatureCoefficient alphaI=+0.00053
    "Temperature coefficient of reference current at TRef"
  parameter Modelica.Units.SI.LinearTemperatureCoefficient alphaV=-0.00340
    "Temperature coefficient of reference voltage at TRef*"
  Modelica.Units.SI.Voltage Vt "Voltage equivalent of temperature (k*T/Q)";
  Modelica.Units.SI.Voltage VRefActual
    "Reference voltage w.r.t. actual temperature";
  Modelica.Units.SI.Current IRefActual
    "Reference current w.r.t. actual temperature";
  Modelica.Units.SI.Current Ids "Saturation current";
equation
  // Temperature dependent voltage
  Vt = Modelica.Constants.k * T_heatPort / Q;
  // Re-calculate reference voltage and current with respect to reference temperature
  VRefActual = VRef * (1 + alphaV * (T_heatPort - TRef));
  IRefActual = IRef * (1 + alphaI * (T_heatPort - TRef));
  // Actual temperature dependent saturation current is determined from reference voltage and current
  Ids = IRefActual / (exp(VRefActual / m / Vt) - 1);
  LossPower = v * i;
end PartialDiode;


Single-phase AC pins. This model provides single-phase AC quasi static pins.

within PhotoVoltaics.Interfaces.QuasiStatic;
partial model ACpins "Single-phase AC pins"
  import Modelica.ComplexMath.conj;
  Modelica.Electrical.QuasiStatic.SinglePhase.Interfaces.PositivePin ac_p
    "AC positive pin"
  Modelica.Electrical.QuasiStatic.SinglePhase.Interfaces.NegativePin ac_n
    "AC negative pin"
  Modelica.Units.SI.ComplexVoltage vAC=ac_p.v - ac_n.v "AC potential";
  Modelica.Units.SI.ComplexCurrent iAC=ac_p.i "AC current";
  Modelica.Units.SI.ComplexPower apparentPowerAC=vAC .* conj(iAC)
    "AC apparent power";
end ACpins;


AC polyphase plug. This model provides a polyphase AC quasi static plug.

within PhotoVoltaics.Interfaces.QuasiStatic;
partial model ACplug "AC polyphase plug"
  import Modelica.ComplexMath.conj;
  parameter Integer m(final min = 3) = 3 "Number of phases";
  Modelica.Electrical.QuasiStatic.Polyphase.Interfaces.PositivePlug ac(final
      m=m) "AC output"
  Modelica.Units.SI.ComplexVoltage vAC[m]=ac.pin[:].v "AC potential";
  Modelica.Units.SI.ComplexCurrent iAC[m]=ac.pin[:].i "AC current";
  Modelica.Units.SI.ComplexPower apparentPowerAC[m]=vAC .* conj(iAC)
    "AC apparent power";
end ACplug;


Quasi-static interfaces

within PhotoVoltaics.Interfaces;
package QuasiStatic "Quasi-static interfaces"
  extends Modelica.Icons.Package;
end QuasiStatic;


Records

within PhotoVoltaics;
package Records "Records"

  extends Modelica.Icons.RecordsPackage;
end Records;


Sources

within PhotoVoltaics;
package Sources "Sources"
  extends Modelica.Icons.Package;
end Sources;


Block sources

within PhotoVoltaics.Sources;
package Blocks "Block sources"
  extends Modelica.Icons.Package;
end Blocks;


Generate ramp signal based logarithmic range. The Real output y of this block is determined by a
ramp output
 from which

within PhotoVoltaics.Sources.Blocks;
block PowerRamp "Generate ramp signal based logarithmic range"
  parameter Real height = 1 "Height of ramps";
  parameter Modelica.Units.SI.Time duration(min=0.0, start=2)
    "Duration of ramp (= 0.0 gives a Step)";
  parameter Real offset = 0 "Offset of output signal";
  parameter Modelica.Units.SI.Time startTime=0
    "Output = offset for time < startTime";
  parameter Real ref = 1 "Reference value, determined by ref * 10 ^ (ramp function)";
  extends Modelica.Blocks.Interfaces.SO;
equation
  y = ref * 10 ^ (offset + (if time < startTime then 0 else if time < startTime + duration then (time - startTime) * height / duration else height));
end PowerRamp;


Multiple steps and triangles.

within PhotoVoltaics.Sources.Blocks;
block TriangleAndStep "Multiple steps and triangles"
  parameter Modelica.Units.SI.Time T=1 "Total time of varying outputs";
  parameter Integer stepNumber = 5 "Number of steps";
  parameter Real stepHeight = 1 "Total step height";
  parameter Real stepOffset = 0 "Offset";
  parameter Modelica.Units.SI.Time startTime=0 "Start time";
  parameter Real triangleHeight = 1 "Height of triangle output";
  parameter Real triangleOffset = 0 "Offset of triangle output";
  Modelica.Blocks.Sources.Ramp ramp(
    final startTime=startTime,
    final height=stepNumber - 1,
    final duration=T*(stepNumber - 1)/stepNumber,
    final offset=0)
  Modelica.Blocks.Math.RealToInteger realToInteger
  Modelica.Blocks.Math.IntegerToReal integerToReal
  Modelica.Blocks.Math.Feedback feedback
  Modelica.Blocks.Sources.Constant constantOffset(final k = stepOffset)
  Modelica.Blocks.Math.Add add
  Modelica.Blocks.Math.Gain gain(final k = stepHeight / (stepNumber - 1))
  Modelica.Blocks.Sources.Trapezoid trapezoid(final amplitude = triangleHeight, final rising = T / stepNumber / 2, final width = 0, final falling = T / stepNumber / 2, final period = T / stepNumber, final nperiod = stepNumber, final offset = triangleOffset, final startTime = startTime)
  Modelica.Blocks.Interfaces.RealOutput step
  Modelica.Blocks.Interfaces.RealOutput triangle
  Modelica.Blocks.Sources.Step const(offset=0, startTime=0, height=0.5)
  Modelica.Blocks.Nonlinear.Limiter limiter(final uMax=Modelica.Constants.inf, final uMin=0)
equation
  connect(realToInteger.y, integerToReal.u)
  connect(ramp.y, feedback.u1)
  connect(integerToReal.y, gain.u)
  connect(constantOffset.y, add.u1)
  connect(gain.y, add.u2)
  connect(add.y, step)
  connect(trapezoid.y, triangle)
  connect(const.y, feedback.u2)
  connect(feedback.y, limiter.u)
  connect(limiter.y, realToInteger.u)
end TriangleAndStep;


Re-chargeable ideal battery without loss. This is a simple, linear rechargable battery model. The actual physical model consists of one
capacitor. In order to consider the number of series and parallel connected cells, an internal
scaling of voltages, currents and power terms, is performed.

within PhotoVoltaics.Sources.Electrical;
model IdealBattery "Re-chargeable ideal battery without loss"
  parameter Integer ns(min = 1) = 1 "Number of series cells";
  parameter Integer np(min = 1) = 1 "Number of parallel cells";
  parameter Modelica.Units.SI.Voltage V1Cell
    "Maximum cell voltage > V0Cell";
  parameter Modelica.Units.SI.Voltage V0Cell
    "Minimum cell voltage < V1Cell";
  final parameter Modelica.Units.SI.Voltage V1=V1Cell*ns
    "Maximum battery voltage > V0";
  final parameter Modelica.Units.SI.Voltage V0=V0Cell*ns
    "Maximum battery voltage < V1";
  parameter Boolean allowOvercharge = false
    "Allows overcharging without error";
  parameter Boolean allowUndercharge = false
    "Allows undercharging without error";
  parameter Modelica.Units.SI.Energy ECell
    "Total cell energy between V0Cell and V1Cell";
  final parameter Modelica.Units.SI.Capacitance CCell=2*ECell/(V1Cell^2 -
      V0Cell^2) "Total charge of battery";
  parameter Modelica.Units.SI.Voltage ViniCell=V1Cell
    "Initial cell voltage";
  Modelica.Units.SI.Voltage v=pin_p.v - pin_n.v "Battery voltage";
  Modelica.Units.SI.Voltage vCell=v/ns "Cell voltage";
  Modelica.Units.SI.Current i=capacitor.i "Battery current";
  Modelica.Units.SI.Current iCell=i/np "Cell current";
  Modelica.Units.SI.Power power=v*i "Battery power";
  Modelica.Units.SI.Power powerCell=power/ns/np "Cell power";
  Modelica.Units.SI.Energy energy "Energy";
  Modelica.Units.SI.Energy energyCell "Cell energy";
  Modelica.Electrical.Analog.Basic.Capacitor capacitor(final C = CCell * np / ns, v(start = ns * ViniCell, fixed = true))
  Modelica.Electrical.Analog.Interfaces.PositivePin pin_p "Positive pin"
  Modelica.Electrical.Analog.Interfaces.NegativePin pin_n "Negative pin"
initial equation
  energyCell = CCell * (ViniCell ^ 2 - V0Cell ^ 2) / 2;
equation
  der(energy) = power;
  energyCell * ns * np = energy;
  assert(vCell >= V0Cell or allowUndercharge, "Battery: cell voltage less than V0Cell");
  assert(vCell <= V1Cell or allowOvercharge, "Battery: cell voltage greater than V1Cell");
  connect(pin_p, capacitor.p)
  connect(capacitor.n, pin_n)
end IdealBattery;


Electrical sources

within PhotoVoltaics.Sources;
package Electrical "Electrical sources"
  extends Modelica.Icons.Package;
end Electrical;


Generic current source using the input signal as source current. The signal current source is a converter of real valued irradiance signal into a source current.
Depending on the actual temperature the current is adjusted through a linear temperature coeffficient.

within PhotoVoltaics.Sources.Electrical;
model SignalCurrent "Generic current source using the input signal as source current"
  extends Modelica.Electrical.Analog.Interfaces.ConditionalHeatPort(T = 298.15);
  parameter Modelica.Units.SI.Temperature TRef=298.15
    "Reference temperature";
  parameter Modelica.Units.SI.Current IRef=1
    "Reference current at reference irradiance and reference temperature";
  parameter Modelica.Units.SI.Irradiance irradianceRef=1000
    "Reference solar irradiance";
  parameter Modelica.Units.SI.LinearTemperatureCoefficient alphaRef=0
    "Temperature coefficient of reference current at TRref";
  Modelica.Electrical.Analog.Interfaces.PositivePin p
  Modelica.Electrical.Analog.Interfaces.NegativePin n
  Modelica.Units.SI.Voltage v
    "Voltage drop between the two pins (= p.v - n.v)";
  Modelica.Units.SI.Current i
    "Current flowing from pin p to pin n as input signal";
  Modelica.Blocks.Interfaces.RealInput irradiance(unit = "W/m2") "Irradiance"
equation
  i = IRef * (irradiance / irradianceRef + alphaRef * (T_heatPort - TRef));
  v = p.v - n.v;
  0 = p.i + n.i;
  i = p.i;
  LossPower = 0;
end SignalCurrent;


Unrooted variable polyphase AC current source.

within PhotoVoltaics.Sources.Electrical;
model VariableUnrootedPolyphaseCurrentSource
  "Unrooted variable polyphase AC current source"
  extends Modelica.Electrical.QuasiStatic.Polyphase.Interfaces.OnePort;
  import Modelica.Constants.pi;
  Modelica.ComplexBlocks.Interfaces.ComplexInput I[m]
equation
  i = I;
end VariableUnrootedPolyphaseCurrentSource;


within PhotoVoltaics.Sources.Electrical;
model VariableUnrootedSinglePhaseCurrentSource "Unrooted variable polyphase AC current source"
  extends Modelica.Electrical.QuasiStatic.SinglePhase.Interfaces.OnePort;
  import Modelica.Constants.pi;
  Modelica.ComplexBlocks.Interfaces.ComplexInput I
equation
  i = I;
end VariableUnrootedSinglePhaseCurrentSource;


Simple solar irradiance without considering weather conditions.

within PhotoVoltaics.Sources.Irradiance;
model Irradiance "Simple solar irradiance without considering weather conditions"
  import Modelica.Constants.pi;
  import PhotoVoltaics.Functions.rad;
  import PhotoVoltaics.Functions.degree;
  import PhotoVoltaics.Functions.dayOfTheYear;
  parameter Integer startDay(final min = 1, final max = 31) = 10 "Day";
  parameter Integer startMonth(final min = 1, final max = 12) = 9 "Month";
  parameter Integer startYear = 2016 "Year";
  parameter Integer TimeZone = 1 "Time zone";
  parameter Modelica.Units.SI.Angle longitude=0.2856929452589518
    "Longitude";
  parameter Modelica.Units.SI.Angle latitude=0.8418964085999744
    "Latitude";
  parameter Modelica.Units.SI.Irradiance irradianceRef=1000
    "Reference solar irradiance";
  parameter Modelica.Units.SI.Angle gamma=10*pi/180
    "Angle of PV module with w.r.t. horizontal plane";
  parameter Modelica.Units.SI.Angle azimuth=0
    "Azimuth of the PV module orientation";
  Integer startDayOfYear(start = dayOfTheYear(startDay, startMonth, startYear), fixed = true) "Start day of year in simulation";
  Integer dayOfYear(final start = dayOfTheYear(startDay, startMonth, startYear), fixed = true) "Actual day of year";
  Integer daysOfYear(final start = dayOfTheYear(31, 12, startYear), fixed = true) "Total number of days of year";
  Integer year(final start = startYear, fixed = true) "Actual year";
  Modelica.Units.SI.Angle Jprime(final start=dayOfTheYear(
              startDay,
              startMonth,
              startYear)/dayOfTheYear(
              31,
              12,
              startYear)*2*pi, fixed=true)
    "Equivalent Angle of the day of the year w.r.t. total number of days";
  Real delta_J;
  Real timeequation_J;
  Modelica.Units.NonSI.Time_day localTimeDays "Local time in days";
  Integer localDays "Locale day";
  Modelica.Units.SI.Time localTime "Local time";
  Modelica.Units.NonSI.Time_hour localTimeHours
    "Local time in unit hours";
  Modelica.Units.NonSI.Time_hour LocalMeanTimeHours
    "Local mean time in unit hours";
  Modelica.Units.NonSI.Time_hour trueMeanTimeHours
    "True mean time in unit hours";
  Modelica.Units.SI.Angle hoursAngle "Hours angle";
  Modelica.Units.SI.Angle sunHeight "Sun height";
  Modelica.Units.SI.Angle sunAzimuth1 "Sun azimuth before 12 p.m.";
  Modelica.Units.SI.Angle sunAzimuth2 "Sun azimuth after 12 p.m.";
  Modelica.Units.SI.Angle sunAzimuth "Sun azimuth";
  Modelica.Units.SI.Angle angleOfIncidence
    "Angle of incidence between a vector in sun direction and a normal vector";
  Modelica.Units.SI.Irradiance directIrradianceHorizontal
    "Direct irradiance on the horizontal in W/m^2";
  Modelica.Units.SI.Irradiance directIrradianceInclined
    "Direct irradiance on the inclined plane in w/m^2";
  Modelica.Blocks.Interfaces.RealOutput irradiance "Irradiance of inclined area"
algorithm
  // Calculate ratio of day w.r.t. total number of days of a year as equivalent angle
  when sample(24 * 3600, 24 * 3600) then
    dayOfYear := mod(pre(dayOfYear), pre(daysOfYear)) + 1;
  end when;
  when startDayOfYear + localDays == daysOfYear + 1 then
    startDayOfYear := 1;
    year := pre(year) + 1;
    daysOfYear := dayOfTheYear(31, 12, year);
  end when;
  // One full year is reached
  // Reset start day of year
  // Increment year
  // Determined actual number of total days of year
equation
  Jprime = dayOfYear / daysOfYear * 2 * pi;
  delta_J = rad(0.3948 - 23.2559 * cos(Jprime + rad(9.1)) - 0.3915 * cos(2 * Jprime + rad(5.4)) - 0.1764 * cos(3 * Jprime + rad(26)));
  timeequation_J = 0.0066 + 7.3525 * cos(Jprime + rad(85.9)) + 9.9359 * cos(2 * Jprime + rad(108.9)) + 0.3387 * cos(3 * Jprime + rad(105.2));
  // Zeit LZ = time
  localTime = time;
  // Convert time into unit hours
  localTimeHours = localTime / 3600;
  // Convert time into unit days
  localTimeDays = localTimeHours / 24;
  // Convert time from real days into integer days (floor)
  localDays = integer(floor(localTimeDays));
  // Calculate locale mean time
  LocalMeanTimeHours = localTimeHours - TimeZone + 4 / 60 * longitude * 180 / Modelica.Constants.pi;
  // cos(latitude)*tan(...)
  trueMeanTimeHours = LocalMeanTimeHours + timeequation_J / 60;
  hoursAngle = rad((12 - trueMeanTimeHours) * 15);
  sunHeight = degree(asin(cos(hoursAngle) * cos(latitude) * cos(delta_J) + sin(latitude) * sin(delta_J))) * (Modelica.Constants.pi / 180);
  sunAzimuth1 = Modelica.Constants.pi - acos((sin(sunHeight) * sin(latitude) - sin(delta_J)) / (cos(sunHeight) * cos(latitude)));
  sunAzimuth2 = Modelica.Constants.pi + acos((sin(sunHeight) * sin(latitude) - sin(delta_J)) / (cos(sunHeight) * cos(latitude)));
  sunAzimuth = if mod(localTimeHours, 24) <= 12 then sunAzimuth1 else sunAzimuth2;
  angleOfIncidence = acos((-cos(sunHeight) * sin(gamma) * cos(sunAzimuth - azimuth)) + sin(sunHeight) * cos(gamma));
  directIrradianceHorizontal = if sunHeight < 0 then 0 else irradianceRef * sin(sunHeight);
  directIrradianceInclined = if angleOfIncidence > pi / 2 then 0 else if abs(sin(sunHeight)) < 1E-5 then 0 else directIrradianceHorizontal * (cos(angleOfIncidence) / sin(sunHeight));
  irradiance = directIrradianceInclined;
end Irradiance;


Simple solar irradiance with fixed sun position.

within PhotoVoltaics.Sources.Irradiance;
model IrradianceFixedSun "Simple solar irradiance with fixed sun position"
  import Modelica.Constants.pi;
  parameter Modelica.Units.SI.Irradiance irradianceRef=1000
    "Reference solar irradiance";
  parameter Modelica.Units.SI.Angle sunHeight "Sun height";
  parameter Modelica.Units.SI.Angle sunAzimuth "Sun azimuth";
  Modelica.Units.SI.Angle angleOfIncidence
    "Angle of incidence between a vector in sun direction and a normal vector";
  Modelica.Units.SI.Irradiance directIrradianceHorizontal
    "Direct irradiance on the horizontal";
  Modelica.Units.SI.Irradiance directIrradianceInclined
    "Direct irradiance on the inclined plane";
  Modelica.Blocks.Interfaces.RealOutput irradiance
  Modelica.Blocks.Interfaces.RealInput gamma
  Modelica.Blocks.Interfaces.RealInput azimuth
equation
  angleOfIncidence = acos((-cos(sunHeight) * sin(gamma) * cos(sunAzimuth - azimuth)) + sin(sunHeight) * cos(gamma));
  directIrradianceHorizontal = if sunHeight < 0 then 0 else irradianceRef * sin(sunHeight);
  directIrradianceInclined = if angleOfIncidence > pi / 2 then 0 else if abs(sin(sunHeight)) < 1E-5 then 0 else directIrradianceHorizontal * (cos(angleOfIncidence) / sin(sunHeight));
  irradiance = directIrradianceInclined;
end IrradianceFixedSun;


within PhotoVoltaics.Sources.Irradiance;
model IrradianceVariableLocation "Simple solar irradiance without considering weather conditions"
  import Modelica.Constants.pi;
  import PhotoVoltaics.Functions.rad;
  import PhotoVoltaics.Functions.degree;
  import PhotoVoltaics.Functions.dayOfTheYear;
  parameter Integer startDay(final min = 1, final max = 31) = 10 "Day";
  parameter Integer startMonth(final min = 1, final max = 12) = 9 "Month";
  parameter Integer startYear = 2016 "Year";
  parameter Integer TimeZone = 1 "Time zone";
  parameter Modelica.Units.SI.Angle longitude=0.2856929452589518
    "Longitude";
  parameter Modelica.Units.SI.Angle latitude=0.8418964085999744
    "Latitude";
  parameter Modelica.Units.SI.Irradiance irradianceRef=1000
    "Reference solar irradiance";
  Integer startDayOfYear(start = dayOfTheYear(startDay, startMonth, startYear)) "Start day of year in simulation";
  Integer dayOfYear(final start = dayOfTheYear(startDay, startMonth, startYear)) "Actual day of year";
  Integer daysOfYear(final start = dayOfTheYear(31, 12, startYear)) "Total number of days of year";
  Integer year(final start = startYear) "Actual year";
  Modelica.Units.SI.Angle Jprime(final start=dayOfTheYear(
              startDay,
              startMonth,
              startYear)/dayOfTheYear(
              31,
              12,
              startYear)*2*pi)
    "Equivalent Angle of the day of the year w.r.t. total number of days";
  Real delta_J;
  Real timeequation_J;
  Modelica.Units.NonSI.Time_day localTimeDays "Local time in days";
  Integer localDays "Locale day";
  Modelica.Units.SI.Time localTime "Local time";
  Modelica.Units.NonSI.Time_hour localTimeHours
    "Local time in unit hours";
  Modelica.Units.NonSI.Time_hour LocalMeanTimeHours
    "Local mean time in unit hours";
  Modelica.Units.NonSI.Time_hour trueMeanTimeHours
    "True mean time in unit hours";
  Modelica.Units.SI.Angle hoursAngle "Hours angle";
  Modelica.Units.SI.Angle sunHeight "Sun height";
  Modelica.Units.SI.Angle sunAzimuth1 "Sun azimuth before 12 p.m.";
  Modelica.Units.SI.Angle sunAzimuth2 "Sun azimuth after 12 p.m.";
  Modelica.Units.SI.Angle sunAzimuth "Sun azimuth";
  Modelica.Units.SI.Angle angleOfIncidence
    "Angle of incidence between a vector in sun direction and a normal vector";
  Modelica.Units.SI.Irradiance directIrradianceHorizontal
    "Direct irradiance on the horizontal in W/m^2";
  Modelica.Units.SI.Irradiance directIrradianceInclined
    "Direct irradiance on the inclined plane in w/m^2";
  Modelica.Blocks.Interfaces.RealOutput irradiance "Irradiance of inclined area"
  Modelica.Blocks.Interfaces.RealInput gamma "Inclination angle of area"
  Modelica.Blocks.Interfaces.RealInput azimuth "Azimuth of area"
algorithm
  // Calculate ratio of day w.r.t. total number of days of a year as equivalent angle
  when sample(24 * 3600, 24 * 3600) then
    dayOfYear := mod(pre(dayOfYear), pre(daysOfYear)) + 1;
  end when;
  when startDayOfYear + localDays == daysOfYear + 1 then
    startDayOfYear := 1;
    year := pre(year) + 1;
    daysOfYear := dayOfTheYear(31, 12, year);
  end when;
  // One full year is reached
  // Reset start day of year
  // Increment year
  // Determined actual number of total days of year
equation
  Jprime = dayOfYear / daysOfYear * 2 * pi;
  delta_J = rad(0.3948 - 23.2559 * cos(Jprime + rad(9.1)) - 0.3915 * cos(2 * Jprime + rad(5.4)) - 0.1764 * cos(3 * Jprime + rad(26)));
  timeequation_J = 0.0066 + 7.3525 * cos(Jprime + rad(85.9)) + 9.9359 * cos(2 * Jprime + rad(108.9)) + 0.3387 * cos(3 * Jprime + rad(105.2));
  // Zeit LZ = time
  localTime = time;
  // Convert time into unit hours
  localTimeHours = localTime / 3600;
  // Convert time into unit days
  localTimeDays = localTimeHours / 24;
  // Convert time from real days into integer days (floor)
  localDays = integer(floor(localTimeDays));
  // Calculate locale mean time
  LocalMeanTimeHours = localTimeHours - TimeZone + 4 / 60 * longitude * 180 / Modelica.Constants.pi;
  // cos(latitude)*tan(...)
  trueMeanTimeHours = LocalMeanTimeHours + timeequation_J / 60;
  hoursAngle = rad((12 - trueMeanTimeHours) * 15);
  sunHeight = degree(asin(cos(hoursAngle) * cos(latitude) * cos(delta_J) + sin(latitude) * sin(delta_J))) * (Modelica.Constants.pi / 180);
  sunAzimuth1 = Modelica.Constants.pi - acos((sin(sunHeight) * sin(latitude) - sin(delta_J)) / (cos(sunHeight) * cos(latitude)));
  sunAzimuth2 = Modelica.Constants.pi + acos((sin(sunHeight) * sin(latitude) - sin(delta_J)) / (cos(sunHeight) * cos(latitude)));
  sunAzimuth = if mod(localTimeHours, 24) <= 12 then sunAzimuth1 else sunAzimuth2;
  angleOfIncidence = acos((-cos(sunHeight) * sin(gamma) * cos(sunAzimuth - azimuth)) + sin(sunHeight) * cos(gamma));
  directIrradianceHorizontal = if sunHeight < 0 then 0 else irradianceRef * sin(sunHeight);
  directIrradianceInclined = if angleOfIncidence > pi / 2 then 0 else if abs(sin(sunHeight)) < 1E-5 then 0 else directIrradianceHorizontal * (cos(angleOfIncidence) / sin(sunHeight));
  irradiance = directIrradianceInclined;
end IrradianceVariableLocation;


Irradiance

within PhotoVoltaics.Sources;
package Irradiance "Irradiance"
  extends Modelica.Icons.Package;
end Irradiance;


within ;
package VehicleInterfaces "VehicleInterfaces Library (Version 2.0.1) - Interface definitions and architectures for vehicle system modeling"
  extends Modelica.Icons.Package;

  import Modelica.Units.SI;
end VehicleInterfaces;


Collection of type definitions

within VehicleInterfaces;
package Types "Collection of type definitions"
  extends Modelica.Icons.TypesPackage;

  type NormalizedReal = Modelica.Icons.TypeReal (
      final quantity="",
      final unit="1",
      final displayUnit="1",
      final min=0,
      final max=1) "Normalized real number";
  type Gear = Modelica.Icons.TypeInteger (final quantity="gear")
    "Gear ...,-2,-1,0,1,2,... = 2nd rear, 1st rear, neutral, 1st, 2nd forward, etc";

  package GearMode
    "Type, constants and menu choices for gear mode, as temporary solution until enumerations are available"

    // type GearMode = enumeration(Park, Drive, Neutral, Rear, Manual, Limited);

    constant Integer Park=1;
    constant Integer Drive=2;
    constant Integer Neutral=3;
    constant Integer Rear=4;
    constant Integer Manual=5;
    constant Integer Limited=6;

    type Temp
      "Temporary type of gear mode with choices for menus (until enumerations are available)"

      extends Integer(min=1,max=6);
    end Temp;
  end GearMode;

  package IgnitionSetting
    "Type, constants and menu choices for ignition setting, as temporary solution until enumerations are available"

    // type IgnitionSetting = enumeration(Off, On, Start);

    constant Integer Off=1 "Ignition is off";
    constant Integer On=2 "Ignition is on";
    constant Integer Start=3
      "Ignition is on and driver requires to start engine";

    type Temp
      "Temporary type of ignition setting with choices for menus (until enumerations are available)"

      extends Integer(min=1,max=3);
    end Temp;
  end IgnitionSetting;
end Types;


Constant torque loss and inertia due to the accessories. Simple accessory model with a single inertia and constant torque loss.

within VehicleInterfaces.Accessories;
model MinimalAccessories
  "Constant torque loss and inertia due to the accessories"
  extends VehicleInterfaces.Icons.Accessories;
  extends Interfaces.Base(includeEngineBearing=world.driveTrainMechanics3D);

  parameter SI.Inertia accessoriesInertia=0.001
    "Total effective rotational inertia of the accessories";
  parameter SI.Torque accessoriesLoad=2
    "Total effective torque load due to the accessories (constant)";
  parameter Modelica.Mechanics.MultiBody.Types.Axis axisOfRotation={1,0,0}
    "Axis of rotation for accessories when including MultiBody effects";

  Modelica.Mechanics.MultiBody.Parts.Rotor1D inertia(
    J=accessoriesInertia,
    n=axisOfRotation)
  Modelica.Mechanics.Rotational.Sources.SignTorque torqueLoss(
    tau_nominal=-accessoriesLoad,
    useSupport=includeEngineBearing,
    w0=1)
  Modelica.Mechanics.MultiBody.Parts.Mounting1D torqueReaction(
    n=axisOfRotation) if includeEngineBearing
protected
  outer Modelica.Mechanics.MultiBody.World world;
equation
  connect(torqueLoss.flange, inertia.flange_a)
  connect(inertia.flange_b, engineFlange.flange)
  connect(torqueReaction.frame_a, engineFlange.bearingFrame)
  connect(torqueReaction.flange_b,torqueLoss.support)
  connect(inertia.frame_a, torqueReaction.frame_a)
end MinimalAccessories;


Empty accessories. Empty accessories subsystem. Using this empty model in overall vehicle architecture the functionality of accessories subsystem can be eliminated.

within VehicleInterfaces.Accessories;
model NoAccessories "Empty accessories"
  extends VehicleInterfaces.Icons.Accessories;
  extends VehicleInterfaces.Icons.Empty;
  extends Interfaces.Base;
end NoAccessories;


within VehicleInterfaces;
package Accessories "Collection of accessory subsystem definitions"
  extends Modelica.Icons.VariantsPackage;
end Accessories;


Accessories Tutorial.

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


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

within VehicleInterfaces.Accessories.Interfaces;
partial model Base "Basic interface definition for the accessories"

  parameter Boolean usingMultiBodyEngine=false
    "= true, if connecting to a MultiBody engine"
protected
  parameter Boolean includeEngineBearing=false "Include the engine bearing";

public
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing engineFlange(
    final includeBearingConnector=includeEngineBearing or usingMultiBodyEngine)
    "Source of drive torque"
  VehicleInterfaces.Interfaces.ControlBus controlBus "Control signal bus"
  Mechanics.MultiBody.MultiBodyEnd end_2(
    final includeBearingConnector=includeEngineBearing or usingMultiBodyEngine)
equation
  connect(end_2.flange, engineFlange)
end Base;


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


Atmospheres with constant conditions. This is the simplest atmosphere model with constant characteristics.

within VehicleInterfaces.Atmospheres;
model ConstantAtmosphere "Atmospheres with constant conditions"
  extends VehicleInterfaces.Icons.Atmosphere;
  extends VehicleInterfaces.Atmospheres.Interfaces.Base(
    redeclare final function windVelocity = constantWindVelocity (windVelocity=v),
    redeclare final function density = constantDensity (density=rho),
    redeclare final function temperature = constantTemperature (T0=T),
    redeclare final function humidity = constantHumidity (h0=h));

  parameter SI.Velocity[3] v=zeros(3) "Wind velocity";
  parameter SI.AbsolutePressure ambientPressure=101300
    "Air pressure";
  parameter SI.Temperature T=293.15 "Air temperature";
  parameter Real h=0.5 "Air humidity (0-1)";
  constant Real R=287.0512249529787 "Gas constant for air";

protected
  parameter SI.Density rho=ambientPressure/(R*T);

  function constantWindVelocity
    extends VehicleInterfaces.Atmospheres.Interfaces.windVelocityBase;
    input SI.Velocity[3] windVelocity={0,0,0};
  algorithm
    v := windVelocity;
  end constantWindVelocity;

  function constantDensity "Determine density"
    extends VehicleInterfaces.Atmospheres.Interfaces.densityBase;
    input SI.Density density=1.18 "Density";
  algorithm
    rho := density;
  end constantDensity;

  function constantTemperature "Determine temperature"
    extends VehicleInterfaces.Atmospheres.Interfaces.temperatureBase;
    input SI.Temperature T0=293 "Constant temperature";
  algorithm
    T := T0;
  end constantTemperature;

  function constantHumidity "Determine humidity"
    extends VehicleInterfaces.Atmospheres.Interfaces.humidityBase;
    input Real h0=0.5 "Constant humidity";
  algorithm
    h := h0;
  end constantHumidity;
end ConstantAtmosphere;


within VehicleInterfaces;
package Atmospheres "Collection of atmosphere subsystem definitions"
  extends Modelica.Icons.VariantsPackage;
end Atmospheres;


Atmosphere Tutorial.

within VehicleInterfaces.Atmospheres;
class Tutorial "Atmosphere Tutorial"
  extends Modelica.Icons.Information;

  //Rest of model definition
  ...
end ConstantAtmosphere;

Adding these redeclares also means we need to add 4 parameters to
      the model v, rho, h
      and T which are the constant wind velocity, density,
      humidity and temperature respectively.

This model is now complete and can be used. The ConstantAtmosphere
      definition included in VehicleInterfaces actually has pressure,
      temperature and wind velocity as it's parameters and automatically
      calculates the air density.

"));
end Tutorial;


Base model for all atmospheres. Dummy model to demonstrate how the wind velocity model should be defined and included in atmosphere model.

within VehicleInterfaces.Atmospheres.Interfaces;
partial model Base "Base model for all atmospheres"

  replaceable function windVelocity=windVelocityBase
    "Dummy model for wind velocity"

  replaceable function density=densityBase "Dummy model for air density"

  replaceable function temperature=temperatureBase
    "Dummy model for air temperature"

  replaceable function humidity=humidityBase "Dummy model for air humidity"

end Base;


Determine density. Partial base model for air density. Extend this model appropriately to define final user model.

within VehicleInterfaces.Atmospheres.Interfaces;
partial function densityBase "Determine density"
  extends Modelica.Icons.Function;
  input SI.Position[3] r=zeros(3)
    "Position vector from world frame to point, resolved in world frame";
  output SI.Density rho=1.18 "Density";
end densityBase;


Determine humidity. Partial base model for air humidity. Extend this model appropriately to define final user model.

within VehicleInterfaces.Atmospheres.Interfaces;
partial function humidityBase "Determine humidity"
  extends Modelica.Icons.Function;
  input SI.Position[3] r=zeros(3)
    "Position vector from world frame to point, resolved in world frame";
  output Real h=0.5 "Humidity";
end humidityBase;


within VehicleInterfaces.Atmospheres;
package Interfaces "Collection of interface definitions for atmosphere"
  extends Modelica.Icons.Package;
end Interfaces;


Determine temperature. Partial base model for air temperature. Extend this model appropriately to define final user model.

within VehicleInterfaces.Atmospheres.Interfaces;
partial function temperatureBase "Determine temperature"
  extends Modelica.Icons.Function;
  input SI.Position[3] r=zeros(3)
    "Position vector from world frame to point, resolved in world frame";
  output SI.Temperature T=298 "Temperature";
end temperatureBase;


Determine wind velocity. Partial base model for wind velocity. Extend this model appropriately to define final user model.

within VehicleInterfaces.Atmospheres.Interfaces;
partial function windVelocityBase "Determine wind velocity"
  extends Modelica.Icons.Function;
  input SI.Position[3] r=zeros(3)
    "Position vector from world frame to point, resolved in world frame";
  output SI.Velocity[3] v=zeros(3)
    "Wind velocity vector, resolved in world frame";
end windVelocityBase;


Output the normalized input signal u [0..1] in inverted form y [1..0].. This block is used to invert a normalized input signal u from [0..1] to [1..0].
Formally, the output y is computed as:

within VehicleInterfaces.Blocks;
block InvertNormalizedInput
  "Output the normalized input signal u [0..1] in inverted form y [1..0]."
  extends Modelica.Blocks.Interfaces.SISO;
equation
  y = 1 - u;
end InvertNormalizedInput;


within VehicleInterfaces;
package Blocks "Collection of input/output fixed causality blocks"
  extends Modelica.Icons.Package;
end Blocks;


Simple proportional (constant gain) braking model for 4 wheeled vehicles. Brakes subsystem model that uses the driver brakePedalPosition
signal to determine the brake torque demand being requested by the driver.

within VehicleInterfaces.Brakes;
model MinimalBrakes
  "Simple proportional (constant gain) braking model for 4 wheeled vehicles"
  extends VehicleInterfaces.Icons.Brakes;
  extends VehicleInterfaces.Brakes.Interfaces.TwoAxleBase(includeWheelBearings=world.driveTrainMechanics3D);

  parameter SI.Torque maxTorque=1000
    "Maximum combined brake torque (for all brakes together)";

  Modelica.Blocks.Math.Gain computeTorque(k=maxTorque/4.0)
  Modelica.Mechanics.Rotational.Components.Brake brake_1(
    mu_pos=[0,1],
    useSupport=true,
    fn_max=1)
  Modelica.Mechanics.Rotational.Components.Brake brake_2(
    mu_pos=[0,1],
    useSupport=true,
    fn_max=1)
  Modelica.Mechanics.Rotational.Components.Brake brake_3(
    mu_pos=[0,1],
    useSupport=true,
    fn_max=1)
  Modelica.Mechanics.Rotational.Components.Brake brake_4(
    mu_pos=[0,1],
    useSupport=true,
    fn_max=1)
  Modelica.Mechanics.Rotational.Sensors.SpeedSensor wheelSpeed_1
  Modelica.Mechanics.Rotational.Sensors.SpeedSensor wheelSpeed_2
  Modelica.Mechanics.Rotational.Sensors.SpeedSensor wheelSpeed_3
  Modelica.Mechanics.Rotational.Sensors.SpeedSensor wheelSpeed_4
  Modelica.Mechanics.MultiBody.Parts.Mounting1D torqueReaction_1(n={0,1,0})
  Modelica.Mechanics.MultiBody.Parts.Mounting1D torqueReaction_2(n={0,1,0})
  Modelica.Mechanics.MultiBody.Parts.Mounting1D torqueReaction_3(n={0,1,0})
  Modelica.Mechanics.MultiBody.Parts.Mounting1D torqueReaction_4(n={0,1,0})
protected
  outer Modelica.Mechanics.MultiBody.World world;
  VehicleInterfaces.Interfaces.BrakesBus brakesBus
  VehicleInterfaces.Interfaces.DriverBus driverBus
equation
  connect(computeTorque.y, brake_1.f_normalized)
  connect(computeTorque.y, brake_2.f_normalized)
  connect(computeTorque.y, brake_3.f_normalized)
  connect(computeTorque.y, brake_4.f_normalized)
  connect(brake_1.flange_b, wheelHub_1.flange)
  connect(brake_2.flange_a, wheelHub_2.flange)
  connect(brake_3.flange_a, wheelHub_3.flange)
  connect(brake_4.flange_b, wheelHub_4.flange)
  connect(wheelSpeed_1.flange, brake_1.flange_a)
  connect(brake_2.flange_b, wheelSpeed_2.flange)
  connect(wheelSpeed_3.flange, brake_3.flange_b)
  connect(brake_4.flange_a, wheelSpeed_4.flange)
  connect(controlBus.driverBus, driverBus)
  connect(computeTorque.u, driverBus.brakePedalPosition)
  connect(wheelSpeed_1.w, brakesBus.wheelSpeed_1)
  connect(wheelSpeed_2.w, brakesBus.wheelSpeed_2)
  connect(wheelSpeed_3.w, brakesBus.wheelSpeed_3)
  connect(wheelSpeed_4.w, brakesBus.wheelSpeed_4)
  connect(controlBus.brakesBus, brakesBus)
  connect(torqueReaction_1.frame_a, wheelHub_1.bearingFrame)
  connect(torqueReaction_1.flange_b, brake_1.support)
  connect(brake_2.support, torqueReaction_2.flange_b)
  connect(torqueReaction_2.frame_a, wheelHub_2.bearingFrame)
  connect(torqueReaction_3.flange_b, brake_3.support)
  connect(torqueReaction_3.frame_a, wheelHub_3.bearingFrame)
  connect(torqueReaction_4.frame_a, wheelHub_4.bearingFrame)
  connect(torqueReaction_4.flange_b, brake_4.support)
end MinimalBrakes;


Simple proportional (constant gain) braking model for 4 wheeled vehicles, uses the brake pedal connection. Brakes subsystem model that uses the physical pedal connection to determine
the brake torque demand being requested by the driver.

within VehicleInterfaces.Brakes;
model MinimalBrakesUsingPedal
  "Simple proportional (constant gain) braking model for 4 wheeled vehicles, uses the brake pedal connection"
  extends VehicleInterfaces.Icons.Brakes;
  extends VehicleInterfaces.Brakes.Interfaces.TwoAxleBase(
    includeBrakePedal=true,
    includeWheelBearings=world.driveTrainMechanics3D);

  parameter SI.Torque maxTorque=1000
    "Maximum combined brake torque";

  Modelica.Blocks.Math.Gain computeTorque(k=maxTorque/4.0)
  Modelica.Mechanics.Rotational.Components.Brake brake_1(
    mu_pos=[0,1],
    useSupport=true,
    fn_max=1)
  Modelica.Mechanics.Rotational.Components.Brake brake_2(
    mu_pos=[0,1],
    useSupport=true,
    fn_max=1)
  Modelica.Mechanics.Rotational.Components.Brake brake_3(
    mu_pos=[0,1],
    useSupport=true,
    fn_max=1)
  Modelica.Mechanics.Rotational.Components.Brake brake_4(
    mu_pos=[0,1],
    useSupport=true,
    fn_max=1)
  Modelica.Mechanics.Translational.Sensors.PositionSensor positionSensor
  Modelica.Mechanics.Rotational.Sensors.SpeedSensor wheelSpeed_1
  Modelica.Mechanics.Rotational.Sensors.SpeedSensor wheelSpeed_2
  Modelica.Mechanics.Rotational.Sensors.SpeedSensor wheelSpeed_3
  Modelica.Mechanics.Rotational.Sensors.SpeedSensor wheelSpeed_4
  Modelica.Mechanics.MultiBody.Parts.Mounting1D torqueReaction_2(n={0,1,0})
  Modelica.Mechanics.MultiBody.Parts.Mounting1D torqueReaction_4(n={0,1,0})
  Modelica.Mechanics.MultiBody.Parts.Mounting1D torqueReaction_3(n={0,1,0})
  Modelica.Mechanics.MultiBody.Parts.Mounting1D torqueReaction_1(n={0,1,0})
protected
  outer Modelica.Mechanics.MultiBody.World world;
  VehicleInterfaces.Interfaces.BrakesBus brakesBus
equation
  connect(computeTorque.y, brake_4.f_normalized)
  connect(computeTorque.y, brake_3.f_normalized)
  connect(computeTorque.y, brake_2.f_normalized)
  connect(computeTorque.y, brake_1.f_normalized)
  connect(brake_1.flange_b, wheelHub_1.flange)
  connect(brake_2.flange_a, wheelHub_2.flange)
  connect(brake_3.flange_a, wheelHub_3.flange)
  connect(brake_4.flange_b, wheelHub_4.flange)
  connect(positionSensor.flange, brakePedal)
  connect(positionSensor.s, computeTorque.u)
  connect(wheelSpeed_1.flange, brake_1.flange_a)
  connect(wheelSpeed_2.flange, brake_2.flange_b)
  connect(wheelSpeed_3.flange, brake_3.flange_b)
  connect(wheelSpeed_4.flange, brake_4.flange_a)
  connect(controlBus.brakesBus, brakesBus)
  connect(wheelSpeed_1.w, brakesBus.wheelSpeed_1)
  connect(wheelSpeed_2.w, brakesBus.wheelSpeed_2)
  connect(wheelSpeed_3.w, brakesBus.wheelSpeed_3)
  connect(wheelSpeed_4.w, brakesBus.wheelSpeed_4)
  connect(torqueReaction_1.frame_a, wheelHub_1.bearingFrame)
  connect(torqueReaction_1.flange_b, brake_1.support)
  connect(torqueReaction_2.frame_a, wheelHub_2.bearingFrame)
  connect(brake_2.support, torqueReaction_2.flange_b)
  connect(torqueReaction_3.frame_a, wheelHub_3.bearingFrame)
  connect(torqueReaction_3.flange_b, brake_3.support)
  connect(torqueReaction_4.frame_a, wheelHub_4.bearingFrame)
  connect(torqueReaction_4.flange_b, brake_4.support)
end MinimalBrakesUsingPedal;


Empty brakes model for 4 wheeled vehicles. Zero torque is applied to all the wheelhubs and the reaction paths in to
the wheel hubs included if the driveTrainMechanics3D flag
in the world object is true.

within VehicleInterfaces.Brakes;
model NoBrakes "Empty brakes model for 4 wheeled vehicles"
  extends VehicleInterfaces.Icons.Brakes;
  extends VehicleInterfaces.Icons.Empty;
  extends VehicleInterfaces.Brakes.Interfaces.TwoAxleBase(includeWheelBearings=world.driveTrainMechanics3D);
protected
  outer Modelica.Mechanics.MultiBody.World world;
end NoBrakes;


within VehicleInterfaces;
package Brakes "Collection of brakes subsystem definitions"
  extends Modelica.Icons.VariantsPackage;
end Brakes;


Brakes Tutorial.

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


Base interface definition for a brakes. This partial model defines the basic interfaces required for any brakes
subsystem. This class should be extended to form a brakes interface
definition with the correct number of wheelHub connectors for the type
of vehicle being modelled. See the
documentation and
tutorial
for more information.

within VehicleInterfaces.Brakes.Interfaces;
partial model Base "Base interface definition for a brakes"

  parameter Boolean usingMultiBodyChassis=false
    "= true, if connecting to a MultiBody chassis"
protected
  parameter Boolean includeBrakePedal=false "Include the brake pedal connection";
  parameter Boolean includeWheelBearings=false "Include the wheel bearing connectors";

public
  Modelica.Mechanics.Translational.Interfaces.Flange_a brakePedal
    if includeBrakePedal "Brake pedal connection (optional)"
  VehicleInterfaces.Interfaces.ControlBus controlBus "Control signal bus"
end Base;


Interface definition for the brakes on a 8 wheeled vehicle. This partial model defines the interfaces required for the brakes subsystem
of a four axled vehicle within the VehicleInterfaces package. See the
documentation and
tutorial
for more information.

within VehicleInterfaces.Brakes.Interfaces;
partial model FourAxleBase
  "Interface definition for the brakes on a 8 wheeled vehicle"
  extends Base;

  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_1(
    final includeBearingConnector=includeWheelBearings)
    "Front left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_2(
    final includeBearingConnector=includeWheelBearings)
    "Front right wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_3(
    final includeBearingConnector=includeWheelBearings)
    "Second axle left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_4(
    final includeBearingConnector=includeWheelBearings)
    "Second axle right wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_5(
    final includeBearingConnector=includeWheelBearings)
    "Third axle left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_6(
    final includeBearingConnector=includeWheelBearings)
    "Third axle right wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_7(
    final includeBearingConnector=includeWheelBearings)
    "Fourth axle left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_8(
    final includeBearingConnector=includeWheelBearings)
    "Fourth axle right wheel"
  Mechanics.MultiBody.MultiBodyEnd end_1(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_2(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_3(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_4(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_5(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_6(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_7(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_8(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
equation
  connect(end_1.flange, wheelHub_1)
  connect(end_2.flange, wheelHub_2)
  connect(end_3.flange, wheelHub_3)
  connect(end_4.flange, wheelHub_4)
  connect(end_5.flange, wheelHub_5)
  connect(end_6.flange, wheelHub_6)
  connect(end_7.flange, wheelHub_7)
  connect(end_8.flange, wheelHub_8)
end FourAxleBase;


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


Interface definition for the brakes on a 6 wheeled vehicle. This partial model defines the interfaces required for the brakes subsystem
of a three axled vehicle within the VehicleInterfaces package. See the
documentation and
tutorial
for more information.

within VehicleInterfaces.Brakes.Interfaces;
partial model ThreeAxleBase
  "Interface definition for the brakes on a 6 wheeled vehicle"
  extends Base;

  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_1(
    final includeBearingConnector=includeWheelBearings)
    "Front left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_2(
    final includeBearingConnector=includeWheelBearings)
    "Front right wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_3(
    final includeBearingConnector=includeWheelBearings)
    "Second axle left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_4(
    final includeBearingConnector=includeWheelBearings)
    "Second axle right wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_5(
    final includeBearingConnector=includeWheelBearings)
    "Third axle left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_6(
    final includeBearingConnector=includeWheelBearings)
    "Third axle right wheel"
  Mechanics.MultiBody.MultiBodyEnd end_1(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_2(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_3(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_4(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_5(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_6(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
equation
  connect(end_1.flange, wheelHub_1)
  connect(end_2.flange, wheelHub_2)
  connect(end_3.flange, wheelHub_3)
  connect(end_4.flange, wheelHub_4)
  connect(end_5.flange, wheelHub_5)
  connect(end_6.flange, wheelHub_6)
end ThreeAxleBase;


Interface definition for the brakes on a 4 wheeled vehicle. This partial model defines the interfaces required for the brakes subsystem
of a two axled vehicle within the VehicleInterfaces package. See the
documentation and
tutorial
for more information.

within VehicleInterfaces.Brakes.Interfaces;
partial model TwoAxleBase
  "Interface definition for the brakes on a 4 wheeled vehicle"
  extends Base;

  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_1(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Front left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_2(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Front right wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_3(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Rear left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_4(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Rear right wheel"
  Mechanics.MultiBody.MultiBodyEnd end_1(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_2(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_3(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_4(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
equation
  connect(end_1.flange, wheelHub_1)
  connect(end_2.flange, wheelHub_2)
  connect(end_3.flange, wheelHub_3)
  connect(end_4.flange, wheelHub_4)
end TwoAxleBase;


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


Basic chassis model with rigid connection between all 4 wheels. Single degree-of-freedom chassis model with mass and speed dependant drag model.

within VehicleInterfaces.Chassis;
model MinimalChassis
  "Basic chassis model with rigid connection between all 4 wheels"
  extends VehicleInterfaces.Icons.Chassis;
  extends VehicleInterfaces.Chassis.Interfaces.TwoAxleBase;

  parameter SI.Mass vehicleMass=1200 "Vehicle mass";
  parameter SI.Radius tyreRadius=0.34 "Tyre rolling radius";
  parameter SI.TranslationalDampingConstant drag=1 "Drag force (force = drag*vehicle_speed)";

  Modelica.Mechanics.Rotational.Components.IdealRollingWheel tyres(
    radius=tyreRadius,
    useSupportT=true,
    useSupportR=true)
  Modelica.Mechanics.Translational.Components.Mass body(
    m=vehicleMass,
    s(stateSelect=StateSelect.always,
      start=0,
      fixed=true))
  Modelica.Mechanics.Translational.Components.Damper dragForces(
    d=drag)
  Modelica.Mechanics.Translational.Components.Fixed ground
  Modelica.Mechanics.Translational.Sensors.SpeedSensor longitudinalVelocity
protected
  VehicleInterfaces.Interfaces.ChassisBus chassisBus
public
  Modelica.Mechanics.Rotational.Components.Fixed fixed
equation
  connect(tyres.flangeT,  body.flange_a)
  connect(body.flange_b, dragForces.flange_a)
  connect(dragForces.flange_b,ground.flange)
  connect(body.flange_b,longitudinalVelocity.flange)
  connect(tyres.flangeR,  wheelHub_1.flange)
  connect(tyres.flangeR,  wheelHub_2.flange)
  connect(tyres.flangeR,  wheelHub_3.flange)
  connect(tyres.flangeR,  wheelHub_4.flange)
  connect(controlBus.chassisBus, chassisBus)
  connect(ground.flange, tyres.supportT)
  connect(fixed.flange, tyres.supportR)
  connect(chassisBus.longitudinalVelocity, longitudinalVelocity.v)
end MinimalChassis;


Basic chassis model with rigid connection between all 4 wheels, uses chassisFrame connection. Single degree-of-freedom chassis model with mass and speed dependant drag model.
Couples the 1d system to a Multibody system to support the other subsystems.

within VehicleInterfaces.Chassis;
model MinimalChassis2
  "Basic chassis model with rigid connection between all 4 wheels, uses chassisFrame connection"
  extends VehicleInterfaces.Icons.Chassis;
  extends VehicleInterfaces.Chassis.Interfaces.TwoAxleBase(includeChassisFrame=true);

  parameter SI.Mass vehicleMass=1200 "Vehicle mass";
  parameter SI.Radius tyreRadius=0.34 "Tyre rolling radius";
  parameter SI.TranslationalDampingConstant drag=1 "Drag force (force = drag*vehicle_speed)";

  Modelica.Mechanics.Rotational.Components.IdealRollingWheel tyres(
    useSupportR=true,
    useSupportT=true,
    radius=tyreRadius)
  Modelica.Mechanics.Translational.Components.Damper dragForces(
    d=drag)
  Modelica.Mechanics.Translational.Sensors.SpeedSensor longitudinalVelocity
  Modelica.Mechanics.MultiBody.Parts.Body body(m=vehicleMass)
  Modelica.Mechanics.MultiBody.Joints.Prismatic constraint(
    useAxisFlange=true,
    a(fixed=false),
    s(fixed=true),
    v(fixed=false))
  Modelica.Mechanics.MultiBody.Parts.Fixed ground
protected
  VehicleInterfaces.Interfaces.ChassisBus chassisBus
public
  Modelica.Mechanics.MultiBody.Parts.Mounting1D mountingR(n=constraint.n)
equation
  connect(tyres.flangeR, wheelHub_2.flange)
  connect(tyres.flangeR, wheelHub_1.flange)
  connect(tyres.flangeR, wheelHub_4.flange)
  connect(tyres.flangeR, wheelHub_3.flange)
  connect(tyres.flangeT, dragForces.flange_a)
  connect(longitudinalVelocity.flange, dragForces.flange_a)
  connect(dragForces.flange_b, constraint.support)
  connect(dragForces.flange_a, constraint.axis)
  connect(controlBus.chassisBus, chassisBus)
  connect(constraint.frame_a, ground.frame_b)
  connect(mountingR.flange_b, tyres.supportR)
  connect(constraint.support, tyres.supportT)
  connect(chassisBus.longitudinalVelocity, longitudinalVelocity.v)
  connect(body.frame_a, mountingR.frame_a)
  connect(body.frame_a, constraint.frame_b)
  connect(body.frame_a, chassisFrame)
end MinimalChassis2;


Basic chassis model with rigid connection between all 4 wheels, uses chassisFrame connection, includes wheel bearings. Single degree-of-freedom chassis model with mass and speed dependant drag model.
Uses MultiBody wheelHub connections and positions these relative to the
vehicle body position.

within VehicleInterfaces.Chassis;
model MinimalChassis3
  "Basic chassis model with rigid connection between all 4 wheels, uses chassisFrame connection, includes wheel bearings"
  extends MinimalChassis2(includeWheelBearings=true, body(r_CM={0,0,0}));

public
  Modelica.Mechanics.MultiBody.Parts.FixedTranslation fixedTranslation(r={0,-1.4,
        0}, animation=false)
  Modelica.Mechanics.MultiBody.Parts.FixedTranslation fixedTranslation1(r={0,
        -1.4,0}, animation=false)
  Modelica.Mechanics.MultiBody.Parts.FixedTranslation fixedTranslation2(r={0,
        0.7,0}, animation=false)
  Modelica.Mechanics.MultiBody.Parts.FixedTranslation fixedTranslation3(r={-2.6,
        0.7,0}, animation=false)
equation
  connect(fixedTranslation.frame_b, wheelHub_2.bearingFrame)
  connect(fixedTranslation1.frame_b, wheelHub_4.bearingFrame)
  connect(fixedTranslation1.frame_a, fixedTranslation3.frame_b)
  connect(fixedTranslation2.frame_b, fixedTranslation.frame_a)
  connect(fixedTranslation2.frame_b, wheelHub_1.bearingFrame)
  connect(fixedTranslation3.frame_b, wheelHub_3.bearingFrame)
  connect(fixedTranslation2.frame_a, fixedTranslation3.frame_a)
  connect(body.frame_a, fixedTranslation2.frame_a)
end MinimalChassis3;


Empty chassis. Empty chassis model. Using this empty model in overall vehicle architecture the functionality of chassis can be eliminated.

within VehicleInterfaces.Chassis;
model NoChassis "Empty chassis"
  extends VehicleInterfaces.Icons.Chassis;
  extends VehicleInterfaces.Icons.Empty;
  extends VehicleInterfaces.Chassis.Interfaces.TwoAxleBase(includeWheelBearings=world.driveTrainMechanics3D);
protected
  outer Modelica.Mechanics.MultiBody.World world;
end NoChassis;


within VehicleInterfaces;
package Chassis "Collection of chassis subsystem definitions"
  extends Modelica.Icons.VariantsPackage;
end Chassis;


Chassis Tutorial.

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


Basic interface definition for a chassis. This partial model defines the basic interfaces required for any chassis
subsystem. This class should be extended to form a chassis interface
definition with the correct number of wheelHub connectors for the type
of vehicle being modelled. See the
documentation and
tutorial
for more information.

within VehicleInterfaces.Chassis.Interfaces;
partial model Base "Basic interface definition for a chassis"

  parameter Boolean usingMultiBodyDriveline=false
    "= true, if connecting to a MultiBody driveline"
protected
  parameter Boolean includeWheelBearings=false "Include wheel bearing connectors";
  parameter Boolean includeChassisFrame=false "Include the chassis frame";
  parameter Boolean includeSteeringWheel=false "Include the steering wheel connection";

public
  Modelica.Mechanics.MultiBody.Interfaces.Frame_b chassisFrame
    if includeChassisFrame "Chassis reference frame (optional)"
  Modelica.Mechanics.Rotational.Interfaces.Flange_a steeringWheel
    if includeSteeringWheel "Steering wheel connection (optional)"

public
  VehicleInterfaces.Interfaces.ControlBus controlBus "Control signal bus"
end Base;


Interface definition for a chassis of a 8 wheeled vehicle. This partial model defines the interfaces required for the chassis subsystem
of a four axled vehicle within the VehicleInterfaces package. See the
documentation and
tutorial
for more information.

within VehicleInterfaces.Chassis.Interfaces;
partial model FourAxleBase
  "Interface definition for a chassis of a 8 wheeled vehicle"
  extends Base;
public
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_1(
    final includeBearingConnector=includeWheelBearings)
    "Front left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_2(
    final includeBearingConnector=includeWheelBearings)
    "Front right wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_3(
    final includeBearingConnector=includeWheelBearings)
    "Second axle left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_4(
    final includeBearingConnector=includeWheelBearings)
    "Second axle right wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_5(
    final includeBearingConnector=includeWheelBearings)
    "Third axle left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_6(
    final includeBearingConnector=includeWheelBearings)
    "Third axle right wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_7(
    final includeBearingConnector=includeWheelBearings)
    "Fourth axle left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_8(
    final includeBearingConnector=includeWheelBearings)
    "Fourth axle right wheel"
  Mechanics.MultiBody.MultiBodyEnd end_1(
    includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
  Mechanics.MultiBody.MultiBodyEnd end_2(
    includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
  Mechanics.MultiBody.MultiBodyEnd end_3(
    includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
  Mechanics.MultiBody.MultiBodyEnd end_4(
    includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
  Mechanics.MultiBody.MultiBodyEnd end_5(
    includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
  Mechanics.MultiBody.MultiBodyEnd end_6(
    includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
  Mechanics.MultiBody.MultiBodyEnd end_7(
    includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
  Mechanics.MultiBody.MultiBodyEnd end_8(
    includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
equation
  connect(end_1.flange, wheelHub_1)
  connect(end_2.flange, wheelHub_2)
  connect(end_3.flange, wheelHub_3)
  connect(end_4.flange, wheelHub_4)
  connect(end_5.flange, wheelHub_6)
  connect(end_6.flange, wheelHub_5)
  connect(end_7.flange, wheelHub_8)
  connect(end_8.flange, wheelHub_7)
end FourAxleBase;


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


Interface definition for a chassis of a 6 wheeled vehicle. This partial model defines the interfaces required for the chassis subsystem
of a three axled vehicle within the VehicleInterfaces package. See the
documentation and
tutorial
for more information.

within VehicleInterfaces.Chassis.Interfaces;
partial model ThreeAxleBase
  "Interface definition for a chassis of a 6 wheeled vehicle"
  extends Base;
public
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_1(
    final includeBearingConnector=includeWheelBearings)
    "Front left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_2(
    final includeBearingConnector=includeWheelBearings)
    "Front right wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_3(
    final includeBearingConnector=includeWheelBearings)
    "Second axle left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_4(
    final includeBearingConnector=includeWheelBearings)
    "Second axle right wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_5(
    final includeBearingConnector=includeWheelBearings)
    "Third axle left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_6(
    final includeBearingConnector=includeWheelBearings)
    "Third axle right wheel"
  Mechanics.MultiBody.MultiBodyEnd end_1(
    includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
  Mechanics.MultiBody.MultiBodyEnd end_2(
    includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
  Mechanics.MultiBody.MultiBodyEnd end_3(
    includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
  Mechanics.MultiBody.MultiBodyEnd end_4(
    includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
  Mechanics.MultiBody.MultiBodyEnd end_5(
    includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
  Mechanics.MultiBody.MultiBodyEnd end_6(
    includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
equation
  connect(end_1.flange, wheelHub_1)
  connect(end_2.flange, wheelHub_2)
  connect(end_3.flange, wheelHub_3)
  connect(end_4.flange, wheelHub_4)
  connect(end_6.flange, wheelHub_5)
  connect(end_5.flange, wheelHub_6)
end ThreeAxleBase;


Interface definition for a chassis of a 4 wheeled vehicle. This partial model defines the interfaces required for the chassis subsystem
of a two axled vehicle within the VehicleInterfaces package. See the
documentation and
tutorial
for more information.

within VehicleInterfaces.Chassis.Interfaces;
partial model TwoAxleBase
  "Interface definition for a chassis of a 4 wheeled vehicle"
  extends Base;
public
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_1(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
    "Front left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_2(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
    "Front right wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_3(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
    "Rear left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_4(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
    "Rear right wheel"
  Mechanics.MultiBody.MultiBodyEnd end_1(
    includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
  Mechanics.MultiBody.MultiBodyEnd end_2(
    includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
  Mechanics.MultiBody.MultiBodyEnd end_3(
    includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
  Mechanics.MultiBody.MultiBodyEnd end_4(
    includeBearingConnector=includeWheelBearings or usingMultiBodyDriveline)
equation
  connect(end_1.flange, wheelHub_1)
  connect(end_2.flange, wheelHub_2)
  connect(end_3.flange, wheelHub_3)
  connect(end_4.flange, wheelHub_4)
end TwoAxleBase;


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


Empty controller. Empty controller model. Using this empty model in overall vehicle architecture the functionality of controller can be eliminated.

within VehicleInterfaces.Controllers;
model NoController "Empty controller"
  extends VehicleInterfaces.Icons.Controller;
  extends VehicleInterfaces.Icons.Empty;
  extends Interfaces.Base;
end NoController;


within VehicleInterfaces;
package Controllers "Collection of controllers subsystem definitions"
  extends Modelica.Icons.VariantsPackage;
end Controllers;


Controllers Tutorial.

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


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

within VehicleInterfaces.Controllers.Interfaces;
partial model Base "Basic interface definition for a controller"

  VehicleInterfaces.Interfaces.ControlBus controlBus "Control signal bus"
end Base;


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


Basic data dictionary example. A simple data dictionary example that creates a new signal called
v_veh within the chassisBus sub-bus of
the control bus.

within VehicleInterfaces.DataDictionaries;
model MinimalExample "Basic data dictionary example"
  extends VehicleInterfaces.Icons.DataDictionary;
  extends VehicleInterfaces.DataDictionaries.Interfaces.Base;
protected
  Modelica.Blocks.Routing.RealPassThrough v_veh
  VehicleInterfaces.Interfaces.ChassisBus chassisBus

equation
  connect(chassisBus, controlBus.chassisBus)
  connect(v_veh.u, chassisBus.longitudinalVelocity)
  connect(chassisBus.v_veh, v_veh.y)
end MinimalExample;


Empty data dictionary. Empty data dictionary model. Using this empty model in overall vehicle architecture the functionality of data dictionary can be eliminated.

within VehicleInterfaces.DataDictionaries;
model NoDataDictionary "Empty data dictionary"
  extends VehicleInterfaces.Icons.DataDictionary;
  extends VehicleInterfaces.Icons.Empty;
  extends VehicleInterfaces.DataDictionaries.Interfaces.Base;
end NoDataDictionary;


within VehicleInterfaces;
package DataDictionaries "Collection of data dictionary definitions"
  extends Modelica.Icons.VariantsPackage;
end DataDictionaries;


Data Dictionary Tutorial.

within VehicleInterfaces.DataDictionaries;
class Tutorial "Data Dictionary Tutorial"
  extends Modelica.Icons.Information;
end Tutorial;


Basic interface definition for a data dictionary. This partial model defines the interfaces required for a data dictionary
within the VehicleInterfaces package. Especially, it provide alias names
for the controBus. See the
documentation and
tutorial
for more information.

within VehicleInterfaces.DataDictionaries.Interfaces;
partial model Base "Basic interface definition for a data dictionary"

  VehicleInterfaces.Interfaces.ControlBus controlBus "Control signal bus"
end Base;


within VehicleInterfaces.DataDictionaries;
package Interfaces "Collection of interface definitions for data dictionary"
  extends Modelica.Icons.InterfacesPackage;
end Interfaces;


Front wheel drive, 4 wheeled vehicle. This driveline model is of a front-wheel drive 4-wheeled vehicle.
The front differential is modelled using an ideal gear and planetary gear.
The model does include the 3D mount effects if the
driveTrainMechanics3D in the world object is set to true.
To properly include these effects the additional constant and
FrameForceAndTorque actuators are required on the front wheel hubs.
A constant zero torque is applied to the rear wheelhubs and the reaction
paths in to the wheelhubs are included.

within VehicleInterfaces.Drivelines;
model MinimalDriveline "Front wheel drive, 4 wheeled vehicle"
  extends VehicleInterfaces.Icons.Driveline;
  extends VehicleInterfaces.Drivelines.Interfaces.TwoAxleBase(includeMount=world.driveTrainMechanics3D);

  parameter SI.Inertia halfshaftInertia=0.1
    "Inertia of each halfshaft";
  parameter Real finalDriveRatio=3 "Final drive ratio";

  Modelica.Mechanics.MultiBody.Parts.Rotor1D rightHalfShaft(
    J=halfshaftInertia)
  Modelica.Mechanics.MultiBody.Parts.Rotor1D leftHalfShaft(
    J=halfshaftInertia)
  Modelica.Mechanics.Rotational.Components.IdealPlanetary differential(
    ratio=1)
protected
  outer Modelica.Mechanics.MultiBody.World world;
public
  Modelica.Mechanics.Rotational.Components.IdealGear finalDrive(
    ratio=finalDriveRatio,
    useSupport=false)
equation
  connect(rightHalfShaft.flange_a, wheelHub_2.flange)
  connect(leftHalfShaft.flange_a, wheelHub_1.flange)
  connect(leftHalfShaft.flange_b, differential.sun)
  connect(differential.ring, rightHalfShaft.flange_b)
  connect(rightHalfShaft.frame_a, drivelineMount)
  connect(leftHalfShaft.frame_a, drivelineMount)
  connect(finalDrive.flange_b, differential.carrier)
  connect(finalDrive.flange_a, transmissionFlange.flange)
end MinimalDriveline;


Empty driveline model for a 4 wheeled vehicle. Zero torque is applied to all the wheelhubs and the reaction paths in to
the wheel hubs included if the driveTrainMechanics3D
flag in the world object is true.

within VehicleInterfaces.Drivelines;
model NoDriveline "Empty driveline model for a 4 wheeled vehicle"
  extends VehicleInterfaces.Icons.Driveline;
  extends VehicleInterfaces.Icons.Empty;
  extends VehicleInterfaces.Drivelines.Interfaces.TwoAxleBase(
    includeWheelBearings=world.driveTrainMechanics3D);
protected
  outer Modelica.Mechanics.MultiBody.World world;
end NoDriveline;


within VehicleInterfaces;
package Drivelines "Collection of drivelines subsystem definitions"
  extends Modelica.Icons.VariantsPackage;
end Drivelines;


Driveline Tutorial.

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


Basic interface definition for a driveline. This partial model defines the basic interfaces required for any driveline
subsystem. This class should be extended to form a driveline interface
definition with the correct number of wheelHub connectors for the type of
vehicle being modelled. See the
documentation and
tutorial
for more information.

within VehicleInterfaces.Drivelines.Interfaces;
partial model Base "Basic interface definition for a driveline"

  parameter Boolean usingMultiBodyChassis=false
    "= true, if connecting to a MultiBody chassis"
  parameter Boolean usingMultiBodyTransmission=false
    "= true, if connecting to a MultiBody transmission"
protected
  parameter Boolean includeWheelBearings=false "Include wheel bearing connectors";
  parameter Boolean includeMount=false "Include the driveline mount";
  parameter Boolean includeTransmissionBearing=false
    "Include the transmission bearing";

public
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing transmissionFlange(
    final includeBearingConnector=includeTransmissionBearing or usingMultiBodyTransmission)
    "Connection to the Transmission output shaft"
  Modelica.Mechanics.MultiBody.Interfaces.Frame_a drivelineMount
    if includeMount "Driveline mount connection (optional)"
  VehicleInterfaces.Interfaces.ControlBus controlBus "Control signal bus"
  Mechanics.MultiBody.MultiBodyEnd end_0(
    final includeBearingConnector=includeTransmissionBearing or usingMultiBodyTransmission)
equation
  connect(end_0.flange, transmissionFlange)
end Base;


Interface definition for a driveline of a 8 wheeled vehicle. This partial model defines the interfaces required for the driveline subsystem
of a four axled vehicle within the VehicleInterfaces package.  See the
documentation and
tutorial
for more information.

within VehicleInterfaces.Drivelines.Interfaces;
partial model FourAxleBase
  "Interface definition for a driveline of a 8 wheeled vehicle"
  extends VehicleInterfaces.Drivelines.Interfaces.Base;

  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_1(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Front left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_2(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Front right wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_3(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Second axle left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_4(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Second axle right wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_5(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Third axle left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_6(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Third axle right wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_7(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Fourth axle left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_8(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Fourth axle right wheel"
  Mechanics.MultiBody.MultiBodyEnd end_1(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_2(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_3(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_4(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_5(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_6(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_7(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_8(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
equation
  connect(end_1.flange, wheelHub_1)
  connect(end_2.flange, wheelHub_2)
  connect(end_3.flange, wheelHub_3)
  connect(end_4.flange, wheelHub_4)
  connect(end_5.flange, wheelHub_5)
  connect(end_6.flange, wheelHub_6)
  connect(end_7.flange, wheelHub_7)
  connect(end_8.flange, wheelHub_8)
end FourAxleBase;


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


Interface definition for a driveline of a 6 wheeled vehicle. This partial model defines the interfaces required for the driveline subsystem
of a three axled vehicle within the VehicleInterfaces package.  See the
documentation and
tutorial
for more information.

within VehicleInterfaces.Drivelines.Interfaces;
partial model ThreeAxleBase
  "Interface definition for a driveline of a 6 wheeled vehicle"
  extends VehicleInterfaces.Drivelines.Interfaces.Base;

  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_1(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Front left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_2(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Front right wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_3(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Second axle left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_4(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Second axle right wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_5(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Third axle left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_6(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Third axle right wheel"
  Mechanics.MultiBody.MultiBodyEnd end_1(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_2(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_3(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_4(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_5(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_6(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
equation
  connect(end_1.flange, wheelHub_1)
  connect(end_2.flange, wheelHub_2)
  connect(end_3.flange, wheelHub_3)
  connect(end_4.flange, wheelHub_4)
  connect(end_5.flange, wheelHub_5)
  connect(end_6.flange, wheelHub_6)
end ThreeAxleBase;


Interface definition for a driveline of a 4 wheeled vehicle. This partial model defines the interfaces required for the driveline subsystem
of a two axled vehicle within the VehicleInterfaces package. See the
documentation and
tutorial
for more information.

within VehicleInterfaces.Drivelines.Interfaces;
partial model TwoAxleBase
  "Interface definition for a driveline of a 4 wheeled vehicle"
  extends Base;

  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_1(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Front left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_2(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Front right wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_3(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Rear left wheel"
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing wheelHub_4(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
    "Rear right wheel"
  Mechanics.MultiBody.MultiBodyEnd end_1(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_2(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_3(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
  Mechanics.MultiBody.MultiBodyEnd end_4(
    final includeBearingConnector=includeWheelBearings or usingMultiBodyChassis)
equation
  connect(end_1.flange, wheelHub_1)
  connect(end_2.flange, wheelHub_2)
  connect(end_3.flange, wheelHub_3)
  connect(end_4.flange, wheelHub_4)
end TwoAxleBase;


Minimal Driver-Vehicle Interface, manual transmission, uses physical pedal connections. Constant acceleration driver with the capabilitiy to step between two
constant throttle values. Fixed gear and constant clutch position.

within VehicleInterfaces.DriverEnvironments;
model ConventionalManual
  "Minimal Driver-Vehicle Interface, manual transmission, uses physical pedal connections"
  extends VehicleInterfaces.Icons.DriverEnvironment;
  extends Interfaces.BaseManualTransmission(
    includeManualShiftConnector=true,
    includeAcceleratorPedal=true,
    includeBrakePedal=true,
    includeClutchPedal=true);

public
  parameter Real initialAccelRequest(min=0, max=1) = 1 "Initial accelerator pedal position";
  parameter Real initialBrakeRequest(min=0, max=1) = 0 "Initial brake pedal position";
  parameter Real finalAccelRequest(min=0, max=1) = 1 "Final accelerator pedal position";
  parameter Real finalBrakeRequest(min=0, max=1) = 0 "Final brake pedal position";
  parameter SI.Time accelTime=10 "Time of accel apply";
  parameter SI.Time brakeTime=10 "Time of brake apply";
  parameter VehicleInterfaces.Types.Gear selectedGear=2
    "Requested gear in manual mode";
  parameter Real clutchRequest=0
    "Clutch position (constant during simulation)";

  Modelica.Blocks.Sources.Step brakeDemand(
    height=finalBrakeRequest,
    offset=initialBrakeRequest,
    startTime=brakeTime)
  Modelica.Blocks.Sources.Step acceleratorDemand(
    height=finalAccelRequest,
    offset=initialAccelRequest,
    startTime=accelTime)
  Modelica.Blocks.Sources.IntegerConstant gear(k=selectedGear)
  Modelica.Blocks.Sources.Constant clutchDemand(k=clutchRequest)
  VehicleInterfaces.Interfaces.ShiftInput shiftInput
  Modelica.Mechanics.Translational.Sources.Position acceleratorPosition
  Modelica.Mechanics.Translational.Sources.Position clutchPosition
  Modelica.Mechanics.Translational.Sources.Position brakePosition
  Modelica.Blocks.Sources.IntegerStep ignition(
    height=-1,
    startTime=0.5,
    offset=VehicleInterfaces.Types.IgnitionSetting.Start)
protected
  VehicleInterfaces.Interfaces.DriverBus driverBus
equation
  connect(acceleratorDemand.y, acceleratorPosition.s_ref)
  connect(acceleratorPosition.flange,   acceleratorPedal)
  connect(brakeDemand.y, brakePosition.s_ref)
  connect(brakePosition.flange,   brakePedal)
  connect(clutchDemand.y, clutchPosition.s_ref)
  connect(clutchPosition.flange,   clutchPedal)
  connect(shiftInput.shiftConnector, shiftConnector)
  connect(gear.y, shiftInput.gear)
  connect(controlBus.driverBus, driverBus)
  connect(ignition.y, driverBus.ignition)
end ConventionalManual;


Minimal Drive-by-wire Driver-Vehicle Interface. Constant acceleration driver with the capabilitiy to step between two
constant throttle values and to step on/off the brakes.

within VehicleInterfaces.DriverEnvironments;
model DriveByWireAutomatic "Minimal Drive-by-wire Driver-Vehicle Interface"
  extends VehicleInterfaces.Icons.DriverEnvironment;
  extends VehicleInterfaces.DriverEnvironments.Interfaces.BaseAutomaticTransmission;
public
  parameter Real initialAccelRequest(min=0, max=1) = 1 "Initial accelerator pedal position";
  parameter Real initialBrakeRequest(min=0, max=1) = 0 "Initial brake pedal position";
  parameter Real finalAccelRequest(min=0, max=1) = 1 "Final accelerator pedal position";
  parameter Real finalBrakeRequest(min=0, max=1) = 0 "Final brake pedal position";
  parameter SI.Time accelTime=10 "Time of accel apply";
  parameter SI.Time brakeTime=10 "Time of brake apply";
  parameter VehicleInterfaces.Types.GearMode.Temp selectedGearboxMode=
    VehicleInterfaces.Types.GearMode.Drive "Current gearbox mode";
  parameter VehicleInterfaces.Types.Gear manualGearRequest=0
    "Requested gear in manual mode";

  Modelica.Blocks.Sources.Step brakeDemand(
    height=finalBrakeRequest,
    offset=initialBrakeRequest,
    startTime=brakeTime)
  Modelica.Blocks.Sources.Step acceleratorDemand(
    height=finalAccelRequest,
    offset=initialAccelRequest,
    startTime=accelTime)

  Modelica.Blocks.Sources.IntegerConstant gearSelect(k=manualGearRequest)
  Modelica.Blocks.Sources.IntegerConstant gearMode(k=selectedGearboxMode)
  Modelica.Blocks.Sources.IntegerStep ignition(
    height=-1,
    startTime=0.5,
    offset=VehicleInterfaces.Types.IgnitionSetting.Start)
protected
  VehicleInterfaces.Interfaces.DriverBus driverBus
equation
  connect(controlBus.driverBus, driverBus)
  connect(acceleratorDemand.y, driverBus.acceleratorPedalPosition)
  connect(gearSelect.y, driverBus.requestedGear)
  connect(driverBus.brakePedalPosition, brakeDemand.y)
  connect(gearMode.y, driverBus.gearboxMode)
  connect(ignition.y, driverBus.ignition)
end DriveByWireAutomatic;


Minimal drive-by-wire driver-vehicle interface with external driver model. Driver environment that requires an external driver model. Signals received
from external driver model are simply propagated throug withouth any
modification.

within VehicleInterfaces.DriverEnvironments;
model DriveByWireAutomaticExternalDriver
  "Minimal drive-by-wire driver-vehicle interface with external driver model"
  extends VehicleInterfaces.Icons.DriverEnvironment;
  extends Interfaces.BaseAutomaticTransmissionExternalDriver;

public
  Mechanics.NormalisedTranslational.PositionSensor acceleratorPosition
  Mechanics.NormalisedTranslational.PositionSensor brakePosition
  Modelica.Blocks.Routing.IntegerPassThrough gearboxMode
  Modelica.Blocks.Routing.IntegerPassThrough requestedGear
  Modelica.Blocks.Routing.IntegerPassThrough ignition
protected
  VehicleInterfaces.Interfaces.DriverBus driverBus
equation
  connect(driverBus, controlBus.driverBus)
  connect(driverInterface.gearboxMode, gearboxMode.u)
  connect(gearboxMode.y, driverBus.gearboxMode)
  connect(driverInterface.requestedGear, requestedGear.u)
  connect(requestedGear.y, driverBus.requestedGear)
  connect(driverInterface.ignition, ignition.u)
  connect(ignition.y, driverBus.ignition)
  connect(driverInterface.brakePedal, brakePosition.flange_a)
  connect(driverInterface.acceleratorPedal, acceleratorPosition.flange_a)
  connect(acceleratorPosition.position, driverBus.acceleratorPedalPosition)
  connect(brakePosition.position, driverBus.brakePedalPosition)
end DriveByWireAutomaticExternalDriver;


Empty driver-vehicle interface. Empty driver environment. Using this empty model in overall vehicle
architecture the functionality of driver environment can be eliminated.

within VehicleInterfaces.DriverEnvironments;
model NoDriverEnvironment "Empty driver-vehicle interface"
  extends VehicleInterfaces.Icons.DriverEnvironment;
  extends VehicleInterfaces.Icons.Empty;
  extends Interfaces.Base;
end NoDriverEnvironment;


within VehicleInterfaces;
package DriverEnvironments "Collection of driver environment subsystem definitions"
  extends Modelica.Icons.VariantsPackage;
end DriverEnvironments;


Driver Environment Tutorial.

within VehicleInterfaces.DriverEnvironments;
class Tutorial "Driver Environment Tutorial"
  extends Modelica.Icons.Information;
end Tutorial;


Basic interface definition for the driver-vehicle interface. This partial model defines the interfaces required for the driver environment
subsystem. See the
documentation
and
tutorial
for more information.

within VehicleInterfaces.DriverEnvironments.Interfaces;
partial model Base
  "Basic interface definition for the driver-vehicle interface"

  VehicleInterfaces.Interfaces.ControlBus controlBus "Control signal bus"
  Modelica.Mechanics.MultiBody.Interfaces.Frame_a chassisFrame
    if includeDriverSeat "Chassis reference frame (optional)"
  Modelica.Mechanics.Rotational.Interfaces.Flange_a steeringWheel
    if includeSteeringWheel "Steering wheel connection (optional)"
  Modelica.Mechanics.Translational.Interfaces.Flange_a acceleratorPedal
    if includeAcceleratorPedal "Accelerator pedal connection (optional)"
  Modelica.Mechanics.Translational.Interfaces.Flange_a brakePedal
    if includeBrakePedal "Brake pedal connection (optional)"
protected
  parameter Boolean includeDriverSeat=false
    "Include the drivers seat connection to the body";
  parameter Boolean includeSteeringWheel=false
    "Include the steering wheel connection";
  parameter Boolean includeAcceleratorPedal=false
    "Include the accelerator pedal connection";
  parameter Boolean includeBrakePedal=false
    "Include the brake pedal connection";
end Base;


Interface definition for the driver-vehicle interface with an automatic transmission. Base class for driver models for vehicles with automatic transmissions
where the driver control logic is contained within the derived model.

within VehicleInterfaces.DriverEnvironments.Interfaces;
partial model BaseAutomaticTransmission
  "Interface definition for the driver-vehicle interface with an automatic transmission"
  extends Base;
end BaseAutomaticTransmission;


Interface definition for the driver-vehicle interface with an automatic transmission and external driver. Base class for driver models for vehicles with automatic transmissions
where the driver control logic is contained in an
external driver model.

within VehicleInterfaces.DriverEnvironments.Interfaces;
partial model BaseAutomaticTransmissionExternalDriver
  "Interface definition for the driver-vehicle interface with an automatic transmission and external driver"
  extends BaseAutomaticTransmission;
  replaceable VehicleInterfaces.Interfaces.DriverInterface driverInterface
    "Driver Interaction Bus"
end BaseAutomaticTransmissionExternalDriver;


Interface definition for the driver-vehicle interface with a manual transmission. Base class for driver models for vehicles with manual transmissions where
the driver control logic is contained within the derived model.

within VehicleInterfaces.DriverEnvironments.Interfaces;
partial model BaseManualTransmission
  "Interface definition for the driver-vehicle interface with a manual transmission"
  extends Base;
protected
  parameter Boolean includeClutchPedal=false
    "Include the clutch pedal connection";
  parameter Boolean includeManualShiftConnector=false
    "Include the manual shift connection";
public
  Modelica.Mechanics.Translational.Interfaces.Flange_a clutchPedal if
    includeClutchPedal "Clutch pedal connection (optional)"
  VehicleInterfaces.Interfaces.ShiftConnector shiftConnector if
    includeManualShiftConnector
    "Manual transmission shift connection (optional)"
end BaseManualTransmission;


Interface definition for the driver-vehicle interface with a manual transmission and external driver. Base class for driver models for vehicles with manual transmissions where
the driver control logic is contained in an
external driver model.

within VehicleInterfaces.DriverEnvironments.Interfaces;
partial model BaseManualTransmissionExternalDriver
  "Interface definition for the driver-vehicle interface with a manual transmission and external driver"
  extends BaseManualTransmission;
  replaceable VehicleInterfaces.Interfaces.DriverInterface driverInterface
    "Driver Interaction Bus"
end BaseManualTransmissionExternalDriver;


within VehicleInterfaces.DriverEnvironments;
package Interfaces "Collection of interface definitions for driver environment"
  extends Modelica.Icons.InterfacesPackage;
end Interfaces;


within VehicleInterfaces.DriverEnvironments;
package Internal "Collection of internal material involving driver environments"
  extends Modelica.Icons.InternalPackage;
end Internal;


Constant acceleration Driver. Constant acceleration driver with the capabilitiy to step between two
constant throttle values.

within VehicleInterfaces.Drivers;
model MinimalDriver "Constant acceleration Driver"
  extends VehicleInterfaces.Icons.Driver;
  extends VehicleInterfaces.Drivers.Interfaces.Base;
  parameter Real initialAccelRequest(min=0, max=1) = 1 "Initial accelerator pedal position";
  parameter Real initialBrakeRequest(min=0, max=1) = 0 "Initial brake pedal position";
  parameter Real finalAccelRequest(min=0, max=1) = 1 "Final accelerator pedal position";
  parameter Real finalBrakeRequest(min=0, max=1) = 0 "Final brake pedal position";
  parameter SI.Time accelTime=10 "Time of accel apply";
  parameter SI.Time brakeTime=10 "Time of brake apply";
  parameter VehicleInterfaces.Types.GearMode.Temp selectedGearboxMode=
      VehicleInterfaces.Types.GearMode.Drive "Current gearbox mode";
  parameter VehicleInterfaces.Types.Gear manualGearRequest=0
    "Requested gear in manual mode";

  Modelica.Blocks.Sources.Step brakeDemand(
    height=finalBrakeRequest,
    offset=initialBrakeRequest,
    startTime=brakeTime)
  Modelica.Blocks.Sources.Step acceleratorDemand(
    height=finalAccelRequest,
    offset=initialAccelRequest,
    startTime=accelTime)
  Modelica.Blocks.Sources.Constant steeringAngle(k=0)
  Modelica.Blocks.Sources.IntegerConstant gearboxMode(k=selectedGearboxMode)
  Modelica.Blocks.Sources.IntegerConstant requestedGear(k=manualGearRequest)
  Mechanics.NormalisedRotational.Position steeringWheelAngle
  Mechanics.NormalisedTranslational.Position brakePosition
  Mechanics.NormalisedTranslational.Position acceleratorPosition
  Modelica.Blocks.Sources.IntegerStep ignition(
    height=-1,
    startTime=0.5,
    offset=VehicleInterfaces.Types.IgnitionSetting.Start)
equation
  connect(gearboxMode.y, driverInterface.gearboxMode)
  connect(requestedGear.y, driverInterface.requestedGear)
  connect(ignition.y, driverInterface.ignition)
  connect(steeringAngle.y, steeringWheelAngle.phi_ref)
  connect(brakeDemand.y, brakePosition.position)
  connect(acceleratorDemand.y, acceleratorPosition.position)
  connect(brakePosition.flange_b, driverInterface.brakePedal)
  connect(acceleratorPosition.flange_b, driverInterface.acceleratorPedal)
  connect(steeringWheelAngle.flange_b, driverInterface.steeringWheel)
end MinimalDriver;


Empty driver. Empty driver model. Using this empty model in overall vehicle architecture
the functionality of driver can be eliminated.

within VehicleInterfaces.Drivers;
model NoDriver "Empty driver"
  extends VehicleInterfaces.Drivers.Interfaces.Base;
  extends VehicleInterfaces.Icons.Driver;
  extends VehicleInterfaces.Icons.Empty;
end NoDriver;


within VehicleInterfaces;
package Drivers "Collection of driver subsystem definitions"
  extends Modelica.Icons.VariantsPackage;
end Drivers;


Drivers Tutorial

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


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

within VehicleInterfaces.Drivers.Interfaces;
partial model Base "Basic interface definition for a driver"

  VehicleInterfaces.Interfaces.DriverInterface driverInterface "Driver Interaction Bus"
end Base;


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


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


within VehicleInterfaces;
package ElectricDrives "Collection of electric drive subsystem definitions"
  extends Modelica.Icons.VariantsPackage;
end ElectricDrives;


Simple DC electric motor. A simple DC electric motor with inductance and internal resistance.

within VehicleInterfaces.ElectricDrives;
model SimpleMotorDC "Simple DC electric motor"
  extends Interfaces.BaseDCMachine;
  extends VehicleInterfaces.Icons.ElectricMotor;
  parameter SI.Inductance L=1e-3 "Inductance";
  parameter SI.Resistance R=10 "Resistance";
  parameter SI.ElectricalTorqueConstant k=0.4 "Transformation coefficient";

  Modelica.Electrical.Analog.Basic.Resistor resistor(R=R)
  Modelica.Electrical.Analog.Basic.Inductor inductor(L=L)
  Modelica.Electrical.Analog.Basic.RotationalEMF eMF(k=k)
equation
  connect(eMF.flange,   shaft_b.flange)
  connect(inductor.n, resistor.p)
  connect(resistor.n, eMF.n)
  connect(eMF.p, pin_p)
  connect(inductor.p, pin_n)
end SimpleMotorDC;


Electric Drives Tutorial.

within VehicleInterfaces.ElectricDrives;
class Tutorial "Electric Drives Tutorial"
  extends Modelica.Icons.Information;
end Tutorial;


Basic interface for an electric drives. This partial model defines the interfaces required for an electric machine
subsystem. This class should be extended to form an electric machine
interface definition with propper electrical connectors. See the
documentation
and
tutorial
for more information.

within VehicleInterfaces.ElectricDrives.Interfaces;
partial model Base "Basic interface for an electric drives"

  parameter Boolean usingMultiBodySystem=false
    "= true, if connecting to a MultiBody system"
protected
  parameter Boolean includeBearing=false "Include bearing connector";

public
  Modelica.Mechanics.MultiBody.Interfaces.FlangeWithBearing shaft_b(
    includeBearingConnector=includeBearing or usingMultiBodySystem)
    "Mechanical shaft"
  VehicleInterfaces.Interfaces.ControlBus controlBus "Control signal bus"
  Mechanics.MultiBody.MultiBodyEnd end_1(
    includeBearingConnector=includeBearing or usingMultiBodySystem)
equation
  connect(end_1.flange, shaft_b)
end Base;


Base interface for electric drive in series. This partial model defines the interfaces required for an electric machine
subsystem. This class should be extended to form a particular electric
machine model. See the
documentation
and
tutorial
for more information.

within VehicleInterfaces.ElectricDrives.Interfaces;
partial model BaseDCMachine "Base interface for electric drive in series"
  extends VehicleInterfaces.ElectricDrives.Interfaces.Base;
  Modelica.Electrical.Analog.Interfaces.PositivePin pin_p
    "Positive electrical pin"
  Modelica.Electrical.Analog.Interfaces.NegativePin pin_n
    "Negative electrical pin"
end BaseDCMachine;


within VehicleInterfaces.ElectricDrives;
package Interfaces "Collection of interface definitions for electric drive"
  extends Modelica.Icons.InterfacesPackage;
end Interfaces;


Simple battery. An ideal battery with a constant voltage. No state of charge is introduced.

within VehicleInterfaces.EnergyStorage;
model Battery "Simple battery"
  parameter SI.Voltage V(start=1) "Value of constant voltage";
  extends .VehicleInterfaces.Icons.Battery;
  extends .VehicleInterfaces.EnergyStorage.Interfaces.Base(heatPort(Q_flow=0));

  Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage(V=V)
equation
  connect(constantVoltage.p, pin_p)
  connect(constantVoltage.n, pin_n)
end Battery;


within VehicleInterfaces;
package EnergyStorage "Collection of energy storage subsystem definitions"
  extends Modelica.Icons.VariantsPackage;
end EnergyStorage;


Energy Storage Device Tutorial.

within VehicleInterfaces.EnergyStorage;
class Tutorial "Energy Storage Device Tutorial"
  extends Modelica.Icons.Information;
end Tutorial;