Oscillator demonstrates the use of initial conditions. A spring - mass system is a mechanical oscillator. If no
damping is included and the system is excited at resonance
frequency infinite amplitudes will result.
The resonant frequency is given by
omega_res = sqrt(c / m)
with:

within Modelica.Mechanics.Translational.Examples;
model Oscillator "Oscillator demonstrates the use of initial conditions"

  extends Modelica.Icons.Example;

  Translational.Components.Mass mass1(
    L=1,
    s(start=-0.5, fixed=true),
    v(start=0, fixed=true),
    m=1)
  Translational.Components.Spring spring1(s_rel0=1, c=10000)
  Translational.Components.Fixed fixed1(s0=1)
  Translational.Sources.Force force1
  Modelica.Blocks.Sources.Sine sine1(f=15.9155)
  Translational.Components.Mass mass2(
    L=1,
    s(start=-0.5, fixed=true),
    v(start=0, fixed=true),
    m=1)
  Translational.Components.Spring spring2(s_rel0=1, c=10000)
  Translational.Components.Fixed fixed2(s0=1)
  Translational.Sources.Force force2
  Modelica.Blocks.Sources.Sine sine2(f=15.9155)
  Translational.Components.Damper damper1(d=10)
equation
  connect(mass1.flange_b, spring1.flange_a)
  connect(spring2.flange_a, damper1.flange_a)
  connect(mass2.flange_b, spring2.flange_a)
  connect(damper1.flange_b, spring2.flange_b)
  connect(sine1.y, force1.f)
  connect(sine2.y, force2.f)
  connect(spring1.flange_b, fixed1.flange)
  connect(force2.flange, mass2.flange_a)
  connect(force1.flange, mass1.flange_a)
  connect(spring2.flange_b, fixed2.flange)
end Oscillator;


within Modelica.Mechanics.Translational;
package Examples "Demonstration examples of the components of this package"

  extends Modelica.Icons.ExamplesPackage;
end Examples;


Preload of a spool using ElastoGap models. When designing hydraulic valves it is often necessary to hold the spool in
a certain position as long as an external force is below a threshold value.
If this force exceeds the threshold value a linear relation between force
and position is desired.
There are designs that need only one spring to accomplish this task. Using
the ElastoGap elements this design can be modelled easily.
Drawing of spool.

within Modelica.Mechanics.Translational.Examples;
model PreLoad "Preload of a spool using ElastoGap models"

  extends Modelica.Icons.Example;

  Translational.Components.ElastoGap innerContactA(
    c=1000e3,
    d=250,
    s_rel0=0.001)
  Translational.Components.ElastoGap innerContactB(
    c=1000e3,
    d=250,
    s_rel0=0.001)
  Translational.Components.Mass spool(
    L=0.19,
    m=0.150,
    s(start=0.01475, fixed=true),
    v(fixed=true))
  Translational.Components.Fixed fixedLe(s0=-0.0955)
  Translational.Components.Mass springPlateA(
    m=10e-3,
    L=0.002,
    s(start=-0.093, fixed=true),
    v(fixed=true))
  Translational.Components.Mass springPlateB(
    m=10e-3,
    s(start=-0.06925, fixed=true),
    L=0.002,
    v(fixed=true))
  Translational.Components.Spring spring(c=20e3, s_rel0=0.025)
  Translational.Components.ElastoGap outerContactA(
    c=1000e3,
    d=250,
    s_rel0=0.0015)
  Translational.Components.ElastoGap outerContactB(
    c=1000e3,
    d=250,
    s_rel0=0.0015)
  Translational.Components.Rod rod1(L=0.007)
  Translational.Components.Damper friction(d=2500)
  Translational.Sources.Force force
  Translational.Components.Rod housing(L=0.0305)
  Translational.Components.Rod rod3(L=0.00575)
  Translational.Components.Rod rod4(L=0.00575)
  Translational.Components.Rod rod2(L=0.007)
  Modelica.Blocks.Sources.Sine sineForce(amplitude=150, f=0.01)
equation
  connect(outerContactA.flange_b, springPlateA.flange_a)
  connect(springPlateA.flange_b, spring.flange_a)
  connect(spring.flange_b, springPlateB.flange_a)
  connect(springPlateB.flange_b, outerContactB.flange_a)
  connect(outerContactB.flange_b, housing.flange_b)
  connect(springPlateA.flange_b, rod1.flange_a)
  connect(innerContactA.flange_a, rod3.flange_a)
  connect(innerContactA.flange_b, rod1.flange_b)
  connect(rod2.flange_a, innerContactB.flange_a)
  connect(rod4.flange_b, innerContactB.flange_b)
  connect(friction.flange_b, rod3.flange_a)
  connect(rod3.flange_b, rod4.flange_a)
  connect(rod2.flange_b, springPlateB.flange_a)
  connect(spool.flange_a, rod4.flange_a)
  connect(sineForce.y, force.f)
  connect(force.flange, spool.flange_a)
  connect(outerContactA.flange_a, fixedLe.flange)
  connect(housing.flange_a, fixedLe.flange)
  connect(friction.flange_a, fixedLe.flange)
end PreLoad;


Sensors for translational systems. These sensors measure

within Modelica.Mechanics.Translational.Examples;
model Sensors "Sensors for translational systems"
  extends Modelica.Icons.Example;

  Translational.Sensors.ForceSensor forceSensor
  Modelica.Mechanics.Translational.Sensors.MultiSensor multiSensor
  Translational.Sensors.SpeedSensor speedSensor1
  Translational.Sensors.PositionSensor positionSensor1
  Translational.Sensors.AccSensor accSensor1
  Translational.Sensors.PositionSensor positionSensor2
  Translational.Components.Mass mass(
    L=1,
    s(fixed=true),
    v(fixed=true),
    m=1)
  Translational.Sources.Force force
  Modelica.Blocks.Sources.Sine sineForce(amplitude=10, f=4)
equation
  connect(sineForce.y, force.f)
  connect(forceSensor.flange_a, force.flange)
  connect(mass.flange_a, positionSensor1.flange)
  connect(mass.flange_a, speedSensor1.flange)
  connect(mass.flange_a, accSensor1.flange)
  connect(mass.flange_b, positionSensor2.flange)
  connect(forceSensor.flange_b, multiSensor.flange_a)
  connect(multiSensor.flange_b, mass.flange_a)
end Sensors;


Examples for the used sign conventions. If all arrows point in the same direction, a positive force
results in a positive acceleration <var>a</var>, velocity <var>v</var> and position <var>s</var>.

within Modelica.Mechanics.Translational.Examples;
model SignConvention "Examples for the used sign conventions"
  extends Modelica.Icons.Example;
  Translational.Components.Mass mass1(
    L=1,
    s(fixed=true),
    v(fixed=true),
    m=1)
  Translational.Sources.Force force1
  Modelica.Blocks.Sources.Constant constant1(k=1)
  Translational.Components.Mass mass2(
    L=1,
    s(fixed=true),
    v(fixed=true),
    m=1)
  Translational.Sources.Force force2
  Modelica.Blocks.Sources.Constant constant2(k=1)
  Translational.Components.Mass mass3(
    L=1,
    s(fixed=true),
    v(fixed=true),
    m=1)
  Translational.Sources.Force force3(useSupport=false)
  Modelica.Blocks.Sources.Constant constant3(k=1)
  Translational.Components.Fixed fixed
equation
  connect(constant1.y, force1.f)
  connect(constant2.y, force2.f)
  connect(constant3.y, force3.f)
  connect(force1.flange, mass1.flange_a)
  connect(force2.flange, mass2.flange_b)
  connect(mass3.flange_b, force3.flange)
  connect(fixed.flange, force3.support)
