Message Boards Message Boards

0
|
6465 Views
|
7 Replies
|
3 Total Likes
View groups...
Share
Share this post:
GROUPS:

Transfer function from SystemModeler when using Multibody library.

Posted 4 years ago

Dear all,

Using the MultiBody library I'm interested in analyzing the effect of ground vibrations on complex mechanical systems in frequency space using Mathematica. Mathematically, this is achieved by calculating a transfer function from the displacement of the attachment point to the ground to the displacement of an object within the mechanical system.

As far as I understand, in order to generate a state space model in Mathematica (via WSMLinearize) with such variable as an input, in the Modelica model the position of the suspension point must be declared as an input variable within the connector representing the physical attachment point to the ground, making the connector causal. However, in the Multibody library the suspension point is an acausal connector (connector Frame). The solution could be just to create a connector similar to MultiBody's Frame connector but causal with the relevant variables declared as inputs.

The big problem with this approach is that I would also like to use other instances of the same mechanical component and connect them to other mechanical components in an acausal way, operation which requires the usual acausal MultiBody's Frame connector.

Is there a way to have both functionalities within the same class?

I'm using SystemModeler 5.1.0 and Mathematica 11.3.0.0

Thank you in advance.

Regards,

Fabian

POSTED BY: Fabián Peña
7 Replies
Posted 4 years ago

Dear Neil,

Thank you very much for your suggestion again.

I did try but unfortunately Mathematica is not able to linearize the system (vibratingSystem1 in the diagram you posted previously) when the boolean "exact" variable is set to true in the position1 component:

SSModel = WSMLinearize[Model1, Method -> "NumericDerivative"] // Chop
SystemModelLinearize::bld: -- Message text not found -- (GroundSimple)
SystemModelLinearize::bldl: -- Message text not found -- (Error) (<<4209>>)

It does it well when it's set to false but the unwanted effect of the filter becomes obvious. I have the impression setting exact=true is not compatible with an input not being connected. The rationale of the code defining the position1 component is not clear from reading it.

Nevertheless, I think you have pointed out the correct way of obtaining the transfer function in Mathematica from SystemModeler. I just have to find a workaround to the effect of the position1 component.

Thank you indeed.

Regards,

Fabian

POSTED BY: Fabián Peña

Fabian,

The easiest solution is to create the subsystem that you want to linearize into a transfer function and put it in its own class (i.e. vibratingSystem). Then create a new class (i.e. RunSimulation) and wire your input to vibratingSystem. When you want transfer functions you work on vibratingSystem but when you simulate you use RunSimulation:

vibratingSystem is what you have above. RunSimulation looks like this

enter image description here

as to this:

By the way, I did not find an option to change the title of the post. It would be good indeed to change it to something more descriptive of what we're writing about.

Go to the bottom of your original post and click on the red edit link.

Regards,

Neil

POSTED BY: Neil Singer
Posted 4 years ago

Dear Neil and Sergio,

Thank you very much indeed for your suggestions. They are indeed very useful.

Currently I'm using a simple dummy system in order to become acquainted with the software and it's easy to set the initial conditions to the equilibrium state by adding a suitable initial equation depending of the physical parameters of the system. This way WSMLinearize can succesfully provide the state space equations. In the future, when the system becomes complex, letting the simulation run until reaching the steady state and then initializing the system from the experiment will likely be the way to go. Even with the ground motion the steady state should be close to the equilibrium conditions.

From seeing Neil's diagram I as able to simplify my system to the following: groundMotion is decleared as input

The sinusoidal generator mimics the ground motion with a zero offset and there's an added input for Modelica and Mathematica to treat it as such when linearizing in Mathematica. By setting the amplitude of the sine wave to zero, Mathematica does calculate numerically the state space model and then the transfer function.

However, there's an additional problem. The position1 component has a filter in order to numerically calculate the acceleration. This changes badly the behavior of the transfer function. I still have to check whether I can change the parameters of the filter in order to get the correct answer numerically, however, in reality I need to turn the filter off completely because I will need to do some symbolic calculations later using Mathematica. The problem is that when I set the "exact" boolean parameter of position1 to true the compiler does not accept the groundMotion input not being fed.

I did confirm that by removing the input and putting an explicit zero there I get the correct state space equations. However, in such case the ground motion does not appear as an input and I cannot calculate the transfer function with TransferFunctionModel.

