Hello everybody,
Dose anybody know how can we restore a value defined by variable in a simulation (it is scaler defined after the simulation results) and then use the value in a new simulation? I use write_restart to save the simulation but it seems that the value defined by variables can not be saved. I can manually input the variable in the new script but it is time consuming. Any good ideas?
Jeremy
richti83 | Fri, 10/18/2013 - 12:01
(not tested, but..
.. you could write your variable into a fix property/global
Information about this fix is written to binary restart files if you set restartvalue to 'yes'.
I do this to replace some particles (but in one script)
Here is a codesnipped for an idea about the process:
variable radius equal c_rad[$i] #only replace particles bigger than D=0.076
if "${radius} > 0.038" then &
"variable x equal x[$i]" &
"variable y equal y[$i]" &
"variable z equal z[$i]" &
"variable D equal 2*${radius}" &
"fix coordX$c all property/global coordX$c scalar $x yes no no" &
"fix coordY$c all property/global coordY$c scalar $y yes no no" &
"fix coordZ$c all property/global coordZ$c scalar $z yes no no" &
"fix coordD$c all property/global coordD$c scalar $D yes no no" &
"group remove id == ${id}" &
"variable c equal $c+1"
(I need to do this because I can not use variable $x$i in the 2nd stage of my script)
and in the reloaded script
variable D equal f_coordD$i
variable dx equal f_coordX$i
variable dy equal f_coordY$i
variable dz equal f_coordZ$i-$D/2
I'm not sure if property/global stores restart values or if only property/atom does.
If it does not: maybe you can glue your script together with
jump secondscript.lmp
at the end of frist script to keep the property/atom alive.
Happy Scripting
J_Wang | Sun, 10/20/2013 - 17:33
Good idea
Good idea. As I'm using an earlier version, it is not possible to wirte property/global to binary file. But I can assign the scalar to property/atom first and then after save and restart I use the compute reduce command to reduce the peratom property to a single scalar and then define it back to the variable. It works fine now. Thanks for your reply.
Jeremy
J_Wang | Sun, 10/20/2013 - 17:32
Good idea
Good idea. As I'm using an earlier version, it is not possible to wirte property/global to binary file. But I can assign the scalar to property/atom first and then after save and restart I use the compute reduce command to reduce the peratom property to a single scalar and then define it back to the variable. It works fine now. Thanks for your reply.
Jeremy