Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- 2_training/hamiltonian/_eval_launcher.pyAdded+12
- 2_training/hamiltonian/infer_sc/dataset/00/element.datAdded+16
- 2_training/hamiltonian/infer_sc/dataset/00/info.jsonAdded+1
- 2_training/hamiltonian/infer_sc/dataset/00/lat.datAdded+3
- 2_training/hamiltonian/infer_sc/dataset/00/orbital_types.datAdded+16
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/config.iniAdded+82
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/result.txtAdded+86
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/__init__.pyAdded+10
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/__pycache__/__init__.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/__pycache__/data.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/__pycache__/graph.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/__pycache__/kernel.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/__pycache__/model.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/__pycache__/rotate.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/__pycache__/utils.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/data.pyAdded+217
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/default.iniAdded+88
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__init__.pyAdded+1
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__pycache__/__init__.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__pycache__/rmnet.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_HermNet/license.txtAdded+1
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_HermNet/rmnet.pyAdded+105
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__init__.pyAdded+2
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/__init__.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/diff_group_norm.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/graph_norm.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/diff_group_norm.pyAdded+109
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/graph_norm.pyAdded+60
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/license.txtAdded+22
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__init__.pyAdded+1
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__pycache__/__init__.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__pycache__/lattice.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/lattice.pyAdded+71
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/license.txtAdded+22
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__init__.pyAdded+1
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__pycache__/__init__.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__pycache__/acsf.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/acsf.pyAdded+50
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/license.txtAdded+35
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/__init__.pyAdded+1
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/__pycache__/__init__.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/__pycache__/representations.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/license.txtAdded+24
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/representations.pyAdded+204
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/graph.pyAdded+934
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/inference/__init__.pyAdded+1
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/inference/__pycache__/__init__.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/inference/__pycache__/pred_ham.cpython-312.pycAdded
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/inference/band_config.jsonAdded+8
- 2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/inference/dense_calc.jlAdded+234
123456789101112import sys, torchtorch.serialization.add_safe_globals([slice])try: from torch_geometric.data.data import DataEdgeAttr, DataTensorAttr from torch_geometric.data.storage import GlobalStorage torch.serialization.add_safe_globals([DataEdgeAttr, DataTensorAttr, GlobalStorage])except ImportError: passsys.path.insert(0, '/home/apolyukhin/Development/DeepH-E3')from deephe3 import DeepHE3Kernelkernel = DeepHE3Kernel()kernel.eval('/home/apolyukhin/Development/epc_ml/example/diamond/2_training/hamiltonian/infer_sc/eval.ini')123456789101112131415166 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 1{"isspinful": false}1230.000000000000000000e+00 3.566999997713848014e+00 3.566999997713848014e+003.566999997713848014e+00 0.000000000000000000e+00 3.566999997713848014e+003.566999997713848014e+00 3.566999997713848014e+00 0.000000000000000000e+00123456789101112131415160 0 1 1 20 0 1 1 20 0 1 1 20 0 1 1 20 0 1 1 20 0 1 1 20 0 1 1 20 0 1 1 20 0 1 1 20 0 1 1 20 0 1 1 20 0 1 1 20 0 1 1 20 0 1 1 20 0 1 1 20 0 1 1 212345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182[basic]graph_dir = /home/apolyukhin/scripts/ml/diamond-qe/deeph-data/graphsave_dir = /home/apolyukhin/scripts/ml/diamond-qe/pristine-222/reconstruction/aohamiltonian/pred_ham_stdraw_dir = /home/apolyukhin/scripts/ml/diamond-qe/deeph-data/preprocessdataset_name = diamond_qeonly_get_graph = Falseinterface = h5target = hamiltoniandisable_cuda = Truedevice = cpunum_threads = -1save_to_time_folder = Falsesave_csv = Truetb_writer = Falseseed = 42multiprocessing = 0orbital = [{"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 = Henergy_component = summationmax_element = -1statistics = Falsenormalizer = Falseboxcox = False
[graph]radius = -1.0max_num_nbr = 0create_from_dft = Trueif_lcmp_graph = Trueseparate_onsite = Falsenew_sp = False
[train]epochs = 5000pretrained = resume = train_ratio = 0.6val_ratio = 0.2test_ratio = 0.2early_stopping_loss = 0.0early_stopping_loss_epoch = [0.000000, 500]revert_then_decay = Truerevert_threshold = 30revert_decay_epoch = [800, 2000, 3000, 4000]revert_decay_gamma = [0.4, 0.5, 0.5, 0.4]clip_grad = Trueclip_grad_value = 4.2switch_sgd = Falseswitch_sgd_lr = 1e-4switch_sgd_epoch = -1
[hyperparameter]batch_size = 1dtype = float32optimizer = adamlearning_rate = 0.001lr_scheduler = lr_milestones = []momentum = 0.9weight_decay = 0criterion = MaskMSELossretain_edge_fea = Truelambda_eij = 0.0lambda_ei = 0.1lambda_etot = 0.0
[network]atom_fea_len = 64edge_fea_len = 128gauss_stop = 6.0num_l = 4aggr = adddistance_expansion = GaussianBasisif_exp = Trueif_multiplelinear = Falseif_edge_update = Trueif_lcmp = Truenormalization = LayerNormatom_update_net = PAINNtrainable_gaussians = Falsetype_affine = False
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586====== CONFIG ======[basic]graph_dir=/home/apolyukhin/scripts/ml/diamond-qe/deeph-data/graphsave_dir=/home/apolyukhin/scripts/ml/diamond-qe/pristine-222/reconstruction/aohamiltonian/pred_ham_stdraw_dir=/home/apolyukhin/scripts/ml/diamond-qe/deeph-data/preprocessdataset_name=diamond_qeonly_get_graph=Falseinterface=h5target=hamiltoniandisable_cuda=Truedevice=cpunum_threads=-1save_to_time_folder=Falsesave_csv=Truetb_writer=Falseseed=42multiprocessing=0orbital=[{"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=Henergy_component=summationmax_element=-1statistics=Falsenormalizer=Falseboxcox=False
[graph]radius=-1.0max_num_nbr=0create_from_dft=Trueif_lcmp_graph=Trueseparate_onsite=Falsenew_sp=False
[train]epochs=5000pretrained=resume=train_ratio=0.6val_ratio=0.2test_ratio=0.2early_stopping_loss=0.0early_stopping_loss_epoch=[0.000000, 500]revert_then_decay=Truerevert_threshold=30revert_decay_epoch=[800, 2000, 3000, 4000]revert_decay_gamma=[0.4, 0.5, 0.5, 0.4]clip_grad=Trueclip_grad_value=4.2switch_sgd=Falseswitch_sgd_lr=1e-4switch_sgd_epoch=-1
[hyperparameter]batch_size=1dtype=float32optimizer=adamlearning_rate=0.001lr_scheduler=lr_milestones=[]momentum=0.9weight_decay=0criterion=MaskMSELossretain_edge_fea=Truelambda_eij=0.0lambda_ei=0.1lambda_etot=0.0
[network]atom_fea_len=64edge_fea_len=128gauss_stop=6.0num_l=4aggr=adddistance_expansion=GaussianBasisif_exp=Trueif_multiplelinear=Falseif_edge_update=Trueif_lcmp=Truenormalization=LayerNormatom_update_net=PAINNtrainable_gaussians=Falsetype_affine=False
=> load best checkpoint (epoch 1070)=> Atomic types: [6], spinful: False, the number of atomic types: 1.Save processed graph to /home/apolyukhin/scripts/ml/diamond-qe/pristine-222/reconstruction/aohamiltonian/graph.pkl, cost 1.6528115272521973 seconds12345678910from .data import HDatafrom .model import HGNN, ExpBernsteinBasisfrom .utils import print_args, Logger, MaskMSELoss, MaskMAELoss, write_ham_npz, write_ham, write_ham_h5, get_config, \ get_inference_config, get_preprocess_configfrom .graph import Collater, collate_fn, get_graph, load_orbital_typesfrom .kernel import DeepHKernelfrom .preprocess import get_rc, OijLoad, GetEEiEij, abacus_parse, siesta_parsefrom .rotate import get_rh, rotate_back, Rotate, dtype_dict
__version__ = "0.2.2"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217import warningsimport osimport timeimport tqdm
from pymatgen.core.structure import Structureimport numpy as npimport torchfrom torch_geometric.data import InMemoryDatasetfrom 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_index12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788[basic]graph_dir = /your/own/pathsave_dir = /your/own/pathraw_dir = /your/own/pathdataset_name = your_own_nameonly_get_graph = False;choices = ['h5', 'npz']interface = h5target = hamiltoniandisable_cuda = Falsedevice = cuda:0;-1 for cpu_count(logical=False) // torch.cuda.device_count()num_threads = -1save_to_time_folder = Truesave_csv = Falsetb_writer = Trueseed = 42multiprocessing = 0orbital = [{"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 = Henergy_component = summationmax_element = -1statistics = Falsenormalizer = Falseboxcox = False
[graph]radius = -1.0max_num_nbr = 0create_from_DFT = Trueif_lcmp_graph = Trueseparate_onsite = Falsenew_sp = False
[train]epochs = 4000pretrained =resume =train_ratio = 0.6val_ratio = 0.2test_ratio = 0.2early_stopping_loss = 0.0early_stopping_loss_epoch = [0.000000, 500]revert_then_decay = Truerevert_threshold = 30revert_decay_epoch = [500, 2000, 3000]revert_decay_gamma = [0.4, 0.5, 0.5]clip_grad = Trueclip_grad_value = 4.2switch_sgd = Falseswitch_sgd_lr = 1e-4switch_sgd_epoch = -1
[hyperparameter]batch_size = 3dtype = float32;choices = ['sgd', 'sgdm', 'adam', 'lbfgs']optimizer = adam;initial learning ratelearning_rate = 0.001;choices = ['', 'MultiStepLR', 'ReduceLROnPlateau', 'CyclicLR']lr_scheduler =lr_milestones = []momentum = 0.9weight_decay = 0criterion = MaskMSELossretain_edge_fea = Truelambda_Eij = 0.0lambda_Ei = 0.1lambda_Etot = 0.0
[network]atom_fea_len = 64edge_fea_len = 128gauss_stop = 6;The number of angular quantum numbers that spherical harmonic functions havenum_l = 5aggr = adddistance_expansion = GaussianBasisif_exp = Trueif_MultipleLinear = Falseif_edge_update = Trueif_lcmp = Truenormalization = LayerNorm;choices = ['CGConv', 'GAT', 'PAINN']atom_update_net = CGConvtrainable_gaussians = Falsetype_affine = False1from .rmnet import RBF, cosine_cutoff, ShiftedSoftplus, _eps1The code in this folder was obtained from "https://github.com/sakuraiiiii/HermNet"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105import math
import torchfrom torch import nn, Tensorimport 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))12from .graph_norm import GraphNormfrom .diff_group_norm import DiffGroupNorm123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109import torchfrom torch import Tensorfrom 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" <https://arxiv.org/abs/2006.06972>`_ 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)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960from typing import Optional
import torchfrom torch import Tensorfrom 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" <https://arxiv.org/abs/2009.03294>`_ 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})'12345678910111213141516171819202122The code in this folder was obtained from "https://github.com/rusty1s/pytorch_geometric", which has the following license:
Copyright (c) 2020 Matthias Fey <matthias.fey@tu-dortmund.de>
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, 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 INTHE SOFTWARE.1from .lattice import find_neighbors, _one_to_three, _compute_cube_index, _three_to_one1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071import itertoolsimport 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_labels12345678910111213141516171819202122The 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 ofthis software and associated documentation files (the "Software"), to deal inthe Software without restriction, including without limitation the rights touse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies ofthe 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 allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESSFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS ORCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHERIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR INCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.1from .acsf import GaussianBasis1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950import torchfrom 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 )1234567891011121314151617181920212223242526272829303132333435The 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 copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, 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 THESOFTWARE.1from .representations import SphericalHarmonics123456789101112131415161718192021222324The 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 copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, 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 THESOFTWARE.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204import torchimport 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)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934import collectionsimport itertoolsimport osimport jsonimport warningsimport math
import torchimport torch_geometricfrom torch_geometric.data import Data, Batchimport numpy as npimport h5py
from .model import get_spherical_from_cartesian, SphericalHarmonicsfrom .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 theUniversity 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 allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, 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 ofthis software and associated documentation files (the "Software"), to deal inthe Software without restriction, including without limitation the rights touse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies ofthe 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 allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESSFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS ORCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHERIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR INCONNECTION 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 data1from .pred_ham import predict, predict_with_grad12345678{ "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 Γ"]}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234using DelimitedFiles, LinearAlgebra, JSONusing HDF5using ArgParseusing SparseArraysusing Arpackusing JLD# BLAS.set_num_threads(1)
const ev2Hartree = 0.036749324533634074const Bohr2Ang = 0.529177249const 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_outend
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) endend
main()2_training/hamiltonian/_eval_launcher.pyAdded+12
2_training/hamiltonian/infer_sc/dataset/00/element.datAdded+16
2_training/hamiltonian/infer_sc/dataset/00/info.jsonAdded+1
2_training/hamiltonian/infer_sc/dataset/00/lat.datAdded+3
2_training/hamiltonian/infer_sc/dataset/00/orbital_types.datAdded+16
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/config.iniAdded+82
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/result.txtAdded+86
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/__init__.pyAdded+10
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/__pycache__/__init__.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/__pycache__/data.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/__pycache__/graph.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/__pycache__/kernel.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/__pycache__/model.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/__pycache__/rotate.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/__pycache__/utils.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/data.pyAdded+217
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/default.iniAdded+88
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__init__.pyAdded+1
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__pycache__/__init__.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_HermNet/__pycache__/rmnet.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_HermNet/license.txtAdded+1
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_HermNet/rmnet.pyAdded+105
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__init__.pyAdded+2
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/__init__.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/diff_group_norm.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/__pycache__/graph_norm.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/diff_group_norm.pyAdded+109
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/graph_norm.pyAdded+60
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_PyG_future/license.txtAdded+22
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__init__.pyAdded+1
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__pycache__/__init__.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/__pycache__/lattice.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/lattice.pyAdded+71
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_pymatgen/license.txtAdded+22
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__init__.pyAdded+1
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__pycache__/__init__.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/__pycache__/acsf.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/acsf.pyAdded+50
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_schnetpack/license.txtAdded+35
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/__init__.pyAdded+1
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/__pycache__/__init__.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/__pycache__/representations.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/license.txtAdded+24
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/from_se3_transformer/representations.pyAdded+204
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/graph.pyAdded+934
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/inference/__init__.pyAdded+1
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/inference/__pycache__/__init__.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/inference/__pycache__/pred_ham.cpython-312.pycAdded
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/inference/band_config.jsonAdded+8
2_training/hamiltonian/infer_sc/dataset/00/pred_ham_std/src/deeph/inference/dense_calc.jlAdded+234