model SpringDamperParallel "Linear spring and linear damper in parallel"
import Modelica.Mechanics.MultiBody.Types;
parameter Boolean animation = true "= true, if animation shall be enabled";
parameter SI.TranslationalSpringConstant c(final min = 0) "Spring constant";
parameter SI.Length s_unstretched = 0 "Unstretched spring length";
parameter SI.TranslationalDampingConstant d(final min = 0) = 0 "Damping constant";
parameter SI.Distance length_a = world.defaultForceLength "Length of damper cylinder at frame_a side"
annotation (Dialog(
tab = "Animation",
group = "if animation = true",
enable = animation));
input SIunits.Diameter diameter_a = world.defaultForceWidth "Diameter of damper cylinder at frame_a side"
annotation (Dialog(
tab = "Animation",
group = "if animation = true",
enable = animation));
input SIunits.Diameter diameter_b = 0.6 * diameter_a "Diameter of damper cylinder at frame_b side"
annotation (Dialog(
tab = "Animation",
group = "if animation = true",
enable = animation));
input Types.Color color_a = {100, 100, 100} "Color of damper cylinder at frame_a"
annotation (Dialog(
colorSelector = true,
tab = "Animation",
group = "if animation = true",
enable = animation));
input Types.Color color_b = {155, 155, 155} "Color of damper cylinder at frame_b"
annotation (Dialog(
colorSelector = true,
tab = "Animation",
group = "if animation = true",
enable = animation));
input Types.SpecularCoefficient specularCoefficient = world.defaultSpecularCoefficient "Reflection of ambient light (= 0: light is completely absorbed)"
annotation (Dialog(
tab = "Animation",
group = "if animation = true",
enable = animation));
input SI.Distance width = world.defaultForceWidth "Width of spring"
annotation (Dialog(
tab = "Animation",
group = "if animation = true",
enable = animation));
input SI.Distance coilWidth = 0.1 * width "Width of spring coil"
annotation (Dialog(
tab = "Animation",
group = "if animation = true",
enable = animation));
parameter Integer numberOfWindings = 5 "Number of spring windings"
annotation (Dialog(
tab = "Animation",
group = "if animation = true",
enable = animation));
input Types.Color color = Modelica.Mechanics.MultiBody.Types.Defaults.SpringColor "Color of spring"
annotation (Dialog(
colorSelector = true,
tab = "Animation",
group = "if animation = true",
enable = animation));
extends Interfaces.PartialLineForce;
extends Modelica.Thermal.HeatTransfer.Interfaces.PartialElementaryConditionalHeatPort(final T = 293.15);
protected
Modelica.SIunits.Force f_d "Damping force";
Visualizers.Advanced.Shape shape_a(shapeType = "cylinder", color = color_a, specularCoefficient = specularCoefficient, length = noEvent(min(length_a, s)), width = diameter_a, height = diameter_a, lengthDirection = e_a, widthDirection = {0, 1, 0}, r = frame_a.r_0, R = frame_a.R) if world.enableAnimation and animation;
Visualizers.Advanced.Shape shape_b(shapeType = "cylinder", color = color_b, specularCoefficient = specularCoefficient, length = noEvent(max(s - length_a, 0)), width = diameter_b, height = diameter_b, lengthDirection = e_a, widthDirection = {0, 1, 0}, r_shape = e_a * noEvent(min(length_a, s)), r = frame_a.r_0, R = frame_a.R) if world.enableAnimation and animation;
Visualizers.Advanced.Shape shape(shapeType = "spring", color = color, specularCoefficient = specularCoefficient, length = s, width = width, height = coilWidth * 2, lengthDirection = e_a, widthDirection = {0, 1, 0}, extra = numberOfWindings, r = frame_a.r_0, R = frame_a.R) if world.enableAnimation and animation;
equation
f = c * (s - s_unstretched) + f_d;
f_d = d * der(s);
lossPower = f_d * der(s);
annotation (
Documentation(info = "<html>\n<p>\n<strong>Linear spring</strong> and <strong>linear damper</strong>\nin parallel acting as line force between frame_a and frame_b.\nA <strong>force f</strong> is exerted on the origin of frame_b and with opposite sign\non the origin of frame_a along the line from the origin of frame_a to the origin\nof frame_b according to the equation:\n</p>\n<pre>\n f = c*(s - s_unstretched) + d*<strong>der</strong>(s);\n</pre>\n<p>\nwhere \"c\", \"s_unstretched\" and \"d\" are parameters, \"s\" is the\ndistance between the origin of frame_a and the origin of frame_b\nand der(s) is the time derivative of s.\n</p>\n</html>"),
Icon(
coordinateSystem(
preserveAspectRatio = true,
extent = {
{-100, -100},
{100, 100}}),
graphics = {
Text(
extent = {
{-150, -150},
{150, -110}},
textString = "%name",
lineColor = {0, 0, 255}),
Line(points = {
{-80, 40},
{-60, 40},
{-45, 10},
{-15, 70},
{15, 10},
{45, 70},
{60, 40},
{80, 40}}),
Line(points = {
{-80, 40},
{-80, -70}}),
Line(points = {
{-80, -70},
{-52, -70}}),
Rectangle(
extent = {
{-52, -40},
{38, -100}},
fillColor = {192, 192, 192},
fillPattern = FillPattern.Solid),
Line(points = {
{-52, -40},
{68, -40}}),
Line(points = {
{-52, -100},
{68, -100}}),
Line(points = {
{38, -70},
{80, -70}}),
Line(points = {
{80, 40},
{80, -70}}),
Line(points = {
{-100, 0},
{-80, 0}}),
Line(points = {
{80, 0},
{100, 0}}),
Text(
extent = {
{-150, 70},
{150, 100}},
textString = "d=%d"),
Line(
visible = useHeatPort,
points = {
{-100, -101},
{-100, -80},
{-6, -80}},
color = {191, 0, 0},
pattern = LinePattern.Dot),
Text(
extent = {
{-150, 105},
{150, 135}},
textString = "c=%c")}),
Diagram(
coordinateSystem(
preserveAspectRatio = true,
extent = {
{-100, -100},
{100, 100}}),
graphics = {
Line(
points = {
{-80, 32},
{-58, 32},
{-43, 2},
{-13, 62},
{17, 2},
{47, 62},
{62, 32},
{80, 32}},
thickness = 0.5),
Line(
points = {
{-68, 32},
{-68, 97}},
color = {128, 128, 128}),
Line(
points = {
{72, 32},
{72, 97}},
color = {128, 128, 128}),
Line(
points = {
{-68, 92},
{72, 92}},
color = {128, 128, 128}),
Polygon(
points = {
{62, 95},
{72, 92},
{62, 89},
{62, 95}},
lineColor = {128, 128, 128},
fillColor = {128, 128, 128},
fillPattern = FillPattern.Solid),
Text(
extent = {
{-20, 72},
{20, 97}},
lineColor = {0, 0, 255},
textString = "s"),
Rectangle(
extent = {
{-52, -20},
{38, -80}},
fillColor = {192, 192, 192},
fillPattern = FillPattern.Solid),
Line(points = {
{-52, -80},
{68, -80}}),
Line(points = {
{-52, -20},
{68, -20}}),
Line(points = {
{38, -50},
{80, -50}}),
Line(points = {
{-80, -50},
{-52, -50}}),
Line(points = {
{-80, 32},
{-80, -50}}),
Line(points = {
{80, 32},
{80, -50}}),
Line(points = {
{-100, 0},
{-80, 0}}),
Line(points = {
{100, 0},
{80, 0}})}));
end SpringDamperParallel;