Skip to content

Commit

Permalink
Merge ok
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiHelleboid committed Feb 1, 2024
2 parents 1043c3f + 1e0a7ad commit 52482a4
Show file tree
Hide file tree
Showing 268 changed files with 1,072,567 additions and 232 deletions.
68 changes: 59 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ option(ENABLE_MPI_BUILD "Build some programs with MPI parralelization." ON)
option(ENABLE_CLANG_TIDY "Enable clang tidy at compilation" OFF)
option(ENABLE_BUILD_DOC "Enable the documentation build (doxygen)" OFF)
option(ENABLE_BUILD_TEST "Enable the documentation build (doxygen)" ON)
option(ENABLE_MARCH_NATIVE "Enable optimization for the local machine." ON)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand Down Expand Up @@ -47,12 +48,17 @@ if(ENABLE_CLANG_TIDY)
set(CMAKE_CXX_CLANG_TIDY clang-tidy -checks=-*,readability-*)
endif()

if (ENABLE_MARCH_NATIVE)
message("Optimization for the local machine is enabled")
add_compile_options(-march=native)
endif()


# Flags for the compiler
if(MSVC)
add_compile_options("/W4" "$<$<CONFIG:RELEASE>:/O2>")
else()
add_compile_options("-Wall" "-Wextra" "-pedantic")
# add_compile_options("-Werror")
# add_compile_options("-Wall" "-Wextra" "-Werror" "-pedantic")

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options("-stdlib=libc++")
Expand All @@ -61,6 +67,16 @@ else()
endif()
endif()

# exclude Anaconda directories from search
if(DEFINED ENV{CONDA_PREFIX})
set(h5_ignore_path
$ENV{CONDA_PREFIX}/bin $ENV{CONDA_PREFIX}/lib $ENV{CONDA_PREFIX}/include
$ENV{CONDA_PREFIX}/Library/bin $ENV{CONDA_PREFIX}/Library/lib $ENV{CONDA_PREFIX}/Library/include
)
list(APPEND CMAKE_IGNORE_PATH ${h5_ignore_path})
endif()


# -----------------------------------------------------------------------------
# FIND / GET RELEVANT LIBRARIES
include(FetchContent)
Expand All @@ -73,16 +89,17 @@ FetchContent_Declare(
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE)

find_package(Eigen3 NO_MODULE)
# find_package(Eigen3)

if(NOT Eigen3_FOUND)
# if(NOT Eigen3_FOUND)
set(EIGEN_BUILD_DOC OFF)
set(BUILD_TESTING OFF)
set(EIGEN_BUILD_PKGCONFIG OFF)
message("Fetching Eigen3 lib ...")
add_compile_definitions(EIGEN_USE_LAPACK=0)
# add_compile_definitions(EIGEN_USE_LAPACK=0)
FetchContent_MakeAvailable(Eigen)
endif()
find_package(Eigen3 REQUIRED)
# endif()

# Find OpenMP
if(ENABLE_OPEN_MP)
Expand Down Expand Up @@ -141,13 +158,31 @@ FetchContent_Declare(
FetchContent_Declare(
yaml-cpp
GIT_REPOSITORY "https://github.com/jbeder/yaml-cpp"
GIT_TAG "328d2d85e833be7cb5a0ab246cc3f5d7e16fc67a")
GIT_TAG "master")

FetchContent_Declare(
rapidcsv
GIT_REPOSITORY "https://github.com/d99kris/rapidcsv.git"
GIT_TAG "master"
CONFIGURE_COMMAND "" BUILD_COMMAND "")

# Get fast-parse-csv lib
find_package(rapidcsv NO_MODULE)

if(NOT rapidcsv_FOUND)
message("Fetching rapidcsv lib ...")
FetchContent_MakeAvailable(rapidcsv)
include_directories(${rapidcsv_SOURCE_DIR})
endif()

# Get yaml_cpp lib
find_package(yaml-cpp NO_MODULE)

if(NOT yaml-cpp_FOUND)
message("Fetching yaml-cpp lib ...")
set(YAML_CPP_BUILD_TESTS OFF)
set(YAML_CPP_BUILD_TOOLS OFF)
set(YAML_CPP_BUILD_CONTRIB OFF)
FetchContent_MakeAvailable(yaml-cpp)
endif()

