Skip to content

Commit b39b5b7

Browse files
committed
to make doc/generate-basis.md consistent with the new generate_orbital.sh/Generate_Orbital_AllInOne.sh
1 parent 546183a commit b39b5b7

File tree

8 files changed

+79
-501
lines changed

8 files changed

+79
-501
lines changed

doc/generate-basis.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
In ABACUS, the atomic orbital bases are generated using a scheme developed in the [paper](https://iopscience.iop.org/article/10.1088/0953-8984/22/44/445501). We provide a script named “generate_orbital.sh” under the directory tools/ to generate the atomic orbitals bases. In order to run this script, an ORBITAL_INPUT file is required.
66

7-
An example of this ORBITAL_INPUT file can be found in $ABACUS/tools/SIAB/2_Generate:
7+
An example of this ORBITAL_INPUT file can be found in $ABACUS/tools/SIAB/SimulatedAnnealing/example_N:
88
```
99
#1.exe_dir
1010
#----------------------------------------------------------------------------
@@ -101,7 +101,7 @@ The ORBITAL_INPUT file contains 5 parts :
101101
This part gives the bond lengths of the reference systems (dimer or trimer). Generally, the bond lengths are chosen to distribute on both sides of the equilibrium value. For example, for N dimer we use (in Å):
102102
- Dis 1.0 1.1 1.5 2.0 3.0
103103
104-
It means we take 5 reference systems (dimer), and the bond lengths are 1.0 1.1 1.5 2.0 3.0 angstrom, respectively. Every element has reference systems with different bond lengths, which could be found in file $ABACUS/tools/SIAB/2_Generate/DIS.txt.
104+
It means we take 5 reference systems (dimer), and the bond lengths are 1.0 1.1 1.5 2.0 3.0 angstrom, respectively. Every element has reference systems with different bond lengths, which could be found in file $ABACUS/tools/SIAB/DIS.txt.
105105
4. orbital generation
106106
107107
The main parameters for orbital generation
@@ -142,7 +142,7 @@ The ORBITAL_INPUT file contains 5 parts :
142142
143143
the accept rise of spillage when optimizing the kinetic energy
144144
145-
After preparing the ORBITAL_INPUT file, one just needs to run the script and wait for the results. The results will be written into several output files under the directory $element.id_element/$Rcut/, for example 07_N/6/.
145+
After preparing the ORBITAL_INPUT file, one just needs to run the script "$PATH_TO/generate_orbital.sh ORBITAL_INPUT" and wait for the results. The results will be written into several output files under the directory $element.id_element/$Rcut/, for example 07_N/6/.
146146
147147
Some output files listed here are useful.
148148
- ORBITAL_RESULTS.txt
@@ -160,4 +160,4 @@ For some elements, you can download the reference ORBITAL_INPUT files and pseudo
160160
A file README is also given and you can decide the parameters with it as a reference.
161161
In most cases, you just need to modify the parameters in Section 1, 2. Section 4 may be
162162
partially modified if you need higher precision orbitals. The users are not encouraged to change
163-
the settings in sections 5, unless you are very familiar with the code generating algorithms.
163+
the settings in sections 5, unless you are very familiar with the code generating algorithms.
File renamed without changes.

tools/SIAB/Generate_Orbital_AllInOne.sh

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ maxL=`grep -E "^\s*maxL" $InputFile | awk -F "maxL" '{print $0}' | awk '{print $
169169
# (0.x.x) check info (include Level) for each STRU
170170
nSTRU=`grep -E "^\s*BLSTRU" $InputFile | wc -l`
171171
#nSTRU=`grep -o "^\s*ListSTRU\s*[^#]*" W/ORBITAL_INPUT_DZP |wc -w |awk '{print $1-1}'`
172+
if [[ "$nSTRU" == "0" ]] ; then
173+
nSTRU=`grep -E "^\s*Dis" $InputFile | wc -l`
174+
if [ "$nSTRU" != "1" ]; then
175+
echo "error: input file has more than one line for Dis argument, please use the BLSTRU* "
176+
fi
177+
fi
172178
echo " nSTRU = $nSTRU"
173179
#
174180
LevelBegin[0]=0
@@ -180,23 +186,27 @@ for((iSTRU=1;iSTRU<=$nSTRU;iSTRU++))
180186
do
181187
ListSTRU[iSTRU]=`grep -E "^\s*ListSTRU " $InputFile |awk -F "ListSTRU" '{print $0}' \\
182188
|awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }'`
189+
ListSTRU[iSTRU]=${ListSTRU[iSTRU]:-dimer}
183190
echo " STRU[$iSTRU] = ${ListSTRU[iSTRU]}"
184191

185192

186-
info[iSTRU]=`grep -E "^\s*BLSTRU$iSTRU" $InputFile | awk -F "BLSTRU$iSTRU" '{print $2}'`
187-
BL_number[iSTRU]=`echo "${info[iSTRU]}" | awk '// {print NF}'`
188-
193+
BLSTRU[iSTRU]=`grep -E "^\s*BLSTRU$iSTRU" $InputFile | awk -F "BLSTRU$iSTRU" '{print $2}'`
194+
if [[ -z "${BLSTRU[iSTRU]}" ]] && [[ "$iSTRU=1" ]] ; then
195+
BLSTRU[iSTRU]=`grep -E "^\s*Dis" $InputFile | awk -F "Dis" '{print $2}'`
196+
fi
197+
BL_number[iSTRU]=`echo "${BLSTRU[iSTRU]}" | awk '// {print NF}'`
189198
# (0.1.11) calculate the number of different dimers or trimers.
190-
#info=`grep "Dis1" $InputFile | awk -F "Dis1" '{print $2}'`
191-
#BL_number=`echo "$info" | awk '// {print NF}'`
192-
echo " BL_number[$iSTRU] = ${BL_number[iSTRU]}, info[$iSTRU] =" ${info[iSTRU]}
199+
#BLSTRU=`grep "Dis1" $InputFile | awk -F "Dis1" '{print $2}'`
200+
#BL_number=`echo "$BLSTRU" | awk '// {print NF}'`
201+
echo " BL_number[$iSTRU] = ${BL_number[iSTRU]}"
202+
echo " BLSTRU[$iSTRU] =" ${BLSTRU[iSTRU]} " :Bond Length for each STRU"
193203

194204
EndLevel[iSTRU]=`grep -E "^\s*Level" $InputFile |awk -F "Level" '{print $0}' \\
195205
|awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }'`
196206
echo " EndLevel[$iSTRU] = ${EndLevel[iSTRU]}"
197207
BeginLevel[iSTRU]=`grep -E "^\s*BeginLevel" $InputFile |awk -F "BeginLevel" '{print $0}' \\
198208
|awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }'`
199-
echo " BeginLevel[$iSTRU] = ${BeginLevel[iSTRU]}"
209+
echo " BeginLevel[$iSTRU] = ${BeginLevel[iSTRU]:-auto/default}"
200210

201211
# (0.1.4)get the nbands
202212
nbands[iSTRU]=`grep -E "^\s*nbands" $InputFile | awk -F "nbands" '{print $0}' \\
@@ -211,7 +221,7 @@ do
211221
RestartSTRU[iSTRU]=`grep -E "^\s*RestartSTRU" $InputFile \\
212222
| awk -F "$RestartSTRU" '{print $0}' \\
213223
| awk -v iSTRU=$iSTRU '{print $(iSTRU+1) }'`
214-
echo " RestartSTRU[$iSTRU] = ${RestartSTRU[iSTRU]}"
224+
echo " RestartSTRU[$iSTRU] = ${RestartSTRU[iSTRU]:-auto/default}"
215225
#if [ ! -n "${RestartSTRU[iSTRU]}" ]; then
216226
# RestartSTRU[iSTRU]=0
217227
# echo " set RestartSTRU[$iSTRU]=0 "
@@ -231,8 +241,6 @@ if [ "$nSTRU" == "1" ]; then
231241
SkipSTRU[1]=0
232242
fi
233243

234-
#exit 0
235-
236244
# (0.1.8)get the level
237245
#Level=`grep "Level" $InputFile | awk -F "level" '{print $0}' | awk '{print $2}'`
238246
#echo "__Level=$Level"
@@ -493,7 +501,7 @@ do
493501
do
494502

495503
# (1.4.2.0) calculate the Bond Length for iSTRU
496-
BL=`echo "${info[iSTRU]}" | awk '{print $'$count'}' `
504+
BL=`echo "${BLSTRU[iSTRU]}" | awk '{print $'$count'}' `
497505
dis1=$(echo "scale=5;$BL * 0.86603 "|bc)
498506
dis2=$(echo "scale=5;$BL * 0.5 "|bc)
499507
dis3=$(echo "scale=5;$BL * 0.81649 "|bc)
@@ -690,7 +698,7 @@ EOF
690698
count_files=1
691699
while [ $count_files -le ${BL_number[iSTRU]} ]
692700
do
693-
BL=`echo "${info[iSTRU]}" | awk '{print $'$count_files'}' `
701+
BL=`echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}' `
694702
cat >> INPUT << EOF
695703
../OUT.$element-$rcut-$BL/orb_matrix.0.dat
696704
EOF
@@ -829,13 +837,13 @@ EOF
829837
count_files=1
830838
while [ $count_files -lt ${BL_number[iSTRU]} ]
831839
do
832-
BL=`echo "${info[iSTRU]}" | awk '{print $'$count_files'}' `
840+
BL=`echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}' `
833841
cat >> INPUT << EOF
834842
"../OUT.$element-$rcut-$BL/orb_matrix.0.dat",
835843
EOF
836844
let count_files++
837845
done
838-
BL=`echo "${info[iSTRU]}" | awk '{print $'$count_files'}' `
846+
BL=`echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}' `
839847
cat >> INPUT << EOF
840848
"../OUT.$element-$rcut-$BL/orb_matrix.0.dat"
841849
],
@@ -847,13 +855,13 @@ EOF
847855
count_files=1
848856
while [ $count_files -lt ${BL_number[iSTRU]} ]
849857
do
850-
BL=`echo "${info[iSTRU]}" | awk '{print $'$count_files'}' `
858+
BL=`echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}' `
851859
cat >> INPUT << EOF
852860
"../OUT.$element-$rcut-$BL/orb_matrix.1.dat",
853861
EOF
854862
let count_files++
855863
done
856-
BL=`echo "${info[iSTRU]}" | awk '{print $'$count_files'}' `
864+
BL=`echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}' `
857865
cat >> INPUT << EOF
858866
"../OUT.$element-$rcut-$BL/orb_matrix.1.dat"
859867
]
@@ -1047,13 +1055,13 @@ EOF
10471055
count_files=1
10481056
while [ $count_files -lt ${BL_number[iSTRU]} ]
10491057
do
1050-
BL=`echo "${info[iSTRU]}" | awk '{print $'$count_files'}' `
1058+
BL=`echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}' `
10511059
cat >> INPUT << EOF
10521060
"../OUT.$element-$rcut-$BL/orb_matrix.0.dat",
10531061
EOF
10541062
let count_files++
10551063
done
1056-
BL=`echo "${info[iSTRU]}" | awk '{print $'$count_files'}' `
1064+
BL=`echo "${BLSTRU[iSTRU]}" | awk '{print $'$count_files'}' `
10571065
cat >> INPUT << EOF
10581066
"../OUT.$element-$rcut-$BL/orb_matrix.0.dat"
10591067
],

