Speed

model Speed "Forced movement of a flange according to a reference angular velocity signal"
    extends Modelica.Mechanics.Rotational.Interfaces.PartialElementaryOneFlangeAndSupport2;

    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.Angle phi(start = 0, fixed = true, stateSelect = StateSelect.prefer) "Rotation angle of flange with respect to support";
    SI.AngularVelocity w(stateSelect = if exact then StateSelect.default else StateSelect.prefer) "Angular velocity of flange with respect to support";
    SI.AngularAcceleration a "If exact=false, angular acceleration of flange with respect to support else dummy";
    Modelica.Blocks.Interfaces.RealInput w_ref(unit = "rad/s") "Reference angular velocity of flange with respect to support 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 
        w = w_ref;
    end if;
equation
    if exact then 
        w = w_ref;
        a = 0;
    else 
        a = der(w);
        a = (w_ref - w) * w_crit;
    end if;
    w = der(phi);
    phi = flange.phi - phi_support;

    annotation (
        Documentation(info = "<html>\n<p>\nThe input signal <strong>w_ref</strong> defines the <strong>reference\nspeed</strong> in [rad/s]. Flange <strong>flange</strong> is <strong>forced</strong>\nto move relative to flange support 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 angle is <strong>filtered</strong> and the second derivative\n    of the filtered curve is used to compute the reference acceleration\n    of the flange. This second 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</html>"),
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Text(
                    extent = {
                        {-140, -60}, 
                        {-40, -30}},
                    lineColor = {128, 128, 128},
                    horizontalAlignment = TextAlignment.Right,
                    textString = "w_ref"), 
                Text(
                    extent = {
                        {30, -60}, 
                        {150, -30}},
                    textString = "exact="), 
                Text(
                    extent = {
                        {30, -90}, 
                        {150, -60}},
                    textString = "%exact"), 
                Rectangle(
                    lineColor = {64, 64, 64},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.HorizontalCylinder,
                    extent = {
                        {-100, -20}, 
                        {100, 20}}), 
                Line(points = {
                    {-30, -32}, 
                    {30, -32}}), 
                Line(points = {
                    {0, 52}, 
                    {0, 32}}), 
                Line(points = {
                    {-29, 32}, 
                    {30, 32}}), 
                Line(points = {
                    {0, -32}, 
                    {0, -100}}), 
                Text(
                    lineColor = {0, 0, 255},
                    extent = {
                        {-150, 60}, 
                        {150, 100}},
                    textString = "%name")}));
end Speed;