| | 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; |
| 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); |
| 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 | |
| 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)); |
| 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)); |
| 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)"; |
| 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); |
| 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"; |
| 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; |
| 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); |
| 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 | |
| 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 | |
| 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 | */ |