Skip to content

Commit 4c01c80

Browse files
committed
update rescu example
1 parent 9641b2c commit 4c01c80

10 files changed

+3177
-18
lines changed

README.md

+79-18
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,92 @@
1-
# dftio
1+
# dftio Developer Guide
22
dftio is to assist machine learning communities to transcript DFT output into a format that is easy to read or used by machine learning models.
33

4+
# How to use
5+
```bash
6+
usage: dftio parse [-h] [-ll {DEBUG,3,INFO,2,WARNING,1,ERROR,0}] [-lp LOG_PATH] [-m MODE] [-r ROOT] [-p PREFIX] [-o OUTROOT] [-f FORMAT] [-ham] [-ovp] [-dm] [-eig]
47

5-
# 这里记录下parser需要的一些功能
8+
optional arguments:
9+
-h, --help show this help message and exit
10+
-ll {DEBUG,3,INFO,2,WARNING,1,ERROR,0}, --log-level {DEBUG,3,INFO,2,WARNING,1,ERROR,0}
11+
set verbosity level by string or number, 0=ERROR, 1=WARNING, 2=INFO and 3=DEBUG (default: INFO)
12+
-lp LOG_PATH, --log-path LOG_PATH
13+
set log file to log messages to disk, if not specified, the logs will only be output to console (default: None)
14+
-m MODE, --mode MODE The name of the DFT software. (default: abacus)
15+
-r ROOT, --root ROOT The root directory of the DFT files. (default: ./)
16+
-p PREFIX, --prefix PREFIX
17+
The prefix of the DFT files under root. (default: frame)
18+
-o OUTROOT, --outroot OUTROOT
19+
The output root directory. (default: ./)
20+
-f FORMAT, --format FORMAT
21+
The output root directory. (default: dat)
22+
-ham, --hamiltonian Whether to parse the Hamiltonian matrix. (default: False)
23+
-ovp, --overlap Whether to parse the Overlap matrix (default: False)
24+
-dm, --density_matrix
25+
Whether to parse the Density matrix (default: False)
26+
-eig, --eigenvalue Whether to parse the kpoints and eigenvalues (default: False)
27+
```
628
7-
## parser 抽象类
8-
### 对于不同的软件接口,读取的方式可以不同,但是最大程度的可以约束一个读取完之后的基本格式,比如数据类型,数据的shape
9-
### 有一个基本格式之后,对于输出的形式,由于内部存储格式相同,输出也可以提前固定,比如我们可以指定几种输出的存储形式,写好方法,后续对接其他软件只需要写好获取这些物理量的方法,输出格式不用管,就可以直接调抽象类。
29+
# Package Structure
30+
The main structure of dftio contrains three module:
1031
11-
### 需要实现的物理量:
12-
1. 原子结构信息,dpdata直接拿
13-
2. 场 - p(r) V_h(r) V_xc(r) (x,y,z) - f(x,y,z)
32+
`data`: Containing the basic graph and dataset / dataloader implemented align with pytorch-geometric convension. By using the dataset and graph class provided, user only need to concentrate on building powerful machine learning models.
33+
34+
`datastruct`: This module contrains the data structure class for the physical quantities that is supported by dftio. For example, the hamiltonian/overlap/density matrix, and the field quantities such as charge density distribution function, potential function and so on.
35+
36+
`io`: IO class is the interfaces of dftio class to all DFT packages. Each DFT that dftio supported cooresponding to a submodule in `io`. Developer only need to implement several parsing functions in each submodule, and summit them by inheriting the parser class and register into the parser collection class. NOTE: for further support of parallization, parsing each DFT snapshot need to be independent.
37+
38+
```
39+
|-- dftio
40+
| |-- __init__.py
41+
| |-- __main__.py
42+
| |-- constants.py
43+
| |-- data
44+
| | `-- _keys.py
45+
| |-- datastruct
46+
| |-- io
47+
| | |-- __init__.py
48+
| | |-- abacus
49+
| | | `-- abacus_parser.py
50+
| | |-- parse.py
51+
| | `-- rescu
52+
| | `-- rescu_parser.py
53+
| |-- logger.py
54+
| |-- register.py
55+
| `-- utils.py
56+
|-- example
57+
|-- pyproject.toml
58+
`-- test
59+
```
60+
61+
# What need to write:
62+
in `io` class, you need to create a submodule for your own DFT package, and implement the following method:
63+
64+
1. get_structure(idx: int): idx is the index of ith target DFT output folder. the output need to be a dict of structure data, containing:
65+
- _keys.ATOMIC_NUMBERS_KEY: atomic number, shape [natom,]
66+
- _keys.PBC_KEY: periodic boundary condition, shape [3,]
67+
- _keys.POSITIONS_KEY: position, unit in Angstrum shape [nframe, natom, 3]
68+
- _keys.CELL_KEY: cell, unit in Bohr2Angstrom, shape [nframe, 3, 3]
69+
2. get_eigenvalues(idx: int): output also need to be a key, containing:
70+
- _keys.KPOINT_KEY: kpoints, shape [natom, nband]
71+
- _keys.ENERGY_EIGENVALUE_KEY: eigenvalues, shape [nframe, natom, nband]
72+
3. get_basis(idx: int): This gives out the basis information used in DFT calculation, the format looks like: {Si: "2s2p1d"}
73+
4. get_blocks(idx: int, hamiltonian: bool=False, overlap: bool=False, density_matrix: bool=False): This function contrains the hamiltonian/overlap/density matrix block data. The returning format is a tuple of three quantities, as ([hamiltonian], [overlap], [density_matrix]). each [...] denote a list of dict, which length equals nframe. Each dict records the blocks data with a structure: {"i_j_Rx_Ry_Rz": np.array(...)}
74+
75+
A example should be added into test/data for further testing
76+
77+
# Supported Physical Quantities:
78+
1. atomic structure
79+
2. field - p(r) V_h(r) V_xc(r) (x,y,z) - f(x,y,z)
1480
- p(r) - LCAO (C_i)
15-
3. O(r,r') - H(r,r'), P(r,r), S(r,r') (i,j,R) -> []
16-
- Gaussian
17-
- VASP PW, <f|H|f>
18-
4. Wave Function
81+
3. Operator under local basis: O(r,r') - H(r,r'), P(r,r), S(r,r') (i,j,R) -> []
82+
4. Projection of scalar field on local basis
1983
5. kpoint eigenvalue
2084
21-
### 对接软件
85+
# Supported DFT software
2286
1. RESCU
2387
2. ABACUS
24-
3. SEASTA
88+
3. SIESTA
2589
4. Wannier
2690
5. Gaussian
2791
6. PYSCF
28-
7. VASP
29-
30-
### 基础的数据类接口
31-
应该提供一个比较基本的数据类,可以加载我们parse出的数据类型,让想拿这个搞ML算法的人可以直接用这个数据集加载已经有的数据,或者在这个基础上魔改一下
92+
7. VASP

test/data/rescu_calc/al_lcao_scf.mat

142 KB
Binary file not shown.
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
LCAO.status = true
2+
info.savepath = 'results/al_lcao_scf'
3+
info.calculationType = 'self-consistent'
4+
atom.element = 1
5+
atom.xyz = [0 0 0]
6+
domain.latvec = ~eye(3)/2*7.652445391; % positions in angstrom
7+
domain.lowres = 2/3
8+
element(1).species = 'Al'
9+
element(1).path = '../rescu-2.8.1/PotentialData/psdojo_pbe_v0.4-TM-PBE.4/psdojo_pbe_v0.4/Al_PBE_OV/Al_PBE_OV_DZP.mat'
10+
functional.list = {'XC_LDA_X','XC_LDA_C_PW'}
11+
eigensolver.emptyBand = 8
12+
kpoint.gridn = [3,3,3]
13+
option.saveLevel = 1
14+
option.saveLCAOHam = true

test/data/rescu_calc/scf/resculog.out

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
------------------------------------------------------------
2+
Beginning self-consistent calculation at 2024:05:30::10:31:26
3+
------------------------------------------------------------
4+
5+
********************* How to cite RESCU ********************
6+
* Michaud-Rioux, V., Zhang, L., & Guo, H. (2016). *
7+
* RESCU: A real space electronic structure method. *
8+
* Journal of Computational Physics, 307, 593-613. *
9+
* https://doi.org/10.1016/j.jcp.2015.12.014 *
10+
************************************************************
11+
12+
------------------------------------------------------------
13+
## INFO ##
14+
RESCU version (path) = 2022B [2.8.1] (/home/zhanghao/rescu-2.8.1/src)
15+
Calculation type = self-consistent
16+
## PSEUDOPOTENTIAL ##
17+
Pseudopotential for Al = /home/zhanghao/rescu-2.8.1/PotentialData/psdojo_pbe_v0.4-TM-PBE.4/psdojo_pbe_v0.4/Al_PBE_OV/Al_PBE_OV_DZP.mat
18+
## BASIS ##
19+
Calculation basis = LCAO
20+
Number of basis functions = 13
21+
## DOMAIN ##
22+
Lattice vectors (Bohr) = [0.000e+00,3.826e+00,3.826e+00]
23+
[3.826e+00,0.000e+00,3.826e+00]
24+
[3.826e+00,3.826e+00,0.000e+00]
25+
Low resolution N = [9,9,9]
26+
Boundary types = [1,1,1]
27+
Differentiation method = fft (1)
28+
Interpolation method (order) = fft (8)
29+
## ATOMS ##
30+
Number of (elements,atoms) = (1,1)
31+
Number of electrons = 3
32+
## SPIN ##
33+
Spin type = degenerate
34+
## KPOINT ##
35+
Monkhorst-Pack grid = [3,3,3]
36+
K-point grid shift = [0.00,0.00,0.00]
37+
Reduced k-grid size = 14
38+
Sampling method (smearing) = fermi-dirac (2.721e-02 eV)
39+
## FUNCTIONAL ##
40+
LibXC = 0
41+
XC functional = XC_LDA_X:XC_LDA_C_PW
42+
## EIGENSOLVER ##
43+
Number of bands = 10
44+
## MIXING ##
45+
Mixing algorithm = pulay
46+
Mixing type = potential
47+
Mixing history = 20
48+
Mixing fraction = 2.000e-01
49+
Mixing metric = nonuniform
50+
Mixing tolerance (Rho,Etot) = (1.000e-05,1.000e-05)
51+
## OPTION ##
52+
Maximal number of SCF iterations = 100
53+
------------------------------------------------------------
54+
Planning orbital-to-real-space conversion 0.048
55+
Generating Boolean overlap matrix 0.062
56+
Calculating local coverage indices 0.012
57+
Generating overlap and kinetic energy matrices 0.330
58+
Generating non-local potential (AO) 0.141
59+
Merging non-local potential and kinetic energy 0.045
60+
Generating neutral atom potential 0.072
61+
Generating isolated atom density 0.053
62+
Generating initial density 0.006
63+
Generating partial core density 0.049
64+
Generating 'isolated atom' potential 0.032
65+
Generating effective potential 0.059
66+
.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
67+
The Hamiltonian was generated in 0.860
68+
------------------------------------------------------------
69+
------------------------------------------------------------
70+
Computing short-range energy and forces 0.162
71+
------------------------------------------------------------
72+
------------------------------------------------------------
73+
#iter | Etot dRho dE dt time
74+
# 1 | -2.278e+00 1.670e-01 1.000e+00 3.138e-01 10:31:27
75+
# 2 | -2.279e+00 1.627e-03 2.301e-04 1.278e-01 10:31:28
76+
# 3 | -2.282e+00 6.184e-03 9.077e-04 1.203e-01 10:31:28
77+
# 4 | -2.282e+00 6.152e-05 2.029e-05 1.163e-01 10:31:28
78+
# 5 | -2.282e+00 1.298e-05 1.322e-06 1.659e-01 10:31:28
79+
# 6 | -2.282e+00 2.577e-08 2.577e-07 9.244e-02 10:31:28
80+
.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
81+
Self-consistent time 0.965
82+
------------------------------------------------------------
83+
------------------------------------------------------------
84+
Computing energy density matrix: 0.008
85+
Computing orthogonalization forces: 0.306
86+
Computing density matrix: 0.006
87+
Computing kinetic energy operator forces: 0.010
88+
Computing non-local forces: 0.210
89+
Computing effective potential forces: 0.069
90+
Computing core-correction forces: 0.033
91+
Computing local pseudo-potential forces: 0.088
92+
.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
93+
The forces were calculated in: 0.744
94+
------------------------------------------------------------
95+
------------------------------------------------------------
96+
Saving results to disk
97+
Generating Hartree potential 0.001
98+
Generating vdh 0.001
99+
Generating exchange-correlation potential 0.002
100+
Generating Hartree potential 0.001
101+
Generating vdh 0.000
102+
Generating exchange-correlation potential 0.002
103+
Generating effective (local) potential 0.001
104+
Generating Hartree potential 0.001
105+
Generating vdh 0.000
106+
Generating exchange-correlation potential 0.002
107+
Generating effective (local) potential 0.000
108+
Saving time 3.217
109+
------------------------------------------------------------
110+
------------------------------------------------------------
111+
Finishing self-consistent calculation at 2024:05:30::10:31:32
112+
------------------------------------------------------------

0 commit comments

Comments
 (0)