| #!/usr/bin/env julia |
| #= |
| DFT electron-phonon coupling calculation for diamond using ElectronPhonon.jl. |
|
|
| Workflow (set one |
| create → / |
| run = true → run QE SCF + pw2bgw for all structures |
| prepare = true → read QE output, create JLD2 eigenvalue/ |
| calc_ep → → /out_dft/ |
|
|
| Usage: |
| cd /diamond/ |
| julia |
| =# |
| using |
|
|
| # ============================================================ |
| # Workflow — |
| # ============================================================ |
| create |
| from_scratch |
| run |
| prepare |
| calc_ep |
|
|
| # ============================================================ |
| # Paths |
| # ============================================================ |
| SCRIPT_DIR |
| path_to_calc |
|
|
| # Path |
| # Update |
| path_to_qe |
|
|
| mpi_ranks |
|
|
| # ============================================================ |
| # Diamond Å |
| # ============================================================ |
| a |
| sc_size |
| k_mesh |
| natoms |
| Ndisplace × × |
|
|
| pseudo_dir |
|
|
| unitcell |
| :symbols |
| :cell |
| [0.0, a/2, a/2], |
| [a/2, 0.0, a/2], |
| [a/2, a/2, 0.0] |
| ]), |
| :scaled_positions |
| (0.0, 0.0, 0.0), |
| (0.25, 0.25, 0.25) |
| ]), |
| :masses |
| ) |
|
|
| scf_parameters |
| :format |
| :kpts |
| :calculation |
| :prefix |
| :outdir |
| :pseudo_dir |
| :ecutwfc |
| :conv_thr |
| :pseudopotentials |
| :diagonalization |
| :mixing_mode |
| :mixing_beta |
| :crystal_coordinates |
| :verbosity |
| :tstress |
| :ibrav |
| :tprnfor |
| :nbnd |
| :electron_maxstep |
| :nosym |
| :noinv |
| ) |
|
|
| abs_disp |
|
|
| model |
| path_to_calc |
| abs_disp |
| path_to_qe |
| mpi_ranks |
| sc_size |
| k_mesh |
| Ndispalce |
| unitcell |
| scf_parameters |
| use_symm |
| ) |
|
|
| # ============================================================ |
| # Step |
| # ============================================================ |
| if |
| println("Creating displacement structures in displacements/...") |
| create_disp_calc!(model; from_scratch = from_scratch) |
| println("Done. Created displacements/scf_0/ and displacements/group_1..$(Ndisplace)/") |
| end |
|
|
| # ============================================================ |
| # Step 2: Run QE SCF + pw2bgw |
| # ============================================================ |
| if run |
| println("Running QE SCF + pw2bgw for all $(Ndisplace + 1) structures...") |
| run_calculations(model) |
| println("Done. QE calculations complete.") |
| println("Next: run HPRO reconstruction via ml_epc.py (step 'hpro'), then set prepare=true") |
| end |
|
|
| # ============================================================ |
| # Step 3: Prepare model |
| # ============================================================ |
| if prepare |
| println("Preparing model (reading QE output, creating JLD2 files)...") |
| prepare_model(model) |
| electrons = create_electrons(model) |
| phonons = create_phonons(model) |
| println("Done. Eigenvalue and phonon JLD2 files created.") |
| end |
|
|
| # ============================================================ |
| # Step 4: Compute DFT EPC matrix elements |
| # ============================================================ |
| if calc_ep |
| electrons = load_electrons(model) |
| phonons = load_phonons(model) |
|
|
| disp_dir = path_to_calc * "displacements/" |
| out_dir = disp_dir * "out/" |
| out_dft = disp_dir * "out_dft/" |
|
|
| ik_list = collect(1:prod(k_mesh)) |
| iq_list = [1] |
|
|
| progress = Progress(length(ik_list) * length(iq_list), dt=5.0) |
| println("Calculating DFT EPC for $(length(ik_list)) k-points...") |
|
|
| for ik in ik_list |
| for iq in iq_list |
| electron_phonon(model, ik, iq, electrons, phonons; phonons_dfpt=false) |
| next!(progress) |
| end |
| end |
|
|
| # Rename out/ → out_dft/ to preserve DFT reference |
| if isdir(out_dft) |
| rm(out_dft; recursive=true) |
| end |
| if isdir(out_dir) |
| mv(out_dir, out_dft) |
| println("Done. DFT EPC saved to: displacements/out_dft/ ($(length(readdir(out_dft))) files)") |
| else |
| println("WARNING: out/ not found after EPC calculation.") |
| end |
| end |
|
|