end SignConvention;


One-dimensional vehicle with driving resistances. Vehicles vehicle and vehicle1 are accelerated
and decelerated by a driving torque.
Nominal torque is defined as the sum of driving resistances at nominal
velocity vNom times wheel radius R.

within Modelica.Mechanics.Translational.Examples;
model Vehicle "One-dimensional vehicle with driving resistances"
  extends Modelica.Icons.Example;
  import Modelica.Constants.g_n;
  parameter SI.Mass m=100 "Mass of vehicle";
  parameter SI.Length R=0.25 "Radius of wheel";
  parameter SI.Area A=1 "Cross section of vehicle";
  parameter Real Cd=0.5 "Drag resistance coefficient";
  parameter SI.Density rho=1.18 "Density of air";
  parameter SI.Velocity vWind=0 "Constant wind velocity";
  parameter Real Cr=0.01 "Rolling resistance coefficient";
  //Check nominal force
  parameter Real inclination=0 "Constant inclination = tan(angle)";
  parameter SI.Velocity vNom=25/3.5 "Nominal velocity";
  final parameter SI.Force fDrag=Cd*A*rho*(vNom - vWind)^2/2 "Drag resistance"
  final parameter SI.Angle alpha=atan(inclination) "Inclination angle"
  final parameter SI.Force fRoll=Cr*m*g_n*cos(alpha) "Roll resistance"
  final parameter SI.Force fGrav=m*g_n*sin(alpha) "Grav resistance"
  Components.Vehicle vehicle(
    m=m,
    J=0,
    R=R,
    A=A,
    Cd=Cd,
    CrConstant=Cr,
    vWindConstant=vWind,
    useInclinationInput=true,
    s(fixed=true),
    v(fixed=true))
  Components.Vehicle vehicle1(
    m=m,
    J=0,
    R=R,
    A=A,
    Cd=Cd,
    CrConstant=Cr,
    vWindConstant=vWind,
    useInclinationInput=true,
    s(fixed=true),
    v(fixed=true))
  Components.Vehicle trailer(
    m=m,
    J=0,
    R=R,
    A=A,
    Cd=Cd,
    CrConstant=Cr,
    vWindConstant=vWind,
    useInclinationInput=true,
    s(fixed=false),
    v(fixed=false))
  Modelica.Mechanics.Translational.Sensors.MultiSensor multiSensor
  Modelica.Blocks.Sources.CombiTimeTable timeTableTorqueInclination(
    table=[0,0,0; 5,0,0; 5,5.6,0; 10.8,5.6,0; 10.8,1,0; 20,1,0; 20,2.8,0.05;
           25,2.8,0.05; 25,1,0; 50,1,0; 50,-5,0; 55,-5,0; 55,0,0; 60,0,0],
    extrapolation=Modelica.Blocks.Types.Extrapolation.HoldLastPoint)
  Rotational.Sources.Torque torque
  Rotational.Sources.Torque torque1
  Modelica.Blocks.Math.Gain gain(k=(fDrag + fRoll + fGrav)*R)
  Blocks.Math.Gain gain1(k=2)
equation
  connect(timeTableTorqueInclination.y[1], gain.u)
  connect(timeTableTorqueInclination.y[2], vehicle.inclination)
  connect(gain.y, torque.tau)
  connect(torque.flange, vehicle.flangeR)
  connect(torque1.flange, vehicle1.flangeR)
  connect(vehicle.inclination, vehicle1.inclination)
  connect(vehicle1.inclination, trailer.inclination)
  connect(gain.y, gain1.u)
  connect(gain1.y, torque1.tau)
  connect(vehicle1.flangeT, multiSensor.flange_a)
  connect(multiSensor.flange_b, trailer.flangeT)
end Vehicle;


Use of arrows in Mechanics.Translational. When using the models of the translational sublibrary
it is recommended to make sure that all arrows point in
the same direction because then all component have the
same reference system.
In the example the distance from flange_a of Rod1 to flange_b
of Rod2 is 2 m. The distance from flange_a of Rod1 to flange_b
of Rod3 is also 2 m though it is difficult to see that. Without
the arrows it would be almost impossible to notice.
That all arrows point in the same direction is a sufficient
condition for an easy use of the library. There are cases
where horizontally flipped models can be used without
problems.

within Modelica.Mechanics.Translational.Examples;
model WhyArrows "Use of arrows in Mechanics.Translational"

  extends Modelica.Icons.Example;

  Translational.Components.Fixed fixed
  Translational.Components.Rod rod1(L=1)
  Translational.Components.Rod rod2(L=1)
  Translational.Components.Rod rod3(L=1)
  Translational.Sensors.PositionSensor positionSensor2
  Translational.Sensors.PositionSensor positionSensor1
  Translational.Sensors.PositionSensor positionSensor3
  Translational.Components.Fixed fixed1(s0=-1.9)
  Translational.Components.Spring spring1(s_rel0=2, c=11)
  Translational.Components.Mass mass1(
    L=2,
    s(fixed=true),
    v(fixed=true),
    m=1)
  Translational.Components.Fixed fixed2(s0=-1.9)
  Translational.Components.Spring spring2(s_rel0=2, c=11)
  Translational.Components.Mass inertia2(
    L=2,
    m=1,
    s(fixed=true),
    v(fixed=true))
equation
  connect(spring1.flange_b, mass1.flange_b)
  connect(spring2.flange_b, inertia2.flange_b)
  connect(rod3.flange_b, positionSensor3.flange)
  connect(rod1.flange_a, positionSensor1.flange)
  connect(rod1.flange_b, fixed.flange)
  connect(rod3.flange_a, fixed.flange)
  connect(fixed.flange, rod2.flange_a)
  connect(rod2.flange_b, positionSensor2.flange)
  connect(fixed1.flange, spring1.flange_a)
  connect(fixed2.flange, spring2.flange_a)
end WhyArrows;


Input/output block of a direct mass model. A translational component with pure signal interface which can be applied for
a FMU (Functional Mock-up Unit)
exchange.
The input force fDrive is applied on one side of a sliding mass
whereby the input force f is applied
on the other side of it.

within Modelica.Mechanics.Translational.Examples.Utilities;
model DirectMass "Input/output block of a direct mass model"
  extends Modelica.Blocks.Icons.Block;
  parameter SI.Mass m(min=0)=1 "Mass";
  Modelica.Mechanics.Translational.Components.Mass mass(
    m=m,
    s(start=0, fixed=true),
    v(start=0, fixed=true))
  Modelica.Mechanics.Translational.Sources.Force forceSource
  Modelica.Blocks.Interfaces.RealInput fDrive(unit="N")
    "Accelerating force acting at flange (= -flange.f)"
  Modelica.Mechanics.Translational.Components.GeneralForceToPositionAdaptor forceToPosition
  Modelica.Blocks.Interfaces.RealOutput s(unit="m")
    "Mass moves with position s due to force f"
  Modelica.Blocks.Interfaces.RealOutput v(unit="m/s")
    "Mass moves with speed v due to force f"
  Modelica.Blocks.Interfaces.RealOutput a(unit="m/s2")
    "Mass moves with acceleration a due to force f"
  Modelica.Blocks.Interfaces.RealInput f(unit="N") "Force to drive the mass"
equation
  connect(forceToPosition.f, f)
  connect(forceToPosition.p, s)
  connect(forceToPosition.pder, v)
  connect(forceToPosition.pder2, a)
  connect(fDrive, forceSource.f)
  connect(forceSource.flange, mass.flange_a)
  connect(mass.flange_b, forceToPosition.flange)
end DirectMass;


