forked from cmc-ucl/MAOA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FHIaimsVib.py
133 lines (112 loc) · 5.11 KB
/
FHIaimsVib.py
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
from AppOutputExtractor.OutputExtractor import BaseExtractor
from AppOutputExtractor.FHIaims.FHIaimsMolecule import molecule as fmol
from AppOutputExtractor.FHIaims.FHIaimsMolecule import calculate_rmsd_molecules
from AppOutputExtractor.FHIaims.FHIaimsOutputExtractor import extractor
from ShellCommand import shellcommand
import ParsingSupport
import os
import shutil
import string,json
class aimsvibcalc(BaseExtractor):
def __init__(self, app_version='22', tag=None):
'''
'''
self.extractor = extractor()
app_output = './aims.out'
self.extractor.set_output_filepath(app_output)
self.species = self.extractor.get_species
#print(self.species)
self.ucl_id = 'uccatka'
self.job_time = '2:00:00'
#self.job_name = 'test'
self.memory = '2'
self.cpu_core = '40' # for Young 40 core = 1 node
self.payment = 'Gold'
self.budgets = 'UCL_chemM_Woodley'
self.path_binary = '/home/uccatka/software/fhi-aims.221103/build/aims.221103.scalapack.mpi.x'
self.vib_path_binary = '/home/uccatka/software/fhi-aims.221103/build/src/vibrations/numerical_vibrations.pl'
self.path_fhiaims_species = '/home/uccatka/software/fhi-aims.221103/species_defaults/defaults_2020/light'
self.step_size = 0.05
super().__init__(app='FHIaims',version=app_version)
# set app output patterns
module_path = os.path.dirname(os.path.abspath(__file__)) + '/OutputPattern' # getting this module path, '__file__'
self.patterns = self.load_patterns(module_path)
# memo
self.tag = tag
# shellcommand obj
self.shell = shellcommand()
return None
def make_job_submit(self, job_name, loc='./vibration', step_size='0.0025'):
''' Write 'submit.sh' job script for SGE system '''
path = os.path.join(loc, 'submit.sh')
with open(path, 'a') as f:
f.write("#!/bin/bash -l\n")
f.write("\n")
f.write("#$ -S /bin/bash\n")
f.write(f"#$ -l h_rt={self.job_time}\n")
f.write(f"#$ -l mem={self.memory}G\n")
f.write(f"#$ -N {job_name}\n")
f.write(f"#$ -pe mpi {self.cpu_core}\n")
f.write("#$ -cwd\n")
f.write("\n")
f.write(f"#$ -P {self.payment}\n")
f.write(f"#$ -A {self.budgets}\n")
f.write("\n")
f.write("#$ -m e\n")
f.write(f"#$ -M {self.ucl_id}@ucl.ac.uk\n")
f.write("\n")
f.write("module purge\n")
f.write("module load gerun\n")
f.write("module load userscripts\n")
f.write("module load gcc-libs/4.9.2\n")
f.write("module unload -f compilers mpi\n")
f.write("module load beta-modules\n")
f.write("module load gcc-libs/10.2.0\n")
f.write("module load openblas/0.3.7-serial/gnu-4.9.2\n")
f.write("module load compilers/intel/2019/update5\n")
f.write("module load mpi/intel/2018/update3/intel\n\n")
f.write(f"gerun {self.vib_path_binary} {job_name}_{step_size} {step_size} > vibres.out\n")
@property
def vib_calc_prep(self):
#shutil.copy('./control.in', './vibration')
geo_next = 'geometry.in.next_step'
geo = 'geometry.in'
vib_dir = 'vibration'
geometry_files = [x for x in os.listdir('./') if '.in' in x]
if geo_next in geometry_files:
shutil.copy(geo_next, f'{vib_dir}/{geo}')
shutil.copy('hessian.aims', vib_dir)
else:
shutil.copy(geo, vib_dir)
basis_set_files = [os.path.join(self.path_fhiaims_species, x) for x in os.listdir(self.path_fhiaims_species)]
basis_set_all = [x.split('_')[1] for x in os.listdir(self.path_fhiaims_species)]
basis_set_index = [basis_set_all.index(x) for x in basis_set_all if x in self.species]
with open(os.path.join(vib_dir, 'control.in'), 'a') as f:
f.write("xc pbesol\n")
f.write("spin none\n")
f.write("relativistic atomic_zora scalar\n")
f.write("charge 0.\n\n")
f.write("# SCF convergence\n")
f.write("occupation_type gaussian 0.01\n")
f.write("mixer pulay\n")
f.write("n_max_pulay 10\n")
f.write("charge_mix_param 0.5\n")
f.write("sc_accuracy_rho 1E-5\n")
f.write("sc_accuracy_eev 1E-3\n")
f.write("sc_accuracy_etot 1E-6\n")
f.write("sc_accuracy_forces 1E-4\n")
f.write("sc_iter_limit 1500\n\n")
for i in basis_set_index:
with open(basis_set_files[i], 'r') as ff:
lines = ff.read()
f.write(lines)
f.write('\n')
return None
if __name__ == "__main__":
vib = aimsvibcalc()
os.mkdir('vibration')
vib.vib_calc_prep
current_dir_name = os.path.basename(os.getcwd())
vib.make_job_submit(f'n{current_dir_name}')
os.chdir('vibration')
os.system('qsub submit.sh')