# Modeling a preloaded rotational spring in SystemModeler?

Posted 2 years ago
3730 Views
|
5 Replies
|
4 Total Likes
|
 I've been trying to model a preloaded rotational spring in SystemModeler for a while now. As far as I understand, there are two ways of constructing this model, By using the components in the Modelica library, By writing the governing equations and creating a custom block. A translational version of a preloaded spring exists in the Modelica.Mechanics.Translational.Examples.PreLoad directory. As a dirty solution, I can directly use that model and convert the input flange to a rotational flange by using an ideal rolling wheel block, however I don't want this.I can also modify this model by replacing the translational blocks with their rotational counterparts. However, I'm not sure whether that would work since ElastoGap and ElastoBacklash components are not completely similar.What I would really like to do was to construct the model by directly writing the governing equations. So I modified the rotational spring model as follows, model RotationalPreloadedSpring extends Modelica.Mechanics.Rotational.Interfaces.PartialCompliantWithRelativeStates; parameter Modelica.SIunits.RotationalSpringConstant c(final min = 0, start = 1.0e5) "Spring constant"; parameter Modelica.SIunits.Angle phi_rel0 = 0 "Unstretched spring angle"; parameter Modelica.SIunits.Torque Tpre "Preloaded torque"; equation phi_rel = if abs(tau) < Tpre then 0 else (tau - sign(tau) * Tpre) / c; end RotationalPreloadedSpring; I've constructed the following basic test setup and obtained the following result, In this basic setup, the model works properly. The spring acts as a rigid shaft and doesn't rotate until the applied torque exceeds the preloaded torque on the spring, then it rotates by an amount of (Tin - Tpre) / c.However, when I connect inertia to the ends of this spring model, I get absurd results from the setup; The spring switches between its two states violently. The simulation gets slowed and doesn't give anything useful.I've couldn't managed to make this model work for non-simple cases. I would be really glad if anyone can point out the mistakes I've been doing.
5 Replies
Sort By:
Posted 2 years ago
 Kursad,You can fix your problem by changing the line:phi_rel = if abs(tau) < Tpre then 0 else (tau - sign(tau) * Tpre) / c; to phi_rel = if abs(pre(tau)) < Tpre then 0 else (tau - sign(tau) * Tpre) / c;the "pre()" function will break an algebraic loop. You essentially have a "race" condition that is numerically unstable. The pre(tau) function will use the value of tau from an infinitesimal time slice earlier to determine the result of the if condition. Based on this test you will get proper behavior.By the way, the code for this seems to be a double preloaded shaft -- preloaded in both directions. Is this what you want or should it be only one directional?Regards
Posted 2 years ago
 Hello again,Thank you for your reply. I've modified the equation like you suggested, model RotationalPreloadedSpring2 extends Modelica.Mechanics.Rotational.Interfaces.PartialCompliantWithRelativeStates; parameter Modelica.SIunits.RotationalSpringConstant c(final min = 0, start = 1.0e5) "Spring constant"; parameter Modelica.SIunits.Angle phi_rel0 = 0 "Unstretched spring angle"; parameter Modelica.SIunits.Torque Tpre "Preloaded torque"; equation phi_rel = if abs(pre(tau)) < Tpre then 0 else (tau - sign(tau) * Tpre) / c; end RotationalPreloadedSpring2; The simulation is now running without a problem. However, the results doesn't seem to be correct,Also, if I remove the inertia block on the input side of the spring, Simulation Center window gets stuck while optimizing equations.By the way, the spring should be preloaded in both directions. Attachments:
Posted 2 years ago