7c_diffusivity_decomposition.py — Transport Decomposition

This script uses the fitted L and R parameters from 7b_fit_dl_parameters.py to compute and plot the full transport decomposition (mirrors Notebook 5):

  • Disorder linewidth Γ(ω) = Γ_defect + Γ_Casimir and its two contributions

  • PDC model VDOS — crystal VDOS Lorentzian-broadened by Γ(ω)/2, compared to measured disordered VDOS

  • Propagation velocity \(v_{\rm prop}(\omega) = \sqrt{D(\omega) / \tau (\omega)}\) [km/s]

  • Mean free path \(\lambda(\omega) = \sqrt{D(\omega) \cdot \tau (\omega)}\) [Å]

where D(ω) is loaded from 2_irg_t2/diffusivity.hdf5 (pre-computed externally) and τ(ω) = 1/Γ(ω) is derived from the fitted linewidth.

Run after 7b_fit_dl_parameters.py.

cd tutorials/disorder_linewidth
python 7c_diffusivity_decomposition.py

Plots are saved to dl_workflow/: disorder_linewidth.png, disordered_vs_pdc_vdos.png, propagation_velocity.png, mean_free_path.png.

  1import sys
  2
  3import h5py
  4import numpy as np
  5import matplotlib
  6import matplotlib.pyplot as plt
  7from ase.io import read
  8from scipy.interpolate import interp1d
  9
 10from tqdm import tqdm
 11
 12from smooth_disorder.structural import obtain_density, THzToCm, THz, Angstrom
 13from smooth_disorder.vis.interactive import *
 14
 15from smooth_disorder.disorder_linewidth import lorentzian_numpy, prepare_fitting_inputs
 16from smooth_disorder.disorder_linewidth import evaluate_linewidth_and_model_prediction
 17
 18
 19CRYSTAL_POSCAR    = "./1_graphite/POSCAR"
 20DISORDERED_POSCAR = "./2_irg_t2/irg_t2_14009.vasp"
 21DISORDERED_DIFFUSIVITY = "./2_irg_t2/diffusivity.hdf5"
 22
 23WORK_DIR = "./dl_workflow"
 24
 25CRYSTAL_VEL_SAVE     = f"{WORK_DIR}/crystal_vdos_group_vel"
 26DISORDERED_VDOS_SAVE = f"{WORK_DIR}/disordered_vdos"
 27SHIFTED_SAVE         = f"{WORK_DIR}/reduced_density_crystal_vdos_group_vel"
 28
 29MODEL_PARAMETERS_SAVE = f"{WORK_DIR}/model_parameters"
 30
 31
 32# read in the preprocessed data
 33(density_crystal,
 34density_disordered,
 35freq_disordered,
 36vdos_disordered,
 37interp_shifted_freq_crystal,
 38interp_shifted_vdos_crystal,
 39interp_shifted_speed_crystal) = prepare_fitting_inputs(
 40    CRYSTAL_POSCAR,
 41    DISORDERED_POSCAR,
 42    DISORDERED_VDOS_SAVE,
 43    SHIFTED_SAVE,
 44)
 45
 46# load the model parameters
 47with h5py.File(f"{MODEL_PARAMETERS_SAVE}.hdf5", "r") as f:
 48    model_params = np.asarray(f["final_model_params"])
 49    L_ref, R_ref = model_params[0]*1e1, model_params[1]*1e-6  # convert to standard units
 50
 51print(f"Grain boundary length: {L_ref} Angstrom")
 52print(f"Defect scattering parameter: {R_ref} THz cm nm^3")
 53
 54
 55# find the PDC VDOS
 56(
 57    vdos_PDC,
 58    disorder_linewidth,
 59    defect_linewidth,
 60    Casimir_model_linewidth
 61) = evaluate_linewidth_and_model_prediction(
 62        density_crystal,
 63        density_disordered,
 64        freq_disordered,
 65        vdos_disordered,
 66        interp_shifted_freq_crystal,
 67        interp_shifted_vdos_crystal,
 68        interp_shifted_speed_crystal,
 69        L=L_ref,
 70        R=R_ref,
 71    )
 72
 73
 74###########################
 75# DISORDER LINEWIDTH PLOT #
 76###########################
 77
 78
 79plt.figure(figsize=(16, 8))
 80
 81plt.plot(interp_shifted_freq_crystal, defect_linewidth, color=Colors[3], label="defect contribution")
 82plt.plot(interp_shifted_freq_crystal, Casimir_model_linewidth, color=Colors[0], label="grain boundary contribution")
 83plt.plot(interp_shifted_freq_crystal, disorder_linewidth, color=Colors[2], label="total disorder linewidth")
 84
 85plt.xlabel("Frequency [cm^-1]")
 86plt.ylabel("Disorder linewidth [cm^-1]")
 87
 88plt.title("Disorder linewidth and its contributions")
 89
 90plt.legend(loc="upper left")
 91
 92plt.savefig(f"{WORK_DIR}/disorder_linewidth.png", dpi=300)
 93
 94
 95
 96########################
 97# VDOS COMPARISON PLOT #
 98########################
 99
