Skip to content

Commit dfe0035

Browse files
committed
fix minor bug of relax in abinit
1 parent 042f717 commit dfe0035

File tree

11 files changed

+12
-11
lines changed

11 files changed

+12
-11
lines changed
-2 Bytes
Binary file not shown.
63 Bytes
Binary file not shown.

DFTtoolbox/abinit.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def ground(self,prefix,soc,mag,dftu,kdense=20):
1616
#spec=sorted(tuple(set(atom)))
1717
atom, a_vec, sublat=self.getxsf(self.wkdir,prefix)
1818
klabel, kpath=self.getkpf(self.wkdir,prefix)
19-
19+
2020
# check if V<0, if yes, swap a1 and a2
2121
V=np.dot(np.cross(a_vec[0,:],a_vec[1,:]),a_vec[2,:])
2222
print('system volume={0} A^3'.format(V))
@@ -66,7 +66,6 @@ def ground(self,prefix,soc,mag,dftu,kdense=20):
6666
for n in range(0,len(atom)):
6767
file.write(' {0[0]:12.8f} {0[1]:12.8f} {0[2]:12.8f} # {1:>2s} ({2:>3d})\n'.\
6868
format(sublat[n,:],ptable[atom[n]],(n+1)))
69-
#file.write('%12.8f %12.8f %12.8f\n' % tuple(sublat[n,:].tolist()))
7069
file.write('\n')
7170
file.write('# Magnetism ======================================\n')
7271
if mag=='on':
@@ -231,15 +230,17 @@ def relax(self,prefix):
231230
ptable=self.ptable()
232231
#spec=sorted(tuple(set(atom)))
233232
atom, a_vec, sublat=self.getxsf(self.wkdir,prefix)
234-
if type(atom[0])==str:
235-
atom=[ self.__grep__(ptable,atn)[0] for atn in atom]
233+
236234
# check if V<0, if yes, swap a1 and a2
237235
V=np.dot(np.cross(a_vec[0,:],a_vec[1,:]),a_vec[2,:])
238236
print('system volume={0} A^3'.format(V))
239237
if V < 0:
240238
print('Warning: V<0, a1/b1 and a2/b2 swapped, else abinit will report error!')
241239
a_vec=a_vec[[1,0,2],:]
242-
sublat=sublat[:,[1,0,2]]
240+
sublat=sublat[:,[1,0,2]]
241+
242+
if type(atom[0])==str:
243+
atom=[ self.__grep__(ptable,atn)[0] for atn in atom]
243244
# convert atomic name format to atomic number format
244245
spec=[]
245246
[spec.append(at_n) for at_n in atom if spec.count(at_n)==0]
@@ -275,7 +276,7 @@ def relax(self,prefix):
275276
file.write(' %12.8f %12.8f %12.8f\n' % tuple(a_vec[n,:].tolist()))
276277
file.write('xred # atom in reduced coordinates\n')
277278
for n in range(0,len(atom)):
278-
file.write(' {0[0]:12.8f} {0[0]:12.8f} {0[0]:12.8f} # {1:>2s} ({2:>3d})\n'.\
279+
file.write(' {0[0]:12.8f} {0[1]:12.8f} {0[2]:12.8f} # {1:>2s} ({2:>3d})\n'.\
279280
format(sublat[n,:],ptable[atom[n]],(n+1)))
280281
file.write('\n')
281282
file.write('# Plane Waves ================================\n')

DFTtoolbox/qe.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def ground(self,prefix,soc,mag,dftu,kdense=20):
3737
file.write(' max_seconds = 21000 ,\n')
3838
file.write('/\n')
3939
file.write('&SYSTEM\n')
40-
file.write(' ! -- < basic parameters > --\n')
40+
file.write(' ! < basic parameters > ===================\n')
4141
file.write(' ibrav = 0,\n')
4242
file.write(' celldm(1) = 1.89,\n')
4343
file.write(' ntyp = {0} ,\n'.format(len(spec)))
@@ -46,7 +46,7 @@ def ground(self,prefix,soc,mag,dftu,kdense=20):
4646
file.write(' ecutrho = 330 , ! 4*ecutwfc for paw/ncpp, 10*ecutwfc for uspp\n')
4747
file.write(' occupations = \'smearing\' ,\n')
4848
file.write(' degauss = 0.02 ,\n')
49-
file.write(' ! -- < spin wavefunctions > --\n')
49+
file.write(' ! < spin wavefunctions > =================\n')
5050
if (soc is 'on'):
5151
file.write(' nspin = 4,\n')
5252
file.write(' noncolin = .true. ,\n')
@@ -57,18 +57,18 @@ def ground(self,prefix,soc,mag,dftu,kdense=20):
5757
elif (soc is 'off') and (mag is 'off'):
5858
file.write(' nspin = 1,\n')
5959
if (mag is 'on'):
60-
file.write(' ! -- < magnetic constrains > --\n')
60+
file.write(' ! < magnetic constrains > ================\n')
6161
file.write(' constrained_magnetization = \'none\' ! constrain scheme\n')
6262
file.write(' lambda = 1.0 ! constraint parameters, 0~1000\n')
6363
file.write(' tot_magnetization=-1 ! major-s - minor-s (LSDA) > 0, if constrained_magnetization=\'total\'\n')
64-
file.write(' ! -- < initial moments > --\n')
64+
file.write(' ! < initial moments > ====================\n')
6565
for n in range(0,len(spec)):
6666
file.write(' starting_magnetization({0}) = 0.0, ! -1~+1, % of polar-valence-e\n'.format(n+1))
6767
if (soc is 'on'):
6868
file.write(' angle1({0}) = 0.0, ! angle between m and z\n'.format(n+1))
6969
file.write(' angle2({0}) = 0.0, ! angle between m on x-y plane and x\n'.format(n+1))
7070
if (dftu is 'on'):
71-
file.write(' ! -- < DFT+U parameters > --\n')
71+
file.write(' ! < DFT+U parameters > ===================\n')
7272
file.write(' lda_plus_u = .true. \n')
7373
if (soc is 'off'):
7474
file.write(' lda_plus_u_kind = 0\n')

examples/abinit/lsda/band-DS2.npz

0 Bytes
Binary file not shown.

examples/abinit/lsda/band-DS2.png

262 Bytes
Loading
6 Bytes
Loading
103 Bytes
Loading

examples/abinit/lsda/fatband-DS3.npz

0 Bytes
Binary file not shown.

examples/abinit/lsda/pdos-DS4.npz

0 Bytes
Binary file not shown.

examples/abinit/lsda/pdos-DS4.png

-71 Bytes
Loading

0 commit comments

Comments
 (0)