tools/SIAB/SimulatedAnnealing/backup_old_version/2_Generate/generate_orbital.sh

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
#!/bin/bash
22
# author mohan
33
# edit by Pengfei Li 2013-6-4
4+
# edit by Wenshuai Zhang 2016-11-30
45
#-----------------------------------------------------------------
56
#
67
# (0.0) fixed parameters
78
#
89
#-----------------------------------------------------------------
910
mass=1 #not used yet.
1011
lat0=20 #in a.u
11-
cpu_num=1
12+
cpu_num=8
13+
export OMP_NUM_THREADS=1
14+
#hostfpath="/home/nic/wszhang/eclipse_project/mesia_dft/error_estimates_for_DFT/cif2cellroot/0abacus_lcao/myhosts"
15+
#hostfpath="/home/nic/wszhang/eclipse_project/mesia_dft/delta_test/delta_dft/cifs2deltaDFT/myhosts"
1216
#-----------------------------------------------------------------
1317
#
1418
# (0.1) input parameters
@@ -170,11 +174,16 @@ do
170174
# (1.4.2.0) calculate the distance of dimers
171175
dis=`echo "$info" | awk '{print $'$count'}' `
172176
dis1=$(echo "scale=5;$dis * 0.86603 "|bc)
173-
dis2=$(echo "scale=5;$dis * 0.5 "|bc)
177+
dis2=$(echo "scale=5;$dis * 0.5 "|bc)
178+
dis3=$(echo "scale=5;$dis * 0.81649 "|bc)
179+
dis4=$(echo "scale=5;$dis * 0.28867 "|bc)
174180
echo "dis=$dis"
181+
182+
175183
# (1.4.2.1) get the" structures"
176184
if ( test $element = Na -o $element = Li -o $element = K -o $element = Ca )
177185
then
186+
echo "use trimer"
178187
na=3
179188
cat > $name.stru << EOF
180189
ATOMIC_SPECIES
@@ -195,7 +204,32 @@ $element //Element Label
195204
0.0 $dis1 $dis2 0 0 0
196205
EOF
197206

