model SignForce "Constant force changing sign with speed"
import Modelica.Constants.pi;
extends Modelica.Mechanics.Translational.Interfaces.PartialForce;
parameter Modelica.SIunits.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"
annotation (Evaluate = true);
parameter Modelica.SIunits.Velocity v0(final min = Modelica.Constants.eps, start = 0.1) "Regularization below v0";
Modelica.SIunits.Velocity v "Velocity of flange with respect to support (= der(s))";
equation
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 v0 <= abs(v) then sign(v) else Modelica.Math.sin(0.5 * pi * v / v0));
elseif reg == Modelica.Blocks.Types.Regularization.Linear then
f = -f_nominal * (if v0 <= abs(v) then sign(v) else v / v0);
else
f = -f_nominal * (if v0 <= abs(v) then sign(v) else sign(v) * (1 - Modelica.Math.cos(0.5 * pi * v / v0)));
end if;
v = der(s);
annotation (
Icon(
coordinateSystem(
preserveAspectRatio = true,
extent = {
{-100, -100},
{100, 100}}),
graphics = {
Line(
points = {
{0, 66},
{0, -20}},
color = {192, 192, 192}),
Line(
points = {
{-75, 24},
{75, 24}},
color = {192, 192, 192}),
Line(points = {
{-74, -12},
{-8, -12},
{-6, -10},
{6, 58},
{8, 60},
{74, 60}}),
Text(
extent = {
{-120, -50},
{120, -20}},
textString = "%f_nominal")}),
Documentation(info = "<html>\n<p>Model of constant force which changes sign with direction of movement.</p>\n<p>Please note:<br>\nPositive force accelerates in both directions of movement.<br>\nNegative force brakes in both directions of movement.</p>\n<p>Around zero speed regularization avoids numerical problems.</p>\n</html>"));
end SignForce;