### Install HamGNN Source: https://github.com/quantumlab-zy/hamepc/blob/main/README.md This command clones the HamGNN repository and installs it using the setup.py script. Ensure you have git and Python installed. ```bash git clone https://github.com/QuantumLab-ZY/HamEPC.git cd HamEPC python setup.py install ``` -------------------------------- ### Initialize EPC_calculator (Python) Source: https://context7.com/quantumlab-zy/hamepc/llms.txt Demonstrates the initialization of the EPC_calculator class from the HamEPC library. It involves loading a YAML configuration file and passing the configuration and an MPI communicator to the constructor. The run() method dispatches to specific calculation modes. ```python import yaml from mpi4py import MPI from HamEPC.EPC_calculator import EPC_calculator # Load configuration with open('mobility_input.yaml', encoding='utf-8') as f: config = yaml.load(f, yaml.SafeLoader) # Initialize calculator with MPI communicator comm = MPI.COMM_WORLD epc_cal = EPC_calculator(config, comm) # Run calculation based on cal_mode epc_cal.run() # Dispatches to appropriate method # Direct method calls for specific calculations # epc_cal.plot_band() # Band structure # epc_cal.plot_phonon() # Phonon dispersion # epc_cal.plot_epc() # EPC elements # epc_cal.mobility_cal() # Carrier mobility # epc_cal.superconductivity_cal() # Tc calculation ``` -------------------------------- ### Calculate Gradient Matrices (Bash) Source: https://context7.com/quantumlab-zy/hamepc/llms.txt Bash command to execute the grad_mat_prep.py script. This command initiates the calculation of gradient matrices, producing the grad_mat.npy file essential for electron-phonon coupling analysis. ```bash # Run to generate grad_mat.npy python grad_mat_prep.py ``` -------------------------------- ### Prepare GradMat: grad_mat_prep.py Source: https://github.com/quantumlab-zy/hamepc/blob/main/README.md This script generates `grad_mat.npy` after predicting Hamiltonians using HamGNN. Key configurations include system name, paths to OpenMX executables, working directory, graph data, `mat_info_rc` file, unitcell file, Hamiltonian prediction results, perturbation delta, and options for central difference calculation, maximum atomic orbitals, gathering prediction results, reading dSon files, dSon perturbation delta, and the OpenMX basic command. ```python python grad_mat_prep.py ``` -------------------------------- ### Prepare GradMat: perturb_supercell.py Source: https://github.com/quantumlab-zy/hamepc/blob/main/README.md This script generates `mat_info_rc.npy` which is required before running HamEPC. Users need to configure several variables such as unitcell directory, supercell path, expansion ranges, perturbation delta, system name, output path for `mat_info_rc.npy`, and whether to use central difference for gradient calculation. It also takes the OpenMX basic command as input. ```python python perturb_supercell.py ``` -------------------------------- ### Calculate EPC Matrix Elements (Python) Source: https://context7.com/quantumlab-zy/hamepc/llms.txt Python snippet to calculate electron-phonon coupling (EPC) elements along a specified q-path for a fixed k-point. It takes band indices for initial and final states and an option to average over degenerate states. The result is a matrix of EPC elements. ```python # Calculate EPC along q-path for fixed k-point k_fixed = [0.0, 0.0, 0.0] # Fractional coordinates q_path = np.array([[0.0, 0.0, 0.0], [0.5, 0.0, 0.0], [0.5, 0.5, 0.0]]) band_initial = 4 # Initial state band index (0-based) band_final = 5 # Final state band index epc_elements = epc_cal.EPC_cal_path( k_fix=k_fixed, q_paths=q_path, band_ini=band_initial, band_fin=band_final, do_symm=True # Average over degenerate states ) # Returns: shape (nq, nmodes) in Hartree ``` -------------------------------- ### Superconduct Input Configuration Source: https://context7.com/quantumlab-zy/hamepc/llms.txt Configuration file for superconductivity calculations, specifying parameters for basic settings, phonon calculations, electron-phonon coupling (EPC), and transport properties. ```yaml basic: cal_mode: 'superconduct' graph_data_path_uc: ./graph_data.npz nao_max: 19 Ham_type: openmx outdir: './' phonon: supercell_matrix: [[3.0, 0.0, 0.0], [0.0, 3.0, 0.0], [0.0, 0.0, 2.0]] primitive_matrix: [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]] unitcell_filename: ./POSCAR force_sets_filename: ./FORCE_SETS epc: grad_mat_path: ./grad_mat.npy mat_info_rc_path: ./mat_info_rc.npy cell_range_cut: [2, 2, 2] transport: k_size: [32, 32, 20] q_size: [32, 32, 20] bands_indices: [59, 60, 61, 62, 63, 64, 65, 66] # Bands near Fermi level temperature: 0.05 # K (low T for superconductivity) phonon_cutoff: 0.5 # meV smeark: 15 # meV smearq: 0.5 # meV gauss_type: 0 e_thr: 45 # meV superconduct: mius: [0.05, 0.25, 0.01] # [min, max, step] for Coulomb pseudopotential omega_range: [0, 50] # meV omega_step: 0.01 # meV ``` -------------------------------- ### Calculate Phonon Spectrum (Python) Source: https://context7.com/quantumlab-zy/hamepc/llms.txt Python code for calculating phonon frequencies and eigenvectors. It first generates a grid of q-points using _get_monkhorst_pack and then computes the phonon spectrum using the _phonon_cal method. The output includes frequencies and eigenvectors, with frequencies in Hartree. ```python # Get q-points in fractional coordinates q_grid = epc_cal._get_monkhorst_pack( mesh=[32, 32, 32], return_frac=True ) # Calculate phonon spectrum frequencies, eigenvectors = epc_cal._phonon_cal(q_grid) # frequencies: shape (nq, nmodes) in Hartree # eigenvectors: shape (nq, nmodes, nmodes) ``` -------------------------------- ### Run HamEPC with MPI and OpenMP Source: https://github.com/quantumlab-zy/hamepc/blob/main/README.md HamEPC supports hybrid parallelization using MPI and OpenMP. Users can specify the number of MPI processes and OpenMP threads to optimize performance and memory usage. The command requires the number of cores and a configuration file in YAML format. ```bash mpirun -np ncores HamEPC --config EPC_input.yaml ``` -------------------------------- ### Calculate Gradient Matrices (Python) Source: https://context7.com/quantumlab-zy/hamepc/llms.txt Python script to calculate gradient matrices after Hamiltonian predictions using HamGNN. It uses the output from the perturbation step and requires paths to executables and prediction results. Parameters like delta_r and nao_max must match the perturbation step. ```python # grad_mat_prep.py configuration system_name = 'material' openmx_executable_path = "./" # Path to read_openmx and openmx_postprocess work_path = "./" graph_data_dir = "./perturb/graph_data.npz" mat_info_sc_dir = "./perturb/mat_info_rc.npy" unitcell_dir = "./POSCAR" H_pred_result_dir = "./perturb/prediction_hamiltonian.npy" delta_r = 0.01 # Must match perturb_supercell.py use_central_difference = False nao_max = 19 # 13, 14, 19, or 26 gather_H_pred = True # Use HamGNN predictions ``` -------------------------------- ### Generate Perturbed Supercells (Bash) Source: https://context7.com/quantumlab-zy/hamepc/llms.txt Bash command to execute the perturb_supercell.py script. This process generates the mat_info_rc.npy file and input files for the perturbed supercells, which are necessary for subsequent gradient matrix calculations. ```bash # Run to generate mat_info_rc.npy and perturbed supercell input files python perturb_supercell.py ``` -------------------------------- ### Generate Perturbed Supercells (Python) Source: https://context7.com/quantumlab-zy/hamepc/llms.txt Python script to generate perturbed supercell structures for Hamiltonian gradient calculations. It requires the unit cell structure and outputs perturbed structures to a specified directory. Key parameters include supercell expansion, perturbation magnitude, and system name. ```python # perturb_supercell.py configuration unitcell_dir = "./POSCAR" # Unit cell structure file (.vasp or .dat) supercell_path = './perturb/' # Output directory for perturbed structures Nrange1, Nrange2, Nrange3 = 1, 1, 1 # Supercell expansion (2*N+1 cells per direction) delta_r = 0.01 # Perturbation magnitude in Angstrom system_name = 'material' mat_info_path = './perturb/' use_central_difference = False # Set True for higher accuracy ``` -------------------------------- ### Calculate Carrier Velocities from Hamiltonian Source: https://context7.com/quantumlab-zy/hamepc/llms.txt Calculates carrier velocities using either the Hamiltonian derivative method or momentum matrix elements. Requires band indices and k-points as input. The output is in atomic units. ```python velocities = epc_cal.vel_nk_cal_from_HS( band_indices=[4, 5, 6], # Bands to calculate k_grid=k_points # k-points array ) # Returns: shape (nk, nbands, 3) in atomic units velocities = epc_cal.vel_nk_cal_from_M( band_indices=[4, 5, 6], k_grid=k_points ) ``` -------------------------------- ### Calculate Electronic Structure (Python) Source: https://context7.com/quantumlab-zy/hamepc/llms.txt Python code snippet for calculating electronic eigenvalues and eigenvectors. It first obtains the irreducible k-mesh using _get_ir_reciprocal_mesh and then computes the electronic structure via _elec_cal. The output includes eigenvalues and eigenvectors, and helper functions are provided to extract CBM and VBM energies. ```python import numpy as np # Get irreducible k-mesh with symmetry weights k_grid, weights = epc_cal._get_ir_reciprocal_mesh( mesh=[32, 32, 32], shift=[0, 0, 0], auxiliary_info=False ) # Calculate electronic structure eigenvalues, eigenvectors = epc_cal._elec_cal(k_grid) # eigenvalues: shape (nbands, nk) # eigenvectors: shape (nk, nbands, norbs) # Get CBM/VBM energies ecbm = epc_cal._get_ecbm(eigenvalues, band_index=5) evbm = epc_cal._get_evbm(eigenvalues, band_index=4) ``` -------------------------------- ### Calculate Band Velocity (Python) Source: https://context7.com/quantumlab-zy/hamepc/llms.txt Placeholder for calculating electron group velocities. This functionality is crucial for transport calculations and is typically implemented within the EPC_calculator class. ```python # Calculate electron group velocities for transport calculations # ... implementation details ... ``` -------------------------------- ### Calculate Fermi Level Source: https://context7.com/quantumlab-zy/hamepc/llms.txt Calculates the Fermi level for both insulating (with doping) and metallic systems. Requires eigenvalues and specific band indices or parameters like degauss and nelec. ```python # For insulators with carrier doping efermi, carrier_density = epc_cal._get_fermi_level_insulator( enks=eigenvalues, # shape (nbands, nk) iband_edge=5 # CBM index for electrons, VBM for holes ) # For metals efermi = epc_cal._get_fermi_level_metal( enks=eigenvalues, degauss=0.025, # Smearing in Hartree ngauss=0, # Gaussian type (0=Methfessel-Paxton) nelec=8.0 # Number of electrons ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.