QuantumLab-ZY / HamGNN

An E(3) equivariant Graph Neural Network for predicting electronic Hamiltonian matrix
GNU General Public License v3.0
63 stars 15 forks source link

training issue with HamGNN #32

Open gaoxuew opened 1 month ago

gaoxuew commented 1 month ago

Dear Dr. Zhong, I have been trying to test HamGNN for a system of interest, but encountered issues to reduce the training error. See the following correlation plot. I would really appreciate if you have any suggestions for improving this. I have uploaded the graph inputs at: https://zenodo.org/records/13941814. I also attached the config.yaml that I used below. Thank you. Best, Gaoxue

Screenshot 2024-10-16 at 11 13 18 AM

config.yaml: dataset_params: batch_size: 1 split_file: null test_ratio: 0.1 train_ratio: 0.8 val_ratio: 0.1 graph_data_path: ./ # Directory where graph_data.npz is located

losses_metrics: losses:

Generally, the optim_params module only needs to set the initial learning rate (lr)

optim_params: lr: 0.01 lr_decay: 0.5 lr_patience: 5 gradient_clip_val: 0.0 max_epochs: 3000 min_epochs: 100 stop_patience: 30

output_nets: output_module: HamGNN_out HamGNN_out: ham_only: true # true: Only the Hamiltonian H is computed; 'false': Fit both H and S ham_type: openmx # openmx: fit openmx Hamiltonian; abacus: fit abacus Hamiltonian nao_max: 19 # The maximum number of atomic orbitals in the data set, which can be 14, 19 or 27 add_H0: true # Generally true, the complete Hamiltonian is predicted as the sum of H_scf plus H_nonscf (H0) symmetrize: true # if set to true, the Hermitian symmetry constraint is imposed on the Hamiltonian calculate_band_energy: false # Whether to calculate the energy bands to train the model num_k: 5 # When calculating the energy bands, the number of K points to use band_num_control: null # dict: controls how many orbitals are considered for each atom in energy bands; int: [vbm-num, vbm+num]; null: all bands k_path: null # auto: Automatically determine the k-point path; null: random k-point path; list: list of k-point paths provided by the user soc_switch: false # if true, fit the SOC Hamiltonian nonlinearity_type: norm # norm or gate

profiler_params: progress_bar_refresh_rat: 1 train_dir: ./ #The folder for saving training information and prediction results. This directory can be read by tensorboard to monitor the training process.

representation_nets:

Network parameters usually do not need to be changed.

HamGNN_pre: cutoff: 26.0 resnet: True cutoff_func: cos edge_sh_normalization: component edge_sh_normalize: true ######## Irreps set 1 (crystal): ################ feature_irreps_hidden: 64x0e+32x1o+16x1e+8x2o+20x2e+8x3o+4x3e+4x4e irreps_edge_output: 64x0e+32x1o+16x1e+8x2o+20x2e+8x3o+4x3e+4x4e irreps_edge_sh: 0e + 1o + 2e + 3o + 4e + 5o irreps_node_features: 64x0e+32x1o+16x1e+8x2o+20x2e+8x3o+4x3e+4x4e irreps_node_output: 64x0e+32x1o+16x1e+8x2o+20x2e+8x3o+4x3e+4x4e irreps_triplet_output: 64x0e+32x1o+16x1e+8x2o+20x2e+8x3o+4x3e+4x4e invariant_layers: 3 invariant_neurons: 64 num_interaction_layers: 3 num_radial: 64 num_spherical: 8 num_types: 60 export_triplet: false rbf_func: bessel set_features: true add_edge_tp: False irreps_node_prev: 64x0e+20x1o+8x1e+8x2o+20x2e+8x3o+4x3e+4x4e num_node_attr_feas: 64

setup: GNN_Net: HamGNN_pre accelerator: null ignore_warnings: true checkpoint_path: ./ # Path to the model weights file load_from_checkpoint: false resume: false num_gpus: null # null: use cpu; [i]: use the ith GPU device precision: 32 property: hamiltonian stage: fit # fit: training; test: inference

QuantumLab-ZY commented 1 month ago

Hi @gaoxuew, Can you show me the openmx .dat file used in your training set? It seems that the problem is caused by the mismatch between the atomic orbital basis of your Te element and that in HamGNN.

gaoxuew commented 1 month ago

Thanks for your reply. I have added a line (52:np.array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18], dtype=int), # Te) in basis_def_19 in utils.py for HamGNN. The following is the .dat file I used for generating dataset:

