Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Wannier90 interface #916

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ option(SIRIUS_USE_OPENMP "use OpenMP" ON)
option(SIRIUS_USE_PROFILER "measure execution of functions with timer" ON)
option(SIRIUS_USE_MEMORY_POOL "use memory pool" ON)
option(SIRIUS_USE_POWER_COUNTER "measure energy consumption with power counters" OFF)
option(SIRIUS_USE_WANNIER90 "use Wannier90 library" OFF)
option(BUILD_TESTING "build test executables" OFF) # override default setting in CTest module
option(SIRIUS_USE_VCSQNM "use variable cell stabilized quasi Newton method" OFF)

Expand Down Expand Up @@ -187,6 +188,10 @@ endif(SIRIUS_USE_VDWXC)

find_package(costa CONFIG REQUIRED)

if(SIRIUS_USE_WANNIER90)
find_package(Wannier90 REQUIRED)
endif()

if(SIRIUS_USE_CUDA)
enable_language(CUDA)
# note find cudatoolkit is called inside the include file. the
Expand Down
6 changes: 6 additions & 0 deletions apps/mini_app/sirius.scf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ ground_state(Simulation_context& ctx, int task_id, cmd_args const& args, int wri
dft.check_scf_density();
}

#if defined(SIRIUS_WANNIER90)
if (ctx.cfg().parameters().wannier()) {
kset.generate_w90_coeffs();
}
#endif

auto repeat_update = args.value<int>("repeat_update", 0);
if (repeat_update) {
auto lv = ctx.unit_cell().lattice_vectors();
Expand Down
25 changes: 25 additions & 0 deletions cmake/modules/FindWannier90.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
include(FindPackageHandleStandardArgs)
find_package(PkgConfig REQUIRED)

find_library(SIRIUS_WANNIER90_LIBRARIES NAMES wannier wannier90
PATH_SUFFIXES lib
HINTS
ENV EBROOTWANNIER90
ENV WANNIER90_ROOT
)

find_path(SIRIUS_WANNIER90_INCLUDE_DIR NAMES w90_wannierise.mod
PATH_SUFFIXES modules
HINTS
ENV EBROOTWANNIER90
ENV WANNIER90_ROOT
)

find_package_handle_standard_args(Wannier90 DEFAULT_MSG SIRIUS_WANNIER90_LIBRARIES SIRIUS_WANNIER90_INCLUDE_DIR)

if(Wannier90_FOUND AND NOT TARGET sirius::wannier90)
add_library(sirius::wannier90 INTERFACE IMPORTED)
set_target_properties(sirius::wannier90 PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SIRIUS_WANNIER90_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${SIRIUS_WANNIER90_LIBRARIES}")
endif()
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ set(_SOURCES
"k_point/generate_spinor_wave_functions.cpp"
"k_point/k_point.cpp"
"k_point/k_point_set.cpp"
"k_point/generate_w90_coeffs.cpp"
"radial/radial_integrals.cpp"
"mixer/mixer_functions.cpp"
"nlcglib/adaptor.cpp"
Expand Down Expand Up @@ -115,6 +116,7 @@ target_link_libraries(sirius PUBLIC ${GSL_LIBRARY}
$<TARGET_NAME_IF_EXISTS:sirius::libvdwxc>
$<TARGET_NAME_IF_EXISTS:nlcglib::nlcglib>
$<TARGET_NAME_IF_EXISTS:kokkos::kokkos>
$<TARGET_NAME_IF_EXISTS:sirius::wannier90>
SpFFT::spfft
SPLA::spla
"${SIRIUS_LINALG_LIB}"
Expand All @@ -130,6 +132,7 @@ target_link_libraries(sirius PUBLIC ${GSL_LIBRARY}
target_include_directories(sirius PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/src>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/src/mod_files>)

target_compile_definitions(sirius PUBLIC
$<$<BOOL:${SIRIUS_USE_PROFILER}>:SIRIUS_PROFILE>
$<$<BOOL:${SIRIUS_USE_SCALAPACK}>:SIRIUS_SCALAPACK>
Expand All @@ -147,6 +150,7 @@ target_compile_definitions(sirius PUBLIC
$<$<BOOL:${SIRIUS_USE_VCSQNM}>:SIRIUS_VCSQNM>
$<$<BOOL:${SIRIUS_HAVE_LIBVDW_WITH_MPI}>:SIRIUS_HAVE_VDWXC_MPI>
$<$<AND:$<BOOL:${SIRIUS_USE_MAGMA}>,$<BOOL:${SIRIUS_USE_ROCM}>>:HAVE_HIP> # Required for magma headers
$<$<BOOL:${SIRIUS_USE_WANNIER90}>:SIRIUS_WANNIER90>
)

if(SIRIUS_CREATE_FORTRAN_BINDINGS)
Expand Down
12 changes: 12 additions & 0 deletions src/context/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,18 @@ class config_t
}
dict_["/parameters/precision_gs"_json_pointer] = precision_gs__;
}
/// True if Wannier functions have to be computed.
inline auto wannier() const
{
return dict_.at("/parameters/wannier"_json_pointer).get<bool>();
}
inline void wannier(bool wannier__)
{
if (dict_.contains("locked")) {
throw std::runtime_error(locked_msg);
}
dict_["/parameters/wannier"_json_pointer] = wannier__;
}
private:
nlohmann::json& dict_;
};
Expand Down
63 changes: 29 additions & 34 deletions src/context/input_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -747,40 +747,35 @@
"type": "number",
"default": -1,
"title": "XC density threshold (debug purposes).",
"$comment": "subject to removal or moving to `settings` section."
},
"use_scf_correction": {
"type": "boolean",
"default": true,
"title": "True if SCF correction to total energy should be computed."
},
"precision_wf": {
"type": "string",
"default": "fp64",
"enum": [
"fp64",
"fp32"
],
"title": "The floating point precision of the Kohn-Sham wave-functions."
},
"precision_hs": {
"type": "string",
"default": "fp64",
"enum": [
"fp64",
"fp32"
],
"title": "The floating point precision of the Hamiltonian subspace matrices."
},
"precision_gs": {
"type": "string",
"default": "auto",
"enum": [
"auto",
"fp32",
"fp64"
],
"title": "The final floating point precision of the ground state DFT calculation (dev options)."
"$comment" : "subject to removal or moving to `settings` section."
},
"use_scf_correction" : {
"type" : "boolean",
"default" : true,
"title" : "True if SCF correction to total energy should be computed."
},
"precision_wf" : {
"type" : "string",
"default" : "fp64",
"enum" : ["fp64", "fp32"],
"title" : "The floating point precision of the Kohn-Sham wave-functions."
},
"precision_hs" : {
"type" : "string",
"default" : "fp64",
"enum" : ["fp64", "fp32"],
"title" : "The floating point precision of the Hamiltonian subspace matrices."
},
"precision_gs" : {
"type" : "string",
"default" : "auto",
"enum" : ["auto", "fp32", "fp64"],
"title" : "The final floating point precision of the ground state DFT calculation (dev options)."
},
"wannier" : {
"type" : "boolean",
"default" : false,
"title" : "True if Wannier functions have to be computed."
}
}
},
Expand Down
Loading
Loading