change a variable through run

Submitted by JoshuaP on Fri, 12/19/2014 - 12:10

hi,

if I use the command

variable zero equal 0
variable an equal -0.1
fix movement all move/mesh mesh mole linear/variable v_zero v_zero v_an
run 10000

and try to change now the vertical velocity to

variable an equal -10

the velocity to the mesh is set positiv doesnt mind if I set it to 10 or -10.
To test it just create a mesh and do

variable zero equal 0
variable an equal -0.1
fix movement all move/mesh mesh mole linear/variable v_zero v_zero v_an
run 10000
variable an equal -10

Would be very thankfull for a quick answer.

Regards

JoshuaP | Wed, 01/07/2015 - 12:58

I can just switch the velocity by unfixing the movement and create a new movement with a new variable...
is there no way to change the variable?
I tried this:

variable f equal 0
variable an equal $f
fix movement all move/mesh mesh mole linear/variable v_zero v_zero v_an
run 10000
variable f equal -1

but this doesnt work.
I mean the variable changes but the fix move/mesh can't registrate this.

regards
Joshua

richti83's picture

richti83 | Wed, 01/07/2015 - 19:55

Hi Joshua,

I can reproduce this issue, but it only appears when another variable is definded between the changes in variable 'an'.
The reason is that the internal variable id is never updated after it was first instanziated in the constructor.
To fix this open src/mesh_mover.cpp
in line 188 add:

// evaluate variable
myvar1_ = input->variable->find(var1str_);
myvar2_ = input->variable->find(var2str_);
myvar3_ = input->variable->find(var3str_);

in front of

vel_[0] = input->variable->compute_equal(myvar1_);
vel_[1] = input->variable->compute_equal(myvar2_);
vel_[2] = input->variable->compute_equal(myvar3_);

and for rotate/variable in line 434

// re-evaluation of omega (global,private)
myvar1_ = input->variable->find(var1str_);

This fixed it for me.

Best,
Christian.

I'm not an associate of DCS GmbH and not a core developer of LIGGGHTS®
ResearchGate | Contact

JoshuaP | Thu, 01/08/2015 - 16:42

Many Thanks Christian.
I fixed it with the additional part from you in the "initial integrate" of the move and it works well.

Regards Joshua

ckloss's picture

ckloss | Wed, 01/14/2015 - 18:35

Hey guys,

thanks for the information on the bug! It will be fixed with the next release

Best wishes
Christoph