Expand Down Expand Up @@ -178,6 +213,22 @@ else(DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif()

# Get yaml_cpp lib
find_package(yaml-cpp NO_MODULE)

if(NOT yaml-cpp_FOUND)
message("Fetching yaml-cpp lib ...")
FetchContent_MakeAvailable(yaml-cpp)
endif()

FetchContent_Declare(
fmt
GIT_REPOSITORY "https://github.com/fmtlib/fmt.git"
GIT_TAG master)
FetchContent_MakeAvailable(fmt)



# MPI SUPPORT
if(ENABLE_MPI_BUILD)
message("MPI support activated.")
Expand All @@ -204,8 +255,7 @@ if(ENABLE_BUILD_TEST)
endif(ENABLE_BUILD_TEST)

# tclap library for argument parsing
include_directories(${PROJECT_SOURCE_DIR}/external/tclap/include)

include_directories(${PROJECT_SOURCE_DIR}/external/tclap-1.4.0/include)
# -----------------------------------------------------------------------------
# The compiled library code is here
add_subdirectory(src/EPP)
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Band structure and DOS computation using empirical pseudopotentials on the full
* Standard __EPM over high symmetry k-points__ in the Brillouin zone.
* Calculation of the __band structure and DOS on a mesh of k-points in the Brillouin zone__.
* __Nonlocal corrections__ to the EPM.
* __Spin-orbit coupling__ (SOC) for the EPM band structure.
* MPI and OpenMP __parallelization__.

[![Build & Unit Test](https://github.com/RemiHelleboid/EmpiricalPseudopotential/actions/workflows/build_code.yaml/badge.svg)](https://github.com/RemiHelleboid/EmpiricalPseudopotential/actions/workflows/build_code.yaml)
Expand All @@ -22,6 +23,10 @@ You can do three types of calculations:
__Compute the electronic band structure over a path of high-symmetry points (e.g. $L \Gamma XWKULWXK \Gamma$) for a given material, and plot the results.__
![Band structure of Silicon](doc/band_structure_Si.png)

The SOC can be included in the computation:

![Band structure of Ge with SOC](doc/band_structure_Ge_soc.png)

---

__Compute the electronic band structure over all k-points of an input mesh of the Brillouin Zone (or a fraction of it). The result can then be visualized, for example, through iso-energy surface.__
Expand Down
10 changes: 8 additions & 2 deletions apps/BandsOnBZ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ 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);
cmd.add(arg_material);
Expand All @@ -41,13 +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 @@ -67,14 +72,15 @@ 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);
} 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
10 changes: 10 additions & 0 deletions apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ add_executable(DOS_MeshBZ DOS_MeshBZ.cpp)
target_link_libraries(DOS_MeshBZ PUBLIC libepp lib_bzmesh)
target_compile_features(DOS_MeshBZ PRIVATE cxx_std_20)

add_executable(epsilon.epm epsilon.cpp)
target_link_libraries(epsilon.epm PUBLIC libepp lib_bzmesh)
target_compile_features(epsilon.epm PRIVATE cxx_std_20)
target_link_libraries(epsilon.epm PUBLIC MPI::MPI_CXX)

add_executable(fullstates.epm fullstates.cpp)
target_link_libraries(fullstates.epm PUBLIC libepp lib_bzmesh)
target_compile_features(fullstates.epm PRIVATE cxx_std_20)
target_link_libraries(fullstates.epm PUBLIC MPI::MPI_CXX)

if(USE_MPI_ACCELERATION)
add_executable(mpiBandsOnBZ mpi_BandsOnBZ.cpp)
target_link_libraries(mpiBandsOnBZ PUBLIC libepp Eigen3::Eigen)
Expand Down
33 changes: 27 additions & 6 deletions apps/EmpiricalPseudoPotentialMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,24 @@ 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;
const std::string file_output =
result_dir + "/" + my_bandstructure.path_band_filename() + (enable_non_local_correction ? "_non_local" : "") + ".txt";
my_bandstructure.export_result_in_file(file_output);
Expand All @@ -79,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 @@ -96,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 @@ -123,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 @@ -147,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 @@ -189,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 @@ -199,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 All @@ -218,7 +235,7 @@ int main(int argc, char* argv[]) {
}

EmpiricalPseudopotential::Materials materials;
std::string file_material_parameters = std::string(CMAKE_SOURCE_DIR) + "/parameter_files/materials.yaml";
std::string file_material_parameters = std::string(CMAKE_SOURCE_DIR) + "/parameter_files/materials-local.yaml";
if (!arg_enable_nonlocal_correction.isSet()) {
file_material_parameters = std::string(CMAKE_SOURCE_DIR) + "/parameter_files/materials-local.yaml";
}
Expand All @@ -236,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 @@ -244,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 @@ -256,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 @@ -266,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
Loading

0 comments on commit 52482a4

Please sign in to comment.