207+
#elif ( test $element = Mn -o $element = Fe )
208+
#then
209+
#echo "use tetramer"
210+
#na=4
211+
#cat > $name.stru << EOF
212+
#ATOMIC_SPECIES
213+
#$element $mass $pseudofile
214+
#LATTICE_CONSTANT
215+
#$lat0 // add lattice constant(a.u.)
216+
#LATTICE_VECTORS
217+
#1 0 0
218+
#0 1 0
219+
#0 0 1
220+
#ATOMIC_POSITIONS
221+
#Cartesian_angstrom //Cartesian or Direct coordinate.
222+
#$element //Element Label
223+
#0.0 //starting magnetism
224+
#4 //number of atoms
225+
#0.0 0.0 0.0 0 0 0 // crystal coor.
226+
#0.0 0.0 $dis 0 0 0
227+
#0.0 $dis1 $dis2 0 0 0
228+
#$dis3 $dis4 $dis2 0 0 0
229+
#EOF
230+
198231
else
232+
echo "use dimer"
199233
na=2
200234
cat > $name.stru << EOF
201235
ATOMIC_SPECIES
@@ -263,7 +297,7 @@ symmetry 0
263297
nbands $nbands
264298
265299
ecutwfc $ecut
266-
dr2 1.0e-7 // about iteration
300+
dr2 2.0e-8 // about iteration
267301
niter 1000
268302
269303
smearing gauss
@@ -290,9 +324,10 @@ let count++
290324
#-------------
291325
#mpiexec -np $cpu_num -machinefile node_openmpi $EXE_pw
292326
#mpiexec -np $1 -machinefile $EXE_pw
293-
#mpirun -np 4 $EXE_pw
327+
mpirun -np $cpu_num $EXE_pw
328+
#mpirun -np $cpu_num -hostfile $hostfpath $EXE_pw
294329