By any chance do you know if in my version of SyetemModeler and Mathematica there's an option to calculate the transfer function to an output from a state variable which was not declared as an input beforehand?

I'm using SystemModeler 5.1.0 and Mathematica 11.3.0.0.

Thank you very much indeed for your comments.

By the way, I did not find an option to change the title of the post. It would be good indeed to change it to something more descriptive of what we're writing about.

Regards,

Fabian

POSTED BY: Fabián Peña

Hi Fabian,

Indeed, we agree with Neil's answers and suggestions.

A possible alternative to simulate starting from a steady state is going to SimulationCenter and use the Settings options on the left. In there you will find a "Stop at steady state" option. If you can get your system to simulate for a time long enough to reach the steady state, you can then use this option to stop at that point. This will work depending on your model but if you manage to do so, you can then use Tools > Initialize > From Experiment and that will use the steady state values that you reached.

Sergio

POSTED BY: Sergio Vargas

Fabian,

I am using version 12 of both WSM and MMA. I suggest that you upgrade, if possible, because this feature of both programs has been significantly enhanced in V12. To use the older version, I would do the equilibrium in WSM by going into SimulationCenter and doing Tools->Initialize_ToSteadyState. Then you do File->save the experiment settings. I would create a new model, only save the physical parameters (not colors, etc) and you will have to go back to model center and set those saved parameters as "fixed" at the start of the simulation. You also have to make sure you do not have any initial conditions previously set that conflict with the new settings.

At this point you can do the linearize.

There may be a way to do the equilibrium in MMA but I don't know how to do that. Maybe @Ankit Naik knows how that should work in WSMLink and V5.1.

I also recommend changing the thread title to make it more useful to people searching -- maybe "How do I get a transfer function in Mathematica from a SystemModeler Multibody model" or something like that.

Regards,

Neil

POSTED BY: Neil Singer
Posted 4 years ago

Hello Neil,

Thank you very much for your kind help.

I was able to reproduce the Modelica model, however, Mathematica does not recognize the command

nlsm =WSM`LocalizedSystemModel[eigensys,"StopTime"];

Instead I can use

WSMFindEquilibrium[Model1] ;
WSMLinearize[Model1] ;

but Mathematica fails to find an equilibrium position and returns an error. The only way in which an equilibrium position is found is by connecting body2 directly to world, in which case its position cannot be an input.

Any suggestion would be appreciated.

I'm using SystemModeler 5.1.0 and Mathematica 11.3.0.0.

Regards,

Fabian

POSTED BY: Fabián Peña

Fabian,

I do not think that this statement is true

As far as I understand, in order to generate a state space model in Mathematica (via WSMLinearize) with such variable as an input, in the Modelica model the position of the suspension point must be declared as an input variable within the connector representing the physical attachment point to the ground, making the connector causal.

I am not certain what you want but I think you can do the following.

Take your multibody system and hook up an input to drive the model. Here is an example. I hooked an input, u, to the "y" direction of the force and 0 to the x and z directions (since the bodies were constrained to move only in "y".

enter image description here

I obtained the transfer function, tf, from the following and I verified the vibration frequency of 0.528 hz against a simulation in WSM.

model = SystemModel["Model1"]
eigensys = SystemModelSimulate[model,All,0.01];
nlsm =WSM`LocalizedSystemModel[eigensys,"StopTime"];
nsimp = nlsm["SelectOutputs",{"body1.r_0[2]"}];
nsimp2 = nsimp["Simplify"];
nssmodel = nsimp2["Linearization"];
tf =TransferFunctionModel[nssmodel];
poles = Flatten[TransferFunctionPoles[tf]];
freq = Abs[poles[[1]]]/2/Pi

You can also leave in some variables in the linearization with something like this:

lsm =WSM`LocalizedSystemModel[eigensys,"StopTime",<|"SymbolicParameters"->{"springDamper1.c"}|>];

and get the transfer function (and the corresponding eigenvalues) as a function of the damper (after completing the other steps above obtaining tf). You can get the eigenvalues by doing:

Eigenvalues[First[Normal[StateSpaceModel[tf]]]]

I hope this helps.

Regards

Neil

Edit: fixed the image

POSTED BY: Neil Singer
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