VariableDamper

model VariableDamper "1D translational damper with variable damping factor"
    input Modelica.Blocks.Interfaces.RealInput d(unit = "Ns/m") "Variable damping factor"
        annotation (Placement(
            visible = true,
            transformation(
                origin = {0, 80},
                extent = {
                    {-20, -20}, 
                    {20, 20}},
                rotation = -90),
            iconTransformation(
                origin = {0, 80},
                extent = {
                    {-20, -20}, 
                    {20, 20}},
                rotation = -90)));

    extends Modelica.Mechanics.Translational.Interfaces.PartialCompliantWithRelativeStates;
    extends Modelica.Thermal.HeatTransfer.Interfaces.PartialElementaryConditionalHeatPortWithoutT;
equation
    f = d * v_rel;
    lossPower = f * v_rel;

    annotation (
        Documentation(info = "<html>\n                <p>\n                    <em>Linear, velocity dependent damper</em> element. It can be either connected\n                    between a sliding mass and the housing (model Fixed), or\n                    between two sliding masses.\n                </p></html>"),
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    points = {
                        {-90, 0}, 
                        {100, 0}},
                    color = {0, 127, 0}), 
                Line(points = {
                    {-60, -30}, 
                    {-60, 30}}), 
                Rectangle(
                    lineColor = {0, 127, 0},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-60, 30}, 
                        {30, -30}}), 
                Polygon(
                    lineColor = {95, 127, 95},
                    fillColor = {95, 127, 95},
                    fillPattern = FillPattern.Solid,
                    points = {
                        {50, -90}, 
                        {20, -80}, 
                        {20, -100}, 
                        {50, -90}}), 
                Line(
                    points = {
                        {-60, -90}, 
                        {20, -90}},
                    color = {95, 127, 95}), 
                Line(
                    visible = false,
                    points = {
                        {-100, -100}, 
                        {-100, -20}, 
                        {-14, -20}},
                    color = {191, 0, 0},
                    pattern = LinePattern.Dot), 
                Line(
                    points = {
                        {60, -30}, 
                        {-60, -30}, 
                        {-60, 30}, 
                        {60, 30}},
                    color = {0, 127, 0})}),
        Diagram(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(points = {
                    {-90, 0}, 
                    {-60, 0}}), 
                Line(points = {
                    {-60, -30}, 
                    {-60, 30}}), 
                Line(points = {
                    {-60, -30}, 
                    {60, -30}}), 
                Line(points = {
                    {-60, 30}, 
                    {60, 30}}), 
                Rectangle(
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-60, 30}, 
                        {30, -30}}), 
                Line(points = {
                    {30, 0}, 
                    {90, 0}}), 
                Line(
                    points = {
                        {-50, 60}, 
                        {50, 60}},
                    color = {128, 128, 128}), 
                Polygon(
                    lineColor = {128, 128, 128},
                    fillColor = {128, 128, 128},
                    fillPattern = FillPattern.Solid,
                    points = {
                        {50, 63}, 
                        {60, 60}, 
                        {50, 57}, 
                        {50, 63}}), 
                Text(
                    lineColor = {128, 128, 128},
                    extent = {
                        {-58, 68}, 
                        {42, 78}},
                    textString = "der(s_rel)")}));
end VariableDamper;