Input/output block of an inverse mass model. A translational component with pure signal interface which can be applied for
a FMU (Functional Mock-up Unit)
exchange.
Based on the kinematic inputs applied on a sliding mass
the output force f is returned.

within Modelica.Mechanics.Translational.Examples.Utilities;
model InverseMass "Input/output block of an inverse mass model"
  extends Modelica.Blocks.Icons.Block;
  parameter SI.Mass m=1 "Mass";
  Modelica.Mechanics.Translational.Components.Mass mass(
    m=m)
  Modelica.Mechanics.Translational.Components.GeneralPositionToForceAdaptor positionToForce
  Modelica.Blocks.Interfaces.RealInput s(unit="m") "Position to drive the mass"
  Modelica.Blocks.Interfaces.RealInput v(unit="m/s") "Speed to drive the mass"
  Modelica.Blocks.Interfaces.RealInput a(unit="m/s2")
    "Acceleration to drive the mass"
  Modelica.Blocks.Interfaces.RealOutput f(unit="N")
    "Force needed to drive the flange according to s, v, a"
equation

  connect(positionToForce.f, f)
  connect(positionToForce.flange, mass.flange_a)
  connect(positionToForce.p, s)
  connect(positionToForce.pder, v)
  connect(positionToForce.pder2, a)
end InverseMass;


within Modelica.Mechanics.Translational.Examples;
package Utilities "Utility classes used by translational example models"
  extends Modelica.Icons.UtilitiesPackage;
end Utilities;


Input/output block of a spring model. A linear 1D translational spring with pure signal
interface which can be applied for
a FMU (Functional Mock-up Unit)
exchange.

within Modelica.Mechanics.Translational.Examples.Utilities;
model Spring "Input/output block of a spring model"
  extends Modelica.Blocks.Icons.Block;
  parameter SI.TranslationalSpringConstant c=1e4
    "Spring constant";
  parameter SI.Length s_rel0=0
    "Unstretched spring length";

  Modelica.Mechanics.Translational.Components.GeneralPositionToForceAdaptor positionToForce1(use_pder=false, use_pder2=
        false)
  Modelica.Blocks.Interfaces.RealInput s1(unit="m")
    "Position of left flange of force element"
  Modelica.Blocks.Interfaces.RealOutput f1(unit="N")
    "Force generated by the force element"
  Modelica.Mechanics.Translational.Components.Spring spring(c=c,
      s_rel0=s_rel0)
  Modelica.Blocks.Interfaces.RealInput s2(unit="m")
    "Position of right flange of force element"
  Modelica.Blocks.Interfaces.RealOutput f2(unit="N")
    "Force generated by the force element"
  Modelica.Mechanics.Translational.Components.GeneralPositionToForceAdaptor positionToForce2(use_pder=false, use_pder2=
        false)
equation

  connect(f1, positionToForce1.f)
  connect(positionToForce2.f, f2)
  connect(positionToForce1.flange, spring.flange_a)
  connect(spring.flange_b, positionToForce2.flange)
  connect(positionToForce1.p, s1)
  connect(positionToForce2.p, s2)
end Spring;


Input/output block of a spring/damper model. A linear 1D translational spring and damper in parallel with pure signal
interface which can be applied for
a FMU (Functional Mock-up Unit)
exchange.

within Modelica.Mechanics.Translational.Examples.Utilities;
model SpringDamper "Input/output block of a spring/damper model"
  extends Modelica.Blocks.Icons.Block;
  parameter SI.TranslationalSpringConstant c=1e4
    "Spring constant";
  parameter SI.TranslationalDampingConstant d=1
    "Damping constant";
  parameter SI.Length s_rel0=0
    "Unstretched spring length";

  Modelica.Mechanics.Translational.Components.GeneralPositionToForceAdaptor positionToForce1(use_pder2=false)
  Modelica.Blocks.Interfaces.RealInput s1(unit="m")
    "Position of left flange of force element"
  Modelica.Blocks.Interfaces.RealInput v1(unit="m/s")
    "Speed to left flange of force element"
  Modelica.Blocks.Interfaces.RealOutput f1(unit="N")
    "Force generated by the force element"
  SpringDamperNoRelativeStates springDamper(
    c=c,
    d=d,
    s_rel0=s_rel0)
  Modelica.Blocks.Interfaces.RealInput s2(unit="m")
    "Position of right flange of force element"
  Modelica.Blocks.Interfaces.RealInput v2(unit="m/s")
    "Speed to right flange of force element"
  Modelica.Blocks.Interfaces.RealOutput f2(unit="N")
    "Force generated by the force element"
  Modelica.Mechanics.Translational.Components.GeneralPositionToForceAdaptor positionToForce2(use_pder2=false)
equation

  connect(f1, positionToForce1.f)
  connect(positionToForce2.f, f2)
  connect(positionToForce1.flange, springDamper.flange_a)
  connect(springDamper.flange_b, positionToForce2.flange)
  connect(positionToForce1.p, s1)
  connect(positionToForce1.pder, v1)
  connect(positionToForce2.p, s2)
  connect(positionToForce2.pder, v2)
end SpringDamper;


Linear 1D translational spring and damper in parallel (s and v are not used as states). A spring and damper element connected in parallel.
The component can be
connected either between two masses to describe the joint elasticity
and damping, or between a mass and the housing (component Fixed),
to describe a coupling of the element with the housing via a spring/damper.

within Modelica.Mechanics.Translational.Examples.Utilities;
model SpringDamperNoRelativeStates
  "Linear 1D translational spring and damper in parallel (s and v are not used as states)"
  parameter SI.TranslationalSpringConstant c(final min=0, start=1.0e5) "Spring constant";
  parameter SI.TranslationalDampingConstant d(final min=0, start=0) "Damping constant";
  parameter SI.Length s_rel0=0
    "Unstretched spring length";
  SI.Velocity v_rel(start=0)
    "Relative velocity (= der(s_rel))";
  extends Modelica.Mechanics.Translational.Interfaces.PartialCompliant;
  extends Modelica.Thermal.HeatTransfer.Interfaces.PartialElementaryConditionalHeatPortWithoutT;
protected
  SI.Force f_c "Spring force";
  SI.Force f_d "Damping force";
equation
  v_rel = der(s_rel);
  f_c = c*(s_rel - s_rel0);
  f_d = d*v_rel;
  f = f_c + f_d;
  lossPower = f_d*v_rel;
end SpringDamperNoRelativeStates;


Adapter model to utilize conditional support connector. This is an adapter model to utilize a conditional
support connector
in a component. It could be applied to both textually (equations based) and graphically
defined components:

within Modelica.Mechanics.Translational.Interfaces;
model InternalSupport
  "Adapter model to utilize conditional support connector"
  input SI.Force f
    "External support force (must be computed via force balance in model where InternalSupport is used; = flange.f)";
  SI.Position s "External support position (= flange.s)";
  Flange_a flange
    "Internal support flange (must be connected to the conditional support connector for useSupport=true and to conditional fixed model for useSupport=false)"
equation
  flange.f = f;
  flange.s = s;
end InternalSupport;


within Modelica.Mechanics.Translational;
package Interfaces "Interfaces for 1-dim. translational mechanical components"
  extends Modelica.Icons.InterfacesPackage;
end Interfaces;


Device to measure a single absolute flange variable. This is the superclass of a 1D translational component with one flange and one
output signal in order to measure an absolute kinematic quantity in the flange
and to provide the measured signal as output signal for further processing
with the Modelica.Blocks blocks.

within Modelica.Mechanics.Translational.Interfaces;
partial model PartialAbsoluteSensor
  "Device to measure a single absolute flange variable"

  extends Modelica.Icons.RectangularSensor;

  Interfaces.Flange_a flange
    "Flange to be measured (flange axis directed into cut plane, e. g. from left to right)"

