@@ -726,8 +726,8 @@ def make_scale_ABACUS(jdata):
726
726
727
727
728
728
def pert_scaled (jdata ):
729
- if "init_fp_style" not in jdata :
730
- jdata ["init_fp_style" ] = " VASP"
729
+ ### Extract data from jdata
730
+ jdata ["init_fp_style" ] = jdata . get ( "init_fp_style" , " VASP")
731
731
out_dir = jdata ["out_dir" ]
732
732
scale = jdata ["scale" ]
733
733
pert_box = jdata ["pert_box" ]
@@ -744,6 +744,7 @@ def pert_scaled(jdata):
744
744
if "from_poscar" in jdata :
745
745
from_poscar = jdata ["from_poscar" ]
746
746
747
+ ### Get the current working directory and the system path
747
748
cwd = os .getcwd ()
748
749
path_sp = os .path .join (out_dir , global_dirname_03 )
749
750
assert os .path .isdir (path_sp )
@@ -752,35 +753,31 @@ def pert_scaled(jdata):
752
753
sys_pe .sort ()
753
754
os .chdir (cwd )
754
755
755
- pert_cmd = os .path .dirname (__file__ )
756
- pert_cmd = os .path .join (pert_cmd , "tools" )
757
- pert_cmd = os .path .join (pert_cmd , "create_random_disturb.py" )
756
+ ### Construct the perturbation command
757
+ python_exec = os .path .join (os .path .dirname (__file__ ), "tools" , "create_random_disturb.py" )
758
758
fp_style = "vasp"
759
759
poscar_name = "POSCAR"
760
760
if jdata ["init_fp_style" ] == "ABACUS" :
761
761
fp_style = "abacus"
762
762
poscar_name = "STRU"
763
- pert_cmd = (
764
- sys .executable
765
- + " "
766
- + pert_cmd
767
- + " -etmax %f -ofmt %s %s %d %f > /dev/null"
768
- % (pert_box , fp_style , poscar_name , pert_numb , pert_atom )
769
- )
763
+
764
+ pert_cmd = sys .executable + f" { python_exec } -etmax { pert_box } -ofmt { fp_style } { poscar_name } { pert_numb } { pert_atom } > /dev/null"
765
+
766
+ ### Loop over each system and scale
770
767
for ii in sys_pe :
771
768
for jj in scale :
772
- path_work = path_sp
773
- path_work = os .path .join (path_work , ii )
774
- path_work = os .path .join (path_work , f"scale-{ jj :.3f} " )
769
+ path_work = os .path .join (path_sp , ii , f"scale-{ jj :.3f} " )
775
770
assert os .path .isdir (path_work )
776
771
os .chdir (path_work )
777
772
sp .check_call (pert_cmd , shell = True )
773
+
774
+ ### Loop over each perturbation
778
775
for kk in range (pert_numb ):
779
776
if fp_style == "vasp" :
780
- pos_in = "POSCAR%d .vasp" % ( kk + 1 )
777
+ pos_in = f "POSCAR{ kk } .vasp"
781
778
elif fp_style == "abacus" :
782
- pos_in = "STRU%d .abacus" % ( kk + 1 )
783
- dir_out = "% 06d" % ( kk + 1 )
779
+ pos_in = f "STRU{ kk } .abacus"
780
+ dir_out = f" { kk : 06d} "
784
781
create_path (dir_out )
785
782
if fp_style == "vasp" :
786
783
pos_out = os .path .join (dir_out , "POSCAR" )
@@ -805,35 +802,7 @@ def pert_scaled(jdata):
805
802
else :
806
803
shutil .copy2 (pos_in , pos_out )
807
804
os .remove (pos_in )
808
- kk = - 1
809
- if fp_style == "vasp" :
810
- pos_in = "POSCAR"
811
- elif fp_style == "abacus" :
812
- pos_in = "STRU"
813
- dir_out = "%06d" % (kk + 1 )
814
- create_path (dir_out )
815
- if fp_style == "vasp" :
816
- pos_out = os .path .join (dir_out , "POSCAR" )
817
- elif fp_style == "abacus" :
818
- pos_out = os .path .join (dir_out , "STRU" )
819
- if not from_poscar :
820
- if fp_style == "vasp" :
821
- poscar_shuffle (pos_in , pos_out )
822
- elif fp_style == "abacus" :
823
- stru_in = get_abacus_STRU (pos_in )
824
- stru_out = shuffle_stru_data (stru_in )
825
- with open (pos_out , "w" ) as fp :
826
- fp .write (
827
- make_abacus_scf_stru (
828
- stru_out ,
829
- pp_file ,
830
- orb_file_names ,
831
- dpks_descriptor_name ,
832
- type_map = jdata ["elements" ],
833
- )
834
- )
835
- else :
836
- shutil .copy2 (pos_in , pos_out )
805
+
837
806
os .chdir (cwd )
838
807
839
808
0 commit comments