VariableDamper

model VariableDamper "Linear 1D rotational damper"
    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.Rotational.Interfaces.PartialCompliantWithRelativeStates;
    extends Modelica.Thermal.HeatTransfer.Interfaces.PartialElementaryConditionalHeatPortWithoutT;
equation
    lossPower = tau * w_rel;
    tau = d * w_rel;

    annotation (
        Documentation(info = "<html>\n                <p>\n                    <strong>Linear, velocity dependent damper</strong> element. It can be either connected\n                    between an inertia or gear and the housing (component Fixed), or\n                    between two inertia/gear elements.\n                </p>\n\n                <p>\n                    See also the discussion\n                    <a href=\"modelica://Modelica.Mechanics.Rotational.UsersGuide.StateSelection\">State Selection</a>\n                    in the User's Guide of the Rotational library.\n                </p></html>"),
        Icon(
            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(
                    extent = {
                        {-60, 30}, 
                        {30, -30}},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Line(points = {
                    {30, 0}, 
                    {90, 0}}), 
                Line(
                    visible = useHeatPort,
                    points = {
                        {-100, -100}, 
                        {-100, -40}, 
                        {-20, -40}, 
                        {-20, 0}},
                    color = {191, 0, 0},
                    pattern = LinePattern.Dot), 
                Line(
                    points = {
                        {0, -60}, 
                        {0, 60}},
                    rotation = -30), 
                Polygon(
                    origin = {30, 52},
                    rotation = -30,
                    fillPattern = FillPattern.Solid,
                    points = {
                        {0, 0}, 
                        {-5, -20}, 
                        {5, -20}, 
                        {0, 0}})}),
        Diagram(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(points = {
                    {-96, 0}, 
                    {-60, 0}}), 
                Line(points = {
                    {-60, -30}, 
                    {-60, 30}}), 
                Line(points = {
                    {-60, -30}, 
                    {60, -30}}), 
                Line(points = {
                    {-60, 30}, 
                    {60, 30}}), 
                Rectangle(
                    extent = {
                        {-60, 30}, 
                        {30, -30}},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Line(points = {
                    {30, 0}, 
                    {96, 0}}), 
                Line(
                    points = {
                        {-68, 0}, 
                        {-68, 65}},
                    color = {128, 128, 128}), 
                Text(
                    extent = {
                        {-40, 66}, 
                        {33, 85}},
                    lineColor = {0, 0, 255},
                    textString = "phi_rel"), 
                Line(
                    points = {
                        {-68, 60}, 
                        {72, 60}},
                    color = {128, 128, 128}), 
                Line(
                    points = {
                        {72, 0}, 
                        {72, 65}},
                    color = {128, 128, 128}), 
                Polygon(
                    points = {
                        {62, 63}, 
                        {72, 60}, 
                        {62, 57}, 
                        {62, 63}},
                    lineColor = {128, 128, 128},
                    fillColor = {128, 128, 128},
                    fillPattern = FillPattern.Solid)}));
end VariableDamper;