Speed

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"
        annotation (Dialog(enable = not exact));
    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"
        annotation (Placement(transformation(extent = {
            {-140, -20}, 
            {-100, 20}})));
protected
    parameter Modelica.SIunits.AngularFrequency w_crit = 2 * Modelica.Constants.pi * f_crit "Critical frequency";
initial equation
    if not exact then 
        v = v_ref;
    end if;
equation
    if exact then 
        v = v_ref;
        a = 0;
    else 
        a = der(v);
        a = (v_ref - v) * w_crit;
    end if;
    v = der(s);

    annotation (
        Documentation(info = "<html>\n<p>\nThe input signal <strong>v_ref</strong> defines the <strong>reference\nspeed</strong> in [m/s]. Flange <strong>flange</strong> is <strong>forced</strong>\nto move relative to the support connector  according to this reference motion. According to parameter\n<strong>exact</strong> (default = <strong>false</strong>), this is done in the following way:\n</p>\n<ol>\n<li><strong>exact=true</strong><br>\n    The reference speed is treated <strong>exactly</strong>. This is only possible, if\n    the input signal is defined by an analytical function which can be\n    differentiated at least once. If this prerequisite is fulfilled,\n    the Modelica translator will differentiate the input signal once\n    in order to compute the reference acceleration of the flange.</li>\n<li><strong>exact=false</strong><br>\n    The reference speed is <strong>filtered</strong> and the first derivative\n    of the filtered curve is used to compute the reference acceleration\n    of the flange. This first derivative is <strong>not</strong> computed by\n    numerical differentiation but by an appropriate realization of the\n    filter. For filtering, a first order filter is used.\n    The critical frequency (also called cut-off frequency) of the\n    filter is defined via parameter <strong>f_crit</strong> in [Hz]. This value\n    should be selected in such a way that it is higher as the essential\n    low frequencies in the signal.</li>\n</ol>\n<p>\nThe input signal can be provided from one of the signal generator\nblocks of the block library Modelica.Blocks.Sources.\n</p>\n\n</html>"),
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    points = {
                        {-30, -32}, 
                        {30, -32}},
                    color = {0, 127, 0}), 
                Line(
                    points = {
                        {0, -32}, 
                        {0, -100}},
                    color = {0, 127, 0}), 
                Rectangle(
                    extent = {
                        {-100, 20}, 
                        {100, -20}},
                    lineColor = {0, 127, 0},
                    fillColor = {160, 215, 160},
                    fillPattern = FillPattern.Solid), 
                Line(
                    points = {
                        {-29, 32}, 
                        {30, 32}},
                    color = {0, 127, 0}), 
                Line(
                    points = {
                        {0, 52}, 
                        {0, 32}},
                    color = {0, 127, 0}), 
                Text(
                    extent = {
                        {150, 60}, 
                        {-150, 100}},
                    textString = "%name",
                    lineColor = {0, 0, 255}), 
                Text(
                    extent = {
                        {-140, -60}, 
                        {-40, -30}},
                    lineColor = {128, 128, 128},
                    horizontalAlignment = TextAlignment.Right,
                    textString = "v_ref"), 
                Text(
                    extent = {
                        {30, -60}, 
                        {150, -30}},
                    textString = "exact="), 
                Text(
                    extent = {
                        {30, -90}, 
                        {150, -60}},
                    textString = "%exact")}));
end Speed;