#

File Name

#

System.CurrrentDirectory ./ # default=./ System.Name CsTe DATA.PATH ../DFT_DATA19 level.of.stdout 1 # default=1 (1-3) level.of.fileout 1 # default=1 (0-2) HS.fileout on # on|off, default=off

#

SCF or Electronic System

#

scf.XcType GGA-PBE # LDA|LSDA-CA|LSDA-PW|GGA-PBE scf.SpinPolarization off # On|Off|NC scf.ElectronicTemperature 100.0 # default=300 (K) scf.energycutoff 200.0 # default=150 (Ry) scf.maxIter 300 # default=40 scf.EigenvalueSolver Band # DC|GDC|Cluster|Band scf.Kgrid 1 2 1 # means 4x4x4 scf.Mixing.Type rmm-diis # Simple|Rmm-Diis|Gr-Pulay|Kerker|Rmm-Diisk scf.Init.Mixing.Weight 0.10 # default=0.30 scf.Min.Mixing.Weight 0.001 # default=0.001 scf.Max.Mixing.Weight 0.400 # default=0.40 scf.Mixing.History 7 # default=5 scf.Mixing.StartPulay 5 # default=6 scf.criterion 1.0e-7 # default=1.0e-6 (Hartree)

#

MD or Geometry Optimization

#

MD.Type Nomd # Nomd|Opt|NVE|NVT_VS|NVT_NH

Constraint_Opt|DIIS2|Constraint_DIIS2

MD.Opt.DIIS.History 4 MD.Opt.StartDIIS 5 # default=5 MD.maxIter 100 # default=1 MD.TimeStep 1.0 # default=0.5 (fs) MD.Opt.criterion 1.0e-4 # default=1.0e-4 (Hartree/bohr)

#

MO output

#

MO.fileout off # on|off, default=off num.HOMOs 2 # default=1 num.LUMOs 2 # default=1

#

DOS and PDOS

#

Dos.fileout off # on|off, default=off Dos.Erange -10.0 10.0 # default = -20 20 Dos.Kgrid 1 1 1 # default = Kgrid1 Kgrid2 Kgrid3 #

Definition of Atomic Species

# Species.Number 2 <Definition.of.Atomic.Species Cs Cs12.0-s3p2d2 Cs_PBE19 Te Te7.0-s3p2d2 Te_PBE19 Definition.of.Atomic.Species>

#

Atoms

# Atoms.Number 12 Atoms.SpeciesAndCoordinates.Unit Ang # Ang|AU <Atoms.SpeciesAndCoordinates # Unit=Ang. 1 Cs 4.5224492 4.3822172 7.8744975 4.50 4.50 2 Cs 0.3435894 1.5109839 1.9337570 4.50 4.50 3 Cs 8.1343161 4.3256746 4.9971739 4.50 4.50 4 Cs 1.3567350 1.5369965 6.5908122 4.50 4.50 5 Cs 5.0892536 1.4874113 3.8570344 4.50 4.50 6 Cs 6.1284089 1.3854998 10.7648949 4.50 4.50 7 Cs 3.3454853 4.4889318 0.8128757 4.50 4.50 8 Cs 9.3356670 4.4768220 9.7022322 4.50 4.50 9 Te 2.3023680 1.4370597 10.3100562 8.00 8.00 10 Te 2.4767720 4.4761123 4.5144374 8.00 8.00 11 Te 7.2584821 1.4876995 7.1216528 8.00 8.00 12 Te 7.2555120 4.4767024 1.2617635 8.00 8.00 Atoms.SpeciesAndCoordinates> Atoms.UnitVectors.Unit Ang # Ang|AU <Atoms.UnitVectors # unit=Ang. 9.6225745 0.0000000 0.0000000 0.0000000 5.8867371 0.0000000 0.0000000 0.0000000 11.6256507 Atoms.UnitVectors>

QuantumLab-ZY commented 1 month ago

Hi @gaoxuew, you can add 55:[0,1,2,3,4,5,6,7,8,9,10,11 ,12 ,13 ,14 ,15 ,16 ,17 ,18], # Te to the dictionary self.basis_def(Line: 1031) in net.py.

gaoxuew commented 1 month ago

Thank you. That’s helpful. I have another question on getting charge density as the one you showed in your paper on silicon with defect. May I know the package/scrips that you used to process the predicted Hamiltonian to get other materials properties?