BearingFriction

model BearingFriction "Coulomb friction in bearings"
    extends Modelica.Mechanics.Rotational.Interfaces.PartialElementaryTwoFlangesAndSupport2;

    parameter Real tau_pos[:,2] = [0,1] "[w,tau] Positive sliding friction characteristic (w>=0)";
    parameter Real peak(final min = 1) = 1 "Peak for maximum friction torque at w==0 (tau0_max = peak*tau_pos[1,2])";

    extends Rotational.Interfaces.PartialFriction;
    extends Modelica.Thermal.HeatTransfer.Interfaces.PartialElementaryConditionalHeatPortWithoutT;

    SI.Angle phi "Angle between shaft flanges (flange_a, flange_b) and support";
    SI.Torque tau "Friction torque";
    SI.AngularVelocity w "Absolute angular velocity of flange_a and flange_b";
    SI.AngularAcceleration a "Absolute angular acceleration of flange_a and flange_b";
equation
    a = der(w);
    w = der(phi);
    a_relfric = a;
    free = false;
    lossPower = tau * w_relfric;
    phi = flange_a.phi - phi_support;
    tau = if locked then sa * unitTorque else if startForward then Modelica.Math.Vectors.interpolate(tau_pos[:,1], tau_pos[:,2], w, 1) else if startBackward then -Modelica.Math.Vectors.interpolate(tau_pos[:,1], tau_pos[:,2], -w, 1) else if pre(mode) == Forward then Modelica.Math.Vectors.interpolate(tau_pos[:,1], tau_pos[:,2], w, 1) else -Modelica.Math.Vectors.interpolate(tau_pos[:,1], tau_pos[:,2], -w, 1);
    tau0 = Modelica.Math.Vectors.interpolate(tau_pos[:,1], tau_pos[:,2], 0, 1);
    tau0_max = peak * tau0;
    w_relfric = w;
    flange_b.phi = flange_a.phi;
    flange_a.tau + flange_b.tau - tau = 0;

    annotation (
        Documentation(info = "<html>\n<p>\nThis element describes <strong>Coulomb friction</strong> in <strong>bearings</strong>,\ni.e., a frictional torque acting between a flange and the housing.\nThe positive sliding friction torque \"tau\" has to be defined\nby table \"tau_pos\" as function of the absolute angular velocity \"w\".\nE.g.\n</p>\n<pre>\n       w | tau\n      ---+-----\n       0 |   0\n       1 |   2\n       2 |   5\n       3 |   8\n</pre>\n<p>\ngives the following table:\n</p>\n<pre>\n   tau_pos = [0, 0; 1, 2; 2, 5; 3, 8];\n</pre>\n<p>\nCurrently, only linear interpolation in the table is supported.\nOutside of the table, extrapolation through the last\ntwo table entries is used. It is assumed that the negative\nsliding friction force has the same characteristic with negative\nvalues. Friction is modelled in the following way:\n</p>\n<p>\nWhen the absolute angular velocity \"w\" is not zero, the friction torque\nis a function of w and of a constant normal force. This dependency\nis defined via table tau_pos and can be determined by measurements,\ne.g., by driving the gear with constant velocity and measuring the\nneeded motor torque (= friction torque).\n</p>\n<p>\nWhen the absolute angular velocity becomes zero, the elements\nconnected by the friction element become stuck, i.e., the absolute\nangle remains constant. In this phase the friction torque is\ncalculated from a torque balance due to the requirement, that\nthe absolute acceleration shall be zero.  The elements begin\nto slide when the friction torque exceeds a threshold value,\ncalled the maximum static friction torque, computed via:\n</p>\n<pre>\n   maximum_static_friction = <strong>peak</strong> * sliding_friction(w=0)  (<strong>peak</strong> >= 1)\n</pre>\n<p>\nThis procedure is implemented in a \"clean\" way by state events and\nleads to continuous/discrete systems of equations if friction elements\nare dynamically coupled which have to be solved by appropriate\nnumerical methods. The method is described in\n(see also a short sketch in <a href=\"modelica://Modelica.Mechanics.Rotational.UsersGuide.ModelingOfFriction\">UsersGuide.ModelingOfFriction</a>):\n</p>\n<dl>\n<dt>Otter M., Elmqvist H., and Mattsson S.E. (1999):</dt>\n<dd><strong>Hybrid Modeling in Modelica based on the Synchronous\n    Data Flow Principle</strong>. CACSD'99, Aug. 22.-26, Hawaii.</dd>\n</dl>\n<p>\nMore precise friction models take into account the elasticity of the\nmaterial when the two elements are \"stuck\", as well as other effects,\nlike hysteresis. This has the advantage that the friction element can\nbe completely described by a differential equation without events. The\ndrawback is that the system becomes stiff (about 10-20 times slower\nsimulation) and that more material constants have to be supplied which\nrequires more sophisticated identification. For more details, see the\nfollowing references, especially (Armstrong and Canudas de Wit 1996):\n</p>\n<dl>\n<dt>Armstrong B. (1991):</dt>\n<dd><strong>Control of Machines with Friction</strong>. Kluwer Academic\n    Press, Boston MA.<br></dd>\n<dt>Armstrong B., and Canudas de Wit C. (1996):</dt>\n<dd><strong>Friction Modeling and Compensation.</strong>\n    The Control Handbook, edited by W.S.Levine, CRC Press,\n    pp. 1369-1382.<br></dd>\n<dt>Canudas de Wit C., Olsson H., &Aring;str&ouml;m K.J., and Lischinsky P. (1995):</dt>\n<dd><strong>A new model for control of systems with friction.</strong>\n    IEEE Transactions on Automatic Control, Vol. 40, No. 3, pp. 419-425.</dd>\n</dl>\n</html>"),
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Rectangle(
                    lineColor = {64, 64, 64},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.HorizontalCylinder,
                    extent = {
                        {-100, -10}, 
                        {100, 10}}), 
                Rectangle(extent = {
                    {-60, -60}, 
                    {60, -10}}), 
                Rectangle(
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-60, -25}, 
                        {60, -10}}), 
                Rectangle(
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-60, -61}, 
                        {60, -45}}), 
                Rectangle(
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-50, -50}, 
                        {50, -18}}), 
                Polygon(
                    fillColor = {160, 160, 164},
                    fillPattern = FillPattern.Solid,
                    points = {
                        {60, -60}, 
                        {60, -70}, 
                        {75, -70}, 
                        {75, -80}, 
                        {-75, -80}, 
                        {-75, -70}, 
                        {-60, -70}, 
                        {-60, -60}, 
                        {60, -60}}), 
                Line(points = {
                    {-75, -10}, 
                    {-75, -70}}), 
                Line(points = {
                    {75, -10}, 
                    {75, -70}}), 
                Rectangle(extent = {
                    {-60, 10}, 
                    {60, 60}}), 
                Rectangle(
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-60, 45}, 
                        {60, 60}}), 
                Rectangle(
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-60, 10}, 
                        {60, 25}}), 
                Rectangle(
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid,
                    extent = {
                        {-50, 19}, 
                        {50, 51}}), 
                Line(points = {
                    {-75, 70}, 
                    {-75, 10}}), 
                Polygon(
                    fillColor = {160, 160, 164},
                    fillPattern = FillPattern.Solid,
                    points = {
                        {60, 60}, 
                        {60, 70}, 
                        {75, 70}, 
                        {75, 80}, 
                        {-75, 80}, 
                        {-75, 70}, 
                        {-60, 70}, 
                        {-60, 60}, 
                        {60, 60}}), 
                Line(points = {
                    {75, 70}, 
                    {75, 10}}), 
                Text(
                    lineColor = {0, 0, 255},
                    extent = {
                        {-150, 90}, 
                        {150, 130}},
                    textString = "%name"), 
                Line(points = {
                    {0, -80}, 
                    {0, -100}}), 
                Line(
                    visible = useHeatPort,
                    points = {
                        {-100, -100}, 
                        {-100, -35}, 
                        {2, -35}},
                    color = {191, 0, 0},
                    pattern = LinePattern.Dot)}));
end BearingFriction;