-
Notifications
You must be signed in to change notification settings - Fork 12
/
calc_manage.py
3279 lines (2066 loc) · 106 KB
/
calc_manage.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#Copyright Aksyonov D.A
from __future__ import division, unicode_literals, absolute_import
from operator import itemgetter
import copy, traceback, datetime, sys, os, glob, shutil, re
from itertools import product
import numpy as np
try:
# pmg config --add VASP_PSP_DIR $VASP_PSP_DIR MAPI_KEY $MAPI_KEY
from pymatgen.ext.matproj import MPRester
from pymatgen.io.vasp.inputs import Poscar
from pymatgen.io.cif import CifParser
pymatgen_flag = True
except:
print('pymatgen is not available')
pymatgen_flag = False
import header
from header import print_and_log, runBash, mpl, plt
from small_functions import is_list_like, makedir, list2string
from classes import Calculation, CalculationVasp, Description
from functions import (gb_energy_volume, element_name_inv
, get_from_server, run_on_server, push_to_server, wrapper_cp_on_server)
from inout import write_xyz, read_xyz, write_occmatrix
from picture_functions import plot_mep, fit_and_plot, plot_conv
from analysis import calc_redox, matrix_diff, fit_a
from geo import replic, image_distance, scale_cell_uniformly, scale_cell_by_matrix, remove_atoms, create_deintercalated_structure, create_antisite_defect, create_antisite_defect2, local_surrounding, find_moving_atom
from set_functions import init_default_sets
from database import push_figure_to_archive
from analysis import find_polaron, neb_analysis
printlog = print_and_log
init_default_sets()
def log_func_exec():
"""
save to history the executed form
"""
''
def write_batch_header(batch_script_filename = None,
schedule_system = None, path_to_job = None, job_name = 'SuperJob', number_cores = 1 ):
"""
self-explanatory)
path_to_job (str) - absolute path to job folder
"""
with open(batch_script_filename,'w', newline = '') as f:
if schedule_system == 'SGE':
f.write("#!/bin/tcsh \n")
f.write("#$ -M aksenov@mpie.de\n")
f.write("#$ -m be\n")
f.write("#$ -S /bin/tcsh\n")
f.write("#$ -cwd \n")
f.write("#$ -R y \n")
f.write("#$ -o "+path_to_job+" -j y\n\n")
f.write("cd "+path_to_job+"\n")
f.write("module load sge\n")
f.write("module load vasp/parallel/5.2.12\n\n")
if schedule_system == 'PBS':
f.write("#!/bin/bash \n")
f.write("#PBS -N "+job_name+"\n")
if 'walltime' in header.cluster:
f.write("#PBS -l walltime="+str(header.cluster['walltime'])+'\n')
else:
if header.WALLTIME_LIMIT: #deprecated remove
f.write("#PBS -l walltime=72:00:00 \n")
# f.write("#PBS -l nodes=1:ppn="+str(number_cores)+"\n")
if header.PBS_PROCS:
f.write("#PBS -l procs="+str(number_cores)+"\n")
else: # 1 node option
f.write("#PBS -l nodes=1:ppn="+str(number_cores)+"\n")
# f.write("#PBS -l pmem=16gb\n") #memory per processor, Skoltech
f.write("#PBS -r n\n")
f.write("#PBS -j eo\n")
f.write("#PBS -m bea\n")
# f.write("#PBS -M dimonaks@gmail.com\n")
f.write("cd $PBS_O_WORKDIR\n")
# f.write("PATH=/share/apps/vasp/bin:/home/aleksenov_d/mpi/openmpi-1.6.3/installed/bin:/usr/bin:$PATH \n")
# f.write("LD_LIBRARY_PATH=/home/aleksenov_d/lib64:$LD_LIBRARY_PATH \n")
if 'modules' in header.cluster:
f.write(header.cluster['modules']+'\n')
# f.write("module load Compilers/Intel/psxe_2015.6\n")
# f.write("module load MPI/intel/5.1.3.258/intel \n")
# f.write("module load QCh/VASP/5.4.1p1/psxe2015.6\n")
# f.write("module load ScriptLang/python/2.7\n\n")
if schedule_system == 'PBS_bsu':
f.write("#!/bin/bash \n")
f.write("#PBS -N "+job_name+"\n")
if header.WALLTIME_LIMIT:
f.write("#PBS -l walltime=72:00:00 \n")
# f.write("#PBS -l nodes=1:ppn="+str(number_cores)+"\n")
if header.PBS_PROCS:
f.write("#PBS -l nodes=node07:ppn="+str(number_cores)+"\n")
else: # 1 node option
f.write("#PBS -l nodes=node07:ppn="+str(number_cores)+"\n")
# f.write("#PBS -l pmem=16gb\n") #memory per processor, Skoltech
f.write("#PBS -r n\n")
f.write("#PBS -j eo\n")
f.write("#PBS -m bea\n")
f.write("#PBS -M boev.anton.olegovich@gmail.com\n")
f.write("cd $PBS_O_WORKDIR\n")
f.write("echo $LD_LIBRARY_PATH \n")
if schedule_system == 'SLURM':
if '~' in path_to_job:
print_and_log('Error! For slurm std err and out you need full paths')
f.write("#!/bin/bash \n")
f.write("#SBATCH -J "+job_name+"\n")
f.write("#SBATCH -t 250:00:00 \n")
f.write("#SBATCH -N 1\n")
f.write("#SBATCH -n "+str(number_cores)+"\n")
f.write("#SBATCH -o "+path_to_job+"sbatch.out\n")
f.write("#SBATCH -e "+path_to_job+"sbatch.err\n")
f.write("#SBATCH --mem-per-cpu=7675\n")
# f.write("#SBATCH -I other=avx\n") # AVX2 instructions for new node to improve speed by 18%
# f.write("#SBATCH --nodelist=node-amg03\n")
if header.siman_run: #only for me
if header.EXCLUDE_NODES:
f.write("#SBATCH --exclude=node-amg13\n")
# f.write("#SBATCH --mail-user=d.aksenov@skoltech.ru\n")
# f.write("#SBATCH --mail-type=END\n")
f.write("cd "+path_to_job+"\n")
f.write("export OMP_NUM_THREADS=1\n")
f.write("module add prun/1.0\n")
f.write("module add intel/16.0.2.181\n")
f.write("module add impi/5.1.3.181\n")
# if header.siman_run: #only for me
f.write("export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/aksenov/tools/lib64:/home/aksenov/tools/atlas\n")
f.write("export PATH=$PATH:/home/aksenov/tools\n")
f.write("touch RUNNING\n")
return
def clean_history_file(history_list):
seen = set()
seen_add = seen.add
return [x for x in history_list if not (x in seen or seen_add(x))]
def prepare_run():
"""
INPUT:
schedule_system - type of job scheduling system:'PBS', 'SGE', 'SLURM'
"""
schedule_system = header.schedule_system
with open('run','w', newline = '') as f:
if schedule_system == 'SGE':
f.write("#!/bin/tcsh\n")
f.write("module load sge\n")
f.write("module load vasp/parallel/5.2.12\n")
elif schedule_system in ('PBS', 'PBS_bsu' 'SLURM'):
f.write("#!/bin/bash\n")
else:
''
# print_and_log('Please provide schedule_system!')
# raise RuntimeError
# f.close()
return
def complete_run(close_run = True):
if close_run:
with open('run','a', newline = '') as f:
if header.schedule_system in ["PBS", 'PBS_bsu']:
f.write("qstat\n")
f.write("sleep 2\n")
elif header.schedule_system == "SLURM":
f.write("squeue\n")
f.write("mv run last_run\n")
if header.copy_to_cluster_flag:
push_to_server('run', header.cluster_home, header.cluster_address)
run_on_server('chmod +x run', header.cluster_address)
printlog('run sent')
return
def create_additional(struct_des):
"""
Automatically make objects in struct_des
with .f and .fvac index
"""
for key in copy.deepcopy(struct_des):
if 'auto-created' in struct_des[key].des: continue
new = copy.deepcopy(struct_des[key])
new.des+=' fitted; des auto-created;'
struct_des[key+'.f'] = new
new = copy.deepcopy(struct_des[key])
new.des+=' fitted and relaxed; des auto-created;'
struct_des[key+'.fr'] = new
new = copy.deepcopy(struct_des[key])
new.des+=' with vacancy; des auto-created;'
struct_des[key+'.fvac'] = new
new = copy.deepcopy(struct_des[key])
new.des+=' with vacancy; des auto-created;'
struct_des[key+'.r'] = new
return struct_des
def add_des(struct_des, it, it_folder, des = 'Lazy author has not provided description for me :( ', override = False):
"""
Function adds description to struct_des dictionary;
###INPUT:
- struct_des (dict) - dict from project database
* it (str) - name of calculation
* it_folder (str) - path and name of folder used for calculation in current project both on local and remote machines
* des (str) - description of calculation
* override (bool) - allows to override existing field
###RETURN:
None
"""
if it not in struct_des or override:
struct_des[it] = Description(it_folder, des)
# hstring = ("%s #on %s"% (traceback.extract_stack(None, 2)[0][3], datetime.date.today() ) )
hstring = 'add_des("{:s}", "{:s}", "{:s}") #on {:})'.format(it, it_folder, des, datetime.date.today())
try:
if hstring != header.history[-1]: header.history.append( hstring )
except:
header.history.append( hstring )
print_and_log("New structure name "+it+ " added to struct_des dict"+"\n")
else:
print_and_log("Attention! "+it+' already exist in struct_des, skipping; use override = True if you really need it; or first remove using manually_remove_from_struct_des()')
# raise RuntimeError
return
def update_des(struct_des, des_list):
"""
Manuall adding of information to struct_des dictionary
###INPUT:
- struct_des (dict) - dict from project database
- des_list (list of tuples) - list of new calculations to be added to database
###RETURN:
- struct_des (dict)
"""
for des in des_list:
if des[0] not in struct_des:
add_des(struct_des, *des)
return create_additional(struct_des)
def cif2poscar(cif_file, poscar_file):
if pymatgen_flag:
parser = CifParser(cif_file)
s = parser.get_structures(primitive = True)[0]
si = s._sites[0]
# print(dir(si))
# print(si.specie)
# from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
# sf = SpacegroupAnalyzer(s, ) #
# sc = sf.get_conventional_standard_structure() # magmom are set to None
# print(sc)
Poscar(s).write_file(poscar_file)
printlog('File',poscar_file, 'created.')
elif header.CIF2CELL: #using cif2cell for conversion
print_and_log( runBash("cif2cell "+cif_file+" -p vasp -o "+poscar_file) )
printlog('File',poscar_file, 'created.')
#check
if not os.path.exists(poscar_file):
print_and_log("Error! cif2cell failed")
else:
printlog('Error! Support of cif files requires pymatgen or cif2cell; install it with "pip install pymatgen" or provide POSCAR or Abinit input file')
def determine_file_format(input_geo_file):
supported_file_formats = {'abinit':'.geo', 'vasp':'POSCAR', 'cif':'.cif', 'xyz':'.xyz'} #format name:format specifier
if 'POSCAR' in input_geo_file or 'CONTCAR' in input_geo_file:
input_geo_format = 'vasp'
elif '.cif' in input_geo_file:
input_geo_format = 'cif'
elif '.geo' in input_geo_file:
input_geo_format = 'abinit'
elif '.xyz' in input_geo_file:
input_geo_format = 'xyz'
else:
printlog("Attention! File format of",input_geo_file ,"is unknown, should be from ", supported_file_formats, 'skipping')
input_geo_format = None
return input_geo_format
def get_file_by_version(geofilelist, version):
"""
Find file with needed version from filelist according to certain rules
"""
curv = None
matched_files = []
# print(geofilelist)
for input_geofile in geofilelist:
input_geofile = os.path.normpath(input_geofile)
input_geo_format = determine_file_format(input_geofile)
# sys.exit()
printlog('For file', input_geofile, input_geo_format, ' format was detected', imp = 'n')
if input_geo_format in ['abinit',]: #version determined from token
# curv = int( runBash("grep version "+str(input_geofile) ).split()[1] )
with open(input_geofile, 'r') as f:
for line in f:
if 'version' in line:
curv = int(line.split()[1])
elif input_geo_format == 'vasp': #from filename
if '-' in input_geofile:
curv = int(input_geofile.split('-')[-1] ) #!Applied only for phonopy POSCAR-n naming convention
# try:
# curv = int(input_geofile.split('-')[-1] ) #!Applied only for phonopy POSCAR-n naming convention
# except:
# printlog('Error! Could not determine version of poscar file')
elif input_geo_format == 'cif': #from filename
printlog('I found cif file ', input_geofile)
try:
curv = int(os.path.basename(input_geofile).split('.')[0] )
except:
curv = None
printlog('Failed to determine version, skipping')
else:
curv = None
if curv == version:
printlog('match', curv, version)
matched_files.append(input_geofile)
if len(matched_files) > 1:
printlog('get_file_by_version(): Error! Several files have same versions:', matched_files)
elif len(matched_files) == 0:
input_geofile = None
else:
input_geofile = matched_files[0]
return input_geofile
def smart_structure_read(filename = None, curver = 1, calcul = None, input_folder = None, input_geo_format = None, input_geo_file = None, ):
"""
Wrapper for reading geometry files
calcul (Calculation()) - object to which the path and version read
curver (int) - version of file to be read
input_geo_file or filename (str) - explicitly provided input file, has higher priority
input_folder (str) - folder with several input files, the names doesnot matter only versions
input_geo_format (str) - explicitly provided format of input file
returns Structure()
"""
search_templates = {'abinit':'*.geo*', 'vasp':'*POSCAR*', 'cif':'*.cif'}
if filename:
input_geo_file = filename
if input_geo_file:
printlog("You provided the following geo file explicitly ", input_geo_file,
'; Version of file does not matter, I use *curver*=',curver, 'as a new version' )
elif input_folder:
print_and_log("I am searching for geofiles in folder "+input_folder+"\n" )
if input_geo_format:
geofilelist = glob.glob(input_folder+'/'+search_templates[input_geo_format]) #Find input_geofile of specific format
else:
geofilelist = glob.glob(input_folder+'/*')
geofilelist = [file for file in geofilelist if os.path.basename(file)[0] != '.' ] #skip hidden files
printlog('List of files:', geofilelist)
input_geo_file = get_file_by_version(geofilelist, curver)
# sys.exit()
printlog('The result of getting by version', input_geo_file)
if input_geo_file:
printlog('File ', input_geo_file, 'was found')
else:
printlog('Error! No input file with version ', curver, 'was found in', input_folder)
else:
printlog('Neither *input_geo_file* nor *input_folder* were provided')
input_geo_format = determine_file_format(input_geo_file)
printlog(input_geo_format,' format is detected')
if calcul:
cl = calcul
else:
cl = CalculationVasp()
if input_geo_format == 'abinit':
cl.read_geometry(input_geo_file)
elif input_geo_format == 'vasp':
cl.read_poscar(input_geo_file, version = curver)
elif input_geo_format == 'cif':
cif2poscar(input_geo_file, input_geo_file.replace('.cif', '.POSCAR'))
input_geo_file = input_geo_file.replace('.cif', '.POSCAR')
cl.read_poscar(input_geo_file)
elif input_geo_format == 'xyz':
#version = 1
st = cl.init
st = read_xyz(st, input_geo_file)
cl.init = st
cl.path["input_geo"] = input_geo_file
cl.version = 1
else:
print_and_log("Error! smart_structure_read(): File format", input_geo_format, "is unknown")
if cl.path["input_geo"] == None:
printlog("Error! Input file was not properly read for some reason")
return cl.init
def name_mod_supercell(ortho = None, mul_matrix = None):
if ortho:
if len(set(ortho))==1:
mod = '.s'+str(ortho[0])
else:
mod = '.s'+list2string(ortho).replace(' ','')
else:
mod = '.s'+str(mul_matrix[0][0])+str(mul_matrix[1][1])+str(mul_matrix[2][2])
return mod
def inherit_ngkpt(it_to, it_from, inputset):
"""
inherit ngkpt from it_from to it_to
"""
# print(it_to, it_from)
struct_des = header.struct_des
if it_to and it_from and it_from in struct_des:
ks = inputset.vasp_params['KSPACING']
for it in [it_to, it_from]: #just create ngkpt_dict_for_kspacings property
if not hasattr(struct_des[it], 'ngkpt_dict_for_kspacings' ):
struct_des[it].ngkpt_dict_for_kspacings = {}
k_dict1 = struct_des[it_from].ngkpt_dict_for_kspacings
k_dict2 = struct_des[it_to].ngkpt_dict_for_kspacings
if ks in k_dict1:
k_dict2[ks] = k_dict1[ks]
printlog('inherit_ngkpt(): the k-grid from', it_from, 'was inherited to', it_to, imp = 'Y')
else:
printlog('no ngkpt for k-spacing', ks, 'in ngkpt_dict_for_kspacings of', it_from, 'ngkpt will determined from inputset k-spacing', imp = 'Y')
return
def choose_cluster(cluster_name, cluster_home, corenum):
"""
*cluster_name* should be in header.project_conf.CLUSTERS dict
"""
if cluster_name in header.CLUSTERS:
printlog('We use', cluster_name,'cluster')
clust = header.CLUSTERS[cluster_name]
else:
printlog('Attention!, cluster', cluster_name, 'is not found, using default', header.DEFAULT_CLUSTER)
clust = header.CLUSTERS[header.DEFAULT_CLUSTER]
header.cluster = clust # dict
header.cluster_address = clust['address']
header.CLUSTER_ADDRESS = clust['address']
if cluster_home is None:
header.cluster_home = clust['homepath']
else:
header.cluster_home = cluster_home
if 'sshpass' in clust and clust['sshpass']:
printlog('setting sshpass to True', imp = '')
# sys.exit()
header.sshpass = True
else:
header.sshpass = None
#Determine cluster home using ssh
# run_on_server('touch ~/.hushlogin', header.cluster_address)
if header.copy_to_cluster_flag:
header.cluster_home = run_on_server('pwd', header.cluster_address)
else:
header.cluster_home = ''
printlog('The home folder on cluster is ', header.cluster_home)
header.CLUSTER_PYTHONPATH = clust['pythonpath']
# header.SCHEDULE_SYSTEM = clust['schedule']
header.schedule_system = clust['schedule']
# header.CORENUM = clust['corenum']
if corenum:
header.corenum = corenum
else:
header.corenum = clust['corenum']
header.project_path_cluster = header.cluster_home +'/'+ header.PATH2PROJECT
try:
header.vasp_command = clust['vasp_com']
except:
header.vasp_command = None
# print(clust)
return
def add_loop(it, setlist, verlist, calc = None, varset = None,
up = 'up2', inherit_option = None, id_from = None, inherit_args = None, confdic = None,
i_atom_to_remove = None,
coord = 'direct', savefile = 'oc', show = '', comment = '',
input_geo_format = None, ifolder = None, input_geo_file = None, input_st = None,
corenum = None,
calc_method = None, u_ramping_region = None, it_folder = None,
mat_proj_cell = '',
mat_proj_id = None,
cee_args = None,
ise_new = None, it_suffix = None,
scale_region = None, n_scale_images = 7,
n_neb_images = None, occ_atom_coressp = None,ortho = None,
mul_matrix = None,
ngkpt = None,
cluster = None, cluster_home = None,
override = None,
ssh_object = None,
run = False, check_job = 1, params = None,
):
"""
Main subroutine for creation of calculations, saving them to database and sending to server.
Input:
- it - arbitary name for your crystal structure
- setlist (list of str or str) - names of sets with vasp parameters from *varset* dictionary
- verlist - list of versions of new calculations
- calc, varset - database dictionaries; could be provided; if not then are taken from header
- input_geo_format - format of files in input geo folder
'abinit' - the version is determined from the value inside the file
'vasp', 'cif' - the version is determined from the name of file; the names should be like POSCAR-1 for vasp files and 1.name.cif for cif
'mat_proj' - take structure from materialsproject.org; use it_folder, len(verlist) = 1
- up - string, possible values are: 'up1', 'up2', 'no_base'; if empty then test run is performed without saving and sending
'up1' - needed for normal creation of calculation and copy to server all files
'no_base': only relevant for typconv
is the same as "up1", but the base set is ommited
'up2' - update only unfinished calculations
'up3' - run only if id does not exist
- coord - type of cooridnates written in POSCAR:
'direct'
'cart'
- savefile - controls which files are saved during VASP run on server; check
'ocvdawx' - outcar, chgcar, chg, dos, AECCAR,WAVECAR, xml
- ifolder - explicit path to folder where to search for input geo file.
- input_geo_file - explicit file name of input file
- input_st - see in add_calculation()
- it_folder - section folder (sfolder) used in struct_des; here needed with input_geo_format = mat_proj
- show - only for read_results() ?.
- comment - arbitrary comment for history.
#inherit flags:
inherit_args (dict) - to pass parameters to inherit_icalc;
confdic (dicts) - additional configuration parameters to inherit_icalc in dict, used for antisites
- inherit_option (str):
- 'continue' - copy last contcar to poscar, outcar to prev.outcar and run again; on the next launch prev.outcar
will be rewritten, please improve the code to save all previous outcars
- 'inherit_xred' - if verlist is provided, xred are copied from previous version to the next
- all options available for inherit_icalc() subroutine (now only 'full' is tested)
- *id_from* - see inherit_icalc()
- ise_new (str) - name of new set for inherited calculation ('uniform_scale')
- occ_atom_coressp (dict) see inherit_icalc()
- ortho, mul_matrix - transfered to inherit_icalc
- ngkpt (list) - the list of k-points provided explicitly added to struct_des
- corenum - number of cores used for calculation; overwrites header.corenum
- calc_method - provides additional functionality:
- 'u_ramping' - realizes U ramping approach #Phys Rev B 82, 195128
- 'afm_ordering' -
- 'uniform_scale' - creates uniformly scaled copies of the provided calculations
- 'scale' - arbitrary scale according to mul_matrix
using *scale_region* and *n_scale_images* (see *scale_cell_uniformly()*)
The copies are available as versions from 1 to *n_scale_images* and
suffix .su appended to *it* name
Copies to cluster *fit* utility that finds volume corresp. to energy minimum, creates 100.POSCAR and continues run
- u_ramping_region - used with 'u_ramping'=tuple(u_start, u_end, u_step)
- cluster_home - override value of header.CLUSTERS
cee_args - arguments for taking files from cee database; see get_structure_from_cee_database
- cee_file (str) - name of file to be taken from cee database
- section (str) - CEStorage, Catalysts, ets
- run (bool) - complete the run file copy to server and run
- params (dic) - dictionary of additional parameters, please move here numerous arguments
- 'occmatrix' - explicit path to occmatrix file
- 'update_set_dic' (dict) - additional parameters to override the existing set
Comments:
!Check To create folders and add calculations add_flag should have value 'add'
TODO:
Now number of images is taken from self.set.vasp_params['IMAGES'];
In the case of generalization to other codes, set.nimages should be added and used
Make class for cluster to save all information about cluster in one object,
like schedule_system, cluster address, corenum and so on
read structure in add_loop, to add calculation provied only structure, mat_proj_st_id pass in structure
- occmatrix in params better to rename to occfile or something like this,
"""
def add_loop_prepare():
nonlocal calc, it, it_folder, verlist, setlist, varset, calc_method, inherit_args, params
if not params:
params = {}
params['show'] = show
# if header.copy_to_cluster_flag:
choose_cluster(cluster, cluster_home, corenum)
if run:
prepare_run()
if header.first_run and header.copy_to_cluster_flag:
prepare_run()
header.first_run = False
if not calc:
calc = header.calc
varset = header.varset
it = it.strip()
if it_folder:
it_folder = it_folder.strip()
if not is_list_like(verlist):
verlist = [verlist]
if not is_list_like(setlist):
setlist = [setlist]
# print(setlist)
if None in setlist:
printlog('Error! None detected in setlist:', setlist)
setlist = [s.strip() for s in setlist]
if not is_list_like(calc_method):
calc_method = [calc_method]
if inherit_args is None:
inherit_args = {}
if ifolder:
if it not in ifolder: # just to be consistent with names
print_and_log('Check ifolder !!! it is not in ifolder')
raise RuntimeError
return
def add_loop_inherit():
"""
inherit options:
full_chg - including chg file
"""
nonlocal it, setlist, id_base, it_suffix
struct_des = header.struct_des
printlog('add_loop: starting add_loop_inherit ...', imp ='n')
#inherit option
inh_opt_ngkpt = ['full', 'full_chg', 'full_nomag', 'occ', 'r1r2r3', 'remove_imp', 'replace_atoms', 'make_vacancy', 'antisite'] #inherit also ngkpt
inh_opt_other = ['supercell', 'r2r3'] # do not inherit ngkpt
# if inherit_option in inh_opt_ngkpt+inh_opt_other:
omit_inh_opt = ['inherit_xred', 'continue']
if inherit_option and inherit_option not in omit_inh_opt:
if 'id_base_st_type' in inherit_args and inherit_args['id_base_st_type'] == 'init':
iti = it+'.init'
else:
iti = it
if inherit_option == 'full':
it_new = iti+'.if'
if inherit_option == 'full_chg':
it_new = iti+'.ifc'
elif inherit_option == 'full_nomag':
it_new = iti+'.ifn'
elif inherit_option == 'occ':
#please add additional vars to control for which atoms the inheritance should take place (added)
it_new = iti+'.ifo' #full inheritence + triggering OMC from some other source
elif inherit_option == 'supercell':
mod = name_mod_supercell(ortho, mul_matrix)
it_new = iti+mod
elif 'antisite' in inherit_option:
suf = inherit_option.split('.')[-1]
it_new = iti+'.'+suf
# print (it_new)
# sys.exit()
elif inherit_option == 'make_vacancy':
it_new = iti+'.vac'
if it_suffix: # override default behaviour
it_new = it+'.'+it_suffix
it_suffix = None
if 'up' in up:
if it_folder:
section_folder = it_folder
else:
section_folder = struct_des[it].sfolder
for inputset in setlist:
for v in verlist:
id_base = (it,inputset,v)
inherit_icalc(inherit_option, it_new, v, id_base, calc, st_base = input_st, id_from = id_from, confdic = confdic,
it_folder = section_folder, occ_atom_coressp = occ_atom_coressp, i_atom_to_remove = i_atom_to_remove,
ortho = ortho, mul_matrix = mul_matrix, override =override, **inherit_args)
if inherit_option in inh_opt_ngkpt:
inherit_ngkpt(it_new, it, varset[inputset]) #
if ise_new:
print_and_log('Inherited calculation uses set', ise_new)
setlist = [ise_new,]
else:
print_and_log('Inherited calculation uses the same sets', setlist)
it = it_new
return
def add_loop_scale():
struct_des = header.struct_des
nonlocal it, verlist, setlist, input_st,it_suffix
u_scale_flag = False
fitted_v100_id = None
if calc_method and ('scale' in calc_method or 'uniform_scale' in calc_method):
# print('sdfsdf')
if 'uniform_scale' in calc_method:
u_scale_flag = True
it_new = it+'.su' #scale uniformly
else:
it_new = it+'.sm' #scale according to mul_matrix