Message Boards Message Boards

3
|
8420 Views
|
5 Replies
|
11 Total Likes
View groups...
Share
Share this post:

Torn Equations and solving Nonlinear problems within SystemModeler

Posted 3 years ago

I am working on a little project to help learn more of SystemModeler and modeling within that environment.

I have a working physical test bench of the system I choose to simulate, I would like to simulate and design and test different control schemes via SystemModeler, Mathematica and the Microcontroller Kit.

The system being a 3d inverted pendulum, like the Cubli.

When simulating the single degree of freedom, I have great stabilization.

single degree

This model is in-fact the second version of it I have designed, the first version using Bodyshapes classes while this newer version uses Rotorswith3Deffects

I have changed the model to use the rotors as the angle/control reactions in the first did not reflect reality with the physical test bench, while the newer version is almost nearly identical...but I digress.

When inverting this model to stand on its corner to be a 3DOF, 3D pendulum, I am now getting constant "torn" errors, which I can view with the Equation browser, however I can't begin to understand how this is helpful, or what I can do, beyond what it seems to be setting initial conditions to repair the problem...this however leads to an ever increasing cascade in more torn system errors. torn

My model isn't particularly large I think but I am using several custom subsystems and functions, I realize, but for an idea of what I have built, see the below images.

The working Single DOF system with control.

single

The Same system with 3 DOF activated, causing torn system.

3dof

I don't think this is a particularly interesting or difficult nonlinear system to Solve for SystemModeler...I feel this has something to do with the Rotorswith3dEffects but since this works in the 1DOF systems, I am somewhat at a loss.

How can I fix the torn system via the equation browser? Is this is the wrong direction to follow? Is there a better way or thing to look out for?

I have looked at the GyroscopicEffects example from recommendations from previous questions...which is how I managed to come up with the model I have (which again works great in the 1DOF simulation).

My physical test bench for reference:

enter image description here

POSTED BY: Mor Bo
5 Replies

however, when importing just the physical model with the three inputs it has unconnected, Mathematica complains the model is unbalanced and and nothing can be done

Many properties and SystemModel functions relay on the model building to be able to compute results. In some cases this is necessary (e.g. when simulating) but in some cases we do have some room for improvement where building would not be necessary in principle.

However, when importing with just a Const.k =0 connected to the models inputs, it can simulate the model, but the outputs and inputs appear empty and it refuses to give a statespacemodel that has any inputs or outputs..

I don't have your model, but let me show you what I think may be happening with one of the Modelica library examples in this domain. If you compute

SystemModelLinearize["Modelica.Mechanics.MultiBody.Examples.Elementary.ForceAndTorque"]

you'll find that there are no inputs or outputs in the resulting state space model. This is because sources are explicitly being provided to the would-be inputs and there are no top-level real outputs either. If you duplicate this model and you replace either the component torque or the component force, for a 3D array of "Modelica.Blocks.Interfaces.RealInput", then linearization will detect these inputs. Similarly, you can add a sensor from "Modelica.Mechanics.MultiBody.Sensors" to a frame in the model, connected to a top level output ("Modelica.Blocks.Interfaces.RealOutput"), and then linearization will detect them as outputs. Hope this helps.

POSTED BY: Sergio Vargas
Posted 3 years ago

Thank you for the explanations! Once I get around to working on it again, I will definitely report back my findings, Though it seems like that is the problem, namely lack of proper Real.Output

POSTED BY: Mor Bo
Posted 3 years ago

Thank you for such a quick reply, and your tips, in fact the error was using the three revolute joints...once switching to a Sphericaljoint as you suggested the problem went away, I can now simulate and test as I please....Though I am now having another problem, I would like to import the model into Mathematica to derive some control values and experiment there...however, when importing just the physical model with the three inputs it has unconnected, Mathematica complains the model is unbalanced and and nothing can be done.

However, when importing with just a Const.k =0 connected to the models inputs, it can simulate the model, but the outputs and inputs appear empty and it refuses to give a statespacemodel that has any inputs or outputs...(outputs I expect to be around 15 and inputs 3...should I ask a new question or are you aware if models have to be specially designed for inputs and outputs when importing to Mathematica?

Thank you again for the initial help!

POSTED BY: Mor Bo

One more thing: I see now that the problematic equation system is in the initialization problem, meaning that the observation above regarding integration of angular velocities doesn't really apply. Initialization can be tricky, but debugging is simplified by the fact that errors don't build up during numeric integration of differential equations; one just has to go through the equation systems one by one and make sure the equations being solved make sense.

POSTED BY: Henrik Tidefelt

Thanks for posting a very nicely illustrated question. I am on the System Modeler development team, and very interested in understanding what we can do better to help users "debug" this sort of problems. Of course, I also wish things were simple enough that one would never need to reach out for help, but I am well aware that this is not always the case when working with MultiBody models.

Some observations to start with:

  • Your model has a sequence of three revolute joints to give the cube its three degrees of freedom. However, such a configuration has the danger of ending up in singular configurations. Maybe you are aware of this and can make sure you don't end up there, but a Spherical joint typically solves this problem in a better way.
  • It surprises me that the only nonlinear system seen in the equation browser has been reduced by tearing to just a single angular variable. I mean, the symmetry of the problem's three degrees of freedom suggests to me that none of the angles should be possible to solve before any of the others, and since the three angles are not algebraically constrained, the nonlinear system where one angle is solved shouldn't be possible to tear to size 1. However, maybe the physical symmetry is lost in the sequence of revolute joints, so I could be wrong about this.
  • My gut feeling is that one could expect angles to be computed by integration of angular velocities rather than being solved from nonlinear systems of equations. Have you checked whether the selection of states looks sensible?
POSTED BY: Henrik Tidefelt
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract