Skip to content

Commit

Permalink
Change all files to add the SOC option
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiHelleboid committed Sep 15, 2023
1 parent 0027379 commit 4b58536
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 95 deletions.
9 changes: 5 additions & 4 deletions 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_enable_soc("s", "soc", "Enable the spin-orbit coupling 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);
Expand All @@ -42,16 +43,16 @@ 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_enable_soc);
cmd.add(arg_cond_band_zero);



cmd.parse(argc, argv);

EmpiricalPseudopotential::Materials materials;
const std::string file_material_parameters = std::string(CMAKE_SOURCE_DIR) + "/parameter_files/materials.yaml";
materials.load_material_parameters(file_material_parameters);
bool enable_nonlocal_correction = arg_enable_nonlocal_correction.isSet();
bool enable_soc = arg_enable_soc.isSet();

Options my_options;
my_options.materialName = arg_material.getValue();
Expand All @@ -71,7 +72,8 @@ int main(int argc, char* argv[]) {
auto start = std::chrono::high_resolution_clock::now();

EmpiricalPseudopotential::BandStructure my_bandstructure;
my_bandstructure.Initialize(mat, my_options.nrLevels, mesh_kpoints, my_options.nearestNeighbors, enable_nonlocal_correction);
my_bandstructure
.Initialize(mat, my_options.nrLevels, mesh_kpoints, my_options.nearestNeighbors, enable_nonlocal_correction, arg_enable_soc);

if (my_options.nrThreads > 1) {
my_bandstructure.Compute_parallel(my_options.nrThreads);
Expand All @@ -80,7 +82,6 @@ int main(int argc, char* argv[]) {
}
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
30 changes: 25 additions & 5 deletions apps/EmpiricalPseudoPotentialMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,21 @@ int compute_path_mat(const EmpiricalPseudopotential::Material& material,
unsigned int nb_bands,
unsigned int nearestNeighbors,
bool enable_non_local_correction,
bool enable_soc,
const std::string& result_dir,
bool call_python_plot) {
Options my_options;
my_options.nearestNeighbors = nearestNeighbors;
my_options.nrPoints = nb_points;
my_options.nrLevels = nb_bands;
EmpiricalPseudopotential::BandStructure my_bandstructure;
my_bandstructure
.Initialize(material, my_options.nrLevels, path, my_options.nrPoints, my_options.nearestNeighbors, enable_non_local_correction);
my_bandstructure.Initialize(material,
my_options.nrLevels,
path,
my_options.nrPoints,
my_options.nearestNeighbors,
enable_non_local_correction,
enable_soc);
my_bandstructure.Compute();
my_bandstructure.AdjustValues();
std::cout << "Time to compute: " << my_bandstructure.get_computation_time_s() << " s" << std::endl;
Expand All @@ -80,6 +86,7 @@ int compute_all_mat(EmpiricalPseudopotential::Materials list_materials,
int nearestNeighbors,
int nrPoints,
bool enable_non_local_correction,
bool enable_soc,
int nb_threads,
const std::string& result_dir,
bool call_python_plot) {
Expand All @@ -97,8 +104,13 @@ int compute_all_mat(EmpiricalPseudopotential::Materials list_materials,
}
std::cout << std::endl;
EmpiricalPseudopotential::BandStructure my_bandstructure;
my_bandstructure
.Initialize(mat, my_options.nrLevels, path, my_options.nrPoints, my_options.nearestNeighbors, enable_non_local_correction);
my_bandstructure.Initialize(mat,
my_options.nrLevels,
path,
my_options.nrPoints,
my_options.nearestNeighbors,
enable_non_local_correction,
enable_soc);

my_bandstructure.Compute_parallel(my_options.nrThreads);
my_bandstructure.AdjustValues();
Expand All @@ -124,6 +136,7 @@ int compute_all_path_all_mat(EmpiricalPseudopotential::Materials list_materials,
int nearestNeighbors,
int nrPoints,
bool enable_non_local_correction,
bool enable_soc,
int nb_threads,
const std::string& result_dir,
bool call_python_plot) {
Expand All @@ -148,7 +161,8 @@ int compute_all_path_all_mat(EmpiricalPseudopotential::Materials list_materials,
my_options.paths[path_index],
my_options.nrPoints,
my_options.nearestNeighbors,
enable_non_local_correction);
enable_non_local_correction,
enable_soc);

my_bandstructure.Compute_parallel(my_options.nrThreads);
my_bandstructure.AdjustValues();
Expand Down Expand Up @@ -190,6 +204,7 @@ int main(int argc, char* argv[]) {
TCLAP::ValueArg<int> arg_nb_threads("j", "nthreads", "number of threads to use.", false, 1, "int");
TCLAP::ValueArg<std::string> arg_res_dir("r", "resultdir", "directory to store the results.", false, "./", "str");
TCLAP::SwitchArg arg_enable_nonlocal_correction("C", "nonlocal-correction", "Enable the non-local-correction for the EPM model", false);
TCLAP::SwitchArg arg_enable_soc("S", "soc", "Enable the spin-orbit coupling for the EPM model", false);
TCLAP::SwitchArg all_path_mat("A", "all", "Compute the band structure on all the paths for all the materials", false);
TCLAP::SwitchArg plot_with_python("P", "plot", "Call a python script after the computation to plot the band structure.", false);
cmd.add(arg_path_sym_points);
Expand All @@ -200,6 +215,7 @@ int main(int argc, char* argv[]) {
cmd.add(arg_nb_threads);
cmd.add(arg_res_dir);
cmd.add(arg_enable_nonlocal_correction);
cmd.add(arg_enable_soc);
cmd.add(all_path_mat);
cmd.add(plot_with_python);

Expand Down Expand Up @@ -237,6 +253,7 @@ int main(int argc, char* argv[]) {

bool call_python_plot = plot_with_python.isSet();
bool enable_nonlocal_correction = arg_enable_nonlocal_correction.isSet();
bool enable_soc = arg_enable_soc.isSet();

if (all_path_mat.getValue()) {
std::cout << "Compute the band structure on all the paths for all the materials" << std::endl;
Expand All @@ -245,6 +262,7 @@ int main(int argc, char* argv[]) {
arg_nearest_neighbors.getValue(),
arg_nb_points.getValue(),
enable_nonlocal_correction,
enable_soc,
arg_nb_threads.getValue(),
arg_res_dir.getValue(),
call_python_plot);
Expand All @@ -257,6 +275,7 @@ int main(int argc, char* argv[]) {
arg_nb_bands.getValue(),
arg_nearest_neighbors.getValue(),
enable_nonlocal_correction,
enable_soc,
arg_res_dir.getValue(),
call_python_plot);
} else if (!arg_material.isSet() && arg_path_sym_points.isSet()) {
Expand All @@ -267,6 +286,7 @@ int main(int argc, char* argv[]) {
arg_nearest_neighbors.getValue(),
arg_nb_points.getValue(),
enable_nonlocal_correction,
enable_soc,
arg_nb_threads.getValue(),
arg_res_dir.getValue(),
call_python_plot);
Expand Down
3 changes: 2 additions & 1 deletion apps/epsilon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ int main(int argc, char** argv) {
int Nkz = config["Nkz"].as<int>();

bool nonlocal_epm = false;
bool enable_soc = false;
if (config["nonlocal"]) {
nonlocal_epm = config["nonlocal"].as<bool>();
}
Expand Down Expand Up @@ -184,7 +185,7 @@ int main(int argc, char** argv) {
EmpiricalPseudopotential::Material current_material = materials.materials.at("Si");
EmpiricalPseudopotential::BandStructure band_structure{};

band_structure.Initialize(current_material, nb_bands, {}, nb_nearest_neighbors, nonlocal_epm);
band_structure.Initialize(current_material, nb_bands, {}, nb_nearest_neighbors, nonlocal_epm, enable_soc);
EmpiricalPseudopotential::DielectricFunction MyDielectricFunc(current_material, band_structure.get_basis_vectors(), nb_bands);

double shift = 0.0;
Expand Down
15 changes: 7 additions & 8 deletions apps/fullstates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ int main(int argc, char *argv[]) {
cmd.parse(argc, argv);

bool nonlocal_epm = false;
bool enable_soc = false;
EmpiricalPseudopotential::Materials materials;
std::string file_material_parameters = std::string(CMAKE_SOURCE_DIR) + "/parameter_files/materials-local.yaml";
if (nonlocal_epm) {
Expand All @@ -64,30 +65,28 @@ int main(int argc, char *argv[]) {
EmpiricalPseudopotential::BandStructure band_structure{};

int nb_nearest_neighbors = 10;
band_structure.Initialize(current_material, nb_bands_to_use, {}, nb_nearest_neighbors, nonlocal_epm);
band_structure.Initialize(current_material, nb_bands_to_use, {}, nb_nearest_neighbors, nonlocal_epm, enable_soc);
auto basis = band_structure.get_basis_vectors();
my_bz_mesh.set_basis_vectors(basis);

my_bz_mesh.read_mesh_geometry_from_msh_file(arg_mesh_file.getValue());
std::cout << "Mesh volume: " << my_bz_mesh.compute_mesh_volume() << std::endl;


my_bz_mesh.compute_eigenstates(my_options.nrThreads);

Vector3D<double> q_shift = Vector3D<double>{1e-10, 0.0, 0.0};
my_bz_mesh.compute_shifted_eigenstates(q_shift, my_options.nrThreads);
std::cout << "\n\n" << std::endl;


auto end = std::chrono::high_resolution_clock::now();

std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "Elapsed time: " << elapsed_seconds.count() << "s" << std::endl;

std::vector<double> list_energy;
double min_energy = 0.0;
double max_energy = 20.0;
double energy_step = 0.01;
double min_energy = 0.0;
double max_energy = 20.0;
double energy_step = 0.01;
for (double energy = min_energy; energy <= max_energy + energy_step; energy += energy_step) {
list_energy.push_back(energy);
}
Expand All @@ -96,9 +95,9 @@ int main(int argc, char *argv[]) {
auto start2 = std::chrono::high_resolution_clock::now();
my_bz_mesh.compute_dielectric_function(list_energy, eta_smearing, my_options.nrThreads);
my_bz_mesh.export_dielectric_function("./TEST_DIELECTRIC_FUNCTION_");
auto end2 = std::chrono::high_resolution_clock::now();
auto end2 = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed_seconds2 = end2 - start2;
std::cout << "Time Dielectric Function : " << elapsed_seconds2.count() << "s" << std::endl;

return 0;
return 0;
}
6 changes: 5 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_enable_soc("S", "soc", "Enable the spin-orbit coupling 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);
Expand All @@ -80,6 +81,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_enable_soc);
cmd.add(arg_cond_band_zero);

cmd.parse(argc, argv);
Expand Down Expand Up @@ -168,8 +170,10 @@ int main(int argc, char* argv[]) {
}

bool enable_nonlocal_correction = arg_enable_nonlocal_correction.getValue();
bool enable_soc = arg_enable_soc.getValue();
EmpiricalPseudopotential::BandStructure my_bandstructure;
my_bandstructure.Initialize(mat, my_options.nrLevels, Chunk_list_k_points, my_options.nearestNeighbors, enable_nonlocal_correction);
my_bandstructure
.Initialize(mat, my_options.nrLevels, Chunk_list_k_points, my_options.nearestNeighbors, enable_nonlocal_correction, enable_soc);
my_bandstructure.Compute();
my_bandstructure.AdjustValues(arg_cond_band_zero.getValue());

Expand Down
8 changes: 6 additions & 2 deletions src/EPP/BandStructure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ void BandStructure::Initialize(const Material& material,
const std::vector<std::string>& path,
unsigned int nbPoints,
unsigned int nearestNeighborsNumber,
bool enable_non_local_correction) {
bool enable_non_local_correction,
bool enable_soc) {
m_material = material;
m_nb_bands = nb_bands;
m_path = path;
m_nb_points = nbPoints;
m_nearestNeighborsNumber = nearestNeighborsNumber;
m_enable_non_local_correction = enable_non_local_correction;
m_enable_spin_orbit_coupling = enable_soc;
m_kpoints.clear();
m_results.clear();
m_kpoints.reserve(m_nb_points);
Expand All @@ -85,12 +87,14 @@ void BandStructure::Initialize(const Material& material,
std::size_t nb_bands,
std::vector<Vector3D<double>> list_k_points,
unsigned int nearestNeighborsNumber,
bool enable_non_local_correction) {
bool enable_non_local_correction,
bool enable_soc) {
m_material = material;
m_nb_bands = nb_bands;
m_nb_points = list_k_points.size();
m_nearestNeighborsNumber = nearestNeighborsNumber;
m_enable_non_local_correction = enable_non_local_correction;
m_enable_spin_orbit_coupling = enable_soc;

m_kpoints.clear();
m_results.clear();
Expand Down
11 changes: 8 additions & 3 deletions src/EPP/BandStructure.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ class BandStructure {
* @param nrPoints
* @param nearestNeighborsNumber
* @param enable_non_local_correction
* @param enable_soc
*/
void Initialize(const Material& material,
std::size_t nb_bands,
const std::vector<std::string>& path,
unsigned int nrPoints,
unsigned int nearestNeighborsNumber,
bool enable_non_local_correction);
bool enable_non_local_correction,
bool enable_soc);

/**
* @brief Initialize the band structure with the given material and the k-points on which we want
Expand All @@ -40,19 +42,21 @@ class BandStructure {
* @param list_k_points
* @param nearestNeighborsNumber
* @param enable_non_local_correction
* @param enable_soc
*/
void Initialize(const Material& material,
std::size_t nb_bands,
std::vector<Vector3D<double>> list_k_points,
unsigned int nearestNeighborsNumber,
bool enable_non_local_correction);
bool enable_non_local_correction,
bool enable_soc);

const std::vector<std::string>& GetPath() const { return m_path; }
std::string get_path_as_string() const;
unsigned int GetPointsNumber() const { return static_cast<unsigned int>(m_kpoints.size()); }
void Compute();
void Compute_parallel(int nb_threads);
double AdjustValues(bool minConductionBandToZero=false);
double AdjustValues(bool minConductionBandToZero = false);

void print_results() const;
std::string path_band_filename() const;
Expand Down Expand Up @@ -82,6 +86,7 @@ class BandStructure {
unsigned int m_nb_bands;
unsigned int m_nearestNeighborsNumber;
bool m_enable_non_local_correction;
bool m_enable_spin_orbit_coupling = false;

std::vector<Vector3D<int>> basisVectors;
std::vector<Vector3D<double>> m_kpoints;
Expand Down
Loading

0 comments on commit 4b58536

Please sign in to comment.