From 9ca7d983738bf139469059131b3a0cd7a7c47e75 Mon Sep 17 00:00:00 2001 From: RemiHelleboid Date: Fri, 7 Apr 2023 22:00:37 +0200 Subject: [PATCH] Add new option --- apps/BandsOnBZ.cpp | 7 ++++++- apps/mpi_BandsOnBZ.cpp | 4 +++- src/EPP/BandStructure.cpp | 23 +++++++++++++---------- src/EPP/BandStructure.h | 2 +- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/apps/BandsOnBZ.cpp b/apps/BandsOnBZ.cpp index 6f2dbda..a3d0cca 100644 --- a/apps/BandsOnBZ.cpp +++ b/apps/BandsOnBZ.cpp @@ -33,6 +33,7 @@ int main(int argc, char* argv[]) { 10, "int"); TCLAP::SwitchArg arg_enable_nonlocal_correction("C", "nonlocal-correction", "Enable the non-local-correction for the EPM model", false); + TCLAP::SwitchArg arg_cond_band_zero("z", "MinCondZero", "Shift the conduction band minimum to 0 eV", false); TCLAP::ValueArg arg_nb_threads("j", "nthreads", "number of threads to use.", false, 1, "int"); cmd.add(arg_mesh_file); cmd.add(arg_material); @@ -41,6 +42,9 @@ int main(int argc, char* argv[]) { cmd.add(arg_nearest_neighbors); cmd.add(arg_nb_threads); cmd.add(arg_enable_nonlocal_correction); + cmd.add(arg_cond_band_zero); + + cmd.parse(argc, argv); @@ -74,7 +78,8 @@ int main(int argc, char* argv[]) { } else { my_bandstructure.Compute(); } - my_bandstructure.AdjustValues(); + my_bandstructure.AdjustValues(arg_cond_band_zero.getValue()); + auto end = std::chrono::high_resolution_clock::now(); auto total_time_count = std::chrono::duration_cast(end - start).count(); diff --git a/apps/mpi_BandsOnBZ.cpp b/apps/mpi_BandsOnBZ.cpp index 90a937e..4c45920 100644 --- a/apps/mpi_BandsOnBZ.cpp +++ b/apps/mpi_BandsOnBZ.cpp @@ -71,6 +71,7 @@ int main(int argc, char* argv[]) { 10, "int"); TCLAP::SwitchArg arg_enable_nonlocal_correction("C", "nonlocal-correction", "Enable the non-local-correction for the EPM model", false); + TCLAP::SwitchArg arg_cond_band_zero("z", "MinCondZero", "Shift the conduction band minimum to 0 eV", false); TCLAP::ValueArg arg_nb_threads("j", "nthreads", "number of threads to use.", false, 1, "int"); cmd.add(arg_mesh_file); cmd.add(arg_material); @@ -79,6 +80,7 @@ int main(int argc, char* argv[]) { cmd.add(arg_nearest_neighbors); cmd.add(arg_nb_threads); cmd.add(arg_enable_nonlocal_correction); + cmd.add(arg_cond_band_zero); cmd.parse(argc, argv); @@ -169,7 +171,7 @@ int main(int argc, char* argv[]) { EmpiricalPseudopotential::BandStructure my_bandstructure; my_bandstructure.Initialize(mat, my_options.nrLevels, Chunk_list_k_points, my_options.nearestNeighbors, enable_nonlocal_correction); my_bandstructure.Compute(); - my_bandstructure.AdjustValues(); + my_bandstructure.AdjustValues(arg_cond_band_zero.getValue()); std::vector chunk_list_energies(counts_element_per_process[process_rank] * my_options.nrLevels); for (int i = 0; i < counts_element_per_process[process_rank]; ++i) { diff --git a/src/EPP/BandStructure.cpp b/src/EPP/BandStructure.cpp index 8727950..080a793 100644 --- a/src/EPP/BandStructure.cpp +++ b/src/EPP/BandStructure.cpp @@ -14,7 +14,6 @@ namespace EmpiricalPseudopotential { - std::string BandStructure::get_path_as_string() const { std::string path = ""; for (const auto& point : m_path) { @@ -155,7 +154,7 @@ void BandStructure::Compute_parallel(int nb_threads) { m_computation_time_s = std::chrono::duration_cast(end - start).count(); } -double BandStructure::AdjustValues() { +double BandStructure::AdjustValues(bool minConductionBandToZero) { double maxValValence; double minValConduction; @@ -165,11 +164,17 @@ double BandStructure::AdjustValues() { band_gap = minValConduction - maxValValence; } - // adjust values to a guessed zero - for (auto& p : m_results) - for (auto& v : p) { - v -= maxValValence; + for (std::size_t idx_k = 0; idx_k < m_results.size(); ++idx_k) { + for (std::size_t idx_band = 0; idx_band < m_results[idx_k].size(); ++idx_band) { + if (idx_band < 4) { + m_results[idx_k][idx_band] -= maxValValence; + } else if (minConductionBandToZero) { + m_results[idx_k][idx_band] -= minValConduction; + } else { + m_results[idx_k][idx_band] -= maxValValence; + } } + } return band_gap; } @@ -274,13 +279,11 @@ std::string BandStructure::path_band_filename() const { path_string += point; } } - std::string filename = "EPM_" + m_material.get_name() + "_nb_bands_" + std::to_string(m_results.front().size()) + "_path_" + path_string + - "_size_basis_" + std::to_string(basisVectors.size()); + std::string filename = "EPM_" + m_material.get_name() + "_nb_bands_" + std::to_string(m_results.front().size()) + "_path_" + + path_string + "_size_basis_" + std::to_string(basisVectors.size()); return filename; } - - void export_vector_bands_result_in_file(const std::string& filename, std::vector> results) { std::cout << "Exporting band structure to file: " << filename << std::endl; std::ofstream file(filename); diff --git a/src/EPP/BandStructure.h b/src/EPP/BandStructure.h index 889ccca..b809ba1 100644 --- a/src/EPP/BandStructure.h +++ b/src/EPP/BandStructure.h @@ -52,7 +52,7 @@ class BandStructure { unsigned int GetPointsNumber() const { return static_cast(m_kpoints.size()); } void Compute(); void Compute_parallel(int nb_threads); - double AdjustValues(); + double AdjustValues(bool minConductionBandToZero=false); void print_results() const; std::string path_band_filename() const;