Skip to content

Commit

Permalink
Up
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiHelleboid committed Nov 29, 2023
1 parent 3aed0e7 commit 203e037
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions python/kpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def main():

directions = [int(x) for x in args.directions]
shift = [float(x) for x in args.shift.split(',')]
print(shift)
irreducible_wedge = args.irreducible_wedge
output = args.output

Expand All @@ -103,6 +104,7 @@ def main():
kx = np.linspace(min, max, Nx)
ky = np.linspace(min, max, Ny)
list_kpoints = [[x, y, 0.0] for x in kx for y in ky if np.linalg.norm(np.array([x, y, 0.0]) - center) <= radius]

elif args.grid == '3D':
kx = np.linspace(min, max, Nx)
ky = np.linspace(min, max, Ny)
Expand All @@ -113,6 +115,9 @@ def main():
else:
raise ValueError('Unknown grid type: {}'.format(args.grid))

# Apply shift
list_kpoints = [np.array(k) + np.array(shift) for k in list_kpoints]

print(f"Generated {len(list_kpoints)} k-points.")
print(f"Writing k-points to {output}.")
np.savetxt(output, list_kpoints, fmt='%.8e')
Expand Down
6 changes: 4 additions & 2 deletions python/plots/plot_epsilon_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_crystal_dir(list_q):


def parse_epsilon_files(dirname):
files = glob.glob(dirname + "/*.csv")
files = glob.glob(dirname + "/Si*.csv")
list_qxyz = []
list_norm_q = []
data = []
Expand All @@ -37,13 +37,15 @@ def parse_epsilon_files(dirname):
for idx, filename in enumerate(files):
print(f"\r File n° {idx} / {len(files)}", end="", flush=True)
stem_name = Path(filename).stem
split_name = stem_name.split("_")
print(split_name)
qx, qy, qz = stem_name.split(
"_")[-3], stem_name.split("_")[-2], stem_name.split("_")[-1]
norm_q = np.sqrt(float(qx)**2 + float(qy)**2 + float(qz)**2)
list_norm_q.append(norm_q)
# print(f"q = (qx, qy, qz) = ({qx}, {qy}, {qz})")
list_qxyz.append((qx, qy, qz))
energies, eps_r = np.loadtxt(
energies, eps_r, eps_i = np.loadtxt(
filename, unpack=True, skiprows=1, delimiter=',')
# print("Type and shape eps_r: ", type(eps_r), eps_r.shape)
list_energies = energies
Expand Down
2 changes: 1 addition & 1 deletion src/BZ_MESH/bz_states.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void BZ_States::compute_dielectric_function(const std::vector<double>& list_ener
std::cout << "Total volume: " << total_volume << std::endl;

double q_squared = m_q_shift.Length() * m_q_shift.Length();
double pre_factor = 4.0 * M_PI / q_squared;
double pre_factor = 2.0 * M_PI / q_squared;
for (std::size_t index_energy = 0; index_energy < list_energies.size(); ++index_energy) {
m_dielectric_function_real[index_energy] = 1.0 + pre_factor * dielectric_function_real_at_energies[index_energy] / total_volume;
}
Expand Down
5 changes: 2 additions & 3 deletions src/EPP/DielectricFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ void DielectricFunction::compute_dielectric_function(double eta_smearing) {
for (std::size_t index_k = m_offset_k_index; index_k < m_offset_k_index + m_nb_kpoints; ++index_k) {
if (index_q == 0) {
auto k_vect = m_kpoints[index_k];
std::cout << "Computing eigenvalues for k = " << k_vect << std::endl;
hamiltonian_k.SetMatrix(k_vect, m_nonlocal_epm);
hamiltonian_k.Diagonalize(keep_eigenvectors);
m_eigenvalues_k[index_k] = hamiltonian_k.eigenvalues();
Expand All @@ -121,7 +120,6 @@ void DielectricFunction::compute_dielectric_function(double eta_smearing) {
eigenvectors_k_plus_q.col(idx_conduction_band).adjoint().dot(m_eigenvectors_k[index_k].col(idx_valence_band))),
2);
double delta_energy = (eigenvalues_k_plus_q[idx_conduction_band]) - m_eigenvalues_k[index_k][idx_valence_band];
std::cout << "Energy val: " << m_eigenvalues_k[index_k][idx_valence_band] << std::endl;
for (std::size_t index_energy = 0; index_energy < m_energies.size(); ++index_energy) {
double energy = m_energies[index_energy];
double factor_1 =
Expand Down Expand Up @@ -193,7 +191,7 @@ DielectricFunction DielectricFunction::merge_results(DielectricFunction
for (std::size_t index_energy = 0; index_energy < total_dielectric_function[index_q].size(); ++index_energy) {
total_dielectric_function[index_q][index_energy] *= renormalization;
total_dielectric_function[index_q][index_energy] =
1.0 + (4.0 * M_PI / q_squared) * total_dielectric_function[index_q][index_energy];
1.0 + (2.0 * M_PI / q_squared) * total_dielectric_function[index_q][index_energy];
}
}

Expand Down Expand Up @@ -251,6 +249,7 @@ void DielectricFunction::export_dielectric_function_at_q(const std::string& file
outname = filename;
}
std::ofstream outfile(outname);
std::cout << m_energies[0] << " " << m_dielectric_function_real[idx_q][0] << std::endl;
outfile << "Energy (eV),EpsilonReal,EpsilonImaginary" << std::endl;
for (std::size_t index_energy = 0; index_energy < m_energies.size(); ++index_energy) {
outfile << m_energies[index_energy] << "," << m_dielectric_function_real[idx_q][index_energy] << ","
Expand Down

0 comments on commit 203e037

Please sign in to comment.