equation
  0 = flange.f;
end PartialAbsoluteSensor;


Compliant connection of two translational 1D flanges. This is a 1D translational component with a compliant connection of two
translational 1D flanges where inertial effects between the two
flanges are not included. The absolute value of the force at the left and the right
flange is the same. It is used to built up springs, dampers etc.

within Modelica.Mechanics.Translational.Interfaces;
partial model PartialCompliant
  "Compliant connection of two translational 1D flanges"

  extends Translational.Interfaces.PartialTwoFlanges;
  SI.Position s_rel(start=0)
    "Relative distance (= flange_b.s - flange_a.s)";
  SI.Force f
    "Force between flanges (positive in direction of flange axis R)";

equation
  s_rel = flange_b.s - flange_a.s;
  flange_b.f = f;
  flange_a.f = -f;
end PartialCompliant;


Base model for the compliant connection of two translational 1-dim. shaft flanges where the relative position and relative velocities are used as states. This is a 1-dim. translational component with a compliant connection of two
translational 1-dim. flanges where inertial effects between the two
flanges are neglected. The basic assumption is that the cut-forces
of the two flanges sum-up to zero, i.e., they have the same absolute value
but opposite sign: flange_a.f + flange_b.f = 0. This base class
is used to built up force elements such as springs, dampers, friction.

within Modelica.Mechanics.Translational.Interfaces;
partial model PartialCompliantWithRelativeStates
  "Base model for the compliant connection of two translational 1-dim. shaft flanges where the relative position and relative velocities are used as states"

  parameter StateSelect stateSelect=StateSelect.prefer
    "Priority to use s_rel and v_rel as states"
  parameter SI.Distance s_nominal=1e-4
    "Nominal value of s_rel (used for scaling)"

  SI.Position s_rel(
    start=0,
    stateSelect=stateSelect,
    nominal=s_nominal) "Relative distance (= flange_b.s - flange_a.s)";
  SI.Velocity v_rel(start=0, stateSelect=stateSelect)
    "Relative velocity (= der(s_rel))";

  SI.Force f "Forces between flanges (= flange_b.f)";
  extends Translational.Interfaces.PartialTwoFlanges;
equation
  s_rel = flange_b.s - flange_a.s;
  v_rel = der(s_rel);
  flange_b.f = f;
  flange_a.f = -f;
end PartialCompliantWithRelativeStates;


Partial model for a component with one translational 1-dim. shaft flange and a support used for textual modeling, i.e., for elementary models. This is a 1-dim. translational component with one flange and a support/housing.
It is used to build up elementary components of a drive train with
equations in the text layer.

within Modelica.Mechanics.Translational.Interfaces;
partial model PartialElementaryOneFlangeAndSupport2
  "Partial model for a component with one translational 1-dim. shaft flange and a support used for textual modeling, i.e., for elementary models"
  parameter Boolean useSupport=false
    "= true, if support flange enabled, otherwise implicitly grounded"
  SI.Length s
    "Distance between flange and support (= flange.s - support.s)";
  Flange_b flange "Flange of component"
  Support support(s=s_support, f=-flange.f) if useSupport
    "Support/housing of component"
protected
  SI.Length s_support "Absolute position of support flange";
equation
  s = flange.s - s_support;
  if not useSupport then
    s_support = 0;
  end if;
end PartialElementaryOneFlangeAndSupport2;


Partial model to transform rotational into translational motion. This is a 1-dim. rotational component with

within Modelica.Mechanics.Translational.Interfaces;
partial model PartialElementaryRotationalToTranslational
  "Partial model to transform rotational into translational motion"
  extends
    Modelica.Mechanics.Rotational.Interfaces.PartialElementaryRotationalToTranslational;
end PartialElementaryRotationalToTranslational;


Partial model for a component with one translational 1-dim. shaft flange and a support used for textual modeling, i.e., for elementary models. This is a 1-dim. translational component with two flanges and an additional support.
It is used e.g., to build up elementary ideal gear components. The component
contains the force balance, i.e., the sum of the forces of the connectors
is zero (therefore, components that are based on PartialGear cannot have
a mass). The support connector needs to be connected
to avoid the unphysical behavior that the
support force is required to be zero (= the default value, if the
connector is not connected).

within Modelica.Mechanics.Translational.Interfaces;
partial model PartialElementaryTwoFlangesAndSupport2
  "Partial model for a component with one translational 1-dim. shaft flange and a support used for textual modeling, i.e., for elementary models"
  parameter Boolean useSupport=false
    "= true, if support flange enabled, otherwise implicitly grounded"
  extends Translational.Interfaces.PartialTwoFlanges;
  Support support(s=s_support, f=-flange_a.f - flange_b.f) if useSupport
    "Support/housing of component"
  SI.Length s_a "Distance between left flange and support";
  SI.Length s_b "Distance between right flange and support";
protected
  SI.Length s_support "Absolute position of support flange";
equation
  s_a = flange_a.s - s_support;
  s_b = flange_b.s - s_support;
  if not useSupport then
    s_support = 0;
  end if;
end PartialElementaryTwoFlangesAndSupport2;


Partial model of a force acting at the flange (accelerates the flange). Partial model of force that accelerates the flange.

within Modelica.Mechanics.Translational.Interfaces;
partial model PartialForce
  "Partial model of a force acting at the flange (accelerates the flange)"
  extends PartialElementaryOneFlangeAndSupport2;
  SI.Force f
    "Accelerating force acting at flange (= flange.f)";
equation
  f = flange.f;
end PartialForce;


Base model of Coulomb friction elements. Basic model for Coulomb friction that models the stuck phase in a reliable way.

within Modelica.Mechanics.Translational.Interfaces;
partial model PartialFriction "Base model of Coulomb friction elements"

  //extends Translational.Interfaces.PartialRigid;
  parameter SI.Velocity v_small=1e-3
    "Relative velocity near to zero (see model info text)"
  // Equations to define the following variables have to be defined in subclasses
  SI.Velocity v_relfric "Relative velocity between frictional surfaces";
  SI.Acceleration a_relfric
    "Relative acceleration between frictional surfaces";
  //SI.Force f "Friction force (positive, if directed in opposite direction of v_relfric)";
  SI.Force f0 "Friction force for v_relfric=0 and forward sliding";
  SI.Force f0_max "Maximum friction force for v_relfric=0 and locked";
  Boolean free "= true, if frictional element is not active";
  // Equations to define the following variables are given in this class
  Real sa(unit="1")
    "Path parameter of friction characteristic f = f(a_relfric)";
  Boolean startForward(start=false, fixed=true)
    "= true, if v_relfric=0 and start of forward sliding";
  Boolean startBackward(start=false, fixed=true)
    "= true, if v_relfric=0 and start of backward sliding";
  Boolean locked(start=false) "= true, if v_relfric=0 and not sliding";
  constant Integer Unknown=3 "Value of mode is not known";
  constant Integer Free=2 "Element is not active";
  constant Integer Forward=1 "v_relfric > 0 (forward sliding)";
  constant Integer Stuck=0
    "v_relfric = 0 (forward sliding, locked or backward sliding)";
  constant Integer Backward=-1 "v_relfric < 0 (backward sliding)";
  Integer mode(
    final min=Backward,
    final max=Unknown,
    start=Unknown,
    fixed=true)
    "Mode of friction (-1: backward sliding, 0: stuck, 1: forward sliding, 2: inactive, 3: unknown)";
protected
  constant SI.Acceleration unitAcceleration=1
  constant SI.Force unitForce=1