295-
$EXE_pw
330+
#$EXE_pw
296331

297332
#mpiexec -n 12 -machinefile $PBS_NODEFILE $EXE_pw >> Log.txt
298333
# end (1.4.2), dimer distace cicle
@@ -343,12 +378,12 @@ cat >> INPUT << EOF
343378
$Start_tem_S // Start temparature for spillage
344379
0.8 // Cooling rate
345380
$Step_S // Number of temperatures(spillage)
346-
500 // Number of steps per temparature
381+
600 // Number of steps per temparature
347382
348383
$Start_tem_K // start temperature for kinetic energy
349384
0.8 // Cooling rate
350385
$Step_K // Number of temperatures(kinetical)
351-
500 // Number of steps per temparature
386+
600 // Number of steps per temparature
352387
353388
$Delta_kappa // Delta kappa
354389
50 // Selectly output information
@@ -416,7 +451,8 @@ cat >> INPUT << EOF
416451
EOF
417452

418453
#mpiexec -n 1 -machinefile $PBS_NODEFILE $EXE_orbital >> Log.txt
419-
$EXE_orbital
454+
$EXE_orbital
455+
#mpirun -np cpu_num $EXE_orbital
420456

421457
# (1.4.3.5)
422458
cd ..
@@ -431,3 +467,4 @@ cd ..
431467
done
432468
# end targets cicle
433469

470+
unset OMP_NUM_THREADS

tools/SIAB/SimulatedAnnealing/example_N/ORBITAL_INPUT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ref_bands 5 # reference bands
1212
nbands 8 # num of bands for calculate ( > reference bands)
1313
Ecut 50 # cutoff energy (in Ry)
1414
Rcut 6 # cutoff radius (in a.u.)
15-
Pseudo_dir ../
15+
Pseudo_dir ./
1616
Pseudo N_ONCV_PBE-1.0.upf
1717
sigma 0.01 # energy range for gauss smearing (in Ry)
1818
#--------------------------------------------------------------------------------
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
http://abacus.ustc.edu.cn/manual_411.html can be a reference to generate orbitals.
22

33
First, change some parameter in ORBITAL_INPUT, for EXE_pw, EXE_orbital and Pseudo_dir, you'd better use the absolute path;
4-
Second, run the script: ./generate_orbital.sh
4+
5+
Second, run the script: ../../../generate_orbital.sh ORBITAL_INPUT

0 commit comments

Comments
 (0)