Skip to content

Simulated Annealing

jspngler edited this page Aug 8, 2024 · 1 revision

In the analysis directory, there are three programs that are helpful: changeTime.cpp, changeTwoBodyConst.cpp, and lsPotentials.cpp. Compile them normally (if they weren't compiled by make):

g++ -O3 changeTime.cpp -o ~/bin/changeTime
g++ -O3 lsPotentials.cpp -o ~/bin/lsPotentials
g++ -O3 changeTwoBodyConst.cpp -o ~/bin/changeTwoBodyConst

Then, you can use lsPotentials to list the non-bonded (two-body) constants:

lsPotentials 100Mono_-1.8Umin
Umin 4 4
0       0       0       0
0       0       -1.8    0
0       -1.8    0       0
0       0       0       -6
Umax 4 4
100     100     100     100
100     100     100     100
100     100     100     100
100     100     100     200

In this case, there are 4 types, and most of them are 0 U_min and 100 U_max constants. Two exceptions are between types 3-3, tail interactions with -6 U_min and 200 U_max, and 1-2, monomer and lipid interactions with -1.8 U_min and 100 U_max. To change these constants, just use changeTwoBodyConst:

changeTwoBodyConst name typeA typeB Umin Umax

Where name is the simulation name, typeA/typeB are the numeric types like 1 or 2, and Umin/Umax are the constants to set the interaction. Something like:

changeTwoBodyConst 100Mono_-1.6Umin 1 2 -1.6 100

will change the two-Body interaction constants between types 1 and 2 to:

lsPotentials 100Mono_-1.6Umin
Umin 4 4
0       0       0       0
0       0       -1.6    0
0       -1.6    0       0
0       0       0       -6
Umax 4 4
100     100     100     100
100     100     100     100
100     100     100     100
100     100     100     200

Changing the initial and final times (in dimensionless system units, tau) is simply:

changeTime name timeInitial timeFinal

To anneal the value, you can make a bash for loop like:

Umax=100.0
Umin=0.0
last="100Mono_-${Umin}Umin"
for i in {1..20}
do
        #Using 10 as the divisor to get decimal values
        Umin=$(echo $i | awk '{print $1/10}')
        #Get the new name
        name="100Mono_-${Umin}Umin"
        #Copy the last system as the basis for the new system
        cp $last $name
        #Update parameters
        changeTime $name 0 10000
        changeTwoBodyConst $name 1 2 -$Umin $Umax
        MD $name
        last=$name
done

This should create 20 systems changing the U_min value by -0.1 steps from -0.1 to -2.0.

Clone this wiki locally