100
101
102def obtain_crystal_vdos():
103
104    with h5py.File(f"{CRYSTAL_VEL_SAVE}.hdf5", "r") as f:
105        freq_crystal = np.asarray(f["frequencies_bin"])  # [cm⁻¹]
106        vdos_crystal = np.asarray(f["vdos_return"])      # [THz⁻¹ nm⁻³]
107
108    return freq_crystal, vdos_crystal
109
110freq_crystal, vdos_crystal = obtain_crystal_vdos()
111
112
113
114plt.figure(figsize=(16, 8))
115
116plt.plot(freq_disordered, vdos_disordered, color=Colors[0], label='disordered system')
117plt.plot(freq_disordered, vdos_PDC, color=Colors[1], label='PDC model of the VDOS of disordered system')
118
119
120plt.xlabel("Frequency [cm^-1]")
121plt.ylabel("VDOS [THz^-1 nm^-3]")
122
123plt.title("VDOS of disordered system vs PDC VDOS model")
124
125plt.legend(loc="upper left")
126
127plt.savefig(f"{WORK_DIR}/disordered_vs_pdc_vdos.png", dpi=300)
128
129
130#############################
131# PROPAGATION VELOCITY PLOT #
132#############################
133
134
135with h5py.File(DISORDERED_DIFFUSIVITY, "r") as f:
136    print(f.keys())
137    diffusivity_plot = np.asarray(f["diffusivity"])  # in m^2/s
138    frequencies_plot_diff = np.asarray(f["frequencies_plot"])  # in cm^-1
139
140
141lifetime = 1/disorder_linewidth * THzToCm * 1e-12  # in seconds
142extrapolation_value = 1/24 * THzToCm * 1e-12  # value for frequencies above maximum
143lifetime_function = interp1d(interp_shifted_freq_crystal, lifetime, bounds_error=False, fill_value=extrapolation_value)
144lifetime_interpolated = lifetime_function(frequencies_plot_diff)
145
146plt.figure(figsize=(16, 8))
147
148plt.plot(interp_shifted_freq_crystal, interp_shifted_speed_crystal * 1e-3, color=Colors[3], label='crystal graphite')
149plt.plot(frequencies_plot_diff, np.sqrt(diffusivity_plot/lifetime_interpolated) * 1e-3, color=Colors[0], label='irradiated graphite')
150
151
152plt.xlabel("Frequency [cm^-1]")
153plt.ylabel("Propagation velocity [km/s]")
154
155plt.title("Propagation velocity in reference crystal and disordered system")
156
157plt.legend(loc="upper right")
158
159plt.savefig(f"{WORK_DIR}/propagation_velocity.png", dpi=300)
160
161
162plt.figure(figsize=(16, 8))
163
164plt.plot(frequencies_plot_diff, np.sqrt(diffusivity_plot*lifetime_interpolated) * 1e10)
165
166plt.xlabel("Frequency [cm^-1]")
167plt.ylabel("Mean free path [A]")
168
169plt.title("Mean free path in the disordered system")
170
171plt.savefig(f"{WORK_DIR}/mean_free_path.png", dpi=300)