equation
  /* Friction characteristic
   (locked is introduced to help the Modelica translator determining
   the different structural configurations,
   if for each configuration special code shall be generated)
*/
  startForward = pre(mode) == Stuck and (sa > f0_max/unitForce or pre(
    startForward) and sa > f0/unitForce) or pre(mode) == Backward and
    v_relfric > v_small or initial() and (v_relfric > 0);
  startBackward = pre(mode) == Stuck and (sa < -f0_max/unitForce or pre(
    startBackward) and sa < -f0/unitForce) or pre(mode) == Forward and
    v_relfric < -v_small or initial() and (v_relfric < 0);
  locked = not free and not (pre(mode) == Forward or startForward or pre(
    mode) == Backward or startBackward);

  a_relfric/unitAcceleration = if locked then 0 else if free then sa
    else if startForward then sa - f0_max/unitForce
    else if startBackward then sa + f0_max/unitForce
    else if pre(mode) == Forward then sa - f0_max/unitForce
    else if pre(mode) == Backward then sa + f0_max/unitForce
    else sa - sign(v_relfric)*f0_max/unitForce;

  /* Friction force "f" has to be defined in a subclass. Example for possible
     realization of a brake utilizing interpolation by ExternalCombiTable1D see:
     Modelica.Mechanics.Translational.Components.Brake
  */

  // finite state machine to determine configuration
  mode = if free then Free else (if (pre(mode) == Forward or pre(mode) ==
    Free or startForward) and v_relfric > 0 then Forward else if (pre(mode)
     == Backward or pre(mode) == Free or startBackward) and v_relfric < 0
     then Backward else Stuck);
end PartialFriction;


Partial model for a component with one translational 1-dim. shaft flange and a support used for graphical modeling, i.e., the model is build up by drag-and-drop from elementary components. This is a 1-dim. translational component with one flange and a support/housing.
It is used e.g., to build up parts of a drive train graphically consisting
of several components.

within Modelica.Mechanics.Translational.Interfaces;
partial model PartialOneFlangeAndSupport
  "Partial model for a component with one translational 1-dim. shaft flange and a support used for graphical modeling, i.e., the model is build up by drag-and-drop from elementary components"
  parameter Boolean useSupport=false
    "= true, if support flange enabled, otherwise implicitly grounded"
  Flange_b flange "Flange of component"
  Support support if useSupport "Support/housing of component"
protected
  Support internalSupport
    "Internal support/housing of component (either connected to support, if useSupport=true, or connected to fixed, if useSupport=false)"
  Components.Fixed fixed if not useSupport
    "Fixed support/housing, if not useSupport"
equation
  connect(fixed.flange, internalSupport)
  connect(internalSupport, support)
end PartialOneFlangeAndSupport;


Device to measure a single relative variable between two flanges. This is a superclass for 1D translational components with two rigidly connected
flanges and one output signal in order to measure relative kinematic quantities
between the two flanges or the cut-force in the flange and
to provide the measured signal as output signal for further processing
with the Modelica.Blocks blocks.

within Modelica.Mechanics.Translational.Interfaces;
partial model PartialRelativeSensor
  "Device to measure a single relative variable between two flanges"

  extends Modelica.Icons.RectangularSensor;
  extends Translational.Interfaces.PartialTwoFlanges;
equation
  0 = flange_a.f + flange_b.f;
end PartialRelativeSensor;


Rigid connection of two translational 1D flanges. This is a 1-dim. translational component with two rigidly connected flanges.
The fixed distance between the left and the right flange is defined by parameter \"L\".
The forces at the right and left flange can be different.
It is used e.g., to built up sliding masses.

within Modelica.Mechanics.Translational.Interfaces;
partial model PartialRigid
  "Rigid connection of two translational 1D flanges"
  SI.Position s
    "Absolute position of center of component (s = flange_a.s + L/2 = flange_b.s - L/2)";
  parameter SI.Length L(start=0)
    "Length of component, from left flange to right flange (= flange_b.s - flange_a.s)";
  extends Translational.Interfaces.PartialTwoFlanges;
equation
  flange_a.s = s - L/2;
  flange_b.s = s + L/2;
end PartialRigid;


Component with two translational 1D flanges. This is a 1D translational component with two flanges.
It is used e.g., to built up parts of a drive train consisting
of several base components.

within Modelica.Mechanics.Translational.Interfaces;
partial model PartialTwoFlanges
  "Component with two translational 1D flanges"

  Flange_a flange_a
    "(left) driving flange (flange axis directed into cut plane, e. g. from left to right)"
  Flange_b flange_b
    "(right) driven flange (flange axis directed out of cut plane)"
end PartialTwoFlanges;


Partial model for a component with two translational 1-dim. shaft flanges and a support used for graphical modeling, i.e., the model is build up by drag-and-drop from elementary components. This is a 1-dim. translational component with two flanges and a support/housing.
It is used e.g., to build up parts of a drive train graphically consisting
of several components.

within Modelica.Mechanics.Translational.Interfaces;
partial model PartialTwoFlangesAndSupport
  "Partial model for a component with two translational 1-dim. shaft flanges and a support used for graphical modeling, i.e., the model is build up by drag-and-drop from elementary components"
  parameter Boolean useSupport=false
    "= true, if support flange enabled, otherwise implicitly grounded"
  extends Translational.Interfaces.PartialTwoFlanges;
  Support support if useSupport "Support/housing of component"
protected
  Support internalSupport
    "Internal support/housing of component (either connected to support, if useSupport=true, or connected to fixed, if useSupport=false)"
  Components.Fixed fixed if not useSupport
    "Fixed support/housing, if not useSupport"
equation
  connect(fixed.flange, internalSupport)
  connect(internalSupport, support)
end PartialTwoFlangesAndSupport;


Support/housing flange of a one-dimensional translational component. This is a connector for 1-dim. translational mechanical systems and models
the support or housing of a shaft.
The following variables are defined in this connector:

within Modelica.Mechanics.Translational.Interfaces;
connector Support "Support/housing flange of a one-dimensional translational component"
  extends Flange;
end Support;


Ideal sensor to measure the absolute acceleration of flange. Measures the absolute acceleration
of a flange in an ideal way and provides the result as
output signal a
(to be further processed with blocks of the
Modelica.Blocks library).

within Modelica.Mechanics.Translational.Sensors;
model AccSensor "Ideal sensor to measure the absolute acceleration of flange"
  extends Translational.Interfaces.PartialAbsoluteSensor;
  SI.Velocity v "Absolute velocity of flange";
  Modelica.Blocks.Interfaces.RealOutput a(unit="m/s2")
    "Absolute acceleration of flange as output signal"

equation
  v = der(flange.s);
  a = der(v);
end AccSensor;


Ideal sensor to measure the force between two flanges. Measures the cut-force between two flanges
in an ideal way and provides the result as output signal f
(to be further processed with blocks of the
Modelica.Blocks library).

within Modelica.Mechanics.Translational.Sensors;
model ForceSensor "Ideal sensor to measure the force between two flanges"
  extends Translational.Interfaces.PartialRelativeSensor;
  Modelica.Blocks.Interfaces.RealOutput f(unit="N")
    "Force in flange_a and flange_b (f = flange_a.f = -flange_b.f) as output signal"
equation
  flange_a.s = flange_b.s;
  flange_a.f = f;
end ForceSensor;


Ideal sensor to measure the absolute velocity, force and power between two flanges. Measures the absolute velocity of the flange_a and
the cut-force and power between two flanges
in an ideal way and provides the results as output signals v,
f and power, respectively.

