diff --git a/.gitattributes b/.gitattributes index 2a1d1ab245cc5319272e2db3f0942ee0c208150b..1425cd7c0dc8c26872ce73c1c6a8adb057663df8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -230,3 +230,4 @@ aobasis/siesta.DM filter=lfs diff=lfs merge=lfs -text 1_data_prepare/data/disp-14/scf/diamond.save/charge-density.dat filter=lfs diff=lfs merge=lfs -text 1_data_prepare/data/disp-07/scf/VSC filter=lfs diff=lfs merge=lfs -text 1_data_prepare/data/disp-07/scf/diamond.save/charge-density.dat filter=lfs diff=lfs merge=lfs -text +2_training/forces/diamond_ase_ref.nequip.pt2 filter=lfs diff=lfs merge=lfs -text diff --git a/2_training/forces/_phonopy_freqs.json b/2_training/forces/_phonopy_freqs.json new file mode 100644 index 0000000000000000000000000000000000000000..a70a73c00ae4742cf5d720717d824f02f0a38c60 --- /dev/null +++ b/2_training/forces/_phonopy_freqs.json @@ -0,0 +1 @@ +{"freqs_thz": [-6.176924148037084e-06, -6.167703510703962e-06, -6.1374103546125556e-06, 38.86256568564987, 38.86256568564988, 38.86256568564988]} \ No newline at end of file diff --git a/2_training/forces/diamond_ase_ref.nequip.pt2 b/2_training/forces/diamond_ase_ref.nequip.pt2 new file mode 100644 index 0000000000000000000000000000000000000000..b200d74d078f2237e668abf57c5469cf9a39c400 --- /dev/null +++ b/2_training/forces/diamond_ase_ref.nequip.pt2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:05a8ffd2d4feb583ae3c0f31b67e811967895e9b3390058a7c1a653e229bc8cd +size 10289338 diff --git a/2_training/forces/phonon_comparison.png b/2_training/forces/phonon_comparison.png new file mode 100644 index 0000000000000000000000000000000000000000..1092b99910c48921f13422b1a91cfcca97dd19e7 --- /dev/null +++ b/2_training/forces/phonon_comparison.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fcf45a338a03b006c6d895f7bd9ea3a666b8de3b327dd74930b819689b08816d +size 32905 diff --git a/2_training/forces/train_force.log b/2_training/forces/train_force.log new file mode 100644 index 0000000000000000000000000000000000000000..0c6cafc4d67a7d1f95f850c1876ea00858f81e10 --- /dev/null +++ b/2_training/forces/train_force.log @@ -0,0 +1,38 @@ +Step 1: Building forces dataset... + Dataset exists: /home/apolyukhin/Development/epc_ml/example/diamond/2_training/forces/dataset.xyz + +Step 2: Running DFPT at q=Gamma... + DFPT output exists: /home/apolyukhin/Development/epc_ml/example/diamond/2_training/forces/dfpt/ph.out + +Step 3: NequIP training... + --skip-training: using existing checkpoint: /home/apolyukhin/Development/epc_ml/example/diamond/2_training/forces/outputs/2026-03-03/13-29-04/best.ckpt + +Step 4: Compiling model... + Compiled model exists: /home/apolyukhin/Development/epc_ml/example/diamond/2_training/forces/diamond_ase.nequip.pth + +Step 5: Running phonopy + NequIP at Gamma... + Running phonopy + NequIP in deeph env ... +/home/apolyukhin/Development/epc_ml/example/diamond/2_training/forces/_phonopy_launcher.py:28: DeprecationWarning: PhonopyAtoms.get_chemical_symbols() is deprecated. Use symbols attribute instead. + a = Atoms(symbols=sc.get_chemical_symbols(), +/home/apolyukhin/Development/epc_ml/example/diamond/2_training/forces/_phonopy_launcher.py:29: DeprecationWarning: PhonopyAtoms.get_positions() is deprecated. Use positions attribute instead. + positions=sc.get_positions(), +/home/apolyukhin/Development/epc_ml/example/diamond/2_training/forces/_phonopy_launcher.py:30: DeprecationWarning: PhonopyAtoms.get_cell() is deprecated. Use cell attribute instead. + cell=sc.get_cell(), pbc=True) + Phonopy: 1 displacements (128 atoms each) + [1/1] |F|max=0.3194 eV/A + Gamma freqs written to /home/apolyukhin/Development/epc_ml/example/diamond/2_training/forces/_phonopy_freqs.json + +Step 6: Comparing phonons... + Mode DFPT (THz) DFPT (cm-1) ML (THz) ML (cm-1) Err (cm-1) +----------------------------------------------------------------- + 1 6.9242 230.97 -0.0000 -0.00 -230.97 + 2 6.9242 230.97 -0.0000 -0.00 -230.97 + 3 6.9242 230.97 -0.0000 -0.00 -230.97 + 4 40.9717 1366.67 38.8626 1296.32 -70.35 + 5 40.9717 1366.67 38.8626 1296.32 -70.35 + 6 40.9717 1366.67 38.8626 1296.32 -70.35 + +Optical: DFPT=23.95 THz, ML=38.86 THz, err=+62.3% + Saved: /home/apolyukhin/Development/epc_ml/example/diamond/2_training/forces/phonon_comparison.png + +train_force.py done. diff --git a/2_training/hamiltonian/infer_sc/dataset/00/overlaps.h5 b/2_training/hamiltonian/infer_sc/dataset/00/overlaps.h5 new file mode 100644 index 0000000000000000000000000000000000000000..72f3bce90989d6d045369b8da478a8ade450efde --- /dev/null +++ b/2_training/hamiltonian/infer_sc/dataset/00/overlaps.h5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:69f8fb67509a2908d6fbcdc098aa26a8a4af716b76aebda4ff04b872cba43859 +size 3986765 diff --git a/2_training/hamiltonian/infer_uc/dataset/00/element.dat b/2_training/hamiltonian/infer_uc/dataset/00/element.dat new file mode 100644 index 0000000000000000000000000000000000000000..1eb61bf3521ddecdb69977631fed8bb365e704eb --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/element.dat @@ -0,0 +1,2 @@ +6 +6 diff --git a/2_training/hamiltonian/infer_uc/dataset/00/graph.pkl b/2_training/hamiltonian/infer_uc/dataset/00/graph.pkl new file mode 100644 index 0000000000000000000000000000000000000000..3ccf1b296b81cb92699f36f267a911700d7fd254 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/graph.pkl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:589308142f311a9e1f063af5f5db20bb434be2fb921ab1a5a1fb8da79b2dadc8 +size 8317809 diff --git a/2_training/hamiltonian/infer_uc/dataset/00/hamiltonians.h5 b/2_training/hamiltonian/infer_uc/dataset/00/hamiltonians.h5 new file mode 100644 index 0000000000000000000000000000000000000000..de50799df3fd6f5860d044f6d482b40cf260a12f --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/hamiltonians.h5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:606d2f8997a1fb3ee3847fcb1a519ee249f8a7e88d323b694daf7858ab43943d +size 558800 diff --git a/2_training/hamiltonian/infer_uc/dataset/00/hamiltonians_pred.h5 b/2_training/hamiltonian/infer_uc/dataset/00/hamiltonians_pred.h5 new file mode 100644 index 0000000000000000000000000000000000000000..4eb5adbedc5d33509e78f5b356b431574d2a66bc --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/hamiltonians_pred.h5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cf17707c62b11e50879ce078e8582ca30180d512206b2f5fc52deee5f2faa823 +size 519600 diff --git a/2_training/hamiltonian/infer_uc/dataset/00/info.json b/2_training/hamiltonian/infer_uc/dataset/00/info.json new file mode 100644 index 0000000000000000000000000000000000000000..cedc0800527d526067961acb4770f85a552de7f3 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/info.json @@ -0,0 +1 @@ +{"isspinful": false} \ No newline at end of file diff --git a/2_training/hamiltonian/infer_uc/dataset/00/lat.dat b/2_training/hamiltonian/infer_uc/dataset/00/lat.dat new file mode 100644 index 0000000000000000000000000000000000000000..57549559fdf027105474116f6f1bc1721925996e --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/lat.dat @@ -0,0 +1,3 @@ +0.000000000000000000e+00 1.783499998856923785e+00 1.783499998856923785e+00 +1.783499998856923785e+00 0.000000000000000000e+00 1.783499998856923785e+00 +1.783499998856923785e+00 1.783499998856923785e+00 0.000000000000000000e+00 diff --git a/2_training/hamiltonian/infer_uc/dataset/00/orbital_types.dat b/2_training/hamiltonian/infer_uc/dataset/00/orbital_types.dat new file mode 100644 index 0000000000000000000000000000000000000000..eab49e9b18c4e546de944bf4decf3042bb987aad --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/orbital_types.dat @@ -0,0 +1,2 @@ +0 0 1 1 2 +0 0 1 1 2 diff --git a/2_training/hamiltonian/infer_uc/dataset/00/overlaps.h5 b/2_training/hamiltonian/infer_uc/dataset/00/overlaps.h5 new file mode 100644 index 0000000000000000000000000000000000000000..061d56170ebb7fa810aa6c360184a1b1412783e1 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/overlaps.h5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fb1a42ebec020dbdbe6e8b9e8ece9f70d737db9e5e6108003c759c0baad85c3d +size 499888 diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/config.ini b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/config.ini new file mode 100644 index 0000000000000000000000000000000000000000..66bda609946c7deac6b070bcbd45fab1dd44da6d --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/config.ini @@ -0,0 +1,82 @@ +[basic] +graph_dir = /home/apolyukhin/scripts/ml/diamond-qe/deeph-data/graph +save_dir = /home/apolyukhin/scripts/ml/diamond-qe/pristine-uc/reconstruction/aohamiltonian/pred_ham_std +raw_dir = /home/apolyukhin/scripts/ml/diamond-qe/deeph-data/preprocess +dataset_name = diamond_qe +only_get_graph = False +interface = h5 +target = hamiltonian +disable_cuda = True +device = cpu +num_threads = -1 +save_to_time_folder = False +save_csv = True +tb_writer = False +seed = 42 +multiprocessing = 0 +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]}] +o_component = H +energy_component = summation +max_element = -1 +statistics = False +normalizer = False +boxcox = False + +[graph] +radius = -1.0 +max_num_nbr = 0 +create_from_dft = True +if_lcmp_graph = True +separate_onsite = False +new_sp = False + +[train] +epochs = 5000 +pretrained = +resume = +train_ratio = 0.6 +val_ratio = 0.2 +test_ratio = 0.2 +early_stopping_loss = 0.0 +early_stopping_loss_epoch = [0.000000, 500] +revert_then_decay = True +revert_threshold = 30 +revert_decay_epoch = [800, 2000, 3000, 4000] +revert_decay_gamma = [0.4, 0.5, 0.5, 0.4] +clip_grad = True +clip_grad_value = 4.2 +switch_sgd = False +switch_sgd_lr = 1e-4 +switch_sgd_epoch = -1 + +[hyperparameter] +batch_size = 1 +dtype = float32 +optimizer = adam +learning_rate = 0.001 +lr_scheduler = +lr_milestones = [] +momentum = 0.9 +weight_decay = 0 +criterion = MaskMSELoss +retain_edge_fea = True +lambda_eij = 0.0 +lambda_ei = 0.1 +lambda_etot = 0.0 + +[network] +atom_fea_len = 64 +edge_fea_len = 128 +gauss_stop = 6.0 +num_l = 4 +aggr = add +distance_expansion = GaussianBasis +if_exp = True +if_multiplelinear = False +if_edge_update = True +if_lcmp = True +normalization = LayerNorm +atom_update_net = PAINN +trainable_gaussians = False +type_affine = False + diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/result.txt b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/result.txt new file mode 100644 index 0000000000000000000000000000000000000000..75c6579646b7e29ba5d7152e83aee99a3dc77beb --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/result.txt @@ -0,0 +1,86 @@ +====== CONFIG ====== +[basic] +graph_dir=/home/apolyukhin/scripts/ml/diamond-qe/deeph-data/graph +save_dir=/home/apolyukhin/scripts/ml/diamond-qe/pristine-uc/reconstruction/aohamiltonian/pred_ham_std +raw_dir=/home/apolyukhin/scripts/ml/diamond-qe/deeph-data/preprocess +dataset_name=diamond_qe +only_get_graph=False +interface=h5 +target=hamiltonian +disable_cuda=True +device=cpu +num_threads=-1 +save_to_time_folder=False +save_csv=True +tb_writer=False +seed=42 +multiprocessing=0 +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]}] +o_component=H +energy_component=summation +max_element=-1 +statistics=False +normalizer=False +boxcox=False + +[graph] +radius=-1.0 +max_num_nbr=0 +create_from_dft=True +if_lcmp_graph=True +separate_onsite=False +new_sp=False + +[train] +epochs=5000 +pretrained= +resume= +train_ratio=0.6 +val_ratio=0.2 +test_ratio=0.2 +early_stopping_loss=0.0 +early_stopping_loss_epoch=[0.000000, 500] +revert_then_decay=True +revert_threshold=30 +revert_decay_epoch=[800, 2000, 3000, 4000] +revert_decay_gamma=[0.4, 0.5, 0.5, 0.4] +clip_grad=True +clip_grad_value=4.2 +switch_sgd=False +switch_sgd_lr=1e-4 +switch_sgd_epoch=-1 + +[hyperparameter] +batch_size=1 +dtype=float32 +optimizer=adam +learning_rate=0.001 +lr_scheduler= +lr_milestones=[] +momentum=0.9 +weight_decay=0 +criterion=MaskMSELoss +retain_edge_fea=True +lambda_eij=0.0 +lambda_ei=0.1 +lambda_etot=0.0 + +[network] +atom_fea_len=64 +edge_fea_len=128 +gauss_stop=6.0 +num_l=4 +aggr=add +distance_expansion=GaussianBasis +if_exp=True +if_multiplelinear=False +if_edge_update=True +if_lcmp=True +normalization=LayerNorm +atom_update_net=PAINN +trainable_gaussians=False +type_affine=False + +=> load best checkpoint (epoch 3217) +=> Atomic types: [6], spinful: False, the number of atomic types: 1. +Save processed graph to /home/apolyukhin/scripts/ml/diamond-qe/pristine-uc/reconstruction/aohamiltonian/graph.pkl, cost 0.1220557689666748 seconds diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__init__.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..87b4f1ea164f796a6735bc58242b7ced01bccef3 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__init__.py @@ -0,0 +1,10 @@ +from .data import HData +from .model import HGNN, ExpBernsteinBasis +from .utils import print_args, Logger, MaskMSELoss, MaskMAELoss, write_ham_npz, write_ham, write_ham_h5, get_config, \ + get_inference_config, get_preprocess_config +from .graph import Collater, collate_fn, get_graph, load_orbital_types +from .kernel import DeepHKernel +from .preprocess import get_rc, OijLoad, GetEEiEij, abacus_parse, siesta_parse +from .rotate import get_rh, rotate_back, Rotate, dtype_dict + +__version__ = "0.2.2" diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/__init__.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a10128effca744f74fa57cf87947211775542709 Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/__init__.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/data.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/data.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..743d349c636f6d43e49af20dfc85ed0f33c03cbd Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/data.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/graph.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/graph.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6234cf545e63d32ca91c4146165f511b71f7333c Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/graph.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/kernel.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/kernel.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6ae578e5847153c0a41a964db12924e7789f24f4 Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/kernel.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/model.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/model.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e553f13252f8df3f09c9d152f05e3a2b85b171a1 Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/model.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/rotate.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/rotate.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f36241e5277fcbc1e734e0206790f8dbcbef4a40 Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/rotate.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/utils.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/utils.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d62bdd5089c07f45819a62e1d5c77e769deda274 Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/__pycache__/utils.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/data.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/data.py new file mode 100644 index 0000000000000000000000000000000000000000..bd61863cd6ab98fff582e1ec771b62932bd91fa1 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/data.py @@ -0,0 +1,217 @@ +import warnings +import os +import time +import tqdm + +from pymatgen.core.structure import Structure +import numpy as np +import torch +from torch_geometric.data import InMemoryDataset +from pathos.multiprocessing import ProcessingPool as Pool + +from .graph import get_graph + + +class HData(InMemoryDataset): + def __init__(self, raw_data_dir: str, graph_dir: str, interface: str, target: str, + dataset_name: str, multiprocessing: int, radius, max_num_nbr, + num_l, max_element, create_from_DFT, if_lcmp_graph, separate_onsite, new_sp, + default_dtype_torch, nums: int = None, transform=None, pre_transform=None, pre_filter=None): + """ +when interface == 'h5', +raw_data_dir +├── 00 +│ ├──rh.h5 / rdm.h5 +│ ├──rc.h5 +│ ├──element.dat +│ ├──orbital_types.dat +│ ├──site_positions.dat +│ ├──lat.dat +│ └──info.json +├── 01 +│ ├──rh.h5 / rdm.h5 +│ ├──rc.h5 +│ ├──element.dat +│ ├──orbital_types.dat +│ ├──site_positions.dat +│ ├──lat.dat +│ └──info.json +├── 02 +│ ├──rh.h5 / rdm.h5 +│ ├──rc.h5 +│ ├──element.dat +│ ├──orbital_types.dat +│ ├──site_positions.dat +│ ├──lat.dat +│ └──info.json +├── ... + """ + self.raw_data_dir = raw_data_dir + assert dataset_name.find('-') == -1, '"-" can not be included in the dataset name' + if create_from_DFT: + way_create_graph = 'FromDFT' + else: + way_create_graph = f'{radius}r{max_num_nbr}mn' + if if_lcmp_graph: + lcmp_str = f'{num_l}l' + else: + lcmp_str = 'WithoutLCMP' + if separate_onsite is True: + onsite_str = '-SeparateOnsite' + else: + onsite_str = '' + if new_sp: + new_sp_str = '-NewSP' + else: + new_sp_str = '' + if target == 'hamiltonian': + title = 'HGraph' + else: + raise ValueError('Unknown prediction target: {}'.format(target)) + graph_file_name = f'{title}-{interface}-{dataset_name}-{lcmp_str}-{way_create_graph}{onsite_str}{new_sp_str}.pkl' + self.data_file = os.path.join(graph_dir, graph_file_name) + os.makedirs(graph_dir, exist_ok=True) + self.data, self.slices = None, None + self.interface = interface + self.target = target + self.dataset_name = dataset_name + self.multiprocessing = multiprocessing + self.radius = radius + self.max_num_nbr = max_num_nbr + self.num_l = num_l + self.create_from_DFT = create_from_DFT + self.if_lcmp_graph = if_lcmp_graph + self.separate_onsite = separate_onsite + self.new_sp = new_sp + self.default_dtype_torch = default_dtype_torch + + self.nums = nums + self.transform = transform + self.pre_transform = pre_transform + self.pre_filter = pre_filter + self.__indices__ = None + self.__data_list__ = None + self._indices = None + self._data_list = None + + print(f'Graph data file: {graph_file_name}') + if os.path.exists(self.data_file): + print('Use existing graph data file') + else: + print('Process new data file......') + self.process() + begin = time.time() + try: + loaded_data = torch.load(self.data_file) + except AttributeError: + raise RuntimeError('Error in loading graph data file, try to delete it and generate the graph file with the current version of PyG') + if len(loaded_data) == 2: + warnings.warn('You are using the graph data file with an old version') + self.data, self.slices = loaded_data + self.info = { + "spinful": False, + "index_to_Z": torch.arange(max_element + 1), + "Z_to_index": torch.arange(max_element + 1), + } + elif len(loaded_data) == 3: + self.data, self.slices, tmp = loaded_data + if isinstance(tmp, dict): + self.info = tmp + print(f"Atomic types: {self.info['index_to_Z'].tolist()}") + else: + warnings.warn('You are using an old version of the graph data file') + self.info = { + "spinful": tmp, + "index_to_Z": torch.arange(max_element + 1), + "Z_to_index": torch.arange(max_element + 1), + } + print(f'Finish loading the processed {len(self)} structures (spinful: {self.info["spinful"]}, ' + f'the number of atomic types: {len(self.info["index_to_Z"])}), cost {time.time() - begin:.0f} seconds') + + def process_worker(self, folder, **kwargs): + stru_id = os.path.split(folder)[-1] + + structure = Structure(np.loadtxt(os.path.join(folder, 'lat.dat')).T, + np.loadtxt(os.path.join(folder, 'element.dat')), + np.loadtxt(os.path.join(folder, 'site_positions.dat')).T, + coords_are_cartesian=True, + to_unit_cell=False) + + cart_coords = torch.tensor(structure.cart_coords, dtype=self.default_dtype_torch) + frac_coords = torch.tensor(structure.frac_coords, dtype=self.default_dtype_torch) + numbers = torch.tensor(structure.atomic_numbers) + structure.lattice.matrix.setflags(write=True) + lattice = torch.tensor(structure.lattice.matrix, dtype=self.default_dtype_torch) + if self.target == 'E_ij': + huge_structure = True + else: + huge_structure = False + return get_graph(cart_coords, frac_coords, numbers, stru_id, r=self.radius, max_num_nbr=self.max_num_nbr, + numerical_tol=1e-8, lattice=lattice, default_dtype_torch=self.default_dtype_torch, + tb_folder=folder, interface=self.interface, num_l=self.num_l, + create_from_DFT=self.create_from_DFT, if_lcmp_graph=self.if_lcmp_graph, + separate_onsite=self.separate_onsite, + target=self.target, huge_structure=huge_structure, if_new_sp=self.new_sp, **kwargs) + + def process(self): + begin = time.time() + folder_list = [] + for root, dirs, files in os.walk(self.raw_data_dir): + if (self.interface == 'h5' and 'rc.h5' in files) or ( + self.interface == 'npz' and 'rc.npz' in files): + folder_list.append(root) + folder_list = sorted(folder_list) + folder_list = folder_list[: self.nums] + if self.dataset_name == 'graphene_450': + folder_list = folder_list[500:5000:10] + if self.dataset_name == 'graphene_1500': + folder_list = folder_list[500:5000:3] + if self.dataset_name == 'bp_bilayer': + folder_list = folder_list[:600] + assert len(folder_list) != 0, "Can not find any structure" + print('Found %d structures, have cost %d seconds' % (len(folder_list), time.time() - begin)) + + if self.multiprocessing == 0: + print(f'Use multiprocessing (nodes = num_processors x num_threads = 1 x {torch.get_num_threads()})') + data_list = [self.process_worker(folder) for folder in tqdm.tqdm(folder_list)] + else: + pool_dict = {} if self.multiprocessing < 0 else {'nodes': self.multiprocessing} + # BS (2023.06.06): + # The keyword "num_threads" in kernel.py can be used to set the torch threads. + # The multiprocessing in the "process_worker" is in contradiction with the num_threads utilized in torch. + # To avoid this conflict, I limit the number of torch threads to one, + # and recover it when finishing the process_worker. + torch_num_threads = torch.get_num_threads() + torch.set_num_threads(1) + + with Pool(**pool_dict) as pool: + nodes = pool.nodes + print(f'Use multiprocessing (nodes = num_processors x num_threads = {nodes} x {torch.get_num_threads()})') + data_list = list(tqdm.tqdm(pool.imap(self.process_worker, folder_list), total=len(folder_list))) + torch.set_num_threads(torch_num_threads) + print('Finish processing %d structures, have cost %d seconds' % (len(data_list), time.time() - begin)) + + if self.pre_filter is not None: + data_list = [d for d in data_list if self.pre_filter(d)] + if self.pre_transform is not None: + data_list = [self.pre_transform(d) for d in data_list] + + index_to_Z, Z_to_index = self.element_statistics(data_list) + spinful = data_list[0].spinful + for d in data_list: + assert spinful == d.spinful + + data, slices = self.collate(data_list) + torch.save((data, slices, dict(spinful=spinful, index_to_Z=index_to_Z, Z_to_index=Z_to_index)), self.data_file) + print('Finish saving %d structures to %s, have cost %d seconds' % ( + len(data_list), self.data_file, time.time() - begin)) + + def element_statistics(self, data_list): + index_to_Z, inverse_indices = torch.unique(data_list[0].x, sorted=True, return_inverse=True) + Z_to_index = torch.full((100,), -1, dtype=torch.int64) + Z_to_index[index_to_Z] = torch.arange(len(index_to_Z)) + + for data in data_list: + data.x = Z_to_index[data.x] + + return index_to_Z, Z_to_index diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/default.ini b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/default.ini new file mode 100644 index 0000000000000000000000000000000000000000..e64acf35a8f0df40d74648501c101bd33bc215d9 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/default.ini @@ -0,0 +1,88 @@ +[basic] +graph_dir = /your/own/path +save_dir = /your/own/path +raw_dir = /your/own/path +dataset_name = your_own_name +only_get_graph = False +;choices = ['h5', 'npz'] +interface = h5 +target = hamiltonian +disable_cuda = False +device = cuda:0 +;-1 for cpu_count(logical=False) // torch.cuda.device_count() +num_threads = -1 +save_to_time_folder = True +save_csv = False +tb_writer = True +seed = 42 +multiprocessing = 0 +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]}] +O_component = H +energy_component = summation +max_element = -1 +statistics = False +normalizer = False +boxcox = False + +[graph] +radius = -1.0 +max_num_nbr = 0 +create_from_DFT = True +if_lcmp_graph = True +separate_onsite = False +new_sp = False + +[train] +epochs = 4000 +pretrained = +resume = +train_ratio = 0.6 +val_ratio = 0.2 +test_ratio = 0.2 +early_stopping_loss = 0.0 +early_stopping_loss_epoch = [0.000000, 500] +revert_then_decay = True +revert_threshold = 30 +revert_decay_epoch = [500, 2000, 3000] +revert_decay_gamma = [0.4, 0.5, 0.5] +clip_grad = True +clip_grad_value = 4.2 +switch_sgd = False +switch_sgd_lr = 1e-4 +switch_sgd_epoch = -1 + +[hyperparameter] +batch_size = 3 +dtype = float32 +;choices = ['sgd', 'sgdm', 'adam', 'lbfgs'] +optimizer = adam +;initial learning rate +learning_rate = 0.001 +;choices = ['', 'MultiStepLR', 'ReduceLROnPlateau', 'CyclicLR'] +lr_scheduler = +lr_milestones = [] +momentum = 0.9 +weight_decay = 0 +criterion = MaskMSELoss +retain_edge_fea = True +lambda_Eij = 0.0 +lambda_Ei = 0.1 +lambda_Etot = 0.0 + +[network] +atom_fea_len = 64 +edge_fea_len = 128 +gauss_stop = 6 +;The number of angular quantum numbers that spherical harmonic functions have +num_l = 5 +aggr = add +distance_expansion = GaussianBasis +if_exp = True +if_MultipleLinear = False +if_edge_update = True +if_lcmp = True +normalization = LayerNorm +;choices = ['CGConv', 'GAT', 'PAINN'] +atom_update_net = CGConv +trainable_gaussians = False +type_affine = False diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__init__.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..483be01919b40f67f6a19fca1d4ccb89fea6f6d3 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__init__.py @@ -0,0 +1 @@ +from .rmnet import RBF, cosine_cutoff, ShiftedSoftplus, _eps \ No newline at end of file diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__pycache__/__init__.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9ce40591d0dd72fc67f7aec8a7f04eac33c55330 Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__pycache__/__init__.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__pycache__/rmnet.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__pycache__/rmnet.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8d154356834f5b63a64283a400efb3aac2f0ee6f Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__pycache__/rmnet.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/license.txt b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/license.txt new file mode 100644 index 0000000000000000000000000000000000000000..897f1c4ecc8d79948914811bce9a83ff49ae2ce5 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/license.txt @@ -0,0 +1 @@ +The code in this folder was obtained from "https://github.com/sakuraiiiii/HermNet" \ No newline at end of file diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/rmnet.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/rmnet.py new file mode 100644 index 0000000000000000000000000000000000000000..209b986e78aa5acc1160059587519745b7162563 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_HermNet/rmnet.py @@ -0,0 +1,105 @@ +import math + +import torch +from torch import nn, Tensor +import numpy as np + + +_eps = 1e-3 + +r"""Tricks: Introducing the parameter `_eps` is to avoid NaN. +In HVNet and HTNet, a subgraph will be extracted to calculate angles. +And with all the nodes still be included in the subgraph, +each hidden state in such a subgraph will contain 0 value. +In `painn`, the calculation w.r.t $r / \parallel r \parallel$ will be taken. +If just alternate $r / \parallel r \parallel$ with $r / (\parallel r \parallel + _eps)$, +NaN will still occur in during the training. +Considering the following example, +$$ +(\frac{x}{r+_eps})^\prime = \frac{r+b-\frac{x^2}{r}}{(r+b)^2} +$$ +where $r = \sqrt{x^2+y^2+z^2}$. It is obvious that NaN will occur. +Thus the solution is change the norm $r$ as $r^\prime = \sqrt(x^2+y^2+z^2+_eps)$. +Since $r$ is rotational invariant, $r^2$ is rotational invariant. +Obviously, $\sqrt(r^2 + _eps)$ is rotational invariant. +""" +class RBF(nn.Module): + r"""Radial basis function. + A modified version of feature engineering in `DimeNet`, + which is used in `PAINN`. + + Parameters + ---------- + rc : float + Cutoff radius + l : int + Parameter in feature engineering in DimeNet + """ + def __init__(self, rc: float, l: int): + super(RBF, self).__init__() + self.rc = rc + self.l = l + + def forward(self, x: Tensor): + ls = torch.arange(1, self.l + 1).float().to(x.device) + norm = torch.sqrt((x ** 2).sum(dim=-1) + _eps).unsqueeze(-1) + return torch.sin(math.pi / self.rc * norm@ls.unsqueeze(0)) / norm + + +class cosine_cutoff(nn.Module): + r"""Cutoff function in https://aip.scitation.org/doi/pdf/10.1063/1.3553717. + + Parameters + ---------- + rc : float + Cutoff radius + """ + def __init__(self, rc: float): + super(cosine_cutoff, self).__init__() + self.rc = rc + + def forward(self, x: Tensor): + norm = torch.norm(x, dim=-1, keepdim=True) + _eps + return 0.5 * (torch.cos(math.pi * norm / self.rc) + 1) + +class ShiftedSoftplus(nn.Module): + r""" + + Description + ----------- + Applies the element-wise function: + + .. math:: + \text{SSP}(x) = \frac{1}{\beta} * \log(1 + \exp(\beta * x)) - \log(\text{shift}) + + Attributes + ---------- + beta : int + :math:`\beta` value for the mathematical formulation. Default to 1. + shift : int + :math:`\text{shift}` value for the mathematical formulation. Default to 2. + """ + def __init__(self, beta=1, shift=2, threshold=20): + super(ShiftedSoftplus, self).__init__() + + self.shift = shift + self.softplus = nn.Softplus(beta=beta, threshold=threshold) + + def forward(self, inputs): + """ + + Description + ----------- + Applies the activation function. + + Parameters + ---------- + inputs : float32 tensor of shape (N, *) + * denotes any number of additional dimensions. + + Returns + ------- + float32 tensor of shape (N, *) + Result of applying the activation function to the input. + """ + return self.softplus(inputs) - np.log(float(self.shift)) diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__init__.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..ad9dfcd9088c4fe4c6fdec95f0c1da9435e8f5aa --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__init__.py @@ -0,0 +1,2 @@ +from .graph_norm import GraphNorm +from .diff_group_norm import DiffGroupNorm diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/__init__.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..28632c5ba3fd37a0352749999a1f8aab2b43cc69 Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/__init__.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/diff_group_norm.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/diff_group_norm.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f6875eaec94071bf93b5e07b8f5562a144e2a297 Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/diff_group_norm.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/graph_norm.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/graph_norm.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..de3c2014997eb238b150686973cb6a97077a479b Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/graph_norm.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/diff_group_norm.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/diff_group_norm.py new file mode 100644 index 0000000000000000000000000000000000000000..f94ca5506180d8596f9778e2c438ed0013c9481d --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/diff_group_norm.py @@ -0,0 +1,109 @@ +import torch +from torch import Tensor +from torch.nn import Linear, BatchNorm1d + + +class DiffGroupNorm(torch.nn.Module): + r"""The differentiable group normalization layer from the `"Towards Deeper + Graph Neural Networks with Differentiable Group Normalization" + `_ paper, which normalizes node features + group-wise via a learnable soft cluster assignment + + .. math:: + + \mathbf{S} = \text{softmax} (\mathbf{X} \mathbf{W}) + + where :math:`\mathbf{W} \in \mathbb{R}^{F \times G}` denotes a trainable + weight matrix mapping each node into one of :math:`G` clusters. + Normalization is then performed group-wise via: + + .. math:: + + \mathbf{X}^{\prime} = \mathbf{X} + \lambda \sum_{i = 1}^G + \text{BatchNorm}(\mathbf{S}[:, i] \odot \mathbf{X}) + + Args: + in_channels (int): Size of each input sample :math:`F`. + groups (int): The number of groups :math:`G`. + lamda (float, optional): The balancing factor :math:`\lambda` between + input embeddings and normalized embeddings. (default: :obj:`0.01`) + eps (float, optional): A value added to the denominator for numerical + stability. (default: :obj:`1e-5`) + momentum (float, optional): The value used for the running mean and + running variance computation. (default: :obj:`0.1`) + affine (bool, optional): If set to :obj:`True`, this module has + learnable affine parameters :math:`\gamma` and :math:`\beta`. + (default: :obj:`True`) + track_running_stats (bool, optional): If set to :obj:`True`, this + module tracks the running mean and variance, and when set to + :obj:`False`, this module does not track such statistics and always + uses batch statistics in both training and eval modes. + (default: :obj:`True`) + """ + def __init__(self, in_channels, groups, lamda=0.01, eps=1e-5, momentum=0.1, + affine=True, track_running_stats=True): + super(DiffGroupNorm, self).__init__() + + self.in_channels = in_channels + self.groups = groups + self.lamda = lamda + + self.lin = Linear(in_channels, groups, bias=False) + self.norm = BatchNorm1d(groups * in_channels, eps, momentum, affine, + track_running_stats) + + self.reset_parameters() + + def reset_parameters(self): + self.lin.reset_parameters() + self.norm.reset_parameters() + + def forward(self, x: Tensor) -> Tensor: + """""" + F, G = self.in_channels, self.groups + + s = self.lin(x).softmax(dim=-1) # [N, G] + out = s.unsqueeze(-1) * x.unsqueeze(-2) # [N, G, F] + out = self.norm(out.view(-1, G * F)).view(-1, G, F).sum(-2) # [N, F] + + return x + self.lamda * out + + @staticmethod + def group_distance_ratio(x: Tensor, y: Tensor, eps: float = 1e-5) -> float: + r"""Measures the ratio of inter-group distance over intra-group + distance + + .. math:: + R_{\text{Group}} = \frac{\frac{1}{(C-1)^2} \sum_{i!=j} + \frac{1}{|\mathbf{X}_i||\mathbf{X}_j|} \sum_{\mathbf{x}_{iv} + \in \mathbf{X}_i } \sum_{\mathbf{x}_{jv^{\prime}} \in \mathbf{X}_j} + {\| \mathbf{x}_{iv} - \mathbf{x}_{jv^{\prime}} \|}_2 }{ + \frac{1}{C} \sum_{i} \frac{1}{{|\mathbf{X}_i|}^2} + \sum_{\mathbf{x}_{iv}, \mathbf{x}_{iv^{\prime}} \in \mathbf{X}_i } + {\| \mathbf{x}_{iv} - \mathbf{x}_{iv^{\prime}} \|}_2 } + + where :math:`\mathbf{X}_i` denotes the set of all nodes that belong to + class :math:`i`, and :math:`C` denotes the total number of classes in + :obj:`y`. + """ + num_classes = int(y.max()) + 1 + + numerator = 0. + for i in range(num_classes): + mask = y == i + dist = torch.cdist(x[mask].unsqueeze(0), x[~mask].unsqueeze(0)) + numerator += (1 / dist.numel()) * float(dist.sum()) + numerator *= 1 / (num_classes - 1)**2 + + denominator = 0. + for i in range(num_classes): + mask = y == i + dist = torch.cdist(x[mask].unsqueeze(0), x[mask].unsqueeze(0)) + denominator += (1 / dist.numel()) * float(dist.sum()) + denominator *= 1 / num_classes + + return numerator / (denominator + eps) + + def __repr__(self): + return '{}({}, groups={})'.format(self.__class__.__name__, + self.in_channels, self.groups) diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/graph_norm.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/graph_norm.py new file mode 100644 index 0000000000000000000000000000000000000000..1ee9a35f5463ae41f573f087a99d4b4242e8ab9a --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/graph_norm.py @@ -0,0 +1,60 @@ +from typing import Optional + +import torch +from torch import Tensor +from torch_scatter import scatter_mean + +from torch_geometric.nn.inits import zeros, ones + + +class GraphNorm(torch.nn.Module): + r"""Applies graph normalization over individual graphs as described in the + `"GraphNorm: A Principled Approach to Accelerating Graph Neural Network + Training" `_ paper + + .. math:: + \mathbf{x}^{\prime}_i = \frac{\mathbf{x} - \alpha \odot + \textrm{E}[\mathbf{x}]} + {\sqrt{\textrm{Var}[\mathbf{x} - \alpha \odot \textrm{E}[\mathbf{x}]] + + \epsilon}} \odot \gamma + \beta + + where :math:`\alpha` denotes parameters that learn how much information + to keep in the mean. + + Args: + in_channels (int): Size of each input sample. + eps (float, optional): A value added to the denominator for numerical + stability. (default: :obj:`1e-5`) + """ + def __init__(self, in_channels: int, eps: float = 1e-5): + super(GraphNorm, self).__init__() + + self.in_channels = in_channels + self.eps = eps + + self.weight = torch.nn.Parameter(torch.Tensor(in_channels)) + self.bias = torch.nn.Parameter(torch.Tensor(in_channels)) + self.mean_scale = torch.nn.Parameter(torch.Tensor(in_channels)) + + self.reset_parameters() + + def reset_parameters(self): + ones(self.weight) + zeros(self.bias) + ones(self.mean_scale) + + def forward(self, x: Tensor, batch: Optional[Tensor] = None) -> Tensor: + """""" + if batch is None: + batch = x.new_zeros(x.size(0), dtype=torch.long) + + batch_size = int(batch.max()) + 1 + + mean = scatter_mean(x, batch, dim=0, dim_size=batch_size)[batch] + out = x - mean * self.mean_scale + var = scatter_mean(out.pow(2), batch, dim=0, dim_size=batch_size) + std = (var + self.eps).sqrt()[batch] + return self.weight * out / std + self.bias + + def __repr__(self): + return f'{self.__class__.__name__}({self.in_channels})' diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/license.txt b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/license.txt new file mode 100644 index 0000000000000000000000000000000000000000..c404d8d688a86a04d2ed9841a71f13b29b39c0bf --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/license.txt @@ -0,0 +1,22 @@ +The code in this folder was obtained from "https://github.com/rusty1s/pytorch_geometric", which has the following license: + + +Copyright (c) 2020 Matthias Fey + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__init__.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..60b7bd19f9e3d0ad28ec4c5c1a73016019be6645 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__init__.py @@ -0,0 +1 @@ +from .lattice import find_neighbors, _one_to_three, _compute_cube_index, _three_to_one diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__pycache__/__init__.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d86e9cd6aafc3adb73ce873a23e06882d1489322 Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__pycache__/__init__.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__pycache__/lattice.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__pycache__/lattice.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..471c206252e45618c89532c650cf05cd9e1df919 Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__pycache__/lattice.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/lattice.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/lattice.py new file mode 100644 index 0000000000000000000000000000000000000000..7fe692b9e533bcaa15351b77dadf314f4b945ef3 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/lattice.py @@ -0,0 +1,71 @@ +import itertools +import numpy as np + + +# The following internal methods are used in the get_points_in_sphere method. +def _compute_cube_index(coords: np.ndarray, global_min: float, radius: float + ) -> np.ndarray: + """ + Compute the cube index from coordinates + Args: + coords: (nx3 array) atom coordinates + global_min: (float) lower boundary of coordinates + radius: (float) cutoff radius + + Returns: (nx3 array) int indices + + """ + return np.array(np.floor((coords - global_min) / radius), dtype=int) + +def _three_to_one(label3d: np.ndarray, ny: int, nz: int) -> np.ndarray: + """ + The reverse of _one_to_three + """ + return np.array(label3d[:, 0] * ny * nz + + label3d[:, 1] * nz + label3d[:, 2]).reshape((-1, 1)) + +def _one_to_three(label1d: np.ndarray, ny: int, nz: int) -> np.ndarray: + """ + Convert a 1D index array to 3D index array + + Args: + label1d: (array) 1D index array + ny: (int) number of cells in y direction + nz: (int) number of cells in z direction + + Returns: (nx3) int array of index + + """ + last = np.mod(label1d, nz) + second = np.mod((label1d - last) / nz, ny) + first = (label1d - last - second * nz) / (ny * nz) + return np.concatenate([first, second, last], axis=1) + +def find_neighbors(label: np.ndarray, nx: int, ny: int, nz: int): + """ + Given a cube index, find the neighbor cube indices + + Args: + label: (array) (n,) or (n x 3) indice array + nx: (int) number of cells in y direction + ny: (int) number of cells in y direction + nz: (int) number of cells in z direction + + Returns: neighbor cell indices + + """ + + array = [[-1, 0, 1]] * 3 + neighbor_vectors = np.array(list(itertools.product(*array)), + dtype=int) + if np.shape(label)[1] == 1: + label3d = _one_to_three(label, ny, nz) + else: + label3d = label + all_labels = label3d[:, None, :] - neighbor_vectors[None, :, :] + filtered_labels = [] + # filter out out-of-bound labels i.e., label < 0 + for labels in all_labels: + ind = (labels[:, 0] < nx) * (labels[:, 1] < ny) * (labels[:, 2] < nz) * np.all(labels > -1e-5, axis=1) + filtered_labels.append(labels[ind]) + return filtered_labels \ No newline at end of file diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/license.txt b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/license.txt new file mode 100644 index 0000000000000000000000000000000000000000..ae43d142bcc2b5f43c69db4acef48fdd4690fb41 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/license.txt @@ -0,0 +1,22 @@ +The code in this folder was obtained from "https://github.com/materialsproject/pymatgen", which has the following license: + + +The MIT License (MIT) +Copyright (c) 2011-2012 MIT & The Regents of the University of California, through Lawrence Berkeley National Laboratory + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__init__.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..1f24e5f1ea7da6de5dc80cc6cff2a0cf7a11403a --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__init__.py @@ -0,0 +1 @@ +from .acsf import GaussianBasis diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__pycache__/__init__.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ded86b48c0acd11887f5f5fb9369f5984355b575 Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__pycache__/__init__.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__pycache__/acsf.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__pycache__/acsf.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6329599ed558bdb325c0aa0fd80071ca52304fcf Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__pycache__/acsf.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/acsf.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/acsf.py new file mode 100644 index 0000000000000000000000000000000000000000..9194cc403895f15e1dadfd321338ebfe968fce0e --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/acsf.py @@ -0,0 +1,50 @@ +import torch +from torch import nn + + +def gaussian_smearing(distances, offset, widths, centered=False): + if not centered: + # compute width of Gaussian functions (using an overlap of 1 STDDEV) + coeff = -0.5 / torch.pow(widths, 2) + # Use advanced indexing to compute the individual components + diff = distances[..., None] - offset + else: + # if Gaussian functions are centered, use offsets to compute widths + coeff = -0.5 / torch.pow(offset, 2) + # if Gaussian functions are centered, no offset is subtracted + diff = distances[..., None] + # compute smear distance values + gauss = torch.exp(coeff * torch.pow(diff, 2)) + return gauss + + +class GaussianBasis(nn.Module): + def __init__( + self, start=0.0, stop=5.0, n_gaussians=50, centered=False, trainable=False + ): + super(GaussianBasis, self).__init__() + # compute offset and width of Gaussian functions + offset = torch.linspace(start, stop, n_gaussians) + widths = torch.FloatTensor((offset[1] - offset[0]) * torch.ones_like(offset)) + if trainable: + self.width = nn.Parameter(widths) + self.offsets = nn.Parameter(offset) + else: + self.register_buffer("width", widths) + self.register_buffer("offsets", offset) + self.centered = centered + + def forward(self, distances): + """Compute smeared-gaussian distance values. + + Args: + distances (torch.Tensor): interatomic distance values of + (N_b x N_at x N_nbh) shape. + + Returns: + torch.Tensor: layer output of (N_b x N_at x N_nbh x N_g) shape. + + """ + return gaussian_smearing( + distances, self.offsets, self.width, centered=self.centered + ) \ No newline at end of file diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/license.txt b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/license.txt new file mode 100644 index 0000000000000000000000000000000000000000..d0a792528f90d0b88f073bbd663e795f1b548a5c --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/license.txt @@ -0,0 +1,35 @@ +The code in this folder was obtained from "https://github.com/atomistic-machine-learning/schnetpack", which has the following license: + + +COPYRIGHT + +Copyright (c) 2018 Kristof Schütt, Michael Gastegger, Pan Kessel, Kim Nicoli + +All other contributions: +Copyright (c) 2018, the respective contributors. +All rights reserved. + +Each contributor holds copyright over their respective contributions. +The project versioning (Git) records all such contribution source information. + +LICENSE + +The MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/__init__.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..1dc6e2de9bea1f996abbb2f4bac19d42e6c1b2b8 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/__init__.py @@ -0,0 +1 @@ +from .representations import SphericalHarmonics \ No newline at end of file diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/__pycache__/__init__.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..85b8b320b50491e14fcbd20f4eb35fdbf5322de0 Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/__pycache__/__init__.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/__pycache__/representations.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/__pycache__/representations.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..65eb06a0ba835a1c179fc9fcad5c3e58fc65a790 Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/__pycache__/representations.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/license.txt b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/license.txt new file mode 100644 index 0000000000000000000000000000000000000000..b1f1e8fbd2324c47b884577aa1e77d2b935bf6e8 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/license.txt @@ -0,0 +1,24 @@ +The code in this folder was obtained from "https://github.com/mariogeiger/se3cnn/", which has the following license: + + +MIT License + +Copyright (c) 2019 Mario Geiger + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/representations.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/representations.py new file mode 100644 index 0000000000000000000000000000000000000000..64952e1bda4e3cd9684a7e982b631958d9afaa64 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/representations.py @@ -0,0 +1,204 @@ +import torch +import numpy as np + + +def semifactorial(x): + """Compute the semifactorial function x!!. + + x!! = x * (x-2) * (x-4) *... + + Args: + x: positive int + Returns: + float for x!! + """ + y = 1. + for n in range(x, 1, -2): + y *= n + return y + + +def pochhammer(x, k): + """Compute the pochhammer symbol (x)_k. + + (x)_k = x * (x+1) * (x+2) *...* (x+k-1) + + Args: + x: positive int + Returns: + float for (x)_k + """ + xf = float(x) + for n in range(x+1, x+k): + xf *= n + return xf + +def lpmv(l, m, x): + """Associated Legendre function including Condon-Shortley phase. + + Args: + m: int order + l: int degree + x: float argument tensor + Returns: + tensor of x-shape + """ + m_abs = abs(m) + if m_abs > l: + return torch.zeros_like(x) + + # Compute P_m^m + yold = ((-1)**m_abs * semifactorial(2*m_abs-1)) * torch.pow(1-x*x, m_abs/2) + + # Compute P_{m+1}^m + if m_abs != l: + y = x * (2*m_abs+1) * yold + else: + y = yold + + # Compute P_{l}^m from recursion in P_{l-1}^m and P_{l-2}^m + for i in range(m_abs+2, l+1): + tmp = y + # Inplace speedup + y = ((2*i-1) / (i-m_abs)) * x * y + y -= ((i+m_abs-1)/(i-m_abs)) * yold + yold = tmp + + if m < 0: + y *= ((-1)**m / pochhammer(l+m+1, -2*m)) + + return y + +def tesseral_harmonics(l, m, theta=0., phi=0.): + """Tesseral spherical harmonic with Condon-Shortley phase. + + The Tesseral spherical harmonics are also known as the real spherical + harmonics. + + Args: + l: int for degree + m: int for order, where -l <= m < l + theta: collatitude or polar angle + phi: longitude or azimuth + Returns: + tensor of shape theta + """ + assert abs(m) <= l, "absolute value of order m must be <= degree l" + + N = np.sqrt((2*l+1) / (4*np.pi)) + leg = lpmv(l, abs(m), torch.cos(theta)) + if m == 0: + return N*leg + elif m > 0: + Y = torch.cos(m*phi) * leg + else: + Y = torch.sin(abs(m)*phi) * leg + N *= np.sqrt(2. / pochhammer(l-abs(m)+1, 2*abs(m))) + Y *= N + return Y + +class SphericalHarmonics(object): + def __init__(self): + self.leg = {} + + def clear(self): + self.leg = {} + + def negative_lpmv(self, l, m, y): + """Compute negative order coefficients""" + if m < 0: + y *= ((-1)**m / pochhammer(l+m+1, -2*m)) + return y + + def lpmv(self, l, m, x): + """Associated Legendre function including Condon-Shortley phase. + + Args: + m: int order + l: int degree + x: float argument tensor + Returns: + tensor of x-shape + """ + # Check memoized versions + m_abs = abs(m) + if (l,m) in self.leg: + return self.leg[(l,m)] + elif m_abs > l: + return None + elif l == 0: + self.leg[(l,m)] = torch.ones_like(x) + return self.leg[(l,m)] + + # Check if on boundary else recurse solution down to boundary + if m_abs == l: + # Compute P_m^m + y = (-1)**m_abs * semifactorial(2*m_abs-1) + y *= torch.pow(1-x*x, m_abs/2) + self.leg[(l,m)] = self.negative_lpmv(l, m, y) + return self.leg[(l,m)] + else: + # Recursively precompute lower degree harmonics + self.lpmv(l-1, m, x) + + # Compute P_{l}^m from recursion in P_{l-1}^m and P_{l-2}^m + # Inplace speedup + y = ((2*l-1) / (l-m_abs)) * x * self.lpmv(l-1, m_abs, x) + if l - m_abs > 1: + y -= ((l+m_abs-1)/(l-m_abs)) * self.leg[(l-2, m_abs)] + #self.leg[(l, m_abs)] = y + + if m < 0: + y = self.negative_lpmv(l, m, y) + self.leg[(l,m)] = y + + return self.leg[(l,m)] + + def get_element(self, l, m, theta, phi): + """Tesseral spherical harmonic with Condon-Shortley phase. + + The Tesseral spherical harmonics are also known as the real spherical + harmonics. + + Args: + l: int for degree + m: int for order, where -l <= m < l + theta: collatitude or polar angle + phi: longitude or azimuth + Returns: + tensor of shape theta + """ + assert abs(m) <= l, "absolute value of order m must be <= degree l" + + N = np.sqrt((2*l+1) / (4*np.pi)) + leg = self.lpmv(l, abs(m), torch.cos(theta)) + if m == 0: + return N*leg + elif m > 0: + Y = torch.cos(m*phi) * leg + else: + Y = torch.sin(abs(m)*phi) * leg + N *= np.sqrt(2. / pochhammer(l-abs(m)+1, 2*abs(m))) + Y *= N + return Y + + def get(self, l, theta, phi, refresh=True): + """Tesseral harmonic with Condon-Shortley phase. + + The Tesseral spherical harmonics are also known as the real spherical + harmonics. + + Args: + l: int for degree + theta: collatitude or polar angle + phi: longitude or azimuth + Returns: + tensor of shape [*theta.shape, 2*l+1] + """ + results = [] + if refresh: + self.clear() + for m in range(-l, l+1): + results.append(self.get_element(l, m, theta, phi)) + return torch.stack(results, -1) + diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/graph.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/graph.py new file mode 100644 index 0000000000000000000000000000000000000000..1eeb610c0c40511009172bc7b64b2b5060647a04 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/graph.py @@ -0,0 +1,934 @@ +import collections +import itertools +import os +import json +import warnings +import math + +import torch +import torch_geometric +from torch_geometric.data import Data, Batch +import numpy as np +import h5py + +from .model import get_spherical_from_cartesian, SphericalHarmonics +from .from_pymatgen import find_neighbors, _one_to_three, _compute_cube_index, _three_to_one + + +""" +The function _spherical_harmonics below is come from "https://github.com/e3nn/e3nn", which has the MIT License below + +--------------------------------------------------------------------------- +MIT License + +Euclidean neural networks (e3nn) Copyright (c) 2020, The Regents of the +University of California, through Lawrence Berkeley National Laboratory +(subject to receipt of any required approvals from the U.S. Dept. of Energy), +Ecole Polytechnique Federale de Lausanne (EPFL), Free University of Berlin +and Kostiantyn Lapchevskyi. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" +def _spherical_harmonics(lmax: int, x: torch.Tensor, y: torch.Tensor, z: torch.Tensor) -> torch.Tensor: + sh_0_0 = torch.ones_like(x) + if lmax == 0: + return torch.stack([ + sh_0_0, + ], dim=-1) + + sh_1_0 = x + sh_1_1 = y + sh_1_2 = z + if lmax == 1: + return torch.stack([ + sh_0_0, + sh_1_0, sh_1_1, sh_1_2 + ], dim=-1) + + sh_2_0 = math.sqrt(3.0) * x * z + sh_2_1 = math.sqrt(3.0) * x * y + y2 = y.pow(2) + x2z2 = x.pow(2) + z.pow(2) + sh_2_2 = y2 - 0.5 * x2z2 + sh_2_3 = math.sqrt(3.0) * y * z + sh_2_4 = math.sqrt(3.0) / 2.0 * (z.pow(2) - x.pow(2)) + + if lmax == 2: + return torch.stack([ + sh_0_0, + sh_1_0, sh_1_1, sh_1_2, + sh_2_0, sh_2_1, sh_2_2, sh_2_3, sh_2_4 + ], dim=-1) + + sh_3_0 = math.sqrt(5.0 / 6.0) * (sh_2_0 * z + sh_2_4 * x) + sh_3_1 = math.sqrt(5.0) * sh_2_0 * y + sh_3_2 = math.sqrt(3.0 / 8.0) * (4.0 * y2 - x2z2) * x + sh_3_3 = 0.5 * y * (2.0 * y2 - 3.0 * x2z2) + sh_3_4 = math.sqrt(3.0 / 8.0) * z * (4.0 * y2 - x2z2) + sh_3_5 = math.sqrt(5.0) * sh_2_4 * y + sh_3_6 = math.sqrt(5.0 / 6.0) * (sh_2_4 * z - sh_2_0 * x) + + if lmax == 3: + return torch.stack([ + sh_0_0, + sh_1_0, sh_1_1, sh_1_2, + sh_2_0, sh_2_1, sh_2_2, sh_2_3, sh_2_4, + sh_3_0, sh_3_1, sh_3_2, sh_3_3, sh_3_4, sh_3_5, sh_3_6 + ], dim=-1) + + sh_4_0 = 0.935414346693485*sh_3_0*z + 0.935414346693485*sh_3_6*x + sh_4_1 = 0.661437827766148*sh_3_0*y + 0.810092587300982*sh_3_1*z + 0.810092587300983*sh_3_5*x + sh_4_2 = -0.176776695296637*sh_3_0*z + 0.866025403784439*sh_3_1*y + 0.684653196881458*sh_3_2*z + 0.684653196881457*sh_3_4*x + 0.176776695296637*sh_3_6*x + sh_4_3 = -0.306186217847897*sh_3_1*z + 0.968245836551855*sh_3_2*y + 0.790569415042095*sh_3_3*x + 0.306186217847897*sh_3_5*x + sh_4_4 = -0.612372435695795*sh_3_2*x + sh_3_3*y - 0.612372435695795*sh_3_4*z + sh_4_5 = -0.306186217847897*sh_3_1*x + 0.790569415042096*sh_3_3*z + 0.968245836551854*sh_3_4*y - 0.306186217847897*sh_3_5*z + sh_4_6 = -0.176776695296637*sh_3_0*x - 0.684653196881457*sh_3_2*x + 0.684653196881457*sh_3_4*z + 0.866025403784439*sh_3_5*y - 0.176776695296637*sh_3_6*z + sh_4_7 = -0.810092587300982*sh_3_1*x + 0.810092587300982*sh_3_5*z + 0.661437827766148*sh_3_6*y + sh_4_8 = -0.935414346693485*sh_3_0*x + 0.935414346693486*sh_3_6*z + if lmax == 4: + return torch.stack([ + sh_0_0, + sh_1_0, sh_1_1, sh_1_2, + sh_2_0, sh_2_1, sh_2_2, sh_2_3, sh_2_4, + sh_3_0, sh_3_1, sh_3_2, sh_3_3, sh_3_4, sh_3_5, sh_3_6, + sh_4_0, sh_4_1, sh_4_2, sh_4_3, sh_4_4, sh_4_5, sh_4_6, sh_4_7, sh_4_8 + ], dim=-1) + + sh_5_0 = 0.948683298050513*sh_4_0*z + 0.948683298050513*sh_4_8*x + sh_5_1 = 0.6*sh_4_0*y + 0.848528137423857*sh_4_1*z + 0.848528137423858*sh_4_7*x + sh_5_2 = -0.14142135623731*sh_4_0*z + 0.8*sh_4_1*y + 0.748331477354788*sh_4_2*z + 0.748331477354788*sh_4_6*x + 0.14142135623731*sh_4_8*x + sh_5_3 = -0.244948974278318*sh_4_1*z + 0.916515138991168*sh_4_2*y + 0.648074069840786*sh_4_3*z + 0.648074069840787*sh_4_5*x + 0.244948974278318*sh_4_7*x + sh_5_4 = -0.346410161513776*sh_4_2*z + 0.979795897113272*sh_4_3*y + 0.774596669241484*sh_4_4*x + 0.346410161513776*sh_4_6*x + sh_5_5 = -0.632455532033676*sh_4_3*x + sh_4_4*y - 0.632455532033676*sh_4_5*z + sh_5_6 = -0.346410161513776*sh_4_2*x + 0.774596669241483*sh_4_4*z + 0.979795897113273*sh_4_5*y - 0.346410161513776*sh_4_6*z + sh_5_7 = -0.244948974278318*sh_4_1*x - 0.648074069840787*sh_4_3*x + 0.648074069840786*sh_4_5*z + 0.916515138991169*sh_4_6*y - 0.244948974278318*sh_4_7*z + sh_5_8 = -0.141421356237309*sh_4_0*x - 0.748331477354788*sh_4_2*x + 0.748331477354788*sh_4_6*z + 0.8*sh_4_7*y - 0.141421356237309*sh_4_8*z + sh_5_9 = -0.848528137423857*sh_4_1*x + 0.848528137423857*sh_4_7*z + 0.6*sh_4_8*y + sh_5_10 = -0.948683298050513*sh_4_0*x + 0.948683298050513*sh_4_8*z + if lmax == 5: + return torch.stack([ + sh_0_0, + sh_1_0, sh_1_1, sh_1_2, + sh_2_0, sh_2_1, sh_2_2, sh_2_3, sh_2_4, + sh_3_0, sh_3_1, sh_3_2, sh_3_3, sh_3_4, sh_3_5, sh_3_6, + sh_4_0, sh_4_1, sh_4_2, sh_4_3, sh_4_4, sh_4_5, sh_4_6, sh_4_7, sh_4_8, + sh_5_0, sh_5_1, sh_5_2, sh_5_3, sh_5_4, sh_5_5, sh_5_6, sh_5_7, sh_5_8, sh_5_9, sh_5_10 + ], dim=-1) + + sh_6_0 = 0.957427107756337*sh_5_0*z + 0.957427107756338*sh_5_10*x + sh_6_1 = 0.552770798392565*sh_5_0*y + 0.874007373475125*sh_5_1*z + 0.874007373475125*sh_5_9*x + sh_6_2 = -0.117851130197757*sh_5_0*z + 0.745355992499929*sh_5_1*y + 0.117851130197758*sh_5_10*x + 0.790569415042094*sh_5_2*z + 0.790569415042093*sh_5_8*x + sh_6_3 = -0.204124145231931*sh_5_1*z + 0.866025403784437*sh_5_2*y + 0.707106781186546*sh_5_3*z + 0.707106781186547*sh_5_7*x + 0.204124145231931*sh_5_9*x + sh_6_4 = -0.288675134594813*sh_5_2*z + 0.942809041582062*sh_5_3*y + 0.623609564462323*sh_5_4*z + 0.623609564462322*sh_5_6*x + 0.288675134594812*sh_5_8*x + sh_6_5 = -0.372677996249965*sh_5_3*z + 0.986013297183268*sh_5_4*y + 0.763762615825972*sh_5_5*x + 0.372677996249964*sh_5_7*x + sh_6_6 = -0.645497224367901*sh_5_4*x + sh_5_5*y - 0.645497224367902*sh_5_6*z + sh_6_7 = -0.372677996249964*sh_5_3*x + 0.763762615825972*sh_5_5*z + 0.986013297183269*sh_5_6*y - 0.372677996249965*sh_5_7*z + sh_6_8 = -0.288675134594813*sh_5_2*x - 0.623609564462323*sh_5_4*x + 0.623609564462323*sh_5_6*z + 0.942809041582062*sh_5_7*y - 0.288675134594812*sh_5_8*z + sh_6_9 = -0.20412414523193*sh_5_1*x - 0.707106781186546*sh_5_3*x + 0.707106781186547*sh_5_7*z + 0.866025403784438*sh_5_8*y - 0.204124145231931*sh_5_9*z + sh_6_10 = -0.117851130197757*sh_5_0*x - 0.117851130197757*sh_5_10*z - 0.790569415042094*sh_5_2*x + 0.790569415042093*sh_5_8*z + 0.745355992499929*sh_5_9*y + sh_6_11 = -0.874007373475124*sh_5_1*x + 0.552770798392566*sh_5_10*y + 0.874007373475125*sh_5_9*z + sh_6_12 = -0.957427107756337*sh_5_0*x + 0.957427107756336*sh_5_10*z + if lmax == 6: + return torch.stack([ + sh_0_0, + sh_1_0, sh_1_1, sh_1_2, + sh_2_0, sh_2_1, sh_2_2, sh_2_3, sh_2_4, + sh_3_0, sh_3_1, sh_3_2, sh_3_3, sh_3_4, sh_3_5, sh_3_6, + sh_4_0, sh_4_1, sh_4_2, sh_4_3, sh_4_4, sh_4_5, sh_4_6, sh_4_7, sh_4_8, + sh_5_0, sh_5_1, sh_5_2, sh_5_3, sh_5_4, sh_5_5, sh_5_6, sh_5_7, sh_5_8, sh_5_9, sh_5_10, + sh_6_0, sh_6_1, sh_6_2, sh_6_3, sh_6_4, sh_6_5, sh_6_6, sh_6_7, sh_6_8, sh_6_9, sh_6_10, sh_6_11, sh_6_12 + ], dim=-1) + + sh_7_0 = 0.963624111659433*sh_6_0*z + 0.963624111659432*sh_6_12*x + sh_7_1 = 0.515078753637713*sh_6_0*y + 0.892142571199771*sh_6_1*z + 0.892142571199771*sh_6_11*x + sh_7_2 = -0.101015254455221*sh_6_0*z + 0.699854212223765*sh_6_1*y + 0.82065180664829*sh_6_10*x + 0.101015254455222*sh_6_12*x + 0.82065180664829*sh_6_2*z + sh_7_3 = -0.174963553055942*sh_6_1*z + 0.174963553055941*sh_6_11*x + 0.82065180664829*sh_6_2*y + 0.749149177264394*sh_6_3*z + 0.749149177264394*sh_6_9*x + sh_7_4 = 0.247435829652697*sh_6_10*x - 0.247435829652697*sh_6_2*z + 0.903507902905251*sh_6_3*y + 0.677630927178938*sh_6_4*z + 0.677630927178938*sh_6_8*x + sh_7_5 = -0.31943828249997*sh_6_3*z + 0.95831484749991*sh_6_4*y + 0.606091526731326*sh_6_5*z + 0.606091526731326*sh_6_7*x + 0.31943828249997*sh_6_9*x + sh_7_6 = -0.391230398217976*sh_6_4*z + 0.989743318610787*sh_6_5*y + 0.755928946018454*sh_6_6*x + 0.391230398217975*sh_6_8*x + sh_7_7 = -0.654653670707977*sh_6_5*x + sh_6_6*y - 0.654653670707978*sh_6_7*z + sh_7_8 = -0.391230398217976*sh_6_4*x + 0.755928946018455*sh_6_6*z + 0.989743318610787*sh_6_7*y - 0.391230398217975*sh_6_8*z + sh_7_9 = -0.31943828249997*sh_6_3*x - 0.606091526731327*sh_6_5*x + 0.606091526731326*sh_6_7*z + 0.95831484749991*sh_6_8*y - 0.31943828249997*sh_6_9*z + sh_7_10 = -0.247435829652697*sh_6_10*z - 0.247435829652697*sh_6_2*x - 0.677630927178938*sh_6_4*x + 0.677630927178938*sh_6_8*z + 0.903507902905251*sh_6_9*y + sh_7_11 = -0.174963553055942*sh_6_1*x + 0.820651806648289*sh_6_10*y - 0.174963553055941*sh_6_11*z - 0.749149177264394*sh_6_3*x + 0.749149177264394*sh_6_9*z + sh_7_12 = -0.101015254455221*sh_6_0*x + 0.82065180664829*sh_6_10*z + 0.699854212223766*sh_6_11*y - 0.101015254455221*sh_6_12*z - 0.82065180664829*sh_6_2*x + sh_7_13 = -0.892142571199772*sh_6_1*x + 0.892142571199772*sh_6_11*z + 0.515078753637713*sh_6_12*y + sh_7_14 = -0.963624111659431*sh_6_0*x + 0.963624111659433*sh_6_12*z + if lmax == 7: + return torch.stack([ + sh_0_0, + sh_1_0, sh_1_1, sh_1_2, + sh_2_0, sh_2_1, sh_2_2, sh_2_3, sh_2_4, + sh_3_0, sh_3_1, sh_3_2, sh_3_3, sh_3_4, sh_3_5, sh_3_6, + sh_4_0, sh_4_1, sh_4_2, sh_4_3, sh_4_4, sh_4_5, sh_4_6, sh_4_7, sh_4_8, + sh_5_0, sh_5_1, sh_5_2, sh_5_3, sh_5_4, sh_5_5, sh_5_6, sh_5_7, sh_5_8, sh_5_9, sh_5_10, + sh_6_0, sh_6_1, sh_6_2, sh_6_3, sh_6_4, sh_6_5, sh_6_6, sh_6_7, sh_6_8, sh_6_9, sh_6_10, sh_6_11, sh_6_12, + sh_7_0, sh_7_1, sh_7_2, sh_7_3, sh_7_4, sh_7_5, sh_7_6, sh_7_7, sh_7_8, sh_7_9, sh_7_10, sh_7_11, sh_7_12, sh_7_13, sh_7_14 + ], dim=-1) + + sh_8_0 = 0.968245836551854*sh_7_0*z + 0.968245836551853*sh_7_14*x + sh_8_1 = 0.484122918275928*sh_7_0*y + 0.90571104663684*sh_7_1*z + 0.90571104663684*sh_7_13*x + sh_8_2 = -0.0883883476483189*sh_7_0*z + 0.661437827766148*sh_7_1*y + 0.843171097702002*sh_7_12*x + 0.088388347648318*sh_7_14*x + 0.843171097702003*sh_7_2*z + sh_8_3 = -0.153093108923948*sh_7_1*z + 0.7806247497998*sh_7_11*x + 0.153093108923949*sh_7_13*x + 0.7806247497998*sh_7_2*y + 0.780624749799799*sh_7_3*z + sh_8_4 = 0.718070330817253*sh_7_10*x + 0.21650635094611*sh_7_12*x - 0.21650635094611*sh_7_2*z + 0.866025403784439*sh_7_3*y + 0.718070330817254*sh_7_4*z + sh_8_5 = 0.279508497187474*sh_7_11*x - 0.279508497187474*sh_7_3*z + 0.927024810886958*sh_7_4*y + 0.655505530106345*sh_7_5*z + 0.655505530106344*sh_7_9*x + sh_8_6 = 0.342326598440729*sh_7_10*x - 0.342326598440729*sh_7_4*z + 0.968245836551854*sh_7_5*y + 0.592927061281572*sh_7_6*z + 0.592927061281571*sh_7_8*x + sh_8_7 = -0.405046293650492*sh_7_5*z + 0.992156741649221*sh_7_6*y + 0.75*sh_7_7*x + 0.405046293650492*sh_7_9*x + sh_8_8 = -0.661437827766148*sh_7_6*x + sh_7_7*y - 0.661437827766148*sh_7_8*z + sh_8_9 = -0.405046293650492*sh_7_5*x + 0.75*sh_7_7*z + 0.992156741649221*sh_7_8*y - 0.405046293650491*sh_7_9*z + sh_8_10 = -0.342326598440728*sh_7_10*z - 0.342326598440729*sh_7_4*x - 0.592927061281571*sh_7_6*x + 0.592927061281571*sh_7_8*z + 0.968245836551855*sh_7_9*y + sh_8_11 = 0.927024810886958*sh_7_10*y - 0.279508497187474*sh_7_11*z - 0.279508497187474*sh_7_3*x - 0.655505530106345*sh_7_5*x + 0.655505530106345*sh_7_9*z + sh_8_12 = 0.718070330817253*sh_7_10*z + 0.866025403784439*sh_7_11*y - 0.216506350946109*sh_7_12*z - 0.216506350946109*sh_7_2*x - 0.718070330817254*sh_7_4*x + sh_8_13 = -0.153093108923948*sh_7_1*x + 0.7806247497998*sh_7_11*z + 0.7806247497998*sh_7_12*y - 0.153093108923948*sh_7_13*z - 0.780624749799799*sh_7_3*x + sh_8_14 = -0.0883883476483179*sh_7_0*x + 0.843171097702002*sh_7_12*z + 0.661437827766147*sh_7_13*y - 0.088388347648319*sh_7_14*z - 0.843171097702002*sh_7_2*x + sh_8_15 = -0.90571104663684*sh_7_1*x + 0.90571104663684*sh_7_13*z + 0.484122918275927*sh_7_14*y + sh_8_16 = -0.968245836551853*sh_7_0*x + 0.968245836551855*sh_7_14*z + if lmax == 8: + return torch.stack([ + sh_0_0, + sh_1_0, sh_1_1, sh_1_2, + sh_2_0, sh_2_1, sh_2_2, sh_2_3, sh_2_4, + sh_3_0, sh_3_1, sh_3_2, sh_3_3, sh_3_4, sh_3_5, sh_3_6, + sh_4_0, sh_4_1, sh_4_2, sh_4_3, sh_4_4, sh_4_5, sh_4_6, sh_4_7, sh_4_8, + sh_5_0, sh_5_1, sh_5_2, sh_5_3, sh_5_4, sh_5_5, sh_5_6, sh_5_7, sh_5_8, sh_5_9, sh_5_10, + sh_6_0, sh_6_1, sh_6_2, sh_6_3, sh_6_4, sh_6_5, sh_6_6, sh_6_7, sh_6_8, sh_6_9, sh_6_10, sh_6_11, sh_6_12, + sh_7_0, sh_7_1, sh_7_2, sh_7_3, sh_7_4, sh_7_5, sh_7_6, sh_7_7, sh_7_8, sh_7_9, sh_7_10, sh_7_11, sh_7_12, sh_7_13, sh_7_14, + sh_8_0, sh_8_1, sh_8_2, sh_8_3, sh_8_4, sh_8_5, sh_8_6, sh_8_7, sh_8_8, sh_8_9, sh_8_10, sh_8_11, sh_8_12, sh_8_13, sh_8_14, sh_8_15, sh_8_16 + ], dim=-1) + + sh_9_0 = 0.97182531580755*sh_8_0*z + 0.971825315807551*sh_8_16*x + sh_9_1 = 0.458122847290851*sh_8_0*y + 0.916245694581702*sh_8_1*z + 0.916245694581702*sh_8_15*x + sh_9_2 = -0.078567420131839*sh_8_0*z + 0.62853936105471*sh_8_1*y + 0.86066296582387*sh_8_14*x + 0.0785674201318385*sh_8_16*x + 0.860662965823871*sh_8_2*z + sh_9_3 = -0.136082763487955*sh_8_1*z + 0.805076485899413*sh_8_13*x + 0.136082763487954*sh_8_15*x + 0.74535599249993*sh_8_2*y + 0.805076485899413*sh_8_3*z + sh_9_4 = 0.749485420179558*sh_8_12*x + 0.192450089729875*sh_8_14*x - 0.192450089729876*sh_8_2*z + 0.831479419283099*sh_8_3*y + 0.749485420179558*sh_8_4*z + sh_9_5 = 0.693888666488711*sh_8_11*x + 0.248451997499977*sh_8_13*x - 0.248451997499976*sh_8_3*z + 0.895806416477617*sh_8_4*y + 0.69388866648871*sh_8_5*z + sh_9_6 = 0.638284738504225*sh_8_10*x + 0.304290309725092*sh_8_12*x - 0.304290309725092*sh_8_4*z + 0.942809041582063*sh_8_5*y + 0.638284738504225*sh_8_6*z + sh_9_7 = 0.360041149911548*sh_8_11*x - 0.360041149911548*sh_8_5*z + 0.974996043043569*sh_8_6*y + 0.582671582316751*sh_8_7*z + 0.582671582316751*sh_8_9*x + sh_9_8 = 0.415739709641549*sh_8_10*x - 0.415739709641549*sh_8_6*z + 0.993807989999906*sh_8_7*y + 0.74535599249993*sh_8_8*x + sh_9_9 = -0.66666666666666666667*sh_8_7*x + sh_8_8*y - 0.66666666666666666667*sh_8_9*z + sh_9_10 = -0.415739709641549*sh_8_10*z - 0.415739709641549*sh_8_6*x + 0.74535599249993*sh_8_8*z + 0.993807989999906*sh_8_9*y + sh_9_11 = 0.974996043043568*sh_8_10*y - 0.360041149911547*sh_8_11*z - 0.360041149911548*sh_8_5*x - 0.582671582316751*sh_8_7*x + 0.582671582316751*sh_8_9*z + sh_9_12 = 0.638284738504225*sh_8_10*z + 0.942809041582063*sh_8_11*y - 0.304290309725092*sh_8_12*z - 0.304290309725092*sh_8_4*x - 0.638284738504225*sh_8_6*x + sh_9_13 = 0.693888666488711*sh_8_11*z + 0.895806416477617*sh_8_12*y - 0.248451997499977*sh_8_13*z - 0.248451997499977*sh_8_3*x - 0.693888666488711*sh_8_5*x + sh_9_14 = 0.749485420179558*sh_8_12*z + 0.831479419283098*sh_8_13*y - 0.192450089729875*sh_8_14*z - 0.192450089729875*sh_8_2*x - 0.749485420179558*sh_8_4*x + sh_9_15 = -0.136082763487954*sh_8_1*x + 0.805076485899413*sh_8_13*z + 0.745355992499929*sh_8_14*y - 0.136082763487955*sh_8_15*z - 0.805076485899413*sh_8_3*x + sh_9_16 = -0.0785674201318389*sh_8_0*x + 0.86066296582387*sh_8_14*z + 0.628539361054709*sh_8_15*y - 0.0785674201318387*sh_8_16*z - 0.860662965823871*sh_8_2*x + sh_9_17 = -0.9162456945817*sh_8_1*x + 0.916245694581702*sh_8_15*z + 0.458122847290851*sh_8_16*y + sh_9_18 = -0.97182531580755*sh_8_0*x + 0.97182531580755*sh_8_16*z + if lmax == 9: + return torch.stack([ + sh_0_0, + sh_1_0, sh_1_1, sh_1_2, + sh_2_0, sh_2_1, sh_2_2, sh_2_3, sh_2_4, + sh_3_0, sh_3_1, sh_3_2, sh_3_3, sh_3_4, sh_3_5, sh_3_6, + sh_4_0, sh_4_1, sh_4_2, sh_4_3, sh_4_4, sh_4_5, sh_4_6, sh_4_7, sh_4_8, + sh_5_0, sh_5_1, sh_5_2, sh_5_3, sh_5_4, sh_5_5, sh_5_6, sh_5_7, sh_5_8, sh_5_9, sh_5_10, + sh_6_0, sh_6_1, sh_6_2, sh_6_3, sh_6_4, sh_6_5, sh_6_6, sh_6_7, sh_6_8, sh_6_9, sh_6_10, sh_6_11, sh_6_12, + sh_7_0, sh_7_1, sh_7_2, sh_7_3, sh_7_4, sh_7_5, sh_7_6, sh_7_7, sh_7_8, sh_7_9, sh_7_10, sh_7_11, sh_7_12, sh_7_13, sh_7_14, + sh_8_0, sh_8_1, sh_8_2, sh_8_3, sh_8_4, sh_8_5, sh_8_6, sh_8_7, sh_8_8, sh_8_9, sh_8_10, sh_8_11, sh_8_12, sh_8_13, sh_8_14, sh_8_15, sh_8_16, + sh_9_0, sh_9_1, sh_9_2, sh_9_3, sh_9_4, sh_9_5, sh_9_6, sh_9_7, sh_9_8, sh_9_9, sh_9_10, sh_9_11, sh_9_12, sh_9_13, sh_9_14, sh_9_15, sh_9_16, sh_9_17, sh_9_18 + ], dim=-1) + + sh_10_0 = 0.974679434480897*sh_9_0*z + 0.974679434480897*sh_9_18*x + sh_10_1 = 0.435889894354067*sh_9_0*y + 0.924662100445347*sh_9_1*z + 0.924662100445347*sh_9_17*x + sh_10_2 = -0.0707106781186546*sh_9_0*z + 0.6*sh_9_1*y + 0.874642784226796*sh_9_16*x + 0.070710678118655*sh_9_18*x + 0.874642784226795*sh_9_2*z + sh_10_3 = -0.122474487139159*sh_9_1*z + 0.824621125123533*sh_9_15*x + 0.122474487139159*sh_9_17*x + 0.714142842854285*sh_9_2*y + 0.824621125123533*sh_9_3*z + sh_10_4 = 0.774596669241484*sh_9_14*x + 0.173205080756887*sh_9_16*x - 0.173205080756888*sh_9_2*z + 0.8*sh_9_3*y + 0.774596669241483*sh_9_4*z + sh_10_5 = 0.724568837309472*sh_9_13*x + 0.223606797749979*sh_9_15*x - 0.223606797749979*sh_9_3*z + 0.866025403784438*sh_9_4*y + 0.724568837309472*sh_9_5*z + sh_10_6 = 0.674536878161602*sh_9_12*x + 0.273861278752583*sh_9_14*x - 0.273861278752583*sh_9_4*z + 0.916515138991168*sh_9_5*y + 0.674536878161602*sh_9_6*z + sh_10_7 = 0.62449979983984*sh_9_11*x + 0.324037034920393*sh_9_13*x - 0.324037034920393*sh_9_5*z + 0.953939201416946*sh_9_6*y + 0.62449979983984*sh_9_7*z + sh_10_8 = 0.574456264653803*sh_9_10*x + 0.374165738677394*sh_9_12*x - 0.374165738677394*sh_9_6*z + 0.979795897113272*sh_9_7*y + 0.574456264653803*sh_9_8*z + sh_10_9 = 0.424264068711928*sh_9_11*x - 0.424264068711929*sh_9_7*z + 0.99498743710662*sh_9_8*y + 0.741619848709567*sh_9_9*x + sh_10_10 = -0.670820393249937*sh_9_10*z - 0.670820393249937*sh_9_8*x + sh_9_9*y + sh_10_11 = 0.99498743710662*sh_9_10*y - 0.424264068711929*sh_9_11*z - 0.424264068711929*sh_9_7*x + 0.741619848709567*sh_9_9*z + sh_10_12 = 0.574456264653803*sh_9_10*z + 0.979795897113272*sh_9_11*y - 0.374165738677395*sh_9_12*z - 0.374165738677394*sh_9_6*x - 0.574456264653803*sh_9_8*x + sh_10_13 = 0.62449979983984*sh_9_11*z + 0.953939201416946*sh_9_12*y - 0.324037034920393*sh_9_13*z - 0.324037034920393*sh_9_5*x - 0.62449979983984*sh_9_7*x + sh_10_14 = 0.674536878161602*sh_9_12*z + 0.916515138991168*sh_9_13*y - 0.273861278752583*sh_9_14*z - 0.273861278752583*sh_9_4*x - 0.674536878161603*sh_9_6*x + sh_10_15 = 0.724568837309472*sh_9_13*z + 0.866025403784439*sh_9_14*y - 0.223606797749979*sh_9_15*z - 0.223606797749979*sh_9_3*x - 0.724568837309472*sh_9_5*x + sh_10_16 = 0.774596669241484*sh_9_14*z + 0.8*sh_9_15*y - 0.173205080756888*sh_9_16*z - 0.173205080756887*sh_9_2*x - 0.774596669241484*sh_9_4*x + sh_10_17 = -0.12247448713916*sh_9_1*x + 0.824621125123532*sh_9_15*z + 0.714142842854285*sh_9_16*y - 0.122474487139158*sh_9_17*z - 0.824621125123533*sh_9_3*x + sh_10_18 = -0.0707106781186548*sh_9_0*x + 0.874642784226796*sh_9_16*z + 0.6*sh_9_17*y - 0.0707106781186546*sh_9_18*z - 0.874642784226796*sh_9_2*x + sh_10_19 = -0.924662100445348*sh_9_1*x + 0.924662100445347*sh_9_17*z + 0.435889894354068*sh_9_18*y + sh_10_20 = -0.974679434480898*sh_9_0*x + 0.974679434480896*sh_9_18*z + if lmax == 10: + return torch.stack([ + sh_0_0, + sh_1_0, sh_1_1, sh_1_2, + sh_2_0, sh_2_1, sh_2_2, sh_2_3, sh_2_4, + sh_3_0, sh_3_1, sh_3_2, sh_3_3, sh_3_4, sh_3_5, sh_3_6, + sh_4_0, sh_4_1, sh_4_2, sh_4_3, sh_4_4, sh_4_5, sh_4_6, sh_4_7, sh_4_8, + sh_5_0, sh_5_1, sh_5_2, sh_5_3, sh_5_4, sh_5_5, sh_5_6, sh_5_7, sh_5_8, sh_5_9, sh_5_10, + sh_6_0, sh_6_1, sh_6_2, sh_6_3, sh_6_4, sh_6_5, sh_6_6, sh_6_7, sh_6_8, sh_6_9, sh_6_10, sh_6_11, sh_6_12, + sh_7_0, sh_7_1, sh_7_2, sh_7_3, sh_7_4, sh_7_5, sh_7_6, sh_7_7, sh_7_8, sh_7_9, sh_7_10, sh_7_11, sh_7_12, sh_7_13, sh_7_14, + sh_8_0, sh_8_1, sh_8_2, sh_8_3, sh_8_4, sh_8_5, sh_8_6, sh_8_7, sh_8_8, sh_8_9, sh_8_10, sh_8_11, sh_8_12, sh_8_13, sh_8_14, sh_8_15, sh_8_16, + sh_9_0, sh_9_1, sh_9_2, sh_9_3, sh_9_4, sh_9_5, sh_9_6, sh_9_7, sh_9_8, sh_9_9, sh_9_10, sh_9_11, sh_9_12, sh_9_13, sh_9_14, sh_9_15, sh_9_16, sh_9_17, sh_9_18, + sh_10_0, sh_10_1, sh_10_2, sh_10_3, sh_10_4, sh_10_5, sh_10_6, sh_10_7, sh_10_8, sh_10_9, sh_10_10, sh_10_11, sh_10_12, sh_10_13, sh_10_14, sh_10_15, sh_10_16, sh_10_17, sh_10_18, sh_10_19, sh_10_20 + ], dim=-1) + + sh_11_0 = 0.977008420918394*sh_10_0*z + 0.977008420918394*sh_10_20*x + sh_11_1 = 0.416597790450531*sh_10_0*y + 0.9315409787236*sh_10_1*z + 0.931540978723599*sh_10_19*x + sh_11_2 = -0.0642824346533223*sh_10_0*z + 0.574959574576069*sh_10_1*y + 0.88607221316445*sh_10_18*x + 0.886072213164452*sh_10_2*z + 0.0642824346533226*sh_10_20*x + sh_11_3 = -0.111340442853781*sh_10_1*z + 0.84060190949577*sh_10_17*x + 0.111340442853781*sh_10_19*x + 0.686348585024614*sh_10_2*y + 0.840601909495769*sh_10_3*z + sh_11_4 = 0.795129803842541*sh_10_16*x + 0.157459164324444*sh_10_18*x - 0.157459164324443*sh_10_2*z + 0.771389215839871*sh_10_3*y + 0.795129803842541*sh_10_4*z + sh_11_5 = 0.74965556829412*sh_10_15*x + 0.203278907045435*sh_10_17*x - 0.203278907045436*sh_10_3*z + 0.838140405208444*sh_10_4*y + 0.74965556829412*sh_10_5*z + sh_11_6 = 0.70417879021953*sh_10_14*x + 0.248964798865985*sh_10_16*x - 0.248964798865985*sh_10_4*z + 0.890723542830247*sh_10_5*y + 0.704178790219531*sh_10_6*z + sh_11_7 = 0.658698943008611*sh_10_13*x + 0.294579122654903*sh_10_15*x - 0.294579122654903*sh_10_5*z + 0.9315409787236*sh_10_6*y + 0.658698943008611*sh_10_7*z + sh_11_8 = 0.613215343783275*sh_10_12*x + 0.340150671524904*sh_10_14*x - 0.340150671524904*sh_10_6*z + 0.962091385841669*sh_10_7*y + 0.613215343783274*sh_10_8*z + sh_11_9 = 0.567727090763491*sh_10_11*x + 0.385694607919935*sh_10_13*x - 0.385694607919935*sh_10_7*z + 0.983332166035633*sh_10_8*y + 0.56772709076349*sh_10_9*z + sh_11_10 = 0.738548945875997*sh_10_10*x + 0.431219680932052*sh_10_12*x - 0.431219680932052*sh_10_8*z + 0.995859195463938*sh_10_9*y + sh_11_11 = sh_10_10*y - 0.674199862463242*sh_10_11*z - 0.674199862463243*sh_10_9*x + sh_11_12 = 0.738548945875996*sh_10_10*z + 0.995859195463939*sh_10_11*y - 0.431219680932052*sh_10_12*z - 0.431219680932053*sh_10_8*x + sh_11_13 = 0.567727090763491*sh_10_11*z + 0.983332166035634*sh_10_12*y - 0.385694607919935*sh_10_13*z - 0.385694607919935*sh_10_7*x - 0.567727090763491*sh_10_9*x + sh_11_14 = 0.613215343783275*sh_10_12*z + 0.96209138584167*sh_10_13*y - 0.340150671524904*sh_10_14*z - 0.340150671524904*sh_10_6*x - 0.613215343783274*sh_10_8*x + sh_11_15 = 0.658698943008611*sh_10_13*z + 0.9315409787236*sh_10_14*y - 0.294579122654903*sh_10_15*z - 0.294579122654903*sh_10_5*x - 0.65869894300861*sh_10_7*x + sh_11_16 = 0.70417879021953*sh_10_14*z + 0.890723542830246*sh_10_15*y - 0.248964798865985*sh_10_16*z - 0.248964798865985*sh_10_4*x - 0.70417879021953*sh_10_6*x + sh_11_17 = 0.749655568294121*sh_10_15*z + 0.838140405208444*sh_10_16*y - 0.203278907045436*sh_10_17*z - 0.203278907045435*sh_10_3*x - 0.749655568294119*sh_10_5*x + sh_11_18 = 0.79512980384254*sh_10_16*z + 0.77138921583987*sh_10_17*y - 0.157459164324443*sh_10_18*z - 0.157459164324444*sh_10_2*x - 0.795129803842541*sh_10_4*x + sh_11_19 = -0.111340442853782*sh_10_1*x + 0.84060190949577*sh_10_17*z + 0.686348585024614*sh_10_18*y - 0.111340442853781*sh_10_19*z - 0.840601909495769*sh_10_3*x + sh_11_20 = -0.0642824346533226*sh_10_0*x + 0.886072213164451*sh_10_18*z + 0.57495957457607*sh_10_19*y - 0.886072213164451*sh_10_2*x - 0.0642824346533228*sh_10_20*z + sh_11_21 = -0.9315409787236*sh_10_1*x + 0.931540978723599*sh_10_19*z + 0.416597790450531*sh_10_20*y + sh_11_22 = -0.977008420918393*sh_10_0*x + 0.977008420918393*sh_10_20*z + return torch.stack([ + sh_0_0, + sh_1_0, sh_1_1, sh_1_2, + sh_2_0, sh_2_1, sh_2_2, sh_2_3, sh_2_4, + sh_3_0, sh_3_1, sh_3_2, sh_3_3, sh_3_4, sh_3_5, sh_3_6, + sh_4_0, sh_4_1, sh_4_2, sh_4_3, sh_4_4, sh_4_5, sh_4_6, sh_4_7, sh_4_8, + sh_5_0, sh_5_1, sh_5_2, sh_5_3, sh_5_4, sh_5_5, sh_5_6, sh_5_7, sh_5_8, sh_5_9, sh_5_10, + sh_6_0, sh_6_1, sh_6_2, sh_6_3, sh_6_4, sh_6_5, sh_6_6, sh_6_7, sh_6_8, sh_6_9, sh_6_10, sh_6_11, sh_6_12, + sh_7_0, sh_7_1, sh_7_2, sh_7_3, sh_7_4, sh_7_5, sh_7_6, sh_7_7, sh_7_8, sh_7_9, sh_7_10, sh_7_11, sh_7_12, sh_7_13, sh_7_14, + sh_8_0, sh_8_1, sh_8_2, sh_8_3, sh_8_4, sh_8_5, sh_8_6, sh_8_7, sh_8_8, sh_8_9, sh_8_10, sh_8_11, sh_8_12, sh_8_13, sh_8_14, sh_8_15, sh_8_16, + sh_9_0, sh_9_1, sh_9_2, sh_9_3, sh_9_4, sh_9_5, sh_9_6, sh_9_7, sh_9_8, sh_9_9, sh_9_10, sh_9_11, sh_9_12, sh_9_13, sh_9_14, sh_9_15, sh_9_16, sh_9_17, sh_9_18, + sh_10_0, sh_10_1, sh_10_2, sh_10_3, sh_10_4, sh_10_5, sh_10_6, sh_10_7, sh_10_8, sh_10_9, sh_10_10, sh_10_11, sh_10_12, sh_10_13, sh_10_14, sh_10_15, sh_10_16, sh_10_17, sh_10_18, sh_10_19, sh_10_20, + sh_11_0, sh_11_1, sh_11_2, sh_11_3, sh_11_4, sh_11_5, sh_11_6, sh_11_7, sh_11_8, sh_11_9, sh_11_10, sh_11_11, sh_11_12, sh_11_13, sh_11_14, sh_11_15, sh_11_16, sh_11_17, sh_11_18, sh_11_19, sh_11_20, sh_11_21, sh_11_22 + ], dim=-1) + + +def collate_fn(graph_list): + return Collater(if_lcmp=True)(graph_list) + + +class Collater: + def __init__(self, if_lcmp): + self.if_lcmp = if_lcmp + self.flag_pyg2 = (torch_geometric.__version__[0] == '2') + + def __call__(self, graph_list): + if self.if_lcmp: + flag_dict = hasattr(graph_list[0], 'subgraph_dict') + if self.flag_pyg2: + assert flag_dict, 'Please generate the graph file with the current version of PyG' + batch = Batch.from_data_list(graph_list) + + subgraph_atom_idx_batch = [] + subgraph_edge_idx_batch = [] + subgraph_edge_ang_batch = [] + subgraph_index_batch = [] + if flag_dict: + for index_batch in range(len(graph_list)): + (subgraph_atom_idx, subgraph_edge_idx, subgraph_edge_ang, + subgraph_index) = graph_list[index_batch].subgraph_dict.values() + if self.flag_pyg2: + subgraph_atom_idx_batch.append(subgraph_atom_idx + batch._slice_dict['x'][index_batch]) + subgraph_edge_idx_batch.append(subgraph_edge_idx + batch._slice_dict['edge_attr'][index_batch]) + subgraph_index_batch.append(subgraph_index + batch._slice_dict['edge_attr'][index_batch] * 2) + else: + subgraph_atom_idx_batch.append(subgraph_atom_idx + batch.__slices__['x'][index_batch]) + subgraph_edge_idx_batch.append(subgraph_edge_idx + batch.__slices__['edge_attr'][index_batch]) + subgraph_index_batch.append(subgraph_index + batch.__slices__['edge_attr'][index_batch] * 2) + subgraph_edge_ang_batch.append(subgraph_edge_ang) + else: + for index_batch, (subgraph_atom_idx, subgraph_edge_idx, + subgraph_edge_ang, subgraph_index) in enumerate(batch.subgraph): + subgraph_atom_idx_batch.append(subgraph_atom_idx + batch.__slices__['x'][index_batch]) + subgraph_edge_idx_batch.append(subgraph_edge_idx + batch.__slices__['edge_attr'][index_batch]) + subgraph_edge_ang_batch.append(subgraph_edge_ang) + subgraph_index_batch.append(subgraph_index + batch.__slices__['edge_attr'][index_batch] * 2) + + subgraph_atom_idx_batch = torch.cat(subgraph_atom_idx_batch, dim=0) + subgraph_edge_idx_batch = torch.cat(subgraph_edge_idx_batch, dim=0) + subgraph_edge_ang_batch = torch.cat(subgraph_edge_ang_batch, dim=0) + subgraph_index_batch = torch.cat(subgraph_index_batch, dim=0) + + subgraph = (subgraph_atom_idx_batch, subgraph_edge_idx_batch, subgraph_edge_ang_batch, subgraph_index_batch) + + return batch, subgraph + else: + return Batch.from_data_list(graph_list) + + +def load_orbital_types(path, return_orbital_types=False): + orbital_types = [] + with open(path) as f: + line = f.readline() + while line: + orbital_types.append(list(map(int, line.split()))) + line = f.readline() + atom_num_orbital = [sum(map(lambda x: 2 * x + 1,atom_orbital_types)) for atom_orbital_types in orbital_types] + if return_orbital_types: + return atom_num_orbital, orbital_types + else: + return atom_num_orbital + + +""" +The function get_graph below is extended from "https://github.com/materialsproject/pymatgen", which has the MIT License below + +--------------------------------------------------------------------------- +The MIT License (MIT) +Copyright (c) 2011-2012 MIT & The Regents of the University of California, through Lawrence Berkeley National Laboratory + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +""" +def get_graph(cart_coords, frac_coords, numbers, stru_id, r, max_num_nbr, numerical_tol, lattice, + default_dtype_torch, tb_folder, interface, num_l, create_from_DFT, if_lcmp_graph, + separate_onsite, target='hamiltonian', huge_structure=False, only_get_R_list=False, if_new_sp=False, + if_require_grad=False, fid_rc=None, **kwargs): + assert target in ['hamiltonian', 'phiVdphi', 'density_matrix', 'O_ij', 'E_ij', 'E_i'] + if target == 'density_matrix' or target == 'O_ij': + assert interface == 'h5' or interface == 'h5_rc_only' + if target == 'E_ij': + assert interface == 'h5' + assert create_from_DFT is True + assert separate_onsite is True + if target == 'E_i': + assert interface == 'h5' + assert if_lcmp_graph is False + assert separate_onsite is True + if create_from_DFT: + assert tb_folder is not None + assert max_num_nbr == 0 + if interface == 'h5_rc_only' and target == 'E_ij': + raise NotImplementedError + elif interface == 'h5' or (interface == 'h5_rc_only' and target != 'E_ij'): + key_atom_list = [[] for _ in range(len(numbers))] + edge_idx, edge_fea, edge_idx_first = [], [], [] + if if_lcmp_graph: + atom_idx_connect, edge_idx_connect = [], [] + edge_idx_connect_cursor = 0 + if target == 'E_ij': + fid = h5py.File(os.path.join(tb_folder, 'E_delta_ee_ij.h5'), 'r') + else: + if if_require_grad: + fid = fid_rc + else: + fid = h5py.File(os.path.join(tb_folder, 'rc.h5'), 'r') + for k in fid.keys(): + key = json.loads(k) + key_tensor = torch.tensor([key[0], key[1], key[2], key[3] - 1, key[4] - 1]) # (R, i, j) i and j is 0-based index + if separate_onsite: + if key[0] == 0 and key[1] == 0 and key[2] == 0 and key[3] == key[4]: + continue + key_atom_list[key[3] - 1].append(key_tensor) + if target != 'E_ij' and not if_require_grad: + fid.close() + + for index_first, (cart_coord, keys_tensor) in enumerate(zip(cart_coords, key_atom_list)): + keys_tensor = torch.stack(keys_tensor) + cart_coords_j = cart_coords[keys_tensor[:, 4]] + keys_tensor[:, :3].type(default_dtype_torch).to(cart_coords.device) @ lattice.to(cart_coords.device) + dist = torch.norm(cart_coords_j - cart_coord[None, :], dim=1) + len_nn = keys_tensor.shape[0] + edge_idx_first.extend([index_first] * len_nn) + edge_idx.extend(keys_tensor[:, 4].tolist()) + + edge_fea_single = torch.cat([dist.view(-1, 1), cart_coord.view(1, 3).expand(len_nn, 3)], dim=-1) + edge_fea_single = torch.cat([edge_fea_single, cart_coords_j, cart_coords[keys_tensor[:, 4]]], dim=-1) + edge_fea.append(edge_fea_single) + + if if_lcmp_graph: + atom_idx_connect.append(keys_tensor[:, 4]) + edge_idx_connect.append(range(edge_idx_connect_cursor, edge_idx_connect_cursor + len_nn)) + edge_idx_connect_cursor += len_nn + + edge_fea = torch.cat(edge_fea).type(default_dtype_torch) + edge_idx = torch.stack([torch.LongTensor(edge_idx_first), torch.LongTensor(edge_idx)]) + else: + raise NotImplemented + else: + cart_coords_np = cart_coords.detach().numpy() + frac_coords_np = frac_coords.detach().numpy() + lattice_np = lattice.detach().numpy() + num_atom = cart_coords.shape[0] + + center_coords_min = np.min(cart_coords_np, axis=0) + center_coords_max = np.max(cart_coords_np, axis=0) + global_min = center_coords_min - r - numerical_tol + global_max = center_coords_max + r + numerical_tol + global_min_torch = torch.tensor(global_min) + global_max_torch = torch.tensor(global_max) + + reciprocal_lattice = np.linalg.inv(lattice_np).T * 2 * np.pi + recp_len = np.sqrt(np.sum(reciprocal_lattice ** 2, axis=1)) + maxr = np.ceil((r + 0.15) * recp_len / (2 * np.pi)) + nmin = np.floor(np.min(frac_coords_np, axis=0)) - maxr + nmax = np.ceil(np.max(frac_coords_np, axis=0)) + maxr + all_ranges = [np.arange(x, y, dtype='int64') for x, y in zip(nmin, nmax)] + images = torch.tensor(list(itertools.product(*all_ranges))).type_as(lattice) + + if only_get_R_list: + return images + + coords = (images @ lattice)[:, None, :] + cart_coords[None, :, :] + indices = torch.arange(num_atom).unsqueeze(0).expand(images.shape[0], num_atom) + valid_index_bool = coords.gt(global_min_torch) * coords.lt(global_max_torch) + valid_index_bool = valid_index_bool.all(dim=-1) + valid_coords = coords[valid_index_bool] + valid_indices = indices[valid_index_bool] + + + valid_coords_np = valid_coords.detach().numpy() + all_cube_index = _compute_cube_index(valid_coords_np, global_min, r) + nx, ny, nz = _compute_cube_index(global_max, global_min, r) + 1 + all_cube_index = _three_to_one(all_cube_index, ny, nz) + site_cube_index = _three_to_one(_compute_cube_index(cart_coords_np, global_min, r), ny, nz) + cube_to_coords_index = collections.defaultdict(list) # type: Dict[int, List] + + for index, cart_coord in enumerate(all_cube_index.ravel()): + cube_to_coords_index[cart_coord].append(index) + + site_neighbors = find_neighbors(site_cube_index, nx, ny, nz) + + edge_idx, edge_fea, edge_idx_first = [], [], [] + if if_lcmp_graph: + atom_idx_connect, edge_idx_connect = [], [] + edge_idx_connect_cursor = 0 + for index_first, (cart_coord, j) in enumerate(zip(cart_coords, site_neighbors)): + l1 = np.array(_three_to_one(j, ny, nz), dtype=int).ravel() + ks = [k for k in l1 if k in cube_to_coords_index] + nn_coords_index = np.concatenate([cube_to_coords_index[k] for k in ks], axis=0) + nn_coords = valid_coords[nn_coords_index] + nn_indices = valid_indices[nn_coords_index] + dist = torch.norm(nn_coords - cart_coord[None, :], dim=1) + + if separate_onsite is False: + nn_coords = nn_coords.squeeze() + nn_indices = nn_indices.squeeze() + dist = dist.squeeze() + else: + nonzero_index = dist.nonzero(as_tuple=False) + nn_coords = nn_coords[nonzero_index] + nn_coords = nn_coords.squeeze(1) + nn_indices = nn_indices[nonzero_index].view(-1) + dist = dist[nonzero_index].view(-1) + + if max_num_nbr > 0: + if len(dist) >= max_num_nbr: + dist_top, index_top = dist.topk(max_num_nbr, largest=False, sorted=True) + edge_idx.extend(nn_indices[index_top]) + if if_lcmp_graph: + atom_idx_connect.append(nn_indices[index_top]) + edge_idx_first.extend([index_first] * len(index_top)) + edge_fea_single = torch.cat([dist_top.view(-1, 1), cart_coord.view(1, 3).expand(len(index_top), 3)], dim=-1) + edge_fea_single = torch.cat([edge_fea_single, nn_coords[index_top], cart_coords[nn_indices[index_top]]], dim=-1) + edge_fea.append(edge_fea_single) + else: + warnings.warn("Can not find a number of max_num_nbr atoms within radius") + edge_idx.extend(nn_indices) + if if_lcmp_graph: + atom_idx_connect.append(nn_indices) + edge_idx_first.extend([index_first] * len(nn_indices)) + edge_fea_single = torch.cat([dist.view(-1, 1), cart_coord.view(1, 3).expand(len(nn_indices), 3)], dim=-1) + edge_fea_single = torch.cat([edge_fea_single, nn_coords, cart_coords[nn_indices]], dim=-1) + edge_fea.append(edge_fea_single) + else: + index_top = dist.lt(r + numerical_tol) + edge_idx.extend(nn_indices[index_top]) + if if_lcmp_graph: + atom_idx_connect.append(nn_indices[index_top]) + edge_idx_first.extend([index_first] * len(nn_indices[index_top])) + edge_fea_single = torch.cat([dist[index_top].view(-1, 1), cart_coord.view(1, 3).expand(len(nn_indices[index_top]), 3)], dim=-1) + edge_fea_single = torch.cat([edge_fea_single, nn_coords[index_top], cart_coords[nn_indices[index_top]]], dim=-1) + edge_fea.append(edge_fea_single) + if if_lcmp_graph: + edge_idx_connect.append(range(edge_idx_connect_cursor, edge_idx_connect_cursor + len(atom_idx_connect[-1]))) + edge_idx_connect_cursor += len(atom_idx_connect[-1]) + + + edge_fea = torch.cat(edge_fea).type(default_dtype_torch) + edge_idx_first = torch.LongTensor(edge_idx_first) + edge_idx = torch.stack([edge_idx_first, torch.LongTensor(edge_idx)]) + + + if tb_folder is not None: + if target == 'E_ij': + read_file_list = ['E_ij.h5', 'E_delta_ee_ij.h5', 'E_xc_ij.h5'] + graph_key_list = ['E_ij', 'E_delta_ee_ij', 'E_xc_ij'] + read_terms_dict = {} + for read_file, graph_key in zip(read_file_list, graph_key_list): + read_terms = {} + fid = h5py.File(os.path.join(tb_folder, read_file), 'r') + for k, v in fid.items(): + key = json.loads(k) + key = (key[0], key[1], key[2], key[3] - 1, key[4] - 1) + read_terms[key] = torch.tensor(v[...], dtype=default_dtype_torch) + read_terms_dict[graph_key] = read_terms + fid.close() + + local_rotation_dict = {} + if if_require_grad: + fid = fid_rc + else: + fid = h5py.File(os.path.join(tb_folder, 'rc.h5'), 'r') + for k, v in fid.items(): + key = json.loads(k) + key = (key[0], key[1], key[2], key[3] - 1, key[4] - 1) # (R, i, j) i and j is 0-based index + if if_require_grad: + local_rotation_dict[key] = v + else: + local_rotation_dict[key] = torch.tensor(v, dtype=default_dtype_torch) + if not if_require_grad: + fid.close() + elif target == 'E_i': + read_file_list = ['E_i.h5'] + graph_key_list = ['E_i'] + read_terms_dict = {} + for read_file, graph_key in zip(read_file_list, graph_key_list): + read_terms = {} + fid = h5py.File(os.path.join(tb_folder, read_file), 'r') + for k, v in fid.items(): + index_i = int(k) # index_i is 0-based index + read_terms[index_i] = torch.tensor(v[...], dtype=default_dtype_torch) + fid.close() + read_terms_dict[graph_key] = read_terms + else: + if interface == 'h5' or interface == 'h5_rc_only': + atom_num_orbital = load_orbital_types(os.path.join(tb_folder, 'orbital_types.dat')) + + if interface == 'h5': + with open(os.path.join(tb_folder, 'info.json'), 'r') as info_f: + info_dict = json.load(info_f) + spinful = info_dict["isspinful"] + + if interface == 'h5': + if target == 'hamiltonian': + read_file_list = ['rh.h5'] + graph_key_list = ['term_real'] + elif target == 'phiVdphi': + read_file_list = ['rphiVdphi.h5'] + graph_key_list = ['term_real'] + elif target == 'density_matrix': + read_file_list = ['rdm.h5'] + graph_key_list = ['term_real'] + elif target == 'O_ij': + read_file_list = ['rh.h5', 'rdm.h5', 'rvna.h5', 'rvdee.h5', 'rvxc.h5'] + graph_key_list = ['rh', 'rdm', 'rvna', 'rvdee', 'rvxc'] + else: + raise ValueError('Unknown prediction target: {}'.format(target)) + read_terms_dict = {} + for read_file, graph_key in zip(read_file_list, graph_key_list): + read_terms = {} + fid = h5py.File(os.path.join(tb_folder, read_file), 'r') + for k, v in fid.items(): + key = json.loads(k) + key = (key[0], key[1], key[2], key[3] - 1, key[4] - 1) + if spinful: + num_orbital_row = atom_num_orbital[key[3]] + num_orbital_column = atom_num_orbital[key[4]] + # soc block order: + # 1 3 + # 4 2 + if target == 'phiVdphi': + raise NotImplementedError + else: + read_value = torch.stack([ + torch.tensor(v[:num_orbital_row, :num_orbital_column].real, dtype=default_dtype_torch), + torch.tensor(v[:num_orbital_row, :num_orbital_column].imag, dtype=default_dtype_torch), + torch.tensor(v[num_orbital_row:, num_orbital_column:].real, dtype=default_dtype_torch), + torch.tensor(v[num_orbital_row:, num_orbital_column:].imag, dtype=default_dtype_torch), + torch.tensor(v[:num_orbital_row, num_orbital_column:].real, dtype=default_dtype_torch), + torch.tensor(v[:num_orbital_row, num_orbital_column:].imag, dtype=default_dtype_torch), + torch.tensor(v[num_orbital_row:, :num_orbital_column].real, dtype=default_dtype_torch), + torch.tensor(v[num_orbital_row:, :num_orbital_column].imag, dtype=default_dtype_torch) + ], dim=-1) + read_terms[key] = read_value + else: + read_terms[key] = torch.tensor(v[...], dtype=default_dtype_torch) + read_terms_dict[graph_key] = read_terms + fid.close() + + local_rotation_dict = {} + if if_require_grad: + fid = fid_rc + else: + fid = h5py.File(os.path.join(tb_folder, 'rc.h5'), 'r') + for k, v in fid.items(): + key = json.loads(k) + key = (key[0], key[1], key[2], key[3] - 1, key[4] - 1) # (R, i, j) i and j is 0-based index + if if_require_grad: + local_rotation_dict[key] = v + else: + local_rotation_dict[key] = torch.tensor(v[...], dtype=default_dtype_torch) + if not if_require_grad: + fid.close() + + max_num_orbital = max(atom_num_orbital) + + elif interface == 'npz' or interface == 'npz_rc_only': + spinful = False + atom_num_orbital = load_orbital_types(os.path.join(tb_folder, 'orbital_types.dat')) + + if interface == 'npz': + graph_key_list = ['term_real'] + read_terms_dict = {'term_real': {}} + hopping_dict_read = np.load(os.path.join(tb_folder, 'rh.npz')) + for k, v in hopping_dict_read.items(): + key = json.loads(k) + key = (key[0], key[1], key[2], key[3] - 1, key[4] - 1) # (R, i, j) i and j is 0-based index + read_terms_dict['term_real'][key] = torch.tensor(v, dtype=default_dtype_torch) + + local_rotation_dict = {} + local_rotation_dict_read = np.load(os.path.join(tb_folder, 'rc.npz')) + for k, v in local_rotation_dict_read.items(): + key = json.loads(k) + key = (key[0], key[1], key[2], key[3] - 1, key[4] - 1) + local_rotation_dict[key] = torch.tensor(v, dtype=default_dtype_torch) + + max_num_orbital = max(atom_num_orbital) + else: + raise ValueError(f'Unknown interface: {interface}') + + if target == 'E_i': + term_dict = {} + onsite_term_dict = {} + for graph_key in graph_key_list: + term_dict[graph_key] = torch.full([numbers.shape[0], 1], np.nan, dtype=default_dtype_torch) + for index_atom in range(numbers.shape[0]): + assert index_atom in read_terms_dict[graph_key_list[0]] + for graph_key in graph_key_list: + term_dict[graph_key][index_atom] = read_terms_dict[graph_key][index_atom] + subgraph = None + else: + if interface == 'h5_rc_only' or interface == 'npz_rc_only': + local_rotation = [] + else: + term_dict = {} + onsite_term_dict = {} + if target == 'E_ij': + for graph_key in graph_key_list: + term_dict[graph_key] = torch.full([edge_fea.shape[0], 1], np.nan, dtype=default_dtype_torch) + local_rotation = [] + if separate_onsite is True: + for graph_key in graph_key_list: + onsite_term_dict['onsite_' + graph_key] = torch.full([numbers.shape[0], 1], np.nan, dtype=default_dtype_torch) + else: + term_mask = torch.zeros(edge_fea.shape[0], dtype=torch.bool) + for graph_key in graph_key_list: + if spinful: + term_dict[graph_key] = torch.full([edge_fea.shape[0], max_num_orbital, max_num_orbital, 8], + np.nan, dtype=default_dtype_torch) + else: + if target == 'phiVdphi': + term_dict[graph_key] = torch.full([edge_fea.shape[0], max_num_orbital, max_num_orbital, 3], + np.nan, dtype=default_dtype_torch) + else: + term_dict[graph_key] = torch.full([edge_fea.shape[0], max_num_orbital, max_num_orbital], + np.nan, dtype=default_dtype_torch) + local_rotation = [] + if separate_onsite is True: + for graph_key in graph_key_list: + if spinful: + onsite_term_dict['onsite_' + graph_key] = torch.full( + [numbers.shape[0], max_num_orbital, max_num_orbital, 8], + np.nan, dtype=default_dtype_torch) + else: + if target == 'phiVdphi': + onsite_term_dict['onsite_' + graph_key] = torch.full( + [numbers.shape[0], max_num_orbital, max_num_orbital, 3], + np.nan, dtype=default_dtype_torch) + else: + onsite_term_dict['onsite_' + graph_key] = torch.full( + [numbers.shape[0], max_num_orbital, max_num_orbital], + np.nan, dtype=default_dtype_torch) + + inv_lattice = torch.inverse(lattice).type(default_dtype_torch) + for index_edge in range(edge_fea.shape[0]): + # h_{i0, jR} i and j is 0-based index + R = torch.round(edge_fea[index_edge, 4:7].cpu() @ inv_lattice - edge_fea[index_edge, 7:10].cpu() @ inv_lattice).int().tolist() + i, j = edge_idx[:, index_edge] + + key_term = (*R, i.item(), j.item()) + if interface == 'h5_rc_only' or interface == 'npz_rc_only': + local_rotation.append(local_rotation_dict[key_term]) + else: + if key_term in read_terms_dict[graph_key_list[0]]: + for graph_key in graph_key_list: + if target == 'E_ij': + term_dict[graph_key][index_edge] = read_terms_dict[graph_key][key_term] + else: + term_mask[index_edge] = True + if spinful: + term_dict[graph_key][index_edge, :atom_num_orbital[i], :atom_num_orbital[j], :] = read_terms_dict[graph_key][key_term] + else: + term_dict[graph_key][index_edge, :atom_num_orbital[i], :atom_num_orbital[j]] = read_terms_dict[graph_key][key_term] + local_rotation.append(local_rotation_dict[key_term]) + else: + raise NotImplementedError( + "Not yet have support for graph radius including hopping without calculation") + + if separate_onsite is True and interface != 'h5_rc_only' and interface != 'npz_rc_only': + for index_atom in range(numbers.shape[0]): + key_term = (0, 0, 0, index_atom, index_atom) + assert key_term in read_terms_dict[graph_key_list[0]] + for graph_key in graph_key_list: + if target == 'E_ij': + onsite_term_dict['onsite_' + graph_key][index_atom] = read_terms_dict[graph_key][key_term] + else: + if spinful: + onsite_term_dict['onsite_' + graph_key][index_atom, :atom_num_orbital[i], :atom_num_orbital[j], :] = \ + read_terms_dict[graph_key][key_term] + else: + onsite_term_dict['onsite_' + graph_key][index_atom, :atom_num_orbital[i], :atom_num_orbital[j]] = \ + read_terms_dict[graph_key][key_term] + + if if_lcmp_graph: + local_rotation = torch.stack(local_rotation, dim=0) + assert local_rotation.shape[0] == edge_fea.shape[0] + r_vec = edge_fea[:, 1:4] - edge_fea[:, 4:7] + r_vec = r_vec.unsqueeze(1) + if huge_structure is False: + r_vec = torch.matmul(r_vec[:, None, :, :], local_rotation[None, :, :, :].to(r_vec.device)).reshape(-1, 3) + if if_new_sp: + r_vec = torch.nn.functional.normalize(r_vec, dim=-1) + angular_expansion = _spherical_harmonics(num_l - 1, -r_vec[..., 2], r_vec[..., 0], + r_vec[..., 1]) + angular_expansion.mul_(torch.cat([ + (math.sqrt(2 * l + 1) / math.sqrt(4 * math.pi)) * torch.ones(2 * l + 1, + dtype=angular_expansion.dtype, + device=angular_expansion.device) + for l in range(num_l) + ])) + angular_expansion = angular_expansion.reshape(edge_fea.shape[0], edge_fea.shape[0], -1) + else: + r_vec_sp = get_spherical_from_cartesian(r_vec) + sph_harm_func = SphericalHarmonics() + angular_expansion = [] + for l in range(num_l): + angular_expansion.append(sph_harm_func.get(l, r_vec_sp[:, 0], r_vec_sp[:, 1])) + angular_expansion = torch.cat(angular_expansion, dim=-1).reshape(edge_fea.shape[0], edge_fea.shape[0], -1) + + subgraph_atom_idx_list = [] + subgraph_edge_idx_list = [] + subgraph_edge_ang_list = [] + subgraph_index = [] + index_cursor = 0 + + for index in range(edge_fea.shape[0]): + # h_{i0, jR} + i, j = edge_idx[:, index] + subgraph_atom_idx = torch.stack([i.repeat(len(atom_idx_connect[i])), atom_idx_connect[i]]).T + subgraph_edge_idx = torch.LongTensor(edge_idx_connect[i]) + if huge_structure: + r_vec_tmp = torch.matmul(r_vec[subgraph_edge_idx, :, :], local_rotation[index, :, :].to(r_vec.device)).reshape(-1, 3) + if if_new_sp: + r_vec_tmp = torch.nn.functional.normalize(r_vec_tmp, dim=-1) + subgraph_edge_ang = _spherical_harmonics(num_l - 1, -r_vec_tmp[..., 2], r_vec_tmp[..., 0], r_vec_tmp[..., 1]) + subgraph_edge_ang.mul_(torch.cat([ + (math.sqrt(2 * l + 1) / math.sqrt(4 * math.pi)) * torch.ones(2 * l + 1, + dtype=subgraph_edge_ang.dtype, + device=subgraph_edge_ang.device) + for l in range(num_l) + ])) + else: + r_vec_sp = get_spherical_from_cartesian(r_vec_tmp) + sph_harm_func = SphericalHarmonics() + angular_expansion = [] + for l in range(num_l): + angular_expansion.append(sph_harm_func.get(l, r_vec_sp[:, 0], r_vec_sp[:, 1])) + subgraph_edge_ang = torch.cat(angular_expansion, dim=-1).reshape(-1, num_l ** 2) + else: + subgraph_edge_ang = angular_expansion[subgraph_edge_idx, index, :] + + subgraph_atom_idx_list.append(subgraph_atom_idx) + subgraph_edge_idx_list.append(subgraph_edge_idx) + subgraph_edge_ang_list.append(subgraph_edge_ang) + subgraph_index += [index_cursor] * len(atom_idx_connect[i]) + index_cursor += 1 + + subgraph_atom_idx = torch.stack([j.repeat(len(atom_idx_connect[j])), atom_idx_connect[j]]).T + subgraph_edge_idx = torch.LongTensor(edge_idx_connect[j]) + if huge_structure: + r_vec_tmp = torch.matmul(r_vec[subgraph_edge_idx, :, :], local_rotation[index, :, :].to(r_vec.device)).reshape(-1, 3) + if if_new_sp: + r_vec_tmp = torch.nn.functional.normalize(r_vec_tmp, dim=-1) + subgraph_edge_ang = _spherical_harmonics(num_l - 1, -r_vec_tmp[..., 2], r_vec_tmp[..., 0], r_vec_tmp[..., 1]) + subgraph_edge_ang.mul_(torch.cat([ + (math.sqrt(2 * l + 1) / math.sqrt(4 * math.pi)) * torch.ones(2 * l + 1, + dtype=subgraph_edge_ang.dtype, + device=subgraph_edge_ang.device) + for l in range(num_l) + ])) + else: + r_vec_sp = get_spherical_from_cartesian(r_vec_tmp) + sph_harm_func = SphericalHarmonics() + angular_expansion = [] + for l in range(num_l): + angular_expansion.append(sph_harm_func.get(l, r_vec_sp[:, 0], r_vec_sp[:, 1])) + subgraph_edge_ang = torch.cat(angular_expansion, dim=-1).reshape(-1, num_l ** 2) + else: + subgraph_edge_ang = angular_expansion[subgraph_edge_idx, index, :] + subgraph_atom_idx_list.append(subgraph_atom_idx) + subgraph_edge_idx_list.append(subgraph_edge_idx) + subgraph_edge_ang_list.append(subgraph_edge_ang) + subgraph_index += [index_cursor] * len(atom_idx_connect[j]) + index_cursor += 1 + subgraph = {"subgraph_atom_idx":torch.cat(subgraph_atom_idx_list, dim=0), + "subgraph_edge_idx":torch.cat(subgraph_edge_idx_list, dim=0), + "subgraph_edge_ang":torch.cat(subgraph_edge_ang_list, dim=0), + "subgraph_index":torch.LongTensor(subgraph_index)} + else: + subgraph = None + + if interface == 'h5_rc_only' or interface == 'npz_rc_only': + data = Data(x=numbers, edge_index=edge_idx, edge_attr=edge_fea, stru_id=stru_id, term_mask=None, + term_real=None, onsite_term_real=None, + atom_num_orbital=torch.tensor(atom_num_orbital), + subgraph_dict=subgraph, + **kwargs) + else: + if target == 'E_ij' or target == 'E_i': + data = Data(x=numbers, edge_index=edge_idx, edge_attr=edge_fea, stru_id=stru_id, + **term_dict, **onsite_term_dict, + subgraph_dict=subgraph, + spinful=False, + **kwargs) + else: + data = Data(x=numbers, edge_index=edge_idx, edge_attr=edge_fea, stru_id=stru_id, term_mask=term_mask, + **term_dict, **onsite_term_dict, + atom_num_orbital=torch.tensor(atom_num_orbital), + subgraph_dict=subgraph, + spinful=spinful, + **kwargs) + else: + data = Data(x=numbers, edge_index=edge_idx, edge_attr=edge_fea, stru_id=stru_id, **kwargs) + return data diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/__init__.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..d925f2cb2e3a1ae4f48ca789c37d3357733ac3e3 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/__init__.py @@ -0,0 +1 @@ +from .pred_ham import predict, predict_with_grad \ No newline at end of file diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/__pycache__/__init__.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4d81434a8ca9f831cdcbbb7ebc999baa47b3d5ca Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/__pycache__/__init__.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/__pycache__/pred_ham.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/__pycache__/pred_ham.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..02e9bbaf9f08b328846dc3fa33397f7df5149dfe Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/__pycache__/pred_ham.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/band_config.json b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/band_config.json new file mode 100644 index 0000000000000000000000000000000000000000..bd8f43e64b6ed56995f1d3c0078559f56c037595 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/band_config.json @@ -0,0 +1,8 @@ +{ + "calc_job": "band", + "which_k": 0, + "fermi_level": -3.82373, + "max_iter": 300, + "num_band": 50, + "k_data": ["15 0 0 0 0.5 0.5 0 Γ M", "15 0.5 0.5 0 0.3333333333333333 0.6666666666666667 0 M K", "15 0.3333333333333333 0.6666666666666667 0 0 0 0 K Γ"] +} \ No newline at end of file diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/dense_calc.jl b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/dense_calc.jl new file mode 100644 index 0000000000000000000000000000000000000000..96a79e7e75bf2250c6eb6b5fdaca7f738f3c956a --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/dense_calc.jl @@ -0,0 +1,234 @@ +using DelimitedFiles, LinearAlgebra, JSON +using HDF5 +using ArgParse +using SparseArrays +using Arpack +using JLD +# BLAS.set_num_threads(1) + +const ev2Hartree = 0.036749324533634074 +const Bohr2Ang = 0.529177249 +const default_dtype = Complex{Float64} + + +function parse_commandline() + s = ArgParseSettings() + @add_arg_table! s begin + "--input_dir", "-i" + help = "path of rlat.dat, orbital_types.dat, site_positions.dat, hamiltonians_pred.h5, and overlaps.h5" + arg_type = String + default = "./" + "--output_dir", "-o" + help = "path of output openmx.Band" + arg_type = String + default = "./" + "--config" + help = "config file in the format of JSON" + arg_type = String + "--ill_project" + help = "projects out the eigenvectors of the overlap matrix that correspond to eigenvalues smaller than ill_threshold" + arg_type = Bool + default = true + "--ill_threshold" + help = "threshold for ill_project" + arg_type = Float64 + default = 5e-4 + end + return parse_args(s) +end + + +function _create_dict_h5(filename::String) + fid = h5open(filename, "r") + T = eltype(fid[keys(fid)[1]]) + d_out = Dict{Array{Int64,1}, Array{T, 2}}() + for key in keys(fid) + data = read(fid[key]) + nk = map(x -> parse(Int64, convert(String, x)), split(key[2 : length(key) - 1], ',')) + d_out[nk] = permutedims(data) + end + close(fid) + return d_out +end + + +function genlist(x) + return collect(range(x[1], stop = x[2], length = Int64(x[3]))) +end + + +function k_data2num_ks(kdata::AbstractString) + return parse(Int64,split(kdata)[1]) +end + + +function k_data2kpath(kdata::AbstractString) + return map(x->parse(Float64,x), split(kdata)[2:7]) +end + + +function std_out_array(a::AbstractArray) + return string(map(x->string(x," "),a)...) +end + + +function main() + parsed_args = parse_commandline() + + println(parsed_args["config"]) + config = JSON.parsefile(parsed_args["config"]) + calc_job = config["calc_job"] + + if isfile(joinpath(parsed_args["input_dir"],"info.json")) + spinful = JSON.parsefile(joinpath(parsed_args["input_dir"],"info.json"))["isspinful"] + else + spinful = false + end + + site_positions = readdlm(joinpath(parsed_args["input_dir"], "site_positions.dat")) + nsites = size(site_positions, 2) + + orbital_types_f = open(joinpath(parsed_args["input_dir"], "orbital_types.dat"), "r") + site_norbits = zeros(nsites) + orbital_types = Vector{Vector{Int64}}() + for index_site = 1:nsites + orbital_type = parse.(Int64, split(readline(orbital_types_f))) + push!(orbital_types, orbital_type) + end + site_norbits = (x->sum(x .* 2 .+ 1)).(orbital_types) * (1 + spinful) + norbits = sum(site_norbits) + site_norbits_cumsum = cumsum(site_norbits) + + rlat = readdlm(joinpath(parsed_args["input_dir"], "rlat.dat")) + + + @info "read h5" + begin_time = time() + hamiltonians_pred = _create_dict_h5(joinpath(parsed_args["input_dir"], "hamiltonians_pred.h5")) + overlaps = _create_dict_h5(joinpath(parsed_args["input_dir"], "overlaps.h5")) + println("Time for reading h5: ", time() - begin_time, "s") + + H_R = Dict{Vector{Int64}, Matrix{default_dtype}}() + S_R = Dict{Vector{Int64}, Matrix{default_dtype}}() + + @info "construct Hamiltonian and overlap matrix in the real space" + begin_time = time() + for key in collect(keys(hamiltonians_pred)) + hamiltonian_pred = hamiltonians_pred[key] + if (key ∈ keys(overlaps)) + overlap = overlaps[key] + else + # continue + overlap = zero(hamiltonian_pred) + end + if spinful + overlap = vcat(hcat(overlap,zeros(size(overlap))),hcat(zeros(size(overlap)),overlap)) # the readout overlap matrix only contains the upper-left block # TODO maybe drop the zeros? + end + R = key[1:3]; atom_i=key[4]; atom_j=key[5] + + @assert (site_norbits[atom_i], site_norbits[atom_j]) == size(hamiltonian_pred) + @assert (site_norbits[atom_i], site_norbits[atom_j]) == size(overlap) + if !(R ∈ keys(H_R)) + H_R[R] = zeros(default_dtype, norbits, norbits) + S_R[R] = zeros(default_dtype, norbits, norbits) + end + for block_matrix_i in 1:site_norbits[atom_i] + for block_matrix_j in 1:site_norbits[atom_j] + index_i = site_norbits_cumsum[atom_i] - site_norbits[atom_i] + block_matrix_i + index_j = site_norbits_cumsum[atom_j] - site_norbits[atom_j] + block_matrix_j + H_R[R][index_i, index_j] = hamiltonian_pred[block_matrix_i, block_matrix_j] + S_R[R][index_i, index_j] = overlap[block_matrix_i, block_matrix_j] + end + end + end + println("Time for constructing Hamiltonian and overlap matrix in the real space: ", time() - begin_time, " s") + + + if calc_job == "band" + fermi_level = config["fermi_level"] + k_data = config["k_data"] + + ill_project = parsed_args["ill_project"] || ("ill_project" in keys(config) && config["ill_project"]) + ill_threshold = max(parsed_args["ill_threshold"], get(config, "ill_threshold", 0.)) + + @info "calculate bands" + num_ks = k_data2num_ks.(k_data) + kpaths = k_data2kpath.(k_data) + + egvals = zeros(Float64, norbits, sum(num_ks)[1]) + + begin_time = time() + idx_k = 1 + for i = 1:size(kpaths, 1) + kpath = kpaths[i] + pnkpts = num_ks[i] + kxs = LinRange(kpath[1], kpath[4], pnkpts) + kys = LinRange(kpath[2], kpath[5], pnkpts) + kzs = LinRange(kpath[3], kpath[6], pnkpts) + for (kx, ky, kz) in zip(kxs, kys, kzs) + idx_k + H_k = zeros(default_dtype, norbits, norbits) + S_k = zeros(default_dtype, norbits, norbits) + for R in keys(H_R) + H_k += H_R[R] * exp(im*2π*([kx, ky, kz]⋅R)) + S_k += S_R[R] * exp(im*2π*([kx, ky, kz]⋅R)) + end + S_k = (S_k + S_k') / 2 + H_k = (H_k + H_k') / 2 + if ill_project + (egval_S, egvec_S) = eigen(Hermitian(S_k)) + # egvec_S: shape (num_basis, num_bands) + project_index = abs.(egval_S) .> ill_threshold + if sum(project_index) != length(project_index) + # egval_S = egval_S[project_index] + egvec_S = egvec_S[:, project_index] + @warn "ill-conditioned eigenvalues detected, projected out $(length(project_index) - sum(project_index)) eigenvalues" + H_k = egvec_S' * H_k * egvec_S + S_k = egvec_S' * S_k * egvec_S + (egval, egvec) = eigen(Hermitian(H_k), Hermitian(S_k)) + egval = vcat(egval, fill(1e4, length(project_index) - sum(project_index))) + egvec = egvec_S * egvec + else + (egval, egvec) = eigen(Hermitian(H_k), Hermitian(S_k)) + end + else + (egval, egvec) = eigen(Hermitian(H_k), Hermitian(S_k)) + end + egvals[:, idx_k] = egval + println("Time for solving No.$idx_k eigenvalues at k = ", [kx, ky, kz], ": ", time() - begin_time, " s") + idx_k += 1 + end + end + + # output in openmx band format + f = open(joinpath(parsed_args["output_dir"], "openmx.Band"),"w") + println(f, norbits, " ", 0, " ", ev2Hartree * fermi_level) + openmx_rlat = reshape((rlat .* Bohr2Ang), 1, :) + println(f, std_out_array(openmx_rlat)) + println(f, length(k_data)) + for line in k_data + println(f,line) + end + idx_k = 1 + for i = 1:size(kpaths, 1) + pnkpts = num_ks[i] + kstart = kpaths[i][1:3] + kend = kpaths[i][4:6] + k_list = zeros(Float64,pnkpts,3) + for alpha = 1:3 + k_list[:,alpha] = genlist([kstart[alpha],kend[alpha],pnkpts]) + end + for j = 1:pnkpts + idx_k + kvec = k_list[j,:] + println(f, norbits, " ", std_out_array(kvec)) + println(f, std_out_array(ev2Hartree * egvals[:, idx_k])) + idx_k += 1 + end + end + close(f) + end +end + + +main() diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/dense_calc.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/dense_calc.py new file mode 100644 index 0000000000000000000000000000000000000000..2c7b6d235d391333f18904e7605feb15589ccc81 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/dense_calc.py @@ -0,0 +1,277 @@ +import json +import argparse +import h5py +import numpy as np +import os +from time import time +from scipy import linalg +import tqdm +from pathos.multiprocessing import ProcessingPool as Pool + +def parse_commandline(): + parser = argparse.ArgumentParser() + parser.add_argument( + "--input_dir", "-i", type=str, default="./", + help="path of rlat.dat, orbital_types.dat, site_positions.dat, hamiltonians_pred.h5, and overlaps.h5" + ) + parser.add_argument( + "--output_dir", "-o", type=str, default="./", + help="path of output openmx.Band" + ) + parser.add_argument( + "--config", type=str, + help="config file in the format of JSON" + ) + parser.add_argument( + "--ill_project", type=bool, + help="projects out the eigenvectors of the overlap matrix that correspond to eigenvalues smaller than ill_threshold", + default=True + ) + parser.add_argument( + "--ill_threshold", type=float, + help="threshold for ill_project", + default=5e-4 + ) + parser.add_argument( + "--multiprocessing", type=int, + help="multiprocessing for band calculation", + default=0 + ) + return parser.parse_args() + +parsed_args = parse_commandline() + +def _create_dict_h5(filename): + fid = h5py.File(filename, "r") + d_out = {} + for key in fid.keys(): + data = np.array(fid[key]) + nk = tuple(map(int, key[1:-1].split(','))) + # BS: + # the matrix do not need be transposed in Python, + # But the transpose should be done in Julia. + d_out[nk] = data # np.transpose(data) + fid.close() + return d_out + + +ev2Hartree = 0.036749324533634074 +Bohr2Ang = 0.529177249 + + +def genlist(x): + return np.linspace(x[0], x[1], int(x[2])) + + +def k_data2num_ks(kdata): + return int(kdata.split()[0]) + + +def k_data2kpath(kdata): + return [float(x) for x in kdata.split()[1:7]] + + +def std_out_array(a): + return ''.join([str(x) + ' ' for x in a]) + + +default_dtype = np.complex128 + +print(parsed_args.config) +with open(parsed_args.config) as f: + config = json.load(f) +calc_job = config["calc_job"] + +if os.path.isfile(os.path.join(parsed_args.input_dir, "info.json")): + with open(os.path.join(parsed_args.input_dir, "info.json")) as f: + spinful = json.load(f)["isspinful"] +else: + spinful = False + +site_positions = np.loadtxt(os.path.join(parsed_args.input_dir, "site_positions.dat")) + +if len(site_positions.shape) == 2: + nsites = site_positions.shape[1] +else: + nsites = 1 + # in case of single atom + + +with open(os.path.join(parsed_args.input_dir, "orbital_types.dat")) as f: + site_norbits = np.zeros(nsites, dtype=int) + orbital_types = [] + for index_site in range(nsites): + orbital_type = list(map(int, f.readline().split())) + orbital_types.append(orbital_type) + site_norbits[index_site] = np.sum(np.array(orbital_type) * 2 + 1) + norbits = np.sum(site_norbits) + site_norbits_cumsum = np.cumsum(site_norbits) + +rlat = np.loadtxt(os.path.join(parsed_args.input_dir, "rlat.dat")).T +# require transposition while reading rlat.dat in python + + +print("read h5") +begin_time = time() +hamiltonians_pred = _create_dict_h5(os.path.join(parsed_args.input_dir, "hamiltonians_pred.h5")) +overlaps = _create_dict_h5(os.path.join(parsed_args.input_dir, "overlaps.h5")) +print("Time for reading h5: ", time() - begin_time, "s") + +H_R = {} +S_R = {} + +print("construct Hamiltonian and overlap matrix in the real space") +begin_time = time() + +# BS: +# this is for debug python and julia +# in julia, you can use 'sort(collect(keys(hamiltonians_pred)))' +# for key in dict(sorted(hamiltonians_pred.items())).keys(): +for key in hamiltonians_pred.keys(): + + hamiltonian_pred = hamiltonians_pred[key] + + if key in overlaps.keys(): + overlap = overlaps[key] + else: + overlap = np.zeros_like(hamiltonian_pred) + if spinful: + overlap = np.vstack((np.hstack((overlap, np.zeros_like(overlap))), np.hstack((np.zeros_like(overlap), overlap)))) + R = key[:3] + atom_i = key[3] - 1 + atom_j = key[4] - 1 + + assert (site_norbits[atom_i], site_norbits[atom_j]) == hamiltonian_pred.shape + assert (site_norbits[atom_i], site_norbits[atom_j]) == overlap.shape + + if R not in H_R.keys(): + H_R[R] = np.zeros((norbits, norbits), dtype=default_dtype) + S_R[R] = np.zeros((norbits, norbits), dtype=default_dtype) + + for block_matrix_i in range(1, site_norbits[atom_i]+1): + for block_matrix_j in range(1, site_norbits[atom_j]+1): + index_i = site_norbits_cumsum[atom_i] - site_norbits[atom_i] + block_matrix_i - 1 + index_j = site_norbits_cumsum[atom_j] - site_norbits[atom_j] + block_matrix_j - 1 + H_R[R][index_i, index_j] = hamiltonian_pred[block_matrix_i-1, block_matrix_j-1] + S_R[R][index_i, index_j] = overlap[block_matrix_i-1, block_matrix_j-1] + + +print("Time for constructing Hamiltonian and overlap matrix in the real space: ", time() - begin_time, " s") + +if calc_job == "band": + fermi_level = config["fermi_level"] + k_data = config["k_data"] + ill_project = parsed_args.ill_project or ("ill_project" in config.keys() and config["ill_project"]) + ill_threshold = max(parsed_args.ill_threshold, config["ill_threshold"] if ("ill_threshold" in config.keys()) else 0.) + multiprocessing = max(parsed_args.multiprocessing, config["multiprocessing"] if ("multiprocessing" in config.keys()) else 0) + + print("calculate bands") + num_ks = [k_data2num_ks(k) for k in k_data] + kpaths = [k_data2kpath(k) for k in k_data] + + egvals = np.zeros((norbits, sum(num_ks))) + + begin_time = time() + idx_k = 0 + # calculate total k points + total_num_ks = sum(num_ks) + list_index_kpath= [] + list_index_kxyz=[] + for i in range(len(num_ks)): + list_index_kpath = list_index_kpath + ([i]*num_ks[i]) + list_index_kxyz.extend(range(num_ks[i])) + + def process_worker(k_point): + """ calculate band + + Args: + k_point (int): the index of k point of all calculated k points + + Returns: + json: { + "k_point":k_point, + "egval" (np array 1D) : eigen value , + "num_projected_out" (int) : ill-conditioned eigenvalues detected。 default is 0 + } + """ + index_kpath = list_index_kpath[k_point] + kpath = kpaths[index_kpath] + pnkpts = num_ks[index_kpath] + kx = np.linspace(kpath[0], kpath[3], pnkpts)[list_index_kxyz[k_point]] + ky = np.linspace(kpath[1], kpath[4], pnkpts)[list_index_kxyz[k_point]] + kz = np.linspace(kpath[2], kpath[5], pnkpts)[list_index_kxyz[k_point]] + + H_k = np.matrix(np.zeros((norbits, norbits), dtype=default_dtype)) + S_k = np.matrix(np.zeros((norbits, norbits), dtype=default_dtype)) + for R in H_R.keys(): + H_k += H_R[R] * np.exp(1j*2*np.pi*np.dot([kx, ky, kz], R)) + S_k += S_R[R] * np.exp(1j*2*np.pi*np.dot([kx, ky, kz], R)) + # print(H_k) + H_k = (H_k + H_k.getH())/2. + S_k = (S_k + S_k.getH())/2. + num_projected_out = 0 + if ill_project: + egval_S, egvec_S = linalg.eig(S_k) + project_index = np.argwhere(abs(egval_S)> ill_threshold) + if len(project_index) != norbits: + egvec_S = np.matrix(egvec_S[:, project_index]) + num_projected_out = norbits - len(project_index) + H_k = egvec_S.H @ H_k @ egvec_S + S_k = egvec_S.H @ S_k @ egvec_S + egval = linalg.eigvalsh(H_k, S_k, lower=False) + egval = np.concatenate([egval, np.full(num_projected_out, 1e4)]) + else: + egval = linalg.eigvalsh(H_k, S_k, lower=False) + else: + #--------------------------------------------- + # BS: only eigenvalues are needed in this part, + # the upper matrix is used + egval = linalg.eigvalsh(H_k, S_k, lower=False) + + return {"k_point":k_point, "egval":egval, "num_projected_out":num_projected_out} + + # parallizing the band calculation + if multiprocessing == 0: + print(f'No use of multiprocessing') + data_list = [process_worker(k_point) for k_point in tqdm.tqdm(range(sum(num_ks)))] + else: + pool_dict = {} if multiprocessing < 0 else {'nodes': multiprocessing} + + with Pool(**pool_dict) as pool: + nodes = pool.nodes + print(f'Use multiprocessing x {multiprocessing})') + data_list = list(tqdm.tqdm(pool.imap(process_worker, range(sum(num_ks))), total=sum(num_ks))) + + # post-process returned band data, and store them in egvals with the order k_point + projected_out = [] + for data in data_list: + egvals[:, data["k_point"]] = data["egval"] + if data["num_projected_out"] > 0: + projected_out.append(data["num_projected_out"]) + if len(projected_out) > 0: + print(f"There are {len(projected_out)} bands with ill-conditioned eigenvalues detected.") + print(f"Projected out {int(np.average(projected_out))} eigenvalues on average.") + print('Finish the calculation of %d k-points, have cost %d seconds' % (sum(num_ks), time() - begin_time)) + + + # output in openmx band format + with open(os.path.join(parsed_args.output_dir, "openmx.Band"), "w") as f: + f.write("{} {} {}\n".format(norbits, 0, ev2Hartree * fermi_level)) + openmx_rlat = np.reshape((rlat * Bohr2Ang), (1, -1))[0] + f.write(std_out_array(openmx_rlat) + "\n") + f.write(str(len(k_data)) + "\n") + for line in k_data: + f.write(line + "\n") + idx_k = 0 + for i in range(len(kpaths)): + pnkpts = num_ks[i] + kstart = kpaths[i][:3] + kend = kpaths[i][3:] + k_list = np.zeros((pnkpts, 3)) + for alpha in range(3): + k_list[:, alpha] = genlist([kstart[alpha], kend[alpha], pnkpts]) + for j in range(pnkpts): + kvec = k_list[j, :] + f.write("{} {}\n".format(norbits, std_out_array(kvec))) + f.write(std_out_array(ev2Hartree * egvals[:, idx_k]) + "\n") + idx_k += 1 diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/inference_default.ini b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/inference_default.ini new file mode 100644 index 0000000000000000000000000000000000000000..426ba6e26887bbdc470d1ba27c267a16d2672fdc --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/inference_default.ini @@ -0,0 +1,23 @@ +[basic] +work_dir = /your/own/path +OLP_dir = /your/own/path +interface = openmx +trained_model_dir = ["/your/trained/model1", "/your/trained/model2"] +task = [1, 2, 3, 4, 5] +sparse_calc_config = /your/own/path +eigen_solver = sparse_jl +disable_cuda = True +device = cuda:0 +huge_structure = True +restore_blocks_py = True +gen_rc_idx = False +gen_rc_by_idx = +with_grad = False + +[interpreter] +julia_interpreter = julia +python_interpreter = python + +[graph] +radius = -1.0 +create_from_DFT = True diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/local_coordinate.jl b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/local_coordinate.jl new file mode 100644 index 0000000000000000000000000000000000000000..392e3eb95a8b766bc64cff29300324e38ce3a929 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/local_coordinate.jl @@ -0,0 +1,79 @@ +using DelimitedFiles, LinearAlgebra +using HDF5 +using ArgParse +using StaticArrays + + +function parse_commandline() + s = ArgParseSettings() + @add_arg_table! s begin + "--input_dir", "-i" + help = "path of site_positions.dat, lat.dat, element.dat, and R_list.dat (overlaps.h5)" + arg_type = String + default = "./" + "--output_dir", "-o" + help = "path of output rc.h5" + arg_type = String + default = "./" + "--radius", "-r" + help = "cutoff radius" + arg_type = Float64 + default = 8.0 + "--create_from_DFT" + help = "retain edges by DFT overlaps neighbour" + arg_type = Bool + default = true + "--output_text" + help = "an option without argument, i.e. a flag" + action = :store_true + "--Hop_dir" + help = "path of Hop.jl" + arg_type = String + default = "/home/lihe/DeepH/process_ham/Hop.jl/" + end + return parse_args(s) +end +parsed_args = parse_commandline() + +using Pkg +Pkg.activate(parsed_args["Hop_dir"]) +using Hop + + +site_positions = readdlm(joinpath(parsed_args["input_dir"], "site_positions.dat")) +lat = readdlm(joinpath(parsed_args["input_dir"], "lat.dat")) +R_list_read = convert(Matrix{Int64}, readdlm(joinpath(parsed_args["input_dir"], "R_list.dat"))) +num_R = size(R_list_read, 1) +R_list = Vector{SVector{3, Int64}}() +for index_R in 1:num_R + push!(R_list, SVector{3, Int64}(R_list_read[index_R, :])) +end + +@info "get local coordinate" +begin_time = time() +rcoordinate = Hop.Deeph.rotate_system(site_positions, lat, R_list, parsed_args["radius"]) +println("time for calculating local coordinate is: ", time() - begin_time) + +if parsed_args["output_text"] + @info "output txt" + mkpath(joinpath(parsed_args["output_dir"], "rresult")) + mkpath(joinpath(parsed_args["output_dir"], "rresult/rc")) + for (R, coord) in rcoordinate + open(joinpath(parsed_args["output_dir"], "rresult/rc/", R, "_real.dat"), "w") do f + writedlm(f, coord) + end + end +end + +@info "output h5" +h5open(joinpath(parsed_args["input_dir"], "overlaps.h5"), "r") do fid_OLP + graph_key = Set(keys(fid_OLP)) + h5open(joinpath(parsed_args["output_dir"], "rc.h5"), "w") do fid + for (key, coord) in rcoordinate + if (parsed_args["create_from_DFT"] == true) && (!(string(key) in graph_key)) + continue + end + write(fid, string(key), permutedims(coord)) + end + end +end diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/pred_ham.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/pred_ham.py new file mode 100644 index 0000000000000000000000000000000000000000..875f137cc5e942888947ab4b70fbc5ca6f05dde2 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/pred_ham.py @@ -0,0 +1,365 @@ +import json +import os +import time +import warnings +from typing import Union, List +import sys + +import tqdm +from configparser import ConfigParser +import numpy as np +from pymatgen.core.structure import Structure +import torch +import torch.autograd.forward_ad as fwAD +import h5py + +from deeph import get_graph, DeepHKernel, collate_fn, write_ham_h5, load_orbital_types, Rotate, dtype_dict, get_rc + + +def predict(input_dir: str, output_dir: str, disable_cuda: bool, device: str, + huge_structure: bool, restore_blocks_py: bool, trained_model_dirs: Union[str, List[str]]): + atom_num_orbital = load_orbital_types(os.path.join(input_dir, 'orbital_types.dat')) + if isinstance(trained_model_dirs, str): + trained_model_dirs = [trained_model_dirs] + assert isinstance(trained_model_dirs, list) + os.makedirs(output_dir, exist_ok=True) + predict_spinful = None + + with torch.no_grad(): + read_structure_flag = False + if restore_blocks_py: + hoppings_pred = {} + else: + index_model = 0 + block_without_restoration = {} + os.makedirs(os.path.join(output_dir, 'block_without_restoration'), exist_ok=True) + for trained_model_dir in tqdm.tqdm(trained_model_dirs): + old_version = False + assert os.path.exists(os.path.join(trained_model_dir, 'config.ini')) + if os.path.exists(os.path.join(trained_model_dir, 'best_model.pt')) is False: + old_version = True + assert os.path.exists(os.path.join(trained_model_dir, 'best_model.pkl')) + assert os.path.exists(os.path.join(trained_model_dir, 'src')) + + config = ConfigParser() + config.read(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'default.ini')) + config.read(os.path.join(trained_model_dir, 'config.ini')) + config.set('basic', 'save_dir', os.path.join(output_dir, 'pred_ham_std')) + config.set('basic', 'disable_cuda', str(disable_cuda)) + config.set('basic', 'device', str(device)) + config.set('basic', 'save_to_time_folder', 'False') + config.set('basic', 'tb_writer', 'False') + config.set('train', 'pretrained', '') + config.set('train', 'resume', '') + + kernel = DeepHKernel(config) + if old_version is False: + checkpoint = kernel.build_model(trained_model_dir, old_version) + else: + warnings.warn('You are using the trained model with an old version') + checkpoint = torch.load( + os.path.join(trained_model_dir, 'best_model.pkl'), + map_location=kernel.device + ) + for key in ['index_to_Z', 'Z_to_index', 'spinful']: + if key in checkpoint: + setattr(kernel, key, checkpoint[key]) + if hasattr(kernel, 'index_to_Z') is False: + kernel.index_to_Z = torch.arange(config.getint('basic', 'max_element') + 1) + if hasattr(kernel, 'Z_to_index') is False: + kernel.Z_to_index = torch.arange(config.getint('basic', 'max_element') + 1) + if hasattr(kernel, 'spinful') is False: + kernel.spinful = False + kernel.num_species = len(kernel.index_to_Z) + print("=> load best checkpoint (epoch {})".format(checkpoint['epoch'])) + print(f"=> Atomic types: {kernel.index_to_Z.tolist()}, " + f"spinful: {kernel.spinful}, the number of atomic types: {len(kernel.index_to_Z)}.") + kernel.build_model(trained_model_dir, old_version) + kernel.model.load_state_dict(checkpoint['state_dict']) + + if predict_spinful is None: + predict_spinful = kernel.spinful + else: + assert predict_spinful == kernel.spinful, "Different models' spinful are not compatible" + + if read_structure_flag is False: + read_structure_flag = True + structure = Structure(np.loadtxt(os.path.join(input_dir, 'lat.dat')).T, + np.loadtxt(os.path.join(input_dir, 'element.dat')), + np.loadtxt(os.path.join(input_dir, 'site_positions.dat')).T, + coords_are_cartesian=True, + to_unit_cell=False) + cart_coords = torch.tensor(structure.cart_coords, dtype=torch.get_default_dtype()) + frac_coords = torch.tensor(structure.frac_coords, dtype=torch.get_default_dtype()) + numbers = kernel.Z_to_index[torch.tensor(structure.atomic_numbers)] + structure.lattice.matrix.setflags(write=True) + lattice = torch.tensor(structure.lattice.matrix, dtype=torch.get_default_dtype()) + inv_lattice = torch.inverse(lattice) + + if os.path.exists(os.path.join(input_dir, 'graph.pkl')): + data = torch.load(os.path.join(input_dir, 'graph.pkl')) + print(f"Load processed graph from {os.path.join(input_dir, 'graph.pkl')}") + else: + begin = time.time() + data = get_graph(cart_coords, frac_coords, numbers, 0, + r=kernel.config.getfloat('graph', 'radius'), + max_num_nbr=kernel.config.getint('graph', 'max_num_nbr'), + numerical_tol=1e-8, lattice=lattice, default_dtype_torch=torch.get_default_dtype(), + tb_folder=input_dir, interface="h5_rc_only", + num_l=kernel.config.getint('network', 'num_l'), + create_from_DFT=kernel.config.getboolean('graph', 'create_from_DFT', + fallback=True), + if_lcmp_graph=kernel.config.getboolean('graph', 'if_lcmp_graph', fallback=True), + separate_onsite=kernel.separate_onsite, + target=kernel.config.get('basic', 'target'), huge_structure=huge_structure, + if_new_sp=kernel.config.getboolean('graph', 'new_sp', fallback=False), + ) + torch.save(data, os.path.join(input_dir, 'graph.pkl')) + print( + f"Save processed graph to {os.path.join(input_dir, 'graph.pkl')}, cost {time.time() - begin} seconds") + batch, subgraph = collate_fn([data]) + sub_atom_idx, sub_edge_idx, sub_edge_ang, sub_index = subgraph + + output = kernel.model(batch.x.to(kernel.device), batch.edge_index.to(kernel.device), + batch.edge_attr.to(kernel.device), + batch.batch.to(kernel.device), + sub_atom_idx.to(kernel.device), sub_edge_idx.to(kernel.device), + sub_edge_ang.to(kernel.device), sub_index.to(kernel.device), + huge_structure=huge_structure) + output = output.detach().cpu() + if restore_blocks_py: + for index in range(batch.edge_attr.shape[0]): + R = torch.round(batch.edge_attr[index, 4:7] @ inv_lattice - batch.edge_attr[index, 7:10] @ inv_lattice).int().tolist() + i, j = batch.edge_index[:, index] + key_term = (*R, i.item() + 1, j.item() + 1) + key_term = str(list(key_term)) + for index_orbital, orbital_dict in enumerate(kernel.orbital): + if f'{kernel.index_to_Z[numbers[i]].item()} {kernel.index_to_Z[numbers[j]].item()}' not in orbital_dict: + continue + orbital_i, orbital_j = orbital_dict[f'{kernel.index_to_Z[numbers[i]].item()} {kernel.index_to_Z[numbers[j]].item()}'] + + if not key_term in hoppings_pred: + if kernel.spinful: + hoppings_pred[key_term] = np.full((2 * atom_num_orbital[i], 2 * atom_num_orbital[j]), np.nan + np.nan * (1j)) + else: + hoppings_pred[key_term] = np.full((atom_num_orbital[i], atom_num_orbital[j]), np.nan) + if kernel.spinful: + hoppings_pred[key_term][orbital_i, orbital_j] = output[index][index_orbital * 8 + 0] + output[index][index_orbital * 8 + 1] * 1j + hoppings_pred[key_term][atom_num_orbital[i] + orbital_i, atom_num_orbital[j] + orbital_j] = output[index][index_orbital * 8 + 2] + output[index][index_orbital * 8 + 3] * 1j + hoppings_pred[key_term][orbital_i, atom_num_orbital[j] + orbital_j] = output[index][index_orbital * 8 + 4] + output[index][index_orbital * 8 + 5] * 1j + hoppings_pred[key_term][atom_num_orbital[i] + orbital_i, orbital_j] = output[index][index_orbital * 8 + 6] + output[index][index_orbital * 8 + 7] * 1j + else: + hoppings_pred[key_term][orbital_i, orbital_j] = output[index][index_orbital] # about output shape w/ or w/o soc, see graph.py line 164, and kernel.py line 281. + else: + if 'edge_index' not in block_without_restoration: + assert index_model == 0 + block_without_restoration['edge_index'] = batch.edge_index + block_without_restoration['edge_attr'] = batch.edge_attr + block_without_restoration[f'output_{index_model}'] = output.numpy() + with open(os.path.join(output_dir, 'block_without_restoration', f'orbital_{index_model}.json'), 'w') as orbital_f: + json.dump(kernel.orbital, orbital_f, indent=4) + index_model += 1 + sys.stdout = sys.stdout.terminal + sys.stderr = sys.stderr.terminal + + if restore_blocks_py: + for hamiltonian in hoppings_pred.values(): + assert np.all(np.isnan(hamiltonian) == False) + write_ham_h5(hoppings_pred, path=os.path.join(output_dir, 'rh_pred.h5')) + else: + block_without_restoration['num_model'] = index_model + write_ham_h5(block_without_restoration, path=os.path.join(output_dir, 'block_without_restoration', 'block_without_restoration.h5')) + with open(os.path.join(output_dir, "info.json"), 'w') as info_f: + json.dump({ + "isspinful": predict_spinful + }, info_f) + + +def predict_with_grad(input_dir: str, output_dir: str, disable_cuda: bool, device: str, + huge_structure: bool, trained_model_dirs: Union[str, List[str]]): + atom_num_orbital, orbital_types = load_orbital_types(os.path.join(input_dir, 'orbital_types.dat'), return_orbital_types=True) + + if isinstance(trained_model_dirs, str): + trained_model_dirs = [trained_model_dirs] + assert isinstance(trained_model_dirs, list) + os.makedirs(output_dir, exist_ok=True) + predict_spinful = None + + read_structure_flag = False + rh_dict = {} + hamiltonians_pred = {} + hamiltonians_grad_pred = {} + + for trained_model_dir in tqdm.tqdm(trained_model_dirs): + old_version = False + assert os.path.exists(os.path.join(trained_model_dir, 'config.ini')) + if os.path.exists(os.path.join(trained_model_dir, 'best_model.pt')) is False: + old_version = True + assert os.path.exists(os.path.join(trained_model_dir, 'best_model.pkl')) + assert os.path.exists(os.path.join(trained_model_dir, 'src')) + + config = ConfigParser() + config.read(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'default.ini')) + config.read(os.path.join(trained_model_dir, 'config.ini')) + config.set('basic', 'save_dir', os.path.join(output_dir, 'pred_ham_std')) + config.set('basic', 'disable_cuda', str(disable_cuda)) + config.set('basic', 'device', str(device)) + config.set('basic', 'save_to_time_folder', 'False') + config.set('basic', 'tb_writer', 'False') + config.set('train', 'pretrained', '') + config.set('train', 'resume', '') + + kernel = DeepHKernel(config) + if old_version is False: + checkpoint = kernel.build_model(trained_model_dir, old_version) + else: + warnings.warn('You are using the trained model with an old version') + checkpoint = torch.load( + os.path.join(trained_model_dir, 'best_model.pkl'), + map_location=kernel.device + ) + for key in ['index_to_Z', 'Z_to_index', 'spinful']: + if key in checkpoint: + setattr(kernel, key, checkpoint[key]) + if hasattr(kernel, 'index_to_Z') is False: + kernel.index_to_Z = torch.arange(config.getint('basic', 'max_element') + 1) + if hasattr(kernel, 'Z_to_index') is False: + kernel.Z_to_index = torch.arange(config.getint('basic', 'max_element') + 1) + if hasattr(kernel, 'spinful') is False: + kernel.spinful = False + kernel.num_species = len(kernel.index_to_Z) + print("=> load best checkpoint (epoch {})".format(checkpoint['epoch'])) + print(f"=> Atomic types: {kernel.index_to_Z.tolist()}, " + f"spinful: {kernel.spinful}, the number of atomic types: {len(kernel.index_to_Z)}.") + kernel.build_model(trained_model_dir, old_version) + kernel.model.load_state_dict(checkpoint['state_dict']) + + if predict_spinful is None: + predict_spinful = kernel.spinful + else: + assert predict_spinful == kernel.spinful, "Different models' spinful are not compatible" + + if read_structure_flag is False: + read_structure_flag = True + structure = Structure(np.loadtxt(os.path.join(input_dir, 'lat.dat')).T, + np.loadtxt(os.path.join(input_dir, 'element.dat')), + np.loadtxt(os.path.join(input_dir, 'site_positions.dat')).T, + coords_are_cartesian=True, + to_unit_cell=False) + cart_coords = torch.tensor(structure.cart_coords, dtype=torch.get_default_dtype(), requires_grad=True, device=kernel.device) + num_atom = cart_coords.shape[0] + frac_coords = torch.tensor(structure.frac_coords, dtype=torch.get_default_dtype()) + numbers = kernel.Z_to_index[torch.tensor(structure.atomic_numbers)] + structure.lattice.matrix.setflags(write=True) + lattice = torch.tensor(structure.lattice.matrix, dtype=torch.get_default_dtype()) + inv_lattice = torch.inverse(lattice) + + fid_rc = get_rc(input_dir, None, radius=-1, create_from_DFT=True, if_require_grad=True, cart_coords=cart_coords) + + assert kernel.config.getboolean('graph', 'new_sp', fallback=False) + data = get_graph(cart_coords.to(kernel.device), frac_coords, numbers, 0, + r=kernel.config.getfloat('graph', 'radius'), + max_num_nbr=kernel.config.getint('graph', 'max_num_nbr'), + numerical_tol=1e-8, lattice=lattice, default_dtype_torch=torch.get_default_dtype(), + tb_folder=input_dir, interface="h5_rc_only", + num_l=kernel.config.getint('network', 'num_l'), + create_from_DFT=kernel.config.getboolean('graph', 'create_from_DFT', fallback=True), + if_lcmp_graph=kernel.config.getboolean('graph', 'if_lcmp_graph', fallback=True), + separate_onsite=kernel.separate_onsite, + target=kernel.config.get('basic', 'target'), huge_structure=huge_structure, + if_new_sp=True, if_require_grad=True, fid_rc=fid_rc) + batch, subgraph = collate_fn([data]) + sub_atom_idx, sub_edge_idx, sub_edge_ang, sub_index = subgraph + + torch_dtype, torch_dtype_real, torch_dtype_complex = dtype_dict[torch.get_default_dtype()] + rotate_kernel = Rotate(torch_dtype, torch_dtype_real=torch_dtype_real, + torch_dtype_complex=torch_dtype_complex, + device=kernel.device, spinful=kernel.spinful) + + output = kernel.model(batch.x, batch.edge_index.to(kernel.device), + batch.edge_attr, + batch.batch.to(kernel.device), + sub_atom_idx.to(kernel.device), sub_edge_idx.to(kernel.device), + sub_edge_ang, sub_index.to(kernel.device), + huge_structure=huge_structure) + + index_for_matrix_block_real_dict = {} # key is atomic number pair + if kernel.spinful: + index_for_matrix_block_imag_dict = {} # key is atomic number pair + + for index in range(batch.edge_attr.shape[0]): + R = torch.round(batch.edge_attr[index, 4:7].cpu() @ inv_lattice - batch.edge_attr[index, 7:10].cpu() @ inv_lattice).int().tolist() + i, j = batch.edge_index[:, index] + key_tensor = torch.tensor([*R, i, j]) + numbers_pair = (kernel.index_to_Z[numbers[i]].item(), kernel.index_to_Z[numbers[j]].item()) + if numbers_pair not in index_for_matrix_block_real_dict: + if not kernel.spinful: + index_for_matrix_block_real = torch.full((atom_num_orbital[i], atom_num_orbital[j]), -1) + else: + index_for_matrix_block_real = torch.full((2 * atom_num_orbital[i], 2 * atom_num_orbital[j]), -1) + index_for_matrix_block_imag = torch.full((2 * atom_num_orbital[i], 2 * atom_num_orbital[j]), -1) + for index_orbital, orbital_dict in enumerate(kernel.orbital): + if f'{kernel.index_to_Z[numbers[i]].item()} {kernel.index_to_Z[numbers[j]].item()}' not in orbital_dict: + continue + orbital_i, orbital_j = orbital_dict[f'{kernel.index_to_Z[numbers[i]].item()} {kernel.index_to_Z[numbers[j]].item()}'] + if not kernel.spinful: + index_for_matrix_block_real[orbital_i, orbital_j] = index_orbital + else: + index_for_matrix_block_real[orbital_i, orbital_j] = index_orbital * 8 + 0 + index_for_matrix_block_imag[orbital_i, orbital_j] = index_orbital * 8 + 1 + index_for_matrix_block_real[atom_num_orbital[i] + orbital_i, atom_num_orbital[j] + orbital_j] = index_orbital * 8 + 2 + index_for_matrix_block_imag[atom_num_orbital[i] + orbital_i, atom_num_orbital[j] + orbital_j] = index_orbital * 8 + 3 + index_for_matrix_block_real[orbital_i, atom_num_orbital[j] + orbital_j] = index_orbital * 8 + 4 + index_for_matrix_block_imag[orbital_i, atom_num_orbital[j] + orbital_j] = index_orbital * 8 + 5 + index_for_matrix_block_real[atom_num_orbital[i] + orbital_i, orbital_j] = index_orbital * 8 + 6 + index_for_matrix_block_imag[atom_num_orbital[i] + orbital_i, orbital_j] = index_orbital * 8 + 7 + assert torch.all(index_for_matrix_block_real != -1), 'json string "orbital" should be complete for Hamiltonian grad' + if kernel.spinful: + assert torch.all(index_for_matrix_block_imag != -1), 'json string "orbital" should be complete for Hamiltonian grad' + + index_for_matrix_block_real_dict[numbers_pair] = index_for_matrix_block_real + if kernel.spinful: + index_for_matrix_block_imag_dict[numbers_pair] = index_for_matrix_block_imag + else: + index_for_matrix_block_real = index_for_matrix_block_real_dict[numbers_pair] + if kernel.spinful: + index_for_matrix_block_imag = index_for_matrix_block_imag_dict[numbers_pair] + + if not kernel.spinful: + rh_dict[key_tensor] = output[index][index_for_matrix_block_real] + else: + rh_dict[key_tensor] = output[index][index_for_matrix_block_real] + 1j * output[index][index_for_matrix_block_imag] + + sys.stdout = sys.stdout.terminal + sys.stderr = sys.stderr.terminal + + print("=> Hamiltonian has been predicted, calculate the grad...") + for key_tensor, rotated_hamiltonian in tqdm.tqdm(rh_dict.items()): + atom_i = key_tensor[3] + atom_j = key_tensor[4] + assert atom_i >= 0 + assert atom_i < num_atom + assert atom_j >= 0 + assert atom_j < num_atom + key_str = str(list([key_tensor[0].item(), key_tensor[1].item(), key_tensor[2].item(), atom_i.item() + 1, atom_j.item() + 1])) + assert key_str in fid_rc, f'Can not found the key "{key_str}" in rc.h5' + # rotation_matrix = torch.tensor(fid_rc[key_str], dtype=torch_dtype_real, device=kernel.device).T + rotation_matrix = fid_rc[key_str].T + hamiltonian = rotate_kernel.rotate_openmx_H(rotated_hamiltonian, rotation_matrix, orbital_types[atom_i], orbital_types[atom_j]) + hamiltonians_pred[key_str] = hamiltonian.detach().cpu() + assert kernel.spinful is False # 检查soc时是否正确 + assert len(hamiltonian.shape) == 2 + dim_1, dim_2 = hamiltonian.shape[:] + assert key_str not in hamiltonians_grad_pred + if not kernel.spinful: + hamiltonians_grad_pred[key_str] = np.full((dim_1, dim_2, num_atom, 3), np.nan) + else: + hamiltonians_grad_pred[key_str] = np.full((2 * dim_1, 2 * dim_2, num_atom, 3), np.nan + 1j * np.nan) + + write_ham_h5(hamiltonians_pred, path=os.path.join(output_dir, 'hamiltonians_pred.h5')) + write_ham_h5(hamiltonians_grad_pred, path=os.path.join(output_dir, 'hamiltonians_grad_pred.h5')) + with open(os.path.join(output_dir, "info.json"), 'w') as info_f: + json.dump({ + "isspinful": predict_spinful + }, info_f) + fid_rc.close() diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/restore_blocks.jl b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/restore_blocks.jl new file mode 100644 index 0000000000000000000000000000000000000000..9e1eb75c2c4f2594a62c72f1f305723b65b960dd --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/restore_blocks.jl @@ -0,0 +1,115 @@ +using JSON +using LinearAlgebra +using DelimitedFiles +using HDF5 +using ArgParse + + +function parse_commandline() + s = ArgParseSettings() + @add_arg_table! s begin + "--input_dir", "-i" + help = "path of block_without_restoration, element.dat, site_positions.dat, orbital_types.dat, and info.json" + arg_type = String + default = "./" + "--output_dir", "-o" + help = "path of output rh_pred.h5" + arg_type = String + default = "./" + end + return parse_args(s) +end +parsed_args = parse_commandline() + + +function _create_dict_h5(filename::String) + fid = h5open(filename, "r") + T = eltype(fid[keys(fid)[1]]) + d_out = Dict{Array{Int64,1}, Array{T, 2}}() + for key in keys(fid) + data = read(fid[key]) + nk = map(x -> parse(Int64, convert(String, x)), split(key[2 : length(key) - 1], ',')) + d_out[nk] = permutedims(data) + end + close(fid) + return d_out +end + + +if isfile(joinpath(parsed_args["input_dir"],"info.json")) + spinful = JSON.parsefile(joinpath(parsed_args["input_dir"],"info.json"))["isspinful"] +else + spinful = false +end + +spinful = JSON.parsefile(joinpath(parsed_args["input_dir"],"info.json"))["isspinful"] +numbers = readdlm(joinpath(parsed_args["input_dir"], "element.dat"), Int64) +lattice = readdlm(joinpath(parsed_args["input_dir"], "lat.dat")) +inv_lattice = inv(lattice) +site_positions = readdlm(joinpath(parsed_args["input_dir"], "site_positions.dat")) +nsites = size(site_positions, 2) +orbital_types_f = open(joinpath(parsed_args["input_dir"], "orbital_types.dat"), "r") +site_norbits = zeros(nsites) +orbital_types = Vector{Vector{Int64}}() +for index_site = 1:nsites + orbital_type = parse.(Int64, split(readline(orbital_types_f))) + push!(orbital_types, orbital_type) +end +site_norbits = (x->sum(x .* 2 .+ 1)).(orbital_types) * (1 + spinful) +atom_num_orbital = (x->sum(x .* 2 .+ 1)).(orbital_types) + +fid = h5open(joinpath(parsed_args["input_dir"], "block_without_restoration", "block_without_restoration.h5"), "r") +num_model = read(fid["num_model"]) +T_pytorch = eltype(fid["output_0"]) +if spinful + T_Hamiltonian = Complex{T_pytorch} +else + T_Hamiltonian = T_pytorch +end +hoppings_pred = Dict{Array{Int64,1}, Array{T_Hamiltonian, 2}}() +println("Found $num_model models, spinful:$spinful") +edge_attr = read(fid["edge_attr"]) +edge_index = read(fid["edge_index"]) +for index_model in 0:(num_model-1) + output = read(fid["output_$index_model"]) + orbital = JSON.parsefile(joinpath(parsed_args["input_dir"], "block_without_restoration", "orbital_$index_model.json")) + orbital = convert(Vector{Dict{String, Vector{Int}}}, orbital) + for index in 1:size(edge_index, 1) + R = Int.(round.(inv_lattice * edge_attr[5:7, index] - inv_lattice * edge_attr[8:10, index])) + i = edge_index[index, 1] + 1 + j = edge_index[index, 2] + 1 + key_term = cat(R, i, j, dims=1) + for (index_orbital, orbital_dict) in enumerate(orbital) + atomic_number_pair = "$(numbers[i]) $(numbers[j])" + if !(atomic_number_pair ∈ keys(orbital_dict)) + continue + end + orbital_i, orbital_j = orbital_dict[atomic_number_pair] + orbital_i += 1 + orbital_j += 1 + + if !(key_term ∈ keys(hoppings_pred)) + if spinful + hoppings_pred[key_term] = fill(NaN + NaN * im, 2 * atom_num_orbital[i], 2 * atom_num_orbital[j]) + else + hoppings_pred[key_term] = fill(NaN, atom_num_orbital[i], atom_num_orbital[j]) + end + end + if spinful + hoppings_pred[key_term][orbital_i, orbital_j] = output[index_orbital * 8 - 7, index] + output[index_orbital * 8 - 6, index] * im + hoppings_pred[key_term][atom_num_orbital[i] + orbital_i, atom_num_orbital[j] + orbital_j] = output[index_orbital * 8 - 5, index] + output[index_orbital * 8 - 4, index] * im + hoppings_pred[key_term][orbital_i, atom_num_orbital[j] + orbital_j] = output[index_orbital * 8 - 3, index] + output[index_orbital * 8 - 2, index] * im + hoppings_pred[key_term][atom_num_orbital[i] + orbital_i, orbital_j] = output[index_orbital * 8 - 1, index] + output[index_orbital * 8, index] * im + else + hoppings_pred[key_term][orbital_i, orbital_j] = output[index_orbital, index] + end + end + end +end +close(fid) + +h5open(joinpath(parsed_args["output_dir"], "rh_pred.h5"), "w") do fid + for (key, rh_pred) in hoppings_pred + write(fid, string(key), permutedims(rh_pred)) + end +end diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/sparse_calc.jl b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/sparse_calc.jl new file mode 100644 index 0000000000000000000000000000000000000000..466031d64f6566877ba64e613b1028296809930a --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/inference/sparse_calc.jl @@ -0,0 +1,412 @@ +using DelimitedFiles, LinearAlgebra, JSON +using HDF5 +using ArgParse +using SparseArrays +using Pardiso, Arpack, LinearMaps +using JLD +# BLAS.set_num_threads(1) + +const ev2Hartree = 0.036749324533634074 +const Bohr2Ang = 0.529177249 +const default_dtype = Complex{Float64} + + +function parse_commandline() + s = ArgParseSettings() + @add_arg_table! s begin + "--input_dir", "-i" + help = "path of rlat.dat, orbital_types.dat, site_positions.dat, hamiltonians_pred.h5, and overlaps.h5" + arg_type = String + default = "./" + "--output_dir", "-o" + help = "path of output openmx.Band" + arg_type = String + default = "./" + "--config" + help = "config file in the format of JSON" + arg_type = String + "--ill_project" + help = "projects out the eigenvectors of the overlap matrix that correspond to eigenvalues smaller than ill_threshold" + arg_type = Bool + default = true + "--ill_threshold" + help = "threshold for ill_project" + arg_type = Float64 + default = 5e-4 + end + return parse_args(s) +end + + +function _create_dict_h5(filename::String) + fid = h5open(filename, "r") + T = eltype(fid[keys(fid)[1]]) + d_out = Dict{Array{Int64,1}, Array{T, 2}}() + for key in keys(fid) + data = read(fid[key]) + nk = map(x -> parse(Int64, convert(String, x)), split(key[2 : length(key) - 1], ',')) + d_out[nk] = permutedims(data) + end + close(fid) + return d_out +end + + +# The function construct_linear_map below is come from https://discourse.julialang.org/t/smallest-magnitude-eigenvalues-of-the-generalized-eigenvalue-equation-for-a-large-sparse-matrix/75485/11 +function construct_linear_map(H, S) + ps = MKLPardisoSolver() + set_matrixtype!(ps, Pardiso.COMPLEX_HERM_INDEF) + pardisoinit(ps) + fix_iparm!(ps, :N) + H_pardiso = get_matrix(ps, H, :N) + b = rand(ComplexF64, size(H, 1)) + set_phase!(ps, Pardiso.ANALYSIS) + pardiso(ps, H_pardiso, b) + set_phase!(ps, Pardiso.NUM_FACT) + pardiso(ps, H_pardiso, b) + return ( + LinearMap{ComplexF64}( + (y, x) -> begin + set_phase!(ps, Pardiso.SOLVE_ITERATIVE_REFINE) + pardiso(ps, y, H_pardiso, S * x) + end, + size(H, 1); + ismutating=true + ), + ps + ) +end + + +function genlist(x) + return collect(range(x[1], stop = x[2], length = Int64(x[3]))) +end + + +function k_data2num_ks(kdata::AbstractString) + return parse(Int64,split(kdata)[1]) +end + + +function k_data2kpath(kdata::AbstractString) + return map(x->parse(Float64,x), split(kdata)[2:7]) +end + + +function std_out_array(a::AbstractArray) + return string(map(x->string(x," "),a)...) +end + + +function constructmeshkpts(nkmesh::Vector{Int64}; offset::Vector{Float64}=[0.0, 0.0, 0.0], + k1::Vector{Float64}=[0.0, 0.0, 0.0], k2::Vector{Float64}=[1.0, 1.0, 1.0]) + length(nkmesh) == 3 || throw(ArgumentError("nkmesh in wrong size.")) + nkpts = prod(nkmesh) + kpts = zeros(3, nkpts) + ik = 1 + for ikx in 1:nkmesh[1], iky in 1:nkmesh[2], ikz in 1:nkmesh[3] + kpts[:, ik] = [ + (ikx-1)/nkmesh[1]*(k2[1]-k1[1])+k1[1], + (iky-1)/nkmesh[2]*(k2[2]-k1[2])+k1[2], + (ikz-1)/nkmesh[3]*(k2[3]-k1[3])+k1[3] + ] + ik += 1 + end + return kpts.+offset +end + + +function main() + parsed_args = parse_commandline() + + println(parsed_args["config"]) + config = JSON.parsefile(parsed_args["config"]) + calc_job = config["calc_job"] + ill_project = parsed_args["ill_project"] + ill_threshold = parsed_args["ill_threshold"] + + if isfile(joinpath(parsed_args["input_dir"],"info.json")) + spinful = JSON.parsefile(joinpath(parsed_args["input_dir"],"info.json"))["isspinful"] + else + spinful = false + end + + site_positions = readdlm(joinpath(parsed_args["input_dir"], "site_positions.dat")) + nsites = size(site_positions, 2) + + orbital_types_f = open(joinpath(parsed_args["input_dir"], "orbital_types.dat"), "r") + site_norbits = zeros(nsites) + orbital_types = Vector{Vector{Int64}}() + for index_site = 1:nsites + orbital_type = parse.(Int64, split(readline(orbital_types_f))) + push!(orbital_types, orbital_type) + end + site_norbits = (x->sum(x .* 2 .+ 1)).(orbital_types) * (1 + spinful) + norbits = sum(site_norbits) + site_norbits_cumsum = cumsum(site_norbits) + + rlat = readdlm(joinpath(parsed_args["input_dir"], "rlat.dat")) + + + if isfile(joinpath(parsed_args["input_dir"], "sparse_matrix.jld")) + @info string("read sparse matrix from ", parsed_args["input_dir"], "/sparse_matrix.jld") + H_R = load(joinpath(parsed_args["input_dir"], "sparse_matrix.jld"), "H_R") + S_R = load(joinpath(parsed_args["input_dir"], "sparse_matrix.jld"), "S_R") + else + @info "read h5" + begin_time = time() + hamiltonians_pred = _create_dict_h5(joinpath(parsed_args["input_dir"], "hamiltonians_pred.h5")) + overlaps = _create_dict_h5(joinpath(parsed_args["input_dir"], "overlaps.h5")) + println("Time for reading h5: ", time() - begin_time, "s") + + I_R = Dict{Vector{Int64}, Vector{Int64}}() + J_R = Dict{Vector{Int64}, Vector{Int64}}() + H_V_R = Dict{Vector{Int64}, Vector{default_dtype}}() + S_V_R = Dict{Vector{Int64}, Vector{default_dtype}}() + + @info "construct sparse matrix in the format of COO" + begin_time = time() + for key in collect(keys(hamiltonians_pred)) + hamiltonian_pred = hamiltonians_pred[key] + if (key ∈ keys(overlaps)) + overlap = overlaps[key] + if spinful + overlap = vcat(hcat(overlap,zeros(size(overlap))),hcat(zeros(size(overlap)),overlap)) # the readout overlap matrix only contains the upper-left block # TODO maybe drop the zeros? + end + else + # continue + overlap = zero(hamiltonian_pred) + end + R = key[1:3]; atom_i=key[4]; atom_j=key[5] + + @assert (site_norbits[atom_i], site_norbits[atom_j]) == size(hamiltonian_pred) + @assert (site_norbits[atom_i], site_norbits[atom_j]) == size(overlap) + if !(R ∈ keys(I_R)) + I_R[R] = Vector{Int64}() + J_R[R] = Vector{Int64}() + H_V_R[R] = Vector{default_dtype}() + S_V_R[R] = Vector{default_dtype}() + end + for block_matrix_i in 1:site_norbits[atom_i] + for block_matrix_j in 1:site_norbits[atom_j] + coo_i = site_norbits_cumsum[atom_i] - site_norbits[atom_i] + block_matrix_i + coo_j = site_norbits_cumsum[atom_j] - site_norbits[atom_j] + block_matrix_j + push!(I_R[R], coo_i) + push!(J_R[R], coo_j) + push!(H_V_R[R], hamiltonian_pred[block_matrix_i, block_matrix_j]) + push!(S_V_R[R], overlap[block_matrix_i, block_matrix_j]) + end + end + end + println("Time for constructing sparse matrix in the format of COO: ", time() - begin_time, "s") + + @info "convert sparse matrix to the format of CSC" + begin_time = time() + H_R = Dict{Vector{Int64}, SparseMatrixCSC{default_dtype, Int64}}() + S_R = Dict{Vector{Int64}, SparseMatrixCSC{default_dtype, Int64}}() + + for R in keys(I_R) + H_R[R] = sparse(I_R[R], J_R[R], H_V_R[R], norbits, norbits) + S_R[R] = sparse(I_R[R], J_R[R], S_V_R[R], norbits, norbits) + end + println("Time for converting to the format of CSC: ", time() - begin_time, "s") + + save(joinpath(parsed_args["input_dir"], "sparse_matrix.jld"), "H_R", H_R, "S_R", S_R) + end + + if calc_job == "band" + which_k = config["which_k"] # which k point to calculate, start counting from 1, 0 for all k points + fermi_level = config["fermi_level"] + max_iter = config["max_iter"] + num_band = config["num_band"] + k_data = config["k_data"] + + @info "calculate bands" + num_ks = k_data2num_ks.(k_data) + kpaths = k_data2kpath.(k_data) + + egvals = zeros(Float64, num_band, sum(num_ks)[1]) + + begin_time = time() + idx_k = 1 + for i = 1:size(kpaths, 1) + kpath = kpaths[i] + pnkpts = num_ks[i] + kxs = LinRange(kpath[1], kpath[4], pnkpts) + kys = LinRange(kpath[2], kpath[5], pnkpts) + kzs = LinRange(kpath[3], kpath[6], pnkpts) + for (kx, ky, kz) in zip(kxs, kys, kzs) + if which_k == 0 || which_k == idx_k + H_k = spzeros(default_dtype, norbits, norbits) + S_k = spzeros(default_dtype, norbits, norbits) + for R in keys(H_R) + H_k += H_R[R] * exp(im*2π*([kx, ky, kz]⋅R)) + S_k += S_R[R] * exp(im*2π*([kx, ky, kz]⋅R)) + end + S_k = (S_k + S_k') / 2 + H_k = (H_k + H_k') / 2 + if ill_project + lm, ps = construct_linear_map(Hermitian(H_k) - (fermi_level) * Hermitian(S_k), Hermitian(S_k)) + println("Time for No.$idx_k matrix factorization: ", time() - begin_time, "s") + egval_sub_inv, egvec_sub = eigs(lm, nev=num_band, which=:LM, ritzvec=true, maxiter=max_iter) + set_phase!(ps, Pardiso.RELEASE_ALL) + pardiso(ps) + egval_sub = real(1 ./ egval_sub_inv) .+ (fermi_level) + + # orthogonalize the eigenvectors + egvec_sub_qr = qr(egvec_sub) + egvec_sub = convert(Matrix{default_dtype}, egvec_sub_qr.Q) + + S_k_sub = egvec_sub' * S_k * egvec_sub + (egval_S, egvec_S) = eigen(Hermitian(S_k_sub)) + # egvec_S: shape (num_basis, num_bands) + project_index = abs.(egval_S) .> ill_threshold + if sum(project_index) != length(project_index) + H_k_sub = egvec_sub' * H_k * egvec_sub + egvec_S = egvec_S[:, project_index] + @warn "ill-conditioned eigenvalues detected, projected out $(length(project_index) - sum(project_index)) eigenvalues" + H_k_sub = egvec_S' * H_k_sub * egvec_S + S_k_sub = egvec_S' * S_k_sub * egvec_S + (egval, egvec) = eigen(Hermitian(H_k_sub), Hermitian(S_k_sub)) + egval = vcat(egval, fill(1e4, length(project_index) - sum(project_index))) + egvec = egvec_S * egvec + egvec = egvec_sub * egvec + else + egval = egval_sub + end + else + lm, ps = construct_linear_map(Hermitian(H_k) - (fermi_level) * Hermitian(S_k), Hermitian(S_k)) + println("Time for No.$idx_k matrix factorization: ", time() - begin_time, "s") + egval_inv, egvec = eigs(lm, nev=num_band, which=:LM, ritzvec=false, maxiter=max_iter) + set_phase!(ps, Pardiso.RELEASE_ALL) + pardiso(ps) + egval = real(1 ./ egval_inv) .+ (fermi_level) + # egval = real(eigs(H_k, S_k, nev=num_band, sigma=(fermi_level + lowest_band), which=:LR, ritzvec=false, maxiter=max_iter)[1]) + end + egvals[:, idx_k] = egval + if which_k == 0 + # println(egval .- fermi_level) + else + open(joinpath(parsed_args["output_dir"], "kpoint.dat"), "w") do f + writedlm(f, [kx, ky, kz]) + end + open(joinpath(parsed_args["output_dir"], "egval.dat"), "w") do f + writedlm(f, egval) + end + end + egvals[:, idx_k] = egval + println("Time for solving No.$idx_k eigenvalues at k = ", [kx, ky, kz], ": ", time() - begin_time, "s") + end + idx_k += 1 + end + end + + # output in openmx band format + f = open(joinpath(parsed_args["output_dir"], "openmx.Band"),"w") + println(f, num_band, " ", 0, " ", ev2Hartree * fermi_level) + openmx_rlat = reshape((rlat .* Bohr2Ang), 1, :) + println(f, std_out_array(openmx_rlat)) + println(f, length(k_data)) + for line in k_data + println(f,line) + end + idx_k = 1 + for i = 1:size(kpaths, 1) + pnkpts = num_ks[i] + kstart = kpaths[i][1:3] + kend = kpaths[i][4:6] + k_list = zeros(Float64,pnkpts,3) + for alpha = 1:3 + k_list[:,alpha] = genlist([kstart[alpha],kend[alpha],pnkpts]) + end + for j = 1:pnkpts + kvec = k_list[j,:] + println(f, num_band, " ", std_out_array(kvec)) + println(f, std_out_array(ev2Hartree * egvals[:, idx_k])) + idx_k += 1 + end + end + close(f) + elseif calc_job == "dos" + fermi_level = config["fermi_level"] + max_iter = config["max_iter"] + num_band = config["num_band"] + nkmesh = convert(Array{Int64,1}, config["kmesh"]) + ks = constructmeshkpts(nkmesh) + nks = size(ks, 2) + + egvals = zeros(Float64, num_band, nks) + begin_time = time() + for idx_k in 1:nks + kx, ky, kz = ks[:, idx_k] + + H_k = spzeros(default_dtype, norbits, norbits) + S_k = spzeros(default_dtype, norbits, norbits) + for R in keys(H_R) + H_k += H_R[R] * exp(im*2π*([kx, ky, kz]⋅R)) + S_k += S_R[R] * exp(im*2π*([kx, ky, kz]⋅R)) + end + S_k = (S_k + S_k') / 2 + H_k = (H_k + H_k') / 2 + if ill_project + lm, ps = construct_linear_map(Hermitian(H_k) - (fermi_level) * Hermitian(S_k), Hermitian(S_k)) + println("Time for No.$idx_k matrix factorization: ", time() - begin_time, "s") + egval_sub_inv, egvec_sub = eigs(lm, nev=num_band, which=:LM, ritzvec=true, maxiter=max_iter) + set_phase!(ps, Pardiso.RELEASE_ALL) + pardiso(ps) + egval_sub = real(1 ./ egval_sub_inv) .+ (fermi_level) + + # orthogonalize the eigenvectors + egvec_sub_qr = qr(egvec_sub) + egvec_sub = convert(Matrix{default_dtype}, egvec_sub_qr.Q) + + S_k_sub = egvec_sub' * S_k * egvec_sub + (egval_S, egvec_S) = eigen(Hermitian(S_k_sub)) + # egvec_S: shape (num_basis, num_bands) + project_index = abs.(egval_S) .> ill_threshold + if sum(project_index) != length(project_index) + H_k_sub = egvec_sub' * H_k * egvec_sub + egvec_S = egvec_S[:, project_index] + @warn "ill-conditioned eigenvalues detected, projected out $(length(project_index) - sum(project_index)) eigenvalues" + H_k_sub = egvec_S' * H_k_sub * egvec_S + S_k_sub = egvec_S' * S_k_sub * egvec_S + (egval, egvec) = eigen(Hermitian(H_k_sub), Hermitian(S_k_sub)) + egval = vcat(egval, fill(1e4, length(project_index) - sum(project_index))) + egvec = egvec_S * egvec + egvec = egvec_sub * egvec + else + egval = egval_sub + end + else + lm, ps = construct_linear_map(Hermitian(H_k) - (fermi_level) * Hermitian(S_k), Hermitian(S_k)) + println("Time for No.$idx_k matrix factorization: ", time() - begin_time, "s") + egval_inv, egvec = eigs(lm, nev=num_band, which=:LM, ritzvec=false, maxiter=max_iter) + set_phase!(ps, Pardiso.RELEASE_ALL) + pardiso(ps) + egval = real(1 ./ egval_inv) .+ (fermi_level) + # egval = real(eigs(H_k, S_k, nev=num_band, sigma=(fermi_level + lowest_band), which=:LR, ritzvec=false, maxiter=max_iter)[1]) + end + egvals[:, idx_k] = egval + println("Time for solving No.$idx_k eigenvalues at k = ", [kx, ky, kz], ": ", time() - begin_time, "s") + end + + open(joinpath(parsed_args["output_dir"], "egvals.dat"), "w") do f + writedlm(f, egvals) + end + + ϵ = config["epsilon"] + ωs = genlist(config["omegas"]) + nωs = length(ωs) + dos = zeros(nωs) + factor = 1/((2π)^3*ϵ*√π) + for idx_k in 1:nks, idx_band in 1:num_band, (idx_ω, ω) in enumerate(ωs) + dos[idx_ω] += exp(-(egvals[idx_band, idx_k] - ω - fermi_level) ^ 2 / ϵ ^ 2) * factor + end + open(joinpath(parsed_args["output_dir"], "dos.dat"), "w") do f + writedlm(f, [ωs dos]) + end + end +end + + +main() diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/kernel.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/kernel.py new file mode 100644 index 0000000000000000000000000000000000000000..8e7ab196125c813959c595873b10eb7405916580 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/kernel.py @@ -0,0 +1,844 @@ +import json +import os +from inspect import signature +import time +import csv +import sys +import shutil +import random +import warnings +from math import sqrt +from itertools import islice +from configparser import ConfigParser + +import torch +import torch.optim as optim +from torch import package +from torch.nn import MSELoss +from torch.optim.lr_scheduler import MultiStepLR, ReduceLROnPlateau, CyclicLR +from torch.utils.data import SubsetRandomSampler, DataLoader +from torch.nn.utils import clip_grad_norm_ +from torch.utils.tensorboard import SummaryWriter +from torch_scatter import scatter_add +import numpy as np +from psutil import cpu_count + +from .data import HData +from .graph import Collater +from .utils import Logger, save_model, LossRecord, MaskMSELoss, Transform + + +class DeepHKernel: + def __init__(self, config: ConfigParser): + self.config = config + + # basic config + if config.getboolean('basic', 'save_to_time_folder'): + config.set('basic', 'save_dir', + os.path.join(config.get('basic', 'save_dir'), + str(time.strftime('%Y-%m-%d_%H-%M-%S', time.localtime(time.time()))))) + assert not os.path.exists(config.get('basic', 'save_dir')) + os.makedirs(config.get('basic', 'save_dir'), exist_ok=True) + + sys.stdout = Logger(os.path.join(config.get('basic', 'save_dir'), "result.txt")) + sys.stderr = Logger(os.path.join(config.get('basic', 'save_dir'), "stderr.txt")) + self.if_tensorboard = config.getboolean('basic', 'tb_writer') + if self.if_tensorboard: + self.tb_writer = SummaryWriter(os.path.join(config.get('basic', 'save_dir'), "tensorboard")) + src_dir = os.path.join(config.get('basic', 'save_dir'), "src") + os.makedirs(src_dir, exist_ok=True) + try: + shutil.copytree(os.path.dirname(__file__), os.path.join(src_dir, 'deeph')) + except: + warnings.warn("Unable to copy scripts") + if not config.getboolean('basic', 'disable_cuda'): + self.device = torch.device(config.get('basic', 'device') if torch.cuda.is_available() else 'cpu') + else: + self.device = torch.device('cpu') + config.set('basic', 'device', str(self.device)) + if config.get('hyperparameter', 'dtype') == 'float32': + default_dtype_torch = torch.float32 + elif config.get('hyperparameter', 'dtype') == 'float16': + default_dtype_torch = torch.float16 + elif config.get('hyperparameter', 'dtype') == 'float64': + default_dtype_torch = torch.float64 + else: + raise ValueError('Unknown dtype: {}'.format(config.get('hyperparameter', 'dtype'))) + np.seterr(all='raise') + np.seterr(under='warn') + np.set_printoptions(precision=8, linewidth=160) + torch.set_default_dtype(default_dtype_torch) + torch.set_printoptions(precision=8, linewidth=160, threshold=np.inf) + np.random.seed(config.getint('basic', 'seed')) + torch.manual_seed(config.getint('basic', 'seed')) + torch.cuda.manual_seed_all(config.getint('basic', 'seed')) + random.seed(config.getint('basic', 'seed')) + torch.backends.cudnn.benchmark = False + torch.backends.cudnn.deterministic = True + torch.cuda.empty_cache() + + if config.getint('basic', 'num_threads', fallback=-1) == -1: + if torch.cuda.device_count() == 0: + torch.set_num_threads(cpu_count(logical=False)) + else: + torch.set_num_threads(cpu_count(logical=False) // torch.cuda.device_count()) + else: + torch.set_num_threads(config.getint('basic', 'num_threads')) + + print('====== CONFIG ======') + for section_k, section_v in islice(config.items(), 1, None): + print(f'[{section_k}]') + for k, v in section_v.items(): + print(f'{k}={v}') + print('') + config.write(open(os.path.join(config.get('basic', 'save_dir'), 'config.ini'), "w")) + + self.if_lcmp = self.config.getboolean('network', 'if_lcmp', fallback=True) + self.if_lcmp_graph = self.config.getboolean('graph', 'if_lcmp_graph', fallback=True) + self.new_sp = self.config.getboolean('graph', 'new_sp', fallback=False) + self.separate_onsite = self.config.getboolean('graph', 'separate_onsite', fallback=False) + if self.if_lcmp == True: + assert self.if_lcmp_graph == True + self.target = self.config.get('basic', 'target') + if self.target == 'O_ij': + self.O_component = config['basic']['O_component'] + if self.target != 'E_ij' and self.target != 'E_i': + self.orbital = json.loads(config.get('basic', 'orbital')) + self.num_orbital = len(self.orbital) + else: + self.energy_component = config['basic']['energy_component'] + # early_stopping + self.early_stopping_loss_epoch = json.loads(self.config.get('train', 'early_stopping_loss_epoch')) + + def build_model(self, model_pack_dir: str = None, old_version=None): + if model_pack_dir is not None: + assert old_version is not None + if old_version is True: + print(f'import HGNN from {model_pack_dir}') + sys.path.append(model_pack_dir) + from src.deeph import HGNN + else: + imp = package.PackageImporter(os.path.join(model_pack_dir, 'best_model.pt')) + checkpoint = imp.load_pickle('checkpoint', 'model.pkl', map_location=self.device) + self.model = checkpoint['model'] + self.model.to(self.device) + self.index_to_Z = checkpoint["index_to_Z"] + self.Z_to_index = checkpoint["Z_to_index"] + self.spinful = checkpoint["spinful"] + print("=> load best checkpoint (epoch {})".format(checkpoint['epoch'])) + print(f"=> Atomic types: {self.index_to_Z.tolist()}, " + f"spinful: {self.spinful}, the number of atomic types: {len(self.index_to_Z)}.") + if self.target != 'E_ij': + if self.spinful: + self.out_fea_len = self.num_orbital * 8 + else: + self.out_fea_len = self.num_orbital + else: + if self.energy_component == 'both': + self.out_fea_len = 2 + elif self.energy_component in ['xc', 'delta_ee', 'summation']: + self.out_fea_len = 1 + else: + raise ValueError('Unknown energy_component: {}'.format(self.energy_component)) + return checkpoint + else: + from .model import HGNN + + if self.spinful: + if self.target == 'phiVdphi': + raise NotImplementedError("Not yet have support for phiVdphi") + else: + self.out_fea_len = self.num_orbital * 8 + else: + if self.target == 'phiVdphi': + self.out_fea_len = self.num_orbital * 3 + else: + self.out_fea_len = self.num_orbital + + print(f'Output features length of single edge: {self.out_fea_len}') + model_kwargs = dict( + n_elements=self.num_species, + num_species=self.num_species, + in_atom_fea_len=self.config.getint('network', 'atom_fea_len'), + in_vfeats=self.config.getint('network', 'atom_fea_len'), + in_edge_fea_len=self.config.getint('network', 'edge_fea_len'), + in_efeats=self.config.getint('network', 'edge_fea_len'), + out_edge_fea_len=self.out_fea_len, + out_efeats=self.out_fea_len, + num_orbital=self.out_fea_len, + distance_expansion=self.config.get('network', 'distance_expansion'), + gauss_stop=self.config.getfloat('network', 'gauss_stop'), + cutoff=self.config.getfloat('network', 'gauss_stop'), + if_exp=self.config.getboolean('network', 'if_exp'), + if_MultipleLinear=self.config.getboolean('network', 'if_MultipleLinear'), + if_edge_update=self.config.getboolean('network', 'if_edge_update'), + if_lcmp=self.if_lcmp, + normalization=self.config.get('network', 'normalization'), + atom_update_net=self.config.get('network', 'atom_update_net', fallback='CGConv'), + separate_onsite=self.separate_onsite, + num_l=self.config.getint('network', 'num_l'), + trainable_gaussians=self.config.getboolean('network', 'trainable_gaussians', fallback=False), + type_affine=self.config.getboolean('network', 'type_affine', fallback=False), + if_fc_out=False, + ) + parameter_list = list(signature(HGNN.__init__).parameters.keys()) + current_parameter_list = list(model_kwargs.keys()) + for k in current_parameter_list: + if k not in parameter_list: + model_kwargs.pop(k) + if 'num_elements' in parameter_list: + model_kwargs['num_elements'] = self.config.getint('basic', 'max_element') + 1 + self.model = HGNN( + **model_kwargs + ) + + model_parameters = filter(lambda p: p.requires_grad, self.model.parameters()) + params = sum([np.prod(p.size()) for p in model_parameters]) + print("The model you built has: %d parameters" % params) + self.model.to(self.device) + self.load_pretrained() + + def set_train(self): + self.criterion_name = self.config.get('hyperparameter', 'criterion', fallback='MaskMSELoss') + if self.target == "E_i": + self.criterion = MSELoss() + elif self.target == "E_ij": + self.criterion = MSELoss() + self.retain_edge_fea = self.config.getboolean('hyperparameter', 'retain_edge_fea') + self.lambda_Eij = self.config.getfloat('hyperparameter', 'lambda_Eij') + self.lambda_Ei = self.config.getfloat('hyperparameter', 'lambda_Ei') + self.lambda_Etot = self.config.getfloat('hyperparameter', 'lambda_Etot') + if self.retain_edge_fea is False: + assert self.lambda_Eij == 0.0 + else: + if self.criterion_name == 'MaskMSELoss': + self.criterion = MaskMSELoss() + else: + raise ValueError(f'Unknown criterion: {self.criterion_name}') + + learning_rate = self.config.getfloat('hyperparameter', 'learning_rate') + momentum = self.config.getfloat('hyperparameter', 'momentum') + weight_decay = self.config.getfloat('hyperparameter', 'weight_decay') + + model_parameters = filter(lambda p: p.requires_grad, self.model.parameters()) + if self.config.get('hyperparameter', 'optimizer') == 'sgd': + self.optimizer = optim.SGD(model_parameters, lr=learning_rate, weight_decay=weight_decay) + elif self.config.get('hyperparameter', 'optimizer') == 'sgdm': + self.optimizer = optim.SGD(model_parameters, lr=learning_rate, momentum=momentum, weight_decay=weight_decay) + elif self.config.get('hyperparameter', 'optimizer') == 'adam': + self.optimizer = optim.Adam(model_parameters, lr=learning_rate, betas=(0.9, 0.999)) + elif self.config.get('hyperparameter', 'optimizer') == 'adamW': + self.optimizer = optim.AdamW(model_parameters, lr=learning_rate, betas=(0.9, 0.999)) + elif self.config.get('hyperparameter', 'optimizer') == 'adagrad': + self.optimizer = optim.Adagrad(model_parameters, lr=learning_rate) + elif self.config.get('hyperparameter', 'optimizer') == 'RMSprop': + self.optimizer = optim.RMSprop(model_parameters, lr=learning_rate) + elif self.config.get('hyperparameter', 'optimizer') == 'lbfgs': + self.optimizer = optim.LBFGS(model_parameters, lr=0.1) + else: + raise ValueError(f'Unknown optimizer: {self.optimizer}') + + if self.config.get('hyperparameter', 'lr_scheduler') == '': + pass + elif self.config.get('hyperparameter', 'lr_scheduler') == 'MultiStepLR': + lr_milestones = json.loads(self.config.get('hyperparameter', 'lr_milestones')) + self.scheduler = MultiStepLR(self.optimizer, milestones=lr_milestones, gamma=0.2) + elif self.config.get('hyperparameter', 'lr_scheduler') == 'ReduceLROnPlateau': + self.scheduler = ReduceLROnPlateau(self.optimizer, mode='min', factor=0.2, patience=10, + verbose=True, threshold=1e-4, threshold_mode='rel', min_lr=0) + elif self.config.get('hyperparameter', 'lr_scheduler') == 'CyclicLR': + self.scheduler = CyclicLR(self.optimizer, base_lr=learning_rate * 0.1, max_lr=learning_rate, + mode='triangular', step_size_up=50, step_size_down=50, cycle_momentum=False) + else: + raise ValueError('Unknown lr_scheduler: {}'.format(self.config.getfloat('hyperparameter', 'lr_scheduler'))) + self.load_resume() + + def load_pretrained(self): + pretrained = self.config.get('train', 'pretrained') + if pretrained: + if os.path.isfile(pretrained): + checkpoint = torch.load(pretrained, map_location=self.device) + pretrained_dict = checkpoint['state_dict'] + model_dict = self.model.state_dict() + + transfer_dict = {} + for k, v in pretrained_dict.items(): + if v.shape == model_dict[k].shape: + transfer_dict[k] = v + print('Use pretrained parameters:', k) + + model_dict.update(transfer_dict) + self.model.load_state_dict(model_dict) + print(f'=> loaded pretrained model at "{pretrained}" (epoch {checkpoint["epoch"]})') + else: + print(f'=> no checkpoint found at "{pretrained}"') + + def load_resume(self): + resume = self.config.get('train', 'resume') + if resume: + if os.path.isfile(resume): + checkpoint = torch.load(resume, map_location=self.device) + self.model.load_state_dict(checkpoint['state_dict']) + self.optimizer.load_state_dict(checkpoint['optimizer_state_dict']) + print(f'=> loaded model at "{resume}" (epoch {checkpoint["epoch"]})') + else: + print(f'=> no checkpoint found at "{resume}"') + + def get_dataset(self, only_get_graph=False): + dataset = HData( + raw_data_dir=self.config.get('basic', 'raw_dir'), + graph_dir=self.config.get('basic', 'graph_dir'), + interface=self.config.get('basic', 'interface'), + target=self.target, + dataset_name=self.config.get('basic', 'dataset_name'), + multiprocessing=self.config.getint('basic', 'multiprocessing', fallback=0), + radius=self.config.getfloat('graph', 'radius'), + max_num_nbr=self.config.getint('graph', 'max_num_nbr'), + num_l=self.config.getint('network', 'num_l'), + max_element=self.config.getint('basic', 'max_element'), + create_from_DFT=self.config.getboolean('graph', 'create_from_DFT', fallback=True), + if_lcmp_graph=self.if_lcmp_graph, + separate_onsite=self.separate_onsite, + new_sp=self.new_sp, + default_dtype_torch=torch.get_default_dtype(), + ) + if only_get_graph: + return None, None, None, None + self.spinful = dataset.info["spinful"] + self.index_to_Z = dataset.info["index_to_Z"] + self.Z_to_index = dataset.info["Z_to_index"] + self.num_species = len(dataset.info["index_to_Z"]) + if self.target != 'E_ij' and self.target != 'E_i': + dataset = self.make_mask(dataset) + + dataset_size = len(dataset) + train_size = int(self.config.getfloat('train', 'train_ratio') * dataset_size) + val_size = int(self.config.getfloat('train', 'val_ratio') * dataset_size) + test_size = int(self.config.getfloat('train', 'test_ratio') * dataset_size) + assert train_size + val_size + test_size <= dataset_size + + indices = list(range(dataset_size)) + np.random.shuffle(indices) + print(f'number of train set: {len(indices[:train_size])}') + print(f'number of val set: {len(indices[train_size:train_size + val_size])}') + print(f'number of test set: {len(indices[train_size + val_size:train_size + val_size + test_size])}') + train_sampler = SubsetRandomSampler(indices[:train_size]) + val_sampler = SubsetRandomSampler(indices[train_size:train_size + val_size]) + test_sampler = SubsetRandomSampler(indices[train_size + val_size:train_size + val_size + test_size]) + train_loader = DataLoader(dataset, batch_size=self.config.getint('hyperparameter', 'batch_size'), + shuffle=False, sampler=train_sampler, + collate_fn=Collater(self.if_lcmp)) + val_loader = DataLoader(dataset, batch_size=self.config.getint('hyperparameter', 'batch_size'), + shuffle=False, sampler=val_sampler, + collate_fn=Collater(self.if_lcmp)) + test_loader = DataLoader(dataset, batch_size=self.config.getint('hyperparameter', 'batch_size'), + shuffle=False, sampler=test_sampler, + collate_fn=Collater(self.if_lcmp)) + + if self.config.getboolean('basic', 'statistics'): + sample_label = torch.cat([dataset[i].label for i in range(len(dataset))]) + sample_mask = torch.cat([dataset[i].mask for i in range(len(dataset))]) + mean_value = abs(sample_label).sum(dim=0) / sample_mask.sum(dim=0) + import matplotlib.pyplot as plt + len_matrix = int(sqrt(self.out_fea_len)) + if len_matrix ** 2 != self.out_fea_len: + raise ValueError + mean_value = mean_value.reshape(len_matrix, len_matrix) + im = plt.imshow(mean_value, cmap='Blues') + plt.colorbar(im) + plt.xticks(range(len_matrix), range(len_matrix)) + plt.yticks(range(len_matrix), range(len_matrix)) + plt.xlabel(r'Orbital $\beta$') + plt.ylabel(r'Orbital $\alpha$') + plt.title(r'Mean of abs($H^\prime_{i\alpha, j\beta}$)') + plt.tight_layout() + plt.savefig(os.path.join(self.config.get('basic', 'save_dir'), 'mean.png'), dpi=800) + np.savetxt(os.path.join(self.config.get('basic', 'save_dir'), 'mean.dat'), mean_value.numpy()) + + print(f"The statistical results are saved to {os.path.join(self.config.get('basic', 'save_dir'), 'mean.dat')}") + + normalizer = self.config.getboolean('basic', 'normalizer') + boxcox = self.config.getboolean('basic', 'boxcox') + if normalizer == False and boxcox == False: + transform = Transform() + else: + sample_label = torch.cat([dataset[i].label for i in range(len(dataset))]) + sample_mask = torch.cat([dataset[i].mask for i in range(len(dataset))]) + transform = Transform(sample_label, mask=sample_mask, normalizer=normalizer, boxcox=boxcox) + print(transform.state_dict()) + + return train_loader, val_loader, test_loader, transform + + def make_mask(self, dataset): + dataset_mask = [] + for data in dataset: + if self.target == 'hamiltonian' or self.target == 'phiVdphi' or self.target == 'density_matrix': + Oij_value = data.term_real + if data.term_real is not None: + if_only_rc = False + else: + if_only_rc = True + elif self.target == 'O_ij': + if self.O_component == 'H_minimum': + Oij_value = data.rvdee + data.rvxc + elif self.O_component == 'H_minimum_withNA': + Oij_value = data.rvna + data.rvdee + data.rvxc + elif self.O_component == 'H': + Oij_value = data.rh + elif self.O_component == 'Rho': + Oij_value = data.rdm + else: + raise ValueError(f'Unknown O_component: {self.O_component}') + if_only_rc = False + else: + raise ValueError(f'Unknown target: {self.target}') + if if_only_rc == False: + if not torch.all(data.term_mask): + raise NotImplementedError("Not yet have support for graph radius including hopping without calculation") + + if self.spinful: + if self.target == 'phiVdphi': + raise NotImplementedError("Not yet have support for phiVdphi") + else: + out_fea_len = self.num_orbital * 8 + else: + if self.target == 'phiVdphi': + out_fea_len = self.num_orbital * 3 + else: + out_fea_len = self.num_orbital + mask = torch.zeros(data.edge_attr.shape[0], out_fea_len, dtype=torch.int8) + label = torch.zeros(data.edge_attr.shape[0], out_fea_len, dtype=torch.get_default_dtype()) + + atomic_number_edge_i = self.index_to_Z[data.x[data.edge_index[0]]] + atomic_number_edge_j = self.index_to_Z[data.x[data.edge_index[1]]] + + for index_out, orbital_dict in enumerate(self.orbital): + for N_M_str, a_b in orbital_dict.items(): + # N_M, a_b means: H_{ia, jb} when the atomic number of atom i is N and the atomic number of atom j is M + condition_atomic_number_i, condition_atomic_number_j = map(lambda x: int(x), N_M_str.split()) + condition_orbital_i, condition_orbital_j = a_b + + if self.spinful: + if self.target == 'phiVdphi': + raise NotImplementedError("Not yet have support for phiVdphi") + else: + mask[:, 8 * index_out:8 * (index_out + 1)] = torch.where( + (atomic_number_edge_i == condition_atomic_number_i) + & (atomic_number_edge_j == condition_atomic_number_j), + 1, + 0 + )[:, None].repeat(1, 8) + else: + if self.target == 'phiVdphi': + mask[:, 3 * index_out:3 * (index_out + 1)] += torch.where( + (atomic_number_edge_i == condition_atomic_number_i) + & (atomic_number_edge_j == condition_atomic_number_j), + 1, + 0 + )[:, None].repeat(1, 3) + else: + mask[:, index_out] += torch.where( + (atomic_number_edge_i == condition_atomic_number_i) + & (atomic_number_edge_j == condition_atomic_number_j), + 1, + 0 + ) + + if if_only_rc == False: + if self.spinful: + if self.target == 'phiVdphi': + raise NotImplementedError + else: + label[:, 8 * index_out:8 * (index_out + 1)] = torch.where( + (atomic_number_edge_i == condition_atomic_number_i) + & (atomic_number_edge_j == condition_atomic_number_j), + Oij_value[:, condition_orbital_i, condition_orbital_j].t(), + torch.zeros(8, data.edge_attr.shape[0], dtype=torch.get_default_dtype()) + ).t() + else: + if self.target == 'phiVdphi': + label[:, 3 * index_out:3 * (index_out + 1)] = torch.where( + (atomic_number_edge_i == condition_atomic_number_i) + & (atomic_number_edge_j == condition_atomic_number_j), + Oij_value[:, condition_orbital_i, condition_orbital_j].t(), + torch.zeros(3, data.edge_attr.shape[0], dtype=torch.get_default_dtype()) + ).t() + else: + label[:, index_out] += torch.where( + (atomic_number_edge_i == condition_atomic_number_i) + & (atomic_number_edge_j == condition_atomic_number_j), + Oij_value[:, condition_orbital_i, condition_orbital_j], + torch.zeros(data.edge_attr.shape[0], dtype=torch.get_default_dtype()) + ) + assert len(torch.where((mask != 1) & (mask != 0))[0]) == 0 + mask = mask.bool() + data.mask = mask + del data.term_mask + if if_only_rc == False: + data.label = label + if self.target == 'hamiltonian' or self.target == 'density_matrix': + del data.term_real + elif self.target == 'O_ij': + del data.rh + del data.rdm + del data.rvdee + del data.rvxc + del data.rvna + dataset_mask.append(data) + return dataset_mask + + def train(self, train_loader, val_loader, test_loader): + begin_time = time.time() + self.best_val_loss = 1e10 + if self.config.getboolean('train', 'revert_then_decay'): + lr_step = 0 + + revert_decay_epoch = json.loads(self.config.get('train', 'revert_decay_epoch')) + revert_decay_gamma = json.loads(self.config.get('train', 'revert_decay_gamma')) + assert len(revert_decay_epoch) == len(revert_decay_gamma) + lr_step_num = len(revert_decay_epoch) + + try: + for epoch in range(self.config.getint('train', 'epochs')): + if self.config.getboolean('train', 'switch_sgd') and epoch == self.config.getint('train', 'switch_sgd_epoch'): + model_parameters = filter(lambda p: p.requires_grad, self.model.parameters()) + self.optimizer = optim.SGD(model_parameters, lr=self.config.getfloat('train', 'switch_sgd_lr')) + print(f"Switch to sgd (epoch: {epoch})") + + learning_rate = self.optimizer.param_groups[0]['lr'] + if self.if_tensorboard: + self.tb_writer.add_scalar('Learning rate', learning_rate, global_step=epoch) + + # train + train_losses = self.kernel_fn(train_loader, 'TRAIN') + if self.if_tensorboard: + self.tb_writer.add_scalars('loss', {'Train loss': train_losses.avg}, global_step=epoch) + + # val + with torch.no_grad(): + val_losses = self.kernel_fn(val_loader, 'VAL') + if val_losses.avg > self.config.getfloat('train', 'revert_threshold') * self.best_val_loss: + print(f'Epoch #{epoch:01d} \t| ' + f'Learning rate: {learning_rate:0.2e} \t| ' + f'Epoch time: {time.time() - begin_time:.2f} \t| ' + f'Train loss: {train_losses.avg:.8f} \t| ' + f'Val loss: {val_losses.avg:.8f} \t| ' + f'Best val loss: {self.best_val_loss:.8f}.' + ) + best_checkpoint = torch.load(os.path.join(self.config.get('basic', 'save_dir'), 'best_state_dict.pkl')) + self.model.load_state_dict(best_checkpoint['state_dict']) + self.optimizer.load_state_dict(best_checkpoint['optimizer_state_dict']) + if self.config.getboolean('train', 'revert_then_decay'): + if lr_step < lr_step_num: + for param_group in self.optimizer.param_groups: + param_group['lr'] = learning_rate * revert_decay_gamma[lr_step] + lr_step += 1 + with torch.no_grad(): + val_losses = self.kernel_fn(val_loader, 'VAL') + print(f"Revert (threshold: {self.config.getfloat('train', 'revert_threshold')}) to epoch {best_checkpoint['epoch']} \t| Val loss: {val_losses.avg:.8f}") + if self.if_tensorboard: + self.tb_writer.add_scalars('loss', {'Validation loss': val_losses.avg}, global_step=epoch) + + if self.config.get('hyperparameter', 'lr_scheduler') == 'MultiStepLR': + self.scheduler.step() + elif self.config.get('hyperparameter', 'lr_scheduler') == 'ReduceLROnPlateau': + self.scheduler.step(val_losses.avg) + elif self.config.get('hyperparameter', 'lr_scheduler') == 'CyclicLR': + self.scheduler.step() + continue + if self.if_tensorboard: + self.tb_writer.add_scalars('loss', {'Validation loss': val_losses.avg}, global_step=epoch) + + if self.config.getboolean('train', 'revert_then_decay'): + if lr_step < lr_step_num and epoch >= revert_decay_epoch[lr_step]: + for param_group in self.optimizer.param_groups: + param_group['lr'] *= revert_decay_gamma[lr_step] + lr_step += 1 + + is_best = val_losses.avg < self.best_val_loss + self.best_val_loss = min(val_losses.avg, self.best_val_loss) + + save_complete = False + while not save_complete: + try: + save_model({ + 'epoch': epoch + 1, + 'optimizer_state_dict': self.optimizer.state_dict(), + 'best_val_loss': self.best_val_loss, + 'spinful': self.spinful, + 'Z_to_index': self.Z_to_index, + 'index_to_Z': self.index_to_Z, + }, {'model': self.model}, {'state_dict': self.model.state_dict()}, + path=self.config.get('basic', 'save_dir'), is_best=is_best) + save_complete = True + except KeyboardInterrupt: + print('\nKeyboardInterrupt while saving model to disk') + + if self.config.get('hyperparameter', 'lr_scheduler') == 'MultiStepLR': + self.scheduler.step() + elif self.config.get('hyperparameter', 'lr_scheduler') == 'ReduceLROnPlateau': + self.scheduler.step(val_losses.avg) + elif self.config.get('hyperparameter', 'lr_scheduler') == 'CyclicLR': + self.scheduler.step() + + print(f'Epoch #{epoch:01d} \t| ' + f'Learning rate: {learning_rate:0.2e} \t| ' + f'Epoch time: {time.time() - begin_time:.2f} \t| ' + f'Train loss: {train_losses.avg:.8f} \t| ' + f'Val loss: {val_losses.avg:.8f} \t| ' + f'Best val loss: {self.best_val_loss:.8f}.' + ) + + if val_losses.avg < self.config.getfloat('train', 'early_stopping_loss'): + print(f"Early stopping because the target accuracy (validation loss < {self.config.getfloat('train', 'early_stopping_loss')}) is achieved at eopch #{epoch:01d}") + break + if epoch > self.early_stopping_loss_epoch[1] and val_losses.avg < self.early_stopping_loss_epoch[0]: + print(f"Early stopping because the target accuracy (validation loss < {self.early_stopping_loss_epoch[0]} and epoch > {self.early_stopping_loss_epoch[1]}) is achieved at eopch #{epoch:01d}") + break + + begin_time = time.time() + except KeyboardInterrupt: + print('\nKeyboardInterrupt') + + print('---------Evaluate Model on Test Set---------------') + best_checkpoint = torch.load(os.path.join(self.config.get('basic', 'save_dir'), 'best_state_dict.pkl')) + self.model.load_state_dict(best_checkpoint['state_dict']) + print("=> load best checkpoint (epoch {})".format(best_checkpoint['epoch'])) + with torch.no_grad(): + test_csv_name = 'test_results.csv' + train_csv_name = 'train_results.csv' + val_csv_name = 'val_results.csv' + + if self.config.getboolean('basic', 'save_csv'): + tmp = 'TEST' + else: + tmp = 'VAL' + test_losses = self.kernel_fn(test_loader, tmp, test_csv_name, output_E=True) + print(f'Test loss: {test_losses.avg:.8f}.') + if self.if_tensorboard: + self.tb_writer.add_scalars('loss', {'Test loss': test_losses.avg}, global_step=epoch) + test_losses = self.kernel_fn(train_loader, tmp, train_csv_name, output_E=True) + print(f'Train loss: {test_losses.avg:.8f}.') + test_losses = self.kernel_fn(val_loader, tmp, val_csv_name, output_E=True) + print(f'Val loss: {test_losses.avg:.8f}.') + + def predict(self, hamiltonian_dirs): + raise NotImplementedError + + def kernel_fn(self, loader, task: str, save_name=None, output_E=False): + assert task in ['TRAIN', 'VAL', 'TEST'] + + losses = LossRecord() + if task == 'TRAIN': + self.model.train() + else: + self.model.eval() + if task == 'TEST': + assert save_name != None + if self.target == "E_i" or self.target == "E_ij": + test_targets = [] + test_preds = [] + test_ids = [] + test_atom_ids = [] + test_atomic_numbers = [] + else: + test_targets = [] + test_preds = [] + test_ids = [] + test_atom_ids = [] + test_atomic_numbers = [] + test_edge_infos = [] + + if task != 'TRAIN' and (self.out_fea_len != 1): + losses_each_out = [LossRecord() for _ in range(self.out_fea_len)] + for step, batch_tuple in enumerate(loader): + if self.if_lcmp: + batch, subgraph = batch_tuple + sub_atom_idx, sub_edge_idx, sub_edge_ang, sub_index = subgraph + output = self.model( + batch.x.to(self.device), + batch.edge_index.to(self.device), + batch.edge_attr.to(self.device), + batch.batch.to(self.device), + sub_atom_idx.to(self.device), + sub_edge_idx.to(self.device), + sub_edge_ang.to(self.device), + sub_index.to(self.device) + ) + else: + batch = batch_tuple + output = self.model( + batch.x.to(self.device), + batch.edge_index.to(self.device), + batch.edge_attr.to(self.device), + batch.batch.to(self.device) + ) + if self.target == 'E_ij': + if self.energy_component == 'E_ij': + label_non_onsite = batch.E_ij.to(self.device) + label_onsite = batch.onsite_E_ij.to(self.device) + elif self.energy_component == 'summation': + label_non_onsite = batch.E_delta_ee_ij.to(self.device) + batch.E_xc_ij.to(self.device) + label_onsite = batch.onsite_E_delta_ee_ij.to(self.device) + batch.onsite_E_xc_ij.to(self.device) + elif self.energy_component == 'delta_ee': + label_non_onsite = batch.E_delta_ee_ij.to(self.device) + label_onsite = batch.onsite_E_delta_ee_ij.to(self.device) + elif self.energy_component == 'xc': + label_non_onsite = batch.E_xc_ij.to(self.device) + label_onsite = batch.onsite_E_xc_ij.to(self.device) + elif self.energy_component == 'both': + raise NotImplementedError + output_onsite, output_non_onsite = output + if self.retain_edge_fea is False: + output_non_onsite = output_non_onsite * 0 + + elif self.target == 'E_i': + label = batch.E_i.to(self.device) + output = output.reshape(label.shape) + else: + label = batch.label.to(self.device) + output = output.reshape(label.shape) + + if self.target == 'E_i': + loss = self.criterion(output, label) + elif self.target == 'E_ij': + loss_Eij = self.criterion(torch.cat([output_onsite, output_non_onsite], dim=0), + torch.cat([label_onsite, label_non_onsite], dim=0)) + output_non_onsite_Ei = scatter_add(output_non_onsite, batch.edge_index.to(self.device)[0, :], dim=0) + label_non_onsite_Ei = scatter_add(label_non_onsite, batch.edge_index.to(self.device)[0, :], dim=0) + output_Ei = output_non_onsite_Ei + output_onsite + label_Ei = label_non_onsite_Ei + label_onsite + loss_Ei = self.criterion(output_Ei, label_Ei) + loss_Etot = self.criterion(scatter_add(output_Ei, batch.batch.to(self.device), dim=0), + scatter_add(label_Ei, batch.batch.to(self.device), dim=0)) + loss = loss_Eij * self.lambda_Eij + loss_Ei * self.lambda_Ei + loss_Etot * self.lambda_Etot + else: + if self.criterion_name == 'MaskMSELoss': + mask = batch.mask.to(self.device) + loss = self.criterion(output, label, mask) + else: + raise ValueError(f'Unknown criterion: {self.criterion_name}') + if task == 'TRAIN': + if self.config.get('hyperparameter', 'optimizer') == 'lbfgs': + def closure(): + self.optimizer.zero_grad() + if self.if_lcmp: + output = self.model( + batch.x.to(self.device), + batch.edge_index.to(self.device), + batch.edge_attr.to(self.device), + batch.batch.to(self.device), + sub_atom_idx.to(self.device), + sub_edge_idx.to(self.device), + sub_edge_ang.to(self.device), + sub_index.to(self.device) + ) + else: + output = self.model( + batch.x.to(self.device), + batch.edge_index.to(self.device), + batch.edge_attr.to(self.device), + batch.batch.to(self.device) + ) + loss = self.criterion(output, label.to(self.device), mask) + loss.backward() + return loss + + self.optimizer.step(closure) + else: + self.optimizer.zero_grad() + loss.backward() + if self.config.getboolean('train', 'clip_grad'): + clip_grad_norm_(self.model.parameters(), self.config.getfloat('train', 'clip_grad_value')) + self.optimizer.step() + + if self.target == "E_i" or self.target == "E_ij": + losses.update(loss.item(), batch.num_nodes) + else: + if self.criterion_name == 'MaskMSELoss': + losses.update(loss.item(), mask.sum()) + if task != 'TRAIN' and self.out_fea_len != 1: + if self.criterion_name == 'MaskMSELoss': + se_each_out = torch.pow(output - label.to(self.device), 2) + for index_out, losses_each_out_for in enumerate(losses_each_out): + count = mask[:, index_out].sum().item() + if count == 0: + losses_each_out_for.update(-1, 1) + else: + losses_each_out_for.update( + torch.masked_select(se_each_out[:, index_out], mask[:, index_out]).mean().item(), + count + ) + if task == 'TEST': + if self.target == "E_ij": + test_targets += torch.squeeze(label_Ei.detach().cpu()).tolist() + test_preds += torch.squeeze(output_Ei.detach().cpu()).tolist() + test_ids += np.array(batch.stru_id)[torch.squeeze(batch.batch).numpy()].tolist() + test_atom_ids += torch.squeeze( + torch.tensor(range(batch.num_nodes)) - torch.tensor(batch.__slices__['x'])[ + batch.batch]).tolist() + test_atomic_numbers += torch.squeeze(self.index_to_Z[batch.x]).tolist() + elif self.target == "E_i": + test_targets = torch.squeeze(label.detach().cpu()).tolist() + test_preds = torch.squeeze(output.detach().cpu()).tolist() + test_ids = np.array(batch.stru_id)[torch.squeeze(batch.batch).numpy()].tolist() + test_atom_ids += torch.squeeze(torch.tensor(range(batch.num_nodes)) - torch.tensor(batch.__slices__['x'])[batch.batch]).tolist() + test_atomic_numbers += torch.squeeze(self.index_to_Z[batch.x]).tolist() + else: + edge_stru_index = torch.squeeze(batch.batch[batch.edge_index[0]]).numpy() + edge_slices = torch.tensor(batch.__slices__['x'])[edge_stru_index].view(-1, 1) + test_preds += torch.squeeze(output.detach().cpu()).tolist() + test_targets += torch.squeeze(label.detach().cpu()).tolist() + test_ids += np.array(batch.stru_id)[edge_stru_index].tolist() + test_atom_ids += torch.squeeze(batch.edge_index.T - edge_slices).tolist() + test_atomic_numbers += torch.squeeze(self.index_to_Z[batch.x[batch.edge_index.T]]).tolist() + test_edge_infos += torch.squeeze(batch.edge_attr[:, :7].detach().cpu()).tolist() + if output_E is True: + if self.target == 'E_ij': + output_non_onsite_Ei = scatter_add(output_non_onsite, batch.edge_index.to(self.device)[1, :], dim=0) + label_non_onsite_Ei = scatter_add(label_non_onsite, batch.edge_index.to(self.device)[1, :], dim=0) + output_Ei = output_non_onsite_Ei + output_onsite + label_Ei = label_non_onsite_Ei + label_onsite + Etot_error = abs(scatter_add(output_Ei, batch.batch.to(self.device), dim=0) + - scatter_add(label_Ei, batch.batch.to(self.device), dim=0)).reshape(-1).tolist() + for test_stru_id, test_error in zip(batch.stru_id, Etot_error): + print(f'{test_stru_id}: {test_error * 1000:.2f} meV / unit_cell') + elif self.target == 'E_i': + Etot_error = abs(scatter_add(output, batch.batch.to(self.device), dim=0) + - scatter_add(label, batch.batch.to(self.device), dim=0)).reshape(-1).tolist() + for test_stru_id, test_error in zip(batch.stru_id, Etot_error): + print(f'{test_stru_id}: {test_error * 1000:.2f} meV / unit_cell') + + if task != 'TRAIN' and (self.out_fea_len != 1): + print('%s loss each out:' % task) + loss_list = list(map(lambda x: f'{x.avg:0.1e}', losses_each_out)) + print('[' + ', '.join(loss_list) + ']') + loss_list = list(map(lambda x: x.avg, losses_each_out)) + print(f'max orbital: {max(loss_list):0.1e} (0-based index: {np.argmax(loss_list)})') + if task == 'TEST': + with open(os.path.join(self.config.get('basic', 'save_dir'), save_name), 'w', newline='') as f: + writer = csv.writer(f) + if self.target == "E_i" or self.target == "E_ij": + writer.writerow(['stru_id', 'atom_id', 'atomic_number'] + + ['target'] * self.out_fea_len + ['pred'] * self.out_fea_len) + for stru_id, atom_id, atomic_number, target, pred in zip(test_ids, test_atom_ids, + test_atomic_numbers, + test_targets, test_preds): + if self.out_fea_len == 1: + writer.writerow((stru_id, atom_id, atomic_number, target, pred)) + else: + writer.writerow((stru_id, atom_id, atomic_number, *target, *pred)) + + else: + writer.writerow(['stru_id', 'atom_id', 'atomic_number', 'dist', 'atom1_x', 'atom1_y', 'atom1_z', + 'atom2_x', 'atom2_y', 'atom2_z'] + + ['target'] * self.out_fea_len + ['pred'] * self.out_fea_len) + for stru_id, atom_id, atomic_number, edge_info, target, pred in zip(test_ids, test_atom_ids, + test_atomic_numbers, + test_edge_infos, test_targets, + test_preds): + if self.out_fea_len == 1: + writer.writerow((stru_id, atom_id, atomic_number, *edge_info, target, pred)) + else: + writer.writerow((stru_id, atom_id, atomic_number, *edge_info, *target, *pred)) + return losses diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/model.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/model.py new file mode 100644 index 0000000000000000000000000000000000000000..3c709eaefeed241cefbf658e04c716e3c9b36231 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/model.py @@ -0,0 +1,676 @@ +import os +from typing import Union, Tuple +from math import ceil, sqrt + +import torch +from torch import nn +import torch.nn.functional as F +from torch_geometric.nn.conv import MessagePassing +from torch_geometric.nn.norm import LayerNorm, PairNorm, InstanceNorm +from torch_geometric.typing import PairTensor, Adj, OptTensor, Size +from torch_geometric.nn.inits import glorot, zeros +from torch_geometric.utils import softmax +from torch_geometric.nn.models.dimenet import BesselBasisLayer +from torch_scatter import scatter_add, scatter +import numpy as np +from scipy.special import comb + +from .from_se3_transformer import SphericalHarmonics +from .from_schnetpack import GaussianBasis +from .from_PyG_future import GraphNorm, DiffGroupNorm +from .from_HermNet import RBF, cosine_cutoff, ShiftedSoftplus, _eps + + +class ExpBernsteinBasis(nn.Module): + def __init__(self, K, gamma, cutoff, trainable=True): + super(ExpBernsteinBasis, self).__init__() + self.K = K + if trainable: + self.gamma = nn.Parameter(torch.tensor(gamma)) + else: + self.gamma = torch.tensor(gamma) + self.register_buffer('cutoff', torch.tensor(cutoff)) + self.register_buffer('comb_k', torch.Tensor(comb(K - 1, np.arange(K)))) + + def forward(self, distances): + f_zero = torch.zeros_like(distances) + f_cut = torch.where(distances < self.cutoff, torch.exp( + -(distances ** 2) / (self.cutoff ** 2 - distances ** 2)), f_zero) + x = torch.exp(-self.gamma * distances) + out = [] + for k in range(self.K): + out.append((x ** k) * ((1 - x) ** (self.K - 1 - k))) + out = torch.stack(out, dim=-1) + out = out * self.comb_k[None, :] * f_cut[:, None] + return out + + +def get_spherical_from_cartesian(cartesian, cartesian_x=1, cartesian_y=2, cartesian_z=0): + spherical = torch.zeros_like(cartesian[..., 0:2]) + r_xy = cartesian[..., cartesian_x] ** 2 + cartesian[..., cartesian_y] ** 2 + spherical[..., 0] = torch.atan2(torch.sqrt(r_xy), cartesian[..., cartesian_z]) + spherical[..., 1] = torch.atan2(cartesian[..., cartesian_y], cartesian[..., cartesian_x]) + return spherical + + +class SphericalHarmonicsBasis(nn.Module): + def __init__(self, num_l=5): + super(SphericalHarmonicsBasis, self).__init__() + self.num_l = num_l + + def forward(self, edge_attr): + r_vec = edge_attr[:, 1:4] - edge_attr[:, 4:7] + r_vec_sp = get_spherical_from_cartesian(r_vec) + sph_harm_func = SphericalHarmonics() + + angular_expansion = [] + for l in range(self.num_l): + angular_expansion.append(sph_harm_func.get(l, r_vec_sp[:, 0], r_vec_sp[:, 1])) + angular_expansion = torch.cat(angular_expansion, dim=-1) + + return angular_expansion + + +""" +The class CGConv below is extended from "https://github.com/rusty1s/pytorch_geometric", which has the MIT License below + +--------------------------------------------------------------------------- +Copyright (c) 2020 Matthias Fey + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" +class CGConv(MessagePassing): + def __init__(self, channels: Union[int, Tuple[int, int]], dim: int = 0, + aggr: str = 'add', normalization: str = None, + bias: bool = True, if_exp: bool = False, **kwargs): + super(CGConv, self).__init__(aggr=aggr, flow="source_to_target", **kwargs) + self.channels = channels + self.dim = dim + self.normalization = normalization + self.if_exp = if_exp + + if isinstance(channels, int): + channels = (channels, channels) + + self.lin_f = nn.Linear(sum(channels) + dim, channels[1], bias=bias) + self.lin_s = nn.Linear(sum(channels) + dim, channels[1], bias=bias) + if self.normalization == 'BatchNorm': + self.bn = nn.BatchNorm1d(channels[1], track_running_stats=True) + elif self.normalization == 'LayerNorm': + self.ln = LayerNorm(channels[1]) + elif self.normalization == 'PairNorm': + self.pn = PairNorm(channels[1]) + elif self.normalization == 'InstanceNorm': + self.instance_norm = InstanceNorm(channels[1]) + elif self.normalization == 'GraphNorm': + self.gn = GraphNorm(channels[1]) + elif self.normalization == 'DiffGroupNorm': + self.group_norm = DiffGroupNorm(channels[1], 128) + elif self.normalization is None: + pass + else: + raise ValueError('Unknown normalization function: {}'.format(normalization)) + + self.reset_parameters() + + def reset_parameters(self): + self.lin_f.reset_parameters() + self.lin_s.reset_parameters() + if self.normalization == 'BatchNorm': + self.bn.reset_parameters() + + def forward(self, x: Union[torch.Tensor, PairTensor], edge_index: Adj, + edge_attr: OptTensor, batch, distance, size: Size = None) -> torch.Tensor: + """""" + if isinstance(x, torch.Tensor): + x: PairTensor = (x, x) + + # propagate_type: (x: PairTensor, edge_attr: OptTensor) + out = self.propagate(edge_index, x=x, edge_attr=edge_attr, distance=distance, size=size) + if self.normalization == 'BatchNorm': + out = self.bn(out) + elif self.normalization == 'LayerNorm': + out = self.ln(out, batch) + elif self.normalization == 'PairNorm': + out = self.pn(out, batch) + elif self.normalization == 'InstanceNorm': + out = self.instance_norm(out, batch) + elif self.normalization == 'GraphNorm': + out = self.gn(out, batch) + elif self.normalization == 'DiffGroupNorm': + out = self.group_norm(out) + out += x[1] + return out + + def message(self, x_i, x_j, edge_attr: OptTensor, distance) -> torch.Tensor: + z = torch.cat([x_i, x_j, edge_attr], dim=-1) + out = self.lin_f(z).sigmoid() * F.softplus(self.lin_s(z)) + if self.if_exp: + sigma = 3 + n = 2 + out = out * torch.exp(-distance ** n / sigma ** n / 2).view(-1, 1) + return out + + def __repr__(self): + return '{}({}, dim={})'.format(self.__class__.__name__, self.channels, self.dim) + + +class GAT_Crystal(MessagePassing): + def __init__(self, in_features, out_features, edge_dim, heads, concat=False, normalization: str = None, + dropout=0, bias=True, **kwargs): + super(GAT_Crystal, self).__init__(node_dim=0, aggr='add', flow='target_to_source', **kwargs) + self.in_features = in_features + self.out_features = out_features + self.heads = heads + self.concat = concat + self.dropout = dropout + self.neg_slope = 0.2 + self.prelu = nn.PReLU() + self.bn1 = nn.BatchNorm1d(heads) + self.W = nn.Parameter(torch.Tensor(in_features + edge_dim, heads * out_features)) + self.att = nn.Parameter(torch.Tensor(1, heads, 2 * out_features)) + + if bias and concat: + self.bias = nn.Parameter(torch.Tensor(heads * out_features)) + elif bias and not concat: + self.bias = nn.Parameter(torch.Tensor(out_features)) + else: + self.register_parameter('bias', None) + + self.normalization = normalization + if self.normalization == 'BatchNorm': + self.bn = nn.BatchNorm1d(out_features, track_running_stats=True) + elif self.normalization == 'LayerNorm': + self.ln = LayerNorm(out_features) + elif self.normalization == 'PairNorm': + self.pn = PairNorm(out_features) + elif self.normalization == 'InstanceNorm': + self.instance_norm = InstanceNorm(out_features) + elif self.normalization == 'GraphNorm': + self.gn = GraphNorm(out_features) + elif self.normalization == 'DiffGroupNorm': + self.group_norm = DiffGroupNorm(out_features, 128) + elif self.normalization is None: + pass + else: + raise ValueError('Unknown normalization function: {}'.format(normalization)) + + self.reset_parameters() + + def reset_parameters(self): + glorot(self.W) + glorot(self.att) + zeros(self.bias) + + def forward(self, x, edge_index, edge_attr, batch, distance): + out = self.propagate(edge_index, x=x, edge_attr=edge_attr) + + if self.normalization == 'BatchNorm': + out = self.bn(out) + elif self.normalization == 'LayerNorm': + out = self.ln(out, batch) + elif self.normalization == 'PairNorm': + out = self.pn(out, batch) + elif self.normalization == 'InstanceNorm': + out = self.instance_norm(out, batch) + elif self.normalization == 'GraphNorm': + out = self.gn(out, batch) + elif self.normalization == 'DiffGroupNorm': + out = self.group_norm(out) + return out + + def message(self, edge_index_i, x_i, x_j, size_i, index, ptr: OptTensor, edge_attr): + x_i = torch.cat([x_i, edge_attr], dim=-1) + x_j = torch.cat([x_j, edge_attr], dim=-1) + + x_i = F.softplus(torch.matmul(x_i, self.W)) + x_j = F.softplus(torch.matmul(x_j, self.W)) + x_i = x_i.view(-1, self.heads, self.out_features) + x_j = x_j.view(-1, self.heads, self.out_features) + + alpha = F.softplus((torch.cat([x_i, x_j], dim=-1) * self.att).sum(dim=-1)) + alpha = F.softplus(self.bn1(alpha)) + + alpha = softmax(alpha, index, ptr, size_i) + + alpha = F.dropout(alpha, p=self.dropout, training=self.training) + + return x_j * alpha.view(-1, self.heads, 1) + + def update(self, aggr_out, x): + if self.concat is True: + aggr_out = aggr_out.view(-1, self.heads * self.out_features) + else: + aggr_out = aggr_out.mean(dim=1) + if self.bias is not None: aggr_out = aggr_out + self.bias + return aggr_out + + +class PaninnNodeFea(): + def __init__(self, node_fea_s, node_fea_v=None): + self.node_fea_s = node_fea_s + if node_fea_v == None: + self.node_fea_v = torch.zeros(node_fea_s.shape[0], node_fea_s.shape[1], 3, dtype=node_fea_s.dtype, + device=node_fea_s.device) + else: + self.node_fea_v = node_fea_v + + def __add__(self, other): + return PaninnNodeFea(self.node_fea_s + other.node_fea_s, self.node_fea_v + other.node_fea_v) + + +class PAINN(nn.Module): + def __init__(self, in_features, edge_dim, rc: float, l: int, normalization): + super(PAINN, self).__init__() + self.ms1 = nn.Linear(in_features, in_features) + self.ssp = ShiftedSoftplus() + self.ms2 = nn.Linear(in_features, in_features * 3) + + self.rbf = RBF(rc, l) + self.mv = nn.Linear(l, in_features * 3) + self.fc = cosine_cutoff(rc) + + self.us1 = nn.Linear(in_features * 2, in_features) + self.us2 = nn.Linear(in_features, in_features * 3) + + self.normalization = normalization + if self.normalization == 'BatchNorm': + self.bn = nn.BatchNorm1d(in_features, track_running_stats=True) + elif self.normalization == 'LayerNorm': + self.ln = LayerNorm(in_features) + elif self.normalization == 'PairNorm': + self.pn = PairNorm(in_features) + elif self.normalization == 'InstanceNorm': + self.instance_norm = InstanceNorm(in_features) + elif self.normalization == 'GraphNorm': + self.gn = GraphNorm(in_features) + elif self.normalization == 'DiffGroupNorm': + self.group_norm = DiffGroupNorm(in_features, 128) + elif self.normalization is None or self.normalization == 'None': + pass + else: + raise ValueError('Unknown normalization function: {}'.format(normalization)) + + def forward(self, x: Union[torch.Tensor, PairTensor], edge_index: Adj, + edge_attr: OptTensor, batch, edge_vec) -> torch.Tensor: + r = torch.sqrt((edge_vec ** 2).sum(dim=-1) + _eps).unsqueeze(-1) + sj = x.node_fea_s[edge_index[1, :]] + vj = x.node_fea_v[edge_index[1, :]] + + phi = self.ms2(self.ssp(self.ms1(sj))) + w = self.fc(r) * self.mv(self.rbf(r)) + v_, s_, r_ = torch.chunk(phi * w, 3, dim=-1) + + ds_update = s_ + dv_update = vj * v_.unsqueeze(-1) + r_.unsqueeze(-1) * (edge_vec / r).unsqueeze(1) + + ds = scatter(ds_update, edge_index[0], dim=0, dim_size=x.node_fea_s.shape[0], reduce='mean') + dv = scatter(dv_update, edge_index[0], dim=0, dim_size=x.node_fea_s.shape[0], reduce='mean') + x = x + PaninnNodeFea(ds, dv) + + sj = x.node_fea_s[edge_index[1, :]] + vj = x.node_fea_v[edge_index[1, :]] + norm = torch.sqrt((vj ** 2).sum(dim=-1) + _eps) + s = torch.cat([norm, sj], dim=-1) + sj = self.us2(self.ssp(self.us1(s))) + + uv = scatter(vj, edge_index[0], dim=0, dim_size=x.node_fea_s.shape[0], reduce='mean') + norm = torch.sqrt((uv ** 2).sum(dim=-1) + _eps).unsqueeze(-1) + s_ = scatter(sj, edge_index[0], dim=0, dim_size=x.node_fea_s.shape[0], reduce='mean') + avv, asv, ass = torch.chunk(s_, 3, dim=-1) + + ds = ((uv / norm) ** 2).sum(dim=-1) * asv + ass + dv = uv * avv.unsqueeze(-1) + + if self.normalization == 'BatchNorm': + ds = self.bn(ds) + elif self.normalization == 'LayerNorm': + ds = self.ln(ds, batch) + elif self.normalization == 'PairNorm': + ds = self.pn(ds, batch) + elif self.normalization == 'InstanceNorm': + ds = self.instance_norm(ds, batch) + elif self.normalization == 'GraphNorm': + ds = self.gn(ds, batch) + elif self.normalization == 'DiffGroupNorm': + ds = self.group_norm(ds) + + x = x + PaninnNodeFea(ds, dv) + + return x + + +class MPLayer(nn.Module): + def __init__(self, in_atom_fea_len, in_edge_fea_len, out_edge_fea_len, if_exp, if_edge_update, normalization, + atom_update_net, gauss_stop, output_layer=False): + super(MPLayer, self).__init__() + if atom_update_net == 'CGConv': + self.cgconv = CGConv(channels=in_atom_fea_len, + dim=in_edge_fea_len, + aggr='add', + normalization=normalization, + if_exp=if_exp) + elif atom_update_net == 'GAT': + self.cgconv = GAT_Crystal( + in_features=in_atom_fea_len, + out_features=in_atom_fea_len, + edge_dim=in_edge_fea_len, + heads=3, + normalization=normalization + ) + elif atom_update_net == 'PAINN': + self.cgconv = PAINN( + in_features=in_atom_fea_len, + edge_dim=in_edge_fea_len, + rc=gauss_stop, + l=64, + normalization=normalization + ) + + self.if_edge_update = if_edge_update + self.atom_update_net = atom_update_net + if if_edge_update: + if output_layer: + self.e_lin = nn.Sequential(nn.Linear(in_edge_fea_len + in_atom_fea_len * 2, 128), + nn.SiLU(), + nn.Linear(128, out_edge_fea_len), + ) + else: + self.e_lin = nn.Sequential(nn.Linear(in_edge_fea_len + in_atom_fea_len * 2, 128), + nn.SiLU(), + nn.Linear(128, out_edge_fea_len), + nn.SiLU(), + ) + + def forward(self, atom_fea, edge_idx, edge_fea, batch, distance, edge_vec): + if self.atom_update_net == 'PAINN': + atom_fea = self.cgconv(atom_fea, edge_idx, edge_fea, batch, edge_vec) + atom_fea_s = atom_fea.node_fea_s + else: + atom_fea = self.cgconv(atom_fea, edge_idx, edge_fea, batch, distance) + atom_fea_s = atom_fea + if self.if_edge_update: + row, col = edge_idx + edge_fea = self.e_lin(torch.cat([atom_fea_s[row], atom_fea_s[col], edge_fea], dim=-1)) + return atom_fea, edge_fea + else: + return atom_fea + + +class LCMPLayer(nn.Module): + def __init__(self, in_atom_fea_len, in_edge_fea_len, out_edge_fea_len, num_l, + normalization: str = None, bias: bool = True, if_exp: bool = False): + super(LCMPLayer, self).__init__() + self.in_atom_fea_len = in_atom_fea_len + self.normalization = normalization + self.if_exp = if_exp + + self.lin_f = nn.Linear(in_atom_fea_len * 2 + in_edge_fea_len, in_atom_fea_len, bias=bias) + self.lin_s = nn.Linear(in_atom_fea_len * 2 + in_edge_fea_len, in_atom_fea_len, bias=bias) + self.bn = nn.BatchNorm1d(in_atom_fea_len, track_running_stats=True) + + self.e_lin = nn.Sequential(nn.Linear(in_edge_fea_len + in_atom_fea_len * 2 - num_l ** 2, 128), + nn.SiLU(), + nn.Linear(128, out_edge_fea_len) + ) + self.reset_parameters() + + def reset_parameters(self): + self.lin_f.reset_parameters() + self.lin_s.reset_parameters() + if self.normalization == 'BatchNorm': + self.bn.reset_parameters() + + def forward(self, atom_fea, edge_fea, sub_atom_idx, sub_edge_idx, sub_edge_ang, sub_index, distance, + huge_structure, output_final_layer_neuron): + if huge_structure: + sub_graph_batch_num = 8 + + sub_graph_num = sub_atom_idx.shape[0] + sub_graph_batch_size = ceil(sub_graph_num / sub_graph_batch_num) + + num_edge = edge_fea.shape[0] + vf_update = torch.zeros((num_edge * 2, self.in_atom_fea_len)).type(torch.get_default_dtype()).to(atom_fea.device) + for sub_graph_batch_index in range(sub_graph_batch_num): + if sub_graph_batch_index == sub_graph_batch_num - 1: + sub_graph_idx = slice(sub_graph_batch_size * sub_graph_batch_index, sub_graph_num) + else: + sub_graph_idx = slice(sub_graph_batch_size * sub_graph_batch_index, + sub_graph_batch_size * (sub_graph_batch_index + 1)) + + sub_atom_idx_batch = sub_atom_idx[sub_graph_idx] + sub_edge_idx_batch = sub_edge_idx[sub_graph_idx] + sub_edge_ang_batch = sub_edge_ang[sub_graph_idx] + sub_index_batch = sub_index[sub_graph_idx] + + z = torch.cat([atom_fea[sub_atom_idx_batch][:, 0, :], atom_fea[sub_atom_idx_batch][:, 1, :], + edge_fea[sub_edge_idx_batch], sub_edge_ang_batch], dim=-1) + out = self.lin_f(z).sigmoid() * F.softplus(self.lin_s(z)) + + if self.if_exp: + sigma = 3 + n = 2 + out = out * torch.exp(-distance[sub_edge_idx_batch] ** n / sigma ** n / 2).view(-1, 1) + + vf_update += scatter_add(out, sub_index_batch, dim=0, dim_size=num_edge * 2) + + if self.normalization == 'BatchNorm': + vf_update = self.bn(vf_update) + vf_update = vf_update.reshape(num_edge, 2, -1) + if output_final_layer_neuron != '': + final_layer_neuron = torch.cat([vf_update[:, 0, :], vf_update[:, 1, :], edge_fea], + dim=-1).detach().cpu().numpy() + np.save(os.path.join(output_final_layer_neuron, 'final_layer_neuron.npy'), final_layer_neuron) + out = self.e_lin(torch.cat([vf_update[:, 0, :], vf_update[:, 1, :], edge_fea], dim=-1)) + + return out + + num_edge = edge_fea.shape[0] + z = torch.cat( + [atom_fea[sub_atom_idx][:, 0, :], atom_fea[sub_atom_idx][:, 1, :], edge_fea[sub_edge_idx], sub_edge_ang], + dim=-1) + out = self.lin_f(z).sigmoid() * F.softplus(self.lin_s(z)) + + if self.if_exp: + sigma = 3 + n = 2 + out = out * torch.exp(-distance[sub_edge_idx] ** n / sigma ** n / 2).view(-1, 1) + + out = scatter_add(out, sub_index, dim=0) + if self.normalization == 'BatchNorm': + out = self.bn(out) + out = out.reshape(num_edge, 2, -1) + if output_final_layer_neuron != '': + final_layer_neuron = torch.cat([out[:, 0, :], out[:, 1, :], edge_fea], dim=-1).detach().cpu().numpy() + np.save(os.path.join(output_final_layer_neuron, 'final_layer_neuron.npy'), final_layer_neuron) + out = self.e_lin(torch.cat([out[:, 0, :], out[:, 1, :], edge_fea], dim=-1)) + return out + + +class MultipleLinear(nn.Module): + def __init__(self, num_linear: int, in_fea_len: int, out_fea_len: int, bias: bool = True) -> None: + super(MultipleLinear, self).__init__() + self.num_linear = num_linear + self.out_fea_len = out_fea_len + self.weight = nn.Parameter(torch.Tensor(num_linear, in_fea_len, out_fea_len)) + if bias: + self.bias = nn.Parameter(torch.Tensor(num_linear, out_fea_len)) + else: + self.register_parameter('bias', None) + # self.ln = LayerNorm(num_linear * out_fea_len) + # self.gn = GraphNorm(out_fea_len) + self.reset_parameters() + + def reset_parameters(self) -> None: + nn.init.kaiming_uniform_(self.weight, a=sqrt(5)) + if self.bias is not None: + fan_in, _ = nn.init._calculate_fan_in_and_fan_out(self.weight) + bound = 1 / sqrt(fan_in) + nn.init.uniform_(self.bias, -bound, bound) + + def forward(self, input: torch.Tensor, batch_edge: torch.Tensor) -> torch.Tensor: + output = torch.matmul(input, self.weight) + + if self.bias is not None: + output += self.bias[:, None, :] + return output + + +class HGNN(nn.Module): + def __init__(self, num_species, in_atom_fea_len, in_edge_fea_len, num_orbital, + distance_expansion, gauss_stop, if_exp, if_MultipleLinear, if_edge_update, if_lcmp, + normalization, atom_update_net, separate_onsite, + trainable_gaussians, type_affine, num_l=5): + super(HGNN, self).__init__() + self.num_species = num_species + self.embed = nn.Embedding(num_species + 5, in_atom_fea_len) + + # pair-type aware affine + if type_affine: + self.type_affine = nn.Embedding( + num_species ** 2, 2, + _weight=torch.stack([torch.ones(num_species ** 2), torch.zeros(num_species ** 2)], dim=-1) + ) + else: + self.type_affine = None + + if if_edge_update or (if_edge_update is False and if_lcmp is False): + distance_expansion_len = in_edge_fea_len + else: + distance_expansion_len = in_edge_fea_len - num_l ** 2 + if distance_expansion == 'GaussianBasis': + self.distance_expansion = GaussianBasis( + 0.0, gauss_stop, distance_expansion_len, trainable=trainable_gaussians + ) + elif distance_expansion == 'BesselBasis': + self.distance_expansion = BesselBasisLayer(distance_expansion_len, gauss_stop, envelope_exponent=5) + elif distance_expansion == 'ExpBernsteinBasis': + self.distance_expansion = ExpBernsteinBasis(K=distance_expansion_len, gamma=0.5, cutoff=gauss_stop, + trainable=True) + else: + raise ValueError('Unknown distance expansion function: {}'.format(distance_expansion)) + + self.if_MultipleLinear = if_MultipleLinear + self.if_edge_update = if_edge_update + self.if_lcmp = if_lcmp + self.atom_update_net = atom_update_net + self.separate_onsite = separate_onsite + + if if_lcmp == True: + mp_output_edge_fea_len = in_edge_fea_len - num_l ** 2 + else: + assert if_MultipleLinear == False + mp_output_edge_fea_len = in_edge_fea_len + + if if_edge_update == True: + self.mp1 = MPLayer(in_atom_fea_len, in_edge_fea_len, in_edge_fea_len, if_exp, if_edge_update, normalization, + atom_update_net, gauss_stop) + self.mp2 = MPLayer(in_atom_fea_len, in_edge_fea_len, in_edge_fea_len, if_exp, if_edge_update, normalization, + atom_update_net, gauss_stop) + self.mp3 = MPLayer(in_atom_fea_len, in_edge_fea_len, in_edge_fea_len, if_exp, if_edge_update, normalization, + atom_update_net, gauss_stop) + self.mp4 = MPLayer(in_atom_fea_len, in_edge_fea_len, in_edge_fea_len, if_exp, if_edge_update, normalization, + atom_update_net, gauss_stop) + self.mp5 = MPLayer(in_atom_fea_len, in_edge_fea_len, mp_output_edge_fea_len, if_exp, if_edge_update, + normalization, atom_update_net, gauss_stop) + else: + self.mp1 = MPLayer(in_atom_fea_len, distance_expansion_len, None, if_exp, if_edge_update, normalization, + atom_update_net, gauss_stop) + self.mp2 = MPLayer(in_atom_fea_len, distance_expansion_len, None, if_exp, if_edge_update, normalization, + atom_update_net, gauss_stop) + self.mp3 = MPLayer(in_atom_fea_len, distance_expansion_len, None, if_exp, if_edge_update, normalization, + atom_update_net, gauss_stop) + self.mp4 = MPLayer(in_atom_fea_len, distance_expansion_len, None, if_exp, if_edge_update, normalization, + atom_update_net, gauss_stop) + self.mp5 = MPLayer(in_atom_fea_len, distance_expansion_len, None, if_exp, if_edge_update, normalization, + atom_update_net, gauss_stop) + + if if_lcmp == True: + if self.if_MultipleLinear == True: + self.lcmp = LCMPLayer(in_atom_fea_len, in_edge_fea_len, 32, num_l, if_exp=if_exp) + self.multiple_linear1 = MultipleLinear(num_orbital, 32, 16) + self.multiple_linear2 = MultipleLinear(num_orbital, 16, 1) + else: + self.lcmp = LCMPLayer(in_atom_fea_len, in_edge_fea_len, num_orbital, num_l, if_exp=if_exp) + else: + self.mp_output = MPLayer(in_atom_fea_len, in_edge_fea_len, num_orbital, if_exp, if_edge_update=True, + normalization=normalization, atom_update_net=atom_update_net, + gauss_stop=gauss_stop, output_layer=True) + + + def forward(self, atom_attr, edge_idx, edge_attr, batch, + sub_atom_idx=None, sub_edge_idx=None, sub_edge_ang=None, sub_index=None, + huge_structure=False, output_final_layer_neuron=''): + batch_edge = batch[edge_idx[0]] + atom_fea0 = self.embed(atom_attr) + distance = edge_attr[:, 0] + edge_vec = edge_attr[:, 1:4] - edge_attr[:, 4:7] + if self.type_affine is None: + edge_fea0 = self.distance_expansion(distance) + else: + affine_coeff = self.type_affine(self.num_species * atom_attr[edge_idx[0]] + atom_attr[edge_idx[1]]) + edge_fea0 = self.distance_expansion(distance * affine_coeff[:, 0] + affine_coeff[:, 1]) + if self.atom_update_net == "PAINN": + atom_fea0 = PaninnNodeFea(atom_fea0) + + if self.if_edge_update == True: + atom_fea, edge_fea = self.mp1(atom_fea0, edge_idx, edge_fea0, batch, distance, edge_vec) + atom_fea, edge_fea = self.mp2(atom_fea, edge_idx, edge_fea, batch, distance, edge_vec) + atom_fea0, edge_fea0 = atom_fea0 + atom_fea, edge_fea0 + edge_fea + atom_fea, edge_fea = self.mp3(atom_fea0, edge_idx, edge_fea0, batch, distance, edge_vec) + atom_fea, edge_fea = self.mp4(atom_fea, edge_idx, edge_fea, batch, distance, edge_vec) + atom_fea0, edge_fea0 = atom_fea0 + atom_fea, edge_fea0 + edge_fea + atom_fea, edge_fea = self.mp5(atom_fea0, edge_idx, edge_fea0, batch, distance, edge_vec) + + if self.if_lcmp == True: + if self.atom_update_net == 'PAINN': + atom_fea_s = atom_fea.node_fea_s + else: + atom_fea_s = atom_fea + out = self.lcmp(atom_fea_s, edge_fea, sub_atom_idx, sub_edge_idx, sub_edge_ang, sub_index, distance, + huge_structure, output_final_layer_neuron) + else: + atom_fea, edge_fea = self.mp_output(atom_fea, edge_idx, edge_fea, batch, distance, edge_vec) + out = edge_fea + else: + atom_fea = self.mp1(atom_fea0, edge_idx, edge_fea0, batch, distance, edge_vec) + atom_fea = self.mp2(atom_fea, edge_idx, edge_fea0, batch, distance, edge_vec) + atom_fea0 = atom_fea0 + atom_fea + atom_fea = self.mp3(atom_fea0, edge_idx, edge_fea0, batch, distance, edge_vec) + atom_fea = self.mp4(atom_fea, edge_idx, edge_fea0, batch, distance, edge_vec) + atom_fea0 = atom_fea0 + atom_fea + atom_fea = self.mp5(atom_fea0, edge_idx, edge_fea0, batch, distance, edge_vec) + + if self.atom_update_net == 'PAINN': + atom_fea_s = atom_fea.node_fea_s + else: + atom_fea_s = atom_fea + if self.if_lcmp == True: + out = self.lcmp(atom_fea_s, edge_fea0, sub_atom_idx, sub_edge_idx, sub_edge_ang, sub_index, distance, + huge_structure, output_final_layer_neuron) + else: + atom_fea, edge_fea = self.mp_output(atom_fea, edge_idx, edge_fea0, batch, distance, edge_vec) + out = edge_fea + + if self.if_MultipleLinear == True: + out = self.multiple_linear1(F.silu(out), batch_edge) + out = self.multiple_linear2(F.silu(out), batch_edge) + out = out.T + + return out diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/__init__.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..46467f369e4bb9d6a43440871d924e32b1d84c15 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/__init__.py @@ -0,0 +1,4 @@ +from .openmx_parse import OijLoad, GetEEiEij, openmx_parse_overlap +from .get_rc import get_rc +from .abacus_get_data import abacus_parse +from .siesta_get_data import siesta_parse diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/__pycache__/__init__.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..eae50e6edc01ecc02d4e68ecfd398da0f79dd8dc Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/__pycache__/__init__.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/__pycache__/abacus_get_data.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/__pycache__/abacus_get_data.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..986338b0fa48e2393897d3f7257d730802ca138d Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/__pycache__/abacus_get_data.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/__pycache__/get_rc.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/__pycache__/get_rc.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d9bb08591b9b381d4ff3e2162dd053a92ee03def Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/__pycache__/get_rc.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/__pycache__/openmx_parse.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/__pycache__/openmx_parse.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a6d829c5ebb08e9c557d13558d94835d9637bd6e Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/__pycache__/openmx_parse.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/__pycache__/siesta_get_data.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/__pycache__/siesta_get_data.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4d7a8c3dbdd7ad2cfad7809cdf425e8bb11ef17c Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/__pycache__/siesta_get_data.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/abacus_get_data.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/abacus_get_data.py new file mode 100644 index 0000000000000000000000000000000000000000..ee5bc73bcfa68449f5e367bf6345e0b0007cadfd --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/abacus_get_data.py @@ -0,0 +1,340 @@ +# Script for interface from ABACUS (http://abacus.ustc.edu.cn/) to DeepH-pack +# Coded by ZC Tang @ Tsinghua Univ. e-mail: az_txycha@126.com +# Modified by He Li @ Tsinghua Univ. & XY Zhou @ Peking Univ. +# To use this script, please add 'out_mat_hs2 1' in ABACUS INPUT File +# Current version is capable of coping with f-orbitals +# 20220717: Read structure from running_scf.log +# 20220919: The suffix of the output sub-directories (OUT.suffix) can be set by ["basic"]["abacus_suffix"] keyword in preprocess.ini +# 20220920: Supporting cartesian coordinates in the log file +# 20231228: Supporting ABACUS v3.4 + +import os +import sys +import json +import re + +import numpy as np +from scipy.sparse import csr_matrix +from scipy.linalg import block_diag +import argparse +import h5py + + +Bohr2Ang = 0.529177249 +periodic_table = {'Ac': 89, 'Ag': 47, 'Al': 13, 'Am': 95, 'Ar': 18, 'As': 33, 'At': 85, 'Au': 79, 'B': 5, 'Ba': 56, + 'Be': 4, 'Bi': 83, 'Bk': 97, 'Br': 35, 'C': 6, 'Ca': 20, 'Cd': 48, 'Ce': 58, 'Cf': 98, 'Cl': 17, + 'Cm': 96, 'Co': 27, 'Cr': 24, 'Cs': 55, 'Cu': 29, 'Dy': 66, 'Er': 68, 'Es': 99, 'Eu': 63, 'F': 9, + 'Fe': 26, 'Fm': 100, 'Fr': 87, 'Ga': 31, 'Gd': 64, 'Ge': 32, 'H': 1, 'He': 2, 'Hf': 72, 'Hg': 80, + 'Ho': 67, 'I': 53, 'In': 49, 'Ir': 77, 'K': 19, 'Kr': 36, 'La': 57, 'Li': 3, 'Lr': 103, 'Lu': 71, + 'Md': 101, 'Mg': 12, 'Mn': 25, 'Mo': 42, 'N': 7, 'Na': 11, 'Nb': 41, 'Nd': 60, 'Ne': 10, 'Ni': 28, + 'No': 102, 'Np': 93, 'O': 8, 'Os': 76, 'P': 15, 'Pa': 91, 'Pb': 82, 'Pd': 46, 'Pm': 61, 'Po': 84, + 'Pr': 59, 'Pt': 78, 'Pu': 94, 'Ra': 88, 'Rb': 37, 'Re': 75, 'Rh': 45, 'Rn': 86, 'Ru': 44, 'S': 16, + 'Sb': 51, 'Sc': 21, 'Se': 34, 'Si': 14, 'Sm': 62, 'Sn': 50, 'Sr': 38, 'Ta': 73, 'Tb': 65, 'Tc': 43, + 'Te': 52, 'Th': 90, 'Ti': 22, 'Tl': 81, 'Tm': 69, 'U': 92, 'V': 23, 'W': 74, 'Xe': 54, 'Y': 39, + 'Yb': 70, 'Zn': 30, 'Zr': 40, 'Rf': 104, 'Db': 105, 'Sg': 106, 'Bh': 107, 'Hs': 108, 'Mt': 109, + 'Ds': 110, 'Rg': 111, 'Cn': 112, 'Nh': 113, 'Fl': 114, 'Mc': 115, 'Lv': 116, 'Ts': 117, 'Og': 118} + + +class OrbAbacus2DeepH: + def __init__(self): + self.Us_abacus2deeph = {} + self.Us_abacus2deeph[0] = np.eye(1) + self.Us_abacus2deeph[1] = np.eye(3)[[1, 2, 0]] + self.Us_abacus2deeph[2] = np.eye(5)[[0, 3, 4, 1, 2]] + self.Us_abacus2deeph[3] = np.eye(7)[[0, 1, 2, 3, 4, 5, 6]] + + minus_dict = { + 1: [0, 1], + 2: [3, 4], + 3: [1, 2, 5, 6], + } + for k, v in minus_dict.items(): + self.Us_abacus2deeph[k][v] *= -1 + + def get_U(self, l): + if l > 3: + raise NotImplementedError("Only support l = s, p, d, f") + return self.Us_abacus2deeph[l] + + def transform(self, mat, l_lefts, l_rights): + block_lefts = block_diag(*[self.get_U(l_left) for l_left in l_lefts]) + block_rights = block_diag(*[self.get_U(l_right) for l_right in l_rights]) + return block_lefts @ mat @ block_rights.T + +def abacus_parse(input_path, output_path, data_name, only_S=False, get_r=False): + input_path = os.path.abspath(input_path) + output_path = os.path.abspath(output_path) + os.makedirs(output_path, exist_ok=True) + + def find_target_line(f, target): + line = f.readline() + while line: + if target in line: + return line + line = f.readline() + return None + if only_S: + log_file_name = "running_get_S.log" + else: + log_file_name = "running_scf.log" + with open(os.path.join(input_path, data_name, log_file_name), 'r') as f: + f.readline() + line = f.readline() + # assert "WELCOME TO ABACUS" in line + assert find_target_line(f, "READING UNITCELL INFORMATION") is not None, 'Cannot find "READING UNITCELL INFORMATION" in log file' + num_atom_type = int(f.readline().split()[-1]) + + assert find_target_line(f, "lattice constant (Bohr)") is not None + lattice_constant = float(f.readline().split()[-1]) # unit is Angstrom + + site_norbits_dict = {} + orbital_types_dict = {} + for index_type in range(num_atom_type): + tmp = find_target_line(f, "READING ATOM TYPE") + assert tmp is not None, 'Cannot find "ATOM TYPE" in log file' + assert tmp.split()[-1] == str(index_type + 1) + if tmp is None: + raise Exception(f"Cannot find ATOM {index_type} in {log_file_name}") + + line = f.readline() + assert "atom label =" in line + atom_label = line.split()[-1] + assert atom_label in periodic_table, "Atom label should be in periodic table" + atom_type = periodic_table[atom_label] + + current_site_norbits = 0 + current_orbital_types = [] + while True: + line = f.readline() + if "number of zeta" in line: + tmp = line.split() + L = int(tmp[0][2:-1]) + num_L = int(tmp[-1]) + current_site_norbits += (2 * L + 1) * num_L + current_orbital_types.extend([L] * num_L) + else: + break + site_norbits_dict[atom_type] = current_site_norbits + orbital_types_dict[atom_type] = current_orbital_types + + line = find_target_line(f, "TOTAL ATOM NUMBER") + assert line is not None, 'Cannot find "TOTAL ATOM NUMBER" in log file' + nsites = int(line.split()[-1]) + + line = find_target_line(f, " COORDINATES") + assert line is not None, 'Cannot find "DIRECT COORDINATES" or "CARTESIAN COORDINATES" in log file' + if "DIRECT" in line: + coords_type = "direct" + elif "CARTESIAN" in line: + coords_type = "cartesian" + else: + raise ValueError('Cannot find "DIRECT COORDINATES" or "CARTESIAN COORDINATES" in log file') + + assert "atom" in f.readline() + frac_coords = np.zeros((nsites, 3)) + site_norbits = np.zeros(nsites, dtype=int) + element = np.zeros(nsites, dtype=int) + for index_site in range(nsites): + line = f.readline() + tmp = line.split() + assert "tau" in tmp[0] + atom_label = ''.join(re.findall(r'[A-Za-z]', tmp[0][5:])) + assert atom_label in periodic_table, "Atom label should be in periodic table" + element[index_site] = periodic_table[atom_label] + site_norbits[index_site] = site_norbits_dict[element[index_site]] + frac_coords[index_site, :] = np.array(tmp[1:4]) + norbits = int(np.sum(site_norbits)) + site_norbits_cumsum = np.cumsum(site_norbits) + + assert find_target_line(f, "Lattice vectors: (Cartesian coordinate: in unit of a_0)") is not None + lattice = np.zeros((3, 3)) + for index_lat in range(3): + lattice[index_lat, :] = np.array(f.readline().split()) + if coords_type == "cartesian": + frac_coords = frac_coords @ np.matrix(lattice).I + lattice = lattice * lattice_constant + if only_S: + spinful = False + else: + line = find_target_line(f, "NSPIN") + assert line is not None, 'Cannot find "NSPIN" in log file' + if "NSPIN == 1" in line: + spinful = False + elif "NSPIN == 4" in line: + spinful = True + else: + raise ValueError(f'{line} is not supported') + if only_S: + fermi_level = 0.0 + else: + with open(os.path.join(input_path, data_name, log_file_name), 'r') as f: + line = find_target_line(f, "EFERMI") + assert line is not None, 'Cannot find "EFERMI" in log file' + assert "eV" in line + fermi_level = float(line.split()[2]) + assert find_target_line(f, "EFERMI") is None, "There is more than one EFERMI in log file" + + np.savetxt(os.path.join(output_path, "lat.dat"), np.transpose(lattice)) + np.savetxt(os.path.join(output_path, "rlat.dat"), np.linalg.inv(lattice) * 2 * np.pi) + cart_coords = frac_coords @ lattice + np.savetxt(os.path.join(output_path, "site_positions.dat").format(output_path), np.transpose(cart_coords)) + np.savetxt(os.path.join(output_path, "element.dat"), element, fmt='%d') + info = {'nsites' : nsites, 'isorthogonal': False, 'isspinful': spinful, 'norbits': norbits, 'fermi_level': fermi_level} + with open('{}/info.json'.format(output_path), 'w') as info_f: + json.dump(info, info_f) + with open(os.path.join(output_path, "orbital_types.dat"), 'w') as f: + for atomic_number in element: + for index_l, l in enumerate(orbital_types_dict[atomic_number]): + if index_l == 0: + f.write(str(l)) + else: + f.write(f" {l}") + f.write('\n') + + U_orbital = OrbAbacus2DeepH() + def parse_matrix(matrix_path, factor, spinful=False): + matrix_dict = dict() + with open(matrix_path, 'r') as f: + line = f.readline() # read "Matrix Dimension of ..." + if not "Matrix Dimension of" in line: + line = f.readline() # ABACUS >= 3.0 + assert "Matrix Dimension of" in line + f.readline() # read "Matrix number of ..." + norbits = int(line.split()[-1]) + for line in f: + line1 = line.split() + if len(line1) == 0: + break + num_element = int(line1[3]) + if num_element != 0: + R_cur = np.array(line1[:3]).astype(int) + line2 = f.readline().split() + line3 = f.readline().split() + line4 = f.readline().split() + if not spinful: + hamiltonian_cur = csr_matrix((np.array(line2).astype(float), np.array(line3).astype(int), + np.array(line4).astype(int)), shape=(norbits, norbits)).toarray() + else: + line2 = np.char.replace(line2, '(', '') + line2 = np.char.replace(line2, ')', 'j') + line2 = np.char.replace(line2, ',', '+') + line2 = np.char.replace(line2, '+-', '-') + hamiltonian_cur = csr_matrix((np.array(line2).astype(np.complex128), np.array(line3).astype(int), + np.array(line4).astype(int)), shape=(norbits, norbits)).toarray() + for index_site_i in range(nsites): + for index_site_j in range(nsites): + key_str = f"[{R_cur[0]}, {R_cur[1]}, {R_cur[2]}, {index_site_i + 1}, {index_site_j + 1}]" + mat = hamiltonian_cur[(site_norbits_cumsum[index_site_i] + - site_norbits[index_site_i]) * (1 + spinful): + site_norbits_cumsum[index_site_i] * (1 + spinful), + (site_norbits_cumsum[index_site_j] - site_norbits[index_site_j]) * (1 + spinful): + site_norbits_cumsum[index_site_j] * (1 + spinful)] + if abs(mat).max() < 1e-8: + continue + if not spinful: + mat = U_orbital.transform(mat, orbital_types_dict[element[index_site_i]], + orbital_types_dict[element[index_site_j]]) + else: + mat = mat.reshape((site_norbits[index_site_i], 2, site_norbits[index_site_j], 2)) + mat = mat.transpose((1, 0, 3, 2)).reshape((2 * site_norbits[index_site_i], + 2 * site_norbits[index_site_j])) + mat = U_orbital.transform(mat, orbital_types_dict[element[index_site_i]] * 2, + orbital_types_dict[element[index_site_j]] * 2) + matrix_dict[key_str] = mat * factor + return matrix_dict, norbits + + if only_S: + overlap_dict, tmp = parse_matrix(os.path.join(input_path, "SR.csr"), 1) + assert tmp == norbits + else: + hamiltonian_dict, tmp = parse_matrix( + os.path.join(input_path, data_name, "data-HR-sparse_SPIN0.csr"), 13.605698, # Ryd2eV + spinful=spinful) + assert tmp == norbits * (1 + spinful) + overlap_dict, tmp = parse_matrix(os.path.join(input_path, data_name, "data-SR-sparse_SPIN0.csr"), 1, + spinful=spinful) + assert tmp == norbits * (1 + spinful) + if spinful: + overlap_dict_spinless = {} + for k, v in overlap_dict.items(): + overlap_dict_spinless[k] = v[:v.shape[0] // 2, :v.shape[1] // 2].real + overlap_dict_spinless, overlap_dict = overlap_dict, overlap_dict_spinless + + if not only_S: + with h5py.File(os.path.join(output_path, "hamiltonians.h5"), 'w') as fid: + for key_str, value in hamiltonian_dict.items(): + fid[key_str] = value + with h5py.File(os.path.join(output_path, "overlaps.h5"), 'w') as fid: + for key_str, value in overlap_dict.items(): + fid[key_str] = value + if get_r: + def parse_r_matrix(matrix_path, factor): + matrix_dict = dict() + with open(matrix_path, 'r') as f: + line = f.readline(); + norbits = int(line.split()[-1]) + for line in f: + line1 = line.split() + if len(line1) == 0: + break + assert len(line1) > 3 + R_cur = np.array(line1[:3]).astype(int) + mat_cur = np.zeros((3, norbits * norbits)) + for line_index in range(norbits * norbits): + line_mat = f.readline().split() + assert len(line_mat) == 3 + mat_cur[:, line_index] = np.array(line_mat) + mat_cur = mat_cur.reshape((3, norbits, norbits)) + + for index_site_i in range(nsites): + for index_site_j in range(nsites): + for direction in range(3): + key_str = f"[{R_cur[0]}, {R_cur[1]}, {R_cur[2]}, {index_site_i + 1}, {index_site_j + 1}, {direction + 1}]" + mat = mat_cur[direction, site_norbits_cumsum[index_site_i] + - site_norbits[index_site_i]:site_norbits_cumsum[index_site_i], + site_norbits_cumsum[index_site_j] + - site_norbits[index_site_j]:site_norbits_cumsum[index_site_j]] + if abs(mat).max() < 1e-8: + continue + mat = U_orbital.transform(mat, orbital_types_dict[element[index_site_i]], + orbital_types_dict[element[index_site_j]]) + matrix_dict[key_str] = mat * factor + return matrix_dict, norbits + position_dict, tmp = parse_r_matrix(os.path.join(input_path, data_name, "data-rR-tr_SPIN1"), 0.529177249) # Bohr2Ang + assert tmp == norbits + + with h5py.File(os.path.join(output_path, "positions.h5"), 'w') as fid: + for key_str, value in position_dict.items(): + fid[key_str] = value + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Predict Hamiltonian') + parser.add_argument( + '-i','--input_dir', type=str, default='./', + help='path of output subdirectory' + ) + parser.add_argument( + '-o','--output_dir', type=str, default='./', + help='path of output .h5 and .dat' + ) + parser.add_argument( + '-a','--abacus_suffix', type=str, default='ABACUS', + help='suffix of output subdirectory' + ) + parser.add_argument( + '-S','--only_S', type=int, default=0 + ) + parser.add_argument( + '-g','--get_r', type=int, default=0 + ) + args = parser.parse_args() + + input_path = args.input_dir + output_path = args.output_dir + data_name = "OUT." + args.abacus_suffix + only_S = bool(args.only_S) + get_r = bool(args.get_r) + print("only_S: {}".format(only_S)) + print("get_r: {}".format(get_r)) + abacus_parse(input_path, output_path, data_name, only_S, get_r) diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/aims_get_data.jl b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/aims_get_data.jl new file mode 100644 index 0000000000000000000000000000000000000000..0b041a28f5ed60ff3b06b4ba325668a5b53d3380 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/aims_get_data.jl @@ -0,0 +1,477 @@ +using JSON +using HDF5 +using LinearAlgebra +using DelimitedFiles +using StaticArrays +using ArgParse + +function parse_commandline() + s = ArgParseSettings() + @add_arg_table! s begin + "--input_dir", "-i" + help = "NoTB.dat, basis-indices.out, geometry.in" + arg_type = String + default = "./" + "--output_dir", "-o" + help = "" + arg_type = String + default = "./output" + "--save_overlap", "-s" + help = "" + arg_type = Bool + default = false + "--save_position", "-p" + help = "" + arg_type = Bool + default = false + end + return parse_args(s) +end +parsed_args = parse_commandline() + +input_dir = abspath(parsed_args["input_dir"]) +output_dir = abspath(parsed_args["output_dir"]) + +@assert isfile(joinpath(input_dir, "NoTB.dat")) +@assert isfile(joinpath(input_dir, "basis-indices.out")) +@assert isfile(joinpath(input_dir, "geometry.in")) + +# @info string("get data from: ", input_dir) +periodic_table = JSON.parsefile(joinpath(@__DIR__, "periodic_table.json")) +mkpath(output_dir) + +# The function parse_openmx below is come from "https://github.com/HopTB/HopTB.jl" +f = open(joinpath(input_dir, "NoTB.dat")) +# number of basis +@assert occursin("n_basis", readline(f)) # start +norbits = parse(Int64, readline(f)) +@assert occursin("end", readline(f)) # end +@assert occursin("n_ham", readline(f)) # start +nhams = parse(Int64, readline(f)) +@assert occursin("end", readline(f)) # end +@assert occursin("n_cell", readline(f)) # start +ncells = parse(Int64, readline(f)) +@assert occursin("end", readline(f)) # end +# lattice vector +@assert occursin("lattice_vector", readline(f)) # start +lat = Matrix{Float64}(I, 3, 3) +for i in 1:3 + lat[:, i] = map(x->parse(Float64, x), split(readline(f))) +end +@assert occursin("end", readline(f)) # end +# hamiltonian +@assert occursin("hamiltonian", readline(f)) # start +hamiltonian = zeros(nhams) +i = 1 +while true + global i + @assert !eof(f) + ln = split(readline(f)) + if occursin("end", ln[1]) break end + hamiltonian[i:i + length(ln) - 1] = map(x->parse(Float64, x), ln) + i += length(ln) +end +# overlaps +@assert occursin("overlap", readline(f)) # start +overlaps = zeros(nhams) +i = 1 +while true + global i + @assert !eof(f) + ln = split(readline(f)) + if occursin("end", ln[1]) break end + overlaps[i:i + length(ln) - 1] = map(x->parse(Float64, x), ln) + i += length(ln) +end +# index hamiltonian +@assert occursin("index_hamiltonian", readline(f)) # start +indexhamiltonian = zeros(Int64, ncells * norbits, 4) +i = 1 +while true + global i + @assert !eof(f) + ln = split(readline(f)) + if occursin("end", ln[1]) break end + indexhamiltonian[i, :] = map(x->parse(Int64, x), ln) + i += 1 +end +# cell index +@assert occursin("cell_index", readline(f)) # start +cellindex = zeros(Int64, ncells, 3) +i = 1 +while true + global i + @assert !eof(f) + ln = split(readline(f)) + if occursin("end", ln[1]) break end + if i <= ncells + cellindex[i, :] = map(x->parse(Int64, x), ln) + end + i += 1 +end +# column index hamiltonian +@assert occursin("column_index_hamiltonian", readline(f)) # start +columnindexhamiltonian = zeros(Int64, nhams) +i = 1 +while true + global i + @assert !eof(f) + ln = split(readline(f)) + if occursin("end", ln[1]) break end + columnindexhamiltonian[i:i + length(ln) - 1] = map(x->parse(Int64, x), ln) + i += length(ln) +end +# positions +positions = zeros(nhams, 3) +for dir in 1:3 + positionsdir = zeros(nhams) + @assert occursin("position", readline(f)) # start + readline(f) # skip direction + i = 1 + while true + @assert !eof(f) + ln = split(readline(f)) + if occursin("end", ln[1]) break end + positionsdir[i:i + length(ln) - 1] = map(x->parse(Float64, x), ln) + i += length(ln) + end + positions[:, dir] = positionsdir +end +if !eof(f) + spinful = true + soc_matrix = zeros(nhams, 3) + for dir in 1:3 + socdir = zeros(nhams) + @assert occursin("soc_matrix", readline(f)) # start + readline(f) # skip direction + i = 1 + while true + @assert !eof(f) + ln = split(readline(f)) + if occursin("end", ln[1]) break end + socdir[i:i + length(ln) - 1] = map(x->parse(Float64, x), ln) + i += length(ln) + end + soc_matrix[:, dir] = socdir + end +else + spinful = false +end +close(f) + +orbital_types = Array{Array{Int64,1},1}(undef, 0) +basis_dir = joinpath(input_dir, "basis-indices.out") +@assert ispath(basis_dir) +f = open(basis_dir) +readline(f) +@assert split(readline(f))[1] == "fn." +basis_indices = zeros(Int64, norbits, 4) +for index_orbit in 1:norbits + line = map(x->parse(Int64, x), split(readline(f))[[1, 3, 4, 5, 6]]) + @assert line[1] == index_orbit + basis_indices[index_orbit, :] = line[2:5] + # basis_indices: 1 ia, 2 n, 3 l, 4 m + if size(orbital_types, 1) < line[2] + orbital_type = Array{Int64,1}(undef, 0) + push!(orbital_types, orbital_type) + end + if line[4] == line[5] + push!(orbital_types[line[2]], line[4]) + end +end +nsites = size(orbital_types, 1) +site_norbits = (x->sum(x .* 2 .+ 1)).(orbital_types) * (1 + spinful) +@assert norbits == sum(site_norbits) +site_norbits_cumsum = cumsum(site_norbits) +site_indices = zeros(Int64, norbits) +for index_site in 1:nsites + if index_site == 1 + site_indices[1:site_norbits_cumsum[index_site]] .= index_site + else + site_indices[site_norbits_cumsum[index_site - 1] + 1:site_norbits_cumsum[index_site]] .= index_site + end +end +close(f) + +f = open(joinpath(input_dir, "geometry.in")) +# atom_frac_pos = zeros(Float64, 3, nsites) +element = Array{Int64,1}(undef, 0) +index_atom = 0 +while !eof(f) + line = split(readline(f)) + if size(line, 1) > 0 && line[1] == "atom_frac" + global index_atom + index_atom += 1 + # atom_frac_pos[:, index_atom] = map(x->parse(Float64, x), line[[2, 3, 4]]) + push!(element, periodic_table[line[5]]["Atomic no"]) + end +end +@assert index_atom == nsites +# site_positions = lat * atom_frac_pos +close(f) + +@info string("spinful: ", spinful) +# write to file +site_positions = fill(NaN, (3, nsites)) +overlaps_dict = Dict{Array{Int64, 1}, Array{Float64, 2}}() +positions_dict = Dict{Array{Int64, 1}, Array{Float64, 2}}() +R_list = Set{Vector{Int64}}() +if spinful + hamiltonians_dict = Dict{Array{Int64, 1}, Array{Complex{Float64}, 2}}() + @error "spinful not implemented yet" + σx = [0 1; 1 0] + σy = [0 -im; im 0] + σz = [1 0; 0 -1] + σ0 = [1 0; 0 1] + nm = TBModel{ComplexF64}(2*norbits, lat, isorthogonal=false) + # convention here is first half up (spin=0); second half down (spin=1). + for i in 1:size(indexhamiltonian, 1) + for j in indexhamiltonian[i, 3]:indexhamiltonian[i, 4] + for nspin in 0:1 + for mspin in 0:1 + sethopping!(nm, + cellindex[indexhamiltonian[i, 1], :], + columnindexhamiltonian[j] + norbits * nspin, + indexhamiltonian[i, 2] + norbits * mspin, + σ0[nspin + 1, mspin + 1] * hamiltonian[j] - + (σx[nspin + 1, mspin + 1] * soc_matrix[j, 1] + + σy[nspin + 1, mspin + 1] * soc_matrix[j, 2] + + σz[nspin + 1, mspin + 1] * soc_matrix[j, 3]) * im) + setoverlap!(nm, + cellindex[indexhamiltonian[i, 1], :], + columnindexhamiltonian[j] + norbits * nspin, + indexhamiltonian[i, 2] + norbits * mspin, + σ0[nspin + 1, mspin + 1] * overlaps[j]) + end + end + end + end + for i in 1:size(indexhamiltonian, 1) + for j in indexhamiltonian[i, 3]:indexhamiltonian[i, 4] + for nspin in 0:1 + for mspin in 0:1 + for dir in 1:3 + setposition!(nm, + cellindex[indexhamiltonian[i, 1], :], + columnindexhamiltonian[j] + norbits * nspin, + indexhamiltonian[i, 2] + norbits * mspin, + dir, + σ0[nspin + 1, mspin + 1] * positions[j, dir]) + end + end + end + end + end + return nm +else + hamiltonians_dict = Dict{Array{Int64, 1}, Array{Float64, 2}}() + + for i in 1:size(indexhamiltonian, 1) + for j in indexhamiltonian[i, 3]:indexhamiltonian[i, 4] + R = cellindex[indexhamiltonian[i, 1], :] + push!(R_list, SVector{3, Int64}(R)) + orbital_i_whole = columnindexhamiltonian[j] + orbital_j_whole = indexhamiltonian[i, 2] + site_i = site_indices[orbital_i_whole] + site_j = site_indices[orbital_j_whole] + block_matrix_i = orbital_i_whole - site_norbits_cumsum[site_i] + site_norbits[site_i] + block_matrix_j = orbital_j_whole - site_norbits_cumsum[site_j] + site_norbits[site_j] + key = cat(dims=1, R, site_i, site_j) + key_inv = cat(dims=1, -R, site_j, site_i) + + mi = 0 + mj = 0 + # p-orbital + if basis_indices[orbital_i_whole, 3] == 1 + if basis_indices[orbital_i_whole, 4] == -1 + block_matrix_i += 1 + mi = 0 + elseif basis_indices[orbital_i_whole, 4] == 0 + block_matrix_i += 1 + mi = 0 + elseif basis_indices[orbital_i_whole, 4] == 1 + block_matrix_i += -2 + mi = 1 + end + end + if basis_indices[orbital_j_whole, 3] == 1 + if basis_indices[orbital_j_whole, 4] == -1 + block_matrix_j += 1 + mj = 0 + elseif basis_indices[orbital_j_whole, 4] == 0 + block_matrix_j += 1 + mj = 0 + elseif basis_indices[orbital_j_whole, 4] == 1 + block_matrix_j += -2 + mj = 1 + end + end + # d-orbital + if basis_indices[orbital_i_whole, 3] == 2 + if basis_indices[orbital_i_whole, 4] == -2 + block_matrix_i += 2 + mi = 0 + elseif basis_indices[orbital_i_whole, 4] == -1 + block_matrix_i += 3 + mi = 0 + elseif basis_indices[orbital_i_whole, 4] == 0 + block_matrix_i += -2 + mi = 0 + elseif basis_indices[orbital_i_whole, 4] == 1 + block_matrix_i += 0 + mi = 1 + elseif basis_indices[orbital_i_whole, 4] == 2 + block_matrix_i += -3 + mi = 0 + end + end + if basis_indices[orbital_j_whole, 3] == 2 + if basis_indices[orbital_j_whole, 4] == -2 + block_matrix_j += 2 + mj = 0 + elseif basis_indices[orbital_j_whole, 4] == -1 + block_matrix_j += 3 + mj = 0 + elseif basis_indices[orbital_j_whole, 4] == 0 + block_matrix_j += -2 + mj = 0 + elseif basis_indices[orbital_j_whole, 4] == 1 + block_matrix_j += 0 + mj = 1 + elseif basis_indices[orbital_j_whole, 4] == 2 + block_matrix_j += -3 + mj = 0 + end + end + # f-orbital + if basis_indices[orbital_i_whole, 3] == 3 + if basis_indices[orbital_i_whole, 4] == -3 + block_matrix_i += 6 + mi = 0 + elseif basis_indices[orbital_i_whole, 4] == -2 + block_matrix_i += 3 + mi = 0 + elseif basis_indices[orbital_i_whole, 4] == -1 + block_matrix_i += 0 + mi = 0 + elseif basis_indices[orbital_i_whole, 4] == 0 + block_matrix_i += -3 + mi = 0 + elseif basis_indices[orbital_i_whole, 4] == 1 + block_matrix_i += -3 + mi = 1 + elseif basis_indices[orbital_i_whole, 4] == 2 + block_matrix_i += -2 + mi = 0 + elseif basis_indices[orbital_i_whole, 4] == 3 + block_matrix_i += -1 + mi = 1 + end + end + if basis_indices[orbital_j_whole, 3] == 3 + if basis_indices[orbital_j_whole, 4] == -3 + block_matrix_j += 6 + mj = 0 + elseif basis_indices[orbital_j_whole, 4] == -2 + block_matrix_j += 3 + mj = 0 + elseif basis_indices[orbital_j_whole, 4] == -1 + block_matrix_j += 0 + mj = 0 + elseif basis_indices[orbital_j_whole, 4] == 0 + block_matrix_j += -3 + mj = 0 + elseif basis_indices[orbital_j_whole, 4] == 1 + block_matrix_j += -3 + mj = 1 + elseif basis_indices[orbital_j_whole, 4] == 2 + block_matrix_j += -2 + mj = 0 + elseif basis_indices[orbital_j_whole, 4] == 3 + block_matrix_j += -1 + mj = 1 + end + end + if (basis_indices[orbital_i_whole, 3] > 3) || (basis_indices[orbital_j_whole, 3] > 3) + @error("The case of l>3 is not implemented") + end + + if !(key ∈ keys(hamiltonians_dict)) + # overlaps_dict[key] = fill(convert(Float64, NaN), (site_norbits[site_i], site_norbits[site_j])) + overlaps_dict[key] = zeros(Float64, site_norbits[site_i], site_norbits[site_j]) + hamiltonians_dict[key] = zeros(Float64, site_norbits[site_i], site_norbits[site_j]) + for direction in 1:3 + positions_dict[cat(dims=1, key, direction)] = zeros(Float64, site_norbits[site_i], site_norbits[site_j]) + end + end + if !(key_inv ∈ keys(hamiltonians_dict)) + overlaps_dict[key_inv] = zeros(Float64, site_norbits[site_j], site_norbits[site_i]) + hamiltonians_dict[key_inv] = zeros(Float64, site_norbits[site_j], site_norbits[site_i]) + for direction in 1:3 + positions_dict[cat(dims=1, key_inv, direction)] = zeros(Float64, site_norbits[site_j], site_norbits[site_i]) + end + end + overlaps_dict[key][block_matrix_i, block_matrix_j] = overlaps[j] * (-1) ^ (mi + mj) + hamiltonians_dict[key][block_matrix_i, block_matrix_j] = hamiltonian[j] * (-1) ^ (mi + mj) + for direction in 1:3 + positions_dict[cat(dims=1, key, direction)][block_matrix_i, block_matrix_j] = positions[j, direction] * (-1) ^ (mi + mj) + end + + overlaps_dict[key_inv][block_matrix_j, block_matrix_i] = overlaps[j] * (-1) ^ (mi + mj) + hamiltonians_dict[key_inv][block_matrix_j, block_matrix_i] = hamiltonian[j] * (-1) ^ (mi + mj) + for direction in 1:3 + positions_dict[cat(dims=1, key_inv, direction)][block_matrix_j, block_matrix_i] = positions[j, direction] * (-1) ^ (mi + mj) + if (R == [0, 0, 0]) && (block_matrix_i == block_matrix_j) && isnan(site_positions[direction, site_i]) + site_positions[direction, site_i] = positions[j, direction] + end + end + end + end +end + +if parsed_args["save_overlap"] + h5open(joinpath(output_dir, "overlaps.h5"), "w") do fid + for (key, overlap) in overlaps_dict + write(fid, string(key), permutedims(overlap)) + end + end +end +h5open(joinpath(output_dir, "hamiltonians.h5"), "w") do fid + for (key, hamiltonian) in hamiltonians_dict + write(fid, string(key), permutedims(hamiltonian)) # npz似乎为julia专门做了个转置而h5没有做 + end +end +if parsed_args["save_position"] + h5open(joinpath(output_dir, "positions.h5"), "w") do fid + for (key, position) in positions_dict + write(fid, string(key), permutedims(position)) # npz似乎为julia专门做了个转置而h5没有做 + end + end +end + +open(joinpath(output_dir, "orbital_types.dat"), "w") do f + writedlm(f, orbital_types) +end +open(joinpath(output_dir, "lat.dat"), "w") do f + writedlm(f, lat) +end +rlat = 2pi * inv(lat)' +open(joinpath(output_dir, "rlat.dat"), "w") do f + writedlm(f, rlat) +end +open(joinpath(output_dir, "site_positions.dat"), "w") do f + writedlm(f, site_positions) +end +R_list = collect(R_list) +open(joinpath(output_dir, "R_list.dat"), "w") do f + writedlm(f, R_list) +end +info_dict = Dict( + "isspinful" => spinful + ) +open(joinpath(output_dir, "info.json"), "w") do f + write(f, json(info_dict, 4)) +end +open(joinpath(output_dir, "element.dat"), "w") do f + writedlm(f, element) +end diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/get_rc.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/get_rc.py new file mode 100644 index 0000000000000000000000000000000000000000..70414629f6a04cee25081a124ce26ea1f0c80143 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/get_rc.py @@ -0,0 +1,165 @@ +import os +import json + +import h5py +import numpy as np +import torch + + +class Neighbours: + def __init__(self): + self.Rs = [] + self.dists = [] + self.eijs = [] + self.indices = [] + + def __str__(self): + return 'Rs: {}\ndists: {}\neijs: {}\nindices: {}'.format( + self.Rs, self.dists, self.indices, self.eijs) + + +def _get_local_coordinate(eij, neighbours_i, gen_rc_idx=False, atom_j=None, atom_j_R=None, r2_rand=False): + if gen_rc_idx: + rc_idx = np.full(8, np.nan, dtype=np.int32) + assert r2_rand is False + assert atom_j is not None, 'atom_j must be specified when gen_rc_idx is True' + assert atom_j_R is not None, 'atom_j_R must be specified when gen_rc_idx is True' + else: + rc_idx = None + if r2_rand: + r2_list = [] + + if not np.allclose(eij.detach(), torch.zeros_like(eij)): + r1 = eij + if gen_rc_idx: + rc_idx[0] = atom_j + rc_idx[1:4] = atom_j_R + else: + r1 = neighbours_i.eijs[1] + if gen_rc_idx: + rc_idx[0] = neighbours_i.indices[1] + rc_idx[1:4] = neighbours_i.Rs[1] + r2_flag = None + for r2, r2_index, r2_R in zip(neighbours_i.eijs[1:], neighbours_i.indices[1:], neighbours_i.Rs[1:]): + if torch.norm(torch.cross(r1, r2)) > 1e-6: + if gen_rc_idx: + rc_idx[4] = r2_index + rc_idx[5:8] = r2_R + r2_flag = True + if r2_rand: + if (len(r2_list) == 0) or (torch.norm(r2_list[0]) + 0.5 > torch.norm(r2)): + r2_list.append(r2) + else: + break + else: + break + assert r2_flag is not None, "There is no linear independent chemical bond in the Rcut range, this may be caused by a too small Rcut or the structure is 1D" + if r2_rand: + # print(f"r2 is randomly chosen from {len(r2_list)} candidates") + r2 = r2_list[np.random.randint(len(r2_list))] + local_coordinate_1 = r1 / torch.norm(r1) + local_coordinate_2 = torch.cross(r1, r2) / torch.norm(torch.cross(r1, r2)) + local_coordinate_3 = torch.cross(local_coordinate_1, local_coordinate_2) + return torch.stack([local_coordinate_1, local_coordinate_2, local_coordinate_3], dim=-1), rc_idx + + +def get_rc(input_dir, output_dir, radius, r2_rand=False, gen_rc_idx=False, gen_rc_by_idx="", create_from_DFT=True, neighbour_file='overlaps.h5', if_require_grad=False, cart_coords=None): + if not if_require_grad: + assert os.path.exists(os.path.join(input_dir, 'site_positions.dat')), 'No site_positions.dat found in {}'.format(input_dir) + cart_coords = torch.tensor(np.loadtxt(os.path.join(input_dir, 'site_positions.dat')).T) + else: + assert cart_coords is not None, 'cart_coords must be provided if "if_require_grad" is True' + assert os.path.exists(os.path.join(input_dir, 'lat.dat')), 'No lat.dat found in {}'.format(input_dir) + lattice = torch.tensor(np.loadtxt(os.path.join(input_dir, 'lat.dat')).T, dtype=cart_coords.dtype) + + rc_dict = {} + if gen_rc_idx: + assert r2_rand is False, 'r2_rand must be False when gen_rc_idx is True' + assert gen_rc_by_idx == "", 'gen_rc_by_idx must be "" when gen_rc_idx is True' + rc_idx_dict = {} + neighbours_dict = {} + if gen_rc_by_idx != "": + # print(f'get local coordinate using {os.path.join(gen_rc_by_idx, "rc_idx.h5")} from: {input_dir}') + assert os.path.exists(os.path.join(gen_rc_by_idx, "rc_idx.h5")), 'Atomic indices for constructing rc rc_idx.h5 is not found in {}'.format(gen_rc_by_idx) + fid_rc_idx = h5py.File(os.path.join(gen_rc_by_idx, "rc_idx.h5"), 'r') + for key_str, rc_idx in fid_rc_idx.items(): + key = json.loads(key_str) + # R = torch.tensor([key[0], key[1], key[2]]) + atom_i = key[3] - 1 + cart_coords_i = cart_coords[atom_i] + + r1 = cart_coords[rc_idx[0]] + torch.tensor(rc_idx[1:4]).type(cart_coords.dtype) @ lattice - cart_coords_i + r2 = cart_coords[rc_idx[4]] + torch.tensor(rc_idx[5:8]).type(cart_coords.dtype) @ lattice - cart_coords_i + local_coordinate_1 = r1 / torch.norm(r1) + local_coordinate_2 = torch.cross(r1, r2) / torch.norm(torch.cross(r1, r2)) + local_coordinate_3 = torch.cross(local_coordinate_1, local_coordinate_2) + + rc_dict[key_str] = torch.stack([local_coordinate_1, local_coordinate_2, local_coordinate_3], dim=-1) + fid_rc_idx.close() + else: + # print("get local coordinate from:", input_dir) + if create_from_DFT: + assert os.path.exists(os.path.join(input_dir, neighbour_file)), 'No {} found in {}'.format(neighbour_file, input_dir) + fid_OLP = h5py.File(os.path.join(input_dir, neighbour_file), 'r') + for key_str in fid_OLP.keys(): + key = json.loads(key_str) + R = torch.tensor([key[0], key[1], key[2]]) + atom_i = key[3] - 1 + atom_j = key[4] - 1 + cart_coords_i = cart_coords[atom_i] + cart_coords_j = cart_coords[atom_j] + R.type(cart_coords.dtype) @ lattice + eij = cart_coords_j - cart_coords_i + dist = torch.norm(eij) + if radius > 0 and dist > radius: + continue + if atom_i not in neighbours_dict: + neighbours_dict[atom_i] = Neighbours() + neighbours_dict[atom_i].Rs.append(R) + neighbours_dict[atom_i].dists.append(dist) + neighbours_dict[atom_i].eijs.append(eij) + neighbours_dict[atom_i].indices.append(atom_j) + + for atom_i, neighbours_i in neighbours_dict.items(): + neighbours_i.Rs = torch.stack(neighbours_i.Rs) + neighbours_i.dists = torch.tensor(neighbours_i.dists, dtype=cart_coords.dtype) + neighbours_i.eijs = torch.stack(neighbours_i.eijs) + neighbours_i.indices = torch.tensor(neighbours_i.indices) + + neighbours_i.dists, sorted_index = torch.sort(neighbours_i.dists) + neighbours_i.Rs = neighbours_i.Rs[sorted_index] + neighbours_i.eijs = neighbours_i.eijs[sorted_index] + neighbours_i.indices = neighbours_i.indices[sorted_index] + + assert np.allclose(neighbours_i.eijs[0].detach(), torch.zeros_like(neighbours_i.eijs[0])), 'eijs[0] should be zero' + + for R, eij, atom_j, atom_j_R in zip(neighbours_i.Rs, neighbours_i.eijs, neighbours_i.indices, neighbours_i.Rs): + key_str = str(list([*R.tolist(), atom_i + 1, atom_j.item() + 1])) + if gen_rc_idx: + rc_dict[key_str], rc_idx_dict[key_str] = _get_local_coordinate(eij, neighbours_i, gen_rc_idx, atom_j, atom_j_R) + else: + rc_dict[key_str] = _get_local_coordinate(eij, neighbours_i, r2_rand=r2_rand)[0] + else: + raise NotImplementedError + + if create_from_DFT: + fid_OLP.close() + + if if_require_grad: + return rc_dict + else: + if os.path.exists(os.path.join(output_dir, 'rc_julia.h5')): + rc_old_flag = True + fid_rc_old = h5py.File(os.path.join(output_dir, 'rc_julia.h5'), 'r') + else: + rc_old_flag = False + fid_rc = h5py.File(os.path.join(output_dir, 'rc.h5'), 'w') + for k, v in rc_dict.items(): + if rc_old_flag: + assert np.allclose(v, fid_rc_old[k][...], atol=1e-4), f"{k}, {v}, {fid_rc_old[k][...]}" + fid_rc[k] = v + fid_rc.close() + if gen_rc_idx: + fid_rc_idx = h5py.File(os.path.join(output_dir, 'rc_idx.h5'), 'w') + for k, v in rc_idx_dict.items(): + fid_rc_idx[k] = v + fid_rc_idx.close() diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/openmx_get_data.jl b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/openmx_get_data.jl new file mode 100644 index 0000000000000000000000000000000000000000..da6f4b53a45f0f17a8c895ccda35175a87dc0317 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/openmx_get_data.jl @@ -0,0 +1,471 @@ +using StaticArrays +using LinearAlgebra +using HDF5 +using JSON +using DelimitedFiles +using Statistics +using ArgParse + +function parse_commandline() + s = ArgParseSettings() + @add_arg_table! s begin + "--input_dir", "-i" + help = "" + arg_type = String + default = "./" + "--output_dir", "-o" + help = "" + arg_type = String + default = "./output" + "--if_DM", "-d" + help = "" + arg_type = Bool + default = false + "--save_overlap", "-s" + help = "" + arg_type = Bool + default = false + end + return parse_args(s) +end +parsed_args = parse_commandline() + +# @info string("get data from: ", parsed_args["input_dir"]) +periodic_table = JSON.parsefile(joinpath(@__DIR__, "periodic_table.json")) + +#= +struct Site_list + R::Array{StaticArrays.SArray{Tuple{3},Int16,1,3},1} + site::Array{Int64,1} + pos::Array{Float64,2} +end + +function _cal_neighbour_site(e_ij::Array{Float64,2},Rcut::Float64) + r_ij = sum(dims=1,e_ij.^2)[1,:] + p = sortperm(r_ij) + j_cut = searchsorted(r_ij[p],Rcut^2).stop + return p[1:j_cut] +end + +function cal_neighbour_site(site_positions::Matrix{<:Real}, lat::Matrix{<:Real}, R_list::Union{Vector{SVector{3, Int64}}, Vector{Vector{Int64}}}, nsites::Int64, Rcut::Float64) + # writed by lihe + neighbour_site = Array{Site_list,1}([]) + # R_list = collect(keys(tm.hoppings)) + pos_R_list = map(R -> collect(lat * R), R_list) + pos_j_list = cat(dims=2, map(pos_R -> pos_R .+ site_positions, pos_R_list)...) + for site_i in 1:nsites + pos_i = site_positions[:, site_i] + e_ij = pos_j_list .- pos_i + p = _cal_neighbour_site(e_ij, Rcut) + R_ordered = R_list[map(x -> div(x + (nsites - 1), nsites),p)] + site_ordered = map(x -> mod(x - 1, nsites) + 1,p) + pos_ordered = e_ij[:,p] + @assert pos_ordered[:,1] ≈ [0,0,0] + push!(neighbour_site, Site_list(R_ordered, site_ordered, pos_ordered)) + end + return neighbour_site +end + +function _get_local_coordinate(e_ij::Array{Float64,1},site_list_i::Site_list) + if e_ij != [0,0,0] + r1 = e_ij + else + r1 = site_list_i.pos[:,2] + end + nsites_i = length(site_list_i.R) + r2 = [0,0,0] + for j in 1:nsites_i + r2 = site_list_i.pos[:,j] + if norm(cross(r1,r2)) != 0 + break + end + if j == nsites_i + for k in 1:3 + r2 = [[1,0,0],[0,1,0],[0,0,1]][k] + if norm(cross(r1,r2)) != 0 + break + end + end + end + end + if r2 == [0,0,0] + error("there is no linear independent chemical bond in the Rcut range, this may be caused by a too small Rcut or the structure is1D") + end + local_coordinate = zeros(Float64,(3,3)) + local_coordinate[:,1] = r1/norm(r1) + + local_coordinate[:,2] = cross(r1,r2)/norm(cross(r1,r2)) + local_coordinate[:,3] = cross(local_coordinate[:,1],local_coordinate[:,2]) + return local_coordinate +end + +function get_local_coordinates(site_positions::Matrix{<:Real}, lat::Matrix{<:Real}, R_list::Vector{SVector{3, Int64}}, Rcut::Float64)::Dict{Array{Int64,1},Array{Float64,2}} + nsites = size(site_positions, 2) + neighbour_site = cal_neighbour_site(site_positions, lat, R_list, nsites, Rcut) + local_coordinates = Dict{Array{Int64,1},Array{Float64,2}}() + for site_i = 1:nsites + site_list_i = neighbour_site[site_i] + nsites_i = length(site_list_i.R) + for j = 1:nsites_i + R = site_list_i.R[j]; site_j = site_list_i.site[j]; e_ij = site_list_i.pos[:,j] + local_coordinate = _get_local_coordinate(e_ij, site_list_i) + local_coordinates[cat(dims=1, R, site_i, site_j)] = local_coordinate + end + end + return local_coordinates +end +=# + +# The function parse_openmx below is come from "https://github.com/HopTB/HopTB.jl" +function parse_openmx(filepath::String; return_DM::Bool = false) + # define some helper functions for mixed structure of OpenMX binary data file. + function multiread(::Type{T}, f, size)::Vector{T} where T + ret = Vector{T}(undef, size) + read!(f, ret);ret + end + multiread(f, size) = multiread(Int32, f, size) + + function read_mixed_matrix(::Type{T}, f, dims::Vector{<:Integer}) where T + ret::Vector{Vector{T}} = [] + for i = dims; t = Vector{T}(undef, i);read!(f, t);push!(ret, t); end; ret + end + + function read_matrix_in_mixed_matrix(::Type{T}, f, spins, atomnum, FNAN, natn, Total_NumOrbs) where T + ret = Vector{Vector{Vector{Matrix{T}}}}(undef, spins) + for spin = 1:spins;t_spin = Vector{Vector{Matrix{T}}}(undef, atomnum) + for ai = 1:atomnum;t_ai = Vector{Matrix{T}}(undef, FNAN[ai]) + for aj_inner = 1:FNAN[ai] + t = Matrix{T}(undef, Total_NumOrbs[natn[ai][aj_inner]], Total_NumOrbs[ai]) + read!(f, t);t_ai[aj_inner] = t + end;t_spin[ai] = t_ai + end;ret[spin] = t_spin + end;return ret + end + read_matrix_in_mixed_matrix(f, spins, atomnum, FNAN, natn, Total_NumOrbs) = read_matrix_in_mixed_matrix(Float64, f, spins, atomnum, FNAN, natn, Total_NumOrbs) + + read_3d_vecs(::Type{T}, f, num) where T = reshape(multiread(T, f, 4 * num), 4, Int(num))[2:4,:] + read_3d_vecs(f, num) = read_3d_vecs(Float64, f, num) + # End of helper functions + + bound_multiread(T, size) = multiread(T, f, size) + bound_multiread(size) = multiread(f, size) + bound_read_mixed_matrix() = read_mixed_matrix(Int32, f, FNAN) + bound_read_matrix_in_mixed_matrix(spins) = read_matrix_in_mixed_matrix(f, spins, atomnum, FNAN, natn, Total_NumOrbs) + bound_read_3d_vecs(num) = read_3d_vecs(f, num) + bound_read_3d_vecs(::Type{T}, num) where T = read_3d_vecs(T, f, num) + # End of bound helper functions + + f = open(filepath) + atomnum, SpinP_switch, Catomnum, Latomnum, Ratomnum, TCpyCell, order_max = bound_multiread(7) + @assert (SpinP_switch >> 2) == 3 "DeepH-pack only supports OpenMX v3.9. Please check your OpenMX version" + SpinP_switch &= 0x03 + + atv, atv_ijk = bound_read_3d_vecs.([Float64,Int32], TCpyCell + 1) + + Total_NumOrbs, FNAN = bound_multiread.([atomnum,atomnum]) + FNAN .+= 1 + natn = bound_read_mixed_matrix() + ncn = ((x)->x .+ 1).(bound_read_mixed_matrix()) # These is to fix that atv and atv_ijk starts from 0 in original C code. + + tv, rtv, Gxyz = bound_read_3d_vecs.([3,3,atomnum]) + + Hk = bound_read_matrix_in_mixed_matrix(SpinP_switch + 1) + iHk = SpinP_switch == 3 ? bound_read_matrix_in_mixed_matrix(3) : nothing + OLP = bound_read_matrix_in_mixed_matrix(1)[1] + OLP_r = [] + for dir in 1:3, order in 1:order_max + t = bound_read_matrix_in_mixed_matrix(1)[1] + if order == 1 push!(OLP_r, t) end + end + OLP_p = bound_read_matrix_in_mixed_matrix(3) + DM = bound_read_matrix_in_mixed_matrix(SpinP_switch + 1) + iDM = bound_read_matrix_in_mixed_matrix(2) + solver = bound_multiread(1)[1] + chem_p, E_temp = bound_multiread(Float64, 2) + dipole_moment_core, dipole_moment_background = bound_multiread.(Float64, [3,3]) + Valence_Electrons, Total_SpinS = bound_multiread(Float64, 2) + dummy_blocks = bound_multiread(1)[1] + for i in 1:dummy_blocks + bound_multiread(UInt8, 256) + end + + # we suppose that the original output file(.out) was appended to the end of the scfout file. + function strip1(s::Vector{UInt8}) + startpos = 0 + for i = 1:length(s) + 1 + if i > length(s) || s[i] & 0x80 != 0 || !isspace(Char(s[i] & 0x7f)) + startpos = i + break + end + end + return s[startpos:end] + end + function startswith1(s::Vector{UInt8}, prefix::Vector{UInt8}) + return length(s) >= length(prefix) && s[1:length(prefix)] == prefix + end + function isnum(s::Char) + if s >= '1' && s <= '9' + return true + else + return false + end + end + + function isorb(s::Char) + if s in ['s','p','d','f'] + return true + else + return false + end + end + + function orbital_types_str2num(str::AbstractString) + orbs = split(str, isnum, keepempty = false) + nums = map(x->parse(Int, x), split(str, isorb, keepempty = false)) + orb2l = Dict("s" => 0, "p" => 1, "d" => 2, "f" => 3) + @assert length(orbs) == length(nums) + orbital_types = Array{Int64,1}(undef, 0) + for (orb, num) in zip(orbs, nums) + for i = 1:num + push!(orbital_types, orb2l[orb]) + end + end + return orbital_types + end + + function find_target_line(target_line::String) + target_line_UInt8 = Vector{UInt8}(target_line) + while !startswith1(strip1(Vector{UInt8}(readline(f))), target_line_UInt8) + if eof(f) + error(string(target_line, "not found. Please check if the .out file was appended to the end of .scfout file!")) + end + end + end + +# @info """get orbital setting of element:orbital_types_element::Dict{String,Array{Int64,1}} "element" => orbital_types""" + find_target_line("" + break + end + element = split(str)[1] + orbital_types_str = split(split(str)[2], "-")[2] + orbital_types_element[element] = orbital_types_str2num(orbital_types_str) + end + + +# @info "get Chemical potential (Hartree)" + find_target_line("(see also PRB 72, 045121(2005) for the energy contributions)") + readline(f) + readline(f) + readline(f) + str = split(readline(f)) + @assert "Chemical" == str[1] + @assert "potential" == str[2] + @assert "(Hartree)" == str[3] + ev2Hartree = 0.036749324533634074 + fermi_level = parse(Float64, str[length(str)])/ev2Hartree + + # @info "get Chemical potential (Hartree)" + # find_target_line("Eigenvalues (Hartree)") + # for i = 1:2;@assert readline(f) == "***********************************************************";end + # readline(f) + # str = split(readline(f)) + # ev2Hartree = 0.036749324533634074 + # fermi_level = parse(Float64, str[length(str)])/ev2Hartree + + +# @info "get Fractional coordinates & orbital types:" + find_target_line("Fractional coordinates of the final structure") + target_line = Vector{UInt8}("Fractional coordinates of the final structure") + for i = 1:2;@assert readline(f) == "***********************************************************";end + @assert readline(f) == "" + orbital_types = Array{Array{Int64,1},1}(undef, 0) #orbital_types + element = Array{Int64,1}(undef, 0) #orbital_types + atom_frac_pos = zeros(3, atomnum) #Fractional coordinates + for i = 1:atomnum + str = readline(f) + element_str = split(str)[2] + push!(orbital_types, orbital_types_element[element_str]) + m = match(r"^\s*\d+\s+\w+\s+([0-9+-.Ee]+)\s+([0-9+-.Ee]+)\s+([0-9+-.Ee]+)", str) + push!(element, periodic_table[element_str]["Atomic no"]) + atom_frac_pos[:,i] = ((x)->parse(Float64, x)).(m.captures) + end + atom_pos = tv * atom_frac_pos + close(f) + + # use the atom_pos to fix + # TODO: Persuade wangc to accept the following code, which seems hopeless and meaningless. + """ + for axis = 1:3 + ((x2, y2, z)->((x, y)->x .+= z * y).(x2, y2)).(OLP_r[axis], OLP, atom_pos[axis,:]) + end + """ + for axis in 1:3,i in 1:atomnum, j in 1:FNAN[i] + OLP_r[axis][i][j] .+= atom_pos[axis,i] * OLP[i][j] + end + + # fix type mismatch + atv_ijk = Matrix{Int64}(atv_ijk) + + if return_DM + return element, atomnum, SpinP_switch, atv, atv_ijk, Total_NumOrbs, FNAN, natn, ncn, tv, Hk, iHk, OLP, OLP_r, orbital_types, fermi_level, atom_pos, DM + else + return element, atomnum, SpinP_switch, atv, atv_ijk, Total_NumOrbs, FNAN, natn, ncn, tv, Hk, iHk, OLP, OLP_r, orbital_types, fermi_level, atom_pos, nothing + end +end + +function get_data(filepath_scfout::String, Rcut::Float64; if_DM::Bool = false) + element, nsites, SpinP_switch, atv, atv_ijk, Total_NumOrbs, FNAN, natn, ncn, lat, Hk, iHk, OLP, OLP_r, orbital_types, fermi_level, site_positions, DM = parse_openmx(filepath_scfout; return_DM=if_DM) + + for t in [Hk, iHk] + if t != nothing + ((x)->((y)->((z)->z .*= 27.2113845).(y)).(x)).(t) # Hartree to eV + end + end + site_positions .*= 0.529177249 # Bohr to Ang + lat .*= 0.529177249 # Bohr to Ang + + # get R_list + R_list = Set{Vector{Int64}}() + for atom_i in 1:nsites, index_nn_i in 1:FNAN[atom_i] + atom_j = natn[atom_i][index_nn_i] + R = atv_ijk[:, ncn[atom_i][index_nn_i]] + push!(R_list, SVector{3, Int64}(R)) + end + R_list = collect(R_list) + + # get neighbour_site + nsites = size(site_positions, 2) + # neighbour_site = cal_neighbour_site(site_positions, lat, R_list, nsites, Rcut) + # local_coordinates = Dict{Array{Int64, 1}, Array{Float64, 2}}() + + # process hamiltonian + norbits = sum(Total_NumOrbs) + overlaps = Dict{Array{Int64, 1}, Array{Float64, 2}}() + if SpinP_switch == 0 + spinful = false + hamiltonians = Dict{Array{Int64, 1}, Array{Float64, 2}}() + if if_DM + density_matrixs = Dict{Array{Int64, 1}, Array{Float64, 2}}() + else + density_matrixs = nothing + end + elseif SpinP_switch == 1 + error("Collinear spin is not supported currently") + elseif SpinP_switch == 3 + @assert if_DM == false + density_matrixs = nothing + spinful = true + for i in 1:length(Hk[4]),j in 1:length(Hk[4][i]) + Hk[4][i][j] += iHk[3][i][j] + iHk[3][i][j] = -Hk[4][i][j] + end + hamiltonians = Dict{Array{Int64, 1}, Array{Complex{Float64}, 2}}() + else + error("SpinP_switch is $SpinP_switch, rather than valid values 0, 1 or 3") + end + + for site_i in 1:nsites, index_nn_i in 1:FNAN[site_i] + site_j = natn[site_i][index_nn_i] + R = atv_ijk[:, ncn[site_i][index_nn_i]] + e_ij = lat * R + site_positions[:, site_j] - site_positions[:, site_i] + # if norm(e_ij) > Rcut + # continue + # end + key = cat(dims=1, R, site_i, site_j) + # site_list_i = neighbour_site[site_i] + # local_coordinate = _get_local_coordinate(e_ij, site_list_i) + # local_coordinates[key] = local_coordinate + + overlap = permutedims(OLP[site_i][index_nn_i]) + overlaps[key] = overlap + if SpinP_switch == 0 + hamiltonian = permutedims(Hk[1][site_i][index_nn_i]) + hamiltonians[key] = hamiltonian + if if_DM + density_matrix = permutedims(DM[1][site_i][index_nn_i]) + density_matrixs[key] = density_matrix + end + elseif SpinP_switch == 1 + error("Collinear spin is not supported currently") + elseif SpinP_switch == 3 + key_inv = cat(dims=1, -R, site_j, site_i) + + len_i_wo_spin = Total_NumOrbs[site_i] + len_j_wo_spin = Total_NumOrbs[site_j] + + if !(key in keys(hamiltonians)) + @assert !(key_inv in keys(hamiltonians)) + hamiltonians[key] = zeros(Complex{Float64}, len_i_wo_spin * 2, len_j_wo_spin * 2) + hamiltonians[key_inv] = zeros(Complex{Float64}, len_j_wo_spin * 2, len_i_wo_spin * 2) + end + for spini in 0:1,spinj in spini:1 + Hk_real, Hk_imag = spini == 0 ? spinj == 0 ? (Hk[1][site_i][index_nn_i], iHk[1][site_i][index_nn_i]) : (Hk[3][site_i][index_nn_i], Hk[4][site_i][index_nn_i]) : spinj == 0 ? (Hk[3][site_i][index_nn_i], iHk[3][site_i][index_nn_i]) : (Hk[2][site_i][index_nn_i], iHk[2][site_i][index_nn_i]) + hamiltonians[key][spini * len_i_wo_spin + 1 : (spini + 1) * len_i_wo_spin, spinj * len_j_wo_spin + 1 : (spinj + 1) * len_j_wo_spin] = permutedims(Hk_real) + im * permutedims(Hk_imag) + if spini == 0 && spinj == 1 + hamiltonians[key_inv][1 * len_j_wo_spin + 1 : (1 + 1) * len_j_wo_spin, 0 * len_i_wo_spin + 1 : (0 + 1) * len_i_wo_spin] = (permutedims(Hk_real) + im * permutedims(Hk_imag))' + end + end + else + error("SpinP_switch is $SpinP_switch, rather than valid values 0, 1 or 3") + end + end + + return element, overlaps, density_matrixs, hamiltonians, fermi_level, orbital_types, lat, site_positions, spinful, R_list +end + +parsed_args["input_dir"] = abspath(parsed_args["input_dir"]) +mkpath(parsed_args["output_dir"]) +cd(parsed_args["output_dir"]) + +element, overlaps, density_matrixs, hamiltonians, fermi_level, orbital_types, lat, site_positions, spinful, R_list = get_data(joinpath(parsed_args["input_dir"], "openmx.scfout"), -1.0; if_DM=parsed_args["if_DM"]) + +if parsed_args["if_DM"] + h5open("density_matrixs.h5", "w") do fid + for (key, density_matrix) in density_matrixs + write(fid, string(key), permutedims(density_matrix)) + end + end +end +if parsed_args["save_overlap"] + h5open("overlaps.h5", "w") do fid + for (key, overlap) in overlaps + write(fid, string(key), permutedims(overlap)) + end + end +end +h5open("hamiltonians.h5", "w") do fid + for (key, hamiltonian) in hamiltonians + write(fid, string(key), permutedims(hamiltonian)) + end +end + +info_dict = Dict( + "fermi_level" => fermi_level, + "isspinful" => spinful + ) +open("info.json", "w") do f + write(f, json(info_dict, 4)) +end +open("site_positions.dat", "w") do f + writedlm(f, site_positions) +end +open("R_list.dat", "w") do f + writedlm(f, R_list) +end +open("lat.dat", "w") do f + writedlm(f, lat) +end +rlat = 2pi * inv(lat)' +open("rlat.dat", "w") do f + writedlm(f, rlat) +end +open("orbital_types.dat", "w") do f + writedlm(f, orbital_types) +end +open("element.dat", "w") do f + writedlm(f, element) +end diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/openmx_parse.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/openmx_parse.py new file mode 100644 index 0000000000000000000000000000000000000000..83612ead536d5b9a7a1adf4140497006180494cd --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/openmx_parse.py @@ -0,0 +1,425 @@ +import os +import json +from math import pi + +import tqdm +import argparse +import h5py +import numpy as np +from pymatgen.core.structure import Structure + +from .abacus_get_data import periodic_table + +Hartree2Ev = 27.2113845 +Ev2Kcalmol = 23.061 +Bohr2R = 0.529177249 + + +def openmx_force_intferface(out_file_dir, save_dir=None, return_Etot=False, return_force=False): + with open(out_file_dir, 'r') as out_file: + lines = out_file.readlines() + for index_line, line in enumerate(lines): + if line.find('Total energy (Hartree) at MD = 1') != -1: + assert lines[index_line + 3].find("Uele.") != -1 + assert lines[index_line + 5].find("Ukin.") != -1 + assert lines[index_line + 7].find("UH1.") != -1 + assert lines[index_line + 8].find("Una.") != -1 + assert lines[index_line + 9].find("Unl.") != -1 + assert lines[index_line + 10].find("Uxc0.") != -1 + assert lines[index_line + 20].find("Utot.") != -1 + parse_E = lambda x: float(x.split()[-1]) + E_tot = parse_E(lines[index_line + 20]) * Hartree2Ev + E_kin = parse_E(lines[index_line + 5]) * Hartree2Ev + E_delta_ee = parse_E(lines[index_line + 7]) * Hartree2Ev + E_NA = parse_E(lines[index_line + 8]) * Hartree2Ev + E_NL = parse_E(lines[index_line + 9]) * Hartree2Ev + E_xc = parse_E(lines[index_line + 10]) * 2 * Hartree2Ev + if save_dir is not None: + with open(os.path.join(save_dir, "openmx_E.json"), 'w') as E_file: + json.dump({ + "Total energy": E_tot, + "E_kin": E_kin, + "E_delta_ee": E_delta_ee, + "E_NA": E_NA, + "E_NL": E_NL, + "E_xc": E_xc + }, E_file) + if line.find('xyz-coordinates (Ang) and forces (Hartree/Bohr)') != -1: + assert lines[index_line + 4].find("') != -1: + flag_read_orbital = False + if flag_read_orbital: + element = line.split()[0] + orbital_str = (line.split()[1]).split('-')[-1] + l_list = [] + assert len(orbital_str) % 2 == 0 + for index_str in range(len(orbital_str) // 2): + l_list.extend([orbital2l[orbital_str[index_str * 2]]] * int(orbital_str[index_str * 2 + 1])) + orbital_dict[element] = l_list + if line.find('-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "10070 kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[Rn].6d1.7s2", "Ionic radii": {"3": 1.26}, "Liquid range": "2250 K", "Melting point": "1323 K", "Mendeleev no": 48, "Mineral hardness": "no data", "Molar volume": "22.55 cm3", "Name": "Actinium", "Oxidation states": [3], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 1.26, "ionic_radius": 1.12}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "12 W m-1 K-1", "Van der waals radius": 2.47, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 1.1, "Youngs modulus": "no data GPa", "Metallic radius": 1.878, "iupac_ordering": 32, "IUPAC ordering": 32, "Ground level": "2D3/2", "Ionization energies": [5.380226, 11.75, 17.431, 44.8, 55.0, 67.0, 79.0, 98.9, 113.9, 143.9, 161.1, 233.0, 255.0, 279.0, 305.0, 330.0, 355.0, 390.0, 416.0, 444.0, 470.0, 610.0, 640.0, 670.0, 710.0, 780.0, 820.0, 920.0, 950.0, 1030.0, 1100.0, 1170.0, 1240.0, 1310.0, 1380.0, 1460.0, 1530.0, 1610.0, 1680.0, 1750.0, 1820.0, 1900.0, 1970.0, 2298.0, 2362.0, 2430.0, 2503.0, 2572.0, 2639.0, 2762.0, 2833.0, 2908.0, 2980.0, 3264.0, 3334.0, 3409.0, 3479.0, 3811.0, 3893.0, 4093.0, 4175.0, 6767.0, 6923.0, 7088.0, 7265.0, 7430.0, 7600.0, 7950.0, 8120.0, 8310.0, 8480.0, 8970.0, 9120.0, 9290.0, 9440.0, 10480.0, 10660.0, 11030.0, 11200.0, 23480.0, 23890.0, 24340.0, 24760.0, 28610.0, 29160.0, 29850.0, 30293.1, 119938.6, 122062.9], "Electron affinity": 0.35}, "Ag": {"Atomic mass": 107.8682, "Atomic no": 47, "Atomic orbitals": {"1s": -900.324578, "2p": -120.913351, "2s": -129.859807, "3d": -13.367803, "3p": -20.06763, "3s": -23.678437, "4d": -0.298706, "4p": -2.086602, "4s": -3.22309, "5s": -0.157407}, "Atomic radius": 1.6, "Atomic radius calculated": 1.65, "Boiling point": "2435 K", "Brinell hardness": "24.5 MN m-2", "Bulk modulus": "100 GPa", "Coefficient of linear thermal expansion": "18.9 x10-6K-1", "Common oxidation states": [1], "Critical temperature": "no data K", "Density of solid": "10490 kg m-3", "Electrical resistivity": "1.63 10-8 Ω m", "Electronic structure": "[Kr].4d10.5s1", "ICSD oxidation states": [1, 2, 3], "Ionic radii": {"1": 1.29, "2": 1.08, "3": 0.89}, "Liquid range": "1200.07 K", "Melting point": "1234.93 K", "Mendeleev no": 71, "Mineral hardness": "2.5", "Molar volume": "10.27 cm3", "Name": "Silver", "Oxidation states": [1, 2, 3], "Poissons ratio": "0.37", "Reflectivity": "97 %", "Refractive index": "no data", "Rigidity modulus": "30 GPa", "Shannon radii": {"1": {"II": {"": {"crystal_radius": 0.81, "ionic_radius": 0.67}}, "IV": {"": {"crystal_radius": 1.14, "ionic_radius": 1.0}}, "IVSQ": {"": {"crystal_radius": 1.16, "ionic_radius": 1.02}}, "V": {"": {"crystal_radius": 1.23, "ionic_radius": 1.09}}, "VI": {"": {"crystal_radius": 1.29, "ionic_radius": 1.15}}, "VII": {"": {"crystal_radius": 1.36, "ionic_radius": 1.22}}, "VIII": {"": {"crystal_radius": 1.42, "ionic_radius": 1.28}}}, "2": {"IVSQ": {"": {"crystal_radius": 0.93, "ionic_radius": 0.79}}, "VI": {"": {"crystal_radius": 1.08, "ionic_radius": 0.94}}}, "3": {"IVSQ": {"": {"crystal_radius": 0.81, "ionic_radius": 0.67}}, "VI": {"": {"crystal_radius": 0.89, "ionic_radius": 0.75}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "430 W m-1 K-1", "Van der waals radius": 2.11, "Velocity of sound": "2600 m s-1", "Vickers hardness": "251 MN m-2", "X": 1.93, "Youngs modulus": "83 GPa", "Metallic radius": 1.445, "iupac_ordering": 72, "IUPAC ordering": 72, "Ground level": "2S1/2", "Ionization energies": [7.576234, 21.4844, 34.8, 49.0, 65.0, 82.0, 106.0, 125.0, 145.1, 167.0, 188.0, 271.46, 294.0, 321.0, 347.0, 381.0, 408.43, 469.0, 500.87, 885.0, 946.0, 1013.0, 1082.0, 1149.0, 1231.0, 1308.0, 1382.0, 1460.0, 1535.0, 1747.0, 1810.5, 1888.0, 1979.0, 2077.0, 2131.0, 2302.0, 2371.99, 5558.0, 5753.0, 5966.0, 6170.0, 6551.0, 6785.0, 7082.0, 7271.298, 30097.318, 30965.698], "Electron affinity": 1.304473}, "Al": {"Atomic mass": 26.9815386, "Atomic no": 13, "Atomic orbitals": {"1s": -55.156044, "2p": -2.564018, "2s": -3.934827, "3p": -0.102545, "3s": -0.286883}, "Atomic radius": 1.25, "Atomic radius calculated": 1.18, "Boiling point": "2792 K", "Brinell hardness": "245 MN m-2", "Bulk modulus": "76 GPa", "Coefficient of linear thermal expansion": "23.1 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "2700 kg m-3", "Electrical resistivity": "2.7 10-8 Ω m", "Electronic structure": "[Ne].3s2.3p1", "ICSD oxidation states": [3], "Ionic radii": {"3": 0.675}, "Liquid range": "1858.53 K", "Melting point": "933.47 K", "Mendeleev no": 80, "Mineral hardness": "2.75", "Molar volume": "10.00 cm3", "Name": "Aluminum", "Oxidation states": [1, 3], "Poissons ratio": "0.35", "Reflectivity": "71 %", "Refractive index": "no data", "Rigidity modulus": "26 GPa", "Shannon radii": {"3": {"IV": {"": {"crystal_radius": 0.53, "ionic_radius": 0.39}}, "V": {"": {"crystal_radius": 0.62, "ionic_radius": 0.48}}, "VI": {"": {"crystal_radius": 0.675, "ionic_radius": 0.535}}}}, "Superconduction temperature": "1.175 K", "Thermal conductivity": "235 W m-1 K-1", "Van der waals radius": 1.84, "Velocity of sound": "5100 m s-1", "Vickers hardness": "167 MN m-2", "X": 1.61, "Youngs modulus": "70 GPa", "NMR Quadrupole Moment": {"Al-27": 146.6}, "Metallic radius": 1.43, "iupac_ordering": 80, "IUPAC ordering": 80, "Ground level": "2P\u00b01/2", "Ionization energies": [5.985769, 18.82855, 28.447642, 119.9924, 153.8252, 190.49, 241.76, 284.64, 330.21, 398.65, 442.005, 2085.97702, 2304.14007], "Electron affinity": 0.432835}, "Am": {"Atomic mass": 243.0, "Atomic no": 95, "Atomic orbitals": "no data", "Atomic radius": 1.75, "Atomic radius calculated": "no data", "Boiling point": "2880 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "no data kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[Rn].5f7.7s2", "Ionic radii": {"2": 1.4, "3": 1.115, "4": 0.99}, "Liquid range": "1431 K", "Melting point": "1449 K", "Mendeleev no": 42, "Mineral hardness": "no data", "Molar volume": "17.63 cm3", "Name": "Americium", "Oxidation states": [2, 3, 4, 5, 6], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"2": {"VII": {"": {"crystal_radius": 1.35, "ionic_radius": 1.21}}, "VIII": {"": {"crystal_radius": 1.4, "ionic_radius": 1.26}}, "IX": {"": {"crystal_radius": 1.45, "ionic_radius": 1.31}}}, "3": {"VI": {"": {"crystal_radius": 1.115, "ionic_radius": 0.975}}, "VIII": {"": {"crystal_radius": 1.23, "ionic_radius": 1.09}}}, "4": {"VI": {"": {"crystal_radius": 0.99, "ionic_radius": 0.85}}, "VIII": {"": {"crystal_radius": 1.09, "ionic_radius": 0.95}}}}, "Superconduction temperature": "0.6 K", "Thermal conductivity": "10 W m-1 K-1", "Van der waals radius": 2.44, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 1.3, "Youngs modulus": "no data GPa", "Metallic radius": 1.73, "iupac_ordering": 26, "IUPAC ordering": 26, "Ground level": "8S\u00b07/2", "Ionization energies": [5.97381, 11.7, 21.7, 36.8, 50.0, 67.9, 95.0, 110.0, 125.0, 141.0, 163.0, 184.0, 206.0, 225.0, 242.0, 284.0, 305.0, 424.0, 451.0, 481.0, 511.0, 541.0, 571.0, 616.0, 646.0, 680.0, 711.0, 870.0, 900.0, 940.0, 980.0, 1090.0, 1130.0, 1240.0, 1280.0, 1410.0, 1490.0, 1570.0, 1650.0, 1730.0, 1820.0, 1900.0, 1980.0, 2070.0, 2160.0, 2240.0, 2320.0, 2410.0, 2480.0, 2874.0, 2946.0, 3021.0, 3101.0, 3178.0, 3251.0, 3402.0, 3479.0, 3563.0, 3641.0, 3956.0, 4033.0, 4115.0, 4191.0, 4642.0, 4733.0, 4960.0, 5050.0, 8040.0, 8210.0, 8390.0, 8590.0, 8770.0, 8950.0, 9380.0, 9560.0, 9770.0, 9960.0, 10490.0, 10650.0, 10830.0, 11000.0, 12400.0, 12600.0, 13000.0, 13190.0, 27110.0, 27550.0, 28040.0, 28500.0, 33700.0, 34300.0, 35100.0, 35549.4, 139769.5, 142161.0], "Electron affinity": 0.1}, "Ar": {"Atomic mass": 39.948, "Atomic no": 18, "Atomic orbitals": {"1s": -113.800134, "2p": -8.443439, "2s": -10.794172, "3p": -0.38233, "3s": -0.883384}, "Atomic radius": 0.71, "Atomic radius calculated": 0.71, "Boiling point": "87.3 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Critical temperature": "150.8 K", "Density of solid": "no data kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[Ne].3s2.3p6", "Liquid range": "3.5 K", "Max oxidation state": 0.0, "Melting point": "83.8 K", "Mendeleev no": 3, "Min oxidation state": 0.0, "Mineral hardness": "no data", "Molar volume": "22.56 cm3", "Name": "Argon", "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "1.000281", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "0.01772 W m-1 K-1", "Van der waals radius": 1.88, "Velocity of sound": "319 m s-1", "Vickers hardness": "no data MN m-2", "Youngs modulus": "no data GPa", "Metallic radius": "no data", "iupac_ordering": 3, "IUPAC ordering": 3, "Ground level": "1S0", "Ionization energies": [15.7596119, 27.62967, 40.735, 59.58, 74.84, 91.29, 124.41, 143.4567, 422.6, 479.76, 540.4, 619.0, 685.5, 755.13, 855.5, 918.375, 4120.6657, 4426.2229], "Electron affinity": -1.02}, "As": {"Atomic mass": 74.9216, "Atomic no": 33, "Atomic orbitals": {"1s": -423.336658, "2p": -47.527869, "2s": -53.093086, "3d": -1.542767, "3p": -4.851725, "3s": -6.730755, "4p": -0.197497, "4s": -0.52367}, "Atomic radius": 1.15, "Atomic radius calculated": 1.14, "Boiling point": "887 K", "Brinell hardness": "1440 MN m-2", "Bulk modulus": "22 GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [-3, 3, 5], "Critical temperature": "1700 K", "Density of solid": "5727 kg m-3", "Electrical resistivity": "33 10-8 Ω m", "Electronic structure": "[Ar].3d10.4s2.4p3", "ICSD oxidation states": [2, 3, 5, -2, -3, -1], "Ionic radii": {"3": 0.72, "5": 0.6}, "Liquid range": "203 K", "Melting point": "1090 K", "Mendeleev no": 89, "Mineral hardness": "3.5", "Molar volume": "12.95 cm3", "Name": "Arsenic", "Oxidation states": [-3, 2, 3, 5], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "1.001552", "Rigidity modulus": "no data GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 0.72, "ionic_radius": 0.58}}}, "5": {"IV": {"": {"crystal_radius": 0.475, "ionic_radius": 0.335}}, "VI": {"": {"crystal_radius": 0.6, "ionic_radius": 0.46}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "50 W m-1 K-1", "Van der waals radius": 1.85, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 2.18, "Youngs modulus": "8 GPa", "Metallic radius": "no data", "iupac_ordering": 89, "IUPAC ordering": 89, "Ground level": "4S\u00b03/2", "Ionization energies": [9.78855, 18.5892, 28.349, 50.15, 62.77, 121.19, 147.0, 180.0, 213.0, 247.0, 296.0, 333.0, 375.0, 418.0, 460.0, 587.6, 628.8, 672.9, 728.9, 774.0, 814.0, 911.7, 956.79, 2356.9, 2486.0, 2626.0, 2766.0, 2938.0, 3088.1, 3287.0, 3411.643, 14447.678, 15028.907], "Electron affinity": 0.80482}, "At": {"Atomic mass": 210.0, "Atomic no": 85, "Atomic orbitals": {"1s": -3127.390276, "2p": -513.044243, "2s": -531.81835, "3d": -103.060375, "3p": -119.995013, "3s": -129.035542, "4d": -18.295162, "4f": -8.063483, "4p": -25.778264, "4s": -29.809515, "5d": -1.643758, "5p": -4.027061, "5s": -5.453383, "6p": -0.255453, "6s": -0.560189}, "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [-1, 1], "Critical temperature": "no data K", "Density of solid": "no data kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[Xe].4f14.5d10.6s2.6p5", "Ionic radii": {"7": 0.76}, "Liquid range": "no data K", "Melting point": "575 K", "Mendeleev no": 96, "Mineral hardness": "no data", "Molar volume": "no data cm3", "Name": "Astatine", "Oxidation states": [-1, 1, 3, 5], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"7": {"VI": {"": {"crystal_radius": 0.76, "ionic_radius": 0.62}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "2 (estimate)W m-1 K-1", "Van der waals radius": 2.02, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 2.2, "Youngs modulus": "no data GPa", "Metallic radius": "no data", "iupac_ordering": 98, "IUPAC ordering": 98, "Ground level": "2P\u00b03/2", "Ionization energies": [9.31751, 17.88, 26.58, 39.65, 50.39, 72.0, 85.1, 130.1, 149.0, 169.0, 192.1, 212.0, 236.0, 263.0, 287.0, 311.0, 335.0, 452.0, 481.0, 510.0, 540.0, 600.0, 630.0, 720.0, 750.0, 790.0, 860.0, 920.0, 990.0, 1050.0, 1120.0, 1180.0, 1250.0, 1320.0, 1380.0, 1450.0, 1510.0, 1590.0, 1650.0, 1948.0, 2007.0, 2071.0, 2139.0, 2203.0, 2266.0, 2373.0, 2439.0, 2510.0, 2576.0, 2841.0, 2905.0, 2977.0, 3042.0, 3312.0, 3388.0, 3573.0, 3649.0, 5976.0, 6122.0, 6279.0, 6445.0, 6604.0, 6759.0, 7068.0, 7230.0, 7410.0, 7570.0, 8030.0, 8180.0, 8330.0, 8480.0, 9330.0, 9500.0, 9830.0, 9990.0, 21210.0, 21600.0, 22030.0, 22420.0, 25580.0, 26090.0, 26730.0, 27139.0, 107923.4, 109886.0], "Electron affinity": 2.415787}, "Au": {"Atomic mass": 196.966569, "Atomic no": 79, "Atomic orbitals": {"1s": -2683.508245, "2p": -430.725701, "2s": -447.888973, "3d": -81.511751, "3p": -96.707, "3s": -104.824516, "4d": -12.131815, "4f": -3.486824, "4p": -18.578652, "4s": -22.078357, "5d": -0.304738, "5p": -2.002495, "5s": -3.113936, "6s": -0.162334}, "Atomic radius": 1.35, "Atomic radius calculated": 1.74, "Boiling point": "3129 K", "Brinell hardness": "2450 MN m-2", "Bulk modulus": "220 GPa", "Coefficient of linear thermal expansion": "14.2 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "19300 kg m-3", "Electrical resistivity": "2.2 10-8 Ω m", "Electronic structure": "[Xe].4f14.5d10.6s1", "Ionic radii": {"1": 1.51, "3": 0.99, "5": 0.71}, "Liquid range": "1791.67 K", "Melting point": "1337.33 K", "Mendeleev no": 70, "Mineral hardness": "2.5", "Molar volume": "10.21 cm3", "Name": "Gold", "Oxidation states": [-1, 1, 2, 3, 5], "Poissons ratio": "0.44", "Reflectivity": "95 %", "Refractive index": "no data", "Rigidity modulus": "27 GPa", "Shannon radii": {"1": {"VI": {"": {"crystal_radius": 1.51, "ionic_radius": 1.37}}}, "3": {"IVSQ": {"": {"crystal_radius": 0.82, "ionic_radius": 0.68}}, "VI": {"": {"crystal_radius": 0.99, "ionic_radius": 0.85}}}, "5": {"VI": {"": {"crystal_radius": 0.71, "ionic_radius": 0.57}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "320 W m-1 K-1", "Van der waals radius": 2.14, "Velocity of sound": "1740 m s-1", "Vickers hardness": "216 MN m-2", "X": 2.54, "Youngs modulus": "78 GPa", "Metallic radius": 1.442, "iupac_ordering": 71, "IUPAC ordering": 71, "Ground level": "2S1/2", "Ionization energies": [9.225554, 20.203, 30.0, 45.0, 60.0, 74.0, 94.0, 112.0, 130.1, 149.0, 168.2, 248.0, 275.0, 299.0, 324.0, 365.0, 392.0, 433.0, 487.0, 520.0, 550.0, 600.0, 650.0, 710.0, 760.0, 820.0, 870.0, 930.0, 990.0, 1040.0, 1100.0, 1150.0, 1210.0, 1475.0, 1527.0, 1584.0, 1644.0, 1702.0, 1758.0, 1845.0, 1904.0, 1967.0, 2026.0, 2261.0, 2320.0, 2383.0, 2443.0, 2640.0, 2708.0, 2870.0, 2941.0, 4888.0, 5013.0, 5156.0, 5307.0, 5452.0, 5594.0, 5846.0, 5994.0, 6156.0, 6305.0, 6724.0, 6854.0, 6997.0, 7130.0, 7760.0, 7910.0, 8210.0, 8360.0, 18040.0, 18400.0, 18790.0, 19150.0, 21470.0, 21920.0, 22500.0, 22868.1, 91515.82, 93254.3], "Electron affinity": 2.30861025}, "B": {"Atomic mass": 10.811, "Atomic no": 5, "Atomic orbitals": {"1s": -6.564347, "2p": -0.136603, "2s": -0.344701}, "Atomic radius": 0.85, "Atomic radius calculated": 0.87, "Boiling point": "4200 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "320 GPa", "Coefficient of linear thermal expansion": "6 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "2460 kg m-3", "Electrical resistivity": "> 101210-8 Ω m", "Electronic structure": "[He].2s2.2p1", "ICSD oxidation states": [3, -3], "Ionic radii": {"3": 0.41}, "Liquid range": "1851 K", "Melting point": "2349 K", "Mendeleev no": 86, "Mineral hardness": "9.3", "Molar volume": "4.39 cm3", "Name": "Boron", "Oxidation states": [1, 2, 3], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"3": {"III": {"": {"crystal_radius": 0.15, "ionic_radius": 0.01}}, "IV": {"": {"crystal_radius": 0.25, "ionic_radius": 0.11}}, "VI": {"": {"crystal_radius": 0.41, "ionic_radius": 0.27}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "27 W m-1 K-1", "Van der waals radius": 1.92, "Velocity of sound": "16200 m s-1", "Vickers hardness": "49000 MN m-2", "X": 2.04, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": {"B-10": 84.59, "B-11": 40.59}, "Metallic radius": "no data", "iupac_ordering": 81, "IUPAC ordering": 81, "Ground level": "2P\u00b01/2", "Ionization energies": [8.298019, 25.15483, 37.93059, 259.3715, 340.2260229], "Electron affinity": 0.27972325}, "Ba": {"Atomic mass": 137.327, "Atomic no": 56, "Atomic orbitals": {"1s": -1305.743258, "2p": -189.598483, "2s": -200.844444, "3d": -28.528933, "3p": -37.536931, "3s": -42.359434, "4d": -3.432441, "4p": -6.497622, "4s": -8.257061, "5p": -0.698605, "5s": -1.157159, "6s": -0.118967}, "Atomic radius": 2.15, "Atomic radius calculated": 2.53, "Boiling point": "2143 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "9.6 GPa", "Coefficient of linear thermal expansion": "20.6 x10-6K-1", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "3510 kg m-3", "Electrical resistivity": "34 10-8 Ω m", "Electronic structure": "[Xe].6s2", "ICSD oxidation states": [2], "Ionic radii": {"2": 1.49}, "Liquid range": "1143 K", "Melting point": "1000 K", "Mendeleev no": 14, "Mineral hardness": "1.25", "Molar volume": "38.16 cm3", "Name": "Barium", "Oxidation states": [2], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "4.9 GPa", "Shannon radii": {"2": {"VI": {"": {"crystal_radius": 1.49, "ionic_radius": 1.35}}, "VII": {"": {"crystal_radius": 1.52, "ionic_radius": 1.38}}, "VIII": {"": {"crystal_radius": 1.56, "ionic_radius": 1.42}}, "IX": {"": {"crystal_radius": 1.61, "ionic_radius": 1.47}}, "X": {"": {"crystal_radius": 1.66, "ionic_radius": 1.52}}, "XI": {"": {"crystal_radius": 1.71, "ionic_radius": 1.57}}, "XII": {"": {"crystal_radius": 1.75, "ionic_radius": 1.61}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "18 W m-1 K-1", "Van der waals radius": 2.68, "Velocity of sound": "1620 m s-1", "Vickers hardness": "no data MN m-2", "X": 0.89, "Youngs modulus": "13 GPa", "Metallic radius": 2.236, "iupac_ordering": 13, "IUPAC ordering": 13, "Ground level": "1S0", "Ionization energies": [5.2116646, 10.003826, 35.8438, 47.0, 58.0, 71.0, 86.0, 101.0, 130.5, 146.52, 241.0, 267.1, 296.0, 325.0, 354.0, 390.0, 422.0, 455.0, 488.0, 520.0, 646.0, 679.0, 717.0, 752.0, 809.0, 846.0, 935.0, 976.62, 1695.0, 1776.0, 1864.0, 1958.0, 2047.0, 2142.0, 2256.0, 2349.0, 2452.0, 2547.0, 2814.0, 2901.0, 2994.0, 3081.0, 3266.0, 3363.0, 3546.0, 3640.0, 8326.0, 8565.0, 8831.0, 9077.0, 9739.0, 10023.0, 10376.0, 10616.42, 43485.366, 44561.47], "Electron affinity": 0.144626}, "Be": {"Atomic mass": 9.012182, "Atomic no": 4, "Atomic orbitals": {"1s": -3.856411, "2s": -0.205744}, "Atomic radius": 1.05, "Atomic radius calculated": 1.12, "Boiling point": "2742 K", "Brinell hardness": "600 MN m-2", "Bulk modulus": "130 GPa", "Coefficient of linear thermal expansion": "11.3 x10-6K-1", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "1848 kg m-3", "Electrical resistivity": "3.8 10-8 Ω m", "Electronic structure": "[He].2s2", "ICSD oxidation states": [2], "Ionic radii": {"2": 0.59}, "Liquid range": "1182 K", "Melting point": "1560 K", "Mendeleev no": 77, "Mineral hardness": "5.5", "Molar volume": "4.85 cm3", "Name": "Beryllium", "Oxidation states": [2], "Poissons ratio": "0.032", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "132 GPa", "Shannon radii": {"2": {"III": {"": {"crystal_radius": 0.3, "ionic_radius": 0.16}}, "IV": {"": {"crystal_radius": 0.41, "ionic_radius": 0.27}}, "VI": {"": {"crystal_radius": 0.59, "ionic_radius": 0.45}}}}, "Superconduction temperature": "0.026 K", "Thermal conductivity": "190 W m-1 K-1", "Van der waals radius": 1.53, "Velocity of sound": "13000 m s-1", "Vickers hardness": "1670 MN m-2", "X": 1.57, "Youngs modulus": "287 GPa", "NMR Quadrupole Moment": {"Be-9": 52.88}, "Metallic radius": 1.12, "iupac_ordering": 17, "IUPAC ordering": 17, "Ground level": "1S0", "Ionization energies": [9.322699, 18.21115, 153.896205, 217.7185861], "Electron affinity": -0.52}, "Bi": {"Atomic mass": 208.9804, "Atomic no": 83, "Atomic orbitals": {"1s": -2975.550959, "2p": -484.716359, "2s": -502.950758, "3d": -95.532476, "3p": -111.883393, "3s": -120.613998, "4d": -16.084817, "4f": -6.382744, "4p": -23.218641, "4s": -27.07034, "5d": -1.139408, "5p": -3.293637, "5s": -4.611934, "6p": -0.180198, "6s": -0.426129}, "Atomic radius": 1.6, "Atomic radius calculated": 1.43, "Boiling point": "1837 K", "Brinell hardness": "94.2 MN m-2", "Bulk modulus": "31 GPa", "Coefficient of linear thermal expansion": "13.4 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "9780 kg m-3", "Electrical resistivity": "130 10-8 Ω m", "Electronic structure": "[Xe].4f14.5d10.6s2.6p3", "ICSD oxidation states": [1, 2, 3, 5], "Ionic radii": {"3": 1.17, "5": 0.9}, "Liquid range": "1292.6 K", "Melting point": "544.4 K", "Mendeleev no": 87, "Mineral hardness": "2.25", "Molar volume": "21.31 cm3", "Name": "Bismuth", "Oxidation states": [-3, 3, 5], "Poissons ratio": "0.33", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "12 GPa", "Shannon radii": {"3": {"V": {"": {"crystal_radius": 1.1, "ionic_radius": 0.96}}, "VI": {"": {"crystal_radius": 1.17, "ionic_radius": 1.03}}, "VIII": {"": {"crystal_radius": 1.31, "ionic_radius": 1.17}}}, "5": {"VI": {"": {"crystal_radius": 0.9, "ionic_radius": 0.76}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "8 W m-1 K-1", "Van der waals radius": 2.07, "Velocity of sound": "1790 m s-1", "Vickers hardness": "no data MN m-2", "X": 2.02, "Youngs modulus": "32 GPa", "Metallic radius": 1.82, "iupac_ordering": 87, "IUPAC ordering": 87, "Ground level": "4S\u00b03/2", "Ionization energies": [7.285516, 16.703, 25.57075, 45.37, 54.856, 88.4, 103.0, 122.0, 143.0, 161.1, 183.0, 208.0, 229.0, 252.0, 272.6, 370.2, 409.0, 436.0, 464.0, 520.0, 550.0, 620.0, 660.0, 690.0, 750.0, 810.0, 870.0, 930.0, 990.0, 1060.0, 1120.0, 1180.0, 1250.0, 1310.0, 1380.0, 1440.0, 1500.0, 1784.0, 1840.0, 1902.0, 1967.0, 2029.0, 2090.0, 2190.0, 2253.0, 2321.0, 2385.0, 2641.0, 2703.0, 2771.0, 2835.0, 3078.0, 3151.0, 3329.0, 3401.8, 5599.0, 5740.0, 5892.0, 6054.0, 6208.0, 6358.0, 6648.0, 6804.0, 6977.0, 7137.0, 7580.0, 7720.0, 7870.0, 8010.0, 8780.0, 8950.0, 9270.0, 9430.0, 20130.0, 20500.0, 20920.0, 21300.0, 24150.0, 24640.0, 25260.0, 25656.9, 102251.76, 104132.8], "Electron affinity": 0.94236213}, "Bk": {"Atomic mass": 247.0, "Atomic no": 97, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "14780 kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[Rn].5f9.7s2", "Ionic radii": {"3": 1.1, "4": 0.97}, "Liquid range": "no data K", "Melting point": "1259 K", "Mendeleev no": 40, "Mineral hardness": "no data", "Molar volume": "16.84 cm3", "Name": "Berkelium", "Oxidation states": [3, 4], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 1.1, "ionic_radius": 0.96}}}, "4": {"VI": {"": {"crystal_radius": 0.97, "ionic_radius": 0.83}}, "VIII": {"": {"crystal_radius": 1.07, "ionic_radius": 0.93}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "10 W m-1 K-1", "Van der waals radius": 2.44, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 1.3, "Youngs modulus": "no data GPa", "Metallic radius": 1.703, "iupac_ordering": 24, "IUPAC ordering": 24, "Ground level": "6H\u00b015/2", "Ionization energies": [6.19785, 11.9, 21.6, 36.0, 56.0, 70.1, 90.0, 114.0, 130.0, 147.0, 171.0, 195.0, 218.0, 240.0, 259.0, 279.0, 303.0, 339.0, 361.0, 497.0, 526.0, 557.0, 590.0, 621.0, 652.0, 700.0, 733.0, 768.0, 800.0, 960.0, 1000.0, 1040.0, 1080.0, 1200.0, 1240.0, 1360.0, 1410.0, 1550.0, 1630.0, 1720.0, 1800.0, 1890.0, 1970.0, 2050.0, 2140.0, 2240.0, 2320.0, 2410.0, 2490.0, 2580.0, 2670.0, 3080.0, 3154.0, 3232.0, 3315.0, 3393.0, 3469.0, 3630.0, 3709.0, 3797.0, 3877.0, 4202.0, 4281.0, 4365.0, 4445.0, 4940.0, 5040.0, 5270.0, 5360.0, 8500.0, 8670.0, 8850.0, 9050.0, 9240.0, 9420.0, 9880.0, 10070.0, 10280.0, 10480.0, 11020.0, 11190.0, 11380.0, 11550.0, 13090.0, 13300.0, 13720.0, 13910.0, 28380.0, 28800.0, 29300.0, 29800.0, 35500.0, 36200.0, 37000.0, 37457.6, 146904.7, 149398.0], "Electron affinity": -1.72}, "Br": {"Atomic mass": 79.904, "Atomic no": 35, "Atomic orbitals": {"1s": -480.182643, "2p": -55.67796, "2s": -61.710022, "3d": -2.52211, "3p": -6.298805, "3s": -8.409057, "4p": -0.295334, "4s": -0.720066}, "Atomic radius": 1.15, "Atomic radius calculated": 0.94, "Boiling point": "332 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "1.9 GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [-1, 1, 3, 5, 7], "Critical temperature": "586 K", "Density of solid": "no data kg m-3", "Electrical resistivity": "> 101810-8 Ω m", "Electronic structure": "[Ar].3d10.4s2.4p5", "ICSD oxidation states": [5, -1], "Ionic radii": {"-1": 1.82, "3": 0.73, "5": 0.45, "7": 0.53}, "Liquid range": "66.2 K", "Melting point": "265.8 K", "Mendeleev no": 98, "Mineral hardness": "no data", "Molar volume": "19.78 cm3", "Name": "Bromine", "Oxidation states": [-1, 1, 3, 4, 5, 7], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "1.001132", "Rigidity modulus": "no data GPa", "Shannon radii": {"-1": {"VI": {"": {"crystal_radius": 1.82, "ionic_radius": 1.96}}}, "3": {"IVSQ": {"": {"crystal_radius": 0.73, "ionic_radius": 0.59}}}, "5": {"IIIPY": {"": {"crystal_radius": 0.45, "ionic_radius": 0.31}}}, "7": {"IV": {"": {"crystal_radius": 0.39, "ionic_radius": 0.25}}, "VI": {"": {"crystal_radius": 0.53, "ionic_radius": 0.39}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "0.12 W m-1 K-1", "Van der waals radius": 1.85, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 2.96, "Youngs modulus": "no data GPa", "Metallic radius": 1.14, "iupac_ordering": 100, "IUPAC ordering": 100, "Ground level": "2P\u00b03/2", "Ionization energies": [11.81381, 21.591, 34.871, 47.782, 59.595, 87.39, 103.03, 192.61, 224.0, 261.0, 301.0, 338.0, 393.0, 436.0, 481.0, 530.0, 577.0, 716.3, 761.0, 809.8, 870.0, 920.8, 963.0, 1070.6, 1119.17, 2731.4, 2869.0, 3021.0, 3169.0, 3361.0, 3523.1, 3735.0, 3868.986, 16317.011, 16937.127], "Electron affinity": 3.3635883}, "C": {"Atomic mass": 12.0107, "Atomic no": 6, "Atomic orbitals": {"1s": -9.947718, "2p": -0.199186, "2s": -0.500866}, "Atomic radius": 0.7, "Atomic radius calculated": 0.67, "Boiling point": "4300 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "33 GPa", "Coefficient of linear thermal expansion": "7.1 x10-6K-1", "Common oxidation states": [-4, 4], "Critical temperature": "no data K", "Density of solid": "2267 kg m-3", "Electrical resistivity": "about 1000 - direction dependent10-8 Ω m", "Electronic structure": "[He].2s2.2p2", "ICSD oxidation states": [2, 3, 4, -4, -3, -2], "Ionic radii": {"4": 0.3}, "Liquid range": "500 K", "Melting point": "3800 K", "Mendeleev no": 95, "Mineral hardness": "0.5 (graphite; diamond is 10.0)(no units)", "Molar volume": "5.29 cm3", "Name": "Carbon", "Oxidation states": [-4, -3, -2, -1, 1, 2, 3, 4], "Poissons ratio": "no data", "Reflectivity": "27 %", "Refractive index": "2.417 (diamond)(no units)", "Rigidity modulus": "no data GPa", "Shannon radii": {"4": {"III": {"": {"crystal_radius": 0.06, "ionic_radius": -0.08}}, "IV": {"": {"crystal_radius": 0.29, "ionic_radius": 0.15}}, "VI": {"": {"crystal_radius": 0.3, "ionic_radius": 0.16}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "140 W m-1 K-1", "Van der waals radius": 1.7, "Velocity of sound": "18350 m s-1", "Vickers hardness": "no data MN m-2", "X": 2.55, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": {"C-11": 33.27}, "Metallic radius": "no data", "iupac_ordering": 86, "IUPAC ordering": 86, "Ground level": "3P0", "Ionization energies": [11.260288, 24.383154, 47.88778, 64.49352, 392.090518, 489.993198], "Electron affinity": 1.262113612}, "Ca": {"Atomic mass": 40.078, "Atomic no": 20, "Atomic orbitals": {"1s": -143.935181, "2p": -12.285376, "2s": -15.046905, "3p": -1.030572, "3s": -1.706331, "4s": -0.141411}, "Atomic radius": 1.8, "Atomic radius calculated": 1.94, "Boiling point": "1757 K", "Brinell hardness": "167 MN m-2", "Bulk modulus": "17 GPa", "Coefficient of linear thermal expansion": "22.3 x10-6K-1", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "1550 kg m-3", "Electrical resistivity": "3.4 10-8 Ω m", "Electronic structure": "[Ar].4s2", "ICSD oxidation states": [2], "Ionic radii": {"2": 1.14}, "Liquid range": "642 K", "Melting point": "1115 K", "Mendeleev no": 16, "Mineral hardness": "1.75", "Molar volume": "26.20 cm3", "Name": "Calcium", "Oxidation states": [2], "Poissons ratio": "0.31", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "7.4 GPa", "Shannon radii": {"2": {"VI": {"": {"crystal_radius": 1.14, "ionic_radius": 1.0}}, "VII": {"": {"crystal_radius": 1.2, "ionic_radius": 1.06}}, "VIII": {"": {"crystal_radius": 1.26, "ionic_radius": 1.12}}, "IX": {"": {"crystal_radius": 1.32, "ionic_radius": 1.18}}, "X": {"": {"crystal_radius": 1.37, "ionic_radius": 1.23}}, "XII": {"": {"crystal_radius": 1.48, "ionic_radius": 1.34}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "200 W m-1 K-1", "Van der waals radius": 2.31, "Velocity of sound": "3810 m s-1", "Vickers hardness": "no data MN m-2", "X": 1.0, "Youngs modulus": "20 GPa", "NMR Quadrupole Moment": {"Ca-41": -66.5, "Ca-43": -40.8}, "Metallic radius": 1.976, "iupac_ordering": 15, "IUPAC ordering": 15, "Ground level": "1S0", "Ionization energies": [6.11315547, 11.871719, 50.91316, 67.2732, 84.34, 108.78, 127.21, 147.24, 188.54, 211.275, 591.6, 658.2, 728.6, 817.2, 894.0, 973.7, 1086.8, 1157.726, 5128.8578, 5469.8616], "Electron affinity": 0.024551}, "Cd": {"Atomic mass": 112.411, "Atomic no": 48, "Atomic orbitals": {"1s": -941.476646, "2p": -127.63512, "2s": -136.83249, "3d": -14.685252, "3p": -21.637522, "3s": -25.379908, "4d": -0.47053, "4p": -2.39526, "4s": -3.596069, "5s": -0.204228}, "Atomic radius": 1.55, "Atomic radius calculated": 1.61, "Boiling point": "1040 K", "Brinell hardness": "203 MN m-2", "Bulk modulus": "42 GPa", "Coefficient of linear thermal expansion": "30.8 x10-6K-1", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "8650 kg m-3", "Electrical resistivity": "7 10-8 Ω m", "Electronic structure": "[Kr].4d10.5s2", "ICSD oxidation states": [2], "Ionic radii": {"2": 1.09}, "Liquid range": "445.78 K", "Melting point": "594.22 K", "Mendeleev no": 75, "Mineral hardness": "2.0", "Molar volume": "13.00 cm3", "Name": "Cadmium", "Oxidation states": [1, 2], "Poissons ratio": "0.30", "Reflectivity": "67 %", "Refractive index": "no data", "Rigidity modulus": "19 GPa", "Shannon radii": {"2": {"IV": {"": {"crystal_radius": 0.92, "ionic_radius": 0.78}}, "V": {"": {"crystal_radius": 1.01, "ionic_radius": 0.87}}, "VI": {"": {"crystal_radius": 1.09, "ionic_radius": 0.95}}, "VII": {"": {"crystal_radius": 1.17, "ionic_radius": 1.03}}, "VIII": {"": {"crystal_radius": 1.24, "ionic_radius": 1.1}}, "XII": {"": {"crystal_radius": 1.45, "ionic_radius": 1.31}}}}, "Superconduction temperature": "0.517 K", "Thermal conductivity": "97 W m-1 K-1", "Van der waals radius": 2.18, "Velocity of sound": "2310 m s-1", "Vickers hardness": "no data MN m-2", "X": 1.69, "Youngs modulus": "50 GPa", "Metallic radius": 1.51, "iupac_ordering": 75, "IUPAC ordering": 75, "Ground level": "1S0", "Ionization energies": [8.99382, 16.908313, 37.468, 51.0, 67.9, 87.0, 105.0, 130.1, 150.0, 173.0, 195.0, 218.0, 305.0, 329.0, 358.0, 385.0, 421.0, 452.6, 513.0, 546.19, 963.0, 1026.0, 1095.0, 1167.0, 1237.0, 1320.0, 1401.0, 1477.0, 1558.0, 1635.0, 1852.0, 1917.9, 1998.0, 2091.0, 2195.0, 2250.0, 2427.0, 2498.62, 5839.0, 6039.0, 6257.0, 6460.0, 6869.0, 7109.0, 7414.0, 7607.95, 31451.062, 32341.49], "Electron affinity": -0.72}, "Ce": {"Atomic mass": 140.116, "Atomic no": 58, "Atomic orbitals": {"1s": -1406.148284, "2p": -206.925148, "2s": -218.684842, "3d": -32.412569, "3p": -41.938282, "3s": -47.035283, "4d": -4.192548, "4f": -0.337442, "4p": -7.532106, "4s": -9.432744, "5d": -0.14055, "5p": -0.85011, "5s": -1.369728, "6s": -0.133974}, "Atomic radius": 1.85, "Atomic radius calculated": "no data", "Boiling point": "3633 K", "Brinell hardness": "412 MN m-2", "Bulk modulus": "22 GPa", "Coefficient of linear thermal expansion": "6.3 x10-6K-1", "Common oxidation states": [3, 4], "Critical temperature": "no data K", "Density of solid": "6689 kg m-3", "Electrical resistivity": "74 10-8 Ω m", "Electronic structure": "[Xe].4f1.5d1.6s2", "ICSD oxidation states": [3, 4], "Ionic radii": {"3": 1.15, "4": 1.01}, "Liquid range": "2565 K", "Melting point": "1068 K", "Mendeleev no": 32, "Mineral hardness": "2.5", "Molar volume": "20.69 cm3", "Name": "Cerium", "Oxidation states": [2, 3, 4], "Poissons ratio": "0.24", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "14 GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 1.15, "ionic_radius": 1.01}}, "VII": {"": {"crystal_radius": 1.21, "ionic_radius": 1.07}}, "VIII": {"": {"crystal_radius": 1.283, "ionic_radius": 1.143}}, "IX": {"": {"crystal_radius": 1.336, "ionic_radius": 1.196}}, "X": {"": {"crystal_radius": 1.39, "ionic_radius": 1.25}}, "XII": {"": {"crystal_radius": 1.48, "ionic_radius": 1.34}}}, "4": {"VI": {"": {"crystal_radius": 1.01, "ionic_radius": 0.87}}, "VIII": {"": {"crystal_radius": 1.11, "ionic_radius": 0.97}}, "X": {"": {"crystal_radius": 1.21, "ionic_radius": 1.07}}, "XII": {"": {"crystal_radius": 1.28, "ionic_radius": 1.14}}}}, "Superconduction temperature": "0.022 (under pressure)K", "Thermal conductivity": "11 W m-1 K-1", "Van der waals radius": 2.42, "Velocity of sound": "2100 m s-1", "Vickers hardness": "270 MN m-2", "X": 1.12, "Youngs modulus": "34 GPa", "Metallic radius": 1.707, "iupac_ordering": 46, "IUPAC ordering": 46, "Ground level": "1G\u00b04", "Ionization energies": [5.5386, 10.956, 20.1974, 36.906, 65.55, 77.6, 91.0, 106.0, 125.0, 140.0, 172.0, 192.24, 312.0, 340.0, 371.0, 403.0, 435.0, 472.0, 509.0, 543.0, 579.0, 613.0, 749.0, 785.0, 824.0, 862.0, 924.0, 965.0, 1060.0, 1103.5, 1908.0, 1994.0, 2087.0, 2185.0, 2280.0, 2378.0, 2500.0, 2600.0, 2706.0, 2806.0, 3087.0, 3176.0, 3274.0, 3366.0, 3570.0, 3672.0, 3865.0, 3963.0, 9020.0, 9269.0, 9545.0, 9803.0, 10542.0, 10840.0, 11210.0, 11459.85, 46840.306, 47965.72], "Electron affinity": 0.572}, "Cf": {"Atomic mass": 251.0, "Atomic no": 98, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "15100 kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[Rn].5f10.7s2", "Ionic radii": {"3": 1.09, "4": 0.961}, "Liquid range": "no data K", "Melting point": "1173 K", "Mendeleev no": 39, "Mineral hardness": "no data", "Molar volume": "16.50 cm3", "Name": "Californium", "Oxidation states": [2, 3, 4], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 1.09, "ionic_radius": 0.95}}}, "4": {"VI": {"": {"crystal_radius": 0.961, "ionic_radius": 0.821}}, "VIII": {"": {"crystal_radius": 1.06, "ionic_radius": 0.92}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m-1 K-1", "Van der waals radius": 2.45, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 1.3, "Youngs modulus": "no data GPa", "Metallic radius": 1.86, "iupac_ordering": 23, "IUPAC ordering": 23, "Ground level": "5I8", "Ionization energies": [6.28166, 12.0, 22.4, 37.7, 51.9, 75.0, 91.0, 112.9, 133.0, 152.0, 178.0, 201.0, 225.0, 247.0, 265.0, 286.0, 310.0, 334.0, 368.0, 390.0, 536.0, 566.0, 597.0, 630.0, 662.0, 695.0, 744.0, 778.0, 814.0, 847.0, 1010.0, 1050.0, 1090.0, 1120.0, 1250.0, 1300.0, 1420.0, 1470.0, 1620.0, 1700.0, 1790.0, 1880.0, 1960.0, 2050.0, 2130.0, 2220.0, 2320.0, 2410.0, 2490.0, 2580.0, 2670.0, 2750.0, 3186.0, 3261.0, 3340.0, 3424.0, 3503.0, 3581.0, 3747.0, 3828.0, 3915.0, 3998.0, 4329.0, 4407.0, 4494.0, 4570.0, 5100.0, 5190.0, 5430.0, 5520.0, 8730.0, 8900.0, 9090.0, 9290.0, 9480.0, 9660.0, 10140.0, 10330.0, 10550.0, 10740.0, 11300.0, 11470.0, 11650.0, 11820.0, 13450.0, 13660.0, 14080.0, 14280.0, 29000.0, 29500.0, 30000.0, 30500.0, 36500.0, 37100.0, 37900.0, 38443.5, 150579.3, 153124.0], "Electron affinity": -1.01}, "Cl": {"Atomic mass": 35.453, "Atomic no": 17, "Atomic orbitals": {"1s": -100.369229, "2p": -7.039982, "2s": -9.187993, "3p": -0.32038, "3s": -0.754458}, "Atomic radius": 1.0, "Atomic radius calculated": 0.79, "Boiling point": "239.11 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "1.1 (liquid)GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [-1, 1, 3, 5, 7], "Critical temperature": "417 K", "Density of solid": "no data kg m-3", "Electrical resistivity": "> 101010-8 Ω m", "Electronic structure": "[Ne].3s2.3p5", "ICSD oxidation states": [-1], "Ionic radii": {"-1": 1.67, "5": 0.26, "7": 0.41}, "Liquid range": "67.51 K", "Melting point": "171.6 K", "Mendeleev no": 99, "Mineral hardness": "no data", "Molar volume": "17.39 cm3", "Name": "Chlorine", "Oxidation states": [-1, 1, 2, 3, 4, 5, 6, 7], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "1.000773", "Rigidity modulus": "no data GPa", "Shannon radii": {"-1": {"VI": {"": {"crystal_radius": 1.67, "ionic_radius": 1.81}}}, "5": {"IIIPY": {"": {"crystal_radius": 0.26, "ionic_radius": 0.12}}}, "7": {"IV": {"": {"crystal_radius": 0.22, "ionic_radius": 0.08}}, "VI": {"": {"crystal_radius": 0.41, "ionic_radius": 0.27}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "0.0089 W m-1 K-1", "Van der waals radius": 1.75, "Velocity of sound": "206 m s-1", "Vickers hardness": "no data MN m-2", "X": 3.16, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": {"Cl-35": -81.65, "Cl-37": -64.35}, "Metallic radius": "no data", "iupac_ordering": 101, "IUPAC ordering": 101, "Ground level": "2P\u00b03/2", "Ionization energies": [12.967633, 23.81364, 39.8, 53.24, 67.68, 96.94, 114.2013, 348.306, 400.851, 456.7, 530.0, 591.58, 656.3, 750.23, 809.198, 3658.3438, 3946.2909], "Electron affinity": 3.61272528}, "Cm": {"Atomic mass": 247.0, "Atomic no": 96, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "3383 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "13510 kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[Rn].5f7.6d1.7s2", "Ionic radii": {"3": 1.11, "4": 0.99}, "Liquid range": "1770 K", "Melting point": "1613 K", "Mendeleev no": 41, "Mineral hardness": "no data", "Molar volume": "18.05 cm3", "Name": "Curium", "Oxidation states": [3, 4], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 1.11, "ionic_radius": 0.97}}}, "4": {"VI": {"": {"crystal_radius": 0.99, "ionic_radius": 0.85}}, "VIII": {"": {"crystal_radius": 1.09, "ionic_radius": 0.95}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "8.8 W m-1 K-1", "Van der waals radius": 2.45, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 1.3, "Youngs modulus": "no data GPa", "Metallic radius": 1.743, "iupac_ordering": 25, "IUPAC ordering": 25, "Ground level": "9D\u00b02", "Ionization energies": [5.99141, 12.4, 20.1, 37.7, 51.0, 69.1, 97.0, 112.0, 128.0, 144.0, 167.0, 190.0, 213.0, 235.0, 253.0, 272.0, 311.0, 332.0, 460.0, 489.0, 518.0, 550.0, 580.0, 611.0, 657.0, 689.0, 723.0, 755.0, 910.0, 950.0, 990.0, 1030.0, 1140.0, 1180.0, 1300.0, 1340.0, 1480.0, 1560.0, 1650.0, 1730.0, 1810.0, 1890.0, 1980.0, 2060.0, 2160.0, 2240.0, 2320.0, 2410.0, 2490.0, 2580.0, 2976.0, 3050.0, 3125.0, 3207.0, 3284.0, 3360.0, 3515.0, 3593.0, 3679.0, 3758.0, 4078.0, 4156.0, 4239.0, 4317.0, 4791.0, 4880.0, 5110.0, 5200.0, 8270.0, 8440.0, 8620.0, 8820.0, 9000.0, 9180.0, 9630.0, 9820.0, 10020.0, 10220.0, 10760.0, 10920.0, 11100.0, 11270.0, 12740.0, 12950.0, 13350.0, 13550.0, 27740.0, 28180.0, 28700.0, 29100.0, 34600.0, 35200.0, 36000.0, 36493.0, 143299.6, 145743.0], "Electron affinity": 0.28}, "Co": {"Atomic mass": 58.933195, "Atomic no": 27, "Atomic orbitals": {"1s": -275.616639, "2p": -28.152095, "2s": -32.379758, "3d": -0.322368, "3p": -2.388285, "3s": -3.651812, "4s": -0.204497}, "Atomic radius": 1.35, "Atomic radius calculated": 1.52, "Boiling point": "3200 K", "Brinell hardness": "700 MN m-2", "Bulk modulus": "180 GPa", "Coefficient of linear thermal expansion": "13.0 x10-6K-1", "Common oxidation states": [2, 3], "Critical temperature": "no data K", "Density of solid": "8900 kg m-3", "Electrical resistivity": "6 10-8 Ω m", "Electronic structure": "[Ar].3d7.4s2", "ICSD oxidation states": [1, 2, 3, 4], "Ionic radii": {"2": 0.885, "3": 0.75, "4": 0.67}, "Ionic radii hs": {"2": 0.885, "3": 0.75, "4": 0.67}, "Ionic radii ls": {"2": 0.79, "3": 0.685}, "Liquid range": "1432 K", "Melting point": "1768 K", "Mendeleev no": 64, "Mineral hardness": "5.0", "Molar volume": "6.67 cm3", "Name": "Cobalt", "Oxidation states": [-1, 1, 2, 3, 4, 5], "Poissons ratio": "0.31", "Reflectivity": "67 %", "Refractive index": "no data", "Rigidity modulus": "75 GPa", "Shannon radii": {"2": {"IV": {"High Spin": {"crystal_radius": 0.72, "ionic_radius": 0.58}}, "V": {"": {"crystal_radius": 0.81, "ionic_radius": 0.67}}, "VI": {"Low Spin": {"crystal_radius": 0.79, "ionic_radius": 0.65}, "High Spin": {"crystal_radius": 0.885, "ionic_radius": 0.745}}, "VIII": {"": {"crystal_radius": 1.04, "ionic_radius": 0.9}}}, "3": {"VI": {"High Spin": {"crystal_radius": 0.75, "ionic_radius": 0.61}, "Low Spin": {"crystal_radius": 0.685, "ionic_radius": 0.545}}}, "4": {"IV": {"": {"crystal_radius": 0.54, "ionic_radius": 0.4}}, "VI": {"High Spin": {"crystal_radius": 0.67, "ionic_radius": 0.53}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "100 W m-1 K-1", "Van der waals radius": 2.0, "Velocity of sound": "4720 m s-1", "Vickers hardness": "1043 MN m-2", "X": 1.88, "Youngs modulus": "209 GPa", "NMR Quadrupole Moment": {"Co-59": 420.3}, "Metallic radius": 1.25, "iupac_ordering": 67, "IUPAC ordering": 67, "Ground level": "4F9/2", "Ionization energies": [7.88101, 17.0844, 33.5, 51.27, 79.5, 102.0, 128.9, 157.8, 186.14, 275.4, 305.32, 336.1, 378.5, 410.0, 441.1, 511.96, 546.588, 1397.2, 1504.5, 1606.0, 1724.0, 1844.0, 1960.8, 2119.4, 2218.876, 9544.1833, 10012.122], "Electron affinity": 0.662265}, "Cr": {"Atomic mass": 51.9961, "Atomic no": 24, "Atomic orbitals": {"1s": -213.881191, "2p": -20.526273, "2s": -24.113457, "3d": -0.118123, "3p": -1.65423, "3s": -2.649085, "4s": -0.150445}, "Atomic radius": 1.4, "Atomic radius calculated": 1.66, "Boiling point": "2944 K", "Brinell hardness": "1120 MN m-2", "Bulk modulus": "160 GPa", "Coefficient of linear thermal expansion": "4.9 x10-6K-1", "Common oxidation states": [3, 6], "Critical temperature": "no data K", "Density of solid": "7140 kg m-3", "Electrical resistivity": "12.7 10-8 Ω m", "Electronic structure": "[Ar].3d5.4s1", "ICSD oxidation states": [2, 3, 4, 5, 6], "Ionic radii": {"2": 0.94}, "Ionic radii hs": {"2": 0.94}, "Ionic radii ls": {"2": 0.87, "3": 0.755, "4": 0.69, "5": 0.63, "6": 0.58}, "Liquid range": "764 K", "Melting point": "2180 K", "Mendeleev no": 57, "Mineral hardness": "8.5", "Molar volume": "7.23 cm3", "Name": "Chromium", "Oxidation states": [-2, -1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "0.21", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "115 GPa", "Shannon radii": {"2": {"VI": {"Low Spin": {"crystal_radius": 0.87, "ionic_radius": 0.73}, "High Spin": {"crystal_radius": 0.94, "ionic_radius": 0.8}}}, "3": {"VI": {"": {"crystal_radius": 0.755, "ionic_radius": 0.615}}}, "4": {"IV": {"": {"crystal_radius": 0.55, "ionic_radius": 0.41}}, "VI": {"": {"crystal_radius": 0.69, "ionic_radius": 0.55}}}, "5": {"IV": {"": {"crystal_radius": 0.485, "ionic_radius": 0.345}}, "VI": {"": {"crystal_radius": 0.63, "ionic_radius": 0.49}}, "VIII": {"": {"crystal_radius": 0.71, "ionic_radius": 0.57}}}, "6": {"IV": {"": {"crystal_radius": 0.4, "ionic_radius": 0.26}}, "VI": {"": {"crystal_radius": 0.58, "ionic_radius": 0.44}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "94 W m-1 K-1", "Van der waals radius": 2.06, "Velocity of sound": "5940 m s-1", "Vickers hardness": "1060 MN m-2", "X": 1.66, "Youngs modulus": "279 GPa", "NMR Quadrupole Moment": {"Cr-53": -150.5}, "Metallic radius": 1.285, "iupac_ordering": 58, "IUPAC ordering": 58, "Ground level": "7S3", "Ionization energies": [6.76651, 16.486305, 30.959, 49.16, 69.46, 90.6349, 160.29, 184.76, 209.5, 244.5, 270.8, 296.7, 354.7, 384.163, 1011.6, 1097.2, 1188.0, 1294.8, 1394.5, 1495.1, 1634.1, 1721.183, 7481.8628, 7894.7992], "Electron affinity": 0.6758412}, "Cs": {"Atomic mass": 132.9054519, "Atomic no": 55, "Atomic orbitals": {"1s": -1256.738791, "2p": -180.995344, "2s": -191.981873, "3d": -26.418398, "3p": -35.166423, "3s": -39.851584, "4d": -2.848386, "4p": -5.769326, "4s": -7.455966, "5p": -0.504903, "5s": -0.915819, "6s": -0.078699}, "Atomic radius": 2.6, "Atomic radius calculated": 2.98, "Boiling point": "944 K", "Brinell hardness": "0.14 MN m-2", "Bulk modulus": "1.6 GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [1], "Critical temperature": "1938 K", "Density of solid": "1879 kg m-3", "Electrical resistivity": "21 10-8 Ω m", "Electronic structure": "[Xe].6s1", "ICSD oxidation states": [1], "Ionic radii": {"1": 1.81}, "Liquid range": "642.41 K", "Melting point": "301.59 K", "Mendeleev no": 8, "Mineral hardness": "0.2", "Molar volume": "70.94 cm3", "Name": "Cesium", "Oxidation states": [1], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"1": {"VI": {"": {"crystal_radius": 1.81, "ionic_radius": 1.67}}, "VIII": {"": {"crystal_radius": 1.88, "ionic_radius": 1.74}}, "IX": {"": {"crystal_radius": 1.92, "ionic_radius": 1.78}}, "X": {"": {"crystal_radius": 1.95, "ionic_radius": 1.81}}, "XI": {"": {"crystal_radius": 1.99, "ionic_radius": 1.85}}, "XII": {"": {"crystal_radius": 2.02, "ionic_radius": 1.88}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "36 W m-1 K-1", "Van der waals radius": 3.43, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 0.79, "Youngs modulus": "1.7 GPa", "Metallic radius": 2.719, "iupac_ordering": 7, "IUPAC ordering": 7, "Ground level": "2S1/2", "Ionization energies": [3.89390572743, 23.15745, 33.195, 43.0, 56.0, 69.1, 82.9, 110.1, 125.61, 213.3, 233.0, 261.0, 289.0, 316.0, 352.0, 382.0, 413.0, 445.0, 476.0, 597.0, 629.0, 666.0, 700.0, 753.0, 791.0, 875.0, 916.1, 1592.0, 1672.0, 1757.0, 1848.0, 1936.0, 2029.0, 2137.0, 2230.0, 2329.0, 2422.0, 2683.0, 2767.0, 2859.0, 2945.0, 3118.0, 3214.0, 3392.0, 3485.0, 7989.0, 8224.0, 8484.0, 8726.0, 9350.0, 9629.0, 9974.0, 10208.78, 41861.075, 42912.99], "Electron affinity": 0.47163025}, "Cu": {"Atomic mass": 63.546, "Atomic no": 29, "Atomic orbitals": {"1s": -320.78852, "2p": -33.481247, "2s": -38.14131, "3d": -0.202272, "3p": -2.609244, "3s": -4.057453, "4s": -0.172056}, "Atomic radius": 1.35, "Atomic radius calculated": 1.45, "Boiling point": "3200 K", "Brinell hardness": "874 MN m-2", "Bulk modulus": "140 GPa", "Coefficient of linear thermal expansion": "16.5 x10-6K-1", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "8920 kg m-3", "Electrical resistivity": "1.72 10-8 Ω m", "Electronic structure": "[Ar].3d10.4s1", "ICSD oxidation states": [1, 2, 3], "Ionic radii": {"1": 0.91, "2": 0.87, "3": 0.68}, "Liquid range": "1842.23 K", "Melting point": "1357.77 K", "Mendeleev no": 72, "Mineral hardness": "3.0", "Molar volume": "7.11 cm3", "Name": "Copper", "Oxidation states": [1, 2, 3, 4], "Poissons ratio": "0.34", "Reflectivity": "90 %", "Refractive index": "no data", "Rigidity modulus": "48 GPa", "Shannon radii": {"1": {"II": {"": {"crystal_radius": 0.6, "ionic_radius": 0.46}}, "IV": {"": {"crystal_radius": 0.74, "ionic_radius": 0.6}}, "VI": {"": {"crystal_radius": 0.91, "ionic_radius": 0.77}}}, "2": {"IV": {"": {"crystal_radius": 0.71, "ionic_radius": 0.57}}, "IVSQ": {"": {"crystal_radius": 0.71, "ionic_radius": 0.57}}, "V": {"": {"crystal_radius": 0.79, "ionic_radius": 0.65}}, "VI": {"": {"crystal_radius": 0.87, "ionic_radius": 0.73}}}, "3": {"VI": {"Low Spin": {"crystal_radius": 0.68, "ionic_radius": 0.54}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "400 W m-1 K-1", "Van der waals radius": 1.96, "Velocity of sound": "3570 m s-1", "Vickers hardness": "369 MN m-2", "X": 1.9, "Youngs modulus": "130 GPa", "NMR Quadrupole Moment": {"Cu-63": -220.15, "Cu-65": -204.14}, "Metallic radius": 1.278, "iupac_ordering": 73, "IUPAC ordering": 73, "Ground level": "2S1/2", "Ionization energies": [7.72638, 20.29239, 36.841, 57.38, 79.8, 103.0, 139.0, 166.0, 198.0, 232.2, 265.33, 367.0, 401.0, 436.0, 483.1, 518.7, 552.8, 632.5, 670.608, 1690.5, 1800.0, 1918.0, 2044.0, 2179.4, 2307.3, 2479.1, 2586.954, 11062.4313, 11567.613], "Electron affinity": 1.235784}, "Dy": {"Atomic mass": 162.5, "Atomic no": 66, "Atomic orbitals": {"1s": -1843.229585, "2p": -281.558531, "2s": -295.342856, "3d": -47.4867, "3p": -59.091931, "3s": -65.299442, "4d": -5.686352, "4f": -0.265302, "4p": -10.094091, "4s": -12.551251, "5p": -0.90349, "5s": -1.547977, "6s": -0.132769}, "Atomic radius": 1.75, "Atomic radius calculated": 2.28, "Boiling point": "2840 K", "Brinell hardness": "500 MN m-2", "Bulk modulus": "41 GPa", "Coefficient of linear thermal expansion": "9.9 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "8551 kg m-3", "Electrical resistivity": "92.6 10-8 Ω m", "Electronic structure": "[Xe].4f10.6s2", "ICSD oxidation states": [3], "Ionic radii": {"2": 1.21, "3": 1.052}, "Liquid range": "1160 K", "Melting point": "1680 K", "Mendeleev no": 24, "Mineral hardness": "no data", "Molar volume": "19.01 cm3", "Name": "Dysprosium", "Oxidation states": [2, 3], "Poissons ratio": "0.25", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "25 GPa", "Shannon radii": {"2": {"VI": {"": {"crystal_radius": 1.21, "ionic_radius": 1.07}}, "VII": {"": {"crystal_radius": 1.27, "ionic_radius": 1.13}}, "VIII": {"": {"crystal_radius": 1.33, "ionic_radius": 1.19}}}, "3": {"VI": {"": {"crystal_radius": 1.052, "ionic_radius": 0.912}}, "VII": {"": {"crystal_radius": 1.11, "ionic_radius": 0.97}}, "VIII": {"": {"crystal_radius": 1.167, "ionic_radius": 1.027}}, "IX": {"": {"crystal_radius": 1.223, "ionic_radius": 1.083}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "11 W m-1 K-1", "Van der waals radius": 2.31, "Velocity of sound": "2710 m s-1", "Vickers hardness": "540 MN m-2", "X": 1.22, "Youngs modulus": "61 GPa", "Metallic radius": 1.773, "iupac_ordering": 38, "IUPAC ordering": 38, "Ground level": "5I8", "Ionization energies": [5.93905, 11.647, 22.89, 41.23, 62.1, 93.0, 110.0, 127.0, 152.0, 170.0, 192.0, 224.0, 259.0, 279.0, 300.0, 332.0, 366.0, 399.0, 431.0, 464.9, 664.0, 702.0, 743.0, 786.0, 827.0, 872.0, 924.0, 969.0, 1014.0, 1059.0, 1232.0, 1275.0, 1325.0, 1371.0, 1468.0, 1520.0, 1638.0, 1691.7, 2882.0, 2987.0, 3098.0, 3217.0, 3331.0, 3445.0, 3607.0, 3725.0, 3852.0, 3970.0, 4303.0, 4407.0, 4523.0, 4629.0, 4945.0, 5066.0, 5296.0, 5412.0, 12081.0, 12370.0, 12690.0, 12986.0, 14144.0, 14495.0, 14936.0, 15228.06, 61736.56, 63073.5], "Electron affinity": 0.352}, "Er": {"Atomic mass": 167.259, "Atomic no": 68, "Atomic orbitals": {"1s": -1961.799176, "2p": -302.01827, "2s": -316.310631, "3d": -51.682149, "3p": -63.818655, "3s": -70.310142, "4d": -6.127443, "4f": -0.278577, "4p": -10.819574, "4s": -13.423547, "5p": -0.935202, "5s": -1.616073, "6s": -0.134905}, "Atomic radius": 1.75, "Atomic radius calculated": 2.26, "Boiling point": "3141 K", "Brinell hardness": "814 MN m-2", "Bulk modulus": "44 GPa", "Coefficient of linear thermal expansion": "12.2 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "9066 kg m-3", "Electrical resistivity": "86.0 10-8 Ω m", "Electronic structure": "[Xe].4f12.6s2", "ICSD oxidation states": [3], "Ionic radii": {"3": 1.03}, "Liquid range": "1371 K", "Melting point": "1802 K", "Mendeleev no": 22, "Mineral hardness": "no data", "Molar volume": "18.46 cm3", "Name": "Erbium", "Oxidation states": [3], "Poissons ratio": "0.24", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "28 GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 1.03, "ionic_radius": 0.89}}, "VII": {"": {"crystal_radius": 1.085, "ionic_radius": 0.945}}, "VIII": {"": {"crystal_radius": 1.144, "ionic_radius": 1.004}}, "IX": {"": {"crystal_radius": 1.202, "ionic_radius": 1.062}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "15 W m-1 K-1", "Van der waals radius": 2.29, "Velocity of sound": "2830 m s-1", "Vickers hardness": "589 MN m-2", "X": 1.24, "Youngs modulus": "70 GPa", "Metallic radius": 1.756, "iupac_ordering": 36, "IUPAC ordering": 36, "Ground level": "3H6", "Ionization energies": [6.1077, 11.916, 22.7, 42.42, 65.1, 96.0, 114.0, 131.0, 158.0, 177.0, 201.0, 235.0, 268.0, 290.0, 311.0, 345.0, 381.0, 415.0, 450.0, 486.0, 520.0, 555.0, 770.0, 810.0, 853.0, 899.0, 943.0, 989.0, 1046.0, 1092.0, 1142.0, 1188.0, 1370.0, 1416.0, 1468.0, 1516.0, 1625.0, 1678.0, 1803.0, 1858.5, 3157.0, 3265.0, 3381.0, 3505.0, 3624.0, 3742.0, 3916.0, 4038.0, 4170.0, 4294.0, 4639.0, 4748.0, 4866.0, 4978.0, 5329.0, 5455.0, 5695.0, 5815.0, 12918.0, 13217.0, 13548.0, 13855.0, 15146.0, 15511.0, 15971.0, 16274.56, 65848.24, 67241.9], "Electron affinity": 0.312}, "Es": {"Atomic mass": 252.0, "Atomic no": 99, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "no data kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[Rn].5f11.7s2", "Liquid range": "no data K", "Melting point": "1133 K", "Mendeleev no": 38, "Mineral hardness": "no data", "Molar volume": "28.52 cm3", "Name": "Einsteinium", "Oxidation states": [2, 3], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m-1 K-1", "Van der waals radius": 2.45, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 1.3, "Youngs modulus": "no data GPa", "Metallic radius": 1.86, "iupac_ordering": 22, "IUPAC ordering": 22, "Ground level": "4I\u00b015/2", "Ionization energies": [6.36758, 12.2, 22.7, 38.8, 54.1, 71.0, 97.0, 112.9, 137.0, 157.0, 180.0, 206.0, 231.0, 252.0, 270.0, 294.0, 317.0, 342.0, 367.0, 398.0, 421.0, 576.0, 606.0, 638.0, 672.0, 705.0, 738.0, 790.0, 824.0, 861.0, 895.0, 1060.0, 1100.0, 1140.0, 1180.0, 1310.0, 1360.0, 1480.0, 1530.0, 1690.0, 1780.0, 1870.0, 1950.0, 2040.0, 2130.0, 2220.0, 2300.0, 2410.0, 2490.0, 2580.0, 2680.0, 2760.0, 2850.0, 3294.0, 3370.0, 3449.0, 3535.0, 3616.0, 3694.0, 3866.0, 3947.0, 4038.0, 4120.0, 4456.0, 4537.0, 4620.0, 4700.0, 5260.0, 5350.0, 5600.0, 5690.0, 8960.0, 9140.0, 9330.0, 9530.0, 9720.0, 9910.0, 10400.0, 10590.0, 10810.0, 11010.0, 11570.0, 11740.0, 11930.0, 12110.0, 13810.0, 14030.0, 14460.0, 14700.0, 29700.0, 30100.0, 30700.0, 31100.0, 37400.0, 38100.0, 38900.0, 39451.4, 154328.1, 156926.0], "Electron affinity": -0.3}, "Eu": {"Atomic mass": 151.964, "Atomic no": 63, "Atomic orbitals": {"1s": -1672.309322, "2p": -252.176697, "2s": -265.199534, "3d": -41.465518, "3p": -52.281987, "3s": -58.068128, "4d": -5.03242, "4f": -0.232773, "4p": -9.025455, "4s": -11.267747, "5p": -0.853575, "5s": -1.444087, "6s": -0.129426}, "Atomic radius": 1.85, "Atomic radius calculated": 2.31, "Boiling point": "1800 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "8.3 GPa", "Coefficient of linear thermal expansion": "35 x10-6K-1", "Common oxidation states": [2, 3], "Critical temperature": "no data K", "Density of solid": "5244 kg m-3", "Electrical resistivity": "90 10-8 Ω m", "Electronic structure": "[Xe].4f7.6s2", "ICSD oxidation states": [2, 3], "Ionic radii": {"2": 1.31, "3": 1.087}, "Liquid range": "701 K", "Melting point": "1099 K", "Mendeleev no": 18, "Mineral hardness": "no data", "Molar volume": "28.97 cm3", "Name": "Europium", "Oxidation states": [2, 3], "Poissons ratio": "0.15", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "7.9 GPa", "Shannon radii": {"2": {"VI": {"": {"crystal_radius": 1.31, "ionic_radius": 1.17}}, "VII": {"": {"crystal_radius": 1.34, "ionic_radius": 1.2}}, "VIII": {"": {"crystal_radius": 1.39, "ionic_radius": 1.25}}, "IX": {"": {"crystal_radius": 1.44, "ionic_radius": 1.3}}, "X": {"": {"crystal_radius": 1.49, "ionic_radius": 1.35}}}, "3": {"VI": {"": {"crystal_radius": 1.087, "ionic_radius": 0.947}}, "VII": {"": {"crystal_radius": 1.15, "ionic_radius": 1.01}}, "VIII": {"": {"crystal_radius": 1.206, "ionic_radius": 1.066}}, "IX": {"": {"crystal_radius": 1.26, "ionic_radius": 1.12}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "14 W m-1 K-1", "Van der waals radius": 2.35, "Velocity of sound": "no data m s-1", "Vickers hardness": "167 MN m-2", "X": 1.2, "Youngs modulus": "18 GPa", "Metallic radius": 2.041, "iupac_ordering": 41, "IUPAC ordering": 41, "Ground level": "8S\u00b07/2", "Ionization energies": [5.670385, 11.24, 24.84, 42.94, 63.2, 89.0, 105.0, 120.0, 144.0, 161.0, 183.0, 213.0, 243.0, 263.0, 281.0, 311.0, 344.4, 518.0, 553.0, 590.0, 630.0, 667.0, 709.0, 755.0, 795.0, 838.0, 879.0, 1037.0, 1078.0, 1124.0, 1167.0, 1249.0, 1296.0, 1406.0, 1456.06, 2495.0, 2591.0, 2697.0, 2807.0, 2914.0, 3022.0, 3168.0, 3279.0, 3398.0, 3510.0, 3823.0, 3921.0, 4031.0, 4131.0, 4400.0, 4513.0, 4729.0, 4838.0, 10880.0, 11153.0, 11457.0, 11739.0, 12718.0, 13050.0, 13462.0, 13738.58, 55865.92, 57120.64], "Electron affinity": 0.11613}, "F": {"Atomic mass": 18.9984032, "Atomic no": 9, "Atomic orbitals": {"1s": -24.189391, "2p": -0.415606, "2s": -1.086859}, "Atomic radius": 0.5, "Atomic radius calculated": 0.42, "Boiling point": "85.03 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [-1], "Critical temperature": "144 K", "Density of solid": "no data kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[He].2s2.2p5", "ICSD oxidation states": [-1], "Ionic radii": {"-1": 1.19, "7": 0.22}, "Liquid range": "31.5 K", "Melting point": "53.53 K", "Mendeleev no": 102, "Mineral hardness": "no data", "Molar volume": "11.20 cm3", "Name": "Fluorine", "Oxidation states": [-1], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "1.000195", "Rigidity modulus": "no data GPa", "Shannon radii": {"-1": {"II": {"": {"crystal_radius": 1.145, "ionic_radius": 1.285}}, "III": {"": {"crystal_radius": 1.16, "ionic_radius": 1.3}}, "IV": {"": {"crystal_radius": 1.17, "ionic_radius": 1.31}}, "VI": {"": {"crystal_radius": 1.19, "ionic_radius": 1.33}}}, "7": {"VI": {"": {"crystal_radius": 0.22, "ionic_radius": 0.08}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "0.0277 W m-1 K-1", "Van der waals radius": 1.47, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 3.98, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": {"F-19": -94.2}, "Metallic radius": "no data", "iupac_ordering": 102, "IUPAC ordering": 102, "Ground level": "2P\u00b03/2", "Ionization energies": [17.42282, 34.97081, 62.70798, 87.175, 114.249, 157.16311, 185.1868, 953.89805, 1103.11748], "Electron affinity": 3.401189824}, "Fe": {"Atomic mass": 55.845, "Atomic no": 26, "Atomic orbitals": {"1s": -254.225505, "2p": -25.551766, "2s": -29.56486, "3d": -0.295049, "3p": -2.187523, "3s": -3.360621, "4s": -0.197978}, "Atomic radius": 1.4, "Atomic radius calculated": 1.56, "Boiling point": "3134 K", "Brinell hardness": "490 MN m-2", "Bulk modulus": "170 GPa", "Coefficient of linear thermal expansion": "11.8 x10-6K-1", "Common oxidation states": [2, 3], "Critical temperature": "no data K", "Density of solid": "7874 kg m-3", "Electrical resistivity": "10 10-8 Ω m", "Electronic structure": "[Ar].3d6.4s2", "ICSD oxidation states": [2, 3], "Ionic radii": {"2": 0.92, "3": 0.785}, "Ionic radii hs": {"2": 0.92, "3": 0.785}, "Ionic radii ls": {"2": 0.75, "3": 0.69, "4": 0.725, "6": 0.39}, "Liquid range": "1323 K", "Melting point": "1811 K", "Mendeleev no": 61, "Mineral hardness": "4.0", "Molar volume": "7.09 cm3", "Name": "Iron", "Oxidation states": [-2, -1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "0.29", "Reflectivity": "65 %", "Refractive index": "no data", "Rigidity modulus": "82 GPa", "Shannon radii": {"2": {"IV": {"High Spin": {"crystal_radius": 0.77, "ionic_radius": 0.63}}, "IVSQ": {"High Spin": {"crystal_radius": 0.78, "ionic_radius": 0.64}}, "VI": {"Low Spin": {"crystal_radius": 0.75, "ionic_radius": 0.61}, "High Spin": {"crystal_radius": 0.92, "ionic_radius": 0.78}}, "VIII": {"High Spin": {"crystal_radius": 1.06, "ionic_radius": 0.92}}}, "3": {"IV": {"High Spin": {"crystal_radius": 0.63, "ionic_radius": 0.49}}, "V": {"": {"crystal_radius": 0.72, "ionic_radius": 0.58}}, "VI": {"Low Spin": {"crystal_radius": 0.69, "ionic_radius": 0.55}, "High Spin": {"crystal_radius": 0.785, "ionic_radius": 0.645}}, "VIII": {"High Spin": {"crystal_radius": 0.92, "ionic_radius": 0.78}}}, "4": {"VI": {"": {"crystal_radius": 0.725, "ionic_radius": 0.585}}}, "6": {"IV": {"": {"crystal_radius": 0.39, "ionic_radius": 0.25}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "80 W m-1 K-1", "Van der waals radius": 2.04, "Velocity of sound": "4910 m s-1", "Vickers hardness": "608 MN m-2", "X": 1.83, "Youngs modulus": "211 GPa", "NMR Quadrupole Moment": {"Fe-57": 160.0}, "Metallic radius": 1.277, "iupac_ordering": 64, "IUPAC ordering": 64, "Ground level": "5D4", "Ionization energies": [7.9024681, 16.19921, 30.651, 54.91, 75.0, 98.985, 124.976, 151.06, 233.6, 262.1, 290.9, 330.8, 361.0, 392.2, 456.2, 489.312, 1262.7, 1357.8, 1460.0, 1575.6, 1687.0, 1798.4, 1950.4, 2045.759, 8828.1879, 9277.6818], "Electron affinity": 0.15323634}, "Fm": {"Atomic mass": 257.0, "Atomic no": 100, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "no data kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[Rn].5f12.7s2", "Liquid range": "no data K", "Melting point": "about 1800 K", "Mendeleev no": 37, "Mineral hardness": "no data", "Molar volume": "no data cm3", "Name": "Fermium", "Oxidation states": [2, 3], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m-1 K-1", "Van der waals radius": 2.45, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 1.3, "Youngs modulus": "no data GPa", "Metallic radius": "no data", "iupac_ordering": 21, "IUPAC ordering": 21, "Ground level": "3H6", "Ionization energies": [6.5, 12.4, 23.2, 39.3, 55.0, 74.0, 93.0, 120.0, 136.0, 162.0, 185.0, 209.0, 237.0, 257.0, 276.0, 300.0, 326.0, 351.0, 377.0, 402.0, 430.0, 453.0, 616.0, 647.0, 680.0, 716.0, 749.0, 782.0, 837.0, 871.0, 909.0, 944.0, 1110.0, 1150.0, 1190.0, 1230.0, 1370.0, 1420.0, 1550.0, 1600.0, 1770.0, 1850.0, 1940.0, 2030.0, 2120.0, 2210.0, 2300.0, 2390.0, 2490.0, 2590.0, 2680.0, 2760.0, 2850.0, 2950.0, 3403.0, 3480.0, 3561.0, 3647.0, 3730.0, 3810.0, 3986.0, 4070.0, 4160.0, 4245.0, 4586.0, 4670.0, 4760.0, 4840.0, 5420.0, 5510.0, 5760.0, 5860.0, 9200.0, 9370.0, 9570.0, 9770.0, 9970.0, 10160.0, 10660.0, 10860.0, 11080.0, 11280.0, 11850.0, 12020.0, 12220.0, 12390.0, 14180.0, 14400.0, 14800.0, 15000.0, 30300.0, 30800.0, 31300.0, 31800.0, 38400.0, 39100.0, 40000.0, 40482.2, 158152.5, 160804.0], "Electron affinity": 0.35}, "Fr": {"Atomic mass": 223.0, "Atomic no": 87, "Atomic orbitals": {"1s": -3283.263399, "2p": -542.41424, "2s": -561.73045, "3d": -111.085223, "3p": -128.607136, "3s": -137.959632, "4d": -20.812462, "4f": -10.050648, "4p": -28.648131, "4s": -32.861013, "5d": -2.360991, "5p": -4.97328, "5s": -6.509516, "6p": -0.466197, "6s": -0.841848, "7s": -0.076176}, "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [1], "Critical temperature": "no data K", "Density of solid": "no data kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[Rn].7s1", "Ionic radii": {"1": 1.94}, "Liquid range": "no data K", "Melting point": "maybe about 300 K", "Mendeleev no": 7, "Mineral hardness": "no data", "Molar volume": "no data cm3", "Name": "Francium", "Oxidation states": [1], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"1": {"VI": {"": {"crystal_radius": 1.94, "ionic_radius": 1.8}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m-1 K-1", "Van der waals radius": 3.48, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 0.7, "Youngs modulus": "no data GPa", "Metallic radius": "no data", "iupac_ordering": 6, "IUPAC ordering": 6, "Ground level": "2S1/2", "Ionization energies": [4.0727411, 22.4, 33.5, 39.1, 50.0, 67.0, 80.0, 106.0, 120.0, 179.0, 200.0, 222.1, 245.0, 269.0, 293.0, 324.0, 349.0, 375.0, 400.0, 530.0, 560.0, 590.0, 620.0, 690.0, 720.0, 810.0, 850.0, 910.0, 980.0, 1040.0, 1110.0, 1180.0, 1250.0, 1320.0, 1380.0, 1460.0, 1530.0, 1600.0, 1670.0, 1740.0, 1810.0, 2119.0, 2182.0, 2247.0, 2317.0, 2384.0, 2450.0, 2564.0, 2631.0, 2706.0, 2774.0, 3049.0, 3115.0, 3190.0, 3257.0, 3556.0, 3635.0, 3828.0, 3907.0, 6365.0, 6516.0, 6678.0, 6849.0, 7013.0, 7172.0, 7500.0, 7670.0, 7850.0, 8020.0, 8500.0, 8640.0, 8800.0, 8950.0, 9890.0, 10070.0, 10420.0, 10590.0, 22330.0, 22730.0, 23170.0, 23570.0, 27060.0, 27590.0, 28260.0, 28683.4, 113817.2, 115859.0], "Electron affinity": 0.486}, "Ga": {"Atomic mass": 69.723, "Atomic no": 31, "Atomic orbitals": {"1s": -370.170639, "2p": -40.093339, "2s": -45.200869, "3d": -0.736204, "3p": -3.584666, "3s": -5.241645, "4p": -0.101634, "4s": -0.328019}, "Atomic radius": 1.3, "Atomic radius calculated": 1.36, "Boiling point": "2477 K", "Brinell hardness": "60 MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "120 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "5904 kg m-3", "Electrical resistivity": "about 14 10-8 Ω m", "Electronic structure": "[Ar].3d10.4s2.4p1", "ICSD oxidation states": [2, 3], "Ionic radii": {"3": 0.76}, "Liquid range": "2174.09 K", "Melting point": "302.91 K", "Mendeleev no": 81, "Mineral hardness": "1.5", "Molar volume": "11.80 cm3", "Name": "Gallium", "Oxidation states": [1, 2, 3], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"3": {"IV": {"": {"crystal_radius": 0.61, "ionic_radius": 0.47}}, "V": {"": {"crystal_radius": 0.69, "ionic_radius": 0.55}}, "VI": {"": {"crystal_radius": 0.76, "ionic_radius": 0.62}}}}, "Superconduction temperature": "1.083 K", "Thermal conductivity": "29 W m-1 K-1", "Van der waals radius": 1.87, "Velocity of sound": "2740 m s-1", "Vickers hardness": "no data MN m-2", "X": 1.81, "Youngs modulus": "no data GPa", "Metallic radius": 1.35, "iupac_ordering": 79, "IUPAC ordering": 79, "Ground level": "2P\u00b01/2", "Ionization energies": [5.999302, 20.51514, 30.72576, 63.241, 86.01, 112.7, 140.8, 169.9, 211.0, 244.0, 280.0, 319.0, 356.0, 471.2, 508.8, 548.3, 599.8, 640.0, 677.0, 765.7, 807.308, 2010.0, 2129.0, 2258.0, 2391.0, 2543.9, 2683.0, 2868.0, 2984.426, 12696.5575, 13239.489], "Electron affinity": 0.3012011}, "Gd": {"Atomic mass": 157.25, "Atomic no": 64, "Atomic orbitals": {"1s": -1728.625195, "2p": -262.081616, "2s": -275.36313, "3d": -43.754556, "3p": -54.836922, "3s": -60.764408, "4d": -5.531835, "4f": -0.489012, "4p": -9.669866, "4s": -11.986486, "5d": -0.12722, "5p": -0.978749, "5s": -1.608477, "6s": -0.143627}, "Atomic radius": 1.8, "Atomic radius calculated": 2.33, "Boiling point": "3523 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "38 GPa", "Coefficient of linear thermal expansion": "9.4 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "7901 kg m-3", "Electrical resistivity": "131 10-8 Ω m", "Electronic structure": "[Xe].4f7.5d1.6s2", "ICSD oxidation states": [3], "Ionic radii": {"3": 1.075}, "Liquid range": "1938 K", "Melting point": "1585 K", "Mendeleev no": 27, "Mineral hardness": "no data", "Molar volume": "19.90 cm3", "Name": "Gadolinium", "Oxidation states": [1, 2, 3], "Poissons ratio": "0.26", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "22 GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 1.078, "ionic_radius": 0.938}}, "VII": {"": {"crystal_radius": 1.14, "ionic_radius": 1.0}}, "VIII": {"": {"crystal_radius": 1.193, "ionic_radius": 1.053}}, "IX": {"": {"crystal_radius": 1.247, "ionic_radius": 1.107}}}}, "Superconduction temperature": "1.083 K", "Thermal conductivity": "11 W m-1 K-1", "Van der waals radius": 2.34, "Velocity of sound": "2680 m s-1", "Vickers hardness": "570 MN m-2", "X": 1.2, "Youngs modulus": "55 GPa", "Metallic radius": 1.802, "iupac_ordering": 40, "IUPAC ordering": 40, "Ground level": "9D\u00b02", "Ionization energies": [6.1498, 12.076, 20.54, 44.44, 64.8, 89.0, 106.0, 123.0, 144.0, 165.0, 183.0, 213.0, 246.0, 268.0, 288.0, 319.0, 352.0, 384.4, 565.0, 601.0, 639.0, 680.0, 719.0, 761.0, 810.0, 851.0, 895.0, 937.0, 1100.0, 1142.0, 1189.0, 1233.0, 1321.0, 1368.0, 1481.0, 1532.3, 2621.0, 2720.0, 2827.0, 2941.0, 3050.0, 3160.0, 3312.0, 3424.0, 3546.0, 3660.0, 3980.0, 4080.0, 4191.0, 4294.0, 4578.0, 4693.0, 4914.0, 5025.0, 11273.0, 11552.0, 11861.0, 12147.0, 13183.0, 13521.0, 13943.0, 14224.57, 57783.9, 59065.53], "Electron affinity": 0.137}, "Ge": {"Atomic mass": 72.64, "Atomic no": 32, "Atomic orbitals": {"1s": -396.292991, "2p": -43.720129, "2s": -49.055282, "3d": -1.117316, "3p": -4.194822, "3s": -5.961472, "4p": -0.149882, "4s": -0.426523}, "Atomic radius": 1.25, "Atomic radius calculated": 1.25, "Boiling point": "3093 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "6 x10-6K-1", "Common oxidation states": [-4, 2, 4], "Critical temperature": "no data K", "Density of solid": "5323 kg m-3", "Electrical resistivity": "about 50000 10-8 Ω m", "Electronic structure": "[Ar].3d10.4s2.4p2", "ICSD oxidation states": [2, 3, 4], "Ionic radii": {"2": 0.87, "4": 0.67}, "Liquid range": "1881.6 K", "Melting point": "1211.4 K", "Mendeleev no": 84, "Mineral hardness": "6.0", "Molar volume": "13.63 cm3", "Name": "Germanium", "Oxidation states": [-4, 1, 2, 3, 4], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"2": {"VI": {"": {"crystal_radius": 0.87, "ionic_radius": 0.73}}}, "4": {"IV": {"": {"crystal_radius": 0.53, "ionic_radius": 0.39}}, "VI": {"": {"crystal_radius": 0.67, "ionic_radius": 0.53}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "60 W m-1 K-1", "Van der waals radius": 2.11, "Velocity of sound": "5400 m s-1", "Vickers hardness": "no data MN m-2", "X": 2.01, "Youngs modulus": "no data GPa", "Metallic radius": 1.39, "iupac_ordering": 84, "IUPAC ordering": 84, "Ground level": "3P0", "Ionization energies": [7.899435, 15.93461, 34.0576, 45.7155, 90.5, 115.9, 144.9, 176.4, 212.5, 252.1, 286.0, 326.0, 367.0, 407.0, 527.9, 567.3, 609.1, 662.8, 706.7, 744.0, 837.1, 880.44, 2180.1, 2304.0, 2439.0, 2575.0, 2737.1, 2881.9, 3074.0, 3194.293, 13557.4208, 14119.43], "Electron affinity": 1.232676413}, "H": {"Atomic mass": 1.00794, "Atomic no": 1, "Atomic orbitals": {"1s": -0.233471}, "Atomic radius": 0.25, "Atomic radius calculated": 0.53, "Boiling point": "20.28 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [-1, 1], "Critical temperature": "33 K", "Density of solid": "no data kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "1s1", "ICSD oxidation states": [1, -1], "Liquid range": "6.27 K", "Melting point": "14.01 K", "Mendeleev no": 103, "Mineral hardness": "no data", "Molar volume": "11.42 cm3", "Name": "Hydrogen", "Oxidation states": [-1, 1], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "1.000132 (gas; liquid 1.12)(no units)", "Rigidity modulus": "no data GPa", "Shannon radii": {"1": {"I": {"": {"crystal_radius": -0.24, "ionic_radius": -0.38}}, "II": {"": {"crystal_radius": -0.04, "ionic_radius": -0.18}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "0.1805 W m-1 K-1", "Van der waals radius": 1.1, "Velocity of sound": "1270 m s-1", "Vickers hardness": "no data MN m-2", "X": 2.2, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": {"H-2": 2.86}, "Metallic radius": "no data", "iupac_ordering": 92, "IUPAC ordering": 92, "Ground level": "2S1/2", "Ionization energies": [13.598434599702], "Electron affinity": 0.754598}, "He": {"Atomic mass": 4.002602, "Atomic no": 2, "Atomic orbitals": {"1s": -0.570425}, "Atomic radius": "no data", "Atomic radius calculated": 0.31, "Boiling point": "4.22 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Critical temperature": "5.19 K", "Density of solid": "no data kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "1s2", "Liquid range": "3.27 K", "Max oxidation state": 0.0, "Melting point": "0.95 K", "Mendeleev no": 1, "Min oxidation state": 0.0, "Mineral hardness": "no data", "Molar volume": "21.0 cm3", "Name": "Helium", "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "1.000035 (gas; liquid 1.028)(no units)", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "0.1513 W m-1 K-1", "Van der waals radius": 1.4, "Velocity of sound": "970 m s-1", "Vickers hardness": "no data MN m-2", "Youngs modulus": "no data GPa", "Metallic radius": "no data", "iupac_ordering": 5, "IUPAC ordering": 5, "Ground level": "1S0", "Ionization energies": [24.587389011, 54.417765486], "Electron affinity": -0.52}, "Hf": {"Atomic mass": 178.49, "Atomic no": 72, "Atomic orbitals": {"1s": -2210.65199, "2p": -345.687023, "2s": -361.006527, "3d": -61.231443, "3p": -74.452656, "3s": -81.522812, "4d": -7.676638, "4f": -0.871574, "4p": -12.971211, "4s": -15.883625, "5d": -0.143805, "5p": -1.246441, "5s": -2.049828, "6s": -0.166465}, "Atomic radius": 1.55, "Atomic radius calculated": 2.08, "Boiling point": "4876 K", "Brinell hardness": "1700 MN m-2", "Bulk modulus": "110 GPa", "Coefficient of linear thermal expansion": "5.9 x10-6K-1", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "13310 kg m-3", "Electrical resistivity": "34 10-8 Ω m", "Electronic structure": "[Xe].4f14.5d2.6s2", "ICSD oxidation states": [4], "Ionic radii": {"4": 0.85}, "Liquid range": "2370 K", "Melting point": "2506 K", "Mendeleev no": 50, "Mineral hardness": "5.5", "Molar volume": "13.44 cm3", "Name": "Hafnium", "Oxidation states": [2, 3, 4], "Poissons ratio": "0.37", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "30 GPa", "Shannon radii": {"4": {"IV": {"": {"crystal_radius": 0.72, "ionic_radius": 0.58}}, "VI": {"": {"crystal_radius": 0.85, "ionic_radius": 0.71}}, "VII": {"": {"crystal_radius": 0.9, "ionic_radius": 0.76}}, "VIII": {"": {"crystal_radius": 0.97, "ionic_radius": 0.83}}}}, "Superconduction temperature": "0.128 K", "Thermal conductivity": "23 W m-1 K-1", "Van der waals radius": 2.23, "Velocity of sound": "3010 m s-1", "Vickers hardness": "1760 MN m-2", "X": 1.3, "Youngs modulus": "78 GPa", "Metallic radius": 1.58, "iupac_ordering": 50, "IUPAC ordering": 50, "Ground level": "3F2", "Ionization energies": [6.82507, 14.61, 22.55, 33.37, 68.37, 98.0, 118.0, 137.0, 157.0, 187.0, 209.0, 230.0, 270.0, 310.0, 334.0, 359.0, 399.0, 440.0, 481.0, 520.0, 570.0, 610.0, 650.0, 690.0, 730.0, 772.0, 1002.0, 1047.0, 1094.0, 1146.0, 1195.0, 1245.0, 1311.0, 1362.0, 1417.0, 1467.0, 1669.0, 1719.0, 1776.0, 1827.0, 1963.0, 2022.0, 2159.0, 2218.9, 3741.0, 3858.0, 3984.0, 4118.0, 4246.0, 4372.0, 4573.0, 4703.0, 4846.0, 4980.0, 5350.0, 5468.0, 5595.0, 5713.0, 6149.0, 6284.0, 6545.0, 6674.0, 14678.0, 14999.0, 15351.0, 15680.0, 17280.0, 17680.0, 18180.0, 18502.32, 74565.93, 76077.8], "Electron affinity": 0.17807}, "Hg": {"Atomic mass": 200.59, "Atomic no": 80, "Atomic orbitals": {"1s": -2755.022637, "2p": -443.848676, "2s": -461.27864, "3d": -84.845492, "3p": -100.328031, "3s": -108.597921, "4d": -13.019221, "4f": -4.110291, "4p": -19.636187, "4s": -23.222921, "5d": -0.452552, "5p": -2.261975, "5s": -3.423486, "6s": -0.205137}, "Atomic radius": 1.5, "Atomic radius calculated": 1.71, "Boiling point": "629.88 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "25 GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [1, 2], "Critical temperature": "1750 K", "Density of solid": "no data kg m-3", "Electrical resistivity": "96 10-8 Ω m", "Electronic structure": "[Xe].4f14.5d10.6s2", "ICSD oxidation states": [1, 2], "Ionic radii": {"1": 1.33, "2": 1.16}, "Liquid range": "395.56 K", "Melting point": "234.32 K", "Mendeleev no": 74, "Mineral hardness": "1.5", "Molar volume": "14.09 cm3", "Name": "Mercury", "Oxidation states": [1, 2, 4], "Poissons ratio": "no data", "Reflectivity": "73 %", "Refractive index": "1.000933", "Rigidity modulus": "no data GPa", "Shannon radii": {"1": {"III": {"": {"crystal_radius": 1.11, "ionic_radius": 0.97}}, "VI": {"": {"crystal_radius": 1.33, "ionic_radius": 1.19}}}, "2": {"II": {"": {"crystal_radius": 0.83, "ionic_radius": 0.69}}, "IV": {"": {"crystal_radius": 1.1, "ionic_radius": 0.96}}, "VI": {"": {"crystal_radius": 1.16, "ionic_radius": 1.02}}, "VIII": {"": {"crystal_radius": 1.28, "ionic_radius": 1.14}}}}, "Superconduction temperature": "3.95 K", "Thermal conductivity": "8.3 W m-1 K-1", "Van der waals radius": 2.23, "Velocity of sound": "1407 m s-1", "Vickers hardness": "no data MN m-2", "X": 2.0, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": {"Hg-201": 387.6}, "Metallic radius": 1.51, "iupac_ordering": 74, "IUPAC ordering": 74, "Ground level": "1S0", "Ionization energies": [10.437504, 18.75688, 34.49, 48.55, 61.2, 76.6, 93.0, 113.9, 134.0, 153.0, 173.0, 192.7, 276.9, 307.0, 332.0, 357.0, 402.0, 429.0, 477.0, 530.0, 560.0, 590.0, 650.0, 710.0, 760.0, 820.0, 880.0, 930.0, 990.0, 1050.0, 1110.0, 1160.0, 1220.0, 1280.0, 1549.0, 1603.0, 1661.0, 1723.0, 1780.0, 1839.0, 1928.0, 1989.0, 2052.0, 2113.0, 2354.0, 2412.0, 2478.0, 2539.0, 2745.0, 2815.0, 2981.0, 3049.9, 5055.0, 5191.0, 5335.0, 5490.0, 5636.0, 5780.0, 6041.0, 6192.0, 6356.0, 6508.0, 6933.0, 7066.0, 7211.0, 7350.0, 8010.0, 8160.0, 8470.0, 8620.0, 18550.0, 18910.0, 19310.0, 19680.0, 22120.0, 22580.0, 23170.0, 23544.1, 94124.7, 95897.7], "Electron affinity": -0.52}, "Ho": {"Atomic mass": 164.93032, "Atomic no": 67, "Atomic orbitals": {"1s": -1902.051908, "2p": -291.700994, "2s": -305.739294, "3d": -49.565996, "3p": -61.436304, "3s": -67.785492, "4d": -5.906195, "4f": -0.272677, "4p": -10.455303, "4s": -12.985498, "5p": -0.919463, "5s": -1.582088, "6s": -0.133845}, "Atomic radius": 1.75, "Atomic radius calculated": "no data", "Boiling point": "2993 K", "Brinell hardness": "746 MN m-2", "Bulk modulus": "40 GPa", "Coefficient of linear thermal expansion": "11.2 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "8795 kg m-3", "Electrical resistivity": "81.4 10-8 Ω m", "Electronic structure": "[Xe].4f11.6s2", "ICSD oxidation states": [3], "Ionic radii": {"3": 1.041}, "Liquid range": "1259 K", "Melting point": "1734 K", "Mendeleev no": 23, "Mineral hardness": "no data", "Molar volume": "18.74 cm3", "Name": "Holmium", "Oxidation states": [3], "Poissons ratio": "0.23", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "26 GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 1.041, "ionic_radius": 0.901}}, "VIII": {"": {"crystal_radius": 1.155, "ionic_radius": 1.015}}, "IX": {"": {"crystal_radius": 1.212, "ionic_radius": 1.072}}, "X": {"": {"crystal_radius": 1.26, "ionic_radius": 1.12}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "16 W m-1 K-1", "Van der waals radius": 2.3, "Velocity of sound": "2760 m s-1", "Vickers hardness": "481 MN m-2", "X": 1.23, "Youngs modulus": "65 GPa", "Metallic radius": 1.765, "iupac_ordering": 37, "IUPAC ordering": 37, "Ground level": "4I\u00b015/2", "Ionization energies": [6.0215, 11.781, 22.79, 42.52, 63.9, 95.0, 112.0, 129.0, 155.0, 173.0, 197.0, 229.0, 263.0, 284.0, 305.0, 340.0, 373.0, 408.0, 441.0, 475.0, 510.0, 715.0, 755.0, 797.0, 842.0, 885.0, 929.0, 985.0, 1029.0, 1077.0, 1122.0, 1300.0, 1346.0, 1395.0, 1443.0, 1545.0, 1598.0, 1719.0, 1773.6, 3018.0, 3125.0, 3238.0, 3359.0, 3476.0, 3592.0, 3760.0, 3880.0, 4009.0, 4131.0, 4469.0, 4576.0, 4693.0, 4802.0, 5135.0, 5258.0, 5494.0, 5611.0, 12495.0, 12790.0, 13116.0, 13417.0, 14639.0, 14998.0, 15448.0, 15745.77, 63772.43, 65136.8], "Electron affinity": 0.338}, "I": {"Atomic mass": 126.90447, "Atomic no": 53, "Atomic orbitals": {"1s": -1161.787047, "2p": -164.603788, "2s": -175.073804, "3d": -22.600693, "3p": -30.831092, "3s": -35.243351, "4d": -1.938179, "4p": -4.572522, "4s": -6.115811, "5p": -0.267904, "5s": -0.596339}, "Atomic radius": 1.4, "Atomic radius calculated": 1.15, "Boiling point": "457.4 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "7.7 GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [-1, 1, 3, 5, 7], "Critical temperature": "819 K", "Density of solid": "4940 kg m-3", "Electrical resistivity": "> 101510-8 Ω m", "Electronic structure": "[Kr].4d10.5s2.5p5", "ICSD oxidation states": [5, -1], "Ionic radii": {"-1": 2.06, "5": 1.09, "7": 0.67}, "Liquid range": "70.55 K", "Melting point": "386.85 K", "Mendeleev no": 97, "Mineral hardness": "no data", "Molar volume": "25.72 cm3", "Name": "Iodine", "Oxidation states": [-1, 1, 3, 5, 7], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"-1": {"VI": {"": {"crystal_radius": 2.06, "ionic_radius": 2.2}}}, "5": {"IIIPY": {"": {"crystal_radius": 0.58, "ionic_radius": 0.44}}, "VI": {"": {"crystal_radius": 1.09, "ionic_radius": 0.95}}}, "7": {"IV": {"": {"crystal_radius": 0.56, "ionic_radius": 0.42}}, "VI": {"": {"crystal_radius": 0.67, "ionic_radius": 0.53}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "0.449 W m-1 K-1", "Van der waals radius": 1.98, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 2.66, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": {"I-127": -696.12, "I-129": -604.1}, "Metallic radius": "no data", "iupac_ordering": 99, "IUPAC ordering": 99, "Ground level": "2P\u00b03/2", "Ionization energies": [10.45126, 19.13126, 29.57, 40.357, 51.52, 74.4, 87.61, 150.81, 171.0, 197.0, 220.9, 247.0, 279.0, 307.0, 335.0, 365.0, 393.0, 505.0, 535.0, 569.0, 601.0, 649.0, 683.0, 762.0, 800.8, 1397.0, 1472.0, 1553.0, 1639.0, 1720.0, 1812.0, 1911.0, 1999.0, 2093.0, 2181.0, 2431.0, 2510.0, 2598.0, 2680.0, 2836.0, 2926.0, 3096.0, 3185.5, 7337.0, 7563.0, 7811.0, 8044.0, 8601.0, 8867.0, 9196.0, 9421.1, 38716.996, 39721.41], "Electron affinity": 3.05905238}, "In": {"Atomic mass": 114.818, "Atomic no": 49, "Atomic orbitals": {"1s": -983.647445, "2p": -134.628845, "2s": -144.078357, "3d": -16.139823, "3p": -23.345778, "3s": -27.2206, "4d": -0.730481, "4p": -2.795832, "4s": -4.062639, "5p": -0.101782, "5s": -0.290497}, "Atomic radius": 1.55, "Atomic radius calculated": 1.56, "Boiling point": "2345 K", "Brinell hardness": "8.83 MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "32.1 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "7310 kg m-3", "Electrical resistivity": "8 10-8 Ω m", "Electronic structure": "[Kr].4d10.5s2.5p1", "ICSD oxidation states": [1, 2, 3], "Ionic radii": {"3": 0.94}, "Liquid range": "1915.25 K", "Melting point": "429.75 K", "Mendeleev no": 79, "Mineral hardness": "1.2", "Molar volume": "15.76 cm3", "Name": "Indium", "Oxidation states": [1, 2, 3], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"3": {"IV": {"": {"crystal_radius": 0.76, "ionic_radius": 0.62}}, "VI": {"": {"crystal_radius": 0.94, "ionic_radius": 0.8}}, "VIII": {"": {"crystal_radius": 1.06, "ionic_radius": 0.92}}}}, "Superconduction temperature": "3.41 K", "Thermal conductivity": "82 W m-1 K-1", "Van der waals radius": 1.93, "Velocity of sound": "1215 m s-1", "Vickers hardness": "no data MN m-2", "X": 1.78, "Youngs modulus": "11 GPa", "NMR Quadrupole Moment": {"In-113": 759.8, "In-115": 770.8}, "Metallic radius": 1.67, "iupac_ordering": 78, "IUPAC ordering": 78, "Ground level": "2P\u00b01/2", "Ionization energies": [5.7863557, 18.87041, 28.04415, 55.45, 69.3, 90.0, 109.0, 130.1, 156.0, 178.0, 201.0, 226.0, 249.0, 341.0, 368.0, 396.0, 425.0, 462.0, 497.1, 560.0, 593.38, 1043.0, 1109.0, 1181.0, 1255.0, 1328.0, 1413.0, 1496.0, 1575.0, 1659.0, 1738.0, 1961.0, 2028.5, 2111.0, 2207.0, 2317.0, 2373.0, 2555.0, 2628.77, 6126.0, 6331.0, 6554.0, 6770.0, 7196.0, 7442.0, 7754.0, 7953.14, 32837.592, 33750.31], "Electron affinity": 0.383926}, "Ir": {"Atomic mass": 192.217, "Atomic no": 77, "Atomic orbitals": {"1s": -2543.761342, "2p": -405.526834, "2s": -422.159424, "3d": -75.485027, "3p": -90.108427, "3s": -97.923081, "4d": -10.856593, "4f": -2.738339, "4p": -16.966578, "4s": -20.29429, "5d": -0.335189, "5p": -1.883349, "5s": -2.909174, "6s": -0.195511}, "Atomic radius": 1.35, "Atomic radius calculated": 1.8, "Boiling point": "4701 K", "Brinell hardness": "1670 MN m-2", "Bulk modulus": "320 GPa", "Coefficient of linear thermal expansion": "6.4 x10-6K-1", "Common oxidation states": [3, 4], "Critical temperature": "no data K", "Density of solid": "22650 kg m-3", "Electrical resistivity": "4.7 10-8 Ω m", "Electronic structure": "[Xe].4f14.5d7.6s2", "ICSD oxidation states": [3, 4, 5], "Ionic radii": {"3": 0.82, "4": 0.765, "5": 0.71}, "Liquid range": "1962 K", "Melting point": "2739 K", "Mendeleev no": 66, "Mineral hardness": "6.5", "Molar volume": "8.52 cm3", "Name": "Iridium", "Oxidation states": [-3, -1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "0.26", "Reflectivity": "78 %", "Refractive index": "no data", "Rigidity modulus": "210 GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 0.82, "ionic_radius": 0.68}}}, "4": {"VI": {"": {"crystal_radius": 0.765, "ionic_radius": 0.625}}}, "5": {"VI": {"": {"crystal_radius": 0.71, "ionic_radius": 0.57}}}}, "Superconduction temperature": "0.11 K", "Thermal conductivity": "150 W m-1 K-1", "Van der waals radius": 2.13, "Velocity of sound": "4825 m s-1", "Vickers hardness": "1760 MN m-2", "X": 2.2, "Youngs modulus": "528 GPa", "Metallic radius": 1.357, "iupac_ordering": 65, "IUPAC ordering": 65, "Ground level": "4F9/2", "Ionization energies": [8.96702, 17.0, 28.0, 40.0, 57.0, 72.0, 89.0, 105.0, 122.7, 194.8, 217.0, 240.0, 264.0, 303.0, 329.0, 356.0, 407.0, 445.0, 472.0, 510.0, 560.0, 610.0, 670.0, 720.0, 770.0, 820.0, 870.0, 920.0, 980.0, 1030.0, 1080.0, 1331.0, 1381.0, 1436.0, 1493.0, 1548.0, 1603.0, 1684.0, 1739.0, 1801.0, 1857.0, 2083.0, 2139.0, 2201.0, 2258.0, 2435.0, 2500.0, 2656.0, 2720.4, 4540.0, 4668.0, 4806.0, 4952.0, 5092.0, 5229.0, 5466.0, 5609.0, 5765.0, 5910.0, 6315.0, 6441.0, 6580.0, 6708.0, 7274.0, 7421.0, 7710.0, 7850.0, 17040.0, 17390.0, 17770.0, 18120.0, 20210.0, 20650.0, 21200.0, 21556.6, 86438.9, 88113.3], "Electron affinity": 1.5643615}, "K": {"Atomic mass": 39.0983, "Atomic no": 19, "Atomic orbitals": {"1s": -128.414957, "2p": -10.283851, "2s": -12.839001, "3p": -0.693776, "3s": -1.281897, "4s": -0.088815}, "Atomic radius": 2.2, "Atomic radius calculated": 2.43, "Boiling point": "1032 K", "Brinell hardness": "0.363 MN m-2", "Bulk modulus": "3.1 GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [1], "Critical temperature": "2223 K", "Density of solid": "856 kg m-3", "Electrical resistivity": "7.5 10-8 Ω m", "Electronic structure": "[Ar].4s1", "ICSD oxidation states": [1], "Ionic radii": {"1": 1.52}, "Liquid range": "695.47 K", "Melting point": "336.53 K", "Mendeleev no": 10, "Mineral hardness": "0.4", "Molar volume": "45.94 cm3", "Name": "Potassium", "Oxidation states": [-1, 1], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "1.3 GPa", "Shannon radii": {"1": {"IV": {"": {"crystal_radius": 1.51, "ionic_radius": 1.37}}, "VI": {"": {"crystal_radius": 1.52, "ionic_radius": 1.38}}, "VII": {"": {"crystal_radius": 1.6, "ionic_radius": 1.46}}, "VIII": {"": {"crystal_radius": 1.65, "ionic_radius": 1.51}}, "IX": {"": {"crystal_radius": 1.69, "ionic_radius": 1.55}}, "X": {"": {"crystal_radius": 1.73, "ionic_radius": 1.59}}, "XII": {"": {"crystal_radius": 1.78, "ionic_radius": 1.64}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "100 W m-1 K-1", "Van der waals radius": 2.75, "Velocity of sound": "2000 m s-1", "Vickers hardness": "no data MN m-2", "X": 0.82, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": {"K-39": 58.5, "K-40": -73.0, "K-41": 71.1}, "Metallic radius": 2.381, "iupac_ordering": 9, "IUPAC ordering": 9, "Ground level": "2S1/2", "Ionization energies": [4.34066373, 31.625, 45.8031, 60.917, 82.66, 99.44, 117.56, 154.87, 175.8174, 503.67, 565.6, 631.1, 714.7, 786.3, 860.92, 967.7, 1034.542, 4610.87018, 4934.0484], "Electron affinity": 0.50145913}, "Kr": {"Atomic mass": 83.798, "Atomic no": 36, "Atomic orbitals": {"1s": -509.982989, "2p": -60.017328, "2s": -66.285953, "3d": -3.074109, "3p": -7.086634, "3s": -9.315192, "4p": -0.34634, "4s": -0.820574}, "Atomic radius": "no data", "Atomic radius calculated": 0.88, "Boiling point": "119.93 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Critical temperature": "209.4 K", "Density of solid": "no data kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[Ar].3d10.4s2.4p6", "Liquid range": "4.14 K", "Max oxidation state": 0.0, "Melting point": "115.79 K", "Mendeleev no": 4, "Min oxidation state": 0.0, "Mineral hardness": "no data", "Molar volume": "27.99 cm3", "Name": "Krypton", "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "1.000427", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "0.00943 W m-1 K-1", "Van der waals radius": 2.02, "Velocity of sound": "1120 m s-1", "Vickers hardness": "no data MN m-2", "X": 3.0, "Youngs modulus": "no data GPa", "Metallic radius": "no data", "iupac_ordering": 2, "IUPAC ordering": 2, "Ground level": "1S0", "Ionization energies": [13.9996055, 24.35984, 35.838, 50.85, 64.69, 78.49, 109.13, 125.802, 233.0, 268.0, 308.0, 350.0, 391.0, 446.0, 492.0, 540.0, 591.0, 640.0, 785.0, 831.6, 882.8, 945.0, 999.0, 1042.0, 1155.0, 1205.23, 2928.9, 3072.0, 3228.0, 3380.0, 3584.0, 3752.0, 3971.0, 4109.083, 17296.421, 17936.209], "Electron affinity": -1.02}, "La": {"Atomic mass": 138.90547, "Atomic no": 57, "Atomic orbitals": {"1s": -1355.622446, "2p": -198.325243, "2s": -209.831151, "3d": -30.626696, "3p": -39.895838, "3s": -44.856283, "4d": -3.95801, "4p": -7.167724, "4s": -9.000543, "5d": -0.141085, "5p": -0.824498, "5s": -1.324936, "6s": -0.132233}, "Atomic radius": 1.95, "Atomic radius calculated": "no data", "Boiling point": "3743 K", "Brinell hardness": "363 MN m-2", "Bulk modulus": "28 GPa", "Coefficient of linear thermal expansion": "12.1 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "6146 kg m-3", "Electrical resistivity": "61.5 10-8 Ω m", "Electronic structure": "[Xe].5d1.6s2", "ICSD oxidation states": [2, 3], "Ionic radii": {"3": 1.172}, "Liquid range": "2550 K", "Melting point": "1193 K", "Mendeleev no": 33, "Mineral hardness": "2.5", "Molar volume": "22.39 cm3", "Name": "Lanthanum", "Oxidation states": [2, 3], "Poissons ratio": "0.28", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "14 GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 1.172, "ionic_radius": 1.032}}, "VII": {"": {"crystal_radius": 1.24, "ionic_radius": 1.1}}, "VIII": {"": {"crystal_radius": 1.3, "ionic_radius": 1.16}}, "IX": {"": {"crystal_radius": 1.356, "ionic_radius": 1.216}}, "X": {"": {"crystal_radius": 1.41, "ionic_radius": 1.27}}, "XII": {"": {"crystal_radius": 1.5, "ionic_radius": 1.36}}}}, "Superconduction temperature": "6.00 K", "Thermal conductivity": "13 W m-1 K-1", "Van der waals radius": 2.43, "Velocity of sound": "2475 m s-1", "Vickers hardness": "491 MN m-2", "X": 1.1, "Youngs modulus": "37 GPa", "NMR Quadrupole Moment": {"La-139": 200.6}, "Metallic radius": 1.877, "iupac_ordering": 47, "IUPAC ordering": 47, "Ground level": "2D3/2", "Ionization energies": [5.5769, 11.18496, 19.1773, 49.95, 61.6, 74.0, 88.0, 105.0, 119.0, 151.4, 168.77, 275.0, 303.0, 332.0, 364.0, 393.0, 431.0, 464.0, 498.0, 533.0, 566.0, 696.0, 731.0, 770.0, 806.0, 865.0, 906.0, 995.0, 1039.09, 1800.0, 1884.0, 1974.0, 2069.0, 2162.0, 2259.0, 2377.0, 2473.0, 2577.0, 2674.0, 2950.0, 3036.0, 3133.0, 3222.0, 3416.0, 3515.0, 3704.0, 3800.0, 8669.0, 8914.0, 9184.0, 9437.0, 10136.0, 10426.0, 10789.0, 11033.4, 45144.996, 46245.6], "Electron affinity": 0.5575462}, "Li": {"Atomic mass": 6.941, "Atomic no": 3, "Atomic orbitals": {"1s": -1.878564, "2s": -0.10554}, "Atomic radius": 1.45, "Atomic radius calculated": 1.67, "Boiling point": "1615 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "11 GPa", "Coefficient of linear thermal expansion": "46 x10-6K-1", "Common oxidation states": [1], "Critical temperature": "3223 K", "Density of solid": "535 kg m-3", "Electrical resistivity": "9.5 10-8 Ω m", "Electronic structure": "[He].2s1", "ICSD oxidation states": [1], "Ionic radii": {"1": 0.9}, "Liquid range": "1161.31 K", "Melting point": "453.69 K", "Mendeleev no": 12, "Mineral hardness": "0.6", "Molar volume": "13.02 cm3", "Name": "Lithium", "Oxidation states": [1], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "4.2 GPa", "Shannon radii": {"1": {"IV": {"": {"crystal_radius": 0.73, "ionic_radius": 0.59}}, "VI": {"": {"crystal_radius": 0.9, "ionic_radius": 0.76}}, "VIII": {"": {"crystal_radius": 1.06, "ionic_radius": 0.92}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "85 W m-1 K-1", "Van der waals radius": 1.82, "Velocity of sound": "6000 m s-1", "Vickers hardness": "no data MN m-2", "X": 0.98, "Youngs modulus": "4.9 GPa", "NMR Quadrupole Moment": {"Li-6": -0.808, "Li-7": -40.1}, "Metallic radius": 1.52, "iupac_ordering": 11, "IUPAC ordering": 11, "Ground level": "2S1/2", "Ionization energies": [5.391714996, 75.640097, 122.45435914], "Electron affinity": 0.61804922}, "Lr": {"Atomic mass": 262.0, "Atomic no": 103, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "no data kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[Rn].5f14.7s2.7p1 (tentative)", "Liquid range": "no data K", "Melting point": "about 1900 K", "Mendeleev no": 34, "Mineral hardness": "no data", "Molar volume": "no data cm3", "Name": "Lawrencium", "Oxidation states": [3], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m-1 K-1", "Van der waals radius": "no data", "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 1.3, "Youngs modulus": "no data GPa", "Metallic radius": "no data", "iupac_ordering": 18, "IUPAC ordering": 18, "Ground level": "2P\u00b01/2", "Ionization energies": [4.96, 14.54, 21.8, 43.6, 56.0, 80.0, 96.0, 121.0, 143.0, 165.0, 197.0, 216.0, 244.0, 269.0, 290.0, 322.0, 344.0, 374.0, 403.0, 431.0, 459.0, 487.0, 510.0, 540.0, 560.0, 745.0, 779.0, 814.0, 852.0, 888.0, 922.0, 985.0, 1020.0, 1061.0, 1098.0, 1280.0, 1320.0, 1360.0, 1410.0, 1570.0, 1620.0, 1760.0, 1810.0, 2010.0, 2100.0, 2190.0, 2290.0, 2380.0, 2470.0, 2570.0, 2670.0, 2780.0, 2860.0, 2960.0, 3060.0, 3150.0, 3250.0, 3741.0, 3821.0, 3906.0, 3996.0, 4082.0, 4165.0, 4360.0, 4448.0, 4540.0, 4630.0, 4990.0, 5070.0, 5160.0, 5250.0, 5920.0, 6030.0, 6290.0, 6390.0, 9920.0, 10110.0, 10310.0, 10520.0, 10720.0, 10920.0, 11470.0, 11680.0, 11910.0, 12120.0, 12710.0, 12890.0, 13090.0, 13300.0, 15300.0, 15600.0, 16000.0, 16200.0, 32400.0, 32900.0, 33400.0, 33900.0, 41600.0, 42300.0, 43200.0, 43759.0, null, 172930.0], "Electron affinity": -0.31}, "Lu": {"Atomic mass": 174.967, "Atomic no": 71, "Atomic orbitals": {"1s": -2146.885351, "2p": -334.330902, "2s": -349.390492, "3d": -58.592982, "3p": -71.538779, "3s": -78.462398, "4d": -7.113364, "4f": -0.568096, "4p": -12.250904, "4s": -15.08337, "5d": -0.103686, "5p": -1.111991, "5s": -1.872086, "6s": -0.155112}, "Atomic radius": 1.75, "Atomic radius calculated": 2.17, "Boiling point": "3675 K", "Brinell hardness": "893 MN m-2", "Bulk modulus": "48 GPa", "Coefficient of linear thermal expansion": "9.9 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "9841 kg m-3", "Electrical resistivity": "58 10-8 Ω m", "Electronic structure": "[Xe].4f14.5d1.6s2", "ICSD oxidation states": [3], "Ionic radii": {"3": 1.001}, "Liquid range": "1750 K", "Melting point": "1925 K", "Mendeleev no": 20, "Mineral hardness": "no data", "Molar volume": "17.78 cm3", "Name": "Lutetium", "Oxidation states": [3], "Poissons ratio": "0.26", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "27 GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 1.001, "ionic_radius": 0.861}}, "VIII": {"": {"crystal_radius": 1.117, "ionic_radius": 0.977}}, "IX": {"": {"crystal_radius": 1.172, "ionic_radius": 1.032}}}}, "Superconduction temperature": "0.022 K", "Thermal conductivity": "16 W m-1 K-1", "Van der waals radius": 2.24, "Velocity of sound": "no data m s-1", "Vickers hardness": "1160 MN m-2", "X": 1.27, "Youngs modulus": "69 GPa", "Metallic radius": 1.735, "iupac_ordering": 33, "IUPAC ordering": 33, "Ground level": "2D3/2", "Ionization energies": [5.425871, 14.13, 20.9594, 45.249, 66.8, 98.0, 117.0, 136.0, 159.0, 185.0, 205.0, 238.0, 276.0, 305.0, 328.0, 361.0, 399.0, 438.0, 476.0, 520.0, 560.0, 600.0, 630.0, 670.0, 713.0, 941.0, 985.0, 1032.0, 1081.0, 1130.0, 1178.0, 1242.0, 1292.0, 1345.0, 1395.0, 1591.0, 1641.0, 1696.0, 1747.0, 1875.0, 1933.0, 2067.0, 2125.5, 3590.0, 3706.0, 3828.0, 3960.0, 4086.0, 4211.0, 4403.0, 4532.0, 4673.0, 4803.0, 5168.0, 5282.0, 5408.0, 5525.0, 5937.0, 6070.0, 6326.0, 6452.0, 14228.0, 14542.0, 14890.0, 15211.0, 16730.0, 17120.0, 17610.0, 17928.05, 72322.91, 73804.8], "Electron affinity": 0.23887}, "Md": {"Atomic mass": 258.0, "Atomic no": 101, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "no data kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[Rn].5f13.7s2", "Liquid range": "no data K", "Melting point": "about 1100 K", "Mendeleev no": 36, "Mineral hardness": "no data", "Molar volume": "no data cm3", "Name": "Mendelevium", "Oxidation states": [2, 3], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m-1 K-1", "Van der waals radius": 2.46, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 1.3, "Youngs modulus": "no data GPa", "Metallic radius": "no data", "iupac_ordering": 20, "IUPAC ordering": 20, "Ground level": "2F\u00b07/2", "Ionization energies": [6.58, 12.4, 24.3, 40.0, 54.1, 76.0, 96.0, 115.1, 143.9, 162.0, 187.0, 215.0, 240.0, 260.0, 282.0, 307.0, 334.0, 360.0, 386.0, 412.0, 438.0, 462.0, 486.0, 659.0, 690.0, 723.0, 760.0, 794.0, 828.0, 885.0, 920.0, 958.0, 994.0, 1160.0, 1210.0, 1250.0, 1290.0, 1430.0, 1480.0, 1620.0, 1660.0, 1840.0, 1930.0, 2020.0, 2110.0, 2200.0, 2290.0, 2390.0, 2480.0, 2580.0, 2680.0, 2760.0, 2860.0, 2950.0, 3050.0, 3513.0, 3592.0, 3675.0, 3762.0, 3845.0, 3926.0, 4109.0, 4194.0, 4286.0, 4371.0, 4720.0, 4800.0, 4890.0, 4970.0, 5580.0, 5680.0, 5930.0, 6030.0, 9430.0, 9620.0, 9810.0, 10020.0, 10220.0, 10410.0, 10930.0, 11130.0, 11350.0, 11560.0, 12130.0, 12310.0, 12500.0, 12680.0, 14560.0, 14800.0, 15200.0, 15400.0, 31000.0, 31500.0, 32000.0, 32500.0, 39500.0, 40100.0, 41000.0, 41548.0, null, 164764.0], "Electron affinity": 0.98}, "Mg": {"Atomic mass": 24.305, "Atomic no": 12, "Atomic orbitals": {"1s": -45.973167, "2p": -1.71897, "2s": -2.903746, "3s": -0.175427}, "Atomic radius": 1.5, "Atomic radius calculated": 1.45, "Boiling point": "1363 K", "Brinell hardness": "260 MN m-2", "Bulk modulus": "45 GPa", "Coefficient of linear thermal expansion": "8.2 x10-6K-1", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "1738 kg m-3", "Electrical resistivity": "4.4 10-8 Ω m", "Electronic structure": "[Ne].3s2", "ICSD oxidation states": [2], "Ionic radii": {"2": 0.86}, "Liquid range": "440 K", "Melting point": "923 K", "Mendeleev no": 73, "Mineral hardness": "2.5", "Molar volume": "14.00 cm3", "Name": "Magnesium", "Oxidation states": [1, 2], "Poissons ratio": "0.29", "Reflectivity": "74 %", "Refractive index": "no data", "Rigidity modulus": "17 GPa", "Shannon radii": {"2": {"IV": {"": {"crystal_radius": 0.71, "ionic_radius": 0.57}}, "V": {"": {"crystal_radius": 0.8, "ionic_radius": 0.66}}, "VI": {"": {"crystal_radius": 0.86, "ionic_radius": 0.72}}, "VIII": {"": {"crystal_radius": 1.03, "ionic_radius": 0.89}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "160 W m-1 K-1", "Van der waals radius": 1.73, "Velocity of sound": "4602 m s-1", "Vickers hardness": "no data MN m-2", "X": 1.31, "Youngs modulus": "45 GPa", "NMR Quadrupole Moment": {"Mg-25": 199.4}, "Metallic radius": 1.6, "iupac_ordering": 16, "IUPAC ordering": 16, "Ground level": "1S0", "Ionization energies": [7.646236, 15.035271, 80.1436, 109.2654, 141.33, 186.76, 225.02, 265.924, 327.99, 367.489, 1761.80488, 1962.66366], "Electron affinity": -0.42}, "Mn": {"Atomic mass": 54.938045, "Atomic no": 25, "Atomic orbitals": {"1s": -233.696912, "2p": -23.066297, "2s": -26.866646, "3d": -0.26654, "3p": -1.99145, "3s": -3.076637, "4s": -0.191136}, "Atomic radius": 1.4, "Atomic radius calculated": 1.61, "Boiling point": "2334 K", "Brinell hardness": "196 MN m-2", "Bulk modulus": "120 GPa", "Coefficient of linear thermal expansion": "21.7 x10-6K-1", "Common oxidation states": [2, 4, 7], "Critical temperature": "no data K", "Density of solid": "7470 kg m-3", "Electrical resistivity": "144 10-8 Ω m", "Electronic structure": "[Ar].3d5.4s2", "ICSD oxidation states": [2, 3, 4, 7], "Ionic radii": {"2": 0.97, "3": 0.785, "4": 0.67, "5": 0.47, "6": 0.395, "7": 0.6}, "Ionic radii hs": {"2": 0.97, "3": 0.785}, "Ionic radii ls": {"2": 0.81, "3": 0.72, "4": 0.67, "5": 0.47, "6": 0.395, "7": 0.6}, "Liquid range": "815 K", "Melting point": "1519 K", "Mendeleev no": 60, "Mineral hardness": "6.0", "Molar volume": "7.35 cm3", "Name": "Manganese", "Oxidation states": [-3, -2, -1, 1, 2, 3, 4, 5, 6, 7], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"2": {"IV": {"High Spin": {"crystal_radius": 0.8, "ionic_radius": 0.66}}, "V": {"High Spin": {"crystal_radius": 0.89, "ionic_radius": 0.75}}, "VI": {"Low Spin": {"crystal_radius": 0.81, "ionic_radius": 0.67}, "High Spin": {"crystal_radius": 0.97, "ionic_radius": 0.83}}, "VII": {"High Spin": {"crystal_radius": 1.04, "ionic_radius": 0.9}}, "VIII": {"": {"crystal_radius": 1.1, "ionic_radius": 0.96}}}, "3": {"V": {"": {"crystal_radius": 0.72, "ionic_radius": 0.58}}, "VI": {"Low Spin": {"crystal_radius": 0.72, "ionic_radius": 0.58}, "High Spin": {"crystal_radius": 0.785, "ionic_radius": 0.645}}}, "4": {"IV": {"": {"crystal_radius": 0.53, "ionic_radius": 0.39}}, "VI": {"": {"crystal_radius": 0.67, "ionic_radius": 0.53}}}, "5": {"IV": {"": {"crystal_radius": 0.47, "ionic_radius": 0.33}}}, "6": {"IV": {"": {"crystal_radius": 0.395, "ionic_radius": 0.255}}}, "7": {"IV": {"": {"crystal_radius": 0.39, "ionic_radius": 0.25}}, "VI": {"": {"crystal_radius": 0.6, "ionic_radius": 0.46}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "7.8 W m-1 K-1", "Van der waals radius": 2.05, "Velocity of sound": "5150 m s-1", "Vickers hardness": "no data MN m-2", "X": 1.55, "Youngs modulus": "198 GPa", "NMR Quadrupole Moment": {"Mn-55": 330.1}, "Metallic radius": 1.292, "iupac_ordering": 61, "IUPAC ordering": 61, "Ground level": "6S5/2", "Ionization energies": [7.434038, 15.63999, 33.668, 51.21, 72.41, 95.604, 119.203, 195.5, 221.89, 248.6, 286.1, 314.4, 343.6, 402.95, 435.172, 1133.7, 1224.1, 1320.3, 1430.9, 1537.2, 1643.2, 1788.7, 1879.873, 8140.7872, 8571.9488], "Electron affinity": -0.52}, "Mo": {"Atomic mass": 95.94, "Atomic no": 42, "Atomic orbitals": {"1s": -709.232119, "2p": -90.791541, "2s": -98.503638, "3d": -8.257721, "3p": -13.71481, "3s": -16.681545, "4d": -0.153347, "4p": -1.39005, "4s": -2.234824, "5s": -0.14788}, "Atomic radius": 1.45, "Atomic radius calculated": 1.9, "Boiling point": "4912 K", "Brinell hardness": "1500 MN m-2", "Bulk modulus": "230 GPa", "Coefficient of linear thermal expansion": "4.8 x10-6K-1", "Common oxidation states": [4, 6], "Critical temperature": "no data K", "Density of solid": "10280 kg m-3", "Electrical resistivity": "5.5 10-8 Ω m", "Electronic structure": "[Kr].4d5.5s1", "ICSD oxidation states": [2, 3, 4, 5, 6], "Ionic radii": {"3": 0.83, "4": 0.79, "5": 0.75, "6": 0.73}, "Liquid range": "2016 K", "Melting point": "2896 K", "Mendeleev no": 56, "Mineral hardness": "5.5", "Molar volume": "9.38 cm3", "Name": "Molybdenum", "Oxidation states": [-2, -1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "0.31", "Reflectivity": "58 %", "Refractive index": "no data", "Rigidity modulus": "20 GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 0.83, "ionic_radius": 0.69}}}, "4": {"VI": {"": {"crystal_radius": 0.79, "ionic_radius": 0.65}}}, "5": {"IV": {"": {"crystal_radius": 0.6, "ionic_radius": 0.46}}, "VI": {"": {"crystal_radius": 0.75, "ionic_radius": 0.61}}}, "6": {"IV": {"": {"crystal_radius": 0.55, "ionic_radius": 0.41}}, "V": {"": {"crystal_radius": 0.64, "ionic_radius": 0.5}}, "VI": {"": {"crystal_radius": 0.73, "ionic_radius": 0.59}}, "VII": {"": {"crystal_radius": 0.87, "ionic_radius": 0.73}}}}, "Superconduction temperature": "0.915 K", "Thermal conductivity": "139 W m-1 K-1", "Van der waals radius": 2.17, "Velocity of sound": "6190 m s-1", "Vickers hardness": "1530 MN m-2", "X": 2.16, "Youngs modulus": "329 GPa", "Metallic radius": 1.402, "iupac_ordering": 57, "IUPAC ordering": 57, "Ground level": "7S3", "Ionization energies": [7.09243, 16.16, 27.13, 40.33, 54.417, 68.82704, 125.638, 143.6, 164.12, 186.3, 209.3, 230.28, 279.1, 302.6, 544.0, 591.0, 646.0, 702.0, 758.0, 829.0, 890.0, 953.0, 1019.0, 1082.0, 1263.0, 1319.6, 1385.1, 1462.0, 1537.0, 1587.0, 1730.1, 1790.93, 4259.0, 4430.0, 4618.0, 4800.0, 5084.0, 5287.0, 5548.0, 5713.194, 23810.654, 24572.156], "Electron affinity": 0.74733}, "N": {"Atomic mass": 14.0067, "Atomic no": 7, "Atomic orbitals": {"1s": -14.011501, "2p": -0.266297, "2s": -0.676151}, "Atomic radius": 0.65, "Atomic radius calculated": 0.56, "Boiling point": "77.36 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [-3, 3, 5], "Critical temperature": "126.2 K", "Density of solid": "no data kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[He].2s2.2p3", "ICSD oxidation states": [1, 3, 5, -1, -3, -2], "Ionic radii": {"-3": 1.32, "3": 0.3, "5": 0.27}, "Liquid range": "14.31 K", "Melting point": "63.05 K", "Mendeleev no": 100, "Mineral hardness": "no data", "Molar volume": "13.54 cm3", "Name": "Nitrogen", "Oxidation states": [-3, -2, -1, 1, 2, 3, 4, 5], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "1.000298 (gas; liquid 1.197)(no units)", "Rigidity modulus": "no data GPa", "Shannon radii": {"-3": {"IV": {"": {"crystal_radius": 1.32, "ionic_radius": 1.46}}}, "3": {"VI": {"": {"crystal_radius": 0.3, "ionic_radius": 0.16}}}, "5": {"III": {"": {"crystal_radius": 0.044, "ionic_radius": -0.104}}, "VI": {"": {"crystal_radius": 0.27, "ionic_radius": 0.13}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "0.02583 W m-1 K-1", "Van der waals radius": 1.55, "Velocity of sound": "333.6 m s-1", "Vickers hardness": "no data MN m-2", "X": 3.04, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": {"N-14": 20.44}, "Metallic radius": "no data", "iupac_ordering": 91, "IUPAC ordering": 91, "Ground level": "4S\u00b03/2", "Ionization energies": [14.53413, 29.60125, 47.4453, 77.4735, 97.8901, 552.06733, 667.046121], "Electron affinity": -0.07}, "Na": {"Atomic mass": 22.98976928, "Atomic no": 11, "Atomic orbitals": {"1s": -37.719975, "2p": -1.060636, "2s": -2.063401, "3s": -0.103415}, "Atomic radius": 1.8, "Atomic radius calculated": 1.9, "Boiling point": "1156 K", "Brinell hardness": "0.69 MN m-2", "Bulk modulus": "6.3 GPa", "Coefficient of linear thermal expansion": "71 x10-6K-1", "Common oxidation states": [1], "Critical temperature": "2573 K", "Density of solid": "968 kg m-3", "Electrical resistivity": "4.9 10-8 Ω m", "Electronic structure": "[Ne].3s1", "ICSD oxidation states": [1], "Ionic radii": {"1": 1.16}, "Liquid range": "785.13 K", "Melting point": "370.87 K", "Mendeleev no": 11, "Mineral hardness": "0.5", "Molar volume": "23.78 cm3", "Name": "Sodium", "Oxidation states": [-1, 1], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "3.3 GPa", "Shannon radii": {"1": {"IV": {"": {"crystal_radius": 1.13, "ionic_radius": 0.99}}, "V": {"": {"crystal_radius": 1.14, "ionic_radius": 1.0}}, "VI": {"": {"crystal_radius": 1.16, "ionic_radius": 1.02}}, "VII": {"": {"crystal_radius": 1.26, "ionic_radius": 1.12}}, "VIII": {"": {"crystal_radius": 1.32, "ionic_radius": 1.18}}, "IX": {"": {"crystal_radius": 1.38, "ionic_radius": 1.24}}, "XII": {"": {"crystal_radius": 1.53, "ionic_radius": 1.39}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "140 W m-1 K-1", "Van der waals radius": 2.27, "Velocity of sound": "3200 m s-1", "Vickers hardness": "no data MN m-2", "X": 0.93, "Youngs modulus": "10 GPa", "NMR Quadrupole Moment": {"Na-23": 104.1}, "Metallic radius": 1.86, "iupac_ordering": 10, "IUPAC ordering": 10, "Ground level": "2S1/2", "Ionization energies": [5.13907696, 47.28636, 71.62, 98.936, 138.404, 172.23, 208.504, 264.192, 299.856, 1465.134502, 1648.7022], "Electron affinity": 0.54792625}, "Nb": {"Atomic mass": 92.90638, "Atomic no": 41, "Atomic orbitals": {"1s": -673.76253, "2p": -85.272175, "2s": -92.74086, "3d": -7.339839, "3p": -12.552855, "3s": -15.393727, "4d": -0.125252, "4p": -1.250049, "4s": -2.036693, "5s": -0.144272}, "Atomic radius": 1.45, "Atomic radius calculated": 1.98, "Boiling point": "5017 K", "Brinell hardness": "736 MN m-2", "Bulk modulus": "170 GPa", "Coefficient of linear thermal expansion": "7.3 x10-6K-1", "Common oxidation states": [5], "Critical temperature": "no data K", "Density of solid": "8570 kg m-3", "Electrical resistivity": "15.2 10-8 Ω m", "Electronic structure": "[Kr].4d4.5s1", "ICSD oxidation states": [2, 3, 4, 5], "Ionic radii": {"3": 0.86, "4": 0.82, "5": 0.78}, "Liquid range": "2267 K", "Melting point": "2750 K", "Mendeleev no": 53, "Mineral hardness": "6.0", "Molar volume": "10.83 cm3", "Name": "Niobium", "Oxidation states": [-1, 2, 3, 4, 5], "Poissons ratio": "0.40", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "38 GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 0.86, "ionic_radius": 0.72}}}, "4": {"VI": {"": {"crystal_radius": 0.82, "ionic_radius": 0.68}}, "VIII": {"": {"crystal_radius": 0.93, "ionic_radius": 0.79}}}, "5": {"IV": {"": {"crystal_radius": 0.62, "ionic_radius": 0.48}}, "VI": {"": {"crystal_radius": 0.78, "ionic_radius": 0.64}}, "VII": {"": {"crystal_radius": 0.83, "ionic_radius": 0.69}}, "VIII": {"": {"crystal_radius": 0.88, "ionic_radius": 0.74}}}}, "Superconduction temperature": "9.25 K", "Thermal conductivity": "54 W m-1 K-1", "Van der waals radius": 2.18, "Velocity of sound": "3480 m s-1", "Vickers hardness": "1320 MN m-2", "X": 1.6, "Youngs modulus": "105 GPa", "Metallic radius": 1.473, "iupac_ordering": 54, "IUPAC ordering": 54, "Ground level": "6D1/2", "Ionization energies": [6.75885, 14.32, 25.04, 37.611, 50.5728, 102.069, 119.1, 136.0, 159.2, 180.0, 200.28, 246.1, 268.59, 482.5, 530.0, 581.0, 636.0, 688.0, 758.0, 816.0, 877.0, 940.0, 1000.0, 1176.0, 1230.6, 1293.7, 1368.0, 1439.0, 1488.0, 1625.9, 1684.97, 4020.1, 4187.0, 4369.0, 4540.0, 4815.0, 5011.0, 5265.0, 5426.066, 22648.046, 23388.801], "Electron affinity": 0.917407}, "Nd": {"Atomic mass": 144.242, "Atomic no": 60, "Atomic orbitals": {"1s": -1509.698955, "2p": -224.351816, "2s": -236.613572, "3d": -35.754515, "3p": -45.791219, "3s": -51.161263, "4d": -4.377027, "4f": -0.179508, "4p": -7.96782, "4s": -10.000891, "5p": -0.798503, "5s": -1.334934, "6s": -0.125796}, "Atomic radius": 1.85, "Atomic radius calculated": 2.06, "Boiling point": "3373 K", "Brinell hardness": "265 MN m-2", "Bulk modulus": "32 GPa", "Coefficient of linear thermal expansion": "9.6 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "6800 kg m-3", "Electrical resistivity": "64.3 10-8 Ω m", "Electronic structure": "[Xe].4f4.6s2", "ICSD oxidation states": [2, 3], "Ionic radii": {"2": 1.43, "3": 1.123}, "Liquid range": "2076 K", "Melting point": "1297 K", "Mendeleev no": 30, "Mineral hardness": "no data", "Molar volume": "20.59 cm3", "Name": "Neodymium", "Oxidation states": [2, 3], "Poissons ratio": "0.28", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "16 GPa", "Shannon radii": {"2": {"VIII": {"": {"crystal_radius": 1.43, "ionic_radius": 1.29}}, "IX": {"": {"crystal_radius": 1.49, "ionic_radius": 1.35}}}, "3": {"VI": {"": {"crystal_radius": 1.123, "ionic_radius": 0.983}}, "VIII": {"": {"crystal_radius": 1.249, "ionic_radius": 1.109}}, "IX": {"": {"crystal_radius": 1.303, "ionic_radius": 1.163}}, "XII": {"": {"crystal_radius": 1.41, "ionic_radius": 1.27}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "17 W m-1 K-1", "Van der waals radius": 2.39, "Velocity of sound": "2330 m s-1", "Vickers hardness": "343 MN m-2", "X": 1.14, "Youngs modulus": "41 GPa", "Metallic radius": 1.821, "iupac_ordering": 44, "IUPAC ordering": 44, "Ground level": "5I4", "Ionization energies": [5.525, 10.783, 22.09, 40.6, 60.0, 84.0, 99.0, 114.0, 136.0, 152.0, 168.0, 195.0, 221.0, 243.0, 389.0, 420.0, 453.0, 489.0, 522.0, 562.0, 602.0, 638.0, 678.0, 714.0, 859.0, 896.0, 939.0, 978.0, 1049.0, 1092.0, 1191.0, 1238.42, 2134.0, 2224.0, 2321.0, 2425.0, 2525.0, 2627.0, 2758.0, 2861.0, 2974.0, 3078.0, 3371.0, 3465.0, 3567.0, 3662.0, 3891.0, 3997.0, 4198.0, 4302.0, 9742.0, 10002.0, 10288.0, 10555.0, 11384.0, 11694.0, 12082.0, 12341.66, 50339.59, 51515.58], "Electron affinity": 0.0974933}, "Ne": {"Atomic mass": 20.1797, "Atomic no": 10, "Atomic orbitals": {"1s": -30.305855, "2p": -0.498034, "2s": -1.322809}, "Atomic radius": "no data", "Atomic radius calculated": 0.38, "Boiling point": "27.07 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Critical temperature": "44.4 K", "Density of solid": "no data kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[He].2s2.2p6", "Liquid range": "2.51 K", "Max oxidation state": 0.0, "Melting point": "24.56 K", "Mendeleev no": 2, "Min oxidation state": 0.0, "Mineral hardness": "no data", "Molar volume": "13.23 cm3", "Name": "Neon", "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "1.000067", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "0.0491 W m-1 K-1", "Van der waals radius": 1.54, "Velocity of sound": "936 m s-1", "Vickers hardness": "no data MN m-2", "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": {"Ne-21": 101.55}, "Metallic radius": "no data", "iupac_ordering": 4, "IUPAC ordering": 4, "Ground level": "1S0", "Ionization energies": [21.564541, 40.96297, 63.4233, 97.19, 126.247, 157.934, 207.271, 239.097, 1195.80784, 1362.19916], "Electron affinity": -1.22}, "Ni": {"Atomic mass": 58.6934, "Atomic no": 28, "Atomic orbitals": {"1s": -297.870824, "2p": -30.868027, "2s": -35.312112, "3d": -0.348699, "3p": -2.594158, "3s": -3.950717, "4s": -0.210764}, "Atomic radius": 1.35, "Atomic radius calculated": 1.49, "Boiling point": "3186 K", "Brinell hardness": "700 MN m-2", "Bulk modulus": "180 GPa", "Coefficient of linear thermal expansion": "13.4 x10-6K-1", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "8908 kg m-3", "Electrical resistivity": "7.2 10-8 Ω m", "Electronic structure": "[Ar].3d8.4s2", "ICSD oxidation states": [1, 2, 3, 4], "Ionic radii": {"3": 0.74}, "Ionic radii hs": {"3": 0.74}, "Ionic radii ls": {"2": 0.83, "3": 0.7, "4": 0.62}, "Liquid range": "1458 K", "Melting point": "1728 K", "Mendeleev no": 67, "Mineral hardness": "4.0", "Molar volume": "6.59 cm3", "Name": "Nickel", "Oxidation states": [-1, 1, 2, 3, 4], "Poissons ratio": "0.31", "Reflectivity": "72 %", "Refractive index": "no data", "Rigidity modulus": "76 GPa", "Shannon radii": {"2": {"IV": {"": {"crystal_radius": 0.69, "ionic_radius": 0.55}}, "IVSQ": {"": {"crystal_radius": 0.63, "ionic_radius": 0.49}}, "V": {"": {"crystal_radius": 0.77, "ionic_radius": 0.63}}, "VI": {"": {"crystal_radius": 0.83, "ionic_radius": 0.69}}}, "3": {"VI": {"Low Spin": {"crystal_radius": 0.7, "ionic_radius": 0.56}, "High Spin": {"crystal_radius": 0.74, "ionic_radius": 0.6}}}, "4": {"VI": {"Low Spin": {"crystal_radius": 0.62, "ionic_radius": 0.48}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "91 W m-1 K-1", "Van der waals radius": 1.97, "Velocity of sound": "4970 m s-1", "Vickers hardness": "638 MN m-2", "X": 1.91, "Youngs modulus": "200 GPa", "NMR Quadrupole Moment": {"Ni-61": 162.15}, "Metallic radius": 1.246, "iupac_ordering": 70, "IUPAC ordering": 70, "Ground level": "3F4", "Ionization energies": [7.639878, 18.168838, 35.187, 54.92, 76.06, 108.0, 132.0, 162.0, 193.2, 224.7, 319.5, 351.6, 384.5, 429.3, 462.8, 495.4, 571.07, 607.02, 1541.0, 1646.0, 1758.0, 1880.0, 2008.1, 2130.5, 2295.6, 2399.259, 10288.8862, 10775.386], "Electron affinity": 1.1571612}, "No": {"Atomic mass": 259.0, "Atomic no": 102, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "no data kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[Rn].5f14.7s2", "Liquid range": "no data K", "Melting point": "about 1100 K", "Mendeleev no": 35, "Mineral hardness": "no data", "Molar volume": "no data cm3", "Name": "Nobelium", "Oxidation states": [2, 3], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"2": {"VI": {"": {"crystal_radius": 1.24, "ionic_radius": 1.1}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m-1 K-1", "Van der waals radius": 2.46, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 1.3, "Youngs modulus": "no data GPa", "Metallic radius": "no data", "iupac_ordering": 19, "IUPAC ordering": 19, "Ground level": "1S0", "Ionization energies": [6.62621, 12.93, 25.8, 41.5, 60.0, 74.0, 97.0, 119.0, 140.0, 170.0, 187.0, 216.0, 246.0, 267.0, 285.0, 312.0, 341.0, 367.0, 394.0, 422.0, 448.0, 475.0, 496.0, 520.0, 701.0, 734.0, 768.0, 805.0, 840.0, 875.0, 934.0, 969.0, 1010.0, 1045.0, 1220.0, 1260.0, 1300.0, 1350.0, 1500.0, 1550.0, 1680.0, 1730.0, 1920.0, 2010.0, 2110.0, 2200.0, 2290.0, 2380.0, 2470.0, 2570.0, 2680.0, 2760.0, 2860.0, 2950.0, 3050.0, 3140.0, 3627.0, 3705.0, 3790.0, 3878.0, 3962.0, 4045.0, 4234.0, 4320.0, 4413.0, 4500.0, 4850.0, 4930.0, 5030.0, 5110.0, 5750.0, 5850.0, 6110.0, 6210.0, 9680.0, 9860.0, 10060.0, 10270.0, 10470.0, 10660.0, 11200.0, 11410.0, 11630.0, 11840.0, 12420.0, 12600.0, 12800.0, 12980.0, 15000.0, 15200.0, 15600.0, 15800.0, 31700.0, 32200.0, 32700.0, 33200.0, 40500.0, 41200.0, 42100.0, 42632.0, null, 168806.0], "Electron affinity": -2.33}, "Np": {"Atomic mass": 237.0, "Atomic no": 93, "Atomic orbitals": "no data", "Atomic radius": 1.75, "Atomic radius calculated": "no data", "Boiling point": "4273 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [5], "Critical temperature": "no data K", "Density of solid": "20450 kg m-3", "Electrical resistivity": "120 10-8 Ω m", "Electronic structure": "[Rn].5f4.6d1.7s2", "Ionic radii": {"2": 1.24, "3": 1.15, "4": 1.01, "5": 0.89, "6": 0.86, "7": 0.85}, "Liquid range": "3363 K", "Melting point": "910 K", "Mendeleev no": 44, "Mineral hardness": "no data", "Molar volume": "11.59 cm3", "Name": "Neptunium", "Oxidation states": [3, 4, 5, 6, 7], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"2": {"VI": {"": {"crystal_radius": 1.24, "ionic_radius": 1.1}}}, "3": {"VI": {"": {"crystal_radius": 1.15, "ionic_radius": 1.01}}}, "4": {"VI": {"": {"crystal_radius": 1.01, "ionic_radius": 0.87}}, "VIII": {"": {"crystal_radius": 1.12, "ionic_radius": 0.98}}}, "5": {"VI": {"": {"crystal_radius": 0.89, "ionic_radius": 0.75}}}, "6": {"VI": {"": {"crystal_radius": 0.86, "ionic_radius": 0.72}}}, "7": {"VI": {"": {"crystal_radius": 0.85, "ionic_radius": 0.71}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "6 W m-1 K-1", "Van der waals radius": 2.39, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 1.36, "Youngs modulus": "no data GPa", "Metallic radius": 1.503, "iupac_ordering": 28, "IUPAC ordering": 28, "Ground level": "6L11/2", "Ionization energies": [6.26554, 11.5, 19.7, 33.8, 48.0, 65.0, 92.0, 107.0, 121.0, 136.0, 151.0, 179.0, 196.0, 233.0, 252.0, 355.0, 382.0, 408.0, 438.0, 466.0, 495.0, 535.0, 565.0, 596.0, 626.0, 770.0, 810.0, 850.0, 880.0, 980.0, 1020.0, 1130.0, 1170.0, 1280.0, 1360.0, 1430.0, 1510.0, 1590.0, 1670.0, 1740.0, 1820.0, 1910.0, 1990.0, 2070.0, 2140.0, 2230.0, 2310.0, 2675.0, 2745.0, 2817.0, 2894.0, 2969.0, 3041.0, 3181.0, 3255.0, 3338.0, 3413.0, 3718.0, 3792.0, 3872.0, 3947.0, 4353.0, 4441.0, 4658.0, 4744.0, 7610.0, 7770.0, 7950.0, 8130.0, 8310.0, 8480.0, 8890.0, 9070.0, 9270.0, 9450.0, 9970.0, 10130.0, 10300.0, 10470.0, 11730.0, 11930.0, 12320.0, 12500.0, 25870.0, 26300.0, 26770.0, 27210.0, 31910.0, 32500.0, 33300.0, 33722.2, 132901.8, 135202.0], "Electron affinity": 0.48}, "O": {"Atomic mass": 15.9994, "Atomic no": 8, "Atomic orbitals": {"1s": -18.758245, "2p": -0.338381, "2s": -0.871362}, "Atomic radius": 0.6, "Atomic radius calculated": 0.48, "Boiling point": "90.2 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [-2], "Critical temperature": "154.6 K", "Density of solid": "no data kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[He].2s2.2p4", "ICSD oxidation states": [-2], "Ionic radii": {"-2": 1.26}, "Liquid range": "35.4 K", "Melting point": "54.8 K", "Mendeleev no": 101, "Mineral hardness": "no data", "Molar volume": "17.36 cm3", "Name": "Oxygen", "Oxidation states": [-2, -1, 1, 2], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "1.000271 (gas; liquid 1.221)(no units)", "Rigidity modulus": "no data GPa", "Shannon radii": {"-2": {"II": {"": {"crystal_radius": 1.21, "ionic_radius": 1.35}}, "III": {"": {"crystal_radius": 1.22, "ionic_radius": 1.36}}, "IV": {"": {"crystal_radius": 1.24, "ionic_radius": 1.38}}, "VI": {"": {"crystal_radius": 1.26, "ionic_radius": 1.4}}, "VIII": {"": {"crystal_radius": 1.28, "ionic_radius": 1.42}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "0.02658 W m-1 K-1", "Van der waals radius": 1.52, "Velocity of sound": "317.5 m s-1", "Vickers hardness": "no data MN m-2", "X": 3.44, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": {"O-17": -25.58}, "Metallic radius": "no data", "iupac_ordering": 97, "IUPAC ordering": 97, "Ground level": "3P2", "Ionization energies": [13.618055, 35.12112, 54.93554, 77.4135, 113.899, 138.1189, 739.32683, 871.409883], "Electron affinity": 1.4611053}, "Os": {"Atomic mass": 190.23, "Atomic no": 76, "Atomic orbitals": {"1s": -2475.238617, "2p": -393.15408, "2s": -409.522396, "3d": -72.497183, "3p": -86.837047, "3s": -94.501324, "4d": -10.176082, "4f": -2.321175, "4p": -16.119671, "4s": -19.362527, "5d": -0.296791, "5p": -1.757404, "5s": -2.738293, "6s": -0.191489}, "Atomic radius": 1.3, "Atomic radius calculated": 1.85, "Boiling point": "5285 K", "Brinell hardness": "3920 MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "5.1 x10-6K-1", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "22610 kg m-3", "Electrical resistivity": "8.1 10-8 Ω m", "Electronic structure": "[Xe].4f14.5d6.6s2", "Ionic radii": {"4": 0.77, "5": 0.715, "6": 0.685, "7": 0.665, "8": 0.53}, "Liquid range": "1979 K", "Melting point": "3306 K", "Mendeleev no": 63, "Mineral hardness": "7.0", "Molar volume": "8.42 cm3", "Name": "Osmium", "Oxidation states": [-2, -1, 1, 2, 3, 4, 5, 6, 7, 8], "Poissons ratio": "0.25", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "222 GPa", "Shannon radii": {"4": {"VI": {"": {"crystal_radius": 0.77, "ionic_radius": 0.63}}}, "5": {"VI": {"": {"crystal_radius": 0.715, "ionic_radius": 0.575}}}, "6": {"V": {"": {"crystal_radius": 0.63, "ionic_radius": 0.49}}, "VI": {"": {"crystal_radius": 0.685, "ionic_radius": 0.545}}}, "7": {"VI": {"": {"crystal_radius": 0.665, "ionic_radius": 0.525}}}, "8": {"IV": {"": {"crystal_radius": 0.53, "ionic_radius": 0.39}}}}, "Superconduction temperature": "0.66 K", "Thermal conductivity": "88 W m-1 K-1", "Van der waals radius": 2.16, "Velocity of sound": "4940 m s-1", "Vickers hardness": "no data MN m-2", "X": 2.2, "Youngs modulus": "no data GPa", "Metallic radius": 1.352, "iupac_ordering": 62, "IUPAC ordering": 62, "Ground level": "5D4", "Ionization energies": [8.43823, 17.0, 25.0, 41.0, 55.0, 70.1, 85.1, 102.02, 168.7, 190.0, 213.0, 235.0, 269.0, 298.0, 322.0, 367.0, 410.0, 436.0, 470.0, 520.0, 570.0, 620.0, 670.0, 720.0, 770.0, 820.0, 870.0, 920.0, 970.0, 1015.0, 1262.0, 1311.0, 1364.0, 1420.0, 1474.0, 1528.0, 1606.0, 1660.0, 1720.0, 1776.0, 1996.0, 2052.0, 2112.0, 2168.0, 2336.0, 2400.0, 2552.0, 2615.5, 4374.0, 4501.0, 4635.0, 4779.0, 4917.0, 5052.0, 5280.0, 5421.0, 5575.0, 5717.0, 6115.0, 6240.0, 6376.0, 6503.0, 7039.0, 7185.0, 7468.0, 7610.0, 16560.0, 16900.0, 17270.0, 17620.0, 19600.0, 20030.0, 20570.0, 20920.6, 83976.21, 85614.4], "Electron affinity": 1.0778013}, "P": {"Atomic mass": 30.973762, "Atomic no": 15, "Atomic orbitals": {"1s": -76.061897, "2p": -4.576617, "2s": -6.329346, "3p": -0.20608, "3s": -0.512364}, "Atomic radius": 1.0, "Atomic radius calculated": 0.98, "Boiling point": "550 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "11 GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [-3, 3, 5], "Critical temperature": "994 K", "Density of solid": "1823 kg m-3", "Electrical resistivity": "about 10 10-8 Ω m", "Electronic structure": "[Ne].3s2.3p3", "ICSD oxidation states": [3, 4, 5, -2, -3, -1], "Ionic radii": {"3": 0.58, "5": 0.52}, "Liquid range": "232.7 K", "Melting point": "(white P) 317.3 K", "Mendeleev no": 90, "Mineral hardness": "no data", "Molar volume": "17.02 cm3", "Name": "Phosphorus", "Oxidation states": [-3, -2, -1, 1, 2, 3, 4, 5], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "1.001212", "Rigidity modulus": "no data GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 0.58, "ionic_radius": 0.44}}}, "5": {"IV": {"": {"crystal_radius": 0.31, "ionic_radius": 0.17}}, "V": {"": {"crystal_radius": 0.43, "ionic_radius": 0.29}}, "VI": {"": {"crystal_radius": 0.52, "ionic_radius": 0.38}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "0.236 W m-1 K-1", "Van der waals radius": 1.8, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 2.19, "Youngs modulus": "no data GPa", "Metallic radius": "no data", "iupac_ordering": 90, "IUPAC ordering": 90, "Ground level": "4S\u00b03/2", "Ionization energies": [10.486686, 19.76949, 30.20264, 51.44387, 65.02511, 220.43, 263.57, 309.6, 372.31, 424.4, 479.44, 560.62, 611.741, 2816.90879, 3069.8416], "Electron affinity": 0.7466071}, "Pa": {"Atomic mass": 231.03588, "Atomic no": 91, "Atomic orbitals": {"1s": -3606.333629, "2p": -603.470278, "2s": -623.870431, "3d": -127.781168, "3p": -146.485678, "3s": -156.466742, "4d": -25.933121, "4f": -14.105747, "4p": -34.48293, "4s": -39.064507, "5d": -3.659928, "5f": -0.316813, "5p": -6.709821, "5s": -8.463463, "6d": -0.142481, "6p": -0.799756, "6s": -1.287232, "7s": -0.129653}, "Atomic radius": 1.8, "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [5], "Critical temperature": "no data K", "Density of solid": "15370 kg m-3", "Electrical resistivity": "18 10-8 Ω m", "Electronic structure": "[Rn].5f2.6d1.7s2", "Ionic radii": {"3": 1.16, "4": 1.04, "5": 0.92}, "Liquid range": "no data K", "Melting point": "1841 K", "Mendeleev no": 46, "Mineral hardness": "no data", "Molar volume": "15.18 cm3", "Name": "Protactinium", "Oxidation states": [3, 4, 5], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 1.18, "ionic_radius": 1.04}}}, "4": {"VI": {"": {"crystal_radius": 1.04, "ionic_radius": 0.9}}, "VIII": {"": {"crystal_radius": 1.15, "ionic_radius": 1.01}}}, "5": {"VI": {"": {"crystal_radius": 0.92, "ionic_radius": 0.78}}, "VIII": {"": {"crystal_radius": 1.05, "ionic_radius": 0.91}}, "IX": {"": {"crystal_radius": 1.09, "ionic_radius": 0.95}}}}, "Superconduction temperature": "1.4 K", "Thermal conductivity": "47 W m-1 K-1", "Van der waals radius": 2.1, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 1.5, "Youngs modulus": "no data GPa", "Metallic radius": 1.642, "iupac_ordering": 30, "IUPAC ordering": 30, "Ground level": "4K11/2", "Ionization energies": [5.89, 11.9, 18.6, 30.9, 44.3, 72.0, 85.1, 98.9, 111.0, 137.0, 153.0, 187.0, 203.0, 292.0, 316.0, 342.0, 369.0, 395.0, 423.0, 460.0, 488.0, 518.0, 546.0, 690.0, 720.0, 760.0, 790.0, 880.0, 920.0, 1020.0, 1060.0, 1150.0, 1220.0, 1300.0, 1370.0, 1450.0, 1520.0, 1600.0, 1670.0, 1760.0, 1830.0, 1910.0, 1980.0, 2060.0, 2130.0, 2483.0, 2550.0, 2620.0, 2696.0, 2766.0, 2837.0, 2968.0, 3040.0, 3119.0, 3193.0, 3488.0, 3558.0, 3637.0, 3709.0, 4077.0, 4161.0, 4370.0, 4454.0, 7181.0, 7341.0, 7510.0, 7690.0, 7870.0, 8040.0, 8410.0, 8590.0, 8780.0, 8960.0, 9460.0, 9620.0, 9790.0, 9950.0, 11100.0, 11290.0, 11660.0, 11840.0, 24660.0, 25080.0, 25540.0, 25970.0, 30230.0, 30800.0, 31520.0, 31971.6, 126296.6, 128507.1], "Electron affinity": 0.55}, "Pb": {"Atomic mass": 207.2, "Atomic no": 82, "Atomic orbitals": {"1s": -2901.078061, "2p": -470.877785, "2s": -488.843335, "3d": -91.889924, "3p": -107.950391, "3s": -116.526852, "4d": -15.030026, "4f": -5.592532, "4p": -21.990564, "4s": -25.75333, "5d": -0.902393, "5p": -2.941657, "5s": -4.206797, "6p": -0.141831, "6s": -0.357187}, "Atomic radius": 1.8, "Atomic radius calculated": 1.54, "Boiling point": "2022 K", "Brinell hardness": "38.3 MN m-2", "Bulk modulus": "46 GPa", "Coefficient of linear thermal expansion": "28.9 x10-6K-1", "Common oxidation states": [2, 4], "Critical temperature": "no data K", "Density of solid": "11340 kg m-3", "Electrical resistivity": "21 10-8 Ω m", "Electronic structure": "[Xe].4f14.5d10.6s2.6p2", "ICSD oxidation states": [2, 4], "Ionic radii": {"2": 1.33, "4": 0.915}, "Liquid range": "1421.39 K", "Melting point": "600.61 K", "Mendeleev no": 82, "Mineral hardness": "1.5", "Molar volume": "18.26 cm3", "Name": "Lead", "Oxidation states": [-4, 2, 4], "Poissons ratio": "0.44", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "5.6 GPa", "Shannon radii": {"2": {"IVPY": {"": {"crystal_radius": 1.12, "ionic_radius": 0.98}}, "VI": {"": {"crystal_radius": 1.33, "ionic_radius": 1.19}}, "VII": {"": {"crystal_radius": 1.37, "ionic_radius": 1.23}}, "VIII": {"": {"crystal_radius": 1.43, "ionic_radius": 1.29}}, "IX": {"": {"crystal_radius": 1.49, "ionic_radius": 1.35}}, "X": {"": {"crystal_radius": 1.54, "ionic_radius": 1.4}}, "XI": {"": {"crystal_radius": 1.59, "ionic_radius": 1.45}}, "XII": {"": {"crystal_radius": 1.63, "ionic_radius": 1.49}}}, "4": {"IV": {"": {"crystal_radius": 0.79, "ionic_radius": 0.65}}, "V": {"": {"crystal_radius": 0.87, "ionic_radius": 0.73}}, "VI": {"": {"crystal_radius": 0.915, "ionic_radius": 0.775}}, "VIII": {"": {"crystal_radius": 1.08, "ionic_radius": 0.94}}}}, "Superconduction temperature": "7.2 K", "Thermal conductivity": "35 W m-1 K-1", "Van der waals radius": 2.02, "Velocity of sound": "1260 m s-1", "Vickers hardness": "no data MN m-2", "X": 2.33, "Youngs modulus": "16 GPa", "Metallic radius": 1.75, "iupac_ordering": 82, "IUPAC ordering": 82, "Ground level": "1/2,1/2)0", "Ionization energies": [7.4166799, 15.032499, 31.9373, 42.33256, 68.8, 82.9, 100.1, 120.0, 138.0, 158.0, 182.0, 203.0, 224.0, 245.1, 338.1, 374.0, 401.0, 427.0, 478.0, 507.0, 570.0, 610.0, 650.0, 690.0, 750.0, 810.0, 870.0, 930.0, 990.0, 1050.0, 1120.0, 1180.0, 1240.0, 1300.0, 1360.0, 1430.0, 1704.0, 1760.0, 1819.0, 1884.0, 1945.0, 2004.0, 2101.0, 2163.0, 2230.0, 2292.0, 2543.0, 2605.0, 2671.0, 2735.0, 2965.0, 3036.0, 3211.0, 3282.1, 5414.0, 5555.0, 5703.0, 5862.0, 6015.0, 6162.0, 6442.0, 6597.0, 6767.0, 6924.0, 7362.0, 7500.0, 7650.0, 7790.0, 8520.0, 8680.0, 9000.0, 9150.0, 19590.0, 19970.0, 20380.0, 20750.0, 23460.0, 23940.0, 24550.0, 24938.2, 99491.85, 101336.4], "Electron affinity": 0.3567212}, "Pd": {"Atomic mass": 106.42, "Atomic no": 46, "Atomic orbitals": {"1s": -860.134909, "2p": -114.408286, "2s": -123.105078, "3d": -12.132197, "3p": -18.580798, "3s": -22.060898, "4d": -0.160771, "4p": -1.815215, "4s": -2.889173}, "Atomic radius": 1.4, "Atomic radius calculated": 1.69, "Boiling point": "3236 K", "Brinell hardness": "37.3 MN m-2", "Bulk modulus": "180 GPa", "Coefficient of linear thermal expansion": "11.8 x10-6K-1", "Common oxidation states": [2, 4], "Critical temperature": "no data K", "Density of solid": "12023 kg m-3", "Electrical resistivity": "10.8 10-8 Ω m", "Electronic structure": "[Kr].4d10", "ICSD oxidation states": [2, 4], "Ionic radii": {"1": 0.73, "2": 1.0, "3": 0.9, "4": 0.755}, "Liquid range": "1407.95 K", "Melting point": "1828.05 K", "Mendeleev no": 69, "Mineral hardness": "4.75", "Molar volume": "8.56 cm3", "Name": "Palladium", "Oxidation states": [2, 4], "Poissons ratio": "0.39", "Reflectivity": "72 %", "Refractive index": "no data", "Rigidity modulus": "44 GPa", "Shannon radii": {"1": {"II": {"": {"crystal_radius": 0.73, "ionic_radius": 0.59}}}, "2": {"IVSQ": {"": {"crystal_radius": 0.78, "ionic_radius": 0.64}}, "VI": {"": {"crystal_radius": 1.0, "ionic_radius": 0.86}}}, "3": {"VI": {"": {"crystal_radius": 0.9, "ionic_radius": 0.76}}}, "4": {"VI": {"": {"crystal_radius": 0.755, "ionic_radius": 0.615}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "72 W m-1 K-1", "Van der waals radius": 2.1, "Velocity of sound": "3070 m s-1", "Vickers hardness": "461 MN m-2", "X": 2.2, "Youngs modulus": "121 GPa", "Metallic radius": 1.376, "iupac_ordering": 69, "IUPAC ordering": 69, "Ground level": "1S0", "Ionization energies": [8.336839, 19.43, 32.93, 46.0, 61.0, 84.1, 101.0, 120.0, 141.0, 159.9, 238.57, 260.0, 286.0, 311.0, 342.0, 369.1, 427.0, 457.5, 810.0, 869.0, 933.0, 1000.0, 1065.0, 1145.0, 1218.0, 1290.0, 1366.0, 1438.0, 1644.0, 1706.2, 1781.3, 1869.0, 1962.0, 2016.0, 2181.0, 2248.87, 5284.0, 5475.0, 5683.0, 5880.0, 6242.0, 6469.0, 6759.0, 6943.097, 28776.034, 29622.6], "Electron affinity": 0.5621412}, "Pm": {"Atomic mass": 145.0, "Atomic no": 61, "Atomic orbitals": {"1s": -1562.980284, "2p": -233.455114, "2s": -245.970548, "3d": -37.625433, "3p": -47.921132, "3s": -53.429311, "4d": -4.596822, "4f": -0.200159, "4p": -8.320495, "4s": -10.422756, "5p": -0.817702, "5s": -1.372265, "6s": -0.127053}, "Atomic radius": 1.85, "Atomic radius calculated": 2.05, "Boiling point": "3273 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "33 GPa", "Coefficient of linear thermal expansion": "11 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "7264 kg m-3", "Electrical resistivity": "about 75 10-8 Ω m", "Electronic structure": "[Xe].4f5.6s2", "Ionic radii": {"3": 1.11}, "Liquid range": "1900 K", "Melting point": "1373 K", "Mendeleev no": 29, "Mineral hardness": "no data", "Molar volume": "20.23 cm3", "Name": "Promethium", "Oxidation states": [3], "Poissons ratio": "0.28", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "18 GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 1.11, "ionic_radius": 0.97}}, "VIII": {"": {"crystal_radius": 1.233, "ionic_radius": 1.093}}, "IX": {"": {"crystal_radius": 1.284, "ionic_radius": 1.144}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "15 W m-1 K-1", "Van der waals radius": 2.38, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 1.13, "Youngs modulus": "46 GPa", "Metallic radius": 1.811, "iupac_ordering": 43, "IUPAC ordering": 43, "Ground level": "6H\u00b05/2", "Ionization energies": [5.58187, 10.938, 22.44, 41.17, 61.7, 85.0, 101.0, 116.0, 138.0, 155.0, 174.0, 202.0, 229.0, 248.0, 269.0, 430.0, 462.0, 497.0, 534.0, 569.0, 609.0, 651.0, 689.0, 730.0, 767.0, 916.0, 956.0, 998.0, 1040.0, 1113.0, 1158.0, 1261.0, 1308.7, 2251.0, 2344.0, 2443.0, 2549.0, 2652.0, 2755.0, 2892.0, 2997.0, 3112.0, 3219.0, 3519.0, 3613.0, 3718.0, 3816.0, 4056.0, 4166.0, 4371.0, 4476.0, 10115.0, 10378.0, 10671.0, 10942.0, 11819.0, 12136.0, 12532.0, 12797.26, 52144.29, 53346.1], "Electron affinity": 0.129}, "Po": {"Atomic mass": 210.0, "Atomic no": 84, "Atomic orbitals": {"1s": -3050.988417, "2p": -498.77192, "2s": -517.275843, "3d": -99.256068, "3p": -115.898384, "3s": -124.783683, "4d": -17.173307, "4f": -7.206499, "4p": -24.481337, "4s": -28.42254, "5d": -1.386458, "5p": -3.655382, "5s": -5.027447, "6p": -0.217889, "6s": -0.493528}, "Atomic radius": 1.9, "Atomic radius calculated": 1.35, "Boiling point": "1235 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [-2, 2, 4], "Critical temperature": "no data K", "Density of solid": "9196 kg m-3", "Electrical resistivity": "40 10-8 Ω m", "Electronic structure": "[Xe].4f14.5d10.6s2.6p4", "Ionic radii": {"4": 1.08, "6": 0.81}, "Liquid range": "708 K", "Melting point": "527 K", "Mendeleev no": 91, "Mineral hardness": "no data", "Molar volume": "22.97 cm3", "Name": "Polonium", "Oxidation states": [-2, 2, 4, 6], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"4": {"VI": {"": {"crystal_radius": 1.08, "ionic_radius": 0.94}}, "VIII": {"": {"crystal_radius": 1.22, "ionic_radius": 1.08}}}, "6": {"VI": {"": {"crystal_radius": 0.81, "ionic_radius": 0.67}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "20 W m-1 K-1", "Van der waals radius": 1.97, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 2.0, "Youngs modulus": "no data GPa", "Metallic radius": 1.53, "iupac_ordering": 93, "IUPAC ordering": 93, "Ground level": "3P2", "Ionization energies": [8.41807, 19.3, 27.3, 36.0, 57.0, 69.1, 108.0, 125.0, 146.1, 166.0, 186.0, 209.0, 235.0, 257.0, 281.0, 304.0, 416.0, 444.0, 473.0, 502.0, 560.0, 590.0, 670.0, 700.0, 740.0, 800.0, 870.0, 930.0, 990.0, 1060.0, 1120.0, 1180.0, 1250.0, 1320.0, 1380.0, 1440.0, 1510.0, 1570.0, 1865.0, 1923.0, 1986.0, 2052.0, 2115.0, 2177.0, 2281.0, 2345.0, 2414.0, 2480.0, 2740.0, 2803.0, 2873.0, 2938.0, 3194.0, 3268.0, 3450.0, 3524.2, 5785.0, 5930.0, 6084.0, 6248.0, 6405.0, 6557.0, 6856.0, 7015.0, 7191.0, 7350.0, 7810.0, 7950.0, 8100.0, 8240.0, 9050.0, 9220.0, 9550.0, 9710.0, 20670.0, 21050.0, 21470.0, 21860.0, 24860.0, 25360.0, 25990.0, 26390.4, 105064.3, 106982.7], "Electron affinity": 1.407}, "Pr": {"Atomic mass": 140.90765, "Atomic no": 59, "Atomic orbitals": {"1s": -1457.338067, "2p": -215.418313, "2s": -227.426363, "3d": -33.913996, "3p": -43.692548, "3s": -48.924994, "4d": -4.154228, "4f": -0.155138, "4p": -7.613108, "4s": -9.577447, "5p": -0.778046, "5s": -1.296106, "6s": -0.124465}, "Atomic radius": 1.85, "Atomic radius calculated": 2.47, "Boiling point": "3563 K", "Brinell hardness": "481 MN m-2", "Bulk modulus": "29 GPa", "Coefficient of linear thermal expansion": "6.7 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "6640 kg m-3", "Electrical resistivity": "70 10-8 Ω m", "Electronic structure": "[Xe].4f3.6s2", "ICSD oxidation states": [3, 4], "Ionic radii": {"3": 1.13, "4": 0.99}, "Liquid range": "2355 K", "Melting point": "1208 K", "Mendeleev no": 31, "Mineral hardness": "no data", "Molar volume": "20.80 cm3", "Name": "Praseodymium", "Oxidation states": [2, 3, 4], "Poissons ratio": "0.28", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "15 GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 1.13, "ionic_radius": 0.99}}, "VIII": {"": {"crystal_radius": 1.266, "ionic_radius": 1.126}}, "IX": {"": {"crystal_radius": 1.319, "ionic_radius": 1.179}}}, "4": {"VI": {"": {"crystal_radius": 0.99, "ionic_radius": 0.85}}, "VIII": {"": {"crystal_radius": 1.1, "ionic_radius": 0.96}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "13 W m-1 K-1", "Van der waals radius": 2.4, "Velocity of sound": "2280 m s-1", "Vickers hardness": "400 MN m-2", "X": 1.13, "Youngs modulus": "37 GPa", "Metallic radius": 1.828, "iupac_ordering": 45, "IUPAC ordering": 45, "Ground level": "4I\u00b09/2", "Ionization energies": [5.4702, 10.631, 21.6237, 38.981, 57.53, 82.0, 97.0, 112.0, 131.0, 148.0, 162.0, 196.0, 217.02, 350.0, 378.0, 412.0, 445.0, 478.0, 516.0, 554.0, 590.0, 627.0, 663.0, 803.0, 840.0, 880.0, 920.0, 985.0, 1028.0, 1124.0, 1169.9, 2019.0, 2108.0, 2202.0, 2304.0, 2400.0, 2501.0, 2628.0, 2729.0, 2838.0, 2941.0, 3227.0, 3319.0, 3419.0, 3512.0, 3729.0, 3832.0, 4030.0, 4130.0, 9378.0, 9632.0, 9913.0, 10175.0, 10959.0, 11262.0, 11641.0, 11895.89, 48571.71, 49722.25], "Electron affinity": 0.1092346}, "Pt": {"Atomic mass": 195.084, "Atomic no": 78, "Atomic orbitals": {"1s": -2613.096532, "2p": -417.96053, "2s": -434.858003, "3d": -78.400271, "3p": -93.309108, "3s": -101.274869, "4d": -11.419476, "4f": -3.038049, "4p": -17.697297, "4s": -21.110651, "5d": -0.273634, "5p": -1.884256, "5s": -2.950526, "6s": -0.161308}, "Atomic radius": 1.35, "Atomic radius calculated": 1.77, "Boiling point": "4098 K", "Brinell hardness": "392 MN m-2", "Bulk modulus": "230 GPa", "Coefficient of linear thermal expansion": "8.8 x10-6K-1", "Common oxidation states": [2, 4], "Critical temperature": "no data K", "Density of solid": "21090 kg m-3", "Electrical resistivity": "10.6 10-8 Ω m", "Electronic structure": "[Xe].4f14.5d9.6s1", "Ionic radii": {"2": 0.94, "4": 0.765, "5": 0.71}, "Liquid range": "2056.6 K", "Melting point": "2041.4 K", "Mendeleev no": 68, "Mineral hardness": "3.5", "Molar volume": "9.09 cm3", "Name": "Platinum", "Oxidation states": [-2, 2, 4, 5, 6], "Poissons ratio": "0.38", "Reflectivity": "73 %", "Refractive index": "no data", "Rigidity modulus": "61 GPa", "Shannon radii": {"2": {"IVSQ": {"": {"crystal_radius": 0.74, "ionic_radius": 0.6}}, "VI": {"": {"crystal_radius": 0.94, "ionic_radius": 0.8}}}, "4": {"VI": {"": {"crystal_radius": 0.765, "ionic_radius": 0.625}}}, "5": {"VI": {"": {"crystal_radius": 0.71, "ionic_radius": 0.57}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "72 W m-1 K-1", "Van der waals radius": 2.13, "Velocity of sound": "2680 m s-1", "Vickers hardness": "549 MN m-2", "X": 2.28, "Youngs modulus": "168 GPa", "Metallic radius": 1.387, "iupac_ordering": 68, "IUPAC ordering": 68, "Ground level": "3D3", "Ionization energies": [8.95883, 18.56, 29.0, 43.0, 56.0, 75.0, 91.0, 109.0, 126.0, 144.9, 220.4, 245.0, 269.0, 293.0, 332.0, 358.0, 392.0, 445.0, 479.0, 507.0, 550.0, 610.0, 660.0, 710.0, 760.0, 820.0, 870.0, 930.0, 980.0, 1040.0, 1090.0, 1140.0, 1402.0, 1454.0, 1509.0, 1567.0, 1624.0, 1680.0, 1763.0, 1821.0, 1883.0, 1941.0, 2171.0, 2228.0, 2291.0, 2350.0, 2536.0, 2603.0, 2762.0, 2827.8, 4715.0, 4839.0, 4980.0, 5128.0, 5270.0, 5410.0, 5654.0, 5800.0, 5959.0, 6106.0, 6517.0, 6646.0, 6787.0, 6918.0, 7512.0, 7660.0, 7960.0, 8100.0, 17540.0, 17890.0, 18280.0, 18630.0, 20840.0, 21280.0, 21840.0, 22205.7, 88955.18, 90659.7], "Electron affinity": 2.125105}, "Pu": {"Atomic mass": 244.0, "Atomic no": 94, "Atomic orbitals": "no data", "Atomic radius": 1.75, "Atomic radius calculated": "no data", "Boiling point": "3503 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "19816 kg m-3", "Electrical resistivity": "150 10-8 Ω m", "Electronic structure": "[Rn].5f6.7s2", "Ionic radii": {"3": 1.14, "4": 1.0, "5": 0.88, "6": 0.85}, "Liquid range": "2590.5 K", "Melting point": "912.5 K", "Mendeleev no": 43, "Mineral hardness": "no data", "Molar volume": "12.29 cm3", "Name": "Plutonium", "Oxidation states": [3, 4, 5, 6, 7], "Poissons ratio": "0.21", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "43 GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 1.14, "ionic_radius": 1.0}}}, "4": {"VI": {"": {"crystal_radius": 1.0, "ionic_radius": 0.86}}, "VIII": {"": {"crystal_radius": 1.1, "ionic_radius": 0.96}}}, "5": {"VI": {"": {"crystal_radius": 0.88, "ionic_radius": 0.74}}}, "6": {"VI": {"": {"crystal_radius": 0.85, "ionic_radius": 0.71}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "6 W m-1 K-1", "Van der waals radius": 2.43, "Velocity of sound": "2260 m s-1", "Vickers hardness": "no data MN m-2", "X": 1.28, "Youngs modulus": "96 GPa", "Metallic radius": 1.523, "iupac_ordering": 27, "IUPAC ordering": 27, "Ground level": "7F0", "Ionization energies": [6.02576, 11.5, 21.1, 35.0, 49.0, 80.0, 95.0, 109.0, 124.0, 139.0, 159.0, 179.0, 200.0, 219.0, 258.0, 278.0, 389.0, 416.0, 444.0, 474.0, 503.0, 532.0, 575.0, 605.0, 637.0, 668.0, 820.0, 850.0, 890.0, 930.0, 1030.0, 1070.0, 1180.0, 1220.0, 1340.0, 1420.0, 1500.0, 1580.0, 1660.0, 1740.0, 1820.0, 1890.0, 1990.0, 2070.0, 2150.0, 2230.0, 2310.0, 2390.0, 2774.0, 2844.0, 2918.0, 2997.0, 3072.0, 3146.0, 3290.0, 3366.0, 3449.0, 3527.0, 3836.0, 3911.0, 3993.0, 4068.0, 4496.0, 4585.0, 4807.0, 4890.0, 7830.0, 7990.0, 8170.0, 8360.0, 8540.0, 8710.0, 9130.0, 9310.0, 9520.0, 9700.0, 10230.0, 10390.0, 10570.0, 10730.0, 12060.0, 12260.0, 12660.0, 12840.0, 26480.0, 26920.0, 27400.0, 27840.0, 32800.0, 33400.0, 34100.0, 34625.8, 136299.2, 138646.0], "Electron affinity": -0.5}, "Ra": {"Atomic mass": 226.0, "Atomic no": 88, "Atomic orbitals": {"1s": -3362.736563, "2p": -557.513214, "2s": -577.101208, "3d": -115.306476, "3p": -133.12325, "3s": -142.632426, "4d": -22.208125, "4f": -11.181066, "4p": -30.221208, "4s": -34.525628, "5d": -2.819853, "5p": -5.547203, "5s": -7.139137, "6p": -0.634674, "6s": -1.05135, "7s": -0.113732}, "Atomic radius": 2.15, "Atomic radius calculated": "no data", "Boiling point": "2010 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "5000 kg m-3", "Electrical resistivity": "100 10-8 Ω m", "Electronic structure": "[Rn].7s2", "Ionic radii": {"2": 1.62}, "Liquid range": "1037 K", "Melting point": "973 K", "Mendeleev no": 13, "Mineral hardness": "no data", "Molar volume": "41.09 cm3", "Name": "Radium", "Oxidation states": [2], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"2": {"VIII": {"": {"crystal_radius": 1.62, "ionic_radius": 1.48}}, "XII": {"": {"crystal_radius": 1.84, "ionic_radius": 1.7}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "19 W m-1 K-1", "Van der waals radius": 2.83, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 0.9, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": {"Ra-223": 1210.3}, "Metallic radius": 2.293, "iupac_ordering": 12, "IUPAC ordering": 12, "Ground level": "1S0", "Ionization energies": [5.2784239, 10.14718, 31.0, 41.0, 52.9, 64.0, 82.0, 97.0, 124.0, 140.0, 204.9, 227.0, 250.0, 274.0, 299.0, 324.0, 356.0, 382.0, 409.0, 435.0, 570.0, 600.0, 630.0, 660.0, 740.0, 770.0, 860.0, 900.0, 970.0, 1040.0, 1110.0, 1180.0, 1250.0, 1320.0, 1390.0, 1460.0, 1530.0, 1610.0, 1680.0, 1750.0, 1820.0, 1880.0, 2208.0, 2271.0, 2338.0, 2409.0, 2477.0, 2544.0, 2662.0, 2731.0, 2806.0, 2876.0, 3155.0, 3224.0, 3298.0, 3368.0, 3682.0, 3762.0, 3959.0, 4040.0, 6565.0, 6718.0, 6881.0, 7056.0, 7222.0, 7380.0, 7720.0, 7890.0, 8080.0, 8250.0, 8730.0, 8880.0, 9040.0, 9200.0, 10190.0, 10360.0, 10720.0, 10890.0, 22900.0, 23300.0, 23750.0, 24160.0, 27830.0, 28370.0, 29050.0, 29479.8, 116848.7, 118931.3], "Electron affinity": 0.1}, "Rb": {"Atomic mass": 85.4678, "Atomic no": 37, "Atomic orbitals": {"1s": -540.957115, "2p": -64.784678, "2s": -71.291202, "3d": -3.915508, "3p": -8.165416, "3s": -10.513861, "4p": -0.59217, "4s": -1.135051, "5s": -0.085375}, "Atomic radius": 2.35, "Atomic radius calculated": 2.65, "Boiling point": "961 K", "Brinell hardness": "0.216 MN m-2", "Bulk modulus": "2.5 GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [1], "Critical temperature": "2093 K", "Density of solid": "1532 kg m-3", "Electrical resistivity": "13.3 10-8 Ω m", "Electronic structure": "[Kr].5s1", "ICSD oxidation states": [1], "Ionic radii": {"1": 1.66}, "Liquid range": "648.54 K", "Melting point": "312.46 K", "Mendeleev no": 9, "Mineral hardness": "0.3", "Molar volume": "55.76 cm3", "Name": "Rubidium", "Oxidation states": [1], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"1": {"VI": {"": {"crystal_radius": 1.66, "ionic_radius": 1.52}}, "VII": {"": {"crystal_radius": 1.7, "ionic_radius": 1.56}}, "VIII": {"": {"crystal_radius": 1.75, "ionic_radius": 1.61}}, "IX": {"": {"crystal_radius": 1.77, "ionic_radius": 1.63}}, "X": {"": {"crystal_radius": 1.8, "ionic_radius": 1.66}}, "XI": {"": {"crystal_radius": 1.83, "ionic_radius": 1.69}}, "XII": {"": {"crystal_radius": 1.86, "ionic_radius": 1.72}}, "XIV": {"": {"crystal_radius": 1.97, "ionic_radius": 1.83}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "58 W m-1 K-1", "Van der waals radius": 3.03, "Velocity of sound": "1300 m s-1", "Vickers hardness": "no data MN m-2", "X": 0.82, "Youngs modulus": "2.4 GPa", "Metallic radius": 2.537, "iupac_ordering": 8, "IUPAC ordering": 8, "Ground level": "2S1/2", "Ionization energies": [4.1771281, 27.28954, 39.247, 52.2, 68.44, 82.9, 98.67, 132.79, 150.628, 277.12, 313.1, 356.0, 400.0, 443.0, 502.0, 550.0, 601.0, 654.0, 706.0, 857.0, 905.3, 958.9, 1024.0, 1080.0, 1125.0, 1242.5, 1294.57, 3133.3, 3281.0, 3443.0, 3600.0, 3815.0, 3988.0, 4214.0, 4356.865, 18305.884, 18965.516], "Electron affinity": 0.48591621}, "Re": {"Atomic mass": 186.207, "Atomic no": 75, "Atomic orbitals": {"1s": -2407.665572, "2p": -380.982869, "2s": -397.087707, "3d": -69.57676, "3p": -83.634578, "3s": -91.149193, "4d": -9.516816, "4f": -1.92508, "4p": -15.295495, "4s": -18.454325, "5d": -0.258639, "5p": -1.631227, "5s": -2.567348, "6s": -0.186859}, "Atomic radius": 1.35, "Atomic radius calculated": 1.88, "Boiling point": "5869 K", "Brinell hardness": "1320 MN m-2", "Bulk modulus": "370 GPa", "Coefficient of linear thermal expansion": "6.2 x10-6K-1", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "21020 kg m-3", "Electrical resistivity": "18 10-8 Ω m", "Electronic structure": "[Xe].4f14.5d5.6s2", "ICSD oxidation states": [3, 4, 5, 6, 7], "Ionic radii": {"4": 0.77, "5": 0.72, "6": 0.69, "7": 0.67}, "Liquid range": "2410 K", "Melting point": "3459 K", "Mendeleev no": 58, "Mineral hardness": "7.0", "Molar volume": "8.86 cm3", "Name": "Rhenium", "Oxidation states": [-3, -1, 1, 2, 3, 4, 5, 6, 7], "Poissons ratio": "0.30", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "178 GPa", "Shannon radii": {"4": {"VI": {"": {"crystal_radius": 0.77, "ionic_radius": 0.63}}}, "5": {"VI": {"": {"crystal_radius": 0.72, "ionic_radius": 0.58}}}, "6": {"VI": {"": {"crystal_radius": 0.69, "ionic_radius": 0.55}}}, "7": {"IV": {"": {"crystal_radius": 0.52, "ionic_radius": 0.38}}, "VI": {"": {"crystal_radius": 0.67, "ionic_radius": 0.53}}}}, "Superconduction temperature": "1.70 K", "Thermal conductivity": "48 W m-1 K-1", "Van der waals radius": 2.16, "Velocity of sound": "4700 m s-1", "Vickers hardness": "2450 MN m-2", "X": 1.9, "Youngs modulus": "463 GPa", "Metallic radius": 1.375, "iupac_ordering": 59, "IUPAC ordering": 59, "Ground level": "6S5/2", "Ionization energies": [7.83352, 16.6, 27.0, 39.1, 51.9, 67.0, 82.71, 144.4, 165.0, 187.0, 208.0, 236.0, 268.0, 291.0, 330.0, 377.0, 403.0, 429.0, 476.0, 520.0, 570.0, 620.0, 670.0, 720.0, 760.0, 810.0, 860.0, 910.0, 953.0, 1194.0, 1242.0, 1294.0, 1349.0, 1402.0, 1454.0, 1530.0, 1583.0, 1641.0, 1696.0, 1912.0, 1966.0, 2025.0, 2080.0, 2240.0, 2302.0, 2450.0, 2514.5, 4214.0, 4335.0, 4468.0, 4609.0, 4745.0, 4877.0, 5099.0, 5236.0, 5388.0, 5528.0, 5919.0, 6042.0, 6176.0, 6300.0, 6810.0, 6952.0, 7230.0, 7366.0, 16080.0, 16410.0, 16780.0, 17120.0, 19000.0, 19420.0, 19950.0, 20297.4, 81556.9, 83162.3], "Electron affinity": 0.06039663}, "Rh": {"Atomic mass": 102.9055, "Atomic no": 45, "Atomic orbitals": {"1s": -821.136773, "2p": -108.357665, "2s": -116.80695, "3d": -11.21725, "3p": -17.415299, "3s": -20.765603, "4d": -0.239422, "4p": -1.806456, "4s": -2.825505, "5s": -0.154624}, "Atomic radius": 1.35, "Atomic radius calculated": 1.73, "Boiling point": "3968 K", "Brinell hardness": "1100 MN m-2", "Bulk modulus": "380 GPa", "Coefficient of linear thermal expansion": "8.2 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "12450 kg m-3", "Electrical resistivity": "4.3 10-8 Ω m", "Electronic structure": "[Kr].4d8.5s1", "ICSD oxidation states": [3, 4], "Ionic radii": {"3": 0.805, "4": 0.74, "5": 0.69}, "Liquid range": "1731 K", "Melting point": "2237 K", "Mendeleev no": 65, "Mineral hardness": "6.0", "Molar volume": "8.28 cm3", "Name": "Rhodium", "Oxidation states": [-1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "0.26", "Reflectivity": "84 %", "Refractive index": "no data", "Rigidity modulus": "150 GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 0.805, "ionic_radius": 0.665}}}, "4": {"VI": {"": {"crystal_radius": 0.74, "ionic_radius": 0.6}}}, "5": {"VI": {"": {"crystal_radius": 0.69, "ionic_radius": 0.55}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "150 W m-1 K-1", "Van der waals radius": 2.1, "Velocity of sound": "4700 m s-1", "Vickers hardness": "1246 MN m-2", "X": 2.28, "Youngs modulus": "275 GPa", "Metallic radius": 1.345, "iupac_ordering": 66, "IUPAC ordering": 66, "Ground level": "4F9/2", "Ionization energies": [7.4589, 18.08, 31.06, 42.0, 63.0, 80.0, 97.0, 115.1, 135.0, 207.51, 228.0, 252.1, 277.0, 306.0, 331.58, 389.3, 415.97, 739.0, 794.0, 857.0, 921.0, 984.0, 1061.0, 1131.0, 1202.0, 1274.0, 1344.0, 1544.0, 1604.9, 1677.6, 1763.0, 1851.0, 1903.0, 2063.0, 2129.22, 5018.0, 5203.0, 5406.0, 5600.0, 5940.0, 6161.0, 6444.0, 6623.262, 27486.983, 28311.965], "Electron affinity": 1.142892}, "Rn": {"Atomic mass": 220.0, "Atomic no": 86, "Atomic orbitals": {"1s": -3204.756288, "2p": -527.533025, "2s": -546.57796, "3d": -106.945006, "3p": -124.172862, "3s": -133.369144, "4d": -19.449994, "4f": -8.953318, "4p": -27.108985, "4s": -31.230804, "5d": -1.911329, "5p": -4.408702, "5s": -5.889683, "6p": -0.29318, "6s": -0.62657}, "Atomic radius": "no data", "Atomic radius calculated": 1.2, "Boiling point": "211.3 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Critical temperature": "377 K", "Density of solid": "no data kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[Xe].4f14.5d10.6s2.6p6", "Liquid range": "9.3 K", "Max oxidation state": 0.0, "Melting point": "202 K", "Mendeleev no": 6, "Min oxidation state": 0.0, "Mineral hardness": "no data", "Molar volume": "50.50 cm3", "Name": "Radon", "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "0.00361 W m-1 K-1", "Van der waals radius": 2.2, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 2.2, "Youngs modulus": "no data GPa", "Metallic radius": "no data", "iupac_ordering": 0, "IUPAC ordering": 0, "Ground level": "1S0", "Ionization energies": [10.7485, 21.4, 29.4, 36.9, 52.9, 64.0, 88.0, 102.0, 154.0, 173.9, 195.0, 218.0, 240.0, 264.0, 293.0, 317.0, 342.0, 367.0, 488.0, 520.0, 550.0, 580.0, 640.0, 680.0, 760.0, 800.0, 850.0, 920.0, 980.0, 1050.0, 1110.0, 1180.0, 1250.0, 1310.0, 1390.0, 1460.0, 1520.0, 1590.0, 1660.0, 1720.0, 2033.0, 2094.0, 2158.0, 2227.0, 2293.0, 2357.0, 2467.0, 2535.0, 2606.0, 2674.0, 2944.0, 3010.0, 3082.0, 3149.0, 3433.0, 3510.0, 3699.0, 3777.0, 6169.0, 6318.0, 6476.0, 6646.0, 6807.0, 6964.0, 7283.0, 7450.0, 7630.0, 7800.0, 8260.0, 8410.0, 8570.0, 8710.0, 9610.0, 9780.0, 10120.0, 10290.0, 21770.0, 22160.0, 22600.0, 22990.0, 26310.0, 26830.0, 27490.0, 27903.1, 110842.0, 112843.7], "Electron affinity": -0.72}, "Ru": {"Atomic mass": 101.07, "Atomic no": 44, "Atomic orbitals": {"1s": -782.918621, "2p": -102.333649, "2s": -110.536054, "3d": -10.195668, "3p": -16.145217, "3s": -19.366692, "4d": -0.210375, "4p": -1.667549, "4s": -2.628363, "5s": -0.152834}, "Atomic radius": 1.3, "Atomic radius calculated": 1.78, "Boiling point": "4423 K", "Brinell hardness": "2160 MN m-2", "Bulk modulus": "220 GPa", "Coefficient of linear thermal expansion": "6.4 x10-6K-1", "Common oxidation states": [3, 4], "Critical temperature": "no data K", "Density of solid": "12370 kg m-3", "Electrical resistivity": "7.1 10-8 Ω m", "Electronic structure": "[Kr].4d7.5s1", "ICSD oxidation states": [2, 3, 4, 5, 6], "Ionic radii": {"3": 0.82, "4": 0.76, "5": 0.705, "7": 0.52, "8": 0.5}, "Liquid range": "1816 K", "Melting point": "2607 K", "Mendeleev no": 62, "Mineral hardness": "6.5", "Molar volume": "8.17 cm3", "Name": "Ruthenium", "Oxidation states": [-2, 1, 2, 3, 4, 5, 6, 7, 8], "Poissons ratio": "0.30", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "173 GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 0.82, "ionic_radius": 0.68}}}, "4": {"VI": {"": {"crystal_radius": 0.76, "ionic_radius": 0.62}}}, "5": {"VI": {"": {"crystal_radius": 0.705, "ionic_radius": 0.565}}}, "7": {"IV": {"": {"crystal_radius": 0.52, "ionic_radius": 0.38}}}, "8": {"IV": {"": {"crystal_radius": 0.5, "ionic_radius": 0.36}}}}, "Superconduction temperature": "0.49 K", "Thermal conductivity": "120 W m-1 K-1", "Van der waals radius": 2.13, "Velocity of sound": "5970 m s-1", "Vickers hardness": "no data MN m-2", "X": 2.2, "Youngs modulus": "447 GPa", "Metallic radius": 1.339, "iupac_ordering": 63, "IUPAC ordering": 63, "Ground level": "5F5", "Ionization energies": [7.3605, 16.76, 28.47, 45.0, 59.0, 76.0, 93.0, 110.0, 178.41, 198.0, 219.9, 245.0, 271.0, 295.9, 348.0, 376.25, 670.0, 723.0, 784.0, 845.0, 905.0, 981.0, 1048.0, 1115.0, 1187.0, 1253.0, 1447.0, 1506.7, 1577.0, 1659.0, 1743.0, 1794.0, 1949.0, 2013.04, 4758.0, 4939.0, 5136.0, 5330.0, 5647.0, 5861.0, 6137.0, 6311.721, 26229.895, 27033.502], "Electron affinity": 1.0463825}, "S": {"Atomic mass": 32.065, "Atomic no": 16, "Atomic orbitals": {"1s": -87.789937, "2p": -5.751257, "2s": -7.69994, "3p": -0.261676, "3s": -0.630912}, "Atomic radius": 1.0, "Atomic radius calculated": 0.88, "Boiling point": "717.87 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "7.7 GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [-2, 2, 4, 6], "Critical temperature": "1314 K", "Density of solid": "1960 kg m-3", "Electrical resistivity": "> 102310-8 Ω m", "Electronic structure": "[Ne].3s2.3p4", "ICSD oxidation states": [-1, 2, 4, -2, 6], "Ionic radii": {"-2": 1.7, "4": 0.51, "6": 0.43}, "Liquid range": "329.51 K", "Melting point": "388.36 K", "Mendeleev no": 94, "Mineral hardness": "2.0", "Molar volume": "15.53 cm3", "Name": "Sulfur", "Oxidation states": [-2, -1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "1.001111", "Rigidity modulus": "no data GPa", "Shannon radii": {"-2": {"VI": {"": {"crystal_radius": 1.7, "ionic_radius": 1.84}}}, "4": {"VI": {"": {"crystal_radius": 0.51, "ionic_radius": 0.37}}}, "6": {"IV": {"": {"crystal_radius": 0.26, "ionic_radius": 0.12}}, "VI": {"": {"crystal_radius": 0.43, "ionic_radius": 0.29}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "0.205 W m-1 K-1", "Van der waals radius": 1.8, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 2.58, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": {"S-33": -67.8, "S-35": 47.1}, "Metallic radius": "no data", "iupac_ordering": 96, "IUPAC ordering": 96, "Ground level": "3P2", "Ionization energies": [10.36001, 23.33788, 34.86, 47.222, 72.5945, 88.0529, 280.954, 328.794, 379.84, 447.7, 504.55, 564.41, 651.96, 706.994, 3223.7807, 3494.1879], "Electron affinity": 2.077104512}, "Sb": {"Atomic mass": 121.76, "Atomic no": 51, "Atomic orbitals": {"1s": -1070.823495, "2p": -149.214271, "2s": -159.171745, "3d": -19.239895, "3p": -26.956184, "3s": -31.098242, "4d": -1.297338, "4p": -3.646579, "4s": -5.04964, "5p": -0.185623, "5s": -0.445605}, "Atomic radius": 1.45, "Atomic radius calculated": 1.33, "Boiling point": "1860 K", "Brinell hardness": "294 MN m-2", "Bulk modulus": "42 GPa", "Coefficient of linear thermal expansion": "11 x10-6K-1", "Common oxidation states": [-3, 3, 5], "Critical temperature": "no data K", "Density of solid": "6697 kg m-3", "Electrical resistivity": "40 10-8 Ω m", "Electronic structure": "[Kr].4d10.5s2.5p3", "ICSD oxidation states": [-2, 3, 5, -1, -3], "Ionic radii": {"3": 0.9, "5": 0.76}, "Liquid range": "956.22 K", "Melting point": "903.78 K", "Mendeleev no": 88, "Mineral hardness": "3.0", "Molar volume": "18.19 cm3", "Name": "Antimony", "Oxidation states": [-3, 3, 5], "Poissons ratio": "no data", "Reflectivity": "55 %", "Refractive index": "no data", "Rigidity modulus": "20 GPa", "Shannon radii": {"3": {"IVPY": {"": {"crystal_radius": 0.9, "ionic_radius": 0.76}}, "V": {"": {"crystal_radius": 0.94, "ionic_radius": 0.8}}, "VI": {"": {"crystal_radius": 0.9, "ionic_radius": 0.76}}}, "5": {"VI": {"": {"crystal_radius": 0.74, "ionic_radius": 0.6}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "24 W m-1 K-1", "Van der waals radius": 2.06, "Velocity of sound": "3420 m s-1", "Vickers hardness": "no data MN m-2", "X": 2.05, "Youngs modulus": "55 GPa", "NMR Quadrupole Moment": {"Sb-121": -543.11, "Sb-123": -692.14}, "Metallic radius": 1.61, "iupac_ordering": 88, "IUPAC ordering": 88, "Ground level": "4S\u00b03/2", "Ionization energies": [8.608389, 16.626, 25.3235, 43.804, 55.0, 99.51, 117.0, 139.0, 162.0, 185.0, 214.0, 238.0, 265.0, 292.0, 317.0, 420.0, 447.0, 479.0, 510.0, 552.0, 584.0, 657.0, 693.26, 1214.0, 1285.0, 1360.0, 1441.0, 1518.0, 1606.0, 1698.0, 1781.0, 1869.0, 1954.0, 2190.0, 2266.0, 2349.0, 2428.0, 2567.0, 2654.0, 2815.0, 2900.0, 6714.0, 6929.0, 7167.0, 7390.0, 7887.0, 8140.0, 8455.0, 8669.48, 35710.028, 36668.05], "Electron affinity": 1.04740119}, "Sc": {"Atomic mass": 44.955912, "Atomic no": 21, "Atomic orbitals": {"1s": -160.184109, "2p": -14.240006, "2s": -17.206464, "3d": -0.13108, "3p": -1.233165, "3s": -1.988378, "4s": -0.156478}, "Atomic radius": 1.6, "Atomic radius calculated": 1.84, "Boiling point": "3103 K", "Brinell hardness": "750 MN m-2", "Bulk modulus": "57 GPa", "Coefficient of linear thermal expansion": "10.2 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "2985 kg m-3", "Electrical resistivity": "about 55 10-8 Ω m", "Electronic structure": "[Ar].3d1.4s2", "ICSD oxidation states": [2, 3], "Ionic radii": {"3": 0.885}, "Liquid range": "1289 K", "Melting point": "1814 K", "Mendeleev no": 19, "Mineral hardness": "no data", "Molar volume": "15.00 cm3", "Name": "Scandium", "Oxidation states": [1, 2, 3], "Poissons ratio": "0.28", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "29 GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 0.885, "ionic_radius": 0.745}}, "VIII": {"": {"crystal_radius": 1.01, "ionic_radius": 0.87}}}}, "Superconduction temperature": "0.05 (under pressure)K", "Thermal conductivity": "16 W m-1 K-1", "Van der waals radius": 2.15, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 1.36, "Youngs modulus": "74 GPa", "NMR Quadrupole Moment": {"Sc-45": -220.2}, "Metallic radius": 1.641, "iupac_ordering": 49, "IUPAC ordering": 49, "Ground level": "2D3/2", "Ionization energies": [6.56149, 12.79977, 24.756839, 73.4894, 91.95, 110.68, 137.99, 158.08, 180.03, 225.18, 249.798, 687.36, 757.7, 833.2, 926.5, 1008.6, 1093.5, 1213.1, 1287.957, 5674.9037, 6033.7542], "Electron affinity": 0.1882}, "Se": {"Atomic mass": 78.96, "Atomic no": 34, "Atomic orbitals": {"1s": -451.300258, "2p": -51.514388, "2s": -57.311948, "3d": -2.011392, "3p": -5.553517, "3s": -7.547186, "4p": -0.245806, "4s": -0.621248}, "Atomic radius": 1.15, "Atomic radius calculated": 1.03, "Boiling point": "958 K", "Brinell hardness": "736 MN m-2", "Bulk modulus": "8.3 GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [-2, 2, 4, 6], "Critical temperature": "1766 K", "Density of solid": "4819 kg m-3", "Electrical resistivity": "high 10-8 Ω m", "Electronic structure": "[Ar].3d10.4s2.4p4", "ICSD oxidation states": [-1, 4, -2, 6], "Ionic radii": {"-2": 1.84, "4": 0.64, "6": 0.56}, "Liquid range": "464 K", "Melting point": "494 K", "Mendeleev no": 93, "Mineral hardness": "2.0", "Molar volume": "16.42 cm3", "Name": "Selenium", "Oxidation states": [-2, 2, 4, 6], "Poissons ratio": "0.33", "Reflectivity": "no data %", "Refractive index": "1.000895", "Rigidity modulus": "3.7 GPa", "Shannon radii": {"-2": {"VI": {"": {"crystal_radius": 1.84, "ionic_radius": 1.98}}}, "4": {"VI": {"": {"crystal_radius": 0.64, "ionic_radius": 0.5}}}, "6": {"IV": {"": {"crystal_radius": 0.42, "ionic_radius": 0.28}}, "VI": {"": {"crystal_radius": 0.56, "ionic_radius": 0.42}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "0.52 W m-1 K-1", "Van der waals radius": 1.9, "Velocity of sound": "3350 m s-1", "Vickers hardness": "no data MN m-2", "X": 2.55, "Youngs modulus": "10 GPa", "Metallic radius": "no data", "iupac_ordering": 95, "IUPAC ordering": 95, "Ground level": "3P2", "Ionization energies": [9.752392, 21.196, 31.697, 42.947, 68.3, 81.83, 155.327, 184.0, 219.0, 255.0, 291.0, 342.9, 383.0, 426.0, 473.0, 517.0, 650.5, 693.4, 739.8, 798.0, 845.8, 887.0, 989.6, 1036.36, 2540.7, 2674.0, 2820.0, 2964.0, 3146.0, 3301.8, 3507.0, 3636.526, 15367.491, 15968.084], "Electron affinity": 2.020604712}, "Si": {"Atomic mass": 28.0855, "Atomic no": 14, "Atomic orbitals": {"1s": -65.184426, "2p": -3.514938, "2s": -5.075056, "3p": -0.153293, "3s": -0.398139}, "Atomic radius": 1.1, "Atomic radius calculated": 1.11, "Boiling point": "3173 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "100 GPa", "Coefficient of linear thermal expansion": "2.6 x10-6K-1", "Common oxidation states": [-4, 4], "Critical temperature": "no data K", "Density of solid": "2330 kg m-3", "Electrical resistivity": "about 100000 10-8 Ω m", "Electronic structure": "[Ne].3s2.3p2", "ICSD oxidation states": [-4, 4], "Ionic radii": {"4": 0.54}, "Liquid range": "1486 K", "Melting point": "1687 K", "Mendeleev no": 85, "Mineral hardness": "6.5", "Molar volume": "12.06 cm3", "Name": "Silicon", "Oxidation states": [-4, -3, -2, -1, 1, 2, 3, 4], "Poissons ratio": "no data", "Reflectivity": "28 %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"4": {"IV": {"": {"crystal_radius": 0.4, "ionic_radius": 0.26}}, "VI": {"": {"crystal_radius": 0.54, "ionic_radius": 0.4}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "150 W m-1 K-1", "Van der waals radius": 2.1, "Velocity of sound": "2200 m s-1", "Vickers hardness": "no data MN m-2", "X": 1.9, "Youngs modulus": "47 GPa", "Metallic radius": "no data", "iupac_ordering": 85, "IUPAC ordering": 85, "Ground level": "3P0", "Ionization energies": [8.15168, 16.34585, 33.493, 45.14179, 166.767, 205.279, 246.57, 303.59, 351.28, 401.38, 476.273, 523.415, 2437.65815, 2673.17755], "Electron affinity": 1.38952128}, "Sm": {"Atomic mass": 150.36, "Atomic no": 62, "Atomic orbitals": {"1s": -1617.183426, "2p": -242.729726, "2s": -255.498846, "3d": -39.528656, "3p": -50.08426, "3s": -55.731133, "4d": -4.814978, "4f": -0.21776, "4p": -8.672685, "4s": -10.844667, "5p": -0.835987, "5s": -1.408552, "6s": -0.128259}, "Atomic radius": 1.85, "Atomic radius calculated": 2.38, "Boiling point": "2076 K", "Brinell hardness": "441 MN m-2", "Bulk modulus": "38 GPa", "Coefficient of linear thermal expansion": "12.7 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "7353 kg m-3", "Electrical resistivity": "94 10-8 Ω m", "Electronic structure": "[Xe].4f6.6s2", "ICSD oxidation states": [2, 3], "Ionic radii": {"2": 1.36, "3": 1.0979999999999999}, "Liquid range": "731 K", "Melting point": "1345 K", "Mendeleev no": 28, "Mineral hardness": "no data", "Molar volume": "19.98 cm3", "Name": "Samarium", "Oxidation states": [2, 3], "Poissons ratio": "0.27", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "20 GPa", "Shannon radii": {"2": {"VII": {"": {"crystal_radius": 1.36, "ionic_radius": 1.22}}, "VIII": {"": {"crystal_radius": 1.41, "ionic_radius": 1.27}}, "IX": {"": {"crystal_radius": 1.46, "ionic_radius": 1.32}}}, "3": {"VI": {"": {"crystal_radius": 1.098, "ionic_radius": 0.958}}, "VII": {"": {"crystal_radius": 1.16, "ionic_radius": 1.02}}, "VIII": {"": {"crystal_radius": 1.219, "ionic_radius": 1.079}}, "IX": {"": {"crystal_radius": 1.272, "ionic_radius": 1.132}}, "XII": {"": {"crystal_radius": 1.38, "ionic_radius": 1.24}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "13 W m-1 K-1", "Van der waals radius": 2.36, "Velocity of sound": "2130 m s-1", "Vickers hardness": "412 MN m-2", "X": 1.17, "Youngs modulus": "50 GPa", "Metallic radius": 1.804, "iupac_ordering": 42, "IUPAC ordering": 42, "Ground level": "7F0", "Ionization energies": [5.64371, 11.078, 23.55, 41.64, 62.7, 87.0, 103.0, 118.0, 141.0, 158.0, 179.0, 208.0, 237.0, 257.0, 276.0, 306.5, 474.0, 506.0, 543.0, 581.0, 617.0, 658.0, 702.0, 742.0, 782.0, 822.0, 976.0, 1016.0, 1060.0, 1103.0, 1180.0, 1226.0, 1332.0, 1381.56, 2371.0, 2466.0, 2569.0, 2676.0, 2782.0, 2887.0, 3028.0, 3137.0, 3253.0, 3363.0, 3669.0, 3766.0, 3873.0, 3971.0, 4227.0, 4337.0, 4548.0, 4655.0, 10494.0, 10762.0, 11060.0, 11337.0, 12264.0, 12588.0, 12992.0, 13262.85, 53986.12, 55214.23], "Electron affinity": 0.162}, "Sn": {"Atomic mass": 118.71, "Atomic no": 50, "Atomic orbitals": {"1s": -1026.762169, "2p": -141.821093, "2s": -151.523991, "3d": -17.657276, "3p": -25.117913, "3s": -29.125969, "4d": -1.004952, "4p": -3.211998, "4s": -4.546335, "5p": -0.14445, "5s": -0.369349}, "Atomic radius": 1.45, "Atomic radius calculated": 1.45, "Boiling point": "2875 K", "Brinell hardness": "51 MN m-2", "Bulk modulus": "58 GPa", "Coefficient of linear thermal expansion": "22 x10-6K-1", "Common oxidation states": [-4, 2, 4], "Critical temperature": "no data K", "Density of solid": "7310 kg m-3", "Electrical resistivity": "11.5 10-8 Ω m", "Electronic structure": "[Kr].4d10.5s2.5p2", "ICSD oxidation states": [2, 3, 4], "Ionic radii": {"4": 0.83}, "Liquid range": "2369.92 K", "Melting point": "505.08 K", "Mendeleev no": 83, "Mineral hardness": "1.5", "Molar volume": "16.29 cm3", "Name": "Tin", "Oxidation states": [-4, 2, 4], "Poissons ratio": "0.36", "Reflectivity": "54 %", "Refractive index": "no data", "Rigidity modulus": "18 GPa", "Shannon radii": {"4": {"IV": {"": {"crystal_radius": 0.69, "ionic_radius": 0.55}}, "V": {"": {"crystal_radius": 0.76, "ionic_radius": 0.62}}, "VI": {"": {"crystal_radius": 0.83, "ionic_radius": 0.69}}, "VII": {"": {"crystal_radius": 0.89, "ionic_radius": 0.75}}, "VIII": {"": {"crystal_radius": 0.95, "ionic_radius": 0.81}}}}, "Superconduction temperature": "3.72 K", "Thermal conductivity": "67 W m-1 K-1", "Van der waals radius": 2.17, "Velocity of sound": "2500 m s-1", "Vickers hardness": "no data MN m-2", "X": 1.96, "Youngs modulus": "50 GPa", "NMR Quadrupole Moment": {"Sn-119": -132.1}, "Metallic radius": 1.58, "iupac_ordering": 83, "IUPAC ordering": 83, "Ground level": "3P0", "Ionization energies": [7.343918, 14.63307, 30.506, 40.74, 77.03, 94.0, 112.9, 135.0, 156.0, 184.0, 208.0, 232.0, 258.0, 282.0, 379.0, 407.0, 437.0, 466.0, 506.0, 537.0, 608.0, 642.35, 1127.0, 1195.0, 1269.0, 1347.0, 1421.0, 1508.0, 1596.0, 1676.0, 1763.0, 1844.0, 2074.0, 2142.1, 2227.0, 2326.0, 2443.0, 2499.0, 2687.0, 2762.49, 6421.0, 6631.0, 6859.0, 7080.0, 7531.0, 7790.0, 8103.0, 8306.95, 34257.143, 35192.39], "Electron affinity": 1.1120702}, "Sr": {"Atomic mass": 87.62, "Atomic no": 38, "Atomic orbitals": {"1s": -572.870169, "2p": -69.745941, "2s": -76.491823, "3d": -4.813498, "3p": -9.301863, "3s": -11.771585, "4p": -0.844489, "4s": -1.455317, "5s": -0.131793}, "Atomic radius": 2.0, "Atomic radius calculated": 2.19, "Boiling point": "1655 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "22.5 x10-6K-1", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "2630 kg m-3", "Electrical resistivity": "13.5 10-8 Ω m", "Electronic structure": "[Kr].5s2", "ICSD oxidation states": [2], "Ionic radii": {"2": 1.32}, "Liquid range": "605 K", "Melting point": "1050 K", "Mendeleev no": 15, "Mineral hardness": "1.5", "Molar volume": "33.94 cm3", "Name": "Strontium", "Oxidation states": [2], "Poissons ratio": "0.28", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "6.1 GPa", "Shannon radii": {"2": {"VI": {"": {"crystal_radius": 1.32, "ionic_radius": 1.18}}, "VII": {"": {"crystal_radius": 1.35, "ionic_radius": 1.21}}, "VIII": {"": {"crystal_radius": 1.4, "ionic_radius": 1.26}}, "IX": {"": {"crystal_radius": 1.45, "ionic_radius": 1.31}}, "X": {"": {"crystal_radius": 1.5, "ionic_radius": 1.36}}, "XII": {"": {"crystal_radius": 1.58, "ionic_radius": 1.44}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "35 W m-1 K-1", "Van der waals radius": 2.49, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 0.95, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": {"Sr-87": 305.2}, "Metallic radius": 2.151, "iupac_ordering": 14, "IUPAC ordering": 14, "Ground level": "1S0", "Ionization energies": [5.69486745, 11.0302765, 42.88353, 56.28, 70.7, 88.0, 104.0, 121.21, 158.33, 177.3, 324.07, 362.0, 408.0, 454.0, 499.0, 562.0, 612.0, 665.0, 722.0, 774.0, 932.0, 982.1, 1038.0, 1105.0, 1165.0, 1211.0, 1333.4, 1387.19, 3344.7, 3497.0, 3664.0, 3830.0, 4053.0, 4232.0, 4465.0, 4612.397, 19345.588, 20025.233], "Electron affinity": 0.052066}, "Ta": {"Atomic mass": 180.94788, "Atomic no": 73, "Atomic orbitals": {"1s": -2275.371387, "2p": -357.248334, "2s": -372.828724, "3d": -63.942521, "3p": -77.440942, "3s": -84.658467, "4d": -8.265848, "4f": -1.199347, "4p": -13.71981, "4s": -16.713337, "5d": -0.182464, "5p": -1.37653, "5s": -2.223807, "6s": -0.174814}, "Atomic radius": 1.45, "Atomic radius calculated": 2.0, "Boiling point": "5731 K", "Brinell hardness": "800 MN m-2", "Bulk modulus": "200 GPa", "Coefficient of linear thermal expansion": "6.3 x10-6K-1", "Common oxidation states": [5], "Critical temperature": "no data K", "Density of solid": "16650 kg m-3", "Electrical resistivity": "13.5 10-8 Ω m", "Electronic structure": "[Xe].4f14.5d3.6s2", "ICSD oxidation states": [3, 4, 5], "Ionic radii": {"3": 0.86, "4": 0.82, "5": 0.78}, "Liquid range": "2441 K", "Melting point": "3290 K", "Mendeleev no": 52, "Mineral hardness": "6.5", "Molar volume": "10.85 cm3", "Name": "Tantalum", "Oxidation states": [-1, 2, 3, 4, 5], "Poissons ratio": "0.34", "Reflectivity": "78 %", "Refractive index": "no data", "Rigidity modulus": "69 GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 0.86, "ionic_radius": 0.72}}}, "4": {"VI": {"": {"crystal_radius": 0.82, "ionic_radius": 0.68}}}, "5": {"VI": {"": {"crystal_radius": 0.78, "ionic_radius": 0.64}}, "VII": {"": {"crystal_radius": 0.83, "ionic_radius": 0.69}}, "VIII": {"": {"crystal_radius": 0.88, "ionic_radius": 0.74}}}}, "Superconduction temperature": "4.47 K", "Thermal conductivity": "57 W m-1 K-1", "Van der waals radius": 2.22, "Velocity of sound": "3400 m s-1", "Vickers hardness": "873 MN m-2", "X": 1.5, "Youngs modulus": "186 GPa", "Metallic radius": 1.47, "iupac_ordering": 53, "IUPAC ordering": 53, "Ground level": "4F3/2", "Ionization energies": [7.549571, 16.2, 23.1, 35.0, 48.272, 94.01, 119.0, 139.0, 159.0, 180.0, 213.0, 235.0, 262.0, 304.0, 338.0, 363.0, 396.0, 439.0, 482.0, 530.0, 570.0, 610.0, 660.0, 700.0, 750.0, 790.0, 832.0, 1064.0, 1110.0, 1160.0, 1211.0, 1262.0, 1313.0, 1382.0, 1434.0, 1490.0, 1542.0, 1748.0, 1799.0, 1857.0, 1910.0, 2053.0, 2113.0, 2254.0, 2314.7, 3898.7, 4014.0, 4143.0, 4278.0, 4410.0, 4537.0, 4745.0, 4877.0, 5024.0, 5159.0, 5537.0, 5655.0, 5785.0, 5907.0, 6364.0, 6502.0, 6769.0, 6900.0, 15137.0, 15461.0, 15820.0, 16150.0, 17840.0, 18250.0, 18760.0, 19088.51, 76852.03, 78394.7], "Electron affinity": 0.32312}, "Tb": {"Atomic mass": 158.92535, "Atomic no": 65, "Atomic orbitals": {"1s": -1785.331942, "2p": -271.590585, "2s": -285.121013, "3d": -45.443863, "3p": -56.785113, "3s": -62.851563, "4d": -5.467662, "4f": -0.256311, "4p": -9.735637, "4s": -12.120486, "5p": -0.88723, "5s": -1.513669, "6s": -0.131677}, "Atomic radius": 1.75, "Atomic radius calculated": 2.25, "Boiling point": "3503 K", "Brinell hardness": "677 MN m-2", "Bulk modulus": "38.7 GPa", "Coefficient of linear thermal expansion": "10.3 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "8219 kg m-3", "Electrical resistivity": "115 10-8 Ω m", "Electronic structure": "[Xe].4f9.6s2", "ICSD oxidation states": [3, 4], "Ionic radii": {"3": 1.063, "4": 0.9}, "Liquid range": "1874 K", "Melting point": "1629 K", "Mendeleev no": 26, "Mineral hardness": "no data", "Molar volume": "19.30 cm3", "Name": "Terbium", "Oxidation states": [1, 3, 4], "Poissons ratio": "0.26", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "22 GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 1.063, "ionic_radius": 0.923}}, "VII": {"": {"crystal_radius": 1.12, "ionic_radius": 0.98}}, "VIII": {"": {"crystal_radius": 1.18, "ionic_radius": 1.04}}, "IX": {"": {"crystal_radius": 1.235, "ionic_radius": 1.095}}}, "4": {"VI": {"": {"crystal_radius": 0.9, "ionic_radius": 0.76}}, "VIII": {"": {"crystal_radius": 1.02, "ionic_radius": 0.88}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "11 W m-1 K-1", "Van der waals radius": 2.33, "Velocity of sound": "2620 m s-1", "Vickers hardness": "863 MN m-2", "X": 1.1, "Youngs modulus": "56 GPa", "Metallic radius": 1.781, "iupac_ordering": 39, "IUPAC ordering": 39, "Ground level": "6H\u00b015/2", "Ionization energies": [5.8638, 11.513, 21.82, 39.33, 66.5, 90.0, 108.0, 125.0, 143.0, 168.0, 186.0, 216.0, 250.0, 273.0, 294.0, 325.0, 358.0, 393.0, 426.6, 613.0, 651.0, 690.0, 732.0, 772.0, 816.0, 866.0, 909.0, 954.0, 997.0, 1165.0, 1208.0, 1256.0, 1301.0, 1393.0, 1443.0, 1559.0, 1610.4, 2750.0, 2852.0, 2961.0, 3078.0, 3189.0, 3300.0, 3458.0, 3573.0, 3698.0, 3814.0, 4139.0, 4242.0, 4355.0, 4460.0, 4760.0, 4877.0, 5103.0, 5217.0, 11673.0, 11957.0, 12272.0, 12563.0, 13658.0, 14003.0, 14434.0, 14721.02, 59739.3, 61049.65], "Electron affinity": 0.131318}, "Tc": {"Atomic mass": 98.0, "Atomic no": 43, "Atomic orbitals": {"1s": -745.742024, "2p": -96.61021, "2s": -104.567508, "3d": -9.33986, "3p": -15.041738, "3s": -18.135303, "4d": -0.270262, "4p": -1.64323, "4s": -2.550712, "5s": -0.183636}, "Atomic radius": 1.35, "Atomic radius calculated": 1.83, "Boiling point": "4538 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [4, 7], "Critical temperature": "no data K", "Density of solid": "11500 kg m-3", "Electrical resistivity": "about 22 10-8 Ω m", "Electronic structure": "[Kr].4d5.5s2", "Ionic radii": {"4": 0.785, "5": 0.74, "7": 0.7}, "Liquid range": "2108 K", "Melting point": "2430 K", "Mendeleev no": 59, "Mineral hardness": "no data", "Molar volume": "8.63 cm3", "Name": "Technetium", "Oxidation states": [-3, -1, 1, 2, 3, 4, 5, 6, 7], "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": {"4": {"VI": {"": {"crystal_radius": 0.785, "ionic_radius": 0.645}}}, "5": {"VI": {"": {"crystal_radius": 0.74, "ionic_radius": 0.6}}}, "7": {"IV": {"": {"crystal_radius": 0.51, "ionic_radius": 0.37}}, "VI": {"": {"crystal_radius": 0.7, "ionic_radius": 0.56}}}}, "Superconduction temperature": "7.8 K", "Thermal conductivity": "51 W m-1 K-1", "Van der waals radius": 2.16, "Velocity of sound": "no data m s-1", "Vickers hardness": "no data MN m-2", "X": 1.9, "Youngs modulus": "no data GPa", "Metallic radius": 1.363, "iupac_ordering": 60, "IUPAC ordering": 60, "Ground level": "6S5/2", "Ionization energies": [7.11938, 15.26, 29.55, 41.0, 57.0, 72.0, 88.0, 150.0, 169.0, 189.9, 214.0, 239.0, 262.08, 311.0, 338.55, 604.0, 655.0, 713.0, 773.0, 829.0, 904.0, 968.0, 1032.0, 1102.0, 1166.0, 1354.0, 1411.6, 1479.5, 1559.0, 1638.0, 1689.0, 1838.0, 1900.28, 4505.0, 4681.0, 4874.0, 5060.0, 5361.0, 5570.0, 5838.0, 6008.391, 25004.533, 25786.99], "Electron affinity": 0.552}, "Te": {"Atomic mass": 127.6, "Atomic no": 52, "Atomic orbitals": {"1s": -1115.831819, "2p": -156.808583, "2s": -167.021776, "3d": -20.887801, "3p": -28.860685, "3s": -33.137485, "4d": -1.608381, "4p": -4.100084, "4s": -5.572846, "5p": -0.226594, "5s": -0.520997}, "Atomic radius": 1.4, "Atomic radius calculated": 1.23, "Boiling point": "1261 K", "Brinell hardness": "180 MN m-2", "Bulk modulus": "65 GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Common oxidation states": [-2, 2, 4, 6], "Critical temperature": "no data K", "Density of solid": "6240 kg m-3", "Electrical resistivity": "about 10000 10-8 Ω m", "Electronic structure": "[Kr].4d10.5s2.5p4", "ICSD oxidation states": [-2, 4, -1, 6], "Ionic radii": {"-2": 2.07, "4": 1.11, "6": 0.7}, "Liquid range": "538.34 K", "Melting point": "722.66 K", "Mendeleev no": 92, "Mineral hardness": "2.25", "Molar volume": "20.46 cm3", "Name": "Tellurium", "Oxidation states": [-2, 2, 4, 5, 6], "Poissons ratio": "no data", "Reflectivity": "50 %", "Refractive index": "1.000991", "Rigidity modulus": "16 GPa", "Shannon radii": {"-2": {"VI": {"": {"crystal_radius": 2.07, "ionic_radius": 2.21}}}, "4": {"III": {"": {"crystal_radius": 0.66, "ionic_radius": 0.52}}, "IV": {"": {"crystal_radius": 0.8, "ionic_radius": 0.66}}, "VI": {"": {"crystal_radius": 1.11, "ionic_radius": 0.97}}}, "6": {"IV": {"": {"crystal_radius": 0.57, "ionic_radius": 0.43}}, "VI": {"": {"crystal_radius": 0.7, "ionic_radius": 0.56}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "3 W m-1 K-1", "Van der waals radius": 2.06, "Velocity of sound": "2610 m s-1", "Vickers hardness": "no data MN m-2", "X": 2.1, "Youngs modulus": "43 GPa", "Metallic radius": "no data", "iupac_ordering": 94, "IUPAC ordering": 94, "Ground level": "3P2", "Ionization energies": [9.009808, 18.6, 27.84, 37.4155, 59.3, 69.1, 124.2, 143.0, 167.0, 191.1, 215.0, 245.0, 272.0, 299.0, 328.0, 354.0, 461.0, 491.0, 522.0, 555.0, 599.0, 633.0, 709.0, 746.12, 1304.0, 1377.0, 1455.0, 1538.0, 1618.0, 1707.0, 1803.0, 1889.0, 1979.0, 2066.0, 2309.0, 2386.0, 2472.0, 2552.0, 2700.0, 2788.0, 2954.0, 3041.0, 7022.0, 7243.0, 7485.0, 7714.0, 8240.0, 8499.0, 8821.0, 9040.83, 37196.522, 38177.56], "Electron affinity": 1.9708757}, "Th": {"Atomic mass": 232.03806, "Atomic no": 90, "Atomic orbitals": {"1s": -3524.439052, "2p": -588.218112, "2s": -608.350958, "3d": -123.846396, "3p": -142.25581, "3s": -152.079741, "4d": -24.955184, "4f": -13.397389, "4p": -33.325252, "4s": -37.814094, "5d": -3.625729, "5p": -6.58281, "5s": -8.287057, "6d": -0.172896, "6p": -0.846921, "6s": -1.333769, "7s": -0.135872}, "Atomic radius": 1.8, "Atomic radius calculated": "no data", "Boiling point": "5093 K", "Brinell hardness": "400 MN m-2", "Bulk modulus": "54 GPa", "Coefficient of linear thermal expansion": "11.0 x10-6K-1", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "11724 kg m-3", "Electrical resistivity": "15 10-8 Ω m", "Electronic structure": "[Rn].6d2.7s2", "ICSD oxidation states": [4], "Ionic radii": {"4": 1.08}, "Liquid range": "2978 K", "Melting point": "2115 K", "Mendeleev no": 47, "Mineral hardness": "3.0", "Molar volume": "19.80 cm3", "Name": "Thorium", "Oxidation states": [2, 3, 4], "Poissons ratio": "0.27", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "31 GPa", "Shannon radii": {"4": {"VI": {"": {"crystal_radius": 1.08, "ionic_radius": 0.94}}, "VIII": {"": {"crystal_radius": 1.19, "ionic_radius": 1.05}}, "IX": {"": {"crystal_radius": 1.23, "ionic_radius": 1.09}}, "X": {"": {"crystal_radius": 1.27, "ionic_radius": 1.13}}, "XI": {"": {"crystal_radius": 1.32, "ionic_radius": 1.18}}, "XII": {"": {"crystal_radius": 1.35, "ionic_radius": 1.21}}}}, "Superconduction temperature": "1.38 K", "Thermal conductivity": "54 W m-1 K-1", "Van der waals radius": 2.45, "Velocity of sound": "2490 m s-1", "Vickers hardness": "350 MN m-2", "X": 1.3, "Youngs modulus": "79 GPa", "Metallic radius": 1.798, "iupac_ordering": 31, "IUPAC ordering": 31, "Ground level": "3F2", "Ionization energies": [6.3067, 12.1, 18.32, 28.648, 58.0, 69.1, 82.0, 95.0, 118.0, 133.0, 165.0, 181.0, 262.0, 285.0, 310.0, 336.0, 362.0, 389.0, 424.0, 451.0, 480.0, 508.0, 650.0, 680.0, 720.0, 750.0, 830.0, 870.0, 970.0, 1010.0, 1090.0, 1160.0, 1240.0, 1310.0, 1380.0, 1460.0, 1530.0, 1600.0, 1680.0, 1760.0, 1830.0, 1910.0, 1980.0, 2060.0, 2390.0, 2455.0, 2524.0, 2598.0, 2669.0, 2737.0, 2864.0, 2935.0, 3013.0, 3086.0, 3375.0, 3445.0, 3522.0, 3593.0, 3943.0, 4025.0, 4230.0, 4313.0, 6972.0, 7130.0, 7299.0, 7480.0, 7650.0, 7810.0, 8180.0, 8350.0, 8550.0, 8720.0, 9220.0, 9370.0, 9540.0, 9690.0, 10790.0, 10970.0, 11340.0, 11510.0, 24060.0, 24480.0, 24940.0, 25360.0, 29410.0, 29970.0, 30680.0, 31122.8, 123086.4, 125253.4], "Electron affinity": 1.17}, "Ti": {"Atomic mass": 47.867, "Atomic no": 22, "Atomic orbitals": {"1s": -177.276643, "2p": -16.285339, "2s": -19.457901, "3d": -0.17001, "3p": -1.422947, "3s": -2.258007, "4s": -0.167106}, "Atomic radius": 1.4, "Atomic radius calculated": 1.76, "Boiling point": "3560 K", "Brinell hardness": "716 MN m-2", "Bulk modulus": "110 GPa", "Coefficient of linear thermal expansion": "8.6 x10-6K-1", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "4507 kg m-3", "Electrical resistivity": "about 40 10-8 Ω m", "Electronic structure": "[Ar].3d2.4s2", "ICSD oxidation states": [2, 3, 4], "Ionic radii": {"2": 1.0, "3": 0.81, "4": 0.745}, "Liquid range": "1619 K", "Melting point": "1941 K", "Mendeleev no": 51, "Mineral hardness": "6.0", "Molar volume": "10.64 cm3", "Name": "Titanium", "Oxidation states": [-1, 2, 3, 4], "Poissons ratio": "0.32", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "44 GPa", "Shannon radii": {"2": {"VI": {"": {"crystal_radius": 1.0, "ionic_radius": 0.86}}}, "3": {"VI": {"": {"crystal_radius": 0.81, "ionic_radius": 0.67}}}, "4": {"IV": {"": {"crystal_radius": 0.56, "ionic_radius": 0.42}}, "V": {"": {"crystal_radius": 0.65, "ionic_radius": 0.51}}, "VI": {"": {"crystal_radius": 0.745, "ionic_radius": 0.605}}, "VIII": {"": {"crystal_radius": 0.88, "ionic_radius": 0.74}}}}, "Superconduction temperature": "0.40 K", "Thermal conductivity": "22 W m-1 K-1", "Van der waals radius": 2.11, "Velocity of sound": "4140 m s-1", "Vickers hardness": "970 MN m-2", "X": 1.54, "Youngs modulus": "116 GPa", "NMR Quadrupole Moment": {"Ti-47": 302.1, "Ti-49": 247.11}, "Metallic radius": 1.462, "iupac_ordering": 52, "IUPAC ordering": 52, "Ground level": "3F2", "Ionization energies": [6.82812, 13.5755, 27.49171, 43.26717, 99.299, 119.533, 140.68, 170.5, 192.1, 215.92, 265.07, 291.5, 787.67, 864.0, 944.5, 1042.5, 1130.2, 1220.3, 1346.3, 1425.257, 6249.0226, 6625.8073], "Electron affinity": 0.075545}, "Tl": {"Atomic mass": 204.3833, "Atomic no": 81, "Atomic orbitals": {"1s": -2827.569408, "2p": -457.255971, "2s": -474.953368, "3d": -88.328299, "3p": -104.099296, "3s": -112.52218, "4d": -14.008848, "4f": -4.835747, "4p": -20.797078, "4s": -24.471512, "5d": -0.674544, "5p": -2.59873, "5s": -3.811512, "6p": -0.101507, "6s": -0.28502}, "Atomic radius": 1.9, "Atomic radius calculated": 1.56, "Boiling point": "1746 K", "Brinell hardness": "26.4 MN m-2", "Bulk modulus": "43 GPa", "Coefficient of linear thermal expansion": "29.9 x10-6K-1", "Common oxidation states": [1, 3], "Critical temperature": "no data K", "Density of solid": "11850 kg m-3", "Electrical resistivity": "15 10-8 Ω m", "Electronic structure": "[Xe].4f14.5d10.6s2.6p1", "ICSD oxidation states": [1, 3], "Ionic radii": {"1": 1.64, "3": 1.025}, "Liquid range": "1169 K", "Melting point": "577 K", "Mendeleev no": 78, "Mineral hardness": "1.2", "Molar volume": "17.22 cm3", "Name": "Thallium", "Oxidation states": [1, 3], "Poissons ratio": "0.45", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "2.8 GPa", "Shannon radii": {"1": {"VI": {"": {"crystal_radius": 1.64, "ionic_radius": 1.5}}, "VIII": {"": {"crystal_radius": 1.73, "ionic_radius": 1.59}}, "XII": {"": {"crystal_radius": 1.84, "ionic_radius": 1.7}}}, "3": {"IV": {"": {"crystal_radius": 0.89, "ionic_radius": 0.75}}, "VI": {"": {"crystal_radius": 1.025, "ionic_radius": 0.885}}, "VIII": {"": {"crystal_radius": 1.12, "ionic_radius": 0.98}}}}, "Superconduction temperature": "2.38 K", "Thermal conductivity": "46 W m-1 K-1", "Van der waals radius": 1.96, "Velocity of sound": "818 m s-1", "Vickers hardness": "no data MN m-2", "X": 1.62, "Youngs modulus": "8 GPa", "Metallic radius": 1.7, "iupac_ordering": 77, "IUPAC ordering": 77, "Ground level": "2P\u00b01/2", "Ionization energies": [6.1082873, 20.4283, 29.852, 51.14, 62.6, 80.0, 97.9, 116.0, 135.0, 158.0, 177.0, 198.0, 218.3, 306.9, 340.0, 366.0, 392.0, 439.0, 467.0, 520.0, 570.0, 600.0, 640.0, 700.0, 760.0, 820.0, 880.0, 930.0, 990.0, 1060.0, 1110.0, 1170.0, 1230.0, 1290.0, 1350.0, 1625.0, 1681.0, 1740.0, 1802.0, 1862.0, 1920.0, 2014.0, 2075.0, 2140.0, 2202.0, 2447.0, 2508.0, 2574.0, 2635.0, 2854.0, 2925.0, 3094.0, 3164.7, 5234.0, 5371.0, 5518.0, 5674.0, 5824.0, 5969.0, 6241.0, 6392.0, 6560.0, 6714.0, 7146.0, 7281.0, 7430.0, 7570.0, 8260.0, 8420.0, 8730.0, 8880.0, 19070.0, 19440.0, 19840.0, 20210.0, 22780.0, 23250.0, 23850.0, 24234.1, 96783.21, 98591.6], "Electron affinity": 0.32005319}, "Tm": {"Atomic mass": 168.93421, "Atomic no": 69, "Atomic orbitals": {"1s": -2022.471608, "2p": -312.510608, "2s": -327.05712, "3d": -53.835494, "3p": -66.239338, "3s": -72.873753, "4d": -6.350307, "4f": -0.28312, "4p": -11.187151, "4s": -13.865665, "5p": -0.950748, "5s": -1.64999, "6s": -0.135953}, "Atomic radius": 1.75, "Atomic radius calculated": 2.22, "Boiling point": "2223 K", "Brinell hardness": "471 MN m-2", "Bulk modulus": "45 GPa", "Coefficient of linear thermal expansion": "13.3 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "9321 kg m-3", "Electrical resistivity": "67.6 10-8 Ω m", "Electronic structure": "[Xe].4f13.6s2", "ICSD oxidation states": [3], "Ionic radii": {"2": 1.17, "3": 1.02}, "Liquid range": "405 K", "Melting point": "1818 K", "Mendeleev no": 21, "Mineral hardness": "no data", "Molar volume": "19.1 cm3", "Name": "Thulium", "Oxidation states": [2, 3], "Poissons ratio": "0.21", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "31 GPa", "Shannon radii": {"2": {"VI": {"": {"crystal_radius": 1.17, "ionic_radius": 1.03}}, "VII": {"": {"crystal_radius": 1.23, "ionic_radius": 1.09}}}, "3": {"VI": {"": {"crystal_radius": 1.02, "ionic_radius": 0.88}}, "VIII": {"": {"crystal_radius": 1.134, "ionic_radius": 0.994}}, "IX": {"": {"crystal_radius": 1.192, "ionic_radius": 1.052}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "17 W m-1 K-1", "Van der waals radius": 2.27, "Velocity of sound": "no data m s-1", "Vickers hardness": "520 MN m-2", "X": 1.25, "Youngs modulus": "74 GPa", "Metallic radius": 1.747, "iupac_ordering": 35, "IUPAC ordering": 35, "Ground level": "2F\u00b07/2", "Ionization energies": [6.18431, 12.065, 23.66, 42.41, 65.4, 98.0, 116.0, 133.0, 160.0, 180.0, 205.0, 239.0, 274.0, 295.0, 317.0, 352.0, 387.0, 424.0, 460.0, 496.0, 530.0, 570.0, 603.0, 825.0, 866.0, 911.0, 958.0, 1004.0, 1050.0, 1110.0, 1157.0, 1207.0, 1255.0, 1442.0, 1490.0, 1542.0, 1591.0, 1706.0, 1761.0, 1889.0, 1945.2, 3298.0, 3409.0, 3528.0, 3653.0, 3775.0, 3895.0, 4075.0, 4199.0, 4335.0, 4461.0, 4812.0, 4922.0, 5044.0, 5157.0, 5527.0, 5656.0, 5901.0, 6023.0, 13347.0, 13651.0, 13988.0, 14300.0, 15663.0, 16036.0, 16510.0, 16814.34, 67965.26, 69387.3], "Electron affinity": 1.02922}, "U": {"Atomic mass": 238.02891, "Atomic no": 92, "Atomic orbitals": {"1s": -3689.355141, "2p": -619.10855, "2s": -639.778728, "3d": -131.977358, "3p": -150.97898, "3s": -161.118073, "4d": -27.123212, "4f": -15.02746, "4p": -35.853321, "4s": -40.528084, "5d": -3.866175, "5f": -0.366543, "5p": -7.018092, "5s": -8.824089, "6d": -0.14319, "6p": -0.822538, "6s": -1.325976, "7s": -0.130948}, "Atomic radius": 1.75, "Atomic radius calculated": "no data", "Boiling point": "4200 K", "Brinell hardness": "2400 MN m-2", "Bulk modulus": "100 GPa", "Coefficient of linear thermal expansion": "13.9 x10-6K-1", "Common oxidation states": [6], "Critical temperature": "no data K", "Density of solid": "19050 kg m-3", "Electrical resistivity": "28 10-8 Ω m", "Electronic structure": "[Rn].5f3.6d1.7s2", "ICSD oxidation states": [3, 4, 5, 6], "Ionic radii": {"3": 1.165, "4": 1.03, "5": 0.9, "6": 0.87}, "Liquid range": "2794.7 K", "Melting point": "1405.3 K", "Mendeleev no": 45, "Mineral hardness": "6.0", "Molar volume": "12.49 cm3", "Name": "Uranium", "Oxidation states": [3, 4, 5, 6], "Poissons ratio": "0.23", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "111 GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 1.165, "ionic_radius": 1.025}}}, "4": {"VI": {"": {"crystal_radius": 1.03, "ionic_radius": 0.89}}, "VII": {"": {"crystal_radius": 1.09, "ionic_radius": 0.95}}, "VIII": {"": {"crystal_radius": 1.14, "ionic_radius": 1.0}}, "IX": {"": {"crystal_radius": 1.19, "ionic_radius": 1.05}}, "XII": {"": {"crystal_radius": 1.31, "ionic_radius": 1.17}}}, "5": {"VI": {"": {"crystal_radius": 0.9, "ionic_radius": 0.76}}, "VII": {"": {"crystal_radius": 0.98, "ionic_radius": 0.84}}}, "6": {"II": {"": {"crystal_radius": 0.59, "ionic_radius": 0.45}}, "IV": {"": {"crystal_radius": 0.66, "ionic_radius": 0.52}}, "VI": {"": {"crystal_radius": 0.87, "ionic_radius": 0.73}}, "VII": {"": {"crystal_radius": 0.95, "ionic_radius": 0.81}}, "VIII": {"": {"crystal_radius": 1.0, "ionic_radius": 0.86}}}}, "Superconduction temperature": "0.2 K", "Thermal conductivity": "27 W m-1 K-1", "Van der waals radius": 2.41, "Velocity of sound": "3155 m s-1", "Vickers hardness": "1960 MN m-2", "X": 1.38, "Youngs modulus": "208 GPa", "Metallic radius": 1.542, "iupac_ordering": 29, "IUPAC ordering": 29, "Ground level": "5L\u00b06", "Ionization energies": [6.19405, 11.6, 19.8, 36.7, 46.0, 62.0, 89.0, 101.0, 116.0, 128.9, 158.0, 173.0, 210.0, 227.0, 323.0, 348.0, 375.0, 402.0, 431.0, 458.0, 497.0, 525.0, 557.0, 585.0, 730.0, 770.0, 800.0, 840.0, 930.0, 970.0, 1070.0, 1110.0, 1210.0, 1290.0, 1370.0, 1440.0, 1520.0, 1590.0, 1670.0, 1750.0, 1830.0, 1910.0, 1990.0, 2070.0, 2140.0, 2220.0, 2578.0, 2646.0, 2718.0, 2794.0, 2867.0, 2938.0, 3073.0, 3147.0, 3228.0, 3301.0, 3602.0, 3675.0, 3753.0, 3827.0, 4214.0, 4299.0, 4513.0, 4598.0, 7393.0, 7550.0, 7730.0, 7910.0, 8090.0, 8260.0, 8650.0, 8830.0, 9030.0, 9210.0, 9720.0, 9870.0, 10040.0, 10200.0, 11410.0, 11600.0, 11990.0, 12160.0, 25260.0, 25680.0, 26150.0, 26590.0, 31060.0, 31640.0, 32400.0, 32836.5, 129570.3, 131821.0], "Electron affinity": 0.53}, "V": {"Atomic mass": 50.9415, "Atomic no": 23, "Atomic orbitals": {"1s": -195.224014, "2p": -18.435189, "2s": -21.815346, "3d": -0.204634, "3p": -1.610516, "3s": -2.526904, "4s": -0.175968}, "Atomic radius": 1.35, "Atomic radius calculated": 1.71, "Boiling point": "3680 K", "Brinell hardness": "628 MN m-2", "Bulk modulus": "160 GPa", "Coefficient of linear thermal expansion": "8.4 x10-6K-1", "Common oxidation states": [5], "Critical temperature": "no data K", "Density of solid": "6110 kg m-3", "Electrical resistivity": "20 10-8 Ω m", "Electronic structure": "[Ar].3d3.4s2", "ICSD oxidation states": [2, 3, 4, 5], "Ionic radii": {"2": 0.93, "3": 0.78, "4": 0.72, "5": 0.68}, "Liquid range": "1497 K", "Melting point": "2183 K", "Mendeleev no": 54, "Mineral hardness": "7.0", "Molar volume": "8.32 cm3", "Name": "Vanadium", "Oxidation states": [-1, 1, 2, 3, 4, 5], "Poissons ratio": "0.37", "Reflectivity": "61 %", "Refractive index": "no data", "Rigidity modulus": "47 GPa", "Shannon radii": {"2": {"VI": {"": {"crystal_radius": 0.93, "ionic_radius": 0.79}}}, "3": {"VI": {"": {"crystal_radius": 0.78, "ionic_radius": 0.64}}}, "4": {"V": {"": {"crystal_radius": 0.67, "ionic_radius": 0.53}}, "VI": {"": {"crystal_radius": 0.72, "ionic_radius": 0.58}}, "VIII": {"": {"crystal_radius": 0.86, "ionic_radius": 0.72}}}, "5": {"IV": {"": {"crystal_radius": 0.495, "ionic_radius": 0.355}}, "V": {"": {"crystal_radius": 0.6, "ionic_radius": 0.46}}, "VI": {"": {"crystal_radius": 0.68, "ionic_radius": 0.54}}}}, "Superconduction temperature": "5.40 K", "Thermal conductivity": "31 W m-1 K-1", "Van der waals radius": 2.07, "Velocity of sound": "4560 m s-1", "Vickers hardness": "628 MN m-2", "X": 1.63, "Youngs modulus": "128 GPa", "NMR Quadrupole Moment": {"V-50": 210.4, "V-51": -52.1}, "Metallic radius": 1.347, "iupac_ordering": 55, "IUPAC ordering": 55, "Ground level": "4F3/2", "Ionization energies": [6.746187, 14.634, 29.3111, 46.709, 65.28165, 128.125, 150.72, 173.55, 206.0, 230.5, 254.8, 308.5, 336.274, 896.0, 977.2, 1062.9, 1165.2, 1258.9, 1354.2, 1486.7, 1569.656, 6851.3109, 7246.1226], "Electron affinity": 0.527662}, "W": {"Atomic mass": 183.84, "Atomic no": 74, "Atomic orbitals": {"1s": -2341.042887, "2p": -369.013973, "2s": -384.856157, "3d": -66.724787, "3p": -80.502102, "3s": -87.867792, "4d": -8.879693, "4f": -1.550835, "4p": -14.495102, "4s": -17.570797, "5d": -0.220603, "5p": -1.504457, "5s": -2.396018, "6s": -0.181413}, "Atomic radius": 1.35, "Atomic radius calculated": 1.93, "Boiling point": "5828 K", "Brinell hardness": "2570 MN m-2", "Bulk modulus": "310 GPa", "Coefficient of linear thermal expansion": "4.5 x10-6K-1", "Common oxidation states": [4, 6], "Critical temperature": "no data K", "Density of solid": "19250 kg m-3", "Electrical resistivity": "5.4 10-8 Ω m", "Electronic structure": "[Xe].4f14.5d4.6s2", "ICSD oxidation states": [2, 3, 4, 5, 6], "Ionic radii": {"4": 0.8, "5": 0.76, "6": 0.74}, "Liquid range": "2133 K", "Melting point": "3695 K", "Mendeleev no": 55, "Mineral hardness": "7.5", "Molar volume": "9.47 cm3", "Name": "Tungsten", "Oxidation states": [-2, -1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "0.28", "Reflectivity": "62 %", "Refractive index": "no data", "Rigidity modulus": "161 GPa", "Shannon radii": {"4": {"VI": {"": {"crystal_radius": 0.8, "ionic_radius": 0.66}}}, "5": {"VI": {"": {"crystal_radius": 0.76, "ionic_radius": 0.62}}}, "6": {"IV": {"": {"crystal_radius": 0.56, "ionic_radius": 0.42}}, "V": {"": {"crystal_radius": 0.65, "ionic_radius": 0.51}}, "VI": {"": {"crystal_radius": 0.74, "ionic_radius": 0.6}}}}, "Superconduction temperature": "0.015 K", "Thermal conductivity": "170 W m-1 K-1", "Van der waals radius": 2.18, "Velocity of sound": "5174 m s-1", "Vickers hardness": "3430 MN m-2", "X": 2.36, "Youngs modulus": "411 GPa", "Metallic radius": 1.41, "iupac_ordering": 56, "IUPAC ordering": 56, "Ground level": "5D0", "Ionization energies": [7.86403, 16.37, 26.0, 38.2, 51.6, 64.77, 122.01, 141.2, 160.2, 179.0, 208.9, 231.6, 258.3, 290.7, 325.3, 361.9, 387.9, 420.7, 462.1, 502.6, 543.4, 594.5, 640.6, 685.6, 734.1, 784.4, 833.4, 881.4, 1132.2, 1180.0, 1230.4, 1283.4, 1335.1, 1386.8, 1459.9, 1512.4, 1569.1, 1621.7, 1829.8, 1882.9, 1940.6, 1994.8, 2149.1, 2210.0, 2354.5, 2414.1, 4057.0, 4180.0, 4309.0, 4446.0, 4578.0, 4709.0, 4927.0, 5063.0, 5209.0, 5348.0, 5719.0, 5840.0, 5970.0, 6093.0, 6596.0, 6735.0, 7000.0, 7130.0, 15566.0, 15896.0, 16252.0, 16588.0, 18476.0, 18872.0, 19362.0, 19686.74, 79181.94, 80755.6], "Electron affinity": 0.816268}, "Xe": {"Atomic mass": 131.293, "Atomic no": 54, "Atomic orbitals": {"1s": -1208.688993, "2p": -172.599583, "2s": -183.327495, "3d": -24.37823, "3p": -32.867042, "3s": -37.415454, "4d": -2.286666, "4p": -5.063802, "4s": -6.67834, "5p": -0.309835, "5s": -0.672086}, "Atomic radius": "no data", "Atomic radius calculated": 1.08, "Boiling point": "165.1 K", "Brinell hardness": "no data MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10-6K-1", "Critical temperature": "289.7 K", "Density of solid": "no data kg m-3", "Electrical resistivity": "no data 10-8 Ω m", "Electronic structure": "[Kr].4d10.5s2.5p6", "Ionic radii": {"8": 0.62}, "Liquid range": "3.7 K", "Max oxidation state": 8.0, "Melting point": "161.4 K", "Mendeleev no": 5, "Min oxidation state": 2.0, "Mineral hardness": "no data", "Molar volume": "35.92 cm3", "Name": "Xenon", "Poissons ratio": "no data", "Reflectivity": "no data %", "Refractive index": "1.000702", "Rigidity modulus": "no data GPa", "Shannon radii": {"8": {"IV": {"": {"crystal_radius": 0.54, "ionic_radius": 0.4}}, "VI": {"": {"crystal_radius": 0.62, "ionic_radius": 0.48}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "0.00565 W m-1 K-1", "Van der waals radius": 2.16, "Velocity of sound": "1090 m s-1", "Vickers hardness": "no data MN m-2", "X": 2.6, "Youngs modulus": "no data GPa", "Metallic radius": "no data", "iupac_ordering": 1, "IUPAC ordering": 1, "Ground level": "1S0", "Ionization energies": [12.1298437, 20.975, 31.05, 42.2, 54.1, 66.703, 91.6, 105.9778, 179.84, 202.0, 229.02, 255.0, 281.0, 314.0, 343.0, 374.0, 404.0, 434.0, 549.0, 582.0, 616.0, 650.0, 700.0, 736.0, 818.0, 857.0, 1493.0, 1571.0, 1653.0, 1742.0, 1826.0, 1919.0, 2023.0, 2113.0, 2209.0, 2300.0, 2556.0, 2637.0, 2726.0, 2811.0, 2975.0, 3068.0, 3243.0, 3333.8, 7660.0, 7889.0, 8144.0, 8382.0, 8971.0, 9243.0, 9581.0, 9810.37, 40271.724, 41299.71], "Electron affinity": -0.82}, "Y": {"Atomic mass": 88.90585, "Atomic no": 39, "Atomic orbitals": {"1s": -605.631981, "2p": -74.803201, "2s": -81.789102, "3d": -5.671499, "3p": -10.399926, "3s": -12.992217, "4d": -0.108691, "4p": -1.02449, "4s": -1.697124, "5s": -0.150727}, "Atomic radius": 1.8, "Atomic radius calculated": 2.12, "Boiling point": "3609 K", "Brinell hardness": "589 MN m-2", "Bulk modulus": "41 GPa", "Coefficient of linear thermal expansion": "10.6 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "4472 kg m-3", "Electrical resistivity": "about 60 10-8 Ω m", "Electronic structure": "[Kr].4d1.5s2", "ICSD oxidation states": [3], "Ionic radii": {"3": 1.04}, "Liquid range": "1810 K", "Melting point": "1799 K", "Mendeleev no": 25, "Mineral hardness": "no data", "Molar volume": "19.88 cm3", "Name": "Yttrium", "Oxidation states": [1, 2, 3], "Poissons ratio": "0.24", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "26 GPa", "Shannon radii": {"3": {"VI": {"": {"crystal_radius": 1.04, "ionic_radius": 0.9}}, "VII": {"": {"crystal_radius": 1.1, "ionic_radius": 0.96}}, "VIII": {"": {"crystal_radius": 1.159, "ionic_radius": 1.019}}, "IX": {"": {"crystal_radius": 1.215, "ionic_radius": 1.075}}}}, "Superconduction temperature": "1.3 (under pressure)K", "Thermal conductivity": "17 W m-1 K-1", "Van der waals radius": 2.32, "Velocity of sound": "3300 m s-1", "Vickers hardness": "no data MN m-2", "X": 1.22, "Youngs modulus": "64 GPa", "Metallic radius": 1.8, "iupac_ordering": 48, "IUPAC ordering": 48, "Ground level": "2D3/2", "Ionization energies": [6.21726, 12.2236, 20.52441, 60.6072, 75.35, 91.39, 110.02, 128.12, 145.64, 185.7, 205.814, 374.04, 414.0, 463.0, 512.0, 559.0, 624.0, 677.0, 733.0, 790.0, 847.0, 1010.0, 1061.9, 1120.2, 1190.0, 1253.0, 1300.0, 1427.6, 1483.12, 3562.9, 3720.0, 3892.0, 4060.0, 4299.0, 4484.0, 4724.0, 4875.731, 20415.717, 21115.55], "Electron affinity": 0.30712}, "Yb": {"Atomic mass": 173.04, "Atomic no": 70, "Atomic orbitals": {"1s": -2084.069389, "2p": -323.178219, "2s": -337.978976, "3d": -56.026315, "3p": -68.698655, "3s": -75.47663, "4d": -6.574963, "4f": -0.286408, "4p": -11.558246, "4s": -14.312076, "5p": -0.966137, "5s": -1.683886, "6s": -0.136989}, "Atomic radius": 1.75, "Atomic radius calculated": 2.22, "Boiling point": "1469 K", "Brinell hardness": "343 MN m-2", "Bulk modulus": "31 GPa", "Coefficient of linear thermal expansion": "26.3 x10-6K-1", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "6570 kg m-3", "Electrical resistivity": "25.0 10-8 Ω m", "Electronic structure": "[Xe].4f14.6s2", "ICSD oxidation states": [2, 3], "Ionic radii": {"2": 1.16, "3": 1.008}, "Liquid range": "372 K", "Melting point": "1097 K", "Mendeleev no": 17, "Mineral hardness": "no data", "Molar volume": "24.84 cm3", "Name": "Ytterbium", "Oxidation states": [2, 3], "Poissons ratio": "0.21", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "9.9 GPa", "Shannon radii": {"2": {"VI": {"": {"crystal_radius": 1.16, "ionic_radius": 1.02}}, "VII": {"": {"crystal_radius": 1.22, "ionic_radius": 1.08}}, "VIII": {"": {"crystal_radius": 1.28, "ionic_radius": 1.14}}}, "3": {"VI": {"": {"crystal_radius": 1.008, "ionic_radius": 0.868}}, "VII": {"": {"crystal_radius": 1.065, "ionic_radius": 0.925}}, "VIII": {"": {"crystal_radius": 1.125, "ionic_radius": 0.985}}, "IX": {"": {"crystal_radius": 1.182, "ionic_radius": 1.042}}}}, "Superconduction temperature": "no data K", "Thermal conductivity": "39 W m-1 K-1", "Van der waals radius": 2.26, "Velocity of sound": "1590 m s-1", "Vickers hardness": "206 MN m-2", "X": 1.1, "Youngs modulus": "24 GPa", "Metallic radius": 1.94, "iupac_ordering": 34, "IUPAC ordering": 34, "Ground level": "1S0", "Ionization energies": [6.25416, 12.179185, 25.053, 43.61, 65.6, 99.0, 117.0, 135.0, 163.0, 182.0, 209.0, 244.0, 279.0, 301.0, 324.0, 360.0, 396.0, 431.0, 469.0, 505.0, 540.0, 580.0, 610.0, 651.0, 882.0, 924.0, 971.0, 1019.0, 1065.0, 1114.0, 1175.0, 1224.0, 1275.0, 1324.0, 1516.0, 1564.0, 1618.0, 1668.0, 1789.0, 1845.0, 1978.0, 2036.4, 3443.0, 3555.0, 3677.0, 3805.0, 3929.0, 4051.0, 4238.0, 4364.0, 4502.0, 4630.0, 4988.0, 5101.0, 5224.0, 5339.0, 5731.0, 5860.0, 6111.0, 6236.0, 13784.0, 14093.0, 14435.0, 14752.0, 16191.0, 16570.0, 17050.0, 17365.44, 70123.04, 71574.8], "Electron affinity": -0.02}, "Zn": {"Atomic mass": 65.409, "Atomic no": 30, "Atomic orbitals": {"1s": -344.969756, "2p": -36.648765, "2s": -41.531323, "3d": -0.398944, "3p": -3.022363, "3s": -4.573041, "4s": -0.222725}, "Atomic radius": 1.35, "Atomic radius calculated": 1.42, "Boiling point": "1180 K", "Brinell hardness": "412 MN m-2", "Bulk modulus": "70 GPa", "Coefficient of linear thermal expansion": "30.2 x10-6K-1", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "7140 kg m-3", "Electrical resistivity": "6.0 10-8 Ω m", "Electronic structure": "[Ar].3d10.4s2", "ICSD oxidation states": [2], "Ionic radii": {"2": 0.88}, "Liquid range": "487.32 K", "Melting point": "692.68 K", "Mendeleev no": 76, "Mineral hardness": "2.5", "Molar volume": "9.16 cm3", "Name": "Zinc", "Oxidation states": [1, 2], "Poissons ratio": "0.25", "Reflectivity": "80 %", "Refractive index": "1.002050", "Rigidity modulus": "43 GPa", "Shannon radii": {"2": {"IV": {"": {"crystal_radius": 0.74, "ionic_radius": 0.6}}, "V": {"": {"crystal_radius": 0.82, "ionic_radius": 0.68}}, "VI": {"": {"crystal_radius": 0.88, "ionic_radius": 0.74}}, "VIII": {"": {"crystal_radius": 1.04, "ionic_radius": 0.9}}}}, "Superconduction temperature": "0.85 K", "Thermal conductivity": "120 W m-1 K-1", "Van der waals radius": 2.01, "Velocity of sound": "3700 m s-1", "Vickers hardness": "no data MN m-2", "X": 1.65, "Youngs modulus": "108 GPa", "NMR Quadrupole Moment": {"Zn-67": 150.15}, "Metallic radius": 1.34, "iupac_ordering": 76, "IUPAC ordering": 76, "Ground level": "1S0", "Ionization energies": [9.394197, 17.96439, 39.7233, 59.573, 82.6, 108.0, 133.9, 173.9, 203.0, 238.0, 274.4, 310.8, 417.6, 453.4, 490.6, 540.0, 577.8, 613.3, 697.5, 737.366, 1846.8, 1961.0, 2085.0, 2214.0, 2358.0, 2491.5, 2669.9, 2781.996, 11864.9399, 12388.929], "Electron affinity": -0.62}, "Zr": {"Atomic mass": 91.224, "Atomic no": 40, "Atomic orbitals": {"1s": -639.292236, "2p": -80.010043, "2s": -87.237062, "3d": -6.544643, "3p": -11.514415, "3s": -14.230432, "4d": -0.150673, "4p": -1.186597, "4s": -1.918971, "5s": -0.162391}, "Atomic radius": 1.55, "Atomic radius calculated": 2.06, "Boiling point": "4682 K", "Brinell hardness": "650 MN m-2", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "5.7 x10-6K-1", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "6511 kg m-3", "Electrical resistivity": "43.3 10-8 Ω m", "Electronic structure": "[Kr].4d2.5s2", "ICSD oxidation states": [2, 3, 4], "Ionic radii": {"4": 0.86}, "Liquid range": "2554 K", "Melting point": "2128 K", "Mendeleev no": 49, "Mineral hardness": "5.0", "Molar volume": "14.02 cm3", "Name": "Zirconium", "Oxidation states": [1, 2, 3, 4], "Poissons ratio": "0.34", "Reflectivity": "no data %", "Refractive index": "no data", "Rigidity modulus": "33 GPa", "Shannon radii": {"4": {"IV": {"": {"crystal_radius": 0.73, "ionic_radius": 0.59}}, "V": {"": {"crystal_radius": 0.8, "ionic_radius": 0.66}}, "VI": {"": {"crystal_radius": 0.86, "ionic_radius": 0.72}}, "VII": {"": {"crystal_radius": 0.92, "ionic_radius": 0.78}}, "VIII": {"": {"crystal_radius": 0.98, "ionic_radius": 0.84}}, "IX": {"": {"crystal_radius": 1.03, "ionic_radius": 0.89}}}}, "Superconduction temperature": "0.61 K", "Thermal conductivity": "23 W m-1 K-1", "Van der waals radius": 2.23, "Velocity of sound": "3800 m s-1", "Vickers hardness": "903 MN m-2", "X": 1.33, "Youngs modulus": "68 GPa", "Metallic radius": 1.602, "iupac_ordering": 51, "IUPAC ordering": 51, "Ground level": "3F2", "Ionization energies": [6.634126, 13.13, 23.17, 34.41836, 80.348, 96.38, 112.0, 133.7, 153.0, 172.02, 214.9, 236.252, 426.0, 470.0, 520.0, 573.0, 622.0, 690.0, 745.0, 803.0, 863.0, 922.0, 1092.0, 1144.7, 1205.4, 1277.0, 1344.0, 1392.0, 1525.1, 1582.37, 3788.0, 3950.0, 4127.0, 4300.0, 4553.0, 4744.0, 4991.0, 5146.935, 21516.469, 22236.678], "Electron affinity": 0.433289}, "Rf": {"Atomic mass": 267, "Atomic no": 104, "Name": "Rutherfordium", "Ground level": "3F2", "Ionization energies": [6.02, 14.35, 23.84, 31.87, 64.0, 77.0, 102.0, 119.0, 146.1, 169.0, 193.0, 225.0, 244.0, 275.0, null, 791.0, 825.0, 860.0, 899.0, 936.0, 972.0, 1036.0, 1073.0, 1114.0, 1151.0, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 3857.0, 3938.0, 4025.0, 4116.0, 4203.0, 4287.0, 4489.0, 4580.0, 4670.0, 4760.0, 5130.0, 5210.0, 5300.0, 5390.0, 6100.0, 6200.0, 6470.0, 6570.0, 10170.0, 10360.0, 10560.0, 10780.0, 10980.0, 11180.0, 11750.0, 11960.0, 12200.0, 12410.0, 13010.0, 13190.0, 13400.0, 13600.0, 15800.0, 16000.0, 16400.0, 16700.0, 33100.0, 33600.0, 34100.0, 34600.0, 42700.0, 43400.0, 44300.0, null, null, 177148.0], "Electron affinity": null, "Van der waals radius": "no data"}, "Db": {"Atomic mass": 268, "Atomic no": 105, "Name": "Dubnium", "Ground level": "4F3/2", "Ionization energies": [6.8, 14.0, 23.1, 33.0, 43.0, 86.0, 98.9, 126.0, 145.1, 172.0, 196.0, 220.9, 254.0, 274.0, 307.0, null, 838.0, 872.0, 908.0, 948.0, 985.0, 1022.0, 1089.0, 1126.0, 1168.0, 1207.0, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 3975.0, 4057.0, 4145.0, 4237.0, 4326.0, 4411.0, 4620.0, 4710.0, 4810.0, 4900.0, 5260.0, 5350.0, 5450.0, 5530.0, 6280.0, 6380.0, 6650.0, 6760.0, 10420.0, 10610.0, 10820.0, 11040.0, 11240.0, 11440.0, 12040.0, 12250.0, 12480.0, 12700.0, 13300.0, 13500.0, 13700.0, 13900.0, 16200.0, 16400.0, 16900.0, 17100.0, 33800.0, 34300.0, 34800.0, 35300.0, 43800.0, 44500.0, 45400.0, null, null, 181444.0], "Electron affinity": null, "Van der waals radius": "no data"}, "Sg": {"Atomic mass": 269, "Atomic no": 106, "Name": "Seaborgium", "Ground level": "0", "Ionization energies": [7.8, 17.1, 25.8, 35.5, 47.2, 59.3, 109.0, 122.0, 152.0, 170.0, 200.0, 224.0, 251.0, 285.0, 306.0, 339.0, null, 885.0, 921.0, 958.0, 998.0, 1036.0, 1073.0, 1143.0, 1181.0, 1223.0, 1263.0, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 4095.0, 4178.0, 4267.0, 4360.0, 4450.0, 4540.0, 4750.0, 4840.0, 4940.0, 5030.0, 5410.0, 5490.0, 5590.0, 5680.0, 6460.0, 6570.0, 6840.0, 6950.0, 10680.0, 10870.0, 11080.0, 11300.0, 11510.0, 11710.0, 12320.0, 12540.0, 12780.0, 12990.0, 13600.0, 13800.0, 14000.0, 14200.0, 16600.0, 16800.0, 17300.0, 17500.0, 34500.0, 35000.0, 35600.0, 36100.0, 44900.0, 45700.0, 46600.0, null, null, 185839.0], "Electron affinity": null, "Van der waals radius": "no data"}, "Bh": {"Atomic mass": 270, "Atomic no": 107, "Name": "Bohrium", "Ground level": "5/2", "Ionization energies": [7.7, 17.5, 26.7, 37.3, 49.0, 62.1, 74.9, 134.0, 148.0, 178.0, 198.0, 228.0, 255.0, 281.0, 318.0, 337.0, 374.0, null, 934.0, 969.0, 1008.0, 1049.0, 1088.0, 1126.0, 1197.0, 1237.0, 1280.0, 1320.0, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 4216.0, 4301.0, 4390.0, 4486.0, 4580.0, 4660.0, 4890.0, 4980.0, 5080.0, 5170.0, 5550.0, 5640.0, 5740.0, 5830.0, 6650.0, 6760.0, 7040.0, 7140.0, 10930.0, 11130.0, 11340.0, 11560.0, 11780.0, 11980.0, 12610.0, 12830.0, 13070.0, 13300.0, 13900.0, 14100.0, 14300.0, 14500.0, 17000.0, 17300.0, 17700.0, 18000.0, 35200.0, 35700.0, 36300.0, 36800.0, 46100.0, 46900.0, 47800.0, null, null, 190331.0], "Electron affinity": null, "Van der waals radius": "no data"}, "Hs": {"Atomic mass": 270, "Atomic no": 108, "Name": "Hassium", "Ground level": "4", "Ionization energies": [7.6, 18.2, 29.3, 37.7, 51.2, 64.0, 78.1, 91.7, 159.9, 173.9, 206.1, 227.0, 258.0, 285.0, 314.0, 351.0, 371.0, 409.0, null, 984.0, 1020.0, 1060.0, 1101.0, 1140.0, 1180.0, 1253.0, 1294.0, 1338.0, 1379.0, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 4339.0, 4425.0, 4516.0, 4610.0, 4700.0, 4790.0, 5020.0, 5110.0, 5220.0, 5310.0, 5700.0, 5780.0, 5880.0, 5980.0, 6840.0, 6950.0, 7230.0, 7340.0, 11200.0, 11390.0, 11610.0, 11830.0, 12040.0, 12250.0, 12910.0, 13130.0, 13400.0, 13600.0, 14200.0, 14400.0, 14600.0, 14800.0, 17500.0, 17700.0, 18200.0, 18400.0, 35900.0, 36400.0, 37000.0, 37500.0, 47300.0, 48100.0, 49000.0, null, null, 194917.0], "Electron affinity": null, "Van der waals radius": "no data"}, "Mt": {"Atomic mass": 278, "Atomic no": 109, "Name": "Meitnerium", "Ground level": null, "Ionization energies": [50.0, null, null, 94.0, 109.0, 187.0, 202.0, 235.9, 257.0, 289.0, 318.0, 346.0, 386.0, 406.0, 445.0, null, 1035.0, 1072.0, 1112.0, 1154.0, 1195.0, 1234.0, 1311.0, 1352.0, 1397.0, 1439.0, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 4464.0, 4551.0, 4640.0, 4740.0, 4830.0, 4920.0, 5160.0, 5250.0, 5360.0, 5450.0, 5840.0, 5930.0, 6030.0, 6130.0, 7030.0, 7150.0, 7430.0, 7550.0, 11460.0, 11660.0, 11870.0, 12100.0, 12320.0, 12530.0, 13200.0, 13400.0, 13700.0, 13900.0, 14500.0, 14700.0, 14900.0, 15100.0, 17900.0, 18200.0, 18700.0, 18900.0, 36700.0, 37200.0, 37800.0, 38300.0, 48500.0, 49400.0, 50300.0, null, null, 199606.0], "Electron affinity": null, "Van der waals radius": "no data"}, "Ds": {"Atomic mass": 281, "Atomic no": 110, "Name": "Darmstadtium", "Ground level": null, "Ionization energies": [65.0, null, null, 112.9, 128.0, 216.0, 231.0, 266.0, 288.0, 322.0, 352.0, 380.0, 422.0, 442.0, 483.0, null, 1087.0, 1125.0, 1165.0, 1208.0, 1250.0, 1290.0, 1369.0, 1412.0, 1457.0, 1500.0, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 4590.0, 4680.0, 4770.0, 4870.0, 4960.0, 5060.0, 5300.0, 5400.0, 5500.0, 5600.0, 5990.0, 6080.0, 6190.0, 6280.0, 7230.0, 7350.0, 7640.0, 7750.0, 11730.0, 11930.0, 12140.0, 12380.0, 12600.0, 12810.0, 13500.0, 13700.0, 14000.0, 14200.0, 14800.0, 15000.0, 15300.0, 15500.0, 18400.0, 18600.0, 19100.0, 19400.0, 37400.0, 37900.0, 38500.0, 39100.0, 49800.0, 50700.0, 51600.0, null, null, 204400.0], "Electron affinity": null, "Van der waals radius": "no data"}, "Rg": {"Atomic mass": 282, "Atomic no": 111, "Name": "Roentgenium", "Ground level": null, "Ionization energies": [], "Electron affinity": 1.565, "Van der waals radius": "no data"}, "Cn": {"Atomic mass": 285, "Atomic no": 112, "Name": "Copernicium", "Ground level": null, "Ionization energies": [], "Electron affinity": null, "Van der waals radius": "no data"}, "Nh": {"Atomic mass": 286, "Atomic no": 113, "Name": "Nihonium", "Ground level": null, "Ionization energies": [], "Electron affinity": 0.69, "Van der waals radius": "no data"}, "Fl": {"Atomic mass": 289, "Atomic no": 114, "Name": "Flerovium", "Ground level": null, "Ionization energies": [], "Electron affinity": null, "Van der waals radius": "no data"}, "Mc": {"Atomic mass": 290, "Atomic no": 115, "Name": "Moscovium", "Ground level": null, "Ionization energies": [], "Electron affinity": 0.366, "Van der waals radius": "no data"}, "Lv": {"Atomic mass": 293, "Atomic no": 116, "Name": "Livermorium", "Ground level": null, "Ionization energies": [], "Electron affinity": 0.776, "Van der waals radius": "no data"}, "Ts": {"Atomic mass": 294, "Atomic no": 117, "Name": "Tennessine", "Ground level": null, "Ionization energies": [], "Electron affinity": 1.719, "Van der waals radius": "no data"}, "Og": {"Atomic mass": 2949, "Atomic no": 118, "Name": "Oganesson", "Ground level": null, "Ionization energies": [], "Electron affinity": 0.0561, "Van der waals radius": "no data"}} \ No newline at end of file diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/preprocess_default.ini b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/preprocess_default.ini new file mode 100644 index 0000000000000000000000000000000000000000..ea0795d3944031a94a863d2bfd419fbcac26cd99 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/preprocess_default.ini @@ -0,0 +1,20 @@ +[basic] +raw_dir = /your/own/path +processed_dir = /your/own/path +target = hamiltonian +interface = openmx +multiprocessing = 0 +local_coordinate = True +get_S = False + +[interpreter] +julia_interpreter = julia + +[graph] +radius = -1.0 +create_from_DFT = True +r2_rand = False + +[magnetic_moment] +parse_magnetic_moment = False +magnetic_element = ["Cr", "Mn", "Fe", "Co", "Ni"] diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/siesta_get_data.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/siesta_get_data.py new file mode 100644 index 0000000000000000000000000000000000000000..f8840aecbdcd152153954f02d0ce6e8e42cb450c --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/preprocess/siesta_get_data.py @@ -0,0 +1,336 @@ +import os +import numpy as np +from numpy.core.fromnumeric import sort +import scipy as sp +import h5py +import json +from scipy.io import FortranFile + +# Transfer SIESTA output to DeepH format +# DeepH-pack: https://deeph-pack.readthedocs.io/en/latest/index.html +# Coded by ZC Tang @ Tsinghua Univ. e-mail: az_txycha@126.com + +def siesta_parse(input_path, output_path): + input_path = os.path.abspath(input_path) + output_path = os.path.abspath(output_path) + os.makedirs(output_path, exist_ok=True) + + # finds system name + f_list = os.listdir(input_path) + for f_name in f_list: + if f_name[::-1][0:9] == 'XDNI_BRO.': + system_name = f_name[:-9] + + with open('{}/{}.STRUCT_OUT'.format(input_path,system_name), 'r') as struct: # structure info from standard output + lattice = np.empty((3,3)) + for i in range(3): + line = struct.readline() + linesplit = line.split() + lattice[i,:] = linesplit[:] + np.savetxt('{}/lat.dat'.format(output_path), np.transpose(lattice), fmt='%.18e') + line = struct.readline() + linesplit = line.split() + num_atoms = int(linesplit[0]) + atom_coord = np.empty((num_atoms, 4)) + for i in range(num_atoms): + line = struct.readline() + linesplit = line.split() + atom_coord[i, :] = linesplit[1:] + np.savetxt('{}/element.dat'.format(output_path), atom_coord[:,0], fmt='%d') + + atom_coord_cart = np.genfromtxt('{}/{}.XV'.format(input_path,system_name),skip_header = 4) + atom_coord_cart = atom_coord_cart[:,2:5] * 0.529177249 + np.savetxt('{}/site_positions.dat'.format(output_path), np.transpose(atom_coord_cart)) + + orb_indx = np.genfromtxt('{}/{}.ORB_INDX'.format(input_path,system_name), skip_header=3, skip_footer=17) + # orb_indx rows: 0 orbital id 1 atom id 2 atom type 3 element symbol + # 4 orbital id within atom 5 n 6 l + # 7 m 8 zeta 9 Polarized? 10 orbital symmetry + # 11 rc(a.u.) 12-14 R 15 equivalent orbital index in uc + + orb_indx[:,12:15]=orb_indx[:,12:15] + + with open('{}/R_list.dat'.format(output_path),'w') as R_list_f: + R_prev = np.empty(3) + for i in range(len(orb_indx)): + R = orb_indx[i, 12:15] + if (R != R_prev).any(): + R_prev = R + R_list_f.write('{} {} {}\n'.format(int(R[0]), int(R[1]), int(R[2]))) + + ia2Riua = np.empty((0,4)) #DeepH key + ia = 0 + for i in range(len(orb_indx)): + if orb_indx[i][1] != ia: + ia = orb_indx[i][1] + Riua = np.empty((1,4)) + Riua[0,0:3] = orb_indx[i][12:15] + iuo = int(orb_indx[i][15]) + iua = int(orb_indx[iuo-1,1]) + Riua[0,3] = int(iua) + ia2Riua = np.append(ia2Riua, Riua) + ia2Riua = ia2Riua.reshape(int(len(ia2Riua)/4),4) + + + #hamiltonians.h5, density_matrixs.h5, overlap.h5 + info = {'nsites' : num_atoms, 'isorthogonal': False, 'isspinful': False, 'norbits': len(orb_indx)} + with open('{}/info.json'.format(output_path), 'w') as info_f: + json.dump(info, info_f) + + a1 = lattice[0, :] + a2 = lattice[1, :] + a3 = lattice[2, :] + b1 = 2 * np.pi * np.cross(a2, a3) / (np.dot(a1, np.cross(a2, a3))) + b2 = 2 * np.pi * np.cross(a3, a1) / (np.dot(a2, np.cross(a3, a1))) + b3 = 2 * np.pi * np.cross(a1, a2) / (np.dot(a3, np.cross(a1, a2))) + rlattice = np.array([b1, b2, b3]) + np.savetxt('{}/rlat.dat'.format(output_path), np.transpose(rlattice), fmt='%.18e') + + # Cope with orbital type information + i = 0 + with open('{}/orbital_types.dat'.format(output_path), 'w') as orb_type_f: + atom_current = 0 + while True: # Loop over atoms in unitcell + if atom_current != orb_indx[i, 1]: + if atom_current != 0: + for j in range(4): + for _ in range(int(atom_orb_cnt[j]/(2*j+1))): + orb_type_f.write('{} '.format(j)) + orb_type_f.write('\n') + + atom_current = int(orb_indx[i, 1]) + atom_orb_cnt = np.array([0,0,0,0]) # number of s, p, d, f orbitals in specific atom + l = int(orb_indx[i, 6]) + atom_orb_cnt[l] += 1 + i += 1 + if i > len(orb_indx)-1: + for j in range(4): + for _ in range(int(atom_orb_cnt[j]/(2*j+1))): + orb_type_f.write('{} '.format(j)) + orb_type_f.write('\n') + break + if orb_indx[i, 0] != orb_indx[i, 15]: + for j in range(4): + for _ in range(int(atom_orb_cnt[j]/(2*j+1))): + orb_type_f.write('{} '.format(j)) + orb_type_f.write('\n') + break + + # yields key for *.h5 file + orb2deephorb = np.zeros((len(orb_indx), 5)) + atom_current = 1 + orb_atom_current = np.empty((0)) # stores orbitals' id in siesta, n, l, m and z, will be reshaped into orb*5 + t = 0 + for i in range(len(orb_indx)): + orb_atom_current = np.append(orb_atom_current, i) + orb_atom_current = np.append(orb_atom_current, orb_indx[i,5:9]) + if i != len(orb_indx)-1 : + if orb_indx[i+1,1] != atom_current: + orb_atom_current = np.reshape(orb_atom_current,((int(len(orb_atom_current)/5),5))) + for j in range(len(orb_atom_current)): + if orb_atom_current[j,2] == 1: #p + if orb_atom_current[j,3] == -1: + orb_atom_current[j,3] = 0 + elif orb_atom_current[j,3] == 0: + orb_atom_current[j,3] = 1 + elif orb_atom_current[j,3] == 1: + orb_atom_current[j,3] = -1 + if orb_atom_current[j,2] == 2: #d + if orb_atom_current[j,3] == -2: + orb_atom_current[j,3] = 0 + elif orb_atom_current[j,3] == -1: + orb_atom_current[j,3] = 2 + elif orb_atom_current[j,3] == 0: + orb_atom_current[j,3] = -2 + elif orb_atom_current[j,3] == 1: + orb_atom_current[j,3] = 1 + elif orb_atom_current[j,3] == 2: + orb_atom_current[j,3] = -1 + if orb_atom_current[j,2] == 3: #f + if orb_atom_current[j,3] == -3: + orb_atom_current[j,3] = 0 + elif orb_atom_current[j,3] == -2: + orb_atom_current[j,3] = 1 + elif orb_atom_current[j,3] == -1: + orb_atom_current[j,3] = -1 + elif orb_atom_current[j,3] == 0: + orb_atom_current[j,3] = 2 + elif orb_atom_current[j,3] == 1: + orb_atom_current[j,3] = -2 + elif orb_atom_current[j,3] == 2: + orb_atom_current[j,3] = 3 + elif orb_atom_current[j,3] == 3: + orb_atom_current[j,3] = -3 + sort_index = np.zeros(len(orb_atom_current)) + for j in range(len(orb_atom_current)): + sort_index[j] = orb_atom_current[j,3] + 10 * orb_atom_current[j,4] + 100 * orb_atom_current[j,1] + 1000 * orb_atom_current[j,2] + orb_order = np.argsort(sort_index) + tmpt = np.empty(len(orb_order)) + for j in range(len(orb_order)): + tmpt[orb_order[j]] = j + orb_order = tmpt + for j in range(len(orb_atom_current)): + orb2deephorb[t,0:3] = np.round(orb_indx[t,12:15]) + orb2deephorb[t,3] = ia2Riua[int(orb_indx[t,1])-1,3] + orb2deephorb[t,4] = int(orb_order[j]) + t += 1 + atom_current += 1 + orb_atom_current = np.empty((0)) + + orb_atom_current = np.reshape(orb_atom_current,((int(len(orb_atom_current)/5),5))) + for j in range(len(orb_atom_current)): + if orb_atom_current[j,2] == 1: + if orb_atom_current[j,3] == -1: + orb_atom_current[j,3] = 0 + elif orb_atom_current[j,3] == 0: + orb_atom_current[j,3] = 1 + elif orb_atom_current[j,3] == 1: + orb_atom_current[j,3] = -1 + if orb_atom_current[j,2] == 2: + if orb_atom_current[j,3] == -2: + orb_atom_current[j,3] = 0 + elif orb_atom_current[j,3] == -1: + orb_atom_current[j,3] = 2 + elif orb_atom_current[j,3] == 0: + orb_atom_current[j,3] = -2 + elif orb_atom_current[j,3] == 1: + orb_atom_current[j,3] = 1 + elif orb_atom_current[j,3] == 2: + orb_atom_current[j,3] = -1 + if orb_atom_current[j,2] == 3: #f + if orb_atom_current[j,3] == -3: + orb_atom_current[j,3] = 0 + elif orb_atom_current[j,3] == -2: + orb_atom_current[j,3] = 1 + elif orb_atom_current[j,3] == -1: + orb_atom_current[j,3] = -1 + elif orb_atom_current[j,3] == 0: + orb_atom_current[j,3] = 2 + elif orb_atom_current[j,3] == 1: + orb_atom_current[j,3] = -2 + elif orb_atom_current[j,3] == 2: + orb_atom_current[j,3] = 3 + elif orb_atom_current[j,3] == 3: + orb_atom_current[j,3] = -3 + sort_index = np.zeros(len(orb_atom_current)) + for j in range(len(orb_atom_current)): + sort_index[j] = orb_atom_current[j,3] + 10 * orb_atom_current[j,4] + 100 * orb_atom_current[j,1] + 1000 * orb_atom_current[j,2] + orb_order = np.argsort(sort_index) + tmpt = np.empty(len(orb_order)) + for j in range(len(orb_order)): + tmpt[orb_order[j]] = j + orb_order = tmpt + for j in range(len(orb_atom_current)): + orb2deephorb[t,0:3] = np.round(orb_indx[t,12:15]) + orb2deephorb[t,3] = ia2Riua[int(orb_indx[t,1])-1,3] + orb2deephorb[t,4] = int(orb_order[j]) + t += 1 + + # Read Useful info of HSX, We only need H and S from this file, but due to structure of fortran unformatted, extra information must be read + f = FortranFile('{}/{}.HSX'.format(input_path,system_name), 'r') + tmpt = f.read_ints() # no_u, no_s, nspin, nh + no_u = tmpt[0] + no_s = tmpt[1] + nspin = tmpt[2] + nh = tmpt[3] + tmpt = f.read_ints() # gamma + tmpt = f.read_ints() # indxuo + tmpt = f.read_ints() # numh + maxnumh = max(tmpt) + listh = np.zeros((no_u, maxnumh),dtype=int) + for i in range(no_u): + tmpt=f.read_ints() # listh + for j in range(len(tmpt)): + listh[i,j] = tmpt[j] + + # finds set of connected atoms + connected_atoms = set() + for i in range(no_u): + for j in range(maxnumh): + if listh[i,j] == 0: + #print(j) + break + else: + atom_1 = int(orb2deephorb[i,3])#orbit i belongs to atom_1 + atom_2 = int(orb2deephorb[listh[i,j]-1,3])# orbit j belongs to atom_2 + Rijk = orb2deephorb[listh[i,j]-1,0:3] + Rijk = Rijk.astype(int) + connected_atoms = connected_atoms | set(['[{}, {}, {}, {}, {}]'.format(Rijk[0],Rijk[1],Rijk[2],atom_1,atom_2)]) + + + H_block_sparse = dict() + for atom_pair in connected_atoms: + H_block_sparse[atom_pair] = [] + # converts csr-like matrix into coo form in atomic pairs + for i in range(nspin): + for j in range(no_u): + tmpt=f.read_reals(dtype=' atom2nu[int(orb_indx[i,1])-1]: + atom2nu[int(orb_indx[i,1]-1)] = int(orb_indx[i,4]) + + # converts coo sparse matrix into full matrix + for Rijkab in H_block_sparse.keys(): + sparse_form = H_block_sparse[Rijkab] + ia1 = int(Rijkab[1:-1].split(',')[3]) + ia2 = int(Rijkab[1:-1].split(',')[4]) + tmpt = np.zeros((int(atom2nu[ia1-1]),int(atom2nu[ia2-1]))) + for i in range(len(sparse_form)): + tmpt[int(sparse_form[i][0]),int(sparse_form[i][1])]=sparse_form[i][2]/0.036749324533634074/2 + H_block_sparse[Rijkab]=tmpt + f.close() + f = h5py.File('{}/hamiltonians.h5'.format(output_path),'w') + for Rijkab in H_block_sparse.keys(): + f[Rijkab] = H_block_sparse[Rijkab] + + for Rijkab in S_block_sparse.keys(): + sparse_form = S_block_sparse[Rijkab] + ia1 = int(Rijkab[1:-1].split(',')[3]) + ia2 = int(Rijkab[1:-1].split(',')[4]) + tmpt = np.zeros((int(atom2nu[ia1-1]),int(atom2nu[ia2-1]))) + for i in range(len(sparse_form)): + tmpt[int(sparse_form[i][0]),int(sparse_form[i][1])]=sparse_form[i][2] + S_block_sparse[Rijkab]=tmpt + + f.close() + f = h5py.File('{}/overlaps.h5'.format(output_path),'w') + for Rijkab in S_block_sparse.keys(): + f[Rijkab] = S_block_sparse[Rijkab] + f.close() diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/rotate.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/rotate.py new file mode 100644 index 0000000000000000000000000000000000000000..7e0279129b325df3032288c579de9a937ea0ba14 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/rotate.py @@ -0,0 +1,277 @@ +import json +import os.path +import warnings + +import numpy as np +import h5py +import torch +from e3nn.o3 import Irrep, Irreps, matrix_to_angles + +from deeph import load_orbital_types + +dtype_dict = { + np.float32: (torch.float32, torch.float32, torch.complex64), + np.float64: (torch.float64, torch.float64, torch.complex128), + np.complex64: (torch.complex64, torch.float32, torch.complex64), + np.complex128: (torch.complex128, torch.float64, torch.complex128), + torch.float32: (torch.float32, torch.float32, torch.complex64), + torch.float64: (torch.float64, torch.float64, torch.complex128), + torch.complex64: (torch.complex64, torch.float32, torch.complex64), + torch.complex128: (torch.complex128, torch.float64, torch.complex128), +} + + +class Rotate: + def __init__(self, torch_dtype, torch_dtype_real=torch.float64, torch_dtype_complex=torch.cdouble, + device=torch.device('cpu'), spinful=False): + self.dtype = torch_dtype + self.torch_dtype_real = torch_dtype_real + self.device = device + self.spinful = spinful + sqrt_2 = 1.4142135623730951 + self.Us_openmx = { + 0: torch.tensor([1], dtype=torch_dtype_complex, device=device), + 1: torch.tensor([[-1 / sqrt_2, 1j / sqrt_2, 0], [0, 0, 1], [1 / sqrt_2, 1j / sqrt_2, 0]], + dtype=torch_dtype_complex, device=device), + 2: torch.tensor([[0, 1 / sqrt_2, -1j / sqrt_2, 0, 0], + [0, 0, 0, -1 / sqrt_2, 1j / sqrt_2], + [1, 0, 0, 0, 0], + [0, 0, 0, 1 / sqrt_2, 1j / sqrt_2], + [0, 1 / sqrt_2, 1j / sqrt_2, 0, 0]], dtype=torch_dtype_complex, device=device), + 3: torch.tensor([[0, 0, 0, 0, 0, -1 / sqrt_2, 1j / sqrt_2], + [0, 0, 0, 1 / sqrt_2, -1j / sqrt_2, 0, 0], + [0, -1 / sqrt_2, 1j / sqrt_2, 0, 0, 0, 0], + [1, 0, 0, 0, 0, 0, 0], + [0, 1 / sqrt_2, 1j / sqrt_2, 0, 0, 0, 0], + [0, 0, 0, 1 / sqrt_2, 1j / sqrt_2, 0, 0], + [0, 0, 0, 0, 0, 1 / sqrt_2, 1j / sqrt_2]], dtype=torch_dtype_complex, device=device), + } + self.Us_openmx2wiki = { + 0: torch.eye(1, dtype=torch_dtype).to(device=device), + 1: torch.eye(3, dtype=torch_dtype)[[1, 2, 0]].to(device=device), + 2: torch.eye(5, dtype=torch_dtype)[[2, 4, 0, 3, 1]].to(device=device), + 3: torch.eye(7, dtype=torch_dtype)[[6, 4, 2, 0, 1, 3, 5]].to(device=device) + } + self.Us_wiki2openmx = {k: v.T for k, v in self.Us_openmx2wiki.items()} + + def rotate_e3nn_v(self, v, R, l, order_xyz=True): + if self.spinful: + raise NotImplementedError + assert len(R.shape) == 2 + if order_xyz: + R_e3nn = self.rotate_matrix_convert(R) + else: + R_e3nn = R + return v @ Irrep(l, 1).D_from_matrix(R_e3nn) + + def rotate_openmx_H_old(self, H, R, l_lefts, l_rights, order_xyz=True): + assert len(R.shape) == 2 + if order_xyz: + R_e3nn = self.rotate_matrix_convert(R) + else: + R_e3nn = R + + block_lefts = [] + for l_left in l_lefts: + block_lefts.append( + self.Us_openmx2wiki[l_left].T @ Irrep(l_left, 1).D_from_matrix(R_e3nn) @ self.Us_openmx2wiki[l_left]) + rotation_left = torch.block_diag(*block_lefts) + + block_rights = [] + for l_right in l_rights: + block_rights.append( + self.Us_openmx2wiki[l_right].T @ Irrep(l_right, 1).D_from_matrix(R_e3nn) @ self.Us_openmx2wiki[l_right]) + rotation_right = torch.block_diag(*block_rights) + + return torch.einsum("cd,ca,db->ab", H, rotation_left, rotation_right) + + def rotate_openmx_H(self, H, R, l_lefts, l_rights, order_xyz=True): + # spin-1/2 is writed by gongxx + assert len(R.shape) == 2 + if order_xyz: + R_e3nn = self.rotate_matrix_convert(R) + else: + R_e3nn = R + irreps_left = Irreps([(1, (l, 1)) for l in l_lefts]) + irreps_right = Irreps([(1, (l, 1)) for l in l_rights]) + U_left = irreps_left.D_from_matrix(R_e3nn) + U_right = irreps_right.D_from_matrix(R_e3nn) + openmx2wiki_left = torch.block_diag(*[self.Us_openmx2wiki[l] for l in l_lefts]) + openmx2wiki_right = torch.block_diag(*[self.Us_openmx2wiki[l] for l in l_rights]) + if self.spinful: + U_left = torch.kron(self.D_one_half(R_e3nn), U_left) + U_right = torch.kron(self.D_one_half(R_e3nn), U_right) + openmx2wiki_left = torch.block_diag(openmx2wiki_left, openmx2wiki_left) + openmx2wiki_right = torch.block_diag(openmx2wiki_right, openmx2wiki_right) + return openmx2wiki_left.T @ U_left.transpose(-1, -2).conj() @ openmx2wiki_left @ H \ + @ openmx2wiki_right.T @ U_right @ openmx2wiki_right + + def rotate_openmx_phiVdphi(self, phiVdphi, R, l_lefts, l_rights, order_xyz=True): + if self.spinful: + raise NotImplementedError + assert phiVdphi.shape[-1] == 3 + assert len(R.shape) == 2 + if order_xyz: + R_e3nn = self.rotate_matrix_convert(R) + else: + R_e3nn = R + block_lefts = [] + for l_left in l_lefts: + block_lefts.append( + self.Us_openmx2wiki[l_left].T @ Irrep(l_left, 1).D_from_matrix(R_e3nn) @ self.Us_openmx2wiki[l_left]) + rotation_left = torch.block_diag(*block_lefts) + + block_rights = [] + for l_right in l_rights: + block_rights.append( + self.Us_openmx2wiki[l_right].T @ Irrep(l_right, 1).D_from_matrix(R_e3nn) @ self.Us_openmx2wiki[l_right]) + rotation_right = torch.block_diag(*block_rights) + + rotation_x = self.Us_openmx2wiki[1].T @ Irrep(1, 1).D_from_matrix(R_e3nn) @ self.Us_openmx2wiki[1] + + return torch.einsum("def,da,eb,fc->abc", phiVdphi, rotation_left, rotation_right, rotation_x) + + def wiki2openmx_H(self, H, l_left, l_right): + if self.spinful: + raise NotImplementedError + return self.Us_openmx2wiki[l_left].T @ H @ self.Us_openmx2wiki[l_right] + + def openmx2wiki_H(self, H, l_left, l_right): + if self.spinful: + raise NotImplementedError + return self.Us_openmx2wiki[l_left] @ H @ self.Us_openmx2wiki[l_right].T + + def rotate_matrix_convert(self, R): + return R.index_select(0, R.new_tensor([1, 2, 0]).int()).index_select(1, R.new_tensor([1, 2, 0]).int()) + + def D_one_half(self, R): + # writed by gongxx + assert self.spinful + d = torch.det(R).sign() + R = d[..., None, None] * R + k = (1 - d) / 2 # parity index + alpha, beta, gamma = matrix_to_angles(R) + J = torch.tensor([[1, 1], [1j, -1j]], dtype=self.dtype) / 1.4142135623730951 # <1/2 mz|1/2 my> + Uz1 = self._sp_z_rot(alpha) + Uy = J @ self._sp_z_rot(beta) @ J.T.conj() + Uz2 = self._sp_z_rot(gamma) + return Uz1 @ Uy @ Uz2 + + def _sp_z_rot(self, angle): + # writed by gongxx + assert self.spinful + M = torch.zeros([*angle.shape, 2, 2], dtype=self.dtype) + inds = torch.tensor([0, 1]) + freqs = torch.tensor([0.5, -0.5], dtype=self.dtype) + M[..., inds, inds] = torch.exp(- freqs * (1j) * angle[..., None]) + return M + + +def get_rh(input_dir, output_dir, target='hamiltonian'): + torch_device = torch.device('cpu') + assert target in ['hamiltonian', 'phiVdphi'] + file_name = { + 'hamiltonian': 'hamiltonians.h5', + 'phiVdphi': 'phiVdphi.h5', + }[target] + prime_file_name = { + 'hamiltonian': 'rh.h5', + 'phiVdphi': 'rphiVdphi.h5', + }[target] + assert os.path.exists(os.path.join(input_dir, file_name)) + assert os.path.exists(os.path.join(input_dir, 'rc.h5')) + assert os.path.exists(os.path.join(input_dir, 'orbital_types.dat')) + assert os.path.exists(os.path.join(input_dir, 'info.json')) + + atom_num_orbital, orbital_types = load_orbital_types(os.path.join(input_dir, 'orbital_types.dat'), + return_orbital_types=True) + nsite = len(atom_num_orbital) + with open(os.path.join(input_dir, 'info.json'), 'r') as info_f: + info_dict = json.load(info_f) + spinful = info_dict["isspinful"] + fid_H = h5py.File(os.path.join(input_dir, file_name), 'r') + fid_rc = h5py.File(os.path.join(input_dir, 'rc.h5'), 'r') + fid_rh = h5py.File(os.path.join(output_dir, prime_file_name), 'w') + assert '[0, 0, 0, 1, 1]' in fid_H.keys() + h5_dtype = fid_H['[0, 0, 0, 1, 1]'].dtype + torch_dtype, torch_dtype_real, torch_dtype_complex = dtype_dict[h5_dtype.type] + rotate_kernel = Rotate(torch_dtype, torch_dtype_real=torch_dtype_real, torch_dtype_complex=torch_dtype_complex, + device=torch_device, spinful=spinful) + + for key_str, hamiltonian in fid_H.items(): + if key_str not in fid_rc: + warnings.warn(f'Hamiltonian matrix block ({key_str}) do not have local coordinate') + continue + rotation_matrix = torch.tensor(fid_rc[key_str], dtype=torch_dtype_real, device=torch_device) + key = json.loads(key_str) + atom_i = key[3] - 1 + atom_j = key[4] - 1 + assert atom_i >= 0 + assert atom_i < nsite + assert atom_j >= 0 + assert atom_j < nsite + if target == 'hamiltonian': + rotated_hamiltonian = rotate_kernel.rotate_openmx_H(torch.tensor(hamiltonian), rotation_matrix, + orbital_types[atom_i], orbital_types[atom_j]) + elif target == 'phiVdphi': + rotated_hamiltonian = rotate_kernel.rotate_openmx_phiVdphi(torch.tensor(hamiltonian), rotation_matrix, + orbital_types[atom_i], orbital_types[atom_j]) + fid_rh[key_str] = rotated_hamiltonian.numpy() + + fid_H.close() + fid_rc.close() + fid_rh.close() + + +def rotate_back(input_dir, output_dir, target='hamiltonian'): + torch_device = torch.device('cpu') + assert target in ['hamiltonian', 'phiVdphi'] + file_name = { + 'hamiltonian': 'hamiltonians_pred.h5', + 'phiVdphi': 'phiVdphi_pred.h5', + }[target] + prime_file_name = { + 'hamiltonian': 'rh_pred.h5', + 'phiVdphi': 'rphiVdphi_pred.h5', + }[target] + assert os.path.exists(os.path.join(input_dir, prime_file_name)) + assert os.path.exists(os.path.join(input_dir, 'rc.h5')) + assert os.path.exists(os.path.join(input_dir, 'orbital_types.dat')) + assert os.path.exists(os.path.join(input_dir, 'info.json')) + + atom_num_orbital, orbital_types = load_orbital_types(os.path.join(input_dir, 'orbital_types.dat'), + return_orbital_types=True) + nsite = len(atom_num_orbital) + with open(os.path.join(input_dir, 'info.json'), 'r') as info_f: + info_dict = json.load(info_f) + spinful = info_dict["isspinful"] + fid_rc = h5py.File(os.path.join(input_dir, 'rc.h5'), 'r') + fid_rh = h5py.File(os.path.join(input_dir, prime_file_name), 'r') + fid_H = h5py.File(os.path.join(output_dir, file_name), 'w') + assert '[0, 0, 0, 1, 1]' in fid_rh.keys() + h5_dtype = fid_rh['[0, 0, 0, 1, 1]'].dtype + torch_dtype, torch_dtype_real, torch_dtype_complex = dtype_dict[h5_dtype.type] + rotate_kernel = Rotate(torch_dtype, torch_dtype_real=torch_dtype_real, torch_dtype_complex=torch_dtype_complex, + device=torch_device, spinful=spinful) + + for key_str, rotated_hamiltonian in fid_rh.items(): + assert key_str in fid_rc + rotation_matrix = torch.tensor(fid_rc[key_str], dtype=torch_dtype_real, device=torch_device).T + key = json.loads(key_str) + atom_i = key[3] - 1 + atom_j = key[4] - 1 + assert atom_i >= 0 + assert atom_i < nsite + assert atom_j >= 0 + assert atom_j < nsite + if target == 'hamiltonian': + hamiltonian = rotate_kernel.rotate_openmx_H(torch.tensor(rotated_hamiltonian), rotation_matrix, + orbital_types[atom_i], orbital_types[atom_j]) + elif target == 'phiVdphi': + hamiltonian = rotate_kernel.rotate_openmx_phiVdphi(torch.tensor(rotated_hamiltonian), rotation_matrix, + orbital_types[atom_i], orbital_types[atom_j]) + fid_H[key_str] = hamiltonian.numpy() + + fid_H.close() + fid_rc.close() + fid_rh.close() diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/__init__.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/__pycache__/__init__.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..58f20d6710b06d272d457744e4d90c59a567dec1 Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/__pycache__/__init__.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/__pycache__/preprocess.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/__pycache__/preprocess.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7da8f8db4ee3796accb90e5ddfeb404957570b5c Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/__pycache__/preprocess.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/__pycache__/train.cpython-312.pyc b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/__pycache__/train.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d15e90c8d13f92411a31ccb8345733a7171afa0d Binary files /dev/null and b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/__pycache__/train.cpython-312.pyc differ diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/evaluate.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/evaluate.py new file mode 100644 index 0000000000000000000000000000000000000000..3331afbd42fd0861c76e989d53bfa05e72f8358f --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/evaluate.py @@ -0,0 +1,173 @@ +import csv +import os +import argparse +import time +import warnings +from configparser import ConfigParser + +import numpy as np +import torch +from pymatgen.core.structure import Structure + +from deeph import get_graph, DeepHKernel, collate_fn + + +def main(): + parser = argparse.ArgumentParser(description='Predict Hamiltonian') + parser.add_argument('--trained_model_dir', type=str, + help='path of trained model') + parser.add_argument('--input_dir', type=str, + help='') + parser.add_argument('--output_dir', type=str, + help='') + parser.add_argument('--disable_cuda', action='store_true', help='Disable CUDA') + parser.add_argument('--save_csv', action='store_true', help='Save the result for each edge in csv format') + parser.add_argument( + '--interface', + type=str, + default='h5', + choices=['h5', 'npz']) + parser.add_argument('--huge_structure', type=bool, default=False, help='') + args = parser.parse_args() + + old_version = False + assert os.path.exists(os.path.join(args.trained_model_dir, 'config.ini')) + if os.path.exists(os.path.join(args.trained_model_dir, 'best_model.pt')) is False: + old_version = True + assert os.path.exists(os.path.join(args.trained_model_dir, 'best_model.pkl')) + assert os.path.exists(os.path.join(args.trained_model_dir, 'src')) + + os.makedirs(args.output_dir, exist_ok=True) + + config = ConfigParser() + config.read(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'default.ini')) + config.read(os.path.join(args.trained_model_dir, 'config.ini')) + config.set('basic', 'save_dir', os.path.join(args.output_dir)) + config.set('basic', 'disable_cuda', str(args.disable_cuda)) + config.set('basic', 'save_to_time_folder', 'False') + config.set('basic', 'tb_writer', 'False') + config.set('train', 'pretrained', '') + config.set('train', 'resume', '') + kernel = DeepHKernel(config) + if old_version is False: + checkpoint = kernel.build_model(args.trained_model_dir, old_version) + else: + warnings.warn('You are using the trained model with an old version') + checkpoint = torch.load( + os.path.join(args.trained_model_dir, 'best_model.pkl'), + map_location=kernel.device + ) + for key in ['index_to_Z', 'Z_to_index', 'spinful']: + if key in checkpoint: + setattr(kernel, key, checkpoint[key]) + if hasattr(kernel, 'index_to_Z') is False: + kernel.index_to_Z = torch.arange(config.getint('basic', 'max_element') + 1) + if hasattr(kernel, 'Z_to_index') is False: + kernel.Z_to_index = torch.arange(config.getint('basic', 'max_element') + 1) + if hasattr(kernel, 'spinful') is False: + kernel.spinful = False + kernel.num_species = len(kernel.index_to_Z) + print("=> load best checkpoint (epoch {})".format(checkpoint['epoch'])) + print(f"=> Atomic types: {kernel.index_to_Z.tolist()}, " + f"spinful: {kernel.spinful}, the number of atomic types: {len(kernel.index_to_Z)}.") + kernel.build_model(args.trained_model_dir, old_version) + kernel.model.load_state_dict(checkpoint['state_dict']) + + with torch.no_grad(): + input_dir = args.input_dir + structure = Structure(np.loadtxt(os.path.join(args.input_dir, 'lat.dat')).T, + np.loadtxt(os.path.join(args.input_dir, 'element.dat')), + np.loadtxt(os.path.join(args.input_dir, 'site_positions.dat')).T, + coords_are_cartesian=True, + to_unit_cell=False) + cart_coords = torch.tensor(structure.cart_coords, dtype=torch.get_default_dtype()) + frac_coords = torch.tensor(structure.frac_coords, dtype=torch.get_default_dtype()) + numbers = kernel.Z_to_index[torch.tensor(structure.atomic_numbers)] + structure.lattice.matrix.setflags(write=True) + lattice = torch.tensor(structure.lattice.matrix, dtype=torch.get_default_dtype()) + inv_lattice = torch.inverse(lattice) + + if os.path.exists(os.path.join(input_dir, 'graph.pkl')): + data = torch.load(os.path.join(input_dir, 'graph.pkl')) + print(f"Load processed graph from {os.path.join(input_dir, 'graph.pkl')}") + else: + begin = time.time() + data = get_graph(cart_coords, frac_coords, numbers, 0, + r=kernel.config.getfloat('graph', 'radius'), + max_num_nbr=kernel.config.getint('graph', 'max_num_nbr'), + numerical_tol=1e-8, lattice=lattice, default_dtype_torch=torch.get_default_dtype(), + tb_folder=args.input_dir, interface=args.interface, + num_l=kernel.config.getint('network', 'num_l'), + create_from_DFT=kernel.config.getboolean('graph', 'create_from_DFT', fallback=True), + if_lcmp_graph=kernel.config.getboolean('graph', 'if_lcmp_graph', fallback=True), + separate_onsite=kernel.separate_onsite, + target=kernel.config.get('basic', 'target'), huge_structure=args.huge_structure) + torch.save(data, os.path.join(input_dir, 'graph.pkl')) + print(f"Save processed graph to {os.path.join(input_dir, 'graph.pkl')}, cost {time.time() - begin} seconds") + + dataset_mask = kernel.make_mask([data]) + batch, subgraph = collate_fn(dataset_mask) + sub_atom_idx, sub_edge_idx, sub_edge_ang, sub_index = subgraph + + output = kernel.model(batch.x.to(kernel.device), batch.edge_index.to(kernel.device), + batch.edge_attr.to(kernel.device), + batch.batch.to(kernel.device), + sub_atom_idx.to(kernel.device), sub_edge_idx.to(kernel.device), + sub_edge_ang.to(kernel.device), sub_index.to(kernel.device), + huge_structure=args.huge_structure) + + label = batch.label + mask = batch.mask + output = output.cpu().reshape(label.shape) + + assert label.shape == output.shape == mask.shape + mse = torch.pow(label - output, 2) + mae = torch.abs(label - output) + + print() + for index_orb, orbital_single in enumerate(kernel.orbital): + if index_orb != 0: + print('================================================================') + print('orbital:', orbital_single) + if kernel.spinful == False: + print(f'mse: {torch.masked_select(mse[:, index_orb], mask[:, index_orb]).mean().item()}, ' + f'mae: {torch.masked_select(mae[:, index_orb], mask[:, index_orb]).mean().item()}') + else: + for index_soc, str_soc in enumerate([ + 'left_up_real', 'left_up_imag', 'right_down_real', 'right_down_imag', + 'right_up_real', 'right_up_imag', 'left_down_real', 'left_down_imag', + ]): + if index_soc != 0: + print('----------------------------------------------------------------') + print(str_soc, ':') + index_out = index_orb * 8 + index_soc + print(f'mse: {torch.masked_select(mse[:, index_out], mask[:, index_out]).mean().item()}, ' + f'mae: {torch.masked_select(mae[:, index_out], mask[:, index_out]).mean().item()}') + + if args.save_csv: + edge_stru_index = torch.squeeze(batch.batch[batch.edge_index[0]]).numpy() + edge_slices = torch.tensor(batch.__slices__['x'])[edge_stru_index].view(-1, 1) + atom_ids = torch.squeeze(batch.edge_index.T - edge_slices).tolist() + atomic_numbers = torch.squeeze(kernel.index_to_Z[batch.x[batch.edge_index.T]]).tolist() + edge_infos = torch.squeeze(batch.edge_attr[:, :7].detach().cpu()).tolist() + + with open(os.path.join(kernel.config.get('basic', 'save_dir'), 'error_distance.csv'), 'w', newline='') as f: + writer = csv.writer(f) + writer.writerow(['index', 'atom_id', 'atomic_number', 'dist', 'atom1_x', 'atom1_y', 'atom1_z', + 'atom2_x', 'atom2_y', 'atom2_z'] + + ['target'] * kernel.out_fea_len + ['pred'] * kernel.out_fea_len + [ + 'mask'] * kernel.out_fea_len) + for index_edge in range(batch.edge_attr.shape[0]): + writer.writerow([ + index_edge, + atom_ids[index_edge], + atomic_numbers[index_edge], + *(edge_infos[index_edge]), + *(label[index_edge].tolist()), + *(output[index_edge].tolist()), + *(mask[index_edge].tolist()), + ]) + + +if __name__ == '__main__': + main() diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/inference.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/inference.py new file mode 100644 index 0000000000000000000000000000000000000000..e5a93fa9b8af1155a52fee361c07ea4db9af3f9f --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/inference.py @@ -0,0 +1,157 @@ +import os +import time +import subprocess as sp +import json + +import argparse + +from deeph import get_inference_config, rotate_back, abacus_parse +from deeph.preprocess import openmx_parse_overlap, get_rc +from deeph.inference import predict, predict_with_grad + + +def main(): + parser = argparse.ArgumentParser(description='Deep Hamiltonian') + parser.add_argument('--config', default=[], nargs='+', type=str, metavar='N') + args = parser.parse_args() + + print(f'User config name: {args.config}') + config = get_inference_config(args.config) + + work_dir = os.path.abspath(config.get('basic', 'work_dir')) + OLP_dir = os.path.abspath(config.get('basic', 'OLP_dir')) + interface = config.get('basic', 'interface') + abacus_suffix = str(config.get('basic', 'abacus_suffix', fallback='ABACUS')) + task = json.loads(config.get('basic', 'task')) + assert isinstance(task, list) + eigen_solver = config.get('basic', 'eigen_solver') + disable_cuda = config.getboolean('basic', 'disable_cuda') + device = config.get('basic', 'device') + huge_structure = config.getboolean('basic', 'huge_structure') + restore_blocks_py = config.getboolean('basic', 'restore_blocks_py') + gen_rc_idx = config.getboolean('basic', 'gen_rc_idx') + gen_rc_by_idx = config.get('basic', 'gen_rc_by_idx') + with_grad = config.getboolean('basic', 'with_grad') + julia_interpreter = config.get('interpreter', 'julia_interpreter', fallback='') + python_interpreter = config.get('interpreter', 'python_interpreter', fallback='') + radius = config.getfloat('graph', 'radius') + + if 5 in task: + if eigen_solver in ['sparse_jl', 'dense_jl']: + assert julia_interpreter, "Please specify julia_interpreter to use Julia code to calculate eigenpairs" + elif eigen_solver in ['dense_py']: + assert python_interpreter, "Please specify python_interpreter to use Python code to calculate eigenpairs" + else: + raise ValueError(f"Unknown eigen_solver: {eigen_solver}") + if 3 in task and not restore_blocks_py: + assert julia_interpreter, "Please specify julia_interpreter to use Julia code to rearrange matrix blocks" + + if with_grad: + assert restore_blocks_py is True + assert 4 not in task + assert 5 not in task + + os.makedirs(work_dir, exist_ok=True) + config.write(open(os.path.join(work_dir, 'config.ini'), "w")) + + + if not restore_blocks_py: + cmd3_post = f"{julia_interpreter} " \ + f"{os.path.join(os.path.dirname(os.path.dirname(__file__)), 'inference', 'restore_blocks.jl')} " \ + f"--input_dir {work_dir} --output_dir {work_dir}" + + if eigen_solver == 'sparse_jl': + cmd5 = f"{julia_interpreter} " \ + f"{os.path.join(os.path.dirname(os.path.dirname(__file__)), 'inference', 'sparse_calc.jl')} " \ + f"--input_dir {work_dir} --output_dir {work_dir} --config {config.get('basic', 'sparse_calc_config')}" + elif eigen_solver == 'dense_jl': + cmd5 = f"{julia_interpreter} " \ + f"{os.path.join(os.path.dirname(os.path.dirname(__file__)), 'inference', 'dense_calc.jl')} " \ + f"--input_dir {work_dir} --output_dir {work_dir} --config {config.get('basic', 'sparse_calc_config')}" + elif eigen_solver == 'dense_py': + cmd5 = f"{python_interpreter} " \ + f"{os.path.join(os.path.dirname(os.path.dirname(__file__)), 'inference', 'dense_calc.py')} " \ + f"--input_dir {work_dir} --output_dir {work_dir} --config {config.get('basic', 'sparse_calc_config')}" + else: + raise ValueError(f"Unknown eigen_solver: {eigen_solver}") + + print(f"\n~~~~~~~ 1.parse_Overlap\n") + print(f"\n~~~~~~~ 2.get_local_coordinate\n") + print(f"\n~~~~~~~ 3.get_pred_Hamiltonian\n") + if not restore_blocks_py: + print(f"\n~~~~~~~ 3_post.restore_blocks, command: \n{cmd3_post}\n") + print(f"\n~~~~~~~ 4.rotate_back\n") + print(f"\n~~~~~~~ 5.sparse_calc, command: \n{cmd5}\n") + + if 1 in task: + begin = time.time() + print(f"\n####### Begin 1.parse_Overlap") + if interface == 'openmx': + assert os.path.exists(os.path.join(OLP_dir, 'openmx.out')), "Necessary files could not be found in OLP_dir" + assert os.path.exists(os.path.join(OLP_dir, 'output')), "Necessary files could not be found in OLP_dir" + openmx_parse_overlap(OLP_dir, work_dir) + elif interface == 'abacus': + print("Output subdirectories:", "OUT." + abacus_suffix) + assert os.path.exists(os.path.join(OLP_dir, 'SR.csr')), "Necessary files could not be found in OLP_dir" + assert os.path.exists(os.path.join(OLP_dir, f'OUT.{abacus_suffix}')), "Necessary files could not be found in OLP_dir" + abacus_parse(OLP_dir, work_dir, data_name=f'OUT.{abacus_suffix}', only_S=True) + assert os.path.exists(os.path.join(work_dir, "overlaps.h5")) + assert os.path.exists(os.path.join(work_dir, "lat.dat")) + assert os.path.exists(os.path.join(work_dir, "rlat.dat")) + assert os.path.exists(os.path.join(work_dir, "site_positions.dat")) + assert os.path.exists(os.path.join(work_dir, "orbital_types.dat")) + assert os.path.exists(os.path.join(work_dir, "element.dat")) + print('\n******* Finish 1.parse_Overlap, cost %d seconds\n' % (time.time() - begin)) + + if not with_grad and 2 in task: + begin = time.time() + print(f"\n####### Begin 2.get_local_coordinate") + get_rc(work_dir, work_dir, radius=radius, gen_rc_idx=gen_rc_idx, gen_rc_by_idx=gen_rc_by_idx, + create_from_DFT=config.getboolean('graph', 'create_from_DFT')) + assert os.path.exists(os.path.join(work_dir, "rc.h5")) + print('\n******* Finish 2.get_local_coordinate, cost %d seconds\n' % (time.time() - begin)) + + if 3 in task: + begin = time.time() + print(f"\n####### Begin 3.get_pred_Hamiltonian") + trained_model_dir = config.get('basic', 'trained_model_dir') + if trained_model_dir[0] == '[' and trained_model_dir[-1] == ']': + trained_model_dir = json.loads(trained_model_dir) + if with_grad: + predict_with_grad(input_dir=work_dir, output_dir=work_dir, disable_cuda=disable_cuda, device=device, + huge_structure=huge_structure, trained_model_dirs=trained_model_dir) + else: + predict(input_dir=work_dir, output_dir=work_dir, disable_cuda=disable_cuda, device=device, + huge_structure=huge_structure, restore_blocks_py=restore_blocks_py, + trained_model_dirs=trained_model_dir) + if restore_blocks_py: + if with_grad: + assert os.path.exists(os.path.join(work_dir, "hamiltonians_grad_pred.h5")) + assert os.path.exists(os.path.join(work_dir, "hamiltonians_pred.h5")) + else: + assert os.path.exists(os.path.join(work_dir, "rh_pred.h5")) + else: + capture_output = sp.run(cmd3_post, shell=True, capture_output=False, encoding="utf-8") + assert capture_output.returncode == 0 + assert os.path.exists(os.path.join(work_dir, "rh_pred.h5")) + print('\n******* Finish 3.get_pred_Hamiltonian, cost %d seconds\n' % (time.time() - begin)) + + if 4 in task: + begin = time.time() + print(f"\n####### Begin 4.rotate_back") + rotate_back(input_dir=work_dir, output_dir=work_dir) + assert os.path.exists(os.path.join(work_dir, "hamiltonians_pred.h5")) + print('\n******* Finish 4.rotate_back, cost %d seconds\n' % (time.time() - begin)) + + if 5 in task: + begin = time.time() + print(f"\n####### Begin 5.sparse_calc") + capture_output = sp.run(cmd5, shell=True, capture_output=False, encoding="utf-8") + assert capture_output.returncode == 0 + if eigen_solver in ['sparse_jl']: + assert os.path.exists(os.path.join(work_dir, "sparse_matrix.jld")) + print('\n******* Finish 5.sparse_calc, cost %d seconds\n' % (time.time() - begin)) + + +if __name__ == '__main__': + main() diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/preprocess.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/preprocess.py new file mode 100644 index 0000000000000000000000000000000000000000..bd518fac80f131fe913964854719fa7ad2629f3a --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/preprocess.py @@ -0,0 +1,199 @@ +import os +import subprocess as sp +import time + +import numpy as np +import argparse +from pathos.multiprocessing import ProcessingPool as Pool + +from deeph import get_preprocess_config, get_rc, get_rh, abacus_parse, siesta_parse + + +def collect_magmom_from_openmx(input_dir, output_dir, num_atom, mag_element): + magmom_data = np.zeros((num_atom, 4)) + + cmd = f'grep --text -A {num_atom + 3} "Total spin moment" {os.path.join(input_dir, "openmx.scfout")}' + magmom_str = os.popen(cmd).read().splitlines() + # print("Total local magnetic moment:", magmom_str[0].split()[4]) + + for index in range(num_atom): + line = magmom_str[3 + index].split() + assert line[0] == str(index + 1) + element_str = line[1] + magmom_r = line[5] + magmom_theta = line[6] + magmom_phi = line[7] + magmom_data[index] = int(element_str in mag_element), magmom_r, magmom_theta, magmom_phi + + np.savetxt(os.path.join(output_dir, "magmom.txt"), magmom_data) + +def collect_magmom_from_abacus(input_dir, output_dir, abacus_suffix, num_atom, mag_element): #to use this feature, be sure to turn out_chg and out_mul in abacus INPUT file, if not, will use mag setting in STRU file, and this may loss accuracy or incorrect + magmom_data = np.zeros((num_atom, 4)) + + # using running_scf.log file with INPUT file out_chg and out_mul == 1 + cmd = f"grep 'Total Magnetism' {os.path.join(input_dir, 'OUT.' + abacus_suffix, 'running_scf.log')}" + datas = os.popen(cmd).read().strip().splitlines() + if datas: + for index, data in enumerate(datas): + element_str = data.split()[4] + x, y, z = map(float, data.split('(')[-1].split(')')[0].split(',')) + vector = np.array([x, y, z]) + r = np.linalg.norm(vector) + theta = np.degrees(np.arctan2(vector[1], vector[0])) + phi = np.degrees(np.arccos(vector[2] / r)) + magmom_data[index] = int(element_str in mag_element), r, theta, phi + else: # using STRU file magmom setting, THIS MAY CAUSE WRONG OUTPUT! + index_atom = 0 + with open(os.path.join(input_dir, "STRU"), 'r') as file: + lines = file.readlines() + for k in range(len(lines)): # k = line index + if lines[k].strip() == 'ATOMIC_POSITIONS': + kk = k + 2 # kk = current line index + while kk < len(lines): + if lines[kk] == "\n": # for if empty line between two elements, as ABACUS accepts + continue + element_str = lines[kk].strip() + element_amount = int(lines[kk + 2].strip()) + for j in range(element_amount): + line = lines[kk + 3 + j].strip().split() + if len(line) < 11: # check if magmom is included + raise ValueError('this line do not contain magmom: {} in this file: {}'.format(line, input_dir)) + if line[7] != "angle1" and line[8] != "angle1": # check if magmom is in angle mode + raise ValueError('mag in STRU should be mag * angle1 * angle2 *') + if line[6] == "mag": # for if 'm' is included + index_str = 7 + else: + index_str = 8 + magmom_data[index_atom] = int(element_str in mag_element), line[index_str], line[index_str + 2], line[index_str + 4] + index_atom += 1 + kk += 3 + element_amount + + np.savetxt(os.path.join(output_dir, "magmom.txt"), magmom_data) + +def main(): + parser = argparse.ArgumentParser(description='Deep Hamiltonian') + parser.add_argument('--config', default=[], nargs='+', type=str, metavar='N') + args = parser.parse_args() + + print(f'User config name: {args.config}') + config = get_preprocess_config(args.config) + + raw_dir = os.path.abspath(config.get('basic', 'raw_dir')) + processed_dir = os.path.abspath(config.get('basic', 'processed_dir')) + abacus_suffix = str(config.get('basic', 'abacus_suffix', fallback='ABACUS')) + target = config.get('basic', 'target') + interface = config.get('basic', 'interface') + local_coordinate = config.getboolean('basic', 'local_coordinate') + multiprocessing = config.getint('basic', 'multiprocessing') + get_S = config.getboolean('basic', 'get_S') + + julia_interpreter = config.get('interpreter', 'julia_interpreter') + + def make_cmd(input_dir, output_dir, target, interface, get_S): + if interface == 'openmx': + if target == 'hamiltonian': + cmd = f"{julia_interpreter} " \ + f"{os.path.join(os.path.dirname(os.path.dirname(__file__)), 'preprocess', 'openmx_get_data.jl')} " \ + f"--input_dir {input_dir} --output_dir {output_dir} --save_overlap {str(get_S).lower()}" + elif target == 'density_matrix': + cmd = f"{julia_interpreter} " \ + f"{os.path.join(os.path.dirname(os.path.dirname(__file__)), 'preprocess', 'openmx_get_data.jl')} " \ + f"--input_dir {input_dir} --output_dir {output_dir} --save_overlap {str(get_S).lower()} --if_DM true" + else: + raise ValueError('Unknown target: {}'.format(target)) + elif interface == 'siesta' or interface == 'abacus': + cmd = '' + elif interface == 'aims': + cmd = f"{julia_interpreter} " \ + f"{os.path.join(os.path.dirname(os.path.dirname(__file__)), 'preprocess', 'aims_get_data.jl')} " \ + f"--input_dir {input_dir} --output_dir {output_dir} --save_overlap {str(get_S).lower()}" + else: + raise ValueError('Unknown interface: {}'.format(interface)) + return cmd + + os.chdir(raw_dir) + relpath_list = [] + abspath_list = [] + for root, dirs, files in os.walk('./'): + if (interface == 'openmx' and 'openmx.scfout' in files) or ( + interface == 'abacus' and 'OUT.' + abacus_suffix in dirs) or ( + interface == 'siesta' and any(['.HSX' in ifile for ifile in files])) or ( + interface == 'aims' and 'NoTB.dat' in files): + relpath_list.append(root) + abspath_list.append(os.path.abspath(root)) + + os.makedirs(processed_dir, exist_ok=True) + os.chdir(processed_dir) + print(f"Found {len(abspath_list)} directories to preprocess") + + def worker(index): + time_cost = time.time() - begin_time + current_block = index // nodes + if current_block < 1: + time_estimate = '?' + else: + num_blocks = (len(abspath_list) + nodes - 1) // nodes + time_estimate = time.localtime(time_cost / (current_block) * (num_blocks - current_block)) + time_estimate = time.strftime("%H:%M:%S", time_estimate) + print(f'\rPreprocessing No. {index + 1}/{len(abspath_list)} ' + f'[{time.strftime("%H:%M:%S", time.localtime(time_cost))}<{time_estimate}]...', end='') + abspath = abspath_list[index] + relpath = relpath_list[index] + os.makedirs(relpath, exist_ok=True) + cmd = make_cmd( + abspath, + os.path.abspath(relpath), + target=target, + interface=interface, + get_S=get_S, + ) + capture_output = sp.run(cmd, shell=True, capture_output=True, encoding="utf-8") + if capture_output.returncode != 0: + with open(os.path.join(os.path.abspath(relpath), 'error.log'), 'w') as f: + f.write(f'[stdout of cmd "{cmd}"]:\n\n{capture_output.stdout}\n\n\n' + f'[stderr of cmd "{cmd}"]:\n\n{capture_output.stderr}') + print(f'\nFailed to preprocess: {abspath}, ' + f'log file was saved to {os.path.join(os.path.abspath(relpath), "error.log")}') + return + + if interface == 'abacus': + print("Output subdirectories:", "OUT." + abacus_suffix) + abacus_parse(abspath, os.path.abspath(relpath), 'OUT.' + abacus_suffix) + elif interface == 'siesta': + siesta_parse(abspath, os.path.abspath(relpath)) + if local_coordinate: + get_rc(os.path.abspath(relpath), os.path.abspath(relpath), radius=config.getfloat('graph', 'radius'), + r2_rand=config.getboolean('graph', 'r2_rand'), + create_from_DFT=config.getboolean('graph', 'create_from_DFT'), neighbour_file='hamiltonians.h5') + get_rh(os.path.abspath(relpath), os.path.abspath(relpath), target) + if config.getboolean('magnetic_moment', 'parse_magnetic_moment'): + num_atom = np.loadtxt(os.path.join(os.path.abspath(relpath), 'element.dat')).shape[0] + if interface == 'openmx': + collect_magmom_from_openmx( + abspath, os.path.abspath(relpath), + num_atom, eval(config.get('magnetic_moment', 'magnetic_element'))) + elif interface == 'abacus': + collect_magmom_from_abacus( + abspath, os.path.abspath(relpath), abacus_suffix, + num_atom, eval(config.get('magnetic_moment', 'magnetic_element'))) + else: + raise ValueError('Magnetic moment can only be parsed from OpenMX or ABACUS output for now, but your interface is {}'.format(interface)) + + begin_time = time.time() + if multiprocessing != 0: + if multiprocessing > 0: + pool_dict = {'nodes': multiprocessing} + else: + pool_dict = {} + with Pool(**pool_dict) as pool: + nodes = pool.nodes + print(f'Use multiprocessing (nodes = {nodes})') + pool.map(worker, range(len(abspath_list))) + else: + nodes = 1 + for index in range(len(abspath_list)): + worker(index) + print(f'\nPreprocess finished in {time.time() - begin_time:.2f} seconds') + +if __name__ == '__main__': + main() diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/train.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/train.py new file mode 100644 index 0000000000000000000000000000000000000000..d4072790c7fb275a418ed8599ba75b20383e6143 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/scripts/train.py @@ -0,0 +1,23 @@ +import argparse + +from deeph import DeepHKernel, get_config + + +def main(): + parser = argparse.ArgumentParser(description='Deep Hamiltonian') + parser.add_argument('--config', default=[], nargs='+', type=str, metavar='N') + args = parser.parse_args() + + print(f'User config name: {args.config}') + config = get_config(args.config) + only_get_graph = config.getboolean('basic', 'only_get_graph') + kernel = DeepHKernel(config) + train_loader, val_loader, test_loader, transform = kernel.get_dataset(only_get_graph) + if only_get_graph: + return + kernel.build_model() + kernel.set_train() + kernel.train(train_loader, val_loader, test_loader) + +if __name__ == '__main__': + main() diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/utils.py b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..72729ac1360957e91cc1f361afb0f02795a8bfd2 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/src/deeph/utils.py @@ -0,0 +1,213 @@ +import os +import shutil +import sys +from configparser import ConfigParser +from inspect import signature + +import numpy as np +import scipy +import torch +from torch import nn, package +import h5py + + +def print_args(args): + for k, v in args._get_kwargs(): + print('{} = {}'.format(k, v)) + print('') + + +class Logger(object): + def __init__(self, filename): + self.terminal = sys.stdout + self.log = open(filename, "a", buffering=1) + + def write(self, message): + self.terminal.write(message) + self.log.write(message) + + def flush(self): + pass + + +class MaskMSELoss(nn.Module): + def __init__(self) -> None: + super(MaskMSELoss, self).__init__() + + def forward(self, input: torch.Tensor, target: torch.Tensor, mask: torch.Tensor) -> torch.Tensor: + assert input.shape == target.shape == mask.shape + mse = torch.pow(input - target, 2) + mse = torch.masked_select(mse, mask).mean() + + return mse + + +class MaskMAELoss(nn.Module): + def __init__(self) -> None: + super(MaskMAELoss, self).__init__() + + def forward(self, input: torch.Tensor, target: torch.Tensor, mask: torch.Tensor) -> torch.Tensor: + assert input.shape == target.shape == mask.shape + mae = torch.abs(input - target) + mae = torch.masked_select(mae, mask).mean() + + return mae + + +class LossRecord: + def __init__(self): + self.reset() + + def reset(self): + self.last_val = 0 + self.avg = 0 + self.sum = 0 + self.count = 0 + + def update(self, val, num=1): + self.last_val = val + self.sum += val * num + self.count += num + self.avg = self.sum / self.count + + +def if_integer(string): + try: + int(string) + return True + except ValueError: + return False + + +class Transform: + def __init__(self, tensor=None, mask=None, normalizer=False, boxcox=False): + self.normalizer = normalizer + self.boxcox = boxcox + if normalizer: + raise NotImplementedError + self.mean = abs(tensor).sum(dim=0) / mask.sum(dim=0) + self.std = None + print(f'[normalizer] mean: {self.mean}, std: {self.std}') + if boxcox: + raise NotImplementedError + _, self.opt_lambda = scipy.stats.boxcox(tensor.double()) + print('[boxcox] optimal lambda value:', self.opt_lambda) + + def tran(self, tensor): + if self.boxcox: + tensor = scipy.special.boxcox(tensor, self.opt_lambda) + if self.normalizer: + tensor = (tensor - self.mean) / self.std + return tensor + + def inv_tran(self, tensor): + if self.normalizer: + tensor = tensor * self.std + self.mean + if self.boxcox: + tensor = scipy.special.inv_boxcox(tensor, self.opt_lambda) + return tensor + + def state_dict(self): + result = {'normalizer': self.normalizer, + 'boxcox': self.boxcox} + if self.normalizer: + result['mean'] = self.mean + result['std'] = self.std + if self.boxcox: + result['opt_lambda'] = self.opt_lambda + return result + + def load_state_dict(self, state_dict): + self.normalizer = state_dict['normalizer'] + self.boxcox = state_dict['boxcox'] + if self.normalizer: + self.mean = state_dict['mean'] + self.std = state_dict['std'] + print(f'Load state dict, mean: {self.mean}, std: {self.std}') + if self.boxcox: + self.opt_lambda = state_dict['opt_lambda'] + print('Load state dict, optimal lambda value:', self.opt_lambda) + + +def save_model(state, model_dict, model_state_dict, path, is_best): + model_dir = os.path.join(path, 'model.pt') + package_dict = {} + if 'verbose' in list(signature(package.PackageExporter.__init__).parameters.keys()): + package_dict['verbose'] = False + with package.PackageExporter(model_dir, **package_dict) as exp: + exp.intern('deeph.**') + exp.extern([ + 'scipy.**', 'numpy.**', 'torch_geometric.**', 'sklearn.**', + 'torch_scatter.**', 'torch_sparse.**', 'torch_sparse.**', 'torch_cluster.**', 'torch_spline_conv.**', + 'pyparsing', 'jinja2', 'sys', 'mkl', 'io', 'setuptools.**', 'rdkit.Chem', 'tqdm', + '__future__', '_operator', '_ctypes', 'six.moves.urllib', 'ase', 'matplotlib.pyplot', 'sympy', 'networkx', + ]) + exp.save_pickle('checkpoint', 'model.pkl', state | model_dict) + torch.save(state | model_state_dict, os.path.join(path, 'state_dict.pkl')) + if is_best: + shutil.copyfile(os.path.join(path, 'model.pt'), os.path.join(path, 'best_model.pt')) + shutil.copyfile(os.path.join(path, 'state_dict.pkl'), os.path.join(path, 'best_state_dict.pkl')) + + +def write_ham_h5(hoppings_dict, path): + fid = h5py.File(path, "w") + for k, v in hoppings_dict.items(): + fid[k] = v + fid.close() + + +def write_ham_npz(hoppings_dict, path): + np.savez(path, **hoppings_dict) + + +def write_ham(hoppings_dict, path): + os.makedirs(path, exist_ok=True) + for key_term, matrix in hoppings_dict.items(): + np.savetxt(os.path.join(path, f'{key_term}_real.dat'), matrix) + + +def get_config(args): + config = ConfigParser() + config.read(os.path.join(os.path.dirname(__file__), 'default.ini')) + for config_file in args: + assert os.path.exists(config_file) + config.read(config_file) + if config['basic']['target'] == 'O_ij': + assert config['basic']['O_component'] in ['H_minimum', 'H_minimum_withNA', 'H', 'Rho'] + if config['basic']['target'] == 'E_ij': + assert config['basic']['energy_component'] in ['xc', 'delta_ee', 'both', 'summation', 'E_ij'] + else: + assert config['hyperparameter']['criterion'] in ['MaskMSELoss'] + assert config['basic']['target'] in ['hamiltonian'] + assert config['basic']['interface'] in ['h5', 'h5_rc_only', 'h5_Eij', 'npz', 'npz_rc_only'] + assert config['network']['aggr'] in ['add', 'mean', 'max'] + assert config['network']['distance_expansion'] in ['GaussianBasis', 'BesselBasis', 'ExpBernsteinBasis'] + assert config['network']['normalization'] in ['BatchNorm', 'LayerNorm', 'PairNorm', 'InstanceNorm', 'GraphNorm', + 'DiffGroupNorm', 'None'] + assert config['network']['atom_update_net'] in ['CGConv', 'GAT', 'PAINN'] + assert config['hyperparameter']['optimizer'] in ['sgd', 'sgdm', 'adam', 'adamW', 'adagrad', 'RMSprop', 'lbfgs'] + assert config['hyperparameter']['lr_scheduler'] in ['', 'MultiStepLR', 'ReduceLROnPlateau', 'CyclicLR'] + + return config + + +def get_inference_config(*args): + config = ConfigParser() + config.read(os.path.join(os.path.dirname(__file__), 'inference', 'inference_default.ini')) + for config_file in args: + config.read(config_file) + assert config['basic']['interface'] in ['openmx', 'abacus'] + + return config + + +def get_preprocess_config(*args): + config = ConfigParser() + config.read(os.path.join(os.path.dirname(__file__), 'preprocess', 'preprocess_default.ini')) + for config_file in args: + config.read(config_file) + assert config['basic']['target'] in ['hamiltonian', 'density_matrix', 'phiVdphi'] + assert config['basic']['interface'] in ['openmx', 'abacus', 'aims', 'siesta'] + assert if_integer(config['basic']['multiprocessing']), "value of multiprocessing must be an integer" + + return config diff --git a/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/stderr.txt b/2_training/hamiltonian/infer_uc/dataset/00/pred_ham_std/stderr.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/2_training/hamiltonian/infer_uc/dataset/00/rc.h5 b/2_training/hamiltonian/infer_uc/dataset/00/rc.h5 new file mode 100644 index 0000000000000000000000000000000000000000..eeb5fe85003d9f1228fb86f102504ee8ac731b43 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/rc.h5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:82b06f63b91841bb0afdde7131c3d4459da9e4861517325787e42628b624e672 +size 133984 diff --git a/2_training/hamiltonian/infer_uc/dataset/00/rh.h5 b/2_training/hamiltonian/infer_uc/dataset/00/rh.h5 new file mode 100644 index 0000000000000000000000000000000000000000..7c020e57db15bccecce1261db9bff689bb1feebd --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/rh.h5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b5246ac1080013d960d56364e9a37344695b21a7e8bce801373e65ed55112bc0 +size 519600 diff --git a/2_training/hamiltonian/infer_uc/dataset/00/rh_pred.h5 b/2_training/hamiltonian/infer_uc/dataset/00/rh_pred.h5 new file mode 100644 index 0000000000000000000000000000000000000000..43420baaa631e40287df1f04d2af8a945007e614 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/rh_pred.h5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:af434d70598cd08fc0dbdf72753a252aa0000ef58f2c74b8121759f2d892bb3c +size 511408 diff --git a/2_training/hamiltonian/infer_uc/dataset/00/rlat.dat b/2_training/hamiltonian/infer_uc/dataset/00/rlat.dat new file mode 100644 index 0000000000000000000000000000000000000000..d85f9e35400c4889647fa474185cec84e7d3318c --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/rlat.dat @@ -0,0 +1,3 @@ +-1.761476117523574025e+00 1.761476117523574025e+00 1.761476117523574025e+00 +1.761476117523574025e+00 -1.761476117523574025e+00 1.761476117523574025e+00 +1.761476117523574025e+00 1.761476117523574025e+00 -1.761476117523574025e+00 diff --git a/2_training/hamiltonian/infer_uc/dataset/00/site_positions.dat b/2_training/hamiltonian/infer_uc/dataset/00/site_positions.dat new file mode 100644 index 0000000000000000000000000000000000000000..d894a4eacd4349473df62e4c3d69082e1f17b71c --- /dev/null +++ b/2_training/hamiltonian/infer_uc/dataset/00/site_positions.dat @@ -0,0 +1,3 @@ +0.000000000000000000e+00 8.917499994284623366e-01 +0.000000000000000000e+00 8.917499994284623366e-01 +0.000000000000000000e+00 8.917499994284623366e-01 diff --git a/2_training/hamiltonian/infer_uc/graph/HGraph-diamond_qe_e3_pristine_uc-rFromDFT-edge=Aij.pkl b/2_training/hamiltonian/infer_uc/graph/HGraph-diamond_qe_e3_pristine_uc-rFromDFT-edge=Aij.pkl new file mode 100644 index 0000000000000000000000000000000000000000..dab8e72f292d8fc84f2669d2154d82c267918985 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/graph/HGraph-diamond_qe_e3_pristine_uc-rFromDFT-edge=Aij.pkl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fdefa505d1b534581dfdbf2be2e4bb38c5e3e9777fc1150e71091d52a763d67b +size 253597 diff --git a/2_training/hamiltonian/infer_uc/output/00/hamiltonians_pred.h5 b/2_training/hamiltonian/infer_uc/output/00/hamiltonians_pred.h5 new file mode 100644 index 0000000000000000000000000000000000000000..fd54f984cb63291d2da96d90daa159ae8cf7a7de --- /dev/null +++ b/2_training/hamiltonian/infer_uc/output/00/hamiltonians_pred.h5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5a0206acf2645177b0adf1a30ee0583629846627ac8a637f6c0c573491c54302 +size 349388 diff --git a/2_training/hamiltonian/infer_uc/output/00/info.json b/2_training/hamiltonian/infer_uc/output/00/info.json new file mode 100644 index 0000000000000000000000000000000000000000..cedc0800527d526067961acb4770f85a552de7f3 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/output/00/info.json @@ -0,0 +1 @@ +{"isspinful": false} \ No newline at end of file diff --git a/2_training/hamiltonian/infer_uc/output/test_result.h5 b/2_training/hamiltonian/infer_uc/output/test_result.h5 new file mode 100644 index 0000000000000000000000000000000000000000..9576d3f5c470cf2f41505d9e73075a1e2431a543 --- /dev/null +++ b/2_training/hamiltonian/infer_uc/output/test_result.h5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ab5c397e84ab47c4e6c7125c1c0792926cf908ad17ce6af244d369b05f897bac +size 533938