[WIP] Add diamond example dataset (all stages) (multi-commit 035430284dc329b6018851d151e26e96cf54512d40b35bfc421cf66e039ac242)

#1
by Koulb - opened
This view is limited to 50 files because it contains too many changes. See the raw diff here.
Files changed (50) hide show
  1. .gitattributes +42 -0
  2. example/diamond/1_data_prepare/README.md +51 -0
  3. example/diamond/1_data_prepare/__pycache__/prepare.cpython-311.pyc +0 -0
  4. example/diamond/1_data_prepare/band_compare_sc.png +3 -0
  5. example/diamond/1_data_prepare/band_compare_uc.png +3 -0
  6. example/diamond/1_data_prepare/compare_bands.py +186 -0
  7. example/diamond/1_data_prepare/data/bands/kpath.json +968 -0
  8. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/element.dat +16 -0
  9. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/graph.pkl +3 -0
  10. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/hamiltonians.h5 +3 -0
  11. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/hamiltonians_pred.h5 +3 -0
  12. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/info.json +1 -0
  13. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/lat.dat +3 -0
  14. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/orbital_types.dat +16 -0
  15. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/overlaps.h5 +3 -0
  16. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/config.ini +82 -0
  17. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/result.txt +86 -0
  18. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/__init__.py +10 -0
  19. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/__pycache__/__init__.cpython-312.pyc +0 -0
  20. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/__pycache__/data.cpython-312.pyc +0 -0
  21. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/__pycache__/graph.cpython-312.pyc +0 -0
  22. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/__pycache__/kernel.cpython-312.pyc +0 -0
  23. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/__pycache__/model.cpython-312.pyc +0 -0
  24. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/__pycache__/rotate.cpython-312.pyc +0 -0
  25. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/__pycache__/utils.cpython-312.pyc +0 -0
  26. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/data.py +217 -0
  27. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/default.ini +88 -0
  28. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_HermNet/__init__.py +1 -0
  29. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_HermNet/__pycache__/__init__.cpython-312.pyc +0 -0
  30. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_HermNet/__pycache__/rmnet.cpython-312.pyc +0 -0
  31. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_HermNet/license.txt +1 -0
  32. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_HermNet/rmnet.py +105 -0
  33. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_PyG_future/__init__.py +2 -0
  34. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_PyG_future/__pycache__/__init__.cpython-312.pyc +0 -0
  35. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_PyG_future/__pycache__/diff_group_norm.cpython-312.pyc +0 -0
  36. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_PyG_future/__pycache__/graph_norm.cpython-312.pyc +0 -0
  37. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_PyG_future/diff_group_norm.py +109 -0
  38. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_PyG_future/graph_norm.py +60 -0
  39. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_PyG_future/license.txt +22 -0
  40. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_pymatgen/__init__.py +1 -0
  41. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_pymatgen/__pycache__/__init__.cpython-312.pyc +0 -0
  42. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_pymatgen/__pycache__/lattice.cpython-312.pyc +0 -0
  43. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_pymatgen/lattice.py +71 -0
  44. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_pymatgen/license.txt +22 -0
  45. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_schnetpack/__init__.py +1 -0
  46. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_schnetpack/__pycache__/__init__.cpython-312.pyc +0 -0
  47. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_schnetpack/__pycache__/acsf.cpython-312.pyc +0 -0
  48. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_schnetpack/acsf.py +50 -0
  49. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_schnetpack/license.txt +35 -0
  50. example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_se3_transformer/__init__.py +1 -0
.gitattributes CHANGED
@@ -58,3 +58,45 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
61
+ example/diamond/1_data_prepare/data/bands/sc/scf/VSC filter=lfs diff=lfs merge=lfs -text
62
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/charge-density.dat filter=lfs diff=lfs merge=lfs -text
63
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc1.dat filter=lfs diff=lfs merge=lfs -text
64
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc10.dat filter=lfs diff=lfs merge=lfs -text
65
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc100.dat filter=lfs diff=lfs merge=lfs -text
66
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc101.dat filter=lfs diff=lfs merge=lfs -text
67
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc102.dat filter=lfs diff=lfs merge=lfs -text
68
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc103.dat filter=lfs diff=lfs merge=lfs -text
69
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc104.dat filter=lfs diff=lfs merge=lfs -text
70
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc105.dat filter=lfs diff=lfs merge=lfs -text
71
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc106.dat filter=lfs diff=lfs merge=lfs -text
72
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc107.dat filter=lfs diff=lfs merge=lfs -text
73
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc108.dat filter=lfs diff=lfs merge=lfs -text
74
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc109.dat filter=lfs diff=lfs merge=lfs -text
75
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc11.dat filter=lfs diff=lfs merge=lfs -text
76
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc110.dat filter=lfs diff=lfs merge=lfs -text
77
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc111.dat filter=lfs diff=lfs merge=lfs -text
78
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc112.dat filter=lfs diff=lfs merge=lfs -text
79
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc113.dat filter=lfs diff=lfs merge=lfs -text
80
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc114.dat filter=lfs diff=lfs merge=lfs -text
81
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc115.dat filter=lfs diff=lfs merge=lfs -text
82
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc116.dat filter=lfs diff=lfs merge=lfs -text
83
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc117.dat filter=lfs diff=lfs merge=lfs -text
84
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc118.dat filter=lfs diff=lfs merge=lfs -text
85
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc119.dat filter=lfs diff=lfs merge=lfs -text
86
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc12.dat filter=lfs diff=lfs merge=lfs -text
87
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc120.dat filter=lfs diff=lfs merge=lfs -text
88
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc121.dat filter=lfs diff=lfs merge=lfs -text
89
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc122.dat filter=lfs diff=lfs merge=lfs -text
90
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc123.dat filter=lfs diff=lfs merge=lfs -text
91
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc124.dat filter=lfs diff=lfs merge=lfs -text
92
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc125.dat filter=lfs diff=lfs merge=lfs -text
93
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc126.dat filter=lfs diff=lfs merge=lfs -text
94
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc127.dat filter=lfs diff=lfs merge=lfs -text
95
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc128.dat filter=lfs diff=lfs merge=lfs -text
96
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc129.dat filter=lfs diff=lfs merge=lfs -text
97
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc13.dat filter=lfs diff=lfs merge=lfs -text
98
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc130.dat filter=lfs diff=lfs merge=lfs -text
99
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc131.dat filter=lfs diff=lfs merge=lfs -text
100
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc132.dat filter=lfs diff=lfs merge=lfs -text
101
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc133.dat filter=lfs diff=lfs merge=lfs -text
102
+ example/diamond/1_data_prepare/data/bands/sc/scf/diamond.save/wfc134.dat filter=lfs diff=lfs merge=lfs -text
example/diamond/1_data_prepare/README.md ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Diamond – Step 1: Data Preparation
2
+
3
+ Generate displaced supercell configurations, run QE DFT, transform to AO basis,
4
+ and verify band structure reconstruction.
5
+
6
+ ## Prerequisites
7
+
8
+ 1. **QE pseudopotential**: Place `C.upf` in `../pseudos/`
9
+ 2. **Siesta pseudopotential**: Place `C.psml` (or appropriate file) in `../aobasis/`
10
+ 3. **QE on PATH**: Source `~/scripts/tools/qe.sh` or set manually
11
+ 4. **Conda environments**: `hpro` (HPRO), `deeph` (DeepH)
12
+
13
+ ## Workflow
14
+
15
+ ```bash
16
+ # 1. Create input files and directory structure
17
+ python prepare.py
18
+
19
+ # 2. Run QE calculations (SCF + pw2bgw + bands)
20
+ python run.py
21
+
22
+ # 3. Transform Hamiltonians to AO basis via HPRO
23
+ python reconstruct.py
24
+
25
+ # 4. Compare QE and reconstructed band structures
26
+ python compare_bands.py
27
+ ```
28
+
29
+ ## Output
30
+
31
+ ```
32
+ data/
33
+ disp-01/ .. disp-50/ displaced 2×2×2 supercell SCF + reconstruction
34
+ bands/
35
+ uc/ pristine unit cell bands
36
+ sc/ pristine 2×2×2 supercell bands
37
+ kpath.json k-path used for band calculations
38
+ band_compare_uc.png QE vs HPRO comparison for unit cell
39
+ band_compare_sc.png QE vs HPRO comparison for supercell
40
+ ```
41
+
42
+ ## Parameters (params.json)
43
+
44
+ | Key | Description |
45
+ |-----|-------------|
46
+ | `supercell_size` | Supercell dimensions (default 2×2×2) |
47
+ | `n_displacements` | Number of displaced configs (default 50) |
48
+ | `displacement_groups` | Amplitude groups in Angstrom |
49
+ | `reconstruction.method` | `"original"` (real-space H(R)) |
50
+ | `reconstruction.nbnd` | Bands to include in reconstruction comparison |
51
+ | `cluster.run_sh` | Path to cluster submission script (null = local) |
example/diamond/1_data_prepare/__pycache__/prepare.cpython-311.pyc ADDED
Binary file (19.9 kB). View file
 
example/diamond/1_data_prepare/band_compare_sc.png ADDED

Git LFS Details

  • SHA256: fe48222e0013fbe99e8518fa1360e429b9e06892762c6168230aa1d393f42818
  • Pointer size: 131 Bytes
  • Size of remote file: 434 kB
example/diamond/1_data_prepare/band_compare_uc.png ADDED

Git LFS Details

  • SHA256: 545090d181fce60fb83a4bacede4c5fb81065c725c5f5b31f82b9b9180b4f991
  • Pointer size: 131 Bytes
  • Size of remote file: 178 kB
