File: simulated_annealing.py

package info (click to toggle)
ball 1.5.0%2Bgit20180813.37fc53c-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 239,924 kB
  • sloc: cpp: 326,149; ansic: 4,208; python: 2,303; yacc: 1,778; lex: 1,099; xml: 958; sh: 322; javascript: 164; makefile: 88
file content (56 lines) | stat: -rw-r--r-- 1,492 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#   example script for simulated annealing
#   output heated structures as Hinfile
#   one system has to be loaded before calling the script
if getSystems() == []:
  print "No System loaded! aborting..:"

system = getSystem(0)

ff = getMolecularStructure().getForceField()
ff.setup(system)
ssm = SnapShotManager()
mds = CanonicalMD()
mds.setup(ff, ssm)
mds.setTimeStep(0.001)
mds.setReferenceTemperature(0)
	
time = 0
starttemperature = 0
endtemperature = 600
temperature = 0
counter = 0
step = 1.
limit = 600
heatlimit = 1050
step = float(endtemperature - starttemperature) / float(limit)

temperature = starttemperature
for counter in range(0, limit):
	mds.simulateIterations(50)
	mds.setReferenceTemperature(temperature)
	getMainControl().update(system)
	getMainControl().processEvents(2000)
	temperature = float(step) * float(counter)

temperature = endtemperature
for counter in range(0, heatlimit):
	mds.simulateIterations(1000)
	mds.setReferenceTemperature(temperature)
	getMainControl().update(system)
	getMainControl().processEvents(2000)
	outfile = HINFile("heating1_"+str(counter)+".hin", File.MODE_OUT)
	outfile.write(system)
	outfile.close()

getMainControl().update(system)

temperature = endtemperature
for counter in range(limit, 0):
	mds.simulateIterations(50)
	mds.setReferenceTemperature(temperature)
	getMainControl().update(system)
	getMainControl().processEvents(2000)
	temperature = float(step) * float(counter)

getMainControl().update(system)
print ff.updateEnergy()