Dear expert users,
I am having a system of oscillating dimers, where I change the dimer’s bond length stochastically. There was no straightforward way to do so, as it included a variable from the previous time. Therefore, I achieved this using python variable and fix adapt. I am pasting below the snippet from my script for your reference.
variable randseed equal ceil(random(1423,8674437,1590))
variable job equal 0
variable rand equal 0.1*(100*dt)+(sqrt(100*dt*2*0.1)*normal(0.0,1.0,${randseed}))
label start
variable ens loop 0 50
print "-----------------------------------------------------XXX${ens}XXX-----------------------------------------------"
variable sum1 python phase1
python phase1 input 1 v_rand return v_sum1 format ff here """
gsum1=0.0
def phase1(a):
global gsum1
gsum1 = gsum1+a
return gsum1
"""
variable sum2 python phase2
python phase2 input 1 v_rand return v_sum2 format ff here """
gsum2=0.0
def phase2(a):
global gsum2
gsum2 = gsum2+a
return gsum2
"""
...
...
...
#and so on "n" python variables for "n" number of dimers with "n" bonds
...
...
#I invoke python varaibale via fix adapt written in "myadapt.txt"
label bonds
variable bondN loop 1 ${ndimers}
set mol ${bondN} bond ${bondN}
variable bond${bondN} equal 1.5+0.5*sin(v_sum${bondN})
next bondN
jump SELF bonds
include "myadapt.txt"
# "myadapt.txt" has following instantiation
fix bondadjust all adapt 1956 &
bond harmonic r0 1 v_bond1 &
bond harmonic r0 2 v_bond2 &
bond harmonic r0 3 v_bond3 &
bond harmonic r0 4 v_bond4 &
bond harmonic r0 5 v_bond5 &
bond harmonic r0 6 v_bond6 &
bond harmonic r0 7 v_bond7 &
bond harmonic r0 8 v_bond8 &
...
...
...
Simulation runs fine, and I could see fluctuations in my dimer’s bond length.
But, the difference appears in my simulation for similar simulation setting but if I replace my single instance of “fix adapt” with the following code of “n” fix adapt instances:
label bonds
variable bondN loop 1 ${ndimers}
set mol ${bondN} bond ${bondN}
variable bond${bondN} equal 1.5+0.5*sin(v_sum${bondN})
fix adapt${bondN} gM adapt 100 bond harmonic r0 ${bondN} v_bond${bondN}
next bondN
jump SELF bonds
I could not find a reason for such a behaviour, where I have similar python variables but they behave differently when invoked via a single fix adapt insatnce, versus invoking via “n” different fix adapt instances.