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.