Skip to content

Commit 3c7a680

Browse files
authored
Merge pull request #87 from wszhang/develop
edit code part of README.md; change name test.0.dat to orb_matrix.0.dat
2 parents e7c1dc1 + bc95105 commit 3c7a680

File tree

10 files changed

+129
-532
lines changed

10 files changed

+129
-532
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.

source/src_io/numerical_basis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void Numerical_Basis::output_overlap( const ModuleBase::ComplexMatrix *psi)
6767
std::ofstream ofs;
6868
std::stringstream ss;
6969
// the parameter 'winput::spillage_outdir' is read from INPUTw.
70-
ss << winput::spillage_outdir << "/" << GlobalC::ucell.latName << "." << derivative_order << ".dat";
70+
ss << winput::spillage_outdir << "/" << "orb_matrix." << derivative_order << ".dat";
7171
if (GlobalV::MY_RANK==0)
7272
{
7373
ofs.open(ss.str().c_str());
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/README.md

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,57 @@
11
# SIAB Package Description
22

33

4-
(S)ystematically
5-
(I)mprovable
6-
(A)tomic orbital
7-
(B)asis generator based on spillage formula
4+
**S**ystematically
5+
6+
**I**mprovable
7+
8+
**A**tomic orbital
9+
10+
**B**asis generator based on spillage formula
811

912

1013
# HOW TO USE SIAB
1114

12-
The optimization can choose three minimization methods: 'Simulated Annealing', 'PyTorch Gradient' and 'PyTorch Gradient whit dpsi'.
15+
The optimization can choose one of the three minimization methods:
16+
17+
- Simulated Annealing (**SA**),
18+
- PyTorch Gradient (**PTG**),
19+
- PyTorch Gradient with dpsi (**PTG_dpsi**).
20+
21+
The executable files for the three methods are:
22+
23+
- ./SimulatedAnnealing/source/SIA_s.exe,
24+
- ./PyTorchGradient/source/main.py,
25+
- ../opt_orb_pytorch_dpsi/main.py,
26+
27+
respectively.
1328

14-
The executable files for three methods are './SimulatedAnnealing/source/SIA_s.exe', './PyTorchGradient/source/main.py', '../opt_orb_pytorch_dpsi/main.py', respectively.
1529

30+
## 1. Write input file
1631

17-
## (1) write input file
18-
Firstly, write the input file, such as "ORBITAL_INPUT_DZP" in example-directories, for script 'Generate_Orbital_AllInOne.sh'.
19-
Both approachs, 'PyTorch Gradient' and 'Simulated Annealing', work with one bash script and use the same input file.
20-
Please use the absolute path for each each file and directory.
32+
Firstly, write the input file, such as **ORBITAL_INPUT_DZP** in example-directories, for script **Generate_Orbital_AllInOne.sh**.
33+
All three approachs work with the same bash script and use the same input file.
34+
Please use **absolute path** for each file/directory in input file.
2135

2236

23-
## (2) set up dependence env
24-
Then, we set up the dependence env for ABACUS and SIAB, such as:
25-
'''
26-
module load hpcx/2.9.0/hpcx-intel-2019.update5 mkl/2019.update5 elpa/2019.05.002/hpcx-intel-2019.update5
27-
'''
28-
Especially for SIAB with 'PyTorch Gradient' approach, we need pytorch v1.1.0.
37+
## 2. Set up dependence environment
2938

39+
Secondly, we set up the dependence environment for ABACUS and SIAB, such as:
40+
41+
```bash
42+
$ module load hpcx/2.9.0/hpcx-intel-2019.update5 mkl/2019.update5 elpa/2019.05.002/hpcx-intel-2019.update5
43+
```
44+
45+
Especially for SIAB with **PyTorch Gradient** approach, we need pytorch v1.1.0.
46+
47+
48+
### How to install pytorch:
3049

31-
### how to install pytorch:
3250
Take the HanHai20@USTC system for example:
3351

34-
''' bash
35-
$ module load gcc/7.5.0min #:optional, larger version gcc may not be necessary.
36-
$ module load anaconda3
52+
```bash
53+
$ module load gcc/7.5.0min #optional, maybe unnecessary.
54+
$ module load anaconda3_nompi
3755
$ module list
3856
Currently Loaded Modulefiles:
3957
1) elpa/2019.05.002/hpcx-intel-2019.update5 4) hpcx/2.9.0/hpcx-intel-2019.update5 7) libxc/4.3.4/hpcx-intel-2019.update5
@@ -43,22 +61,23 @@ $ python3 -V
4361
Python 3.7.4
4462

4563
$ conda create -n pytorch110 python=3.7
46-
$ source activate pytorch110 #or: conda activate pytorch110
64+
$ source activate pytorch110 #or: conda activate pytorch110
4765
$ conda install pytorch torchvision torchaudio cpuonly -c pytorch
48-
$ source deactivate #or: conda deactivate
66+
$ source deactivate #or: conda deactivate
4967

5068
$ source activate pytorch110 #or: conda activate pytorch110
5169
$ pip3 install --user scipy numpy
5270
$ pip3 install --user torch_optimizer
53-
'''
71+
```
72+
5473

74+
## 3. Run generation
5575

56-
## (3) run generation
57-
Finally, 'cd' into an example folder, and run command like this:
76+
Finally, `cd` into an example folder, and run command like this:
5877

59-
''' bash
60-
../Generate_Orbital_AllInOne.sh ORBITAL_INPUT_DZP
61-
# or
62-
bsub -q idle -n 8 -oo running.log ../Generate_Orbital_AllInOne.sh ORBITAL_INPUT_DZP
63-
'''
78+
```bash
79+
$ ../Generate_Orbital_AllInOne.sh ORBITAL_INPUT_DZP
80+
or
81+
$ bsub -q idle -n 8 -oo running.log ../Generate_Orbital_AllInOne.sh ORBITAL_INPUT_DZP
82+
```
6483

0 commit comments

Comments
 (0)