Reputation: 135
I made the wrap angle code in the Modelica like below.
thetta_eq=mod(thetta, 720);
thetta keep increasing 0 to infinite angle and thetta_eq is the wrapped angle 0 to 720deg.
However, the problem is occurring when i differentiate the wrapped angle.
Furthermore, i'm not able to use the wrapangle block in the Modelica Standard Library 3.2.3 because i have to use 3.2.2 version.
Does anyone have solution for this problem? Code, Logic or options?
I already know that it's not possible to differentiate when angle drops 720 to 0 deg, because it's discontinuous.
So, What i'd like to ask was making it continuous even the falling region.
Acutually, above picture is sigmoid function and i thought i can use this function when the wrap angle falls 720 to 0 deg.
If i make the sigmoid function's inclination really high, i thought this can be functioning like original wrap angle. And the derivative is not infinite or -infinite so it can be differentiated.
How do you think? and How can i make the logic for this idea?
ps) I really appreciate your reply!
Upvotes: 1
Views: 422
Reputation: 6655
Like matth commented, you can not differentiate a variable with discontinuities. What would you expect for the derivative when theta jumps from 720 to 0?
Instead of using the wrapped angle, you can use the derivative of the original angle.
model Demo
Modelica.SIunits.Angle theta = 100*sin(time);
Modelica.SIunits.Angle theta_wrap;
Modelica.SIunits.AngularVelocity w;
equation
w = der(theta);
theta_wrap=mod(theta, 2*Modelica.Constants.pi);
end Demo;
Note: I used the proper SIunit type for theta, so I have to wrap to 2*pi radians, instead of 720 degree.
Upvotes: 4