-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.py
More file actions
75 lines (66 loc) · 2.89 KB
/
Main.py
File metadata and controls
75 lines (66 loc) · 2.89 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#Class to run the simulations
from InputData import *
from LatticeHandler import *
from Lattice import *
from Result import *
from ResultsList import *
import numpy as np
import os
#Creating result list to store the result of the simulation
resultList=ResultsList()
#Number of steps to get record system state
meanSteps=100
#Number of measurements to do the mean
valuesForMean=100
#Simulation temperatures
iniT=190 #Initial temperature
finT=300 #Final temperature
tempIncrement=10 #Increment of temperature in each simulation
#simulation steps
mcSteps=10000000 #MonteCarlo steps during measurement phase
initialEq=30000000 #Steps to reach the equilibrium before the simulation
Eq=10000000 #Steps to reach equilibrium after changing the temperature of the system
#Pressure (S.I.)
P=1e5
#Free volumes (Random units)
fbv=0.2 #Free volume of + state
fsv=1.0 #Free volume of - state
#Volumes (S.I)
Vb=4.151444703e-29 #V+
Vs=3.321078553e-29 #V-
#Energies (S.I.)
Eb=-1.660577881e-21 #E+
Es=0 #E-
#Lattice length (Unit cells)
l=50
#Removing probability data file to create a new one
if os.path.isfile("probabilities"):
os.remove("probabilities")
inputdata=InputData(l, iniT, mcSteps, Eq,
Vb, Vs, fbv, fsv, Eb, Es, P) #Creating Inputdata object containing the initial simulation parameters
lattice=Lattice(inputdata) #Creating Lattice object using the simulation parameters contained in the Inputdata object
#Initial equilibrium steps
print("Initial thermalization")
for i in range(0, initialEq):
if math.fmod(i/initialEq*100,1.0)==0: #Checking progress of the equilibrium steps
print(str(i/(initialEq)*100)+"%")
LatticeHandler().changeVol(lattice, lattice.getInputData()) #Attempting to change state of one cell
#Removing histogram data file to create a new one
if os.path.isfile("Neighbor_Histogram"):
os.remove("Neighbor_Histogram")
#Repeating simulation for the specified temperatures
for T in range(iniT, finT+tempIncrement, tempIncrement):
#Creation of the inputData with the desired parameters(L, T, MCs, Therm, Vb, Vs, FVb, FVs, Eb, Es, P)
print(T)
#Changing temperature of the simulation
lattice.changeInputData(T, P) #Changing simulation parameters
print("Thermalization")
#Setting new thermalization for new parameters
for i in range(0, inputdata.getEq()):
if math.fmod(i/Eq*100,1.0)==0: #Checking progress of the equilibrium steps
print(str(i/(Eq)*100)+"%")
LatticeHandler().changeVol(lattice, lattice.getInputData()) #Attempting to change state of one cell
lattice.resetHistogram()
#Getting measurements of the evolution of volume, intermolecular energy and enthalpy
measurements=LatticeHandler().getSystemEvolution(lattice, lattice.getInputData(), meanSteps)
lattice.saveHistogram() #Saving neighbor histogram