[MBDyn-users] Standard way to have a dynamically updated set of formulas

Richard Crozier r.crozier at ed.ac.uk
Tue Sep 18 09:40:40 CEST 2018


Thanks, I'll bear this in mind. In my case I'm trying actually trying to 
model a kind of pulley system, which I was going to do by having pulley 
sheaves as nodes, calculating the total length of the cable between all 
sheaves and when this length increases have a quadratically increasing 
force which represents the tension in the cable. I plan to then use the 
structural internal force to apply the resulting forces from the cable 
to each sheave node.

Imagine something like:

fixed        fixed
    x            x
    |            |
    |            |
    |            |
    |            |
    |            |
    x------------x
sheave   |    sheave
          x
     body hanging

Where the sheave positions are fixed relative to the body and the body 
experiences forces in all directions.

If there's a way of achieving this which does it more robustly I'd be 
happy to take advice. I might consider a custom module, if there was a 
similar example which is reasonable well commented. I've considered a 
custom module in the past but you have to have a pretty deep 
understanding of how everything works and there is no tutorial 
explaining how exactly the custom module works (I haven't checked the 
developers manual for this admittedly), but have looked at the 
templates. Unfortunately there is a shortage of comments in the code.

I would actually really like to add a wave hydrodynamic interaction 
module in the future, and was going to copy the aerodyn module to do 
this. Another thing I would like to do is add a moordyn module, similar 
to aerodyn. Unfortunately time is very short.

Richard


On 17/09/18 16:00, Andrea Zanoni wrote:
> Hi Richard,
> 
> as Louis and Reinhard pointed out, the most immediate way of achieving 
> the behavior that you want is to combine drives together.
> Depending on the complexity of your model, though, this solution can 
> lead to convergence problems, since you're introducing a force that 
> depends on the the system's state without adding its Jacobian contribution.
> 
> The best way would be to write your own custom element into a module.
> Again, this is probably worth the effort only if the drive based 
> solution is slowing down the convergence of your problem significantly.
> 
> Cheers
> Andrea
> 
> On 9/17/18 1:46 PM, Louis Gagnon wrote:
>> Dear Richard,
>>
>> If I am not mistaking, this can only be done with drives, something like:
>>
>> set: const integer vardist = 100;
>> set: const integer varxdist = 101;
>> set: const integer FX = 201;
>>
>>     drive caller: vardist,
>>         string, "model::distance(n_base01,n_body01)",
>>         output,
>>             value, 1,
>>             derivative, no;
>>
>>     drive caller: varxdist,
>>         string, "model::xdistance(n_base01,n_body01)",
>>         output,
>>             value, 1,
>>             derivative, no;
>>
>> then
>>
>>
>> drive caller: FX,
>>         mult, drive, string, "2.0*Var", reference, varxdist, drive, 
>> string, "1/Var", reference, vardist,
>>         output,
>>             value, 1,
>>             derivative, no;
>> then
>>
>> force:
>>           f_rod01,
>>           absolute internal,
>>           n_base01,    # node 1
>>           null,        # node 1 arm
>>           n_body01,    # node 2
>>           null,        # node 2 arm
>>           component,    # three components as separate drives
>>         reference, FX,...
>>
>>
>> etc..
>>
>> So in this case, the mult drive multiplies the outputs of the string 
>> drives together and the string drives use the reference drive numbers 
>> (or variables in this case) as input instead of time...
>>
>> Hope this helps,
>>
>>
>> -Louis
>>
>>
>>
>>
>>
>> On 09/17/2018 12:26 PM, Richard Crozier wrote:
>>> Dear List,
>>>
>>> I would like to have some values calculated in my model which are 
>>> evaluated at run time based on the model state. I would like to 
>>> calculate a series of expressions whose input are the outputs of 
>>> other expressions.
>>>
>>> I'm aware of the string driver where I can do things like:
>>>
>>> string,
>>> "2.0*model::xdistance(n_base01,n_body01)/model::distance(n_base01,n_body01)", 
>>>
>>>
>>> but what if I want to calculate a value in another formula and then 
>>> use this value in the string expression?
>>>
>>> Basically, can I calculate a series of expressions, i.e. do something 
>>> like:
>>>
>>> vardist = model::distance(n_base01,n_body01)
>>>
>>> varxdist = model::xdistance(n_base01,n_body01)
>>> varydist = model::ydistance(n_base01,n_body01)
>>> varzdist = model::zdistance(n_base01,n_body01)
>>>
>>> Fx = 2.0*varxdist/vardist
>>>
>>> Fy = 2.0*varydist/vardist
>>>
>>> Fz = 2.0*varzdist/vardist
>>>
>>>
>>>        force:
>>>            f_rod01,
>>>            absolute internal,
>>>            n_base01,    # node 1
>>>            null,        # node 1 arm
>>>            n_body01,    # node 2
>>>            null,        # node 2 arm
>>>            component,    # three components as separate drives
>>>          string, "Fx",
>>>          string, "Fy",
>>>          string, "Fz";
>>>
>>> If so what is the syntax? I realise I could probably have a series of 
>>> drivers, using 'drive drive' that could do this, but is there a 
>>> clearer way like above where one can simply set out a series of 
>>> formulas to be evaluates which take as input previously evaluated 
>>> variables? Somehting like the plugin variables?
>>>
>>> Thanks!
>>>
>>> Richard
>>>
>>
> 

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.



More information about the MBDyn-users mailing list