Changeset 1130

Show
Ignore:
Timestamp:
05/25/08 13:11:28 (3 months ago)
Author:
otter
Message:

maintenance/3.0_ImprovedFriction/Modelica:
New, much simplified method without state machine to describe friction in Rotational and Translational library. The efficiency will be usually enhanced because less event iterations. Since no state machine any longer, inconsistent friction states, due to initialization and/or impulses are no longer possible.
Release notes updated.

Location:
branches/maintenance/3.0_ImprovedFriction/Modelica
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/maintenance/3.0_ImprovedFriction/Modelica/Mechanics/Rotational.mo

    r1119 r1130  
    669669          smooth=Smooth.None)); 
    670670    end FirstGrounded; 
     671 
     672    model SimpleFriction "Demonstration of BearingFriction element" 
     673       extends Modelica.Icons.Example; 
     674 
     675      Components.Inertia inertia( 
     676        J=2, 
     677        phi(fixed=true, start=0), 
     678        w(fixed=true, start=0)) 
     679        annotation (Placement(transformation(extent={{20,20},{40,40}}))); 
     680      Sources.Torque torque 
     681        annotation (Placement(transformation(extent={{-20,20},{0,40}}))); 
     682      annotation (Diagram(coordinateSystem(preserveAspectRatio=true, extent={{ 
     683                -100,-100},{100,100}}), graphics)); 
     684      Blocks.Sources.Sine sine(freqHz=2, amplitude=1.5) 
     685        annotation (Placement(transformation(extent={{-60,20},{-40,40}}))); 
     686      Components.BearingFriction bearingFriction(tau_pos=[0,1; 1,2], peak=1.1) 
     687        annotation (Placement(transformation(extent={{60,20},{80,40}}))); 
     688    equation 
     689      connect(torque.flange, inertia.flange_a) annotation (Line( 
     690          points={{0,30},{20,30}}, 
     691          color={0,0,0}, 
     692          smooth=Smooth.None)); 
     693      connect(sine.y, torque.tau) annotation (Line( 
     694          points={{-39,30},{-22,30}}, 
     695          color={0,0,127}, 
     696          smooth=Smooth.None)); 
     697      connect(inertia.flange_b, bearingFriction.flange_a) annotation (Line( 
     698          points={{40,30},{60,30}}, 
     699          color={0,0,0}, 
     700          smooth=Smooth.None)); 
     701    end SimpleFriction; 
    671702 
    672703    model Friction "Drive train with clutch and brake" 
     
    22822313 
    22832314      // Friction torque 
    2284       tau = if locked then sa*unitTorque else (if startForward then  
    2285         Modelica.Math.tempInterpol1(w, tau_pos, 2) else if startBackward then - 
    2286         Modelica.Math.tempInterpol1(-w, tau_pos, 2) else if pre(mode) == Forward then  
    2287               Modelica.Math.tempInterpol1(w, tau_pos, 2) else - 
    2288         Modelica.Math.tempInterpol1(-w, tau_pos, 2)); 
     2315      tau = if mode == Locked then  sa*unitTorque else  
     2316            if mode == Free then    0 else  
     2317            if mode == Forward then  Modelica.Math.tempInterpol1( w, tau_pos, 2) else  
     2318                                    -Modelica.Math.tempInterpol1(-w, tau_pos, 2); 
    22892319    end BearingFriction; 
    22902320 
     
    23662396              fillPattern=FillPattern.Solid), 
    23672397            Line(points={{0,90},{80,70},{80,-40},{70,-40}}, color={0,0,127}), 
    2368             Line(points={{0,90},{-80,70},{-80,-40},{-70,-40}}, color={0,0,127}), 
     2398            Line(points={{0,90},{-80,70},{-80,-40},{-70,-40}}, color={0,0,127}),  
     2399 
    23692400            Text( 
    23702401              extent={{-150,-180},{150,-140}}, 
     
    24842515 
    24852516      // friction torque 
    2486       tau = if locked then sa*unitTorque else if free then 0 else cgeo*fn*(if startForward then  
    2487               Modelica.Math.tempInterpol1(w, mue_pos, 2) else if startBackward then  
    2488               -Modelica.Math.tempInterpol1(-w, mue_pos, 2) else if pre(mode) == 
    2489         Forward then Modelica.Math.tempInterpol1(w, mue_pos, 2) else - 
    2490         Modelica.Math.tempInterpol1(-w, mue_pos, 2)); 
     2517      tau = if mode == Locked then sa*unitTorque else  
     2518            if mode == Free then   0 else  
     2519            cgeo*fn*(if mode==Forward then  Modelica.Math.tempInterpol1( w, mue_pos, 2) else  
     2520                                           -Modelica.Math.tempInterpol1(-w, mue_pos, 2)); 
    24912521    end Brake; 
    24922522 
     
    26652695 
    26662696      // friction torque 
    2667       tau = if locked then sa*unitTorque else if free then 0 else cgeo*fn*(if startForward then  
    2668               Modelica.Math.tempInterpol1(w_rel, mue_pos, 2) else if  
    2669         startBackward then -Modelica.Math.tempInterpol1(-w_rel, mue_pos, 2) else  
    2670         if pre(mode) == Forward then Modelica.Math.tempInterpol1(w_rel, mue_pos, 
    2671         2) else -Modelica.Math.tempInterpol1(-w_rel, mue_pos, 2)); 
     2697      tau = if mode == Locked then sa*unitTorque else  
     2698            if mode == Free then   0 else  
     2699            cgeo*fn*(if mode==Forward then  Modelica.Math.tempInterpol1( w_rel, mue_pos, 2) else  
     2700                                           -Modelica.Math.tempInterpol1(-w_rel, mue_pos, 2)); 
    26722701    end Clutch; 
    26732702 
     
    26832712        "Geometry constant containing friction distribution assumption"; 
    26842713      parameter SI.Force fn_max(final min=0, start=1) "Maximum normal force"; 
    2685       parameter SI.AngularVelocity w_small=1e10 
    2686         "Relative angular velocity near to zero if jumps due to a reinit(..) of the velocity can occur (set to low value only if such impulses can occur)" 
    2687          annotation(Dialog(tab="Advanced")); 
    26882714 
    26892715      Real u "normalized force input signal (0..1)"; 
    2690       SI.Force fn "Normal force (fn=fn_max*inPort.signal)"; 
    2691       Boolean startForward 
    2692         "true, if w_rel=0 and start of forward sliding or w_rel > w_small"; 
    2693       Boolean locked "true, if w_rel=0 and not sliding"; 
    2694       Boolean stuck(final start=false) "w_rel=0 (forward sliding or locked)"; 
    2695  
     2716      SI.Force fn "Normal force (fn=fn_max*u)"; 
     2717      Boolean locked(start=false) "true, if locked"; 
     2718      Boolean free "true, if not active (no friction)"; 
    26962719    protected 
    26972720      SI.Torque tau0 "Friction torque for w=0 and sliding"; 
    26982721      SI.Torque tau0_max "Maximum friction torque for w=0 and locked"; 
    26992722      Real mue0 "Friction coefficient for w=0 and sliding"; 
    2700       Boolean free "true, if frictional element is not active"; 
    27012723      Real sa(final unit="1") 
    27022724        "path parameter of tau = f(a_rel) Friction characteristic"; 
     2725      constant SI.AngularVelocity w_eps = 1e-8 
     2726        "If newFrictionDescription: defines region around zero, where the friction state is determined by acceleration, otherwise by w"; 
    27032727      constant Real eps0=1.0e-4 "Relative hysteresis epsilon"; 
    27042728      SI.Torque tau0_max_low "lowest value for tau0_max"; 
     
    27062730      constant SI.AngularAcceleration unitAngularAcceleration = 1; 
    27072731      constant SI.Torque unitTorque = 1; 
     2732      Real sa0 = (tau0_max + (tau0_max - tau0))/unitTorque 
     2733        "Value of sa when start of forward sliding at w=0"; 
    27082734    public 
    27092735      Modelica.Blocks.Interfaces.RealInput f_normalized 
     
    28602886      tau0_max = if free then tau0_max_low else peak2*tau0; 
    28612887 
    2862       /* Friction characteristic 
    2863        (locked is introduced to help the Modelica translator determining 
    2864        the different structural configurations, if for each configuration 
    2865        special code shall be generated) 
    2866     */ 
    2867       startForward = pre(stuck) and (sa > tau0_max/unitTorque or pre(startForward) and sa > 
    2868         tau0/unitTorque or w_rel > w_small) or initial() and (w_rel > 0); 
    2869       locked = pre(stuck) and not startForward; 
    2870  
    2871       // acceleration and friction torque 
    2872       a_rel = unitAngularAcceleration* (if locked then 0 else sa - tau0/unitTorque); 
    2873       tau = if locked then sa*unitTorque else (if free then 0 else cgeo*fn* 
    2874         Modelica.Math.tempInterpol1(w_rel, mue_pos, 2)); 
    2875  
    2876       // Determine configuration 
    2877       stuck = locked or w_rel <= 0; 
     2888      /* Friction characteristic */ 
     2889      locked = if w_rel > w_eps then false else  
     2890               if sa > tau0_max/unitTorque then false else true; 
     2891 
     2892      a_rel = unitAngularAcceleration*(if locked then 0 else sa - sa0); 
     2893 
     2894      tau = if locked then sa*unitTorque else if free then 0 else  
     2895                           cgeo*fn*Math.tempInterpol1(w_rel, mue_pos, 2); 
    28782896    end OneWayClutch; 
    28792897 
     
    30013019      SI.Torque tauLossMin "Torque loss for negative speed"; 
    30023020 
    3003       Boolean tau_aPos(start=true) 
    3004         "true, if torque of flange_a is not negative"; 
    3005       Boolean startForward(start=false) "true, if starting to roll forward"; 
    3006       Boolean startBackward(start=false) "true, if starting to roll backward"; 
    3007       Boolean locked(start=false) "true, if gear is locked"; 
     3021      Boolean tau_aPos(start=true) "true, if torque of flange_a is >= 0"; 
    30083022 
    30093023      Boolean ideal "true, if losses are neglected"; 
    30103024 
    3011       constant Integer Unknown=3 "Value of mode is not known"; 
    3012       constant Integer Free=2 "Element is not active"; 
    3013       constant Integer Forward=1 "w_a > 0 (forward rolling)"; 
    3014       constant Integer Stuck=0 
    3015         "w_a = 0 (forward rolling, locked or backward rolling)"; 
    3016       constant Integer Backward=-1 "w_a < 0 (backward rolling)"; 
    3017       Integer mode( 
    3018         final min=Backward, 
    3019         final max=Unknown, 
    3020         start=Free, 
    3021         fixed=true); 
     3025      constant Integer Free=2 "Element is not active" annotation(HideResult=true); 
     3026      constant Integer Forward=1 "Forward sliding" annotation(HideResult=true); 
     3027      constant Integer Locked=0 "Locked (no relative motion)" annotation(HideResult=true); 
     3028      constant Integer Backward=-1 "Backward sliding" annotation(HideResult=true); 
     3029      Integer mode(final max=2, final min=-1, start=Free) 
     3030        "Mode of friction element: 2: free, 1: forward sliding, 0: Locked, -1: Backward sliding"; 
    30223031 
    30233032      annotation ( 
     
    32033212 
    32043213    protected 
     3214      constant SI.AngularVelocity w_eps = 1e-8 
     3215        "Defines region around zero, where the friction state is determined by acceleration, otherwise by w_a"; 
    32053216      constant SI.AngularAcceleration unitAngularAcceleration = 1; 
    32063217      constant SI.Torque unitTorque = 1; 
    3207       function equal "Compare whether two Real matrices are identical" 
    3208  
    3209         extends Modelica.Icons.Function; 
    3210         input Real A[:, :]; 
    3211         input Real B[:, :]; 
    3212         input Real eps=Modelica.Constants.eps 
    3213           "two numbers r1, r2 are identical if abs(r1-r2) <= eps"; 
    3214         output Boolean result; 
    3215       algorithm 
    3216         result := false; 
    3217         if size(A, 1) == size(B, 1) and size(A, 2) == size(B, 2) then 
    3218           result := true; 
    3219           for i in 1:size(A, 1) loop 
    3220             for j in 1:size(A, 2) loop 
    3221               if abs(A[i, j] - B[i, j]) >= eps then 
    3222                 result := false; 
    3223               end if; 
    3224             end for; 
    3225           end for; 
    3226         end if; 
    3227         annotation (Documentation(info="<HTML> 
    3228 <p> 
    3229 The function call 
    3230 </p> 
    3231 <pre>     equal(A1, A2); 
    3232 </pre> 
    3233 <p> 
    3234 returns <b>true</b>, if the two Real matrices A1 and A2 have the 
    3235 same dimensions and the same elements. Otherwise the function 
    3236 returns <b>false</b>. Two elements r1 and r2 of A1 and A2 respectively 
    3237 are checked on equality by the test 'eps >= abs(r1-r2)', where 'eps' 
    3238 can be provided as third argument of the function (the default is 
    3239 Modelica.Constants.eps). 
    3240 </p> 
    3241 </HTML>")); 
    3242       end equal; 
    32433218    equation 
    32443219      assert(abs(ratio) > 0, 
    32453220        "Error in initialization of LossyGear: ratio may not be zero"); 
    32463221 
    3247       ideal = equal(lossTable, [0, 1, 1, 0, 0]); 
     3222      ideal = Modelica.Math.Matrices.isEqual(lossTable, [0, 1, 1, 0, 0], Modelica.Constants.eps); 
    32483223 
    32493224      interpolation_result = if ideal then [1, 1, 0, 0] else  
     
    32753250      tauLossMin = if tau_aPos then quadrant4 else quadrant3; 
    32763251 
    3277       // Determine rolling/stuck mode when w_rel = 0 
    3278       startForward = pre(mode) == Stuck and sa > tauLossMax/unitTorque or initial() and w_a 
    3279          > 0; 
    3280       startBackward = pre(mode) == Stuck and sa < tauLossMin/unitTorque or initial() and w_a 
    3281          < 0; 
    3282       locked = not (ideal or pre(mode) == Forward or startForward or pre(mode) 
    3283          == Backward or startBackward); 
    3284  
    3285       /* Parameterized curve description a_a = f1(sa), tauLoss = f2(sa) 
    3286        In comparison to Modelica.Mechanics.Rotational.FrictionBase it is possible 
    3287        to simplify the following expression as mode == Stuck is assured in case 
    3288        of startForward or startBackward */ 
    3289       tauLoss = if ideal then 0 else (if locked then sa*unitTorque else (if (startForward or  
    3290             pre(mode) == Forward) then tauLossMax else tauLossMin)); 
    3291  
    3292       a_a = unitAngularAcceleration*(if locked then 0 else sa - tauLoss/unitTorque); 
    3293  
    3294       /* Finite state machine to fix configuration after the computation above 
    3295        The above equations are only dependent on pre(mode) and not on the actual 
    3296        value of mode. This prevents loops. So mode can be determined in one step. */ 
    3297       mode = if ideal then Free else (if (pre(mode) == Forward or startForward) 
    3298          and w_a > 0 then Forward else if (pre(mode) == Backward or startBackward) 
    3299          and w_a < 0 then Backward else Stuck); 
     3252      // Determine mode of friction element 
     3253       mode = if ideal then Free else  
     3254              if w_a >  w_eps then Forward else  
     3255              if w_a < -w_eps then Backward else  
     3256              if sa > tauLossMax/unitTorque then Forward else  
     3257              if sa < tauLossMin/unitTorque then Backward else Locked; 
     3258 
     3259       tauLoss = if ideal then 0 else  
     3260                 if mode == Free then 0 else  
     3261                 if mode == Locked then sa*unitTorque else  
     3262                 if mode == Forward then tauLossMax else tauLossMin; 
     3263 
     3264       a_a = unitAngularAcceleration*(if mode==Locked then 0 else sa - tauLoss/unitTorque); 
    33003265    end LossyGear; 
    33013266 
     
    35793544              fillColor={192,192,192}), 
    35803545            Polygon( 
    3581               points={{-60,10},{-60,20},{-40,40},{-40,-40},{-60,-20},{-60,10}}, 
     3546              points={{-60,10},{-60,20},{-40,40},{-40,-40},{-60,-20},{-60,10}},  
     3547 
    35823548              lineColor={0,0,0}, 
    35833549              fillPattern=FillPattern.HorizontalCylinder, 
     
    62366202</p> 
    62376203</html>")); 
    6238       // parameter SI.AngularVelocity w_small=1 "Relative angular velocity near to zero (see model info text)"; 
    6239       parameter SI.AngularVelocity w_small=1.0e10 
    6240         "Relative angular velocity near to zero if jumps due to a reinit(..) of the velocity can occur (set to low value only if such impulses can occur)" 
    6241          annotation(Dialog(tab="Advanced")); 
     6204 
    62426205    // Equations to define the following variables have to be defined in subclasses 
    62436206      SI.AngularVelocity w_relfric 
     
    62506213      SI.Torque tau0_max "Maximum friction torque for w=0 and locked"; 
    62516214      Boolean free "true, if frictional element is not active"; 
     6215 
    62526216    // Equations to define the following variables are given in this class 
    62536217      Real sa(final unit="1") 
    62546218        "Path parameter of friction characteristic tau = f(a_relfric)"; 
    6255       Boolean startForward(start=false, fixed=true) 
    6256         "true, if w_rel=0 and start of forward sliding"; 
    6257       Boolean startBackward(start=false, fixed=true) 
    6258         "true, if w_rel=0 and start of backward sliding"; 
    6259       Boolean locked(start=false) "true, if w_rel=0 and not sliding"; 
    6260       constant Integer Unknown=3 "Value of mode is not known"; 
    6261       constant Integer Free=2 "Element is not active"; 
    6262       constant Integer Forward=1 "w_rel > 0 (forward sliding)"; 
    6263       constant Integer Stuck=0 
    6264         "w_rel = 0 (forward sliding, locked or backward sliding)"; 
    6265       constant Integer Backward=-1 "w_rel < 0 (backward sliding)"; 
    6266       Integer mode( 
    6267         final min=Backward, 
    6268         final max=Unknown, 
    6269         start=Unknown, fixed=true); 
     6219 
     6220      constant Integer Free=2 "Element is not active" annotation(HideResult=true); 
     6221      constant Integer Forward=1 "Forward sliding" annotation(HideResult=true); 
     6222      constant Integer Locked=0 "Locked (no relative motion)" annotation(HideResult=true); 
     6223      constant Integer Backward=-1 "Backward sliding" annotation(HideResult=true); 
     6224      Integer mode(final max=2, final min=-1, start=Free) 
     6225        "Mode of friction element: 2: free, 1: forward sliding, 0: Locked, -1: Backward sliding"; 
     6226 
    62706227    protected 
     6228      constant SI.AngularVelocity w_eps = 1e-8 
     6229        "If newFrictionDescription: defines region around zero, where the friction state is determined by acceleration, otherwise by w"; 
    62716230      constant SI.AngularAcceleration unitAngularAcceleration = 1 annotation(HideResult=true); 
    62726231      constant SI.Torque unitTorque = 1 annotation(HideResult=true); 
     
    62746233        "Value of sa when start of forward sliding at w=0"; 
    62756234    equation 
    6276     /* Friction characteristic 
    6277    locked is introduced to help the Modelica translator determining 
    6278    the different structural configurations,  
    6279    if for each configuration special code shall be generated) 
    6280 */ 
    6281       startForward  = pre(mode) == Stuck and sa >  tau0_max/unitTorque or  
    6282         pre(mode) == Backward and w_relfric >  w_small or initial() and w_relfric > 0; 
    6283       startBackward = pre(mode) == Stuck and sa < -tau0_max/unitTorque or  
    6284         pre(mode) == Forward  and w_relfric < -w_small or initial() and w_relfric < 0; 
    6285       locked = not free and  
    6286         not (pre(mode) == Forward or startForward or pre(mode) == Backward or startBackward); 
    6287       a_relfric/unitAngularAcceleration = if locked then               0 else  
    6288                                           if free then                 sa else  
    6289                                           if startForward then         sa - sa0 else  
    6290                                           if startBackward then        sa + sa0 else  
    6291                                           if pre(mode) == Forward then sa - sa0 else  
    6292                                                                        sa + sa0; 
    6293     /* Friction torque has to be defined in a subclass. Example for a clutch: 
    6294    tau = if locked then sa else  
    6295          if free then   0 else  
    6296          cgeo*fn*(if startForward then          Math.tempInterpol1( w_relfric, mue_pos, 2) else 
    6297                   if startBackward then        -Math.tempInterpol1(-w_relfric, mue_pos, 2) else 
    6298                   if pre(mode) == Forward then  Math.tempInterpol1( w_relfric, mue_pos, 2) else  
    6299                                                -Math.tempInterpol1(-w_relfric, mue_pos, 2)); 
    6300 */ 
    6301     // finite state machine to determine configuration 
    6302       mode = if free then Free else  
    6303         (if (pre(mode) == Forward  or pre(mode) == Free or startForward)  and w_relfric > 0 then  
    6304            Forward else  
    6305          if (pre(mode) == Backward or pre(mode) == Free or startBackward) and w_relfric < 0 then  
    6306            Backward else  
    6307            Stuck); 
     6235       mode = if free then Free else  
     6236              if w_relfric >  w_eps then Forward else  
     6237              if w_relfric < -w_eps then Backward else  
     6238              if sa > tau0_max/unitTorque then Forward else  
     6239              if sa < -tau0_max/unitTorque then Backward else Locked; 
     6240 
     6241       a_relfric = unitAngularAcceleration*(if mode == Locked then  0 else  
     6242                                            if mode == Free then    sa else  
     6243                                            if mode == Forward then sa - sa0 else sa + sa0); 
     6244 
     6245       /* Friction torque has to be defined in a subclass. Example for a clutch: 
     6246      tau = if mode == Locked then sa*unitTorque else  
     6247            if mode == Free   then 0 else  
     6248            cgeo*fn*(if mode==Forward then  Math.tempInterpol1(w_relfric, mue_pos, 2) 
     6249                                      else -Math.tempInterpol1(-w_relfric, mue_pos, 2)); 
     6250   */ 
    63086251    end PartialFriction; 
    63096252 
  • branches/maintenance/3.0_ImprovedFriction/Modelica/Mechanics/Translational.mo

    r1119 r1130  
    898898            Text( 
    899899              extent={{-98,-68},{102,-94}}, 
    900               textString="positive force => spool moves in positive direction ", 
     900              textString="positive force => spool moves in positive direction ",  
     901 
    901902              lineColor={0,0,255}), 
    902903            Text( 
     
    19901991 
    19911992    // Friction force 
    1992       f = if locked then sa*unitForce else  
    1993          (if startForward then          Modelica.Math.tempInterpol1( v, f_pos, 2) else  
    1994           if startBackward then        -Modelica.Math.tempInterpol1(-v, f_pos, 2) else  
    1995           if pre(mode) == Forward then  Modelica.Math.tempInterpol1( v, f_pos, 2) else  
    1996                                        -Modelica.Math.tempInterpol1(-v, f_pos, 2)); 
     1993       f = if mode == Locked then sa*unitForce else  
     1994           if mode == Free then      0 else  
     1995           if mode == Forward then  Math.tempInterpol1( v, f_pos, 2) else  
     1996                                   -Math.tempInterpol1(-v, f_pos, 2); 
     1997 
    19971998    end SupportFriction; 
    19981999 
     
    21792180      free = fn <= 0; 
    21802181 
    2181       // friction force 
    2182       f = if locked then sa*unitForce else  
    2183           if free then   0 else  
    2184           cgeo*fn*(if startForward then          Modelica.Math.tempInterpol1( v, mue_pos, 2) else  
    2185                    if startBackward then        -Modelica.Math.tempInterpol1(-v, mue_pos, 2) else  
    2186                    if pre(mode) == Forward then  Modelica.Math.tempInterpol1( v, mue_pos, 2) else  
    2187                                                 -Modelica.Math.tempInterpol1(-v, mue_pos, 2)); 
     2182    // friction force 
     2183      f = if mode == Locked then  sa*unitForce else  
     2184          if mode == Free then 0 else  
     2185          cgeo*fn*(if mode == Forward then  Math.tempInterpol1( v, mue_pos, 2) else  
     2186                                           -Math.tempInterpol1(-v, mue_pos, 2)); 
    21882187    end Brake; 
    21892188 
     
    26272626              textString="Length L", 
    26282627              lineColor={0,0,255})})); 
     2628 
    26292629    encapsulated partial model PartialFrictionWithStop 
    26302630        "Base model of Coulomb friction elements with stop" 
     
    26582658      Real sa(unit="1") 
    26592659          "Path parameter of friction characteristic f = f(a_relfric)"; 
    2660       Boolean startForward(start=false, fixed=true) 
    2661           "= true, if v_rel=0 and start of forward sliding or v_rel > v_small"; 
    2662       Boolean startBackward(start=false, fixed=true) 
    2663           "= true, if v_rel=0 and start of backward sliding or v_rel < -v_small"; 
    2664       Boolean locked(start=false) "true, if v_rel=0 and not sliding"; 
     2660 
    26652661      extends PartialRigid(s(start=0, stateSelect = StateSelect.always)); 
    2666       constant Integer Unknown=3 "Value of mode is not known"; 
    2667       constant Integer Free=2 "Element is not active"; 
    2668       constant Integer Forward=1 "v_rel > 0 (forward sliding)"; 
    2669       constant Integer Stuck=0 
    2670           "v_rel = 0 (forward sliding, locked or backward sliding)"; 
    2671       constant Integer Backward=-1 "v_rel < 0 (backward sliding)"; 
    2672       Integer mode( 
    2673         final min=Backward, 
    2674         final max=Unknown, 
    2675         start=Unknown, fixed=true); 
     2662 
     2663      constant Integer Free=2 "Element is not active" annotation(HideResult=true); 
     2664      constant Integer Forward=1 "Forward sliding" annotation(HideResult=true); 
     2665      constant Integer Locked=0 "Locked (no relative motion)" annotation(HideResult=true); 
     2666      constant Integer Backward=-1 "Backward sliding" annotation(HideResult=true); 
     2667      Integer mode(final max=2, final min=-1, start=Free) 
     2668          "Mode of friction element: 2: free, 1: forward sliding, 0: Locked, -1: Backward sliding"; 
    26762669      protected 
     2670      constant SI.Velocity v_eps = 1e-8 
     2671          "If newFrictionDescription: defines region around zero, where the friction state is determined by acceleration, otherwise by v"; 
    26772672      constant SI.Acceleration unitAcceleration = 1 annotation(HideResult=true); 
    26782673      constant SI.Force unitForce = 1 annotation(HideResult=true); 
     
    26802675          "Value of sa when start of forward sliding at w=0"; 
    26812676    equation 
    2682     /* Friction characteristic 
    2683    (locked is introduced to help the Modelica translator determining 
    2684    the different structural configurations,  
    2685    if for each configuration special code shall be generated) 
    2686 */ 
    2687       startForward  = pre(mode) == Stuck and sa >  f0_max/unitForce and s < (smax - L/2) or  
    2688         pre(mode) == Backward and v_relfric >  v_small or initial() and v_relfric > 0; 
    2689       startBackward = pre(mode) == Stuck and sa < -f0_max/unitForce and s > (smin + L/2) or  
    2690         pre(mode) == Forward  and v_relfric < -v_small or initial() and v_relfric < 0; 
    2691       locked = not free and  
    2692         not (pre(mode) == Forward or startForward or pre(mode) == Backward or startBackward); 
    2693       a_relfric/unitAcceleration = if locked then               0 else  
    2694                                    if free then                 sa else  
    2695                                    if startForward then         sa - sa0 else  
    2696                                    if startBackward then        sa + sa0 else  
    2697                                    if pre(mode) == Forward then sa - sa0 else  
    2698                                                                 sa + sa0; 
    2699     /* Friction torque has to be defined in a subclass. Example for a clutch: 
    2700    f = if locked then sa else  
    2701        if free then   0 else  
    2702        cgeo*fn*(if startForward then          Math.tempInterpol1( v_relfric, mue_pos, 2) else  
    2703                 if startBackward then        -Math.tempInterpol1(-v_relfric, mue_pos, 2) else  
    2704                 if pre(mode) == Forward then  Math.tempInterpol1( v_relfric, mue_pos, 2) else  
    2705                                              -Math.tempInterpol1(-v_relfric, mue_pos, 2)); 
    2706 */ 
    2707     // finite state machine to determine configuration 
    2708       mode = if free then Free else  
    2709         (if (pre(mode) == Forward  or pre(mode) == Free or startForward)  and v_relfric > 0 and s < (smax - L/2) then  
    2710            Forward else  
    2711          if (pre(mode) == Backward or pre(mode) == Free or startBackward) and v_relfric < 0 and s > (smin + L/2) then  
    2712            Backward else  
    2713            Stuck); 
     2677    /* Friction characteristic */ 
     2678       mode = if free then Free else  
     2679              if v_relfric >  v_eps and s < (smax - L/2) then Forward else  
     2680              if v_relfric < -v_eps and s > (smin + L/2) then Backward else  
     2681              if sa >  f0_max/unitForce and s < (smax - L/2) then Forward else  
     2682              if sa < -f0_max/unitForce and s > (smin + L/2) then Backward else Locked; 
     2683 
     2684       a_relfric = unitAcceleration*(if mode == Locked then  0 else  
     2685                                     if mode == Free then    sa else  
     2686                                     if mode == Forward then sa - sa0 else sa + sa0); 
    27142687    end PartialFrictionWithStop; 
     2688 
    27152689    equation 
    27162690      // Constant auxiliary variables 
     
    27182692      f0_max = f0*1.001; 
    27192693      free = f0 <= 0 and F_prop <= 0 and s > smin + L/2 and s < smax - L/2; 
     2694 
    27202695      // Velocity and acceleration of flanges 
    27212696      v = der(s); 
     
    27232698      v_relfric = v; 
    27242699      a_relfric = a; 
     2700 
    27252701    // Equilibrium of forces 
    27262702      0 = flange_a.f + flange_b.f - f - m*der(v); 
     2703 
    27272704    // Friction force 
    2728       f = if locked then sa*unitForce else  
    2729           if free then   0 else  
    2730                         (if startForward then         F_prop*v + F_Coulomb + F_Stribeck else  
    2731                          if startBackward then        F_prop*v - F_Coulomb - F_Stribeck else  
    2732                          if pre(mode) == Forward then F_prop*v + F_Coulomb + F_Stribeck*exp(-fexp*abs(v)) else  
    2733                                                       F_prop*v - F_Coulomb - F_Stribeck*exp(-fexp*abs(v))); 
     2705       f = if mode == Locked then  sa*unitForce else  
     2706           if mode == Free then    0 else  
     2707           if mode == Forward then F_prop*v + F_Coulomb + F_Stribeck*exp(-fexp*abs(v)) else  
     2708                                   F_prop*v - F_Coulomb - F_Stribeck*exp(-fexp*abs(v)); 
     2709 
    27342710    // Define events for hard stops and reinitiliaze the state variables velocity v and position s 
    27352711    algorithm 
     
    35613537            preserveAspectRatio=true, 
    35623538            extent={{-100,-100},{100,100}}, 
    3563             grid={1,1}), graphics={Line(points={{-70,0},{-90,0}}, color={0,0,0}), 
     3539            grid={1,1}), graphics={Line(points={{-70,0},{-90,0}}, color={0,0,0}),  
    35643540              Text( 
    35653541              extent={{80,-28},{114,-62}}, 
     
    35933569            preserveAspectRatio=true, 
    35943570            extent={{-100,-100},{100,100}}, 
    3595             grid={1,1}), graphics={Line(points={{-70,0},{-90,0}}, color={0,0,0}), 
     3571            grid={1,1}), graphics={Line(points={{-70,0},{-90,0}}, color={0,0,0}),  
    35963572              Text( 
    35973573              extent={{80,-28},{111,-61}}, 
     
    36273603            preserveAspectRatio=true, 
    36283604            extent={{-100,-100},{100,100}}, 
    3629             grid={1,1}), graphics={Line(points={{-70,0},{-90,0}}, color={0,0,0}), 
     3605            grid={1,1}), graphics={Line(points={{-70,0},{-90,0}}, color={0,0,0}),  
    36303606              Text( 
    36313607              extent={{80,-28},{115,-60}}, 
     
    46814657</html> 
    46824658")); 
    4683     /