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

Andrea Zanoni andrea.zanoni at polimi.it
Mon Sep 17 17:00:33 CEST 2018


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
>>
>

-- 
Andrea Zanoni
Aerospace Science and Technology Department
Politecnico di Milano
Ph. (+39) 02 2399 8035



More information about the MBDyn-users mailing list