within Modelica.Mechanics.Translational.Sensors;
model MultiSensor
  "Ideal sensor to measure the absolute velocity, force and power between two flanges"
  extends Translational.Interfaces.PartialRelativeSensor;
  Modelica.Blocks.Interfaces.RealOutput power(unit="W")
    "Power in flange flange_a as output signal"
  Modelica.Blocks.Interfaces.RealOutput f(unit="N")
    "Force in flange_a and flange_b (f = flange_a.f = -flange_b.f) as output signal"
  Modelica.Blocks.Interfaces.RealOutput v(unit="m/s")
    "Absolute velocity of flange as output signal"
equation
  flange_a.s = flange_b.s;
  f = flange_a.f;
  v = der(flange_a.s);
  power = f*v;
end MultiSensor;


within Modelica.Mechanics.Translational;
package Sensors "Sensors for 1-dim. translational mechanical quantities"

  extends Modelica.Icons.SensorsPackage;
end Sensors;


Ideal sensor to measure the absolute position of flange. Measures the absolute position
of a flange in an ideal way and provides the result as
output signal s
(to be further processed with blocks of the
Modelica.Blocks library).

within Modelica.Mechanics.Translational.Sensors;
model PositionSensor "Ideal sensor to measure the absolute position of flange"
  extends Translational.Interfaces.PartialAbsoluteSensor;
  Modelica.Blocks.Interfaces.RealOutput s(unit="m")
    "Absolute position of flange as output signal"

equation
  s = flange.s;
end PositionSensor;


Ideal sensor to measure the power between two flanges. Measures the power between two flanges
in an ideal way and provides the result as output signal power
(to be further processed with blocks of the
Modelica.Blocks library), i.e.

within Modelica.Mechanics.Translational.Sensors;
model PowerSensor
  "Ideal sensor to measure the power between two flanges"
  extends Translational.Interfaces.PartialRelativeSensor;
  Modelica.Blocks.Interfaces.RealOutput power(unit="W")
    "Power in flange flange_a as output signal"
equation
  flange_a.s = flange_b.s;
  power = flange_a.f*der(flange_a.s);
end PowerSensor;


Ideal sensor to measure the relative acceleration between two flanges. Measures the relative acceleration between two flanges
in an ideal way and provides the result as output signal a_rel
(to be further processed with blocks of the
Modelica.Blocks library).

within Modelica.Mechanics.Translational.Sensors;
model RelAccSensor "Ideal sensor to measure the relative acceleration between two flanges"
  extends Translational.Interfaces.PartialRelativeSensor;
  SI.Position s_rel "Relative distance between two flanges (flange_b.s - flange_a.s)";
  SI.Velocity v_rel "Relative velocity between two flanges (der(flange_b.s) - der(flange_a.s))";
  Modelica.Blocks.Interfaces.RealOutput a_rel(unit="m/s2")
    "Relative acceleration between two flanges (= der(v_rel)) as output signal"

equation
  s_rel = flange_b.s - flange_a.s;
  v_rel = der(s_rel);
  a_rel = der(v_rel);
  0 = flange_a.f;
end RelAccSensor;


Ideal sensor to measure the relative position between two flanges. Measures the relative position between two flanges
in an ideal way and provides the result as output signal s_rel
(to be further processed with blocks of the
Modelica.Blocks library).

within Modelica.Mechanics.Translational.Sensors;
model RelPositionSensor "Ideal sensor to measure the relative position between two flanges"
  extends Translational.Interfaces.PartialRelativeSensor;
  Modelica.Blocks.Interfaces.RealOutput s_rel(unit="m")
    "Relative distance between two flanges (= flange_b.s - flange_a.s) as output signal"

equation
  s_rel = flange_b.s - flange_a.s;
  0 = flange_a.f;
end RelPositionSensor;


Ideal sensor to measure the relative velocity between two flanges. Measures the relative velocity between two flanges
in an ideal way and provides the result as output signal v_rel
(to be further processed with blocks of the
Modelica.Blocks library).

within Modelica.Mechanics.Translational.Sensors;
model RelSpeedSensor "Ideal sensor to measure the relative velocity between two flanges"
  extends Translational.Interfaces.PartialRelativeSensor;
  SI.Position s_rel "Relative distance between two flanges (flange_b.s - flange_a.s)";
  Modelica.Blocks.Interfaces.RealOutput v_rel(unit="m/s")
    "Relative velocity between two flanges (= der(flange_b.s) - der(flange_a.s)) as output signal"

equation
  s_rel = flange_b.s - flange_a.s;
  v_rel = der(s_rel);
  0 = flange_a.f;
end RelSpeedSensor;


Ideal sensor to measure the absolute velocity of flange. Measures the absolute velocity
of a flange in an ideal way and provides the result as
output signal v
(to be further processed with blocks of the
Modelica.Blocks library).

within Modelica.Mechanics.Translational.Sensors;
model SpeedSensor "Ideal sensor to measure the absolute velocity of flange"
  extends Translational.Interfaces.PartialAbsoluteSensor;
  Modelica.Blocks.Interfaces.RealOutput v(unit="m/s")
    "Absolute velocity of flange as output signal"

equation
  v = der(flange.s);
end SpeedSensor;


Forced movement of a flange according to an acceleration signal. The input signal a_ref in [m/s2] moves the 1D translational flange
connector flange with a predefined acceleration, i.e., the flange
is forced to move relative to the support connector with this acceleration.
The velocity and the position of the flange are also predefined and are determined by
integration of the acceleration.

within Modelica.Mechanics.Translational.Sources;
model Accelerate
  "Forced movement of a flange according to an acceleration signal"
  extends
    Modelica.Mechanics.Translational.Interfaces.PartialElementaryOneFlangeAndSupport2(
    s(start=0,
      fixed=true,
      stateSelect=StateSelect.prefer));
  SI.Velocity v(
    start=0,
    fixed=true,
    stateSelect=StateSelect.prefer) "Absolute velocity of flange";
  SI.Acceleration a "Absolute acceleration of flange";

  Modelica.Blocks.Interfaces.RealInput a_ref(unit="m/s2")
    "Absolute acceleration of flange as input signal"

equation
  v = der(s);
  a = der(v);
  a = a_ref;
end Accelerate;


Constant force, not dependent on speed. Model of constant force, not dependent on velocity of flange.

within Modelica.Mechanics.Translational.Sources;
model ConstantForce "Constant force, not dependent on speed"
  extends Modelica.Mechanics.Translational.Interfaces.PartialForce;
  parameter SI.Force f_constant
    "Nominal force (if negative, force is acting as load in positive direction of motion)";
equation
  f = -f_constant;
end ConstantForce;


Constant speed, not dependent on force. Model of fixed velocity of flange, not dependent on force.

within Modelica.Mechanics.Translational.Sources;
model ConstantSpeed "Constant speed, not dependent on force"
  extends Modelica.Mechanics.Translational.Interfaces.PartialForce;
  parameter SI.Velocity v_fixed
    "Fixed speed (if negative, force is acting as load)";
  SI.Velocity v
    "Velocity of flange with respect to support (= der(s))";
equation
  v = der(s);
  v = v_fixed;
end ConstantSpeed;


Simple model of a translational eddy current brake. This is a simple model of a translational eddy current brake. The force versus speed characteristic is defined by Kloss' equation.

within Modelica.Mechanics.Translational.Sources;
model EddyCurrentForce "Simple model of a translational eddy current brake"
  import Modelica.Electrical.Machines.Thermal.linearTemperatureDependency;
  parameter Boolean useExcitationInput=false "Enable signal input for excitation";
  parameter Real constantExcitation=1 "Excitation=1 to reach maximum force"
  parameter SI.Force f_nominal "Constant maximum force (always braking)";
  parameter SI.Velocity v_nominal(min=Modelica.Constants.eps)
    "Nominal speed (leads to maximum force) at reference temperature";
  parameter SI.Temperature TRef(start=293.15)
    "Reference temperature";
  parameter Modelica.Electrical.Machines.Thermal.LinearTemperatureCoefficient20
    alpha20(start=0) "Temperature coefficient of material";
  extends Modelica.Mechanics.Translational.Interfaces.PartialForce;
  extends Modelica.Thermal.HeatTransfer.Interfaces.PartialElementaryConditionalHeatPort;
  SI.Velocity v "Velocity of flange with respect to support (= der(s))";
  Real v_normalized "Relative speed v/v_nominal";
  Blocks.Interfaces.RealInput excitation = excitationInternal if useExcitationInput
    "Excitation"
