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

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


Dear Reinhard,

Thanks, had come across this this, but I was thinking that the string 
drive doesn't take  any inputs in my case, but of course,  I see now 
that it always can take Time as an input, even if I don't use it.

Your showing the example in this way is very helpful, thanks!

Richard


On 17/09/18 15:43, Resch, Reinhard [NGAA-FUE] wrote:
> Dear Mr Crozier,
> 
> You could use the model::drive function. Here an example:
> 
> set: integer vardist = 1;
> set: integer varxdist = 2;
> set: integer varydist = 3;
> set: integer varzdist = 4;
> 
> drive caller: vardist, string, "model::distance(n_base01,n_body01)";
> 
> drive caller: varxdist, string, "model::xdistance(n_base01,n_body01)";
> drive caller: varydist, string, "model::ydistance(n_base01,n_body01)";
> drive caller: varzdist, string, "model::zdistance(n_base01,n_body01)";
> 
>         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, "2.0*model::drive(varxdist, Time)/model::drive(vardist, Time)",
> 		string, "2.0*model::drive(varydist, Time)/model::drive(vardist, Time)",
> 		string, "2.0*model::drive(varzdist, Time)/model::drive(vardist, Time)";
> 
> Mit freundlichen Grüßen / Best regards
>   
> Reinhard Resch
> 
> -----Ursprüngliche Nachricht-----
> Von: MBDyn-users [mailto:mbdyn-users-bounces at mbdyn.org] Im Auftrag von Richard Crozier
> Gesendet: Montag, 17. September 2018 12:27
> An: mbdyn-users at mbdyn.org
> Betreff: [MBDyn-users] Standard way to have a dynamically updated set of formulas
> 
> 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