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

Richard Crozier r.crozier at ed.ac.uk
Mon Sep 17 16:56:58 CEST 2018


Thanks for the reply, another list user suggested using the model::drive 
function to do the same thing essentiall, but make it less verbose, and 
gives me something very close to what I suggested.

Richard

On 17/09/18 12:46, 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