protected
  Real excitationInternal "Excitation";
equation
  if not useExcitationInput then
    excitationInternal = constantExcitation;
  end if;
  v = der(s);
  v_normalized = v/(v_nominal*linearTemperatureDependency(1, TRef, alpha20, TheatPort));
  f = 2*f_nominal*excitationInternal^2*v_normalized/(1 + v_normalized*v_normalized);
  lossPower = f*v;
end EddyCurrentForce;


External force acting on a drive train element as input signal. The input signal \"f\" in [N] characterizes an external
force which acts (with positive sign) at a flange,
i.e., the component connected to the flange is driven by force f.

within Modelica.Mechanics.Translational.Sources;
model Force
  "External force acting on a drive train element as input signal"
  extends Modelica.Mechanics.Translational.Interfaces.PartialElementaryOneFlangeAndSupport2;
  Modelica.Blocks.Interfaces.RealInput f(unit="N")
    "Driving force as input signal"

equation
  flange.f = -f;
end Force;


Input signal acting as force on two flanges. The input signal \"f\" in [N] characterizes an external
force which acts (with positive sign) at both flanges,
i.e., the components connected to these flanges are driven by force f.

within Modelica.Mechanics.Translational.Sources;
model Force2 "Input signal acting as force on two flanges"
  extends Translational.Interfaces.PartialTwoFlanges;
  Modelica.Blocks.Interfaces.RealInput f(unit="N")
    "Driving force as input signal"

equation
  flange_a.f = f;
  flange_b.f = -f;
end Force2;


Constant force, not dependent on speed. Model of a force step at time startTime.
Positive force accelerates in positive direction of flange translation.

within Modelica.Mechanics.Translational.Sources;
model ForceStep "Constant force, not dependent on speed"
  extends Modelica.Mechanics.Translational.Interfaces.PartialForce;
  parameter SI.Force stepForce(start=1)
    "Height of force step (if negative, force is acting as load)";
  parameter SI.Force offsetForce(start=0) "Offset of force";
  parameter SI.Time startTime=0
    "Force = offset for time < startTime";
equation
  f = -offsetForce - (if time < startTime then 0 else stepForce);
end ForceStep;


Force reciprocal dependent on speed. Model of inverse speed dependent force.

within Modelica.Mechanics.Translational.Sources;
model InverseSpeedDependentForce
  "Force reciprocal dependent on speed"
  extends Translational.Interfaces.PartialForce;
  parameter SI.Force f_nominal
    "Nominal force (if negative, torque is acting as load in positive direction of motion)";
  parameter Boolean ForceDirection=true
    "Same direction of force in both directions of motion";
  parameter SI.Velocity v_nominal(min=Modelica.Constants.eps)
    "Nominal speed";
  parameter SI.Velocity v0(final min=Modelica.Constants.eps, start=0.1)
    "Regularization below v0"
  SI.Velocity v
    "Velocity of flange with respect to support (= der(s))";
equation
  v = der(s);
  if ForceDirection then
    f = if abs(v)<v0 then -f_nominal*v_nominal/v0 else -f_nominal*v_nominal/abs(v);
  else
    f = if abs(v)<v0 then -f_nominal*v/v0 else -f_nominal*v_nominal/v;
  end if;
end InverseSpeedDependentForce;


Linear dependency of force versus speed. Model of force, linearly dependent on velocity of flange.<br>
Parameter ForceDirection chooses whether direction of force is the same in both directions of movement or not.

within Modelica.Mechanics.Translational.Sources;
model LinearSpeedDependentForce "Linear dependency of force versus speed"
  extends Modelica.Mechanics.Translational.Interfaces.PartialForce;
  parameter SI.Force f_nominal
    "Nominal force (if negative, force is acting as load in positive direction of motion)";
  parameter Boolean ForceDirection=true
    "Same direction of force in both directions of motion";
  parameter SI.Velocity v_nominal(min=Modelica.Constants.eps)
    "Nominal speed";
  SI.Velocity v
    "Velocity of flange with respect to support (= der(s))";

equation
  v = der(s);
  if ForceDirection then
    f = -f_nominal*abs(v/v_nominal);
  else
    f = -f_nominal*(v/v_nominal);
  end if;
end LinearSpeedDependentForce;


Forced movement of a flange according to a position, velocity and acceleration signal. Flange flange is forced to move relative to the support connector with a predefined motion
according to the input signals:

within Modelica.Mechanics.Translational.Sources;
model Move
  "Forced movement of a flange according to a position, velocity and acceleration signal"
  extends
    Modelica.Mechanics.Translational.Interfaces.PartialElementaryOneFlangeAndSupport2;
  Modelica.Blocks.Interfaces.RealInput u[3]
    "Position, velocity and acceleration of flange as input signals"
protected
  function position
    extends Modelica.Icons.Function;
    input Real q_qd_qdd[3]
      "Required values for position, speed, acceleration";
    input Real dummy
      "Just to have one input signal that should be differentiated to avoid possible problems in the Modelica tool (is not used)";
    output Real q;
  algorithm
    q := q_qd_qdd[1];
  end position;

  function position_der
    extends Modelica.Icons.Function;
    input Real q_qd_qdd[3]
      "Required values for position, speed, acceleration";
    input Real dummy
      "Just to have one input signal that should be differentiated to avoid possible problems in the Modelica tool (is not used)";
    input Real dummy_der;
    output Real qd;
  algorithm
    qd := q_qd_qdd[2];
  end position_der;

  function position_der2
    extends Modelica.Icons.Function;
    input Real q_qd_qdd[3]
      "Required values for position, speed, acceleration";
    input Real dummy
      "Just to have one input signal that should be differentiated to avoid possible problems in the Modelica tool (is not used)";
    input Real dummy_der;
    input Real dummy_der2;
    output Real qdd;
  algorithm
    qdd := q_qd_qdd[3];
  end position_der2;
equation
  s = position(u, time);
end Move;


within Modelica.Mechanics.Translational;
package Sources "Sources to drive 1D translational mechanical components"
  extends Modelica.Icons.SourcesPackage;
end Sources;


Forced movement of a flange according to a reference position. The input signal s_ref defines the reference
position in [m]. Flange flange is forced
to move relative to the support connector according to this reference motion. According to parameter
exact (default = false), this is done in the following way:

within Modelica.Mechanics.Translational.Sources;
model Position
  "Forced movement of a flange according to a reference position"
  extends
    Modelica.Mechanics.Translational.Interfaces.PartialElementaryOneFlangeAndSupport2(
     s(stateSelect=if exact then StateSelect.default else StateSelect.prefer));
  parameter Boolean exact=false
    "Is true/false for exact treatment/filtering of the input signal, respectively"
  parameter SI.Frequency f_crit=50
    "If exact=false, critical frequency of filter to filter input signal"
  SI.Velocity v(start=0,
    stateSelect=if exact then StateSelect.default else StateSelect.prefer)
    "If exact=false, absolute velocity of flange else dummy"
  SI.Acceleration a(start=0)
    "If exact=false, absolute acceleration of flange else dummy"
  Modelica.Blocks.Interfaces.RealInput s_ref(unit="m")
    "Reference position of flange as input signal"
