Skip to content

Commit

Permalink
Add new option
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiHelleboid committed Apr 7, 2023
1 parent 67dc60f commit 9ca7d98
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
7 changes: 6 additions & 1 deletion apps/BandsOnBZ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> arg_nb_threads("j", "nthreads", "number of threads to use.", false, 1, "int");
cmd.add(arg_mesh_file);
cmd.add(arg_material);
Expand All @@ -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);

Expand Down Expand Up @@ -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<std::chrono::milliseconds>(end - start).count();
Expand Down
4 changes: 3 additions & 1 deletion apps/mpi_BandsOnBZ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> arg_nb_threads("j", "nthreads", "number of threads to use.", false, 1, "int");
cmd.add(arg_mesh_file);
cmd.add(arg_material);
Expand All @@ -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);

Expand Down Expand Up @@ -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<double> chunk_list_energies(counts_element_per_process[process_rank] * my_options.nrLevels);
for (int i = 0; i < counts_element_per_process[process_rank]; ++i) {
Expand Down
23 changes: 13 additions & 10 deletions src/EPP/BandStructure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

namespace EmpiricalPseudopotential {


std::string BandStructure::get_path_as_string() const {
std::string path = "";
for (const auto& point : m_path) {
Expand Down Expand Up @@ -155,7 +154,7 @@ void BandStructure::Compute_parallel(int nb_threads) {
m_computation_time_s = std::chrono::duration_cast<std::chrono::seconds>(end - start).count();
}

double BandStructure::AdjustValues() {
double BandStructure::AdjustValues(bool minConductionBandToZero) {
double maxValValence;
double minValConduction;

Expand All @@ -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;
}
Expand Down Expand Up @@ -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<std::vector<double>> results) {
std::cout << "Exporting band structure to file: " << filename << std::endl;
std::ofstream file(filename);
Expand Down
2 changes: 1 addition & 1 deletion src/EPP/BandStructure.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class BandStructure {
unsigned int GetPointsNumber() const { return static_cast<unsigned int>(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;
Expand Down

0 comments on commit 9ca7d98

Please sign in to comment.