example/diamond/1_data_prepare/compare_bands.py ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ """
3
+ Compare QE band structure with HPRO real-space reconstruction for diamond.
4
+
5
+ Reads:
6
+ - data/bands/kpath.json (k-path from prepare.py)
7
+ - data/bands/{uc,sc}/scf/bands.dat.gnu (QE eigenvalues from bands.x)
8
+ - data/bands/{uc,sc}/reconstruction/aohamiltonian/ (HPRO H(R))
9
+
10
+ Produces band comparison plots: band_compare_uc.png and band_compare_sc.png
11
+
12
+ Usage: python compare_bands.py [params.json]
13
+ """
14
+ import json
15
+ import os
16
+ import sys
17
+
18
+ import numpy as np
19
+ import matplotlib
20
+ matplotlib.use('Agg')
21
+ import matplotlib.pyplot as plt
22
+ from scipy.linalg import eigh
23
+
24
+ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
25
+
26
+
27
+ def load_params(path=None):
28
+ if path is None:
29
+ path = os.path.join(SCRIPT_DIR, 'params.json')
30
+ with open(path) as f:
31
+ return json.load(f)
32
+
33
+
34
+ def load_kpath(data_dir):
35
+ with open(os.path.join(data_dir, 'bands', 'kpath.json')) as f:
36
+ return json.load(f)
37
+
38
+
39
+ def parse_bands_gnu(gnu_path):
40
+ """Parse QE bands.dat.gnu: blocks separated by blank lines.
41
+
42
+ Each block corresponds to one band; each line is 'k_dist eigenvalue'.
43
+ Returns eigs (nk, nbnd) in eV (same units as bands.x output).
44
+ """
45
+ bands, block = [], []
46
+ with open(gnu_path) as f:
47
+ for line in f:
48
+ line = line.strip()
49
+ if line:
50
+ block.append(float(line.split()[1]))
51
+ else:
52
+ if block:
53
+ bands.append(block)
54
+ block = []
55
+ if block:
56
+ bands.append(block)
57
+ if not bands:
58
+ raise FileNotFoundError(f"No data found in {gnu_path}")
59
+ return np.array(bands).T # (nk, nbnd)
60
+
61
+
62
+ def compute_hpro_bands(aodir, kpts_all, x_arr, nbnd):
63
+ """Compute band structure from HPRO H(R) via direct Fourier transform.
64
+
65
+ Uses load_deeph_HS + scipy.eigh for each k-point.
66
+ Hermitianizes H(k) (not H(R)) before diagonalizing.
67
+
68
+ Returns:
69
+ eigs (nk, nbnd) eigenvalues in eV, aligned to kpts_all
70
+ """
71
+ from HPRO.deephio import load_deeph_HS
72
+ from HPRO.constants import hartree2ev
73
+
74
+ matH = load_deeph_HS(aodir, 'hamiltonians.h5', energy_unit=True)
75
+ matS = load_deeph_HS(aodir, 'overlaps.h5', energy_unit=False)
76
+ matS.hermitianize() # S(R) is exact, hermitianize in real space
77
+
78
+ nk = len(kpts_all)
79
+ eigs_all = np.empty((nk, nbnd))
80
+
81
+ print(f" Diagonalizing at {nk} k-points...")
82
+ for ik, kpt in enumerate(kpts_all):
83
+ if ik % 50 == 0:
84
+ print(f" k-point {ik}/{nk}")
85
+ Hk = matH.r2k(kpt).toarray()
86
+ Sk = matS.r2k(kpt).toarray()
87
+ Hk = 0.5 * (Hk + Hk.conj().T) # hermitianize H(k) only
88
+ eigs_k, _ = eigh(Hk, Sk)
89
+ eigs_all[ik] = eigs_k[:nbnd] * hartree2ev
90
+
91
+ return eigs_all
92
+
93
+
94
+ def plot_comparison(x, eigs_qe, eigs_hpro, x_hs, labels, title, outpath):
95
+ """Plot QE vs HPRO band structures (both pre-aligned to their own VBM)."""
96
+ fig, ax = plt.subplots(figsize=(6, 5))
97
+
98
+ for ib in range(eigs_qe.shape[1]):
99
+ ax.plot(x, eigs_qe[:, ib], 'b-', lw=1.2, alpha=0.8,
100
+ label='QE' if ib == 0 else '')
101
+ for ib in range(eigs_hpro.shape[1]):
102
+ ax.plot(x, eigs_hpro[:, ib], 'r--', lw=1.0, alpha=0.8,
103
+ label='HPRO' if ib == 0 else '')
104
+
105
+ for xv in x_hs:
106
+ ax.axvline(xv, color='k', lw=0.8, ls='--')
107
+ ax.axhline(0, color='k', lw=0.5, ls=':')
108
+
109
+ ax.set_xticks(x_hs)
110
+ ax.set_xticklabels(labels, fontsize=11)
111
+ ax.set_ylabel('Energy (eV)', fontsize=11)
112
+ ax.set_xlim(x[0], x[-1])
113
+ emax = max(np.max(eigs_qe), np.max(eigs_hpro))
114
+ emin = min(np.min(eigs_qe), np.min(eigs_hpro))
115
+ ax.set_ylim(emin - 1, emax + 1)
116
+ ax.set_title(title, fontsize=11)
117
+ ax.legend(fontsize=10)
118
+ fig.tight_layout()
119
+ fig.savefig(outpath, dpi=200)
120
+ plt.close(fig)
121
+ print(f" Saved: {outpath}")
122
+
123
+
124
+ def main():
125
+ params_path = sys.argv[1] if len(sys.argv) > 1 else \
126
+ os.path.join(SCRIPT_DIR, 'params.json')
127
+ params = load_params(params_path)
128
+
129
+ data_dir = os.path.join(SCRIPT_DIR, 'data')
130
+ kpath = load_kpath(data_dir)
131
+
132
+ kpts_hs = np.array(kpath['kpts_hs'])
133
+ npts = kpath['npts']
134
+ labels = kpath['labels']
135
+ x_ref = np.array(kpath['x'])
136
+ x_hs = kpath['x_hs']
137
+
138
+ for cell_label in ('uc', 'sc'):
139
+ bands_dir = os.path.join(data_dir, 'bands', cell_label)
140
+ scf_dir = os.path.join(bands_dir, 'scf')
141
+ aodir = os.path.join(bands_dir, 'reconstruction', 'aohamiltonian')
142
+
143
+ if not os.path.exists(os.path.join(aodir, 'hamiltonians.h5')):
144
+ print(f"[{cell_label}] HPRO hamiltonians.h5 not found, "
145
+ "run reconstruct.py first")
146
+ continue
147
+
148
+ gnu = os.path.join(scf_dir, 'bands.dat.gnu')
149
+ if not os.path.exists(gnu):
150
+ print(f"[{cell_label}] bands.dat.gnu not found ({gnu}), "
151
+ "run run.py first")
152
+ continue
153
+
154
+ print(f"\n[{cell_label}] Loading QE bands from bands.dat.gnu...")
155
+ eigs_qe = parse_bands_gnu(gnu)
156
+ # VBM: highest occupied level
157
+ n_occ = 4 if cell_label == 'uc' else 4 * 8 # 4 electrons per UC
158
+
159
+ rec = params['reconstruction']
160
+ nbnd_param = rec.get('nbnd_sc', rec['nbnd']) if cell_label == 'sc' else rec['nbnd']
161
+
162
+ print(f"[{cell_label}] Computing HPRO bands...")
163
+ kpts_all = np.array(kpath['kpts_all'])
164
+ eigs_hpro = compute_hpro_bands(aodir, kpts_all, x_ref, nbnd_param)
165
+
166
+ # Align each source independently to its own VBM
167
+ nbnd_cmp = min(nbnd_param, eigs_qe.shape[1], eigs_hpro.shape[1])
168
+ vbm_qe = np.max(eigs_qe[:, :n_occ])
169
+ vbm_hpro = np.max(eigs_hpro[:, :n_occ])
170
+ eigs_qe_al = eigs_qe[:, :nbnd_cmp] - vbm_qe
171
+ eigs_hpro_al = eigs_hpro[:, :nbnd_cmp] - vbm_hpro
172
+
173
+ mae = np.mean(np.abs(eigs_qe_al - eigs_hpro_al))
174
+ print(f"[{cell_label}] MAE (first {nbnd_cmp} bands, VBM-aligned) = "
175
+ f"{mae*1000:.1f} meV")
176
+
177
+ outpath = os.path.join(SCRIPT_DIR, f'band_compare_{cell_label}.png')
178
+ title = f'Diamond {cell_label.upper()}: QE vs HPRO reconstruction'
179
+ plot_comparison(x_ref, eigs_qe_al, eigs_hpro_al,
180
+ x_hs, labels, title, outpath)
181
+
182
+ print("\ncompare_bands.py done.")
183
+
184
+
185
+ if __name__ == '__main__':
186
+ main()
example/diamond/1_data_prepare/data/bands/kpath.json ADDED
@@ -0,0 +1,968 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "kpts_hs": [
3
+ [
4
+ 0.0,
5
+ 0.0,
6
+ 0.0
7
+ ],
8
+ [
9
+ 0.5,
10
+ 0.0,
11
+ 0.5
12
+ ],
13
+ [
14
+ 0.5,
15
+ 0.25,
16
+ 0.75
17
+ ],
18
+ [
19
+ 0.375,
20
+ 0.375,
21
+ 0.75
22
+ ],
23
+ [
24
+ 0.0,
25
+ 0.0,
26
+ 0.0
27
+ ],
28
+ [
29
+ 0.5,
30
+ 0.5,
31
+ 0.5
32
+ ]
33
+ ],
34
+ "npts": [
35
+ 30,
36
+ 30,
37
+ 30,
38
+ 30,
39
+ 30,
40
+ 1
41
+ ],
42
+ "labels": [
43
+ "G",
44
+ "X",
45
+ "W",
46
+ "K",
47
+ "G",
48
+ "L"
49
+ ],
50
+ "kpts_all": [
51
+ [
52
+ 0.0,
53
+ 0.0,
54
+ 0.0
55
+ ],
56
+ [
57
+ 0.016666666666666666,
58
+ 0.0,
59
+ 0.016666666666666666
60
+ ],
61
+ [
62
+ 0.03333333333333333,
63
+ 0.0,
64
+ 0.03333333333333333
65
+ ],
66
+ [
67
+ 0.05,
68
+ 0.0,
69
+ 0.05
70
+ ],
71
+ [
72
+ 0.06666666666666667,
73
+ 0.0,
74
+ 0.06666666666666667
75
+ ],
76
+ [
77
+ 0.08333333333333333,
78
+ 0.0,
79
+ 0.08333333333333333
80
+ ],
81
+ [
82
+ 0.1,
83
+ 0.0,
84
+ 0.1
85
+ ],
86
+ [
87
+ 0.11666666666666667,
88
+ 0.0,
89
+ 0.11666666666666667
90
+ ],
91
+ [
92
+ 0.13333333333333333,
93
+ 0.0,
94
+ 0.13333333333333333
95
+ ],
96
+ [
97
+ 0.15,
98
+ 0.0,
99
+ 0.15
100
+ ],
101
+ [
102
+ 0.16666666666666666,
103
+ 0.0,
104
+ 0.16666666666666666
105
+ ],
106
+ [
107
+ 0.18333333333333332,
108
+ 0.0,
109
+ 0.18333333333333332
110
+ ],
111
+ [
112
+ 0.2,
113
+ 0.0,
114
+ 0.2
115
+ ],
116
+ [
117
+ 0.21666666666666667,
118
+ 0.0,
119
+ 0.21666666666666667
120
+ ],
121
+ [
122
+ 0.23333333333333334,
123
+ 0.0,
124
+ 0.23333333333333334
125
+ ],
126
+ [
127
+ 0.25,
128
+ 0.0,
129
+ 0.25
130
+ ],
131
+ [
132
+ 0.26666666666666666,
133
+ 0.0,
134
+ 0.26666666666666666
135
+ ],
136
+ [
137
+ 0.2833333333333333,
138
+ 0.0,
139
+ 0.2833333333333333
140
+ ],
141
+ [
142
+ 0.3,
143
+ 0.0,
144
+ 0.3
145
+ ],
146
+ [
147
+ 0.31666666666666665,
148
+ 0.0,
149
+ 0.31666666666666665
150
+ ],
151
+ [
152
+ 0.3333333333333333,
153
+ 0.0,
154
+ 0.3333333333333333
155
+ ],
156
+ [
157
+ 0.35,
158
+ 0.0,
159
+ 0.35
160
+ ],
161
+ [
162
+ 0.36666666666666664,
163
+ 0.0,
164
+ 0.36666666666666664
165
+ ],
166
+ [
167
+ 0.38333333333333336,
168
+ 0.0,
169
+ 0.38333333333333336
170
+ ],
171
+ [
172
+ 0.4,
173
+ 0.0,
174
+ 0.4
175
+ ],
176
+ [
177
+ 0.4166666666666667,
178
+ 0.0,
179
+ 0.4166666666666667
180
+ ],
181
+ [
182
+ 0.43333333333333335,
183
+ 0.0,
184
+ 0.43333333333333335
185
+ ],
186
+ [
187
+ 0.45,
188
+ 0.0,
189
+ 0.45
190
+ ],
191
+ [
192
+ 0.4666666666666667,
193
+ 0.0,
194
+ 0.4666666666666667
195
+ ],
196
+ [
197
+ 0.48333333333333334,
198
+ 0.0,
199
+ 0.48333333333333334
200
+ ],
201
+ [
202
+ 0.5,
203
+ 0.0,
204
+ 0.5
205
+ ],
206
+ [
207
+ 0.5,
208
+ 0.008333333333333333,
209
+ 0.5083333333333333
210
+ ],
211
+ [
212
+ 0.5,
213
+ 0.016666666666666666,
214
+ 0.5166666666666667
215
+ ],
216
+ [
217
+ 0.5,
218
+ 0.025,
219
+ 0.525
220
+ ],
221
+ [
222
+ 0.5,
223
+ 0.03333333333333333,
224
+ 0.5333333333333333
225
+ ],
226
+ [
227
+ 0.5,
228
+ 0.041666666666666664,
229
+ 0.5416666666666666
230
+ ],
231
+ [
232
+ 0.5,
233
+ 0.05,
234
+ 0.55
235
+ ],
236
+ [
237
+ 0.5,
238
+ 0.058333333333333334,
239
+ 0.5583333333333333
240
+ ],
241
+ [
242
+ 0.5,
243
+ 0.06666666666666667,
244
+ 0.5666666666666667
245
+ ],
246
+ [
247
+ 0.5,
248
+ 0.075,
249
+ 0.575
250
+ ],
251
+ [
252
+ 0.5,
253
+ 0.08333333333333333,
254
+ 0.5833333333333334
255
+ ],
256
+ [
257
+ 0.5,
258
+ 0.09166666666666666,
259
+ 0.5916666666666667
260
+ ],
261
+ [
262
+ 0.5,
263
+ 0.1,
264
+ 0.6
265
+ ],
266
+ [
267
+ 0.5,
268
+ 0.10833333333333334,
269
+ 0.6083333333333334
270
+ ],
271
+ [
272
+ 0.5,
273
+ 0.11666666666666667,
274
+ 0.6166666666666667
275
+ ],
276
+ [
277
+ 0.5,
278
+ 0.125,
279
+ 0.625
280
+ ],
281
+ [
282
+ 0.5,
283
+ 0.13333333333333333,
284
+ 0.6333333333333333
285
+ ],
286
+ [
287
+ 0.5,
288
+ 0.14166666666666666,
289
+ 0.6416666666666666
290
+ ],
291
+ [
292
+ 0.5,
293
+ 0.15,
294
+ 0.65
295
+ ],
296
+ [
297
+ 0.5,
298
+ 0.15833333333333333,
299
+ 0.6583333333333333
300
+ ],
301
+ [
302
+ 0.5,
303
+ 0.16666666666666666,
304
+ 0.6666666666666666
305
+ ],
306
+ [
307
+ 0.5,
308
+ 0.175,
309
+ 0.675
310
+ ],
311
+ [
312
+ 0.5,
313
+ 0.18333333333333332,
314
+ 0.6833333333333333
315
+ ],
316
+ [
317
+ 0.5,
318
+ 0.19166666666666668,
319
+ 0.6916666666666667
320
+ ],
321
+ [
322
+ 0.5,
323
+ 0.2,
324
+ 0.7
325
+ ],
326
+ [
327
+ 0.5,
328
+ 0.20833333333333334,
329
+ 0.7083333333333334
330
+ ],
331
+ [
332
+ 0.5,
333
+ 0.21666666666666667,
334
+ 0.7166666666666667
335
+ ],
336
+ [
337
+ 0.5,
338
+ 0.225,
339
+ 0.725
340
+ ],
341
+ [
342
+ 0.5,
343
+ 0.23333333333333334,
344
+ 0.7333333333333334
345
+ ],
346
+ [
347
+ 0.5,
348
+ 0.24166666666666667,
349
+ 0.7416666666666667
350
+ ],
351
+ [
352
+ 0.5,
353
+ 0.25,
354
+ 0.75
355
+ ],
356
+ [
357
+ 0.49583333333333335,
358
+ 0.25416666666666665,
359
+ 0.75
360
+ ],
361
+ [
362
+ 0.49166666666666664,
363
+ 0.25833333333333336,
364
+ 0.75
365
+ ],
366
+ [
367
+ 0.4875,
368
+ 0.2625,
369
+ 0.75
370
+ ],
371
+ [
372
+ 0.48333333333333334,
373
+ 0.26666666666666666,
374
+ 0.75
375
+ ],
376
+ [
377
+ 0.4791666666666667,
378
+ 0.2708333333333333,
379
+ 0.75
380
+ ],
381
+ [
382
+ 0.475,
383
+ 0.275,
384
+ 0.75
385
+ ],
386
+ [
387
+ 0.4708333333333333,
388
+ 0.2791666666666667,
389
+ 0.75
390
+ ],
391
+ [
392
+ 0.4666666666666667,
393
+ 0.2833333333333333,
394
+ 0.75
395
+ ],
396
+ [
397
+ 0.4625,
398
+ 0.2875,
399
+ 0.75
400
+ ],
401
+ [
402
+ 0.4583333333333333,
403
+ 0.2916666666666667,
404
+ 0.75
405
+ ],
406
+ [
407
+ 0.45416666666666666,
408
+ 0.29583333333333334,
409
+ 0.75
410
+ ],
411
+ [
412
+ 0.45,
413
+ 0.3,
414
+ 0.75
415
+ ],
416
+ [
417
+ 0.4458333333333333,
418
+ 0.3041666666666667,
419
+ 0.75
420
+ ],
421
+ [
422
+ 0.44166666666666665,
423
+ 0.30833333333333335,
424
+ 0.75
425
+ ],
426
+ [
427
+ 0.4375,
428
+ 0.3125,
429
+ 0.75
430
+ ],
431
+ [
432
+ 0.43333333333333335,
433
+ 0.31666666666666665,
434
+ 0.75
435
+ ],
436
+ [
437
+ 0.4291666666666667,
438
+ 0.3208333333333333,
439
+ 0.75
440
+ ],
441
+ [
442
+ 0.425,
443
+ 0.325,
444
+ 0.75
445
+ ],
446
+ [
447
+ 0.42083333333333334,
448
+ 0.32916666666666666,
449
+ 0.75
450
+ ],
451
+ [
452
+ 0.4166666666666667,
453
+ 0.3333333333333333,
454
+ 0.75
455
+ ],
456
+ [
457
+ 0.4125,
458
+ 0.3375,
459
+ 0.75
460
+ ],
461
+ [
462
+ 0.4083333333333333,
463
+ 0.3416666666666667,
464
+ 0.75
465
+ ],
466
+ [
467
+ 0.4041666666666667,
468
+ 0.3458333333333333,
469
+ 0.75
470
+ ],
471
+ [
472
+ 0.4,
473
+ 0.35,
474
+ 0.75
475
+ ],
476
+ [
477
+ 0.3958333333333333,
478
+ 0.3541666666666667,
479
+ 0.75
480
+ ],
481
+ [
482
+ 0.39166666666666666,
483
+ 0.35833333333333334,
484
+ 0.75
485
+ ],
486
+ [
487
+ 0.3875,
488
+ 0.3625,
489
+ 0.75
490
+ ],
491
+ [
492
+ 0.3833333333333333,
493
+ 0.3666666666666667,
494
+ 0.75
495
+ ],
496
+ [
497
+ 0.37916666666666665,
498
+ 0.37083333333333335,
499
+ 0.75
500
+ ],
501
+ [
502
+ 0.375,
503
+ 0.375,
504
+ 0.75
505
+ ],
506
+ [
507
+ 0.3625,
508
+ 0.3625,
509
+ 0.725
510
+ ],
511
+ [
512
+ 0.35,
513
+ 0.35,
514
+ 0.7
515
+ ],
516
+ [
517
+ 0.3375,
518
+ 0.3375,
519
+ 0.675
520
+ ],
521
+ [
522
+ 0.325,
523
+ 0.325,
524
+ 0.65
525
+ ],
526
+ [
527
+ 0.3125,
528
+ 0.3125,
529
+ 0.625
530
+ ],
531
+ [
532
+ 0.3,
533
+ 0.3,
534
+ 0.6
535
+ ],
536
+ [
537
+ 0.2875,
538
+ 0.2875,
539
+ 0.575
540
+ ],
541
+ [
542
+ 0.275,
543
+ 0.275,
544
+ 0.55
545
+ ],
546
+ [
547
+ 0.2625,
548
+ 0.2625,
549
+ 0.525
550
+ ],
551
+ [
552
+ 0.25,
553
+ 0.25,
554
+ 0.5
555
+ ],
556
+ [
557
+ 0.23750000000000002,
558
+ 0.23750000000000002,
559
+ 0.47500000000000003
560
+ ],
561
+ [
562
+ 0.22499999999999998,
563
+ 0.22499999999999998,
564
+ 0.44999999999999996
565
+ ],
566
+ [
567
+ 0.2125,
568
+ 0.2125,
569
+ 0.425
570
+ ],
571
+ [
572
+ 0.2,
573
+ 0.2,
574
+ 0.4
575
+ ],
576
+ [
577
+ 0.1875,
578
+ 0.1875,
579
+ 0.375
580
+ ],
581
+ [
582
+ 0.175,
583
+ 0.175,
584
+ 0.35
585
+ ],
586
+ [
587
+ 0.1625,
588
+ 0.1625,
589
+ 0.325
590
+ ],
591
+ [
592
+ 0.15000000000000002,
593
+ 0.15000000000000002,
594
+ 0.30000000000000004
595
+ ],
596
+ [
597
+ 0.1375,
598
+ 0.1375,
599
+ 0.275
600
+ ],
601
+ [
602
+ 0.125,
603
+ 0.125,
604
+ 0.25
605
+ ],
606
+ [
607
+ 0.11250000000000004,
608
+ 0.11250000000000004,
609
+ 0.2250000000000001
610
+ ],
611
+ [
612
+ 0.10000000000000003,
613
+ 0.10000000000000003,
614
+ 0.20000000000000007
615
+ ],
616
+ [
617
+ 0.08749999999999997,
618
+ 0.08749999999999997,
619
+ 0.17499999999999993
620
+ ],
621
+ [
622
+ 0.07499999999999996,
623
+ 0.07499999999999996,
624
+ 0.1499999999999999
625
+ ],
626
+ [
627
+ 0.0625,
628
+ 0.0625,
629
+ 0.125
630
+ ],
631
+ [
632
+ 0.04999999999999999,
633
+ 0.04999999999999999,
634
+ 0.09999999999999998
635
+ ],
636
+ [
637
+ 0.03749999999999998,
638
+ 0.03749999999999998,
639
+ 0.07499999999999996
640
+ ],
641
+ [
642
+ 0.025000000000000022,
643
+ 0.025000000000000022,
644
+ 0.050000000000000044
645
+ ],
646
+ [
647
+ 0.012500000000000011,
648
+ 0.012500000000000011,
649
+ 0.025000000000000022
650
+ ],
651
+ [
652
+ 0.0,
653
+ 0.0,
654
+ 0.0
655
+ ],
656
+ [
657
+ 0.016666666666666666,
658
+ 0.016666666666666666,
659
+ 0.016666666666666666
660
+ ],
661
+ [
662
+ 0.03333333333333333,
663
+ 0.03333333333333333,
664
+ 0.03333333333333333
665
+ ],
666
+ [
667
+ 0.05,
668
+ 0.05,
669
+ 0.05
670
+ ],
671
+ [
672
+ 0.06666666666666667,
673
+ 0.06666666666666667,
674
+ 0.06666666666666667
675
+ ],
676
+ [
677
+ 0.08333333333333333,
678
+ 0.08333333333333333,
679
+ 0.08333333333333333
680
+ ],
681
+ [
682
+ 0.1,
683
+ 0.1,
684
+ 0.1
685
+ ],
686
+ [
687
+ 0.11666666666666667,
688
+ 0.11666666666666667,
689
+ 0.11666666666666667
690
+ ],
691
+ [
692
+ 0.13333333333333333,
693
+ 0.13333333333333333,
694
+ 0.13333333333333333
695
+ ],
696
+ [
697
+ 0.15,
698
+ 0.15,
699
+ 0.15
700
+ ],
701
+ [
702
+ 0.16666666666666666,
703
+ 0.16666666666666666,
704
+ 0.16666666666666666
705
+ ],
706
+ [
707
+ 0.18333333333333332,
708
+ 0.18333333333333332,
709
+ 0.18333333333333332
710
+ ],
711
+ [
712
+ 0.2,
713
+ 0.2,
714
+ 0.2
715
+ ],
716
+ [
717
+ 0.21666666666666667,
718
+ 0.21666666666666667,
719
+ 0.21666666666666667
720
+ ],
721
+ [
722
+ 0.23333333333333334,
723
+ 0.23333333333333334,
724
+ 0.23333333333333334
725
+ ],
726
+ [
727
+ 0.25,
728
+ 0.25,
729
+ 0.25
730
+ ],
731
+ [
732
+ 0.26666666666666666,
733
+ 0.26666666666666666,
734
+ 0.26666666666666666
735
+ ],
736
+ [
737
+ 0.2833333333333333,
738
+ 0.2833333333333333,
739
+ 0.2833333333333333
740
+ ],
741
+ [
742
+ 0.3,
743
+ 0.3,
744
+ 0.3
745
+ ],
746
+ [
747
+ 0.31666666666666665,
748
+ 0.31666666666666665,
749
+ 0.31666666666666665
750
+ ],
751
+ [
752
+ 0.3333333333333333,
753
+ 0.3333333333333333,
754
+ 0.3333333333333333
755
+ ],
756
+ [
757
+ 0.35,
758
+ 0.35,
759
+ 0.35
760
+ ],
761
+ [
762
+ 0.36666666666666664,
763
+ 0.36666666666666664,
764
+ 0.36666666666666664
765
+ ],
766
+ [
767
+ 0.38333333333333336,
768
+ 0.38333333333333336,
769
+ 0.38333333333333336
770
+ ],
771
+ [
772
+ 0.4,
773
+ 0.4,
774
+ 0.4
775
+ ],
776
+ [
777
+ 0.4166666666666667,
778
+ 0.4166666666666667,
779
+ 0.4166666666666667
780
+ ],
781
+ [
782
+ 0.43333333333333335,
783
+ 0.43333333333333335,
784
+ 0.43333333333333335
785
+ ],
786
+ [
787
+ 0.45,
788
+ 0.45,
789
+ 0.45
790
+ ],
791
+ [
792
+ 0.4666666666666667,
793
+ 0.4666666666666667,
794
+ 0.4666666666666667
795
+ ],
796
+ [
797
+ 0.48333333333333334,
798
+ 0.48333333333333334,
799
+ 0.48333333333333334
800
+ ],
801
+ [
802
+ 0.5,
803
+ 0.5,
804
+ 0.5
805
+ ]
806
+ ],
807
+ "x": [
808
+ 0.0,
809
+ 0.009344921035417245,
810
+ 0.01868984207083449,
811
+ 0.028034763106251737,
812
+ 0.03737968414166898,
813
+ 0.04672460517708622,
814
+ 0.056069526212503475,
815
+ 0.06541444724792073,
816
+ 0.07475936828333796,
817
+ 0.0841042893187552,
818
+ 0.09344921035417245,
819
+ 0.10279413138958969,
820
+ 0.11213905242500695,
821
+ 0.1214839734604242,
822
+ 0.13082889449584145,
823
+ 0.14017381553125868,
824
+ 0.1495187365666759,
825
+ 0.15886365760209317,
826
+ 0.1682085786375104,
827
+ 0.17755349967292766,
828
+ 0.1868984207083449,
829
+ 0.19624334174376215,
830
+ 0.20558826277917938,
831
+ 0.21493318381459667,
832
+ 0.2242781048500139,
833
+ 0.23362302588543116,
834
+ 0.2429679469208484,
835
+ 0.2523128679562656,
836
+ 0.2616577889916829,
837
+ 0.27100271002710014,
838
+ 0.28034763106251737,
839
+ 0.285020091580226,
840
+ 0.28969255209793465,
841
+ 0.2943650126156433,
842
+ 0.29903747313335194,
843
+ 0.3037099336510605,
844
+ 0.30838239416876917,
845
+ 0.31305485468647776,
846
+ 0.3177273152041864,
847
+ 0.322399775721895,
848
+ 0.32707223623960363,
849
+ 0.3317446967573123,
850
+ 0.33641715727502086,
851
+ 0.3410896177927295,
852
+ 0.34576207831043815,
853
+ 0.3504345388281468,
854
+ 0.35510699934585543,
855
+ 0.3597794598635641,
856
+ 0.3644519203812727,
857
+ 0.36912438089898136,
858
+ 0.37379684141669,
859
+ 0.37846930193439865,
860
+ 0.3831417624521073,
861
+ 0.38781422296981594,
862
+ 0.3924866834875246,
863
+ 0.3971591440052332,
864
+ 0.40183160452294187,
865
+ 0.4065040650406505,
866
+ 0.41117652555835915,
867
+ 0.4158489860760678,
868
+ 0.42052144659377644,
869
+ 0.42382537511067464,
870
+ 0.42712930362757284,
871
+ 0.43043323214447105,
872
+ 0.4337371606613692,
873
+ 0.4370410891782674,
874
+ 0.4403450176951656,
875
+ 0.4436489462120638,
876
+ 0.4469528747289619,
877
+ 0.4502568032458601,
878
+ 0.4535607317627583,
879
+ 0.4568646602796565,
880
+ 0.46016858879655465,
881
+ 0.46347251731345285,
882
+ 0.466776445830351,
883
+ 0.47008037434724914,
884
+ 0.4733843028641473,
885
+ 0.47668823138104544,
886
+ 0.47999215989794364,
887
+ 0.4832960884148418,
888
+ 0.48660001693173993,
889
+ 0.48990394544863813,
890
+ 0.4932078739655363,
891
+ 0.4965118024824345,
892
+ 0.49981573099933263,
893
+ 0.5031196595162308,
894
+ 0.506423588033129,
895
+ 0.5097275165500272,
896
+ 0.5130314450669254,
897
+ 0.5163353735838236,
898
+ 0.5196393021007218,
899
+ 0.5295510876514165,
900
+ 0.539462873202111,
901
+ 0.5493746587528054,
902
+ 0.5592864443034999,
903
+ 0.5691982298541944,
904
+ 0.5791100154048889,
905
+ 0.5890218009555834,
906
+ 0.5989335865062779,
907
+ 0.6088453720569724,
908
+ 0.6187571576076669,
909
+ 0.6286689431583614,
910
+ 0.638580728709056,
911
+ 0.6484925142597505,
912
+ 0.658404299810445,
913
+ 0.6683160853611395,
914
+ 0.678227870911834,
915
+ 0.6881396564625285,
916
+ 0.698051442013223,
917
+ 0.7079632275639175,
918
+ 0.717875013114612,
919
+ 0.7277867986653065,
920
+ 0.737698584216001,
921
+ 0.7476103697666956,
922
+ 0.7575221553173901,
923
+ 0.7674339408680846,
924
+ 0.7773457264187791,
925
+ 0.7872575119694736,
926
+ 0.7971692975201681,
927
+ 0.8070810830708626,
928
+ 0.8169928686215571,
929
+ 0.8250858076345879,
930
+ 0.8331787466476188,
931
+ 0.8412716856606497,
932
+ 0.8493646246736806,
933
+ 0.8574575636867114,
934
+ 0.8655505026997423,
935
+ 0.8736434417127732,
936
+ 0.8817363807258041,
937
+ 0.889829319738835,
938
+ 0.8979222587518658,
939
+ 0.9060151977648967,
940
+ 0.9141081367779276,
941
+ 0.9222010757909584,
942
+ 0.9302940148039893,
943
+ 0.9383869538170202,
944
+ 0.9464798928300511,
945
+ 0.954572831843082,
946
+ 0.9626657708561128,
947
+ 0.9707587098691437,
948
+ 0.9788516488821746,
949
+ 0.9869445878952054,
950
+ 0.9950375269082363,
951
+ 1.0031304659212672,
952
+ 1.011223404934298,
953
+ 1.019316343947329,
954
+ 1.0274092829603598,
955
+ 1.0355022219733907,
956
+ 1.0435951609864216,
957
+ 1.0516880999994525,
958
+ 1.0597810390124833
959
+ ],
960
+ "x_hs": [
961
+ 0.0,
962
+ 0.28034763106251737,
963
+ 0.42052144659377644,
964
+ 0.5196393021007218,
965
+ 0.8169928686215571,
966
+ 1.0597810390124833
967
+ ]
968
+ }
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/element.dat ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 6
2
+ 6
3
+ 6
4
+ 6
5
+ 6
6
+ 6
7
+ 6
8
+ 6
9
+ 6
10
+ 6
11
+ 6
12
+ 6
13
+ 6
14
+ 6
15
+ 6
16
+ 6
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/graph.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cfd61a07726975702831d134fb49ee605708fd42a0300f839d3649014ffbeed3
3
+ size 66518065
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/hamiltonians.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fa8acd9782efa0e90adb8ac7925747b5c6802c49147e3247a746ff7cc2ff3946
3
+ size 4466069
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/hamiltonians_pred.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:93801ad1f05279316e1392ac835cfa5b06298eed9747ed0746058e19434932ca
3
+ size 4141696
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/info.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"isspinful": false}
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/lat.dat ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ 0.000000000000000000e+00 3.566999997713848014e+00 3.566999997713848014e+00
2
+ 3.566999997713848014e+00 0.000000000000000000e+00 3.566999997713848014e+00
3
+ 3.566999997713848014e+00 3.566999997713848014e+00 0.000000000000000000e+00
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/orbital_types.dat ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 0 0 1 1 2
2
+ 0 0 1 1 2
3
+ 0 0 1 1 2
4
+ 0 0 1 1 2
5
+ 0 0 1 1 2
6
+ 0 0 1 1 2
7
+ 0 0 1 1 2
8
+ 0 0 1 1 2
9
+ 0 0 1 1 2
10
+ 0 0 1 1 2
11
+ 0 0 1 1 2
12
+ 0 0 1 1 2
13
+ 0 0 1 1 2
14
+ 0 0 1 1 2
15
+ 0 0 1 1 2
16
+ 0 0 1 1 2
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/overlaps.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:69f8fb67509a2908d6fbcdc098aa26a8a4af716b76aebda4ff04b872cba43859
3
+ size 3986765
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/config.ini ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [basic]
2
+ graph_dir = /home/apolyukhin/scripts/ml/diamond-qe/deeph-data/graph
3
+ save_dir = /home/apolyukhin/scripts/ml/diamond-qe/pristine-222/reconstruction/aohamiltonian/pred_ham_std
4
+ raw_dir = /home/apolyukhin/scripts/ml/diamond-qe/deeph-data/preprocess
5
+ dataset_name = diamond_qe
6
+ only_get_graph = False
7
+ interface = h5
8
+ target = hamiltonian
9
+ disable_cuda = True
10
+ device = cpu
11
+ num_threads = -1
12
+ save_to_time_folder = False
13
+ save_csv = True
14
+ tb_writer = False
15
+ seed = 42
16
+ multiprocessing = 0
17
+ orbital = [{"6 6": [0, 0]}, {"6 6": [0, 1]}, {"6 6": [0, 2]}, {"6 6": [0, 3]}, {"6 6": [0, 4]}, {"6 6": [0, 5]}, {"6 6": [0, 6]}, {"6 6": [0, 7]}, {"6 6": [0, 8]}, {"6 6": [0, 9]}, {"6 6": [0, 10]}, {"6 6": [0, 11]}, {"6 6": [0, 12]}, {"6 6": [1, 0]}, {"6 6": [1, 1]}, {"6 6": [1, 2]}, {"6 6": [1, 3]}, {"6 6": [1, 4]}, {"6 6": [1, 5]}, {"6 6": [1, 6]}, {"6 6": [1, 7]}, {"6 6": [1, 8]}, {"6 6": [1, 9]}, {"6 6": [1, 10]}, {"6 6": [1, 11]}, {"6 6": [1, 12]}, {"6 6": [2, 0]}, {"6 6": [2, 1]}, {"6 6": [2, 2]}, {"6 6": [2, 3]}, {"6 6": [2, 4]}, {"6 6": [2, 5]}, {"6 6": [2, 6]}, {"6 6": [2, 7]}, {"6 6": [2, 8]}, {"6 6": [2, 9]}, {"6 6": [2, 10]}, {"6 6": [2, 11]}, {"6 6": [2, 12]}, {"6 6": [3, 0]}, {"6 6": [3, 1]}, {"6 6": [3, 2]}, {"6 6": [3, 3]}, {"6 6": [3, 4]}, {"6 6": [3, 5]}, {"6 6": [3, 6]}, {"6 6": [3, 7]}, {"6 6": [3, 8]}, {"6 6": [3, 9]}, {"6 6": [3, 10]}, {"6 6": [3, 11]}, {"6 6": [3, 12]}, {"6 6": [4, 0]}, {"6 6": [4, 1]}, {"6 6": [4, 2]}, {"6 6": [4, 3]}, {"6 6": [4, 4]}, {"6 6": [4, 5]}, {"6 6": [4, 6]}, {"6 6": [4, 7]}, {"6 6": [4, 8]}, {"6 6": [4, 9]}, {"6 6": [4, 10]}, {"6 6": [4, 11]}, {"6 6": [4, 12]}, {"6 6": [5, 0]}, {"6 6": [5, 1]}, {"6 6": [5, 2]}, {"6 6": [5, 3]}, {"6 6": [5, 4]}, {"6 6": [5, 5]}, {"6 6": [5, 6]}, {"6 6": [5, 7]}, {"6 6": [5, 8]}, {"6 6": [5, 9]}, {"6 6": [5, 10]}, {"6 6": [5, 11]}, {"6 6": [5, 12]}, {"6 6": [6, 0]}, {"6 6": [6, 1]}, {"6 6": [6, 2]}, {"6 6": [6, 3]}, {"6 6": [6, 4]}, {"6 6": [6, 5]}, {"6 6": [6, 6]}, {"6 6": [6, 7]}, {"6 6": [6, 8]}, {"6 6": [6, 9]}, {"6 6": [6, 10]}, {"6 6": [6, 11]}, {"6 6": [6, 12]}, {"6 6": [7, 0]}, {"6 6": [7, 1]}, {"6 6": [7, 2]}, {"6 6": [7, 3]}, {"6 6": [7, 4]}, {"6 6": [7, 5]}, {"6 6": [7, 6]}, {"6 6": [7, 7]}, {"6 6": [7, 8]}, {"6 6": [7, 9]}, {"6 6": [7, 10]}, {"6 6": [7, 11]}, {"6 6": [7, 12]}, {"6 6": [8, 0]}, {"6 6": [8, 1]}, {"6 6": [8, 2]}, {"6 6": [8, 3]}, {"6 6": [8, 4]}, {"6 6": [8, 5]}, {"6 6": [8, 6]}, {"6 6": [8, 7]}, {"6 6": [8, 8]}, {"6 6": [8, 9]}, {"6 6": [8, 10]}, {"6 6": [8, 11]}, {"6 6": [8, 12]}, {"6 6": [9, 0]}, {"6 6": [9, 1]}, {"6 6": [9, 2]}, {"6 6": [9, 3]}, {"6 6": [9, 4]}, {"6 6": [9, 5]}, {"6 6": [9, 6]}, {"6 6": [9, 7]}, {"6 6": [9, 8]}, {"6 6": [9, 9]}, {"6 6": [9, 10]}, {"6 6": [9, 11]}, {"6 6": [9, 12]}, {"6 6": [10, 0]}, {"6 6": [10, 1]}, {"6 6": [10, 2]}, {"6 6": [10, 3]}, {"6 6": [10, 4]}, {"6 6": [10, 5]}, {"6 6": [10, 6]}, {"6 6": [10, 7]}, {"6 6": [10, 8]}, {"6 6": [10, 9]}, {"6 6": [10, 10]}, {"6 6": [10, 11]}, {"6 6": [10, 12]}, {"6 6": [11, 0]}, {"6 6": [11, 1]}, {"6 6": [11, 2]}, {"6 6": [11, 3]}, {"6 6": [11, 4]}, {"6 6": [11, 5]}, {"6 6": [11, 6]}, {"6 6": [11, 7]}, {"6 6": [11, 8]}, {"6 6": [11, 9]}, {"6 6": [11, 10]}, {"6 6": [11, 11]}, {"6 6": [11, 12]}, {"6 6": [12, 0]}, {"6 6": [12, 1]}, {"6 6": [12, 2]}, {"6 6": [12, 3]}, {"6 6": [12, 4]}, {"6 6": [12, 5]}, {"6 6": [12, 6]}, {"6 6": [12, 7]}, {"6 6": [12, 8]}, {"6 6": [12, 9]}, {"6 6": [12, 10]}, {"6 6": [12, 11]}, {"6 6": [12, 12]}]
18
+ o_component = H
19
+ energy_component = summation
20
+ max_element = -1
21
+ statistics = False
22
+ normalizer = False
23
+ boxcox = False
24
+
25
+ [graph]
26
+ radius = -1.0
27
+ max_num_nbr = 0
28
+ create_from_dft = True
29
+ if_lcmp_graph = True
30
+ separate_onsite = False
31
+ new_sp = False
32
+
33
+ [train]
34
+ epochs = 5000
35
+ pretrained =
36
+ resume =
37
+ train_ratio = 0.6
38
+ val_ratio = 0.2
39
+ test_ratio = 0.2
40
+ early_stopping_loss = 0.0
41
+ early_stopping_loss_epoch = [0.000000, 500]
42
+ revert_then_decay = True
43
+ revert_threshold = 30
44
+ revert_decay_epoch = [800, 2000, 3000, 4000]
45
+ revert_decay_gamma = [0.4, 0.5, 0.5, 0.4]
46
+ clip_grad = True
47
+ clip_grad_value = 4.2
48
+ switch_sgd = False
49
+ switch_sgd_lr = 1e-4
50
+ switch_sgd_epoch = -1
51
+
52
+ [hyperparameter]
53
+ batch_size = 1
54
+ dtype = float32
55
+ optimizer = adam
56
+ learning_rate = 0.001
57
+ lr_scheduler =
58
+ lr_milestones = []
59
+ momentum = 0.9
60
+ weight_decay = 0
61
+ criterion = MaskMSELoss
62
+ retain_edge_fea = True
63
+ lambda_eij = 0.0
64
+ lambda_ei = 0.1
65
+ lambda_etot = 0.0
66
+
67
+ [network]
68
+ atom_fea_len = 64
69
+ edge_fea_len = 128
70
+ gauss_stop = 6.0
71
+ num_l = 4
72
+ aggr = add
73
+ distance_expansion = GaussianBasis
74
+ if_exp = True
75
+ if_multiplelinear = False
76
+ if_edge_update = True
77
+ if_lcmp = True
78
+ normalization = LayerNorm
79
+ atom_update_net = PAINN
80
+ trainable_gaussians = False
81
+ type_affine = False
82
+
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/result.txt ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ====== CONFIG ======
2
+ [basic]
3
+ graph_dir=/home/apolyukhin/scripts/ml/diamond-qe/deeph-data/graph
4
+ save_dir=/home/apolyukhin/scripts/ml/diamond-qe/pristine-222/reconstruction/aohamiltonian/pred_ham_std
5
+ raw_dir=/home/apolyukhin/scripts/ml/diamond-qe/deeph-data/preprocess
6
+ dataset_name=diamond_qe
7
+ only_get_graph=False
8
+ interface=h5
9
+ target=hamiltonian
10
+ disable_cuda=True
11
+ device=cpu
12
+ num_threads=-1
13
+ save_to_time_folder=False
14
+ save_csv=True
15
+ tb_writer=False
16
+ seed=42
17
+ multiprocessing=0
18
+ orbital=[{"6 6": [0, 0]}, {"6 6": [0, 1]}, {"6 6": [0, 2]}, {"6 6": [0, 3]}, {"6 6": [0, 4]}, {"6 6": [0, 5]}, {"6 6": [0, 6]}, {"6 6": [0, 7]}, {"6 6": [0, 8]}, {"6 6": [0, 9]}, {"6 6": [0, 10]}, {"6 6": [0, 11]}, {"6 6": [0, 12]}, {"6 6": [1, 0]}, {"6 6": [1, 1]}, {"6 6": [1, 2]}, {"6 6": [1, 3]}, {"6 6": [1, 4]}, {"6 6": [1, 5]}, {"6 6": [1, 6]}, {"6 6": [1, 7]}, {"6 6": [1, 8]}, {"6 6": [1, 9]}, {"6 6": [1, 10]}, {"6 6": [1, 11]}, {"6 6": [1, 12]}, {"6 6": [2, 0]}, {"6 6": [2, 1]}, {"6 6": [2, 2]}, {"6 6": [2, 3]}, {"6 6": [2, 4]}, {"6 6": [2, 5]}, {"6 6": [2, 6]}, {"6 6": [2, 7]}, {"6 6": [2, 8]}, {"6 6": [2, 9]}, {"6 6": [2, 10]}, {"6 6": [2, 11]}, {"6 6": [2, 12]}, {"6 6": [3, 0]}, {"6 6": [3, 1]}, {"6 6": [3, 2]}, {"6 6": [3, 3]}, {"6 6": [3, 4]}, {"6 6": [3, 5]}, {"6 6": [3, 6]}, {"6 6": [3, 7]}, {"6 6": [3, 8]}, {"6 6": [3, 9]}, {"6 6": [3, 10]}, {"6 6": [3, 11]}, {"6 6": [3, 12]}, {"6 6": [4, 0]}, {"6 6": [4, 1]}, {"6 6": [4, 2]}, {"6 6": [4, 3]}, {"6 6": [4, 4]}, {"6 6": [4, 5]}, {"6 6": [4, 6]}, {"6 6": [4, 7]}, {"6 6": [4, 8]}, {"6 6": [4, 9]}, {"6 6": [4, 10]}, {"6 6": [4, 11]}, {"6 6": [4, 12]}, {"6 6": [5, 0]}, {"6 6": [5, 1]}, {"6 6": [5, 2]}, {"6 6": [5, 3]}, {"6 6": [5, 4]}, {"6 6": [5, 5]}, {"6 6": [5, 6]}, {"6 6": [5, 7]}, {"6 6": [5, 8]}, {"6 6": [5, 9]}, {"6 6": [5, 10]}, {"6 6": [5, 11]}, {"6 6": [5, 12]}, {"6 6": [6, 0]}, {"6 6": [6, 1]}, {"6 6": [6, 2]}, {"6 6": [6, 3]}, {"6 6": [6, 4]}, {"6 6": [6, 5]}, {"6 6": [6, 6]}, {"6 6": [6, 7]}, {"6 6": [6, 8]}, {"6 6": [6, 9]}, {"6 6": [6, 10]}, {"6 6": [6, 11]}, {"6 6": [6, 12]}, {"6 6": [7, 0]}, {"6 6": [7, 1]}, {"6 6": [7, 2]}, {"6 6": [7, 3]}, {"6 6": [7, 4]}, {"6 6": [7, 5]}, {"6 6": [7, 6]}, {"6 6": [7, 7]}, {"6 6": [7, 8]}, {"6 6": [7, 9]}, {"6 6": [7, 10]}, {"6 6": [7, 11]}, {"6 6": [7, 12]}, {"6 6": [8, 0]}, {"6 6": [8, 1]}, {"6 6": [8, 2]}, {"6 6": [8, 3]}, {"6 6": [8, 4]}, {"6 6": [8, 5]}, {"6 6": [8, 6]}, {"6 6": [8, 7]}, {"6 6": [8, 8]}, {"6 6": [8, 9]}, {"6 6": [8, 10]}, {"6 6": [8, 11]}, {"6 6": [8, 12]}, {"6 6": [9, 0]}, {"6 6": [9, 1]}, {"6 6": [9, 2]}, {"6 6": [9, 3]}, {"6 6": [9, 4]}, {"6 6": [9, 5]}, {"6 6": [9, 6]}, {"6 6": [9, 7]}, {"6 6": [9, 8]}, {"6 6": [9, 9]}, {"6 6": [9, 10]}, {"6 6": [9, 11]}, {"6 6": [9, 12]}, {"6 6": [10, 0]}, {"6 6": [10, 1]}, {"6 6": [10, 2]}, {"6 6": [10, 3]}, {"6 6": [10, 4]}, {"6 6": [10, 5]}, {"6 6": [10, 6]}, {"6 6": [10, 7]}, {"6 6": [10, 8]}, {"6 6": [10, 9]}, {"6 6": [10, 10]}, {"6 6": [10, 11]}, {"6 6": [10, 12]}, {"6 6": [11, 0]}, {"6 6": [11, 1]}, {"6 6": [11, 2]}, {"6 6": [11, 3]}, {"6 6": [11, 4]}, {"6 6": [11, 5]}, {"6 6": [11, 6]}, {"6 6": [11, 7]}, {"6 6": [11, 8]}, {"6 6": [11, 9]}, {"6 6": [11, 10]}, {"6 6": [11, 11]}, {"6 6": [11, 12]}, {"6 6": [12, 0]}, {"6 6": [12, 1]}, {"6 6": [12, 2]}, {"6 6": [12, 3]}, {"6 6": [12, 4]}, {"6 6": [12, 5]}, {"6 6": [12, 6]}, {"6 6": [12, 7]}, {"6 6": [12, 8]}, {"6 6": [12, 9]}, {"6 6": [12, 10]}, {"6 6": [12, 11]}, {"6 6": [12, 12]}]
19
+ o_component=H
20
+ energy_component=summation
21
+ max_element=-1
22
+ statistics=False
23
+ normalizer=False
24
+ boxcox=False
25
+
26
+ [graph]
27
+ radius=-1.0
28
+ max_num_nbr=0
29
+ create_from_dft=True
30
+ if_lcmp_graph=True
31
+ separate_onsite=False
32
+ new_sp=False
33
+
34
+ [train]
35
+ epochs=5000
36
+ pretrained=
37
+ resume=
38
+ train_ratio=0.6
39
+ val_ratio=0.2
40
+ test_ratio=0.2
41
+ early_stopping_loss=0.0
42
+ early_stopping_loss_epoch=[0.000000, 500]
43
+ revert_then_decay=True
44
+ revert_threshold=30
45
+ revert_decay_epoch=[800, 2000, 3000, 4000]
46
+ revert_decay_gamma=[0.4, 0.5, 0.5, 0.4]
47
+ clip_grad=True
48
+ clip_grad_value=4.2
49
+ switch_sgd=False
50
+ switch_sgd_lr=1e-4
51
+ switch_sgd_epoch=-1
52
+
53
+ [hyperparameter]
54
+ batch_size=1
55
+ dtype=float32
56
+ optimizer=adam
57
+ learning_rate=0.001
58
+ lr_scheduler=
59
+ lr_milestones=[]
60
+ momentum=0.9
61
+ weight_decay=0
62
+ criterion=MaskMSELoss
63
+ retain_edge_fea=True
64
+ lambda_eij=0.0
65
+ lambda_ei=0.1
66
+ lambda_etot=0.0
67
+
68
+ [network]
69
+ atom_fea_len=64
70
+ edge_fea_len=128
71
+ gauss_stop=6.0
72
+ num_l=4
73
+ aggr=add
74
+ distance_expansion=GaussianBasis
75
+ if_exp=True
76
+ if_multiplelinear=False
77
+ if_edge_update=True
78
+ if_lcmp=True
79
+ normalization=LayerNorm
80
+ atom_update_net=PAINN
81
+ trainable_gaussians=False
82
+ type_affine=False
83
+
84
+ => load best checkpoint (epoch 1070)
85
+ => Atomic types: [6], spinful: False, the number of atomic types: 1.
86
+ Save processed graph to /home/apolyukhin/scripts/ml/diamond-qe/pristine-222/reconstruction/aohamiltonian/graph.pkl, cost 1.6528115272521973 seconds
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/__init__.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from .data import HData
2
+ from .model import HGNN, ExpBernsteinBasis
3
+ from .utils import print_args, Logger, MaskMSELoss, MaskMAELoss, write_ham_npz, write_ham, write_ham_h5, get_config, \
4
+ get_inference_config, get_preprocess_config
5
+ from .graph import Collater, collate_fn, get_graph, load_orbital_types
6
+ from .kernel import DeepHKernel
7
+ from .preprocess import get_rc, OijLoad, GetEEiEij, abacus_parse, siesta_parse
8
+ from .rotate import get_rh, rotate_back, Rotate, dtype_dict
9
+
10
+ __version__ = "0.2.2"
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (925 Bytes). View file
 
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/__pycache__/data.cpython-312.pyc ADDED
Binary file (12.2 kB). View file
 
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/__pycache__/graph.cpython-312.pyc ADDED
Binary file (71.1 kB). View file
 
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/__pycache__/kernel.cpython-312.pyc ADDED
Binary file (61.3 kB). View file
 
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/__pycache__/model.cpython-312.pyc ADDED
Binary file (38.4 kB). View file
 
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/__pycache__/rotate.cpython-312.pyc ADDED
Binary file (18.7 kB). View file
 
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/__pycache__/utils.cpython-312.pyc ADDED
Binary file (13.3 kB). View file
 
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/data.py ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import warnings
2
+ import os
3
+ import time
4
+ import tqdm
5
+
6
+ from pymatgen.core.structure import Structure
7
+ import numpy as np
8
+ import torch
9
+ from torch_geometric.data import InMemoryDataset
10
+ from pathos.multiprocessing import ProcessingPool as Pool
11
+
12
+ from .graph import get_graph
13
+
14
+
15
+ class HData(InMemoryDataset):
16
+ def __init__(self, raw_data_dir: str, graph_dir: str, interface: str, target: str,
17
+ dataset_name: str, multiprocessing: int, radius, max_num_nbr,
18
+ num_l, max_element, create_from_DFT, if_lcmp_graph, separate_onsite, new_sp,
19
+ default_dtype_torch, nums: int = None, transform=None, pre_transform=None, pre_filter=None):
20
+ """
21
+ when interface == 'h5',
22
+ raw_data_dir
23
+ ├── 00
24
+ │ ├──rh.h5 / rdm.h5
25
+ │ ├──rc.h5
26
+ │ ├──element.dat
27
+ │ ├──orbital_types.dat
28
+ │ ├──site_positions.dat
29
+ │ ├──lat.dat
30
+ │ └──info.json
31
+ ├── 01
32
+ │ ├──rh.h5 / rdm.h5
33
+ │ ├──rc.h5
34
+ │ ├──element.dat
35
+ │ ├──orbital_types.dat
36
+ │ ├──site_positions.dat
37
+ │ ├──lat.dat
38
+ │ └──info.json
39
+ ├── 02
40
+ │ ├──rh.h5 / rdm.h5
41
+ │ ├──rc.h5
42
+ │ ├──element.dat
43
+ │ ├──orbital_types.dat
44
+ │ ├──site_positions.dat
45
+ │ ├──lat.dat
46
+ │ └──info.json
47
+ ├── ...
48
+ """
49
+ self.raw_data_dir = raw_data_dir
50
+ assert dataset_name.find('-') == -1, '"-" can not be included in the dataset name'
51
+ if create_from_DFT:
52
+ way_create_graph = 'FromDFT'
53
+ else:
54
+ way_create_graph = f'{radius}r{max_num_nbr}mn'
55
+ if if_lcmp_graph:
56
+ lcmp_str = f'{num_l}l'
57
+ else:
58
+ lcmp_str = 'WithoutLCMP'
59
+ if separate_onsite is True:
60
+ onsite_str = '-SeparateOnsite'
61
+ else:
62
+ onsite_str = ''
63
+ if new_sp:
64
+ new_sp_str = '-NewSP'
65
+ else:
66
+ new_sp_str = ''
67
+ if target == 'hamiltonian':
68
+ title = 'HGraph'
69
+ else:
70
+ raise ValueError('Unknown prediction target: {}'.format(target))
71
+ graph_file_name = f'{title}-{interface}-{dataset_name}-{lcmp_str}-{way_create_graph}{onsite_str}{new_sp_str}.pkl'
72
+ self.data_file = os.path.join(graph_dir, graph_file_name)
73
+ os.makedirs(graph_dir, exist_ok=True)
74
+ self.data, self.slices = None, None
75
+ self.interface = interface
76
+ self.target = target
77
+ self.dataset_name = dataset_name
78
+ self.multiprocessing = multiprocessing
79
+ self.radius = radius
80
+ self.max_num_nbr = max_num_nbr
81
+ self.num_l = num_l
82
+ self.create_from_DFT = create_from_DFT
83
+ self.if_lcmp_graph = if_lcmp_graph
84
+ self.separate_onsite = separate_onsite
85
+ self.new_sp = new_sp
86
+ self.default_dtype_torch = default_dtype_torch
87
+
88
+ self.nums = nums
89
+ self.transform = transform
90
+ self.pre_transform = pre_transform
91
+ self.pre_filter = pre_filter
92
+ self.__indices__ = None
93
+ self.__data_list__ = None
94
+ self._indices = None
95
+ self._data_list = None
96
+
97
+ print(f'Graph data file: {graph_file_name}')
98
+ if os.path.exists(self.data_file):
99
+ print('Use existing graph data file')
100
+ else:
101
+ print('Process new data file......')
102
+ self.process()
103
+ begin = time.time()
104
+ try:
105
+ loaded_data = torch.load(self.data_file)
106
+ except AttributeError:
107
+ raise RuntimeError('Error in loading graph data file, try to delete it and generate the graph file with the current version of PyG')
108
+ if len(loaded_data) == 2:
109
+ warnings.warn('You are using the graph data file with an old version')
110
+ self.data, self.slices = loaded_data
111
+ self.info = {
112
+ "spinful": False,
113
+ "index_to_Z": torch.arange(max_element + 1),
114
+ "Z_to_index": torch.arange(max_element + 1),
115
+ }
116
+ elif len(loaded_data) == 3:
117
+ self.data, self.slices, tmp = loaded_data
118
+ if isinstance(tmp, dict):
119
+ self.info = tmp
120
+ print(f"Atomic types: {self.info['index_to_Z'].tolist()}")
121
+ else:
122
+ warnings.warn('You are using an old version of the graph data file')
123
+ self.info = {
124
+ "spinful": tmp,
125
+ "index_to_Z": torch.arange(max_element + 1),
126
+ "Z_to_index": torch.arange(max_element + 1),
127
+ }
128
+ print(f'Finish loading the processed {len(self)} structures (spinful: {self.info["spinful"]}, '
129
+ f'the number of atomic types: {len(self.info["index_to_Z"])}), cost {time.time() - begin:.0f} seconds')
130
+
131
+ def process_worker(self, folder, **kwargs):
132
+ stru_id = os.path.split(folder)[-1]
133
+
134
+ structure = Structure(np.loadtxt(os.path.join(folder, 'lat.dat')).T,
135
+ np.loadtxt(os.path.join(folder, 'element.dat')),
136
+ np.loadtxt(os.path.join(folder, 'site_positions.dat')).T,
137
+ coords_are_cartesian=True,
138
+ to_unit_cell=False)
139
+
140
+ cart_coords = torch.tensor(structure.cart_coords, dtype=self.default_dtype_torch)
141
+ frac_coords = torch.tensor(structure.frac_coords, dtype=self.default_dtype_torch)
142
+ numbers = torch.tensor(structure.atomic_numbers)
143
+ structure.lattice.matrix.setflags(write=True)
144
+ lattice = torch.tensor(structure.lattice.matrix, dtype=self.default_dtype_torch)
145
+ if self.target == 'E_ij':
146
+ huge_structure = True
147
+ else:
148
+ huge_structure = False
149
+ return get_graph(cart_coords, frac_coords, numbers, stru_id, r=self.radius, max_num_nbr=self.max_num_nbr,
150
+ numerical_tol=1e-8, lattice=lattice, default_dtype_torch=self.default_dtype_torch,
151
+ tb_folder=folder, interface=self.interface, num_l=self.num_l,
152
+ create_from_DFT=self.create_from_DFT, if_lcmp_graph=self.if_lcmp_graph,
153
+ separate_onsite=self.separate_onsite,
154
+ target=self.target, huge_structure=huge_structure, if_new_sp=self.new_sp, **kwargs)
155
+
156
+ def process(self):
157
+ begin = time.time()
158
+ folder_list = []
159
+ for root, dirs, files in os.walk(self.raw_data_dir):
160
+ if (self.interface == 'h5' and 'rc.h5' in files) or (
161
+ self.interface == 'npz' and 'rc.npz' in files):
162
+ folder_list.append(root)
163
+ folder_list = sorted(folder_list)
164
+ folder_list = folder_list[: self.nums]
165
+ if self.dataset_name == 'graphene_450':
166
+ folder_list = folder_list[500:5000:10]
167
+ if self.dataset_name == 'graphene_1500':
168
+ folder_list = folder_list[500:5000:3]
169
+ if self.dataset_name == 'bp_bilayer':
170
+ folder_list = folder_list[:600]
171
+ assert len(folder_list) != 0, "Can not find any structure"
172
+ print('Found %d structures, have cost %d seconds' % (len(folder_list), time.time() - begin))
173
+
174
+ if self.multiprocessing == 0:
175
+ print(f'Use multiprocessing (nodes = num_processors x num_threads = 1 x {torch.get_num_threads()})')
176
+ data_list = [self.process_worker(folder) for folder in tqdm.tqdm(folder_list)]
177
+ else:
178
+ pool_dict = {} if self.multiprocessing < 0 else {'nodes': self.multiprocessing}
179
+ # BS (2023.06.06):
180
+ # The keyword "num_threads" in kernel.py can be used to set the torch threads.
181
+ # The multiprocessing in the "process_worker" is in contradiction with the num_threads utilized in torch.
182
+ # To avoid this conflict, I limit the number of torch threads to one,
183
+ # and recover it when finishing the process_worker.
184
+ torch_num_threads = torch.get_num_threads()
185
+ torch.set_num_threads(1)
186
+
187
+ with Pool(**pool_dict) as pool:
188
+ nodes = pool.nodes
189
+ print(f'Use multiprocessing (nodes = num_processors x num_threads = {nodes} x {torch.get_num_threads()})')
190
+ data_list = list(tqdm.tqdm(pool.imap(self.process_worker, folder_list), total=len(folder_list)))
191
+ torch.set_num_threads(torch_num_threads)
192
+ print('Finish processing %d structures, have cost %d seconds' % (len(data_list), time.time() - begin))
193
+
194
+ if self.pre_filter is not None:
195
+ data_list = [d for d in data_list if self.pre_filter(d)]
196
+ if self.pre_transform is not None:
197
+ data_list = [self.pre_transform(d) for d in data_list]
198
+
199
+ index_to_Z, Z_to_index = self.element_statistics(data_list)
200
+ spinful = data_list[0].spinful
201
+ for d in data_list:
202
+ assert spinful == d.spinful
203
+
204
+ data, slices = self.collate(data_list)
205
+ torch.save((data, slices, dict(spinful=spinful, index_to_Z=index_to_Z, Z_to_index=Z_to_index)), self.data_file)
206
+ print('Finish saving %d structures to %s, have cost %d seconds' % (
207
+ len(data_list), self.data_file, time.time() - begin))
208
+
209
+ def element_statistics(self, data_list):
210
+ index_to_Z, inverse_indices = torch.unique(data_list[0].x, sorted=True, return_inverse=True)
211
+ Z_to_index = torch.full((100,), -1, dtype=torch.int64)
212
+ Z_to_index[index_to_Z] = torch.arange(len(index_to_Z))
213
+
214
+ for data in data_list:
215
+ data.x = Z_to_index[data.x]
216
+
217
+ return index_to_Z, Z_to_index
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/default.ini ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [basic]
2
+ graph_dir = /your/own/path
3
+ save_dir = /your/own/path
4
+ raw_dir = /your/own/path
5
+ dataset_name = your_own_name
6
+ only_get_graph = False
7
+ ;choices = ['h5', 'npz']
8
+ interface = h5
9
+ target = hamiltonian
10
+ disable_cuda = False
11
+ device = cuda:0
12
+ ;-1 for cpu_count(logical=False) // torch.cuda.device_count()
13
+ num_threads = -1
14
+ save_to_time_folder = True
15
+ save_csv = False
16
+ tb_writer = True
17
+ seed = 42
18
+ multiprocessing = 0
19
+ orbital = [{"6 6": [0, 0]}, {"6 6": [0, 1]}, {"6 6": [0, 2]}, {"6 6": [0, 3]}, {"6 6": [0, 4]}, {"6 6": [0, 5]}, {"6 6": [0, 6]}, {"6 6": [0, 7]}, {"6 6": [0, 8]}, {"6 6": [0, 9]}, {"6 6": [0, 10]}, {"6 6": [0, 11]}, {"6 6": [0, 12]}, {"6 6": [1, 0]}, {"6 6": [1, 1]}, {"6 6": [1, 2]}, {"6 6": [1, 3]}, {"6 6": [1, 4]}, {"6 6": [1, 5]}, {"6 6": [1, 6]}, {"6 6": [1, 7]}, {"6 6": [1, 8]}, {"6 6": [1, 9]}, {"6 6": [1, 10]}, {"6 6": [1, 11]}, {"6 6": [1, 12]}, {"6 6": [2, 0]}, {"6 6": [2, 1]}, {"6 6": [2, 2]}, {"6 6": [2, 3]}, {"6 6": [2, 4]}, {"6 6": [2, 5]}, {"6 6": [2, 6]}, {"6 6": [2, 7]}, {"6 6": [2, 8]}, {"6 6": [2, 9]}, {"6 6": [2, 10]}, {"6 6": [2, 11]}, {"6 6": [2, 12]}, {"6 6": [3, 0]}, {"6 6": [3, 1]}, {"6 6": [3, 2]}, {"6 6": [3, 3]}, {"6 6": [3, 4]}, {"6 6": [3, 5]}, {"6 6": [3, 6]}, {"6 6": [3, 7]}, {"6 6": [3, 8]}, {"6 6": [3, 9]}, {"6 6": [3, 10]}, {"6 6": [3, 11]}, {"6 6": [3, 12]}, {"6 6": [4, 0]}, {"6 6": [4, 1]}, {"6 6": [4, 2]}, {"6 6": [4, 3]}, {"6 6": [4, 4]}, {"6 6": [4, 5]}, {"6 6": [4, 6]}, {"6 6": [4, 7]}, {"6 6": [4, 8]}, {"6 6": [4, 9]}, {"6 6": [4, 10]}, {"6 6": [4, 11]}, {"6 6": [4, 12]}, {"6 6": [5, 0]}, {"6 6": [5, 1]}, {"6 6": [5, 2]}, {"6 6": [5, 3]}, {"6 6": [5, 4]}, {"6 6": [5, 5]}, {"6 6": [5, 6]}, {"6 6": [5, 7]}, {"6 6": [5, 8]}, {"6 6": [5, 9]}, {"6 6": [5, 10]}, {"6 6": [5, 11]}, {"6 6": [5, 12]}, {"6 6": [6, 0]}, {"6 6": [6, 1]}, {"6 6": [6, 2]}, {"6 6": [6, 3]}, {"6 6": [6, 4]}, {"6 6": [6, 5]}, {"6 6": [6, 6]}, {"6 6": [6, 7]}, {"6 6": [6, 8]}, {"6 6": [6, 9]}, {"6 6": [6, 10]}, {"6 6": [6, 11]}, {"6 6": [6, 12]}, {"6 6": [7, 0]}, {"6 6": [7, 1]}, {"6 6": [7, 2]}, {"6 6": [7, 3]}, {"6 6": [7, 4]}, {"6 6": [7, 5]}, {"6 6": [7, 6]}, {"6 6": [7, 7]}, {"6 6": [7, 8]}, {"6 6": [7, 9]}, {"6 6": [7, 10]}, {"6 6": [7, 11]}, {"6 6": [7, 12]}, {"6 6": [8, 0]}, {"6 6": [8, 1]}, {"6 6": [8, 2]}, {"6 6": [8, 3]}, {"6 6": [8, 4]}, {"6 6": [8, 5]}, {"6 6": [8, 6]}, {"6 6": [8, 7]}, {"6 6": [8, 8]}, {"6 6": [8, 9]}, {"6 6": [8, 10]}, {"6 6": [8, 11]}, {"6 6": [8, 12]}, {"6 6": [9, 0]}, {"6 6": [9, 1]}, {"6 6": [9, 2]}, {"6 6": [9, 3]}, {"6 6": [9, 4]}, {"6 6": [9, 5]}, {"6 6": [9, 6]}, {"6 6": [9, 7]}, {"6 6": [9, 8]}, {"6 6": [9, 9]}, {"6 6": [9, 10]}, {"6 6": [9, 11]}, {"6 6": [9, 12]}, {"6 6": [10, 0]}, {"6 6": [10, 1]}, {"6 6": [10, 2]}, {"6 6": [10, 3]}, {"6 6": [10, 4]}, {"6 6": [10, 5]}, {"6 6": [10, 6]}, {"6 6": [10, 7]}, {"6 6": [10, 8]}, {"6 6": [10, 9]}, {"6 6": [10, 10]}, {"6 6": [10, 11]}, {"6 6": [10, 12]}, {"6 6": [11, 0]}, {"6 6": [11, 1]}, {"6 6": [11, 2]}, {"6 6": [11, 3]}, {"6 6": [11, 4]}, {"6 6": [11, 5]}, {"6 6": [11, 6]}, {"6 6": [11, 7]}, {"6 6": [11, 8]}, {"6 6": [11, 9]}, {"6 6": [11, 10]}, {"6 6": [11, 11]}, {"6 6": [11, 12]}, {"6 6": [12, 0]}, {"6 6": [12, 1]}, {"6 6": [12, 2]}, {"6 6": [12, 3]}, {"6 6": [12, 4]}, {"6 6": [12, 5]}, {"6 6": [12, 6]}, {"6 6": [12, 7]}, {"6 6": [12, 8]}, {"6 6": [12, 9]}, {"6 6": [12, 10]}, {"6 6": [12, 11]}, {"6 6": [12, 12]}]
20
+ O_component = H
21
+ energy_component = summation
22
+ max_element = -1
23
+ statistics = False
24
+ normalizer = False
25
+ boxcox = False
26
+
27
+ [graph]
28
+ radius = -1.0
29
+ max_num_nbr = 0
30
+ create_from_DFT = True
31
+ if_lcmp_graph = True
32
+ separate_onsite = False
33
+ new_sp = False
34
+
35
+ [train]
36
+ epochs = 4000
37
+ pretrained =
38
+ resume =
39
+ train_ratio = 0.6
40
+ val_ratio = 0.2
41
+ test_ratio = 0.2
42
+ early_stopping_loss = 0.0
43
+ early_stopping_loss_epoch = [0.000000, 500]
44
+ revert_then_decay = True
45
+ revert_threshold = 30
46
+ revert_decay_epoch = [500, 2000, 3000]
47
+ revert_decay_gamma = [0.4, 0.5, 0.5]
48
+ clip_grad = True
49
+ clip_grad_value = 4.2
50
+ switch_sgd = False
51
+ switch_sgd_lr = 1e-4
52
+ switch_sgd_epoch = -1
53
+
54
+ [hyperparameter]
55
+ batch_size = 3
56
+ dtype = float32
57
+ ;choices = ['sgd', 'sgdm', 'adam', 'lbfgs']
58
+ optimizer = adam
59
+ ;initial learning rate
60
+ learning_rate = 0.001
61
+ ;choices = ['', 'MultiStepLR', 'ReduceLROnPlateau', 'CyclicLR']
62
+ lr_scheduler =
63
+ lr_milestones = []
64
+ momentum = 0.9
65
+ weight_decay = 0
66
+ criterion = MaskMSELoss
67
+ retain_edge_fea = True
68
+ lambda_Eij = 0.0
69
+ lambda_Ei = 0.1
70
+ lambda_Etot = 0.0
71
+
72
+ [network]
73
+ atom_fea_len = 64
74
+ edge_fea_len = 128
75
+ gauss_stop = 6
76
+ ;The number of angular quantum numbers that spherical harmonic functions have
77
+ num_l = 5
78
+ aggr = add
79
+ distance_expansion = GaussianBasis
80
+ if_exp = True
81
+ if_MultipleLinear = False
82
+ if_edge_update = True
83
+ if_lcmp = True
84
+ normalization = LayerNorm
85
+ ;choices = ['CGConv', 'GAT', 'PAINN']
86
+ atom_update_net = CGConv
87
+ trainable_gaussians = False
88
+ type_affine = False
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_HermNet/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from .rmnet import RBF, cosine_cutoff, ShiftedSoftplus, _eps
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_HermNet/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (263 Bytes). View file
 
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_HermNet/__pycache__/rmnet.cpython-312.pyc ADDED
Binary file (4.67 kB). View file
 
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_HermNet/license.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ The code in this folder was obtained from "https://github.com/sakuraiiiii/HermNet"
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_HermNet/rmnet.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import math
2
+
3
+ import torch
4
+ from torch import nn, Tensor
5
+ import numpy as np
6
+
7
+
8
+ _eps = 1e-3
9
+
10
+ r"""Tricks: Introducing the parameter `_eps` is to avoid NaN.
11
+ In HVNet and HTNet, a subgraph will be extracted to calculate angles.
12
+ And with all the nodes still be included in the subgraph,
13
+ each hidden state in such a subgraph will contain 0 value.
14
+ In `painn`, the calculation w.r.t $r / \parallel r \parallel$ will be taken.
15
+ If just alternate $r / \parallel r \parallel$ with $r / (\parallel r \parallel + _eps)$,
16
+ NaN will still occur in during the training.
17
+ Considering the following example,
18
+ $$
19
+ (\frac{x}{r+_eps})^\prime = \frac{r+b-\frac{x^2}{r}}{(r+b)^2}
20
+ $$
21
+ where $r = \sqrt{x^2+y^2+z^2}$. It is obvious that NaN will occur.
22
+ Thus the solution is change the norm $r$ as $r^\prime = \sqrt(x^2+y^2+z^2+_eps)$.
23
+ Since $r$ is rotational invariant, $r^2$ is rotational invariant.
24
+ Obviously, $\sqrt(r^2 + _eps)$ is rotational invariant.
25
+ """
26
+ class RBF(nn.Module):
27
+ r"""Radial basis function.
28
+ A modified version of feature engineering in `DimeNet`,
29
+ which is used in `PAINN`.
30
+
31
+ Parameters
32
+ ----------
33
+ rc : float
34
+ Cutoff radius
35
+ l : int
36
+ Parameter in feature engineering in DimeNet
37
+ """
38
+ def __init__(self, rc: float, l: int):
39
+ super(RBF, self).__init__()
40
+ self.rc = rc
41
+ self.l = l
42
+
43
+ def forward(self, x: Tensor):
44
+ ls = torch.arange(1, self.l + 1).float().to(x.device)
45
+ norm = torch.sqrt((x ** 2).sum(dim=-1) + _eps).unsqueeze(-1)
46
+ return torch.sin(math.pi / self.rc * norm@ls.unsqueeze(0)) / norm
47
+
48
+
49
+ class cosine_cutoff(nn.Module):
50
+ r"""Cutoff function in https://aip.scitation.org/doi/pdf/10.1063/1.3553717.
51
+
52
+ Parameters
53
+ ----------
54
+ rc : float
55
+ Cutoff radius
56
+ """
57
+ def __init__(self, rc: float):
58
+ super(cosine_cutoff, self).__init__()
59
+ self.rc = rc
60
+
61
+ def forward(self, x: Tensor):
62
+ norm = torch.norm(x, dim=-1, keepdim=True) + _eps
63
+ return 0.5 * (torch.cos(math.pi * norm / self.rc) + 1)
64
+
65
+ class ShiftedSoftplus(nn.Module):
66
+ r"""
67
+
68
+ Description
69
+ -----------
70
+ Applies the element-wise function:
71
+
72
+ .. math::
73
+ \text{SSP}(x) = \frac{1}{\beta} * \log(1 + \exp(\beta * x)) - \log(\text{shift})
74
+
75
+ Attributes
76
+ ----------
77
+ beta : int
78
+ :math:`\beta` value for the mathematical formulation. Default to 1.
79
+ shift : int
80
+ :math:`\text{shift}` value for the mathematical formulation. Default to 2.
81
+ """
82
+ def __init__(self, beta=1, shift=2, threshold=20):
83
+ super(ShiftedSoftplus, self).__init__()
84
+
85
+ self.shift = shift
86
+ self.softplus = nn.Softplus(beta=beta, threshold=threshold)
87
+
88
+ def forward(self, inputs):
89
+ """
90
+
91
+ Description
92
+ -----------
93
+ Applies the activation function.
94
+
95
+ Parameters
96
+ ----------
97
+ inputs : float32 tensor of shape (N, *)
98
+ * denotes any number of additional dimensions.
99
+
100
+ Returns
101
+ -------
102
+ float32 tensor of shape (N, *)
103
+ Result of applying the activation function to the input.
104
+ """
105
+ return self.softplus(inputs) - np.log(float(self.shift))
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_PyG_future/__init__.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ from .graph_norm import GraphNorm
2
+ from .diff_group_norm import DiffGroupNorm
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_PyG_future/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (263 Bytes). View file
 
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_PyG_future/__pycache__/diff_group_norm.cpython-312.pyc ADDED
Binary file (6.43 kB). View file
 
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_PyG_future/__pycache__/graph_norm.cpython-312.pyc ADDED
Binary file (3.76 kB). View file
 
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_PyG_future/diff_group_norm.py ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from torch import Tensor
3
+ from torch.nn import Linear, BatchNorm1d
4
+
5
+
6
+ class DiffGroupNorm(torch.nn.Module):
7
+ r"""The differentiable group normalization layer from the `"Towards Deeper
8
+ Graph Neural Networks with Differentiable Group Normalization"
9
+ <https://arxiv.org/abs/2006.06972>`_ paper, which normalizes node features
10
+ group-wise via a learnable soft cluster assignment
11
+
12
+ .. math::
13
+
14
+ \mathbf{S} = \text{softmax} (\mathbf{X} \mathbf{W})
15
+
16
+ where :math:`\mathbf{W} \in \mathbb{R}^{F \times G}` denotes a trainable
17
+ weight matrix mapping each node into one of :math:`G` clusters.
18
+ Normalization is then performed group-wise via:
19
+
20
+ .. math::
21
+
22
+ \mathbf{X}^{\prime} = \mathbf{X} + \lambda \sum_{i = 1}^G
23
+ \text{BatchNorm}(\mathbf{S}[:, i] \odot \mathbf{X})
24
+
25
+ Args:
26
+ in_channels (int): Size of each input sample :math:`F`.
27
+ groups (int): The number of groups :math:`G`.
28
+ lamda (float, optional): The balancing factor :math:`\lambda` between
29
+ input embeddings and normalized embeddings. (default: :obj:`0.01`)
30
+ eps (float, optional): A value added to the denominator for numerical
31
+ stability. (default: :obj:`1e-5`)
32
+ momentum (float, optional): The value used for the running mean and
33
+ running variance computation. (default: :obj:`0.1`)
34
+ affine (bool, optional): If set to :obj:`True`, this module has
35
+ learnable affine parameters :math:`\gamma` and :math:`\beta`.
36
+ (default: :obj:`True`)
37
+ track_running_stats (bool, optional): If set to :obj:`True`, this
38
+ module tracks the running mean and variance, and when set to
39
+ :obj:`False`, this module does not track such statistics and always
40
+ uses batch statistics in both training and eval modes.
41
+ (default: :obj:`True`)
42
+ """
43
+ def __init__(self, in_channels, groups, lamda=0.01, eps=1e-5, momentum=0.1,
44
+ affine=True, track_running_stats=True):
45
+ super(DiffGroupNorm, self).__init__()
46
+
47
+ self.in_channels = in_channels
48
+ self.groups = groups
49
+ self.lamda = lamda
50
+
51
+ self.lin = Linear(in_channels, groups, bias=False)
52
+ self.norm = BatchNorm1d(groups * in_channels, eps, momentum, affine,
53
+ track_running_stats)
54
+
55
+ self.reset_parameters()
56
+
57
+ def reset_parameters(self):
58
+ self.lin.reset_parameters()
59
+ self.norm.reset_parameters()
60
+
61
+ def forward(self, x: Tensor) -> Tensor:
62
+ """"""
63
+ F, G = self.in_channels, self.groups
64
+
65
+ s = self.lin(x).softmax(dim=-1) # [N, G]
66
+ out = s.unsqueeze(-1) * x.unsqueeze(-2) # [N, G, F]
67
+ out = self.norm(out.view(-1, G * F)).view(-1, G, F).sum(-2) # [N, F]
68
+
69
+ return x + self.lamda * out
70
+
71
+ @staticmethod
72
+ def group_distance_ratio(x: Tensor, y: Tensor, eps: float = 1e-5) -> float:
73
+ r"""Measures the ratio of inter-group distance over intra-group
74
+ distance
75
+
76
+ .. math::
77
+ R_{\text{Group}} = \frac{\frac{1}{(C-1)^2} \sum_{i!=j}
78
+ \frac{1}{|\mathbf{X}_i||\mathbf{X}_j|} \sum_{\mathbf{x}_{iv}
79
+ \in \mathbf{X}_i } \sum_{\mathbf{x}_{jv^{\prime}} \in \mathbf{X}_j}
80
+ {\| \mathbf{x}_{iv} - \mathbf{x}_{jv^{\prime}} \|}_2 }{
81
+ \frac{1}{C} \sum_{i} \frac{1}{{|\mathbf{X}_i|}^2}
82
+ \sum_{\mathbf{x}_{iv}, \mathbf{x}_{iv^{\prime}} \in \mathbf{X}_i }
83
+ {\| \mathbf{x}_{iv} - \mathbf{x}_{iv^{\prime}} \|}_2 }
84
+
85
+ where :math:`\mathbf{X}_i` denotes the set of all nodes that belong to
86
+ class :math:`i`, and :math:`C` denotes the total number of classes in
87
+ :obj:`y`.
88
+ """
89
+ num_classes = int(y.max()) + 1
90
+
91
+ numerator = 0.
92
+ for i in range(num_classes):
93
+ mask = y == i
94
+ dist = torch.cdist(x[mask].unsqueeze(0), x[~mask].unsqueeze(0))
95
+ numerator += (1 / dist.numel()) * float(dist.sum())
96
+ numerator *= 1 / (num_classes - 1)**2
97
+
98
+ denominator = 0.
99
+ for i in range(num_classes):
100
+ mask = y == i
101
+ dist = torch.cdist(x[mask].unsqueeze(0), x[mask].unsqueeze(0))
102
+ denominator += (1 / dist.numel()) * float(dist.sum())
103
+ denominator *= 1 / num_classes
104
+
105
+ return numerator / (denominator + eps)
106
+
107
+ def __repr__(self):
108
+ return '{}({}, groups={})'.format(self.__class__.__name__,
109
+ self.in_channels, self.groups)
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_PyG_future/graph_norm.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Optional
2
+
3
+ import torch
4
+ from torch import Tensor
5
+ from torch_scatter import scatter_mean
6
+
7
+ from torch_geometric.nn.inits import zeros, ones
8
+
9
+
10
+ class GraphNorm(torch.nn.Module):
11
+ r"""Applies graph normalization over individual graphs as described in the
12
+ `"GraphNorm: A Principled Approach to Accelerating Graph Neural Network
13
+ Training" <https://arxiv.org/abs/2009.03294>`_ paper
14
+
15
+ .. math::
16
+ \mathbf{x}^{\prime}_i = \frac{\mathbf{x} - \alpha \odot
17
+ \textrm{E}[\mathbf{x}]}
18
+ {\sqrt{\textrm{Var}[\mathbf{x} - \alpha \odot \textrm{E}[\mathbf{x}]]
19
+ + \epsilon}} \odot \gamma + \beta
20
+
21
+ where :math:`\alpha` denotes parameters that learn how much information
22
+ to keep in the mean.
23
+
24
+ Args:
25
+ in_channels (int): Size of each input sample.
26
+ eps (float, optional): A value added to the denominator for numerical
27
+ stability. (default: :obj:`1e-5`)
28
+ """
29
+ def __init__(self, in_channels: int, eps: float = 1e-5):
30
+ super(GraphNorm, self).__init__()
31
+
32
+ self.in_channels = in_channels
33
+ self.eps = eps
34
+
35
+ self.weight = torch.nn.Parameter(torch.Tensor(in_channels))
36
+ self.bias = torch.nn.Parameter(torch.Tensor(in_channels))
37
+ self.mean_scale = torch.nn.Parameter(torch.Tensor(in_channels))
38
+
39
+ self.reset_parameters()
40
+
41
+ def reset_parameters(self):
42
+ ones(self.weight)
43
+ zeros(self.bias)
44
+ ones(self.mean_scale)
45
+
46
+ def forward(self, x: Tensor, batch: Optional[Tensor] = None) -> Tensor:
47
+ """"""
48
+ if batch is None:
49
+ batch = x.new_zeros(x.size(0), dtype=torch.long)
50
+
51
+ batch_size = int(batch.max()) + 1
52
+
53
+ mean = scatter_mean(x, batch, dim=0, dim_size=batch_size)[batch]
54
+ out = x - mean * self.mean_scale
55
+ var = scatter_mean(out.pow(2), batch, dim=0, dim_size=batch_size)
56
+ std = (var + self.eps).sqrt()[batch]
57
+ return self.weight * out / std + self.bias
58
+
59
+ def __repr__(self):
60
+ return f'{self.__class__.__name__}({self.in_channels})'
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_PyG_future/license.txt ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The code in this folder was obtained from "https://github.com/rusty1s/pytorch_geometric", which has the following license:
2
+
3
+
4
+ Copyright (c) 2020 Matthias Fey <matthias.fey@tu-dortmund.de>
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_pymatgen/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from .lattice import find_neighbors, _one_to_three, _compute_cube_index, _three_to_one
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_pymatgen/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (290 Bytes). View file
 
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_pymatgen/__pycache__/lattice.cpython-312.pyc ADDED
Binary file (3.65 kB). View file
 
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_pymatgen/lattice.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import itertools
2
+ import numpy as np
3
+
4
+
5
+ # The following internal methods are used in the get_points_in_sphere method.
6
+ def _compute_cube_index(coords: np.ndarray, global_min: float, radius: float
7
+ ) -> np.ndarray:
8
+ """
9
+ Compute the cube index from coordinates
10
+ Args:
11
+ coords: (nx3 array) atom coordinates
12
+ global_min: (float) lower boundary of coordinates
13
+ radius: (float) cutoff radius
14
+
15
+ Returns: (nx3 array) int indices
16
+
17
+ """
18
+ return np.array(np.floor((coords - global_min) / radius), dtype=int)
19
+
20
+ def _three_to_one(label3d: np.ndarray, ny: int, nz: int) -> np.ndarray:
21
+ """
22
+ The reverse of _one_to_three
23
+ """
24
+ return np.array(label3d[:, 0] * ny * nz +
25
+ label3d[:, 1] * nz + label3d[:, 2]).reshape((-1, 1))
26
+
27
+ def _one_to_three(label1d: np.ndarray, ny: int, nz: int) -> np.ndarray:
28
+ """
29
+ Convert a 1D index array to 3D index array
30
+
31
+ Args:
32
+ label1d: (array) 1D index array
33
+ ny: (int) number of cells in y direction
34
+ nz: (int) number of cells in z direction
35
+
36
+ Returns: (nx3) int array of index
37
+
38
+ """
39
+ last = np.mod(label1d, nz)
40
+ second = np.mod((label1d - last) / nz, ny)
41
+ first = (label1d - last - second * nz) / (ny * nz)
42
+ return np.concatenate([first, second, last], axis=1)
43
+
44
+ def find_neighbors(label: np.ndarray, nx: int, ny: int, nz: int):
45
+ """
46
+ Given a cube index, find the neighbor cube indices
47
+
48
+ Args:
49
+ label: (array) (n,) or (n x 3) indice array
50
+ nx: (int) number of cells in y direction
51
+ ny: (int) number of cells in y direction
52
+ nz: (int) number of cells in z direction
53
+
54
+ Returns: neighbor cell indices
55
+
56
+ """
57
+
58
+ array = [[-1, 0, 1]] * 3
59
+ neighbor_vectors = np.array(list(itertools.product(*array)),
60
+ dtype=int)
61
+ if np.shape(label)[1] == 1:
62
+ label3d = _one_to_three(label, ny, nz)
63
+ else:
64
+ label3d = label
65
+ all_labels = label3d[:, None, :] - neighbor_vectors[None, :, :]
66
+ filtered_labels = []
67
+ # filter out out-of-bound labels i.e., label < 0
68
+ for labels in all_labels:
69
+ ind = (labels[:, 0] < nx) * (labels[:, 1] < ny) * (labels[:, 2] < nz) * np.all(labels > -1e-5, axis=1)
70
+ filtered_labels.append(labels[ind])
71
+ return filtered_labels
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_pymatgen/license.txt ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The code in this folder was obtained from "https://github.com/materialsproject/pymatgen", which has the following license:
2
+
3
+
4
+ The MIT License (MIT)
5
+ Copyright (c) 2011-2012 MIT & The Regents of the University of California, through Lawrence Berkeley National Laboratory
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
8
+ this software and associated documentation files (the "Software"), to deal in
9
+ the Software without restriction, including without limitation the rights to
10
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11
+ the Software, and to permit persons to whom the Software is furnished to do so,
12
+ subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_schnetpack/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from .acsf import GaussianBasis
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_schnetpack/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (207 Bytes). View file
 
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_schnetpack/__pycache__/acsf.cpython-312.pyc ADDED
Binary file (2.45 kB). View file
 
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_schnetpack/acsf.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from torch import nn
3
+
4
+
5
+ def gaussian_smearing(distances, offset, widths, centered=False):
6
+ if not centered:
7
+ # compute width of Gaussian functions (using an overlap of 1 STDDEV)
8
+ coeff = -0.5 / torch.pow(widths, 2)
9
+ # Use advanced indexing to compute the individual components
10
+ diff = distances[..., None] - offset
11
+ else:
12
+ # if Gaussian functions are centered, use offsets to compute widths
13
+ coeff = -0.5 / torch.pow(offset, 2)
14
+ # if Gaussian functions are centered, no offset is subtracted
15
+ diff = distances[..., None]
16
+ # compute smear distance values
17
+ gauss = torch.exp(coeff * torch.pow(diff, 2))
18
+ return gauss
19
+
20
+
21
+ class GaussianBasis(nn.Module):
22
+ def __init__(
23
+ self, start=0.0, stop=5.0, n_gaussians=50, centered=False, trainable=False
24
+ ):
25
+ super(GaussianBasis, self).__init__()
26
+ # compute offset and width of Gaussian functions
27
+ offset = torch.linspace(start, stop, n_gaussians)
28
+ widths = torch.FloatTensor((offset[1] - offset[0]) * torch.ones_like(offset))
29
+ if trainable:
30
+ self.width = nn.Parameter(widths)
31
+ self.offsets = nn.Parameter(offset)
32
+ else:
33
+ self.register_buffer("width", widths)
34
+ self.register_buffer("offsets", offset)
35
+ self.centered = centered
36
+
37
+ def forward(self, distances):
38
+ """Compute smeared-gaussian distance values.
39
+
40
+ Args:
41
+ distances (torch.Tensor): interatomic distance values of
42
+ (N_b x N_at x N_nbh) shape.
43
+
44
+ Returns:
45
+ torch.Tensor: layer output of (N_b x N_at x N_nbh x N_g) shape.
46
+
47
+ """
48
+ return gaussian_smearing(
49
+ distances, self.offsets, self.width, centered=self.centered
50
+ )
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_schnetpack/license.txt ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The code in this folder was obtained from "https://github.com/atomistic-machine-learning/schnetpack", which has the following license:
2
+
3
+
4
+ COPYRIGHT
5
+
6
+ Copyright (c) 2018 Kristof Schütt, Michael Gastegger, Pan Kessel, Kim Nicoli
7
+
8
+ All other contributions:
9
+ Copyright (c) 2018, the respective contributors.
10
+ All rights reserved.
11
+
12
+ Each contributor holds copyright over their respective contributions.
13
+ The project versioning (Git) records all such contribution source information.
14
+
15
+ LICENSE
16
+
17
+ The MIT License
18
+
19
+ Permission is hereby granted, free of charge, to any person obtaining a copy
20
+ of this software and associated documentation files (the "Software"), to deal
21
+ in the Software without restriction, including without limitation the rights
22
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23
+ copies of the Software, and to permit persons to whom the Software is
24
+ furnished to do so, subject to the following conditions:
25
+
26
+ The above copyright notice and this permission notice shall be included in all
27
+ copies or substantial portions of the Software.
28
+
29
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
+ SOFTWARE.
example/diamond/1_data_prepare/data/bands/sc/reconstruction/aohamiltonian/pred_ham_std/src/deeph/from_se3_transformer/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from .representations import SphericalHarmonics