protected
  parameter SI.AngularFrequency w_crit=2*Modelica.Constants.pi*f_crit "Critical frequency";
  constant Real af=1.3617 "s coefficient of Bessel filter";
  constant Real bf=0.6180 "s*s coefficient of Bessel filter";

initial equation
  if not exact then
    s = s_ref;
  end if;
equation
  if exact then
    s = s_ref;
    v = 0;
    a = 0;
  else
    // Filter: a = s_ref*S^2/(1 + (af/w_crit)*S + (bf/w_crit^2)*S^2)
    v = der(s);
    a = der(v);
    a = ((s_ref - s)*w_crit - af*v)*(w_crit/bf);
  end if;
end Position;


Quadratic dependency of force versus speed. Model of force, quadratic dependent on velocity of flange.<br>
Parameter ForceDirection chooses whether direction of force is the same in both directions of movement or not.

within Modelica.Mechanics.Translational.Sources;
model QuadraticSpeedDependentForce
  "Quadratic dependency of force versus speed"
  extends Modelica.Mechanics.Translational.Interfaces.PartialForce;
  parameter SI.Force f_nominal
    "Nominal force (if negative, force is acting as load in positive direction of motion)";
  parameter Boolean ForceDirection=true
    "Same direction of force in both directions of motion";
  parameter SI.Velocity v_nominal(min=Modelica.Constants.eps)
    "Nominal speed";
  SI.Velocity v
    "Velocity of flange with respect to support (= der(s))";
equation
  v = der(s);
  if ForceDirection then
    f = -f_nominal*(v/v_nominal)^2;
  else
    f = -f_nominal*smooth(1, if v >= 0 then (v/v_nominal)^2 else -(v/v_nominal)^2);
  end if;
end QuadraticSpeedDependentForce;


Constant force changing sign with speed. Model of constant force which changes sign with direction of movement.

within Modelica.Mechanics.Translational.Sources;
model SignForce "Constant force changing sign with speed"
  extends Modelica.Mechanics.Translational.Interfaces.PartialForce;
  import Modelica.Constants.pi;
  parameter SI.Force f_nominal
    "Nominal force (if negative, force is acting as load)";
  parameter Modelica.Blocks.Types.Regularization reg=Modelica.Blocks.Types.Regularization.Exp
    "Type of regularization"
  parameter SI.Velocity v0(final min=Modelica.Constants.eps, start=0.1)
    "Regularization below v0";
  SI.Velocity v
    "Velocity of flange with respect to support (= der(s))";
equation
  v = der(s);
  if reg==Modelica.Blocks.Types.Regularization.Exp then
    f = -f_nominal*(2/(1 + Modelica.Math.exp(-v/(0.01*v0)))-1);
  elseif reg==Modelica.Blocks.Types.Regularization.Sine then
    f = -f_nominal*smooth(1, (if abs(v)>=v0 then sign(v) else Modelica.Math.sin(pi/2*v/v0)));
  elseif reg==Modelica.Blocks.Types.Regularization.Linear then
    f = -f_nominal*(if abs(v)>=v0 then sign(v) else (v/v0));
  else//if reg==Modelica.Blocks.Types.Regularization.CoSine
    f = -f_nominal*(if abs(v)>=v0 then sign(v) else sign(v)*(1 - Modelica.Math.cos(pi/2*v/v0)));
  end if;
end SignForce;


Forced movement of a flange according to a reference speed. The input signal v_ref defines the reference
speed in [m/s]. Flange flange is forced
to move relative to the support connector  according to this reference motion. According to parameter
exact (default = false), this is done in the following way:

within Modelica.Mechanics.Translational.Sources;
model Speed "Forced movement of a flange according to a reference speed"
  extends
    Modelica.Mechanics.Translational.Interfaces.PartialElementaryOneFlangeAndSupport2(
     s(
      start=0,
      fixed=true,
      stateSelect=StateSelect.prefer));
  parameter Boolean exact=false
    "Is true/false for exact treatment/filtering of the input signal, respectively"
  parameter SI.Frequency f_crit=50
    "If exact=false, critical frequency of filter to filter input signal"
  SI.Velocity v(stateSelect=if exact then StateSelect.default else
        StateSelect.prefer) "Absolute velocity of flange";
  SI.Acceleration a
    "If exact=false, absolute acceleration of flange else dummy";
  Modelica.Blocks.Interfaces.RealInput v_ref(unit="m/s")
    "Reference speed of flange as input signal"

protected
  parameter SI.AngularFrequency w_crit=2*Modelica.Constants.pi
      *f_crit "Critical frequency";
initial equation
  if not exact then
    v = v_ref;
  end if;
equation
  v = der(s);
  if exact then
    v = v_ref;
    a = 0;
  else
    // Filter: a = v_ref/(1 + (1/w_crit)*s)
    a = der(v);
    a = (v_ref - v)*w_crit;
  end if;
end Speed;


Compressible liquid models

within Modelica.Media;
package CompressibleLiquids "Compressible liquid models"
  extends Modelica.Icons.VariantsPackage;
  package Common "Base classes for compressible liquids"
    extends Modelica.Icons.Package;
    partial package LinearWater_pT
      "Base class for liquid, linear compressibility water models"
      extends Media.Interfaces.PartialLinearFluid(
        constantJacobian=true,
        reference_d=Modelica.Media.Water.StandardWater.density(state),
        reference_h=Modelica.Media.Water.StandardWater.specificEnthalpy(state),
        reference_s=Modelica.Media.Water.StandardWater.specificEntropy(state),
        cp_const=Modelica.Media.Water.StandardWater.specificHeatCapacityCp(state),
        beta_const=
            Modelica.Media.Water.StandardWater.isobaricExpansionCoefficient(state),
        kappa_const=Modelica.Media.Water.StandardWater.isothermalCompressibility(
            state),
        MM_const=Modelica.Media.Water.StandardWater.molarMass(state));

      constant Modelica.Media.Water.StandardWater.ThermodynamicState state=
          Modelica.Media.Water.StandardWater.setState_pT(reference_p, reference_T);
    end LinearWater_pT;
  end Common;

  package LinearColdWater "Cold water model with linear compressibility"
    extends Media.Interfaces.PartialLinearFluid(
      mediumName="Linear cold water",
      constantJacobian=true,
      reference_p=101325,
      reference_T=278.15,
      reference_d=997.05,
      reference_h=104929,
      reference_s=100.0,
      cp_const=4181.9,
      beta_const=2.5713e-4,
      kappa_const=4.5154e-10,
      MM_const=0.018015268);

  redeclare function extends dynamicViscosity "Dynamic viscosity of water"
  algorithm
    eta := 1.5e-3;
  end dynamicViscosity;

  redeclare function extends thermalConductivity
      "Thermal conductivity of water"
  algorithm
    lambda := 0.572;
  end thermalConductivity;

  end LinearColdWater;

  package LinearWater_pT_Ambient
    "Liquid, linear compressibility water model at 1.01325 bar and 25 degree Celsius"
    extends Modelica.Media.CompressibleLiquids.Common.LinearWater_pT(
      mediumName="Liquid linear water",
      reference_p = 101325,
      reference_T = 298.15);
  redeclare function extends dynamicViscosity "Dynamic viscosity of water"
  algorithm
    eta := 8.9e-4;
  end dynamicViscosity;

  redeclare function extends thermalConductivity
      "Thermal conductivity of water"
  algorithm
    lambda := 0.608;
  end thermalConductivity;
  end LinearWater_pT_Ambient;
end CompressibleLiquids;


Medium model for T-dependent properties, defined by tables or polynomials