├── .clang-format ├── .github └── workflows │ ├── ci.yml │ └── deploy-ghpages-doc.yml ├── .gitignore ├── .gitmodules ├── .vscode └── settings.json ├── CMakeLists.txt ├── LICENSE ├── README.md ├── binding └── fortran │ ├── CMakeLists.txt │ └── librpa_f.f90 ├── cmake.inc ├── cmake ├── FindCereal.cmake ├── FindIntelMKL.cmake ├── FindLibComm.cmake ├── FindLibRI.cmake ├── FindScaLAPACK.cmake └── UseDoxygenDoc.cmake ├── docs ├── .gitignore ├── CMakeLists.txt ├── Makefile ├── README.md ├── assets │ ├── abacus_interface.drawio.jpg │ ├── aims_interface.drawio.jpg │ └── librpa_flowchat.jpg ├── conf.py ├── develop │ ├── dataset_format.md │ ├── design.md │ └── documentation.md ├── doxygen │ ├── CMakeLists.txt │ ├── Doxyfile.in │ ├── Makefile │ └── README.md ├── driver.rst ├── index.rst ├── install.md ├── requirements.txt ├── tutorial │ ├── gw │ │ ├── gw_driver_aims.md │ │ └── index.md │ └── rpa │ │ ├── index.md │ │ └── rpa_driver_aims.md └── user_guide │ ├── api_usage.md │ ├── compile_options.md │ └── input_parameters.md ├── driver ├── CMakeLists.txt ├── inputfile.cpp ├── inputfile.h ├── main.cpp ├── read_data.cpp ├── read_data.h ├── task_exx.cpp ├── task_exx.h ├── task_rpa.cpp ├── task_rpa.h ├── write_aims.cpp └── write_aims.h ├── platforms ├── linux_intel_classic_general.sh ├── linux_intel_llvm_general.sh ├── linux_intel_llvm_libri.sh └── macos_gcc_mpich_openblas.sh ├── regression_tests ├── .gitignore ├── refs │ ├── prim_C_diamond_k64 │ │ └── aims │ │ │ ├── aims.out │ │ │ ├── control.in │ │ │ ├── geometry.in │ │ │ ├── librpa.out │ │ │ └── reference.json │ └── prim_MgO_k64 │ │ └── aims │ │ ├── aims.out │ │ ├── control.in │ │ ├── geometry.in │ │ ├── librpa.out │ │ └── reference.json └── testcases │ ├── mole_H2O │ └── aims │ │ ├── control.in │ │ ├── geometry.in │ │ ├── input_librpa.tar.gz │ │ └── librpa.in │ ├── prim_C_diamond_k64 │ └── aims │ │ ├── control.in │ │ └── geometry.in │ └── prim_MgO_k64 │ └── aims │ ├── control.in │ └── geometry.in ├── src ├── CMakeLists.txt ├── analycont.cpp ├── analycont.h ├── app_exx.cpp ├── app_exx.h ├── app_rpa.cpp ├── app_rpa.h ├── atomic_basis.cpp ├── atomic_basis.h ├── atoms.cpp ├── atoms.h ├── base_utility.h ├── chi0.cpp ├── chi0.h ├── complexmatrix.cpp ├── complexmatrix.h ├── constants.cpp ├── constants.h ├── coulmat.cpp ├── coulmat.h ├── dielecmodel.cpp ├── dielecmodel.h ├── envs_dir.cpp ├── envs_dir.cpp.in ├── envs_dir.h ├── envs_io.cpp ├── envs_io.h ├── envs_mpi.cpp ├── envs_mpi.h ├── epsilon.cpp ├── epsilon.h ├── exx.cpp ├── exx.h ├── fitting.cpp ├── fitting.h ├── get_minimax.h ├── get_minimax_gx.cpp ├── get_minimax_local.cpp ├── gw.cpp ├── gw.h ├── gx_minimax_wrp.f90 ├── gx_minimax_wrp.h ├── interface │ ├── blacs_scalapack.h │ └── blas_lapack.h ├── interpolate.cpp ├── interpolate.h ├── lapack_connector.h ├── libri_stub.h ├── libri_utils.h ├── librpa.cpp ├── librpa.h ├── librpa_main.cpp ├── librpa_main.h ├── mathtools.cpp ├── mathtools.h ├── matrix.cpp ├── matrix.h ├── matrix3.cpp ├── matrix3.h ├── matrix_m.h ├── matrix_m_parallel_utils.h ├── meanfield.cpp ├── meanfield.h ├── minimax_grid │ ├── 6 │ │ ├── INFO.txt │ │ ├── freq_grid.txt │ │ ├── minimax_grid_main.py │ │ ├── modi_leastsq.py │ │ ├── read_grid.py │ │ ├── tau_grid.py │ │ ├── time2freq_transform_grid.py │ │ ├── time2freq_transform_grid.txt │ │ └── time_grid.txt │ ├── 10 │ │ ├── INFO.txt │ │ ├── freq_grid.txt │ │ ├── minimax_grid_main.py │ │ ├── modi_leastsq.py │ │ ├── read_grid.py │ │ ├── tau_grid.py │ │ ├── time2freq_transform_grid.py │ │ ├── time2freq_transform_grid.txt │ │ └── time_grid.txt │ ├── 18 │ │ ├── INFO.txt │ │ ├── freq_grid.txt │ │ ├── minimax_grid_main.py │ │ ├── modi_leastsq.py │ │ ├── read_grid.py │ │ ├── tau_grid.py │ │ ├── time2freq_transform_grid.py │ │ ├── time2freq_transform_grid.txt │ │ └── time_grid.txt │ ├── 20 │ │ ├── INFO.txt │ │ ├── freq_grid.txt │ │ ├── job.err │ │ ├── job.log │ │ ├── minimax_grid_main.py │ │ ├── modi_leastsq.py │ │ ├── read_grid.py │ │ ├── tau_grid.py │ │ ├── time2freq_transform_grid.py │ │ ├── time2freq_transform_grid.txt │ │ └── time_grid.txt │ ├── 22 │ │ ├── INFO.txt │ │ ├── freq_grid.txt │ │ ├── job.err │ │ ├── job.log │ │ ├── minimax_grid_main.py │ │ ├── modi_leastsq.py │ │ ├── pyjob_sub.sh │ │ ├── read_grid.py │ │ ├── tau_grid.py │ │ ├── time2freq_transform_grid.py │ │ ├── time2freq_transform_grid.txt │ │ └── time_grid.txt │ ├── 24 │ │ ├── INFO.txt │ │ ├── freq_grid.txt │ │ ├── job.err │ │ ├── job.log │ │ ├── minimax_grid_main.py │ │ ├── modi_leastsq.py │ │ ├── pyjob_sub.sh │ │ ├── read_grid.py │ │ ├── tau_grid.py │ │ ├── time2freq_transform_grid.py │ │ ├── time2freq_transform_grid.txt │ │ └── time_grid.txt │ ├── GreenX │ │ ├── 10_freq_points.dat │ │ ├── 10_time_points.dat │ │ ├── 12_freq_points.dat │ │ ├── 12_time_points.dat │ │ ├── 14_freq_points.dat │ │ ├── 14_time_points.dat │ │ ├── 16_freq_points.dat │ │ ├── 16_time_points.dat │ │ ├── 18_freq_points.dat │ │ ├── 18_time_points.dat │ │ ├── 20_freq_points.dat │ │ ├── 20_time_points.dat │ │ ├── 26_freq_points.dat │ │ ├── 26_time_points.dat │ │ ├── 28_freq_points.dat │ │ ├── 28_time_points.dat │ │ ├── 30_freq_points.dat │ │ ├── 30_time_points.dat │ │ ├── 32_freq_points.dat │ │ ├── 32_time_points.dat │ │ ├── 34_freq_points.dat │ │ ├── 34_time_points.dat │ │ ├── 6_freq_points.dat │ │ ├── 6_freq_points_copy.dat │ │ ├── 6_time_points.dat │ │ ├── 8_freq_points.dat │ │ ├── 8_time_points.dat │ │ ├── INFO.txt │ │ ├── generate_fortran_subroutine.py │ │ ├── generate_local_grid.py │ │ ├── generate_python_module.py │ │ ├── local_10_freq_points.dat │ │ ├── local_10_time_points.dat │ │ └── time2freq_transform_grid.txt │ ├── INFO.txt │ ├── freq_grid.txt │ ├── gw_librpa_prototype.py │ ├── gx_20 │ │ ├── INFO.txt │ │ ├── freq_grid.txt │ │ ├── minimax_grid_main.py │ │ ├── modi_leastsq.py │ │ ├── ori_INFO.txt │ │ ├── ori_time2freq_transform_grid.txt │ │ ├── read_grid.py │ │ ├── tau_grid.py │ │ ├── time2freq_transform_grid.py │ │ ├── time2freq_transform_grid.txt │ │ └── time_grid.txt │ ├── gx_26 │ │ ├── INFO.txt │ │ ├── freq_grid.txt │ │ ├── minimax_grid_main.py │ │ ├── modi_leastsq.py │ │ ├── ori_INFO │ │ ├── ori_t2w.txt │ │ ├── read_grid.py │ │ ├── tau_grid.py │ │ ├── time2freq_transform_grid.py │ │ ├── time2freq_transform_grid.txt │ │ └── time_grid.txt │ ├── gx_34 │ │ ├── INFO.txt │ │ ├── freq_grid.txt │ │ ├── minimax_grid_main.py │ │ ├── modi_leastsq.py │ │ ├── ori_INFO │ │ ├── ori_t2w.txt │ │ ├── read_grid.py │ │ ├── tau_grid.py │ │ ├── time2freq_transform_grid.py │ │ ├── time2freq_transform_grid.txt │ │ └── time_grid.txt │ ├── gx_test_10 │ │ ├── INFO.txt │ │ ├── freq_grid.txt │ │ ├── minimax_grid_main.py │ │ ├── modi_leastsq.py │ │ ├── read_grid.py │ │ ├── tau_grid.py │ │ ├── time2freq_transform_grid.py │ │ ├── time2freq_transform_grid.txt │ │ └── time_grid.txt │ ├── gx_test_16 │ │ ├── INFO.txt │ │ ├── freq_grid.txt │ │ ├── minimax_grid_main.py │ │ ├── modi_leastsq.py │ │ ├── read_grid.py │ │ ├── tau_grid.py │ │ ├── time2freq_transform_grid.py │ │ ├── time2freq_transform_grid.txt │ │ └── time_grid.txt │ ├── local10_freq_points.dat │ ├── local10_time_points.dat │ ├── print_data.py │ ├── pyjob_sub.sh │ ├── test │ │ ├── INFO.txt │ │ ├── freq_grid.txt │ │ ├── local20_freq_points.dat │ │ ├── local20_time_points.dat │ │ ├── local_10_freq_points.dat │ │ ├── local_10_time_points.dat │ │ ├── local_16_freq_points.dat │ │ ├── local_16_time_points.dat │ │ ├── local_30_freq_points.dat │ │ ├── local_30_time_points.dat │ │ ├── minimax_grid_main.py │ │ ├── modi_leastsq.py │ │ ├── read_grid.py │ │ ├── tau_grid.py │ │ ├── time2freq_transform_grid.py │ │ ├── time2freq_transform_grid.txt │ │ └── time_grid.txt │ ├── time2freq_transform_grid.txt │ └── time_grid.txt ├── parallel_mpi.cpp ├── parallel_mpi.h ├── params.cpp ├── params.h ├── pbc.cpp ├── pbc.h ├── profiler.cpp ├── profiler.h ├── qpe_solver.cpp ├── qpe_solver.h ├── ri.cpp ├── ri.h ├── scalapack_connector.h ├── stl_io_helper.h ├── stl_io_helper.hpp ├── task.h ├── test │ ├── CMakeLists.txt │ ├── test_analycont.cpp │ ├── test_atomic_basis.cpp │ ├── test_atoms.cpp │ ├── test_base_utility.cpp │ ├── test_blas_lapack.cpp │ ├── test_complexmatrix.cpp │ ├── test_fitting.cpp │ ├── test_librpa.cpp │ ├── test_matrix.cpp │ ├── test_matrix_m.cpp │ ├── test_matrix_m_parallel_utils.cpp │ ├── test_meanfield.cpp │ ├── test_parallel_mpi.cpp │ ├── test_pbc.cpp │ ├── test_timefreq.cpp │ └── testutils.h ├── timefreq.cpp ├── timefreq.h ├── utils_io.h ├── utils_mem.cpp ├── utils_mem.h ├── utils_mpi_io.h ├── vec.h ├── vector3.h ├── vector3_order.cpp ├── vector3_order.h └── version.h └── thirdparty ├── cereal-1.3.0 ├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── appveyor.yml ├── doc │ ├── CMakeLists.txt │ ├── DoxygenLayout.xml │ ├── doxygen.in │ ├── footer.html │ └── mainpage.dox ├── include │ └── cereal │ │ ├── access.hpp │ │ ├── archives │ │ ├── adapters.hpp │ │ ├── binary.hpp │ │ ├── json.hpp │ │ ├── portable_binary.hpp │ │ └── xml.hpp │ │ ├── cereal.hpp │ │ ├── details │ │ ├── helpers.hpp │ │ ├── polymorphic_impl.hpp │ │ ├── polymorphic_impl_fwd.hpp │ │ ├── static_object.hpp │ │ ├── traits.hpp │ │ └── util.hpp │ │ ├── external │ │ ├── base64.hpp │ │ ├── rapidjson │ │ │ ├── allocators.h │ │ │ ├── cursorstreamwrapper.h │ │ │ ├── document.h │ │ │ ├── encodedstream.h │ │ │ ├── encodings.h │ │ │ ├── error │ │ │ │ ├── en.h │ │ │ │ └── error.h │ │ │ ├── filereadstream.h │ │ │ ├── filewritestream.h │ │ │ ├── fwd.h │ │ │ ├── internal │ │ │ │ ├── biginteger.h │ │ │ │ ├── diyfp.h │ │ │ │ ├── dtoa.h │ │ │ │ ├── ieee754.h │ │ │ │ ├── itoa.h │ │ │ │ ├── meta.h │ │ │ │ ├── pow10.h │ │ │ │ ├── regex.h │ │ │ │ ├── stack.h │ │ │ │ ├── strfunc.h │ │ │ │ ├── strtod.h │ │ │ │ └── swap.h │ │ │ ├── istreamwrapper.h │ │ │ ├── memorybuffer.h │ │ │ ├── memorystream.h │ │ │ ├── msinttypes │ │ │ │ ├── inttypes.h │ │ │ │ └── stdint.h │ │ │ ├── ostreamwrapper.h │ │ │ ├── pointer.h │ │ │ ├── prettywriter.h │ │ │ ├── rapidjson.h │ │ │ ├── reader.h │ │ │ ├── schema.h │ │ │ ├── stream.h │ │ │ ├── stringbuffer.h │ │ │ └── writer.h │ │ └── rapidxml │ │ │ ├── license.txt │ │ │ ├── manual.html │ │ │ ├── rapidxml.hpp │ │ │ ├── rapidxml_iterators.hpp │ │ │ ├── rapidxml_print.hpp │ │ │ └── rapidxml_utils.hpp │ │ ├── macros.hpp │ │ ├── specialize.hpp │ │ ├── types │ │ ├── array.hpp │ │ ├── atomic.hpp │ │ ├── base_class.hpp │ │ ├── bitset.hpp │ │ ├── boost_variant.hpp │ │ ├── chrono.hpp │ │ ├── common.hpp │ │ ├── complex.hpp │ │ ├── concepts │ │ │ └── pair_associative_container.hpp │ │ ├── deque.hpp │ │ ├── forward_list.hpp │ │ ├── functional.hpp │ │ ├── list.hpp │ │ ├── map.hpp │ │ ├── memory.hpp │ │ ├── optional.hpp │ │ ├── polymorphic.hpp │ │ ├── queue.hpp │ │ ├── set.hpp │ │ ├── stack.hpp │ │ ├── string.hpp │ │ ├── tuple.hpp │ │ ├── unordered_map.hpp │ │ ├── unordered_set.hpp │ │ ├── utility.hpp │ │ ├── valarray.hpp │ │ ├── variant.hpp │ │ └── vector.hpp │ │ └── version.hpp ├── sandbox │ ├── CMakeLists.txt │ ├── performance.cpp │ ├── sandbox.cpp │ ├── sandbox_json.cpp │ ├── sandbox_rtti.cpp │ ├── sandbox_shared_lib │ │ ├── CMakeLists.txt │ │ ├── base.cpp │ │ ├── base.hpp │ │ ├── derived.cpp │ │ └── derived.hpp │ └── sandbox_vs.cpp ├── scripts │ ├── add_rapidjson_prefix.sh │ ├── appveyor.bat │ ├── renameincludes.sh │ ├── updatecoverage.sh │ └── updatedoc.in └── unittests │ ├── CMakeLists.txt │ ├── array.cpp │ ├── array.hpp │ ├── atomic.cpp │ ├── atomic.hpp │ ├── basic_string.cpp │ ├── basic_string.hpp │ ├── bitset.cpp │ ├── bitset.hpp │ ├── boost │ ├── CMakeLists.txt │ ├── boost_variant.cpp │ └── boost_variant.hpp │ ├── chrono.cpp │ ├── chrono.hpp │ ├── cmake-config-module.cmake │ ├── common.hpp │ ├── complex.cpp │ ├── complex.hpp │ ├── cpp17 │ ├── CMakeLists.txt │ ├── optional.cpp │ ├── optional.hpp │ ├── variant.cpp │ └── variant.hpp │ ├── defer.cpp │ ├── defer.hpp │ ├── deque.cpp │ ├── deque.hpp │ ├── doctest.h │ ├── forward_list.cpp │ ├── forward_list.hpp │ ├── list.cpp │ ├── list.hpp │ ├── load_construct.cpp │ ├── load_construct.hpp │ ├── map.cpp │ ├── map.hpp │ ├── memory.cpp │ ├── memory.hpp │ ├── memory_cycles.cpp │ ├── memory_cycles.hpp │ ├── multimap.cpp │ ├── multimap.hpp │ ├── multiset.cpp │ ├── multiset.hpp │ ├── pair.cpp │ ├── pair.hpp │ ├── pod.cpp │ ├── pod.hpp │ ├── polymorphic.cpp │ ├── polymorphic.hpp │ ├── portability_test.cpp │ ├── portable_binary_archive.cpp │ ├── portable_binary_archive.hpp │ ├── priority_queue.cpp │ ├── priority_queue.hpp │ ├── queue.cpp │ ├── queue.hpp │ ├── run_portability_test.cmake │ ├── run_valgrind.sh │ ├── set.cpp │ ├── set.hpp │ ├── stack.cpp │ ├── stack.hpp │ ├── structs.cpp │ ├── structs.hpp │ ├── structs_minimal.cpp │ ├── structs_minimal.hpp │ ├── structs_specialized.cpp │ ├── structs_specialized.hpp │ ├── tuple.cpp │ ├── tuple.hpp │ ├── unordered_loads.cpp │ ├── unordered_loads.hpp │ ├── unordered_map.cpp │ ├── unordered_map.hpp │ ├── unordered_multimap.cpp │ ├── unordered_multimap.hpp │ ├── unordered_multiset.cpp │ ├── unordered_multiset.hpp │ ├── unordered_set.cpp │ ├── unordered_set.hpp │ ├── user_data_adapters.cpp │ ├── user_data_adapters.hpp │ ├── valarray.cpp │ ├── valarray.hpp │ ├── vector.cpp │ ├── vector.hpp │ ├── versioning.cpp │ └── versioning.hpp └── greenX-6ff8a00 ├── .github └── workflows │ └── action.yml ├── .gitignore ├── CMakeLists.txt ├── Doxyfile ├── GX-AnalyticContinuation ├── CMakeLists.txt └── src │ ├── pade_approximant.f90 │ └── test_pade_approximant.f90 ├── GX-LAPW └── README.md ├── GX-LocalizedBasis └── README.md ├── GX-PAW └── README.md ├── GX-PlaneWaves └── README.md ├── GX-TimeFrequency ├── CMakeLists.txt ├── README.md ├── api │ ├── api_utilities.f90 │ └── gx_minimax.f90 ├── src │ ├── gx_common.h │ ├── minimax_grids.F90 │ ├── minimax_omega.F90 │ ├── minimax_tau.F90 │ └── minimax_utils.F90 ├── test │ ├── conftest.py │ ├── test_gx_minimax_grid.f90 │ ├── test_gx_minimax_grid.py │ └── test_gx_tabulate_minimax.py └── utilities │ └── gx_tabulate_minimax.F90 ├── GX-common ├── CMakeLists.txt └── src │ ├── constants.f90 │ ├── error_handling.f90 │ ├── kinds.f90 │ └── unit_conversion.f90 ├── GX-q=0 └── README.md ├── README.md ├── cmake ├── CompilerFlags.cmake ├── CompilerWarnings.cmake ├── Findzofu.cmake ├── StandardProjectSettings.cmake ├── python3.cmake ├── testFunctions.cmake └── unit_test_functions.cmake ├── developers.md └── python ├── __init__.py ├── pygreenx ├── __init__.py ├── run.py └── utilities.py ├── pyproject.toml ├── setup.cfg └── setup.py /.github/workflows/deploy-ghpages-doc.yml: -------------------------------------------------------------------------------- 1 | name: Documentation 2 | on: push 3 | 4 | jobs: 5 | build: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v4 9 | - uses: actions/setup-python@v4 10 | - name: Install documentation dependencies 11 | run: | 12 | pip3 install -r docs/requirements.txt 13 | pip3 install doxysphinx 14 | sudo apt-get install doxygen -y 15 | - name: Build documentation 16 | run: cd docs && make html 17 | - name: Configure GitHub Pages 18 | uses: actions/configure-pages@v3 19 | - name: Upload artifact 20 | uses: actions/upload-pages-artifact@v1 21 | with: 22 | path: ./docs/_build/html/ 23 | 24 | deploy: 25 | runs-on: ubuntu-latest 26 | # Deploy only when building on the master branch 27 | if: success() && github.ref == 'refs/heads/master' 28 | environment: 29 | name: github-pages 30 | url: ${{ steps.deployment.outputs.page_url }} 31 | needs: build 32 | permissions: 33 | pages: write 34 | id-token: write 35 | steps: 36 | - id: deployment 37 | uses: actions/deploy-pages@v2 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.toptal.com/developers/gitignore/api/cmake,c++ 2 | # Edit at https://www.toptal.com/developers/gitignore?templates=cmake,c++ 3 | 4 | ### C++ ### 5 | # Prerequisites 6 | *.d 7 | 8 | # Compiled Object files 9 | *.slo 10 | *.lo 11 | *.o 12 | *.obj 13 | 14 | # Precompiled Headers 15 | *.gch 16 | *.pch 17 | 18 | # Compiled Dynamic libraries 19 | *.so 20 | *.dylib 21 | *.dll 22 | 23 | # Fortran module files 24 | *.mod 25 | *.smod 26 | 27 | # Compiled Static libraries 28 | *.lai 29 | *.la 30 | *.a 31 | *.lib 32 | 33 | # Executables 34 | *.exe 35 | *.out 36 | *.app 37 | 38 | ### CMake ### 39 | CMakeLists.txt.user 40 | CMakeCache.txt 41 | CMakeFiles 42 | CMakeScripts 43 | Testing 44 | Makefile 45 | cmake_install.cmake 46 | install_manifest.txt 47 | compile_commands.json 48 | CTestTestfile.cmake 49 | _deps 50 | 51 | ### CMake Patch ### 52 | # External projects 53 | *-prefix/ 54 | 55 | # End of https://www.toptal.com/developers/gitignore/api/cmake,c++ 56 | 57 | *.pyc 58 | __pycache__ 59 | local_*_points.dat 60 | *_time2freq_grid_*.txt 61 | *_freq2time_grid_*.txt 62 | 63 | # cmake build directories 64 | build*/ 65 | 66 | # Necessary makefiles 67 | # !src/Makefile 68 | # !tests/Makefile 69 | 70 | .cache 71 | 72 | # environment config 73 | .envrc 74 | .clangd 75 | # personal build script 76 | mybuild*.sh 77 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "thirdparty/LibComm"] 2 | path = thirdparty/LibComm 3 | url = https://github.com/abacusmodeling/LibComm 4 | [submodule "thirdparty/LibRI"] 5 | path = thirdparty/LibRI 6 | url = https://github.com/abacusmodeling/LibRI 7 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "iostream": "cpp", 4 | "*.tcc": "cpp", 5 | "bitset": "cpp", 6 | "complex": "cpp", 7 | "iomanip": "cpp", 8 | "istream": "cpp", 9 | "ostream": "cpp", 10 | "thread": "cpp", 11 | "array": "cpp", 12 | "atomic": "cpp", 13 | "cctype": "cpp", 14 | "chrono": "cpp", 15 | "clocale": "cpp", 16 | "cmath": "cpp", 17 | "cstdarg": "cpp", 18 | "cstdint": "cpp", 19 | "cstdio": "cpp", 20 | "cstdlib": "cpp", 21 | "cstring": "cpp", 22 | "ctime": "cpp", 23 | "cwchar": "cpp", 24 | "cwctype": "cpp", 25 | "deque": "cpp", 26 | "unordered_map": "cpp", 27 | "vector": "cpp", 28 | "exception": "cpp", 29 | "fstream": "cpp", 30 | "functional": "cpp", 31 | "initializer_list": "cpp", 32 | "iosfwd": "cpp", 33 | "limits": "cpp", 34 | "new": "cpp", 35 | "numeric": "cpp", 36 | "ratio": "cpp", 37 | "sstream": "cpp", 38 | "stdexcept": "cpp", 39 | "streambuf": "cpp", 40 | "regex": "cpp", 41 | "tuple": "cpp", 42 | "type_traits": "cpp", 43 | "utility": "cpp", 44 | "typeinfo": "cpp" 45 | } 46 | } -------------------------------------------------------------------------------- /binding/fortran/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (BUILD_LIBRPA_SHARED) 2 | add_library(rpa_f_lib SHARED) 3 | else() 4 | add_library(rpa_f_lib STATIC) 5 | endif() 6 | 7 | set_target_properties(rpa_f_lib PROPERTIES 8 | OUTPUT_NAME ${FORTRAN_LIB_NAME} 9 | VERSION ${CMAKE_PROJECT_VERSION} 10 | SOVERSION ${CMAKE_PROJECT_VERSION} 11 | ) 12 | 13 | target_sources(rpa_f_lib 14 | PRIVATE 15 | librpa_f.f90 16 | ) 17 | target_link_libraries(rpa_f_lib PRIVATE rpa_lib) 18 | 19 | install(TARGETS rpa_f_lib 20 | ARCHIVE 21 | DESTINATION ${CMAKE_INSTALL_LIBDIR}) 22 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/librpa_f.mod 23 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 24 | -------------------------------------------------------------------------------- /cmake.inc: -------------------------------------------------------------------------------- 1 | # Basic C++ compiler setup 2 | # set(CMAKE_C_COMPILER "mpiicc" CACHE STRING "" FORCE) 3 | set(CMAKE_CXX_COMPILER "mpiicpc" CACHE STRING "" FORCE) 4 | set(CMAKE_Fortran_COMPILER "ifort" CACHE STRING "" FORCE) 5 | 6 | set(CMAKE_CXX_FLAGS "-g -O2 -fopenmp" CACHE STRING "" FORCE) 7 | if(DEBUG) 8 | set(CMAKE_CXX_FLAGS "-g -O0 -Wall -fopenmp" CACHE STRING "" FORCE) 9 | endif() 10 | 11 | 12 | # set(LAPACK_LIBRARIES "-L$ENV{MKLROOT}/lib/intel64 -lmkl_intel_lp64 -lmkl_sequential -lmkl_core") 13 | set(LAPACK_LIBRARIES "-L$ENV{MKLROOT}/lib/intel64 -lmkl_scalapack_lp64 -lmkl_intel_lp64 -lmkl_core -lmkl_intel_thread -lmkl_blacs_intelmpi_lp64 -lpthread -lm -ldl") 14 | 15 | # whether to use LibRI for tensor contraction 16 | # set(USE_LIBRI ON) 17 | -------------------------------------------------------------------------------- /cmake/FindCereal.cmake: -------------------------------------------------------------------------------- 1 | # Find Cereal headers 2 | # Adapted from the ABACUS FindCereal module and cmake cookbook ch03-r10 3 | # 4 | # Variables 5 | # CEREAL_INCLUDE_DIR - specify the path by -DCEREAL_INCLUDE_DIR to search the cereal headers 6 | # 7 | # Returns 8 | # Cereal_FOUND - True if cereal is found. 9 | # Cereal_INCLUDE_DIR - Where to find cereal headers. 10 | 11 | find_path(Cereal_INCLUDE_DIR 12 | cereal/cereal.hpp 13 | HINTS ${CEREAL_INCLUDE_DIR} 14 | ) 15 | 16 | # Disable auto download. Handle CEREAL_FOUND instead 17 | # if(NOT Cereal_INCLUDE_DIR) 18 | # include(FetchContent) 19 | # FetchContent_Declare( 20 | # cereal 21 | # GIT_REPOSITORY https://github.com.cnpmjs.org/USCiLab/cereal.git 22 | # # URL https://github.com/USCiLab/cereal/archive/refs/tags/v1.3.0.tar.gz 23 | # ) 24 | # set(Cereal_INCLUDE_DIR ${cereal_SOURCE_DIR}) 25 | # endif() 26 | 27 | # Handle the QUIET and REQUIRED arguments and 28 | # set Cereal_FOUND to TRUE if all variables are non-zero. 29 | include(FindPackageHandleStandardArgs) 30 | find_package_handle_standard_args(Cereal 31 | FOUND_VAR 32 | Cereal_FOUND 33 | REQUIRED_VARS 34 | Cereal_INCLUDE_DIR 35 | ) 36 | 37 | # Copy the results to the output variables and target. 38 | # mark_as_advanced(Cereal_INCLUDE_DIR) 39 | -------------------------------------------------------------------------------- /cmake/FindLibComm.cmake: -------------------------------------------------------------------------------- 1 | # Find LibComm headers 2 | 3 | # Variables 4 | # LIBCOMM_INCLUDE_DIR - specify the path by -DLIBCOMM_INCLUDE_DIR to search the LibComm headers 5 | # 6 | # Returns 7 | # LibComm_FOUND - True if LibComm is found 8 | # LibComm_INCLUDE_DIR - Where to find the LibComm headers 9 | 10 | find_path(LibComm_INCLUDE_DIR 11 | Comm/Comm_Tools.h 12 | HINTS ${LIBCOMM_INCLUDE_DIR} 13 | ) 14 | 15 | include(FindPackageHandleStandardArgs) 16 | find_package_handle_standard_args(LibComm 17 | FOUND_VAR 18 | LibComm_FOUND 19 | REQUIRED_VARS 20 | LibComm_INCLUDE_DIR 21 | ) 22 | -------------------------------------------------------------------------------- /cmake/FindLibRI.cmake: -------------------------------------------------------------------------------- 1 | # Find LibRI headers 2 | 3 | # Variables 4 | # LIBRI_INCLUDE_DIR - specify the path by either environment varaible or -DLIBRI_INCLUDE_DIR to search the cereal headers 5 | # 6 | # LibRI_FOUND - True if LibRI is found 7 | # LibRI_INCLUDE_DIR - Where to find the LibRI headers 8 | find_path(LibRI_INCLUDE_DIR 9 | RI/ri/RI_Tools.h 10 | HINTS ${LIBRI_INCLUDE_DIR} 11 | ) 12 | 13 | include(FindPackageHandleStandardArgs) 14 | find_package_handle_standard_args(LibRI 15 | FOUND_VAR 16 | LibRI_FOUND 17 | REQUIRED_VARS 18 | LibRI_INCLUDE_DIR 19 | ) 20 | -------------------------------------------------------------------------------- /cmake/FindScaLAPACK.cmake: -------------------------------------------------------------------------------- 1 | # - Find ScaLAPACK 2 | # Find the native double precision ScaLAPACK headers and libraries. 3 | # 4 | # ScaLAPACK_LIBRARIES - List of libraries when using ScaLAPACK. 5 | # ScaLAPACK_FOUND - True if ScaLAPACK is found. 6 | # 7 | 8 | find_library(ScaLAPACK_LIBRARY 9 | NAMES scalapack scalapack-openmpi 10 | HINTS ${SCALAPACK_DIR} 11 | PATH_SUFFIXES "lib" 12 | ) 13 | 14 | # Handle the QUIET and REQUIRED arguments and 15 | # set ScaLAPACK_FOUND to TRUE if all variables are non-zero. 16 | include(FindPackageHandleStandardArgs) 17 | find_package_handle_standard_args(ScaLAPACK DEFAULT_MSG ScaLAPACK_LIBRARY) 18 | 19 | # Copy the results to the output variables and target. 20 | if(ScaLAPACK_FOUND) 21 | set(ScaLAPACK_LIBRARIES ${ScaLAPACK_LIBRARY}) 22 | 23 | if(NOT TARGET ScaLAPACK::ScaLAPACK) 24 | add_library(ScaLAPACK::ScaLAPACK UNKNOWN IMPORTED) 25 | set_target_properties(ScaLAPACK::ScaLAPACK PROPERTIES 26 | IMPORTED_LINK_INTERFACE_LANGUAGES "C" 27 | IMPORTED_LOCATION "${ScaLAPACK_LIBRARY}") 28 | endif() 29 | endif() 30 | 31 | mark_as_advanced(ScaLAPACK_LIBRARY) 32 | -------------------------------------------------------------------------------- /cmake/UseDoxygenDoc.cmake: -------------------------------------------------------------------------------- 1 | # from https://raw.githubusercontent.com/dev-cafe/cmake-cookbook/master/chapter-12/recipe-01/cxx-example/cmake/UseDoxygenDoc.cmake 2 | # find_package(Perl REQUIRED) 3 | find_package(Doxygen REQUIRED) 4 | 5 | function(add_doxygen_doc) 6 | set(options) 7 | set(oneValueArgs BUILD_DIR DOXY_FILE TARGET_NAME COMMENT) 8 | set(multiValueArgs) 9 | 10 | cmake_parse_arguments(DOXY_DOC 11 | "${options}" 12 | "${oneValueArgs}" 13 | "${multiValueArgs}" 14 | ${ARGN} 15 | ) 16 | 17 | configure_file( 18 | ${DOXY_DOC_DOXY_FILE} 19 | ${DOXY_DOC_BUILD_DIR}/Doxyfile 20 | @ONLY 21 | ) 22 | 23 | add_custom_target(${DOXY_DOC_TARGET_NAME} 24 | COMMAND 25 | ${DOXYGEN_EXECUTABLE} Doxyfile 26 | WORKING_DIRECTORY 27 | ${DOXY_DOC_BUILD_DIR} 28 | COMMENT 29 | "Building ${DOXY_DOC_COMMENT} with Doxygen" 30 | VERBATIM 31 | ) 32 | 33 | message(STATUS "Added ${DOXY_DOC_TARGET_NAME} [Doxygen] target to build documentation") 34 | endfunction() 35 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | doxygen/Doxyfile 3 | !doxygen/Makefile 4 | doxygen/doxygen-awesome-css* 5 | doxygen/librpa 6 | !Makefile 7 | -------------------------------------------------------------------------------- /docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(doxygen) 2 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # Variables for this project 3 | DOXY_SOURCE = doxygen 4 | DOXY_BUILDDIR = $(DOXY_SOURCE)/$(shell awk '/OUTPUT_DIRECTORY/ {print $$3}' $(DOXY_SOURCE)/Doxyfile) 5 | 6 | # You can set these variables from the command line, and also 7 | # from the environment for the first two. 8 | SPHINXOPTS ?= 9 | SPHINXBUILD ?= sphinx-build 10 | DOXYSPHINX = doxysphinx 11 | SOURCEDIR = . 12 | BUILDDIR = _build 13 | 14 | # Targets 15 | .PHONY: html help clean doxygen doxysphinx 16 | 17 | html: doxygen doxysphinx sphinx 18 | 19 | sphinx: 20 | @$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) 21 | 22 | doxygen: 23 | @cd $(DOXY_SOURCE) && $(MAKE) 24 | 25 | doxysphinx: 26 | @doxysphinx build $(SOURCEDIR) $(BUILDDIR)/html $(DOXY_SOURCE)/Doxyfile --doxygen_cwd $(DOXY_SOURCE)/ 27 | 28 | # Put it first so that "make" without argument is like "make help". 29 | help: 30 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) 31 | 32 | clean: 33 | rm -rf $(BUILDDIR) 34 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Documentation of LibRPA 2 | 3 | The documentation is built using Doxygen and Sphinx. 4 | Doxygen configuration file is `doxygen/Doxyfile`, generated from `doxygen/Doxyfile.in`. 5 | 6 | To build, 7 | - first make sure that `make` and `doxygen` is available. 8 | - then install the necessary Python packages mentioned in the `requirements.txt` file using some package manager. 9 | - finally issue `make html` 10 | -------------------------------------------------------------------------------- /docs/assets/abacus_interface.drawio.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Srlive1201/LibRPA/4676a0d845024e73aa6e92f4aca843a2bbb4c847/docs/assets/abacus_interface.drawio.jpg -------------------------------------------------------------------------------- /docs/assets/aims_interface.drawio.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Srlive1201/LibRPA/4676a0d845024e73aa6e92f4aca843a2bbb4c847/docs/assets/aims_interface.drawio.jpg -------------------------------------------------------------------------------- /docs/assets/librpa_flowchat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Srlive1201/LibRPA/4676a0d845024e73aa6e92f4aca843a2bbb4c847/docs/assets/librpa_flowchat.jpg -------------------------------------------------------------------------------- /docs/develop/design.md: -------------------------------------------------------------------------------- 1 | # Code Design 2 | 3 | LibRPA is designed to provide efficient and scalable implementations of various beyond-DFT methods, including but not limited to random-phase approximation (RPA) correlation energies. The library is developed in C++ and Python, utilizing a hybrid parallelism model with MPI and OpenMP to maximize performance on modern high-performance computing systems. 4 | 5 | ## Framework of RPA calculation 6 | 7 | ![Framework of RPA calculation](../assets/librpa_flowchat.jpg) 8 | 9 | ## RPA interface to FHI-aims 10 | 11 | ![RPA interface to FHI-aims](../assets/aims_interface.drawio.jpg) 12 | 13 | ## RPA interface to ABACUS 14 | 15 | ![RPA interface to ABACUS](../assets/abacus_interface.drawio.jpg) 16 | 17 | ## TODO 18 | 19 | - [ ] Adapt RPA force work by Mohammad in the [backup branch](https://github.com/Srlive1201/LibRPA/tree/master-backup-240416) 20 | -------------------------------------------------------------------------------- /docs/develop/documentation.md: -------------------------------------------------------------------------------- 1 | # Documentation 2 | 3 | ## Overview 4 | 5 | LibRPA uses [Sphinx](https://www.sphinx-doc.org/en/master/) toolchain to build its user documentation. 6 | C++ API documentation is generated using [Doxygen](https://www.doxygen.nl) 7 | and connected to Sphinx using [Doxysphinx](https://github.com/boschglobal/doxysphinx) 8 | and [doxylink](https://sphinxcontrib-doxylink.readthedocs.io/en/stable/). 9 | We also use the following packages to make the writing easier and prettify the documentation 10 | 11 | - [Sphinx RTD theme](https://github.com/readthedocs/sphinx_rtd_theme) 12 | - [Sphinx design](https://github.com/executablebooks/sphinx-design) 13 | - [Sphinx copy-button](https://github.com/executablebooks/sphinx-copybutton) 14 | - [MyST parser](https://github.com/executablebooks/MyST-Parser) 15 | - [Doxygen Awesome](https://jothepro.github.io/doxygen-awesome-css/) 16 | 17 | ## Build 18 | 19 | To build the documentation, the mentioned prerequisites can be installed from PyPi 20 | ```shell 21 | pip3 install -r docs/requirements.txt 22 | pip3 install doxysphinx 23 | ``` 24 | or using conda 25 | ```shell 26 | conda install -c conda-forge --file docs/requirements.txt 27 | # unfortunately doxysphinx can only be installed from pypi 28 | pip3 install doxysphinx 29 | ``` 30 | It is recommened to create a dedivated virtual environment to install the packages. 31 | 32 | After successful install of the prerequisites, the document can be built by issuing 33 | the following `make` command under `docs` directory. 34 | ```shell 35 | make html 36 | # or simply 37 | make 38 | ``` 39 | This will download the required style sheet and run the toolchain. 40 | The generated (HTML) documentation is under `_build/html` directory. 41 | You can preview the documentation by opening `_build/html/index.html` using any 42 | web browser. 43 | -------------------------------------------------------------------------------- /docs/doxygen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_doxygen_doc( 2 | BUILD_DIR 3 | ${CMAKE_CURRENT_BINARY_DIR}/_build_doxygen 4 | DOXY_FILE 5 | ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in 6 | TARGET_NAME 7 | docs 8 | COMMENT 9 | "Doxygen HTML documentation" 10 | ) 11 | -------------------------------------------------------------------------------- /docs/doxygen/Makefile: -------------------------------------------------------------------------------- 1 | DOXYFILE_TEMPLATE = Doxyfile.in 2 | DOXYFILE = Doxyfile 3 | DOXY_OUTPUT_DIRECTORY = librpa 4 | HTML_OUTPUT = html 5 | DOT_PATH = $(shell which dot) 6 | 7 | DOXYGEN_AWESOME_VERSION = 2.3.3 8 | DOXYGEN_AWESOME_DIRECTORY = doxygen-awesome-css 9 | 10 | .PHONY: default clean 11 | 12 | # CAIRO_DEBUG_PDF=1 is a workaround to fix the 13 | # "Failed to extract bounding box from generated diagram file" 14 | # error before doxygen 1.9.7. 15 | # For details please see https://github.com/doxygen/doxygen/issues/9319 16 | default: $(DOXYFILE) $(DOXYGEN_AWESOME_DIRECTORY)/doxygen-awesome.css 17 | CAIRO_DEBUG_PDF="1" doxygen $< 18 | 19 | $(DOXYFILE): $(DOXYFILE_TEMPLATE) Makefile 20 | sed -e "s|\(OUTPUT_DIRECTORY *=\) *.*|\1 $(DOXY_OUTPUT_DIRECTORY)|g" \ 21 | -e "s|\(INPUT *=\) *.*|\1 README.md ../../src ../../driver|g" \ 22 | -e "s|\(GENERATE_TAGFILE *=\) *.*|\1 $(DOXY_OUTPUT_DIRECTORY)/$(HTML_OUTPUT)/tagfile.xml|g" \ 23 | -e "s|\(DOT_PATH *=\) *.*|\1 $(DOT_PATH)|g" $< > $@ 24 | 25 | 26 | # https://github.com/boschglobal/doxysphinx/blob/main/external/get_doxygen_awesome.sh 27 | $(DOXYGEN_AWESOME_DIRECTORY)/doxygen-awesome.css: 28 | mkdir -p $(DOXYGEN_AWESOME_DIRECTORY) 29 | curl -sSL https://github.com/jothepro/doxygen-awesome-css/archive/refs/tags/v$(DOXYGEN_AWESOME_VERSION).tar.gz \ 30 | | tar -xzvf - --strip-components=1 -C $(DOXYGEN_AWESOME_DIRECTORY) \ 31 | doxygen-awesome-css-$(DOXYGEN_AWESOME_VERSION)/doxygen-awesome.css doxygen-awesome-css-$(DOXYGEN_AWESOME_VERSION)/LICENSE 32 | 33 | clean: 34 | rm -rf $(DOXYFILE) 35 | 36 | veryclean: clean 37 | rm -rf $(DOXY_OUTPUT_DIRECTORY) 38 | -------------------------------------------------------------------------------- /docs/doxygen/README.md: -------------------------------------------------------------------------------- 1 | # LibRPA 2 | 3 | This is API documentation of LibRPA, generated by [doxygen](https://www.doxygen.nl). 4 | The HTML version is rendered using [Doxygen Awesome](https://jothepro.github.io/doxygen-awesome-css) stylesheet. 5 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | sphinx 2 | # sphinx-book-theme 3 | sphinx-design 4 | sphinx-copybutton 5 | # Linking to Doxygen API documentation 6 | sphinxcontrib-doxylink 7 | myst-parser 8 | sphinx_rtd_theme 9 | # doxyphinx is not available on conda, use pip to install 10 | # doxysphinx 11 | -------------------------------------------------------------------------------- /docs/tutorial/gw/gw_driver_aims.md: -------------------------------------------------------------------------------- 1 | # Using LibRPA driver with FHI-aims dataset 2 | 3 | Under construction. 4 | 5 | -------------------------------------------------------------------------------- /docs/tutorial/gw/index.md: -------------------------------------------------------------------------------- 1 | # One-shot *GW* 2 | 3 | ```{toctree} 4 | :maxdepth: 1 5 | 6 | Driver with FHI-aims 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/tutorial/rpa/index.md: -------------------------------------------------------------------------------- 1 | # RPA correlation energy 2 | 3 | ```{toctree} 4 | :maxdepth: 1 5 | 6 | Driver with FHI-aims 7 | ``` 8 | -------------------------------------------------------------------------------- /docs/user_guide/input_parameters.md: -------------------------------------------------------------------------------- 1 | # Input Parameters 2 | 3 | For Driver Usage, you can create a file named `librpa.in` in your working directory and input the parameter settings as follows: 4 | 5 | ``` 6 | task = rpa 7 | nfreq = 16 8 | gf_R_threshold = 1e-4 9 | ``` 10 | If `librpa.in` or the related keyword is not found, the default value will be used. 11 | 12 | ## Common Parameter Settings for LibRPA 13 | 14 | | Parameter Name | Description | Type | Default Value (Options) | 15 | |------------------------|-----------------------------------------------------------------------|--------|------------------------------| 16 | | `task` | Task type | string | rpa (rpa, g0w0, exx) | 17 | | `tfgrid_type` | Type of time-frequency integration grid | string | minimax (minimax) | 18 | | `nfreq` | Number of frequency integration grid points | int | 6 | 19 | | `gf_R_threshold` | Real-space Green's function screening threshold for response function | double | 1e-3 | 20 | | `cs_threshold` | Auxiliary basis coefficient tensor screening threshold | double | 1e-4 | 21 | | `parallel_routing` | Parallel scheme of LibRPA | string | auto (atompair, rtau, libri) | 22 | | `use_scalapack_ecrpa` | Flag to use ScaLapack for calculating $E_\text{c}^{\text{RPA}}$ | bool | true | 23 | | `debug` | Flag to enable debug mode | bool | false | 24 | 25 | For details on all parameters, you can visit the API documentation of struct {librpa}`LibRPAParams`. 26 | -------------------------------------------------------------------------------- /driver/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(rpa_exe) 2 | set_target_properties(rpa_exe PROPERTIES 3 | OUTPUT_NAME ${DRIVER_NAME} 4 | ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} 5 | LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} 6 | RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) 7 | 8 | list(APPEND exe_sources 9 | main.cpp 10 | read_data.cpp 11 | write_aims.cpp 12 | inputfile.cpp 13 | task_rpa.cpp 14 | task_exx.cpp 15 | ) 16 | 17 | target_include_directories(rpa_exe 18 | PUBLIC 19 | ${PROJECT_SOURCE_DIR}/src 20 | ) 21 | 22 | target_sources(rpa_exe PRIVATE ${exe_sources}) 23 | if(USE_LIBRI) 24 | target_include_directories(rpa_exe 25 | PRIVATE 26 | ${Cereal_INCLUDE_DIR} 27 | ${LibComm_INCLUDE_DIR} 28 | ${LibRI_INCLUDE_DIR} 29 | ) 30 | endif() 31 | 32 | target_link_libraries(rpa_exe PRIVATE rpa_lib ${math_libs} ${parallel_libs}) 33 | 34 | install(TARGETS rpa_exe DESTINATION ${CMAKE_INSTALL_BINDIR}) 35 | -------------------------------------------------------------------------------- /driver/read_data.h: -------------------------------------------------------------------------------- 1 | //! Functions to parse files generated by FHI-aims 2 | /* 3 | */ 4 | #ifndef READ_DATA_H 5 | #define READ_DATA_H 6 | 7 | #include 8 | 9 | #include "matrix.h" 10 | #include "meanfield.h" 11 | #include "ri.h" 12 | #include "vector3_order.h" 13 | 14 | using std::string; 15 | 16 | void read_band(const string &file_path, MeanField &mf); 17 | 18 | /*! 19 | * @brief Read exchange-correlation potential 20 | * 21 | * @param[in] file_path data file path 22 | * @return status code, 0 for succesful read, 1 with error 23 | */ 24 | int read_vxc(const string &file_path, std::vector &vxc); 25 | 26 | void read_eigenvector(const string &dir_path, MeanField &mf); 27 | 28 | size_t read_Cs(const string &dir_path, double threshold, const vector &local_atpair, 29 | bool binary = false); 30 | 31 | size_t read_Cs_evenly_distribute(const string &dir_path, double threshold, int myid, int nprocs, 32 | bool binary = false); 33 | 34 | size_t read_Vq_full(const string &dir_path, const string &vq_fprefix, bool is_cut_coulomb); 35 | 36 | size_t read_Vq_row(const string &dir_path, const string &vq_fprefix, double threshold, 37 | const vector &local_atpair, bool is_cut_coulomb); 38 | 39 | void read_stru(const int& n_kpoints, const std::string &file_path); 40 | 41 | void read_dielec_func(const string &file_path, std::vector &omegas, 42 | std::vector &dielec_func_imagfreq); 43 | 44 | void erase_Cs_from_local_atp(atpair_R_mat_t &Cs, vector &local_atpair); 45 | 46 | void get_natom_ncell_from_first_Cs_file(int &n_atom, int &n_cell, const string &dir_path, bool binary = false); 47 | 48 | #endif // !READ_DATA_H 49 | -------------------------------------------------------------------------------- /driver/task_exx.cpp: -------------------------------------------------------------------------------- 1 | #include "task_exx.h" 2 | 3 | // other driver headers 4 | #include "read_data.h" 5 | 6 | // src headers 7 | #include "app_exx.h" 8 | #include "constants.h" 9 | #include "meanfield.h" 10 | #include "envs_mpi.h" 11 | #include "utils_io.h" 12 | #include "pbc.h" 13 | 14 | // debug headers 15 | // #include "stl_io_helper.h" 16 | 17 | void task_exx() 18 | { 19 | using LIBRPA::envs::mpi_comm_global_h; 20 | using LIBRPA::utils::lib_printf; 21 | 22 | // Load the cut coulomb data 23 | read_Vq_full("./", "coulomb_cut_", true); 24 | 25 | // NOTE: since the internal object does not support parallel calculation with different k-points on each process 26 | // we compute all and only let master process print 27 | const int i_state_low = 0; 28 | const int n_kpoints = meanfield.get_n_kpoints(); 29 | const int i_state_high = meanfield.get_n_bands(); 30 | const int n_states_calc = i_state_high - i_state_low; 31 | 32 | auto exx_ks = LIBRPA::app::compute_exx_orbital_energy_(i_state_low, i_state_high, -1, nullptr); 33 | 34 | if (exx_ks.size() > 0 && mpi_comm_global_h.is_root()) 35 | { 36 | for (int isp = 0; isp != meanfield.get_n_spins(); isp++) 37 | { 38 | lib_printf("Spin channel %1d\n", isp+1); 39 | for (int ik = 0; ik != meanfield.get_n_kpoints(); ik++) 40 | { 41 | cout << "k-point " << ik + 1 << ": " << kfrac_list[ik] << endl; 42 | lib_printf("%-4s %-10s %-10s\n", "Band", "e_exx (Ha)", "e_exx (eV)"); 43 | for (int ib = i_state_low; ib != i_state_high; ib++) 44 | { 45 | const int index = isp * n_kpoints * n_states_calc + ik * n_states_calc + ib - i_state_low; 46 | const auto e = exx_ks[index]; 47 | lib_printf("%4d %10.5f %10.5f\n", ib + 1, e, HA2EV * e); 48 | } 49 | lib_printf("\n"); 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /driver/task_exx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void task_exx(); 4 | -------------------------------------------------------------------------------- /driver/task_rpa.cpp: -------------------------------------------------------------------------------- 1 | #include "task_rpa.h" 2 | 3 | #include "librpa.h" 4 | #include "app_rpa.h" 5 | #include "envs_mpi.h" 6 | #include "ri.h" 7 | 8 | void task_rpa() 9 | { 10 | using LIBRPA::envs::mpi_comm_global_h; 11 | using LIBRPA::utils::lib_printf; 12 | 13 | // Using public API. 14 | // std::vector temp_corr(2); 15 | // std::vector temp_corr_irk(2 * n_irk_points); 16 | // get_rpa_correlation_energy(temp_corr.data(), temp_corr_irk.data()); 17 | // std::complex corr(temp_corr[0], temp_corr[1]); 18 | // auto dp = reinterpret_cast*>(temp_corr_irk.data()); 19 | // std::vector> corr_irk(dp, dp + n_irk_points); 20 | 21 | // Using the internal work function, avoid copying between vector and double* 22 | std::complex corr; 23 | std::vector> corr_irk(n_irk_points); 24 | 25 | LIBRPA::app::get_rpa_correlation_energy_(corr, corr_irk); 26 | 27 | if (mpi_comm_global_h.is_root()) 28 | { 29 | lib_printf("RPA correlation energy (Hartree)\n"); 30 | lib_printf("| Weighted contribution from each k:\n"); 31 | 32 | for (int i_irk = 0; i_irk < n_irk_points; i_irk++) 33 | { 34 | cout << "| " << irk_points[i_irk] << ": " << corr_irk[i_irk] << endl; 35 | } 36 | lib_printf("| Total EcRPA: %18.9f\n", corr.real()); 37 | if (std::abs(corr.imag()) > 1.e-3) 38 | lib_printf("Warning: considerable imaginary part of EcRPA = %f\n", corr.imag()); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /driver/task_rpa.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void task_rpa(); 4 | -------------------------------------------------------------------------------- /driver/write_aims.cpp: -------------------------------------------------------------------------------- 1 | #include "write_aims.h" 2 | 3 | #include "gw.h" 4 | 5 | #include 6 | #include 7 | 8 | void write_self_energy_omega(const char *fn, const LIBRPA::G0W0 &s_g0w0) 9 | { 10 | const auto &n_spins = s_g0w0.mf.get_n_spins(); 11 | const auto &n_kpts = s_g0w0.mf.get_n_kpoints(); 12 | const auto &n_bands = s_g0w0.mf.get_n_bands(); 13 | const auto &freqs = s_g0w0.tfg.get_freq_nodes(); 14 | std::ofstream ofs; 15 | ofs.open(fn); 16 | ofs << freqs.size() << " " 17 | << n_spins << " " 18 | << n_kpts << " " 19 | << n_bands << "\n"; 20 | for (const auto& freq: freqs) 21 | { 22 | ofs << fixed << setprecision(12) << freq << "\n"; 23 | } 24 | 25 | for (int ispin = 0; ispin != n_spins; ispin++) 26 | { 27 | for (int ik = 0; ik != n_kpts; ik++) 28 | { 29 | for (int ib = 0; ib != n_bands; ib++) 30 | { 31 | for (const auto& freq: freqs) 32 | { 33 | const auto sigc = s_g0w0.sigc_is_ik_f_KS.at(ispin).at(ik).at(freq)(ib, ib); 34 | char s[100]; 35 | sprintf(s, "%23.16f%23.16f", sigc.real(), sigc.imag()); 36 | // ofs << fixed << setw(23) << setprecision(16) << sigc.real() << setw(23) << setprecision(16) << sigc.imag() << "\n"; 37 | ofs << s << "\n"; 38 | } 39 | } 40 | } 41 | } 42 | ofs.close(); 43 | } 44 | -------------------------------------------------------------------------------- /driver/write_aims.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace LIBRPA 4 | { 5 | class G0W0; 6 | } 7 | 8 | void write_self_energy_omega(const char *fn, const LIBRPA::G0W0& s_g0w0); 9 | -------------------------------------------------------------------------------- /platforms/linux_intel_classic_general.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script uses Intel classic compilers, Intel MPI and MKL to build LibRPA 4 | # on Linux platform for develop and production use. Tested on Ubuntu, CentOS and SUSE. 5 | 6 | # Intel compilers icpc (C++) and ifort (Fortran) needs to be found under directories 7 | # in environment variable PATH, as well as the C++ MPI wrapper mpiicpc. 8 | # Note that Fortran is used only when USE_GREENX_API or ENABLE_FORTRAN_BIND is on. 9 | # Intel MKL will be used as the working math library. 10 | 11 | BUILDDIR="${BUILDDIR:=build_intel_classic_mkl}" 12 | 13 | # # Ensure environment variables are correctly set. 14 | # # On PC, they can be set by sourcing setup script provided by the vendor. 15 | # # For oneAPI: 16 | # source /opt/intel/oneapi/setvars.sh 17 | # # For old Intel versions 18 | # source /opt/intel/compilers_and_libraries_2020.4.304/linux/bin/compilervars.sh intel64 19 | 20 | # # On HPC, usually environment modules are provided. 21 | # # Examples: 22 | # # MPCDF platforms, oneAPI 2023 23 | # module load intel/2023.1.0.x impi/2021.9 mkl/2023.1 24 | 25 | # # MPCDF platforms, Intel 2020 update 4 26 | # module load intel/19.1.3 impi/2019.9 mkl/2020.4 27 | 28 | # # Or you might set it manually, which is not recommended. 29 | 30 | # The GreenX API is switched on. In this case, the Fortran compiler needs to be configured. 31 | export CXX=mpiicpc 32 | export FC=ifort 33 | 34 | cmake -B $BUILDDIR -DENABLE_TEST=ON -DUSE_LIBRI=OFF -DUSE_GREENX_API=ON 35 | cd $BUILDDIR && make -j 4 36 | -------------------------------------------------------------------------------- /platforms/linux_intel_llvm_general.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script uses Intel LLVM-based compilers, Intel MPI and MKL to build LibRPA 4 | # on Linux platform for develop and production use. Tested on Ubuntu and SUSE. 5 | 6 | # Intel compilers icpx (C++) and ifx (Fortran) needs to be found under directories 7 | # in environment variable PATH, as well as the C++ MPI wrapper mpiicpx. 8 | # Note that Fortran is used only when USE_GREENX_API or ENABLE_FORTRAN_BIND is on. 9 | # Intel MKL will be used as the working math library. 10 | 11 | BUILDDIR="${BUILDDIR:=build_intel_llvm_mkl}" 12 | 13 | # # Ensure environment variables are correctly set. 14 | # # On PC, they can be set by sourcing setup script provided by the vendor. 15 | # # As LLVM-based compilers are only provided in oneAPI toolchain, this can be done by: 16 | # source /opt/intel/oneapi/setvars.sh 17 | 18 | # # On HPC, usually environment modules are provided: 19 | # module load intel/2023.1.0.x impi/2021.9 mkl/2023.1 20 | 21 | # # Or you might set it manually, which is not recommended. 22 | 23 | # The GreenX API is switched on. In this case, the Fortran compiler needs to be configured. 24 | export CXX=mpiicpx 25 | export FC=ifx 26 | 27 | cmake -B $BUILDDIR -DENABLE_TEST=ON -DUSE_LIBRI=OFF -DUSE_GREENX_API=ON 28 | cd $BUILDDIR && make -j 4 29 | -------------------------------------------------------------------------------- /platforms/linux_intel_llvm_libri.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script uses Intel LLVM-based compilers, Intel MPI and MKL to build LibRPA 4 | # with LibRI support on Linux platform for develop and production use. 5 | 6 | # Intel compilers icpx (C++) and ifx (Fortran) needs to be found under directories 7 | # in environment variable PATH, as well as the C++ MPI wrapper mpiicpx. 8 | # Note that Fortran is used only when USE_GREENX_API or ENABLE_FORTRAN_BIND is on. 9 | # Intel MKL will be used as the working math library. 10 | 11 | BUILDDIR="${BUILDDIR:=build_intel_llvm_libri}" 12 | 13 | # # Ensure environment variables are correctly set. 14 | # # On PC, they can be set by sourcing setup script provided by the vendor. 15 | # # As LLVM-based compilers are only provided in oneAPI toolchain, this can be done by: 16 | # source /opt/intel/oneapi/setvars.sh 17 | 18 | # # On HPC, usually environment modules are provided: 19 | # module load intel/2023.1.0.x impi/2021.9 mkl/2023.1 20 | 21 | # # Or you might set it manually, which is not recommended. 22 | 23 | # Optionally, one can specify the path of their own LibRI and LibComm libraries. 24 | # If not set, those under thirdparty/ will be used. 25 | # Since they are hosted as git submodule, you may need to run "git submodule update --init --recursive" 26 | export LIBRI_DIR="$HOME/programs/LibRI" 27 | export LIBCOMM_DIR="$HOME/programs/LibComm" 28 | 29 | # The GreenX API is switched on. In this case, the Fortran compiler needs to be configured. 30 | export CXX=mpiicpx 31 | export FC=ifx 32 | 33 | if [[ -n $LIBRI_DIR ]]; then 34 | cmake -B $BUILDDIR -DENABLE_TEST=ON -DUSE_LIBRI=ON -DUSE_GREENX_API=ON \ 35 | -DLIBRI_INCLUDE_DIR="$LIBRI_DIR/include" \ 36 | -DLIBCOMM_INCLUDE_DIR="$LIBCOMM_DIR/include" 37 | else 38 | cmake -B $BUILDDIR -DENABLE_TEST=ON -DUSE_LIBRI=ON -DUSE_GREENX_API=ON 39 | fi 40 | 41 | cd $BUILDDIR && make -j 4 42 | -------------------------------------------------------------------------------- /platforms/macos_gcc_mpich_openblas.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script uses GCC, MPICH, OpenBLAS and ScaLAPACK to build LibRPA 4 | # on macOS for develop and test use. Tested for Sonoma and Ventura. 5 | 6 | # GCC compilers (g++, gfortran), MPICH and OpenBLAS are installed using homebrew. 7 | # ScaLAPACK needs to be installed manually, because the homebrew ScaLAPACK is 8 | # built on OpenMPI. 9 | # Note that Fortran is used only when USE_GREENX_API or ENABLE_FORTRAN_BIND is on. 10 | 11 | BUILDDIR="${BUILDDIR:=build_macos_gcc_mpich}" 12 | 13 | # The following two variables need customize 14 | export OPENBLAS_DIR="/opt/homebrew/Cellar/openblas/0.3.28/lib" 15 | export SCALAPACK_DIR="/opt/packages/scalapack/2.2.0/gcc-14.2.0-mpich-4.2.2-openblas" 16 | 17 | # Compilers setup 18 | export CXX=mpicxx 19 | export MPICH_CXX=g++-14 20 | export CC=gcc-14 21 | export FC=gfortran-14 22 | 23 | export FCFLAGS="-Wl,-ld_classic" 24 | # The GreenX API is switched on. In this case, the Fortran compiler needs to be configured. 25 | export CXXFLAGS="-cxx=g++-14 -g -rdynamic -Wl,-lgfortran -Wl,-ld_classic" 26 | 27 | cmake -B $BUILDDIR -DUSE_LIBRI=OFF -DUSE_GREENX_API=ON \ 28 | -DENABLE_TEST=ON \ 29 | -DBLAS_LIBRARIES="-L${OPENBLAS_DIR} -lblas" \ 30 | -DLAPACK_LIBRARIES="-L${OPENBLAS_DIR} -llapack" \ 31 | -DSCALAPACK_DIR="$SCALAPACK_DIR" \ 32 | -DCMAKE_CXX_FLAGS="$CXXFLAGS" \ 33 | -DCMAKE_Fortran_FLAGS="$FCFLAGS" 34 | 35 | cmake --build $BUILDDIR -j 4 36 | -------------------------------------------------------------------------------- /regression_tests/.gitignore: -------------------------------------------------------------------------------- 1 | !aims.out 2 | !librpa.out 3 | -------------------------------------------------------------------------------- /regression_tests/refs/prim_C_diamond_k64/aims/geometry.in: -------------------------------------------------------------------------------- 1 | # 2 | # C1, NA, Diamond#C(cF8)#α−Sn type 3 | # reference: Acta Crystallographica, Section B: Structural Science vol 52, pp 232 4 | # 5 | atom_frac 0.250000000 0.250000000 0.250000000 C 6 | atom_frac 0.000000000 0.000000000 0.000000000 C 7 | lattice_vector 0.000000000 1.783560000 1.783560000 8 | lattice_vector 1.783560000 0.000000000 1.783560000 9 | lattice_vector 1.783560000 1.783560000 0.000000000 10 | -------------------------------------------------------------------------------- /regression_tests/refs/prim_C_diamond_k64/aims/reference.json: -------------------------------------------------------------------------------- 1 | { 2 | "aims": { 3 | "version": "220225-fbbdcd540", 4 | "nprocs": 4 5 | }, 6 | "lib": { 7 | "version": "2aa89bf59", 8 | "n_tf_grids": 16, 9 | "green_threshold": 1e-4, 10 | "cs_threshold": 1e-6 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /regression_tests/refs/prim_MgO_k64/aims/geometry.in: -------------------------------------------------------------------------------- 1 | #Mg1 O1 2 | 3 | lattice_vector 3.0097887516 0.0000000000 0.0000000000 4 | lattice_vector 1.5048943758 2.6065535189 0.0000000000 5 | lattice_vector 1.5048943758 0.8688511730 2.4574822250 6 | 7 | 8 | atom_frac 0.000000000 0.000000000 0.000000000 Mg 9 | atom_frac 0.500000000 0.500000000 0.500000000 O 10 | -------------------------------------------------------------------------------- /regression_tests/refs/prim_MgO_k64/aims/reference.json: -------------------------------------------------------------------------------- 1 | { 2 | "aims": { 3 | "version": "200112_2-6aec163", 4 | "nprocs": 48 5 | }, 6 | "lib": { 7 | "version": "81cee9c", 8 | "n_tf_grids": 14, 9 | "green_threshold": 1e-4, 10 | "cs_threshold": 1e-6 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /regression_tests/testcases/mole_H2O/aims/geometry.in: -------------------------------------------------------------------------------- 1 | lattice_vector 20.00000 0.00000 0.00000 2 | lattice_vector 0.00000 20.00000 0.00000 3 | lattice_vector 0.00000 0.00000 20.00000 4 | atom -0.07712649 0.00000000 1.49704522 O 5 | atom 0.82002231 0.00000000 1.86358518 H 6 | atom 0.07269418 -0.00000000 0.53972961 H 7 | -------------------------------------------------------------------------------- /regression_tests/testcases/mole_H2O/aims/input_librpa.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Srlive1201/LibRPA/4676a0d845024e73aa6e92f4aca843a2bbb4c847/regression_tests/testcases/mole_H2O/aims/input_librpa.tar.gz -------------------------------------------------------------------------------- /regression_tests/testcases/mole_H2O/aims/librpa.in: -------------------------------------------------------------------------------- 1 | task = rpa 2 | nfreq = 16 3 | binary_input = t 4 | use_scalapack_ecrpa = t -------------------------------------------------------------------------------- /regression_tests/testcases/prim_C_diamond_k64/aims/geometry.in: -------------------------------------------------------------------------------- 1 | # 2 | # C1, NA, Diamond#C(cF8)#α−Sn type 3 | # reference: Acta Crystallographica, Section B: Structural Science vol 52, pp 232 4 | # 5 | atom_frac 0.250000000 0.250000000 0.250000000 C 6 | atom_frac 0.000000000 0.000000000 0.000000000 C 7 | lattice_vector 0.000000000 1.783560000 1.783560000 8 | lattice_vector 1.783560000 0.000000000 1.783560000 9 | lattice_vector 1.783560000 1.783560000 0.000000000 10 | -------------------------------------------------------------------------------- /regression_tests/testcases/prim_MgO_k64/aims/geometry.in: -------------------------------------------------------------------------------- 1 | #Mg1 O1 2 | 3 | lattice_vector 3.0097887516 0.0000000000 0.0000000000 4 | lattice_vector 1.5048943758 2.6065535189 0.0000000000 5 | lattice_vector 1.5048943758 0.8688511730 2.4574822250 6 | 7 | 8 | atom_frac 0.000000000 0.000000000 0.000000000 Mg 9 | atom_frac 0.500000000 0.500000000 0.500000000 O 10 | -------------------------------------------------------------------------------- /src/analycont.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | * @author Min-Ye Zhang 3 | * @date 2024-04-25 4 | */ 5 | #include "analycont.h" 6 | 7 | #include 8 | // #include 9 | 10 | #include "complexmatrix.h" 11 | // #include "stl_io_helper.h" 12 | 13 | namespace LIBRPA 14 | { 15 | 16 | AnalyContPade::AnalyContPade(int n_pars_in, const std::vector &xs, const std::vector &data) 17 | : n_pars(n_pars_in) 18 | { 19 | int n_data = data.size(); 20 | std::vector data_npar; 21 | 22 | assert (n_pars > 0); 23 | 24 | if (n_data <= n_pars) 25 | { 26 | // Use all data points 27 | n_pars = n_data; 28 | par_x = xs; 29 | data_npar = data; 30 | } 31 | else 32 | { 33 | // Select the data points evenly, when number of parameters are fewer than data points 34 | par_x.resize(n_pars); 35 | data_npar.resize(n_pars); 36 | int step = n_data / (n_pars - 1); 37 | for (int ipar = 0; ipar < n_pars - 1; ipar++) 38 | { 39 | par_x[ipar] = xs[ipar * step]; 40 | data_npar[ipar] = data[ipar * step]; 41 | } 42 | data_npar[n_pars-1] = data[n_data-1]; 43 | } 44 | 45 | // Calculate the continuation coefficients, using Thiel's reciprocal difference method 46 | ComplexMatrix g(n_pars, n_pars); 47 | for (int i_par = 0; i_par < n_pars; i_par++) 48 | { 49 | g(i_par, 0) = data_npar[i_par]; 50 | } 51 | 52 | for (int i_par = 1; i_par < n_pars; i_par++) 53 | { 54 | for (int i = i_par; i < n_pars; i++) 55 | { 56 | g(i, i_par) = 57 | (g(i_par-1, i_par-1) - g(i, i_par-1)) / ((par_x[i] - par_x[i_par-1]) * g(i, i_par-1)); 58 | } 59 | } 60 | 61 | par_y.resize(n_pars); 62 | for (int i_par = 0; i_par < n_pars; i_par++) 63 | { 64 | par_y[i_par] = g(i_par, i_par); 65 | } 66 | } 67 | 68 | cplxdb 69 | AnalyContPade::get(const cplxdb &x) const 70 | { 71 | cplxdb tmp = {1.0, 0.0}; 72 | 73 | for (int i_par = n_pars - 1; i_par > 0; i_par--) 74 | { 75 | tmp = 1.0 + par_y[i_par] * (x - par_x[i_par-1]) / tmp; 76 | } 77 | return par_y[0] / tmp; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/analycont.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file analycont.h 3 | * @brief Utilities for analytic continuation 4 | * @author Min-Ye Zhang 5 | * @date 2024-04-23 6 | */ 7 | #pragma once 8 | #include 9 | 10 | #include "base_utility.h" 11 | 12 | namespace LIBRPA 13 | { 14 | 15 | class AnalyContPade 16 | { 17 | private: 18 | int n_pars; 19 | std::vector par_x; 20 | std::vector par_y; 21 | 22 | public: 23 | AnalyContPade(int n_pars_in, 24 | const std::vector &xs, 25 | const std::vector &data); 26 | 27 | /*! 28 | * @brief get the value of continued function at complex number 29 | * 30 | * @param [in] x complex argument of function 31 | * 32 | * @return a complex double, the value of function at x 33 | */ 34 | cplxdb get(const cplxdb &x) const; 35 | }; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/app_exx.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file app_exx.h 3 | * @author Min-Ye Zhang 4 | * @date 2024-07-02 5 | */ 6 | #pragma once 7 | #include 8 | 9 | namespace LIBRPA 10 | { 11 | 12 | namespace app 13 | { 14 | 15 | /*! 16 | * @brief Compute the exact exchange (EXX) energy for states at specified k-points 17 | * 18 | * @param[in] i_state_low The lowest index of state (included) to compute 19 | * @param[in] i_state_high The highest index of state (excluded) to compute 20 | * @param[in] n_kpoints_task The number of k-points to return in the called process. 21 | * When equal to 0, an empty vector will be returned. 22 | * When less than 0, all k-points will be computed. 23 | * Otherwise, the states at k-points whose indices 24 | * are stored in `i_kpoints_task` will be computed. 25 | * @param[in] i_kpoints_task The indices of k-points to compute EXX energy. 26 | * 27 | * @returns `std::vector`, exchange energy of states. 28 | * If `i_state_low` is no less than `i_state_high`, or `n_kpoints_task` is 0, the vector is empty. 29 | * Otherwise the vector is of size `n_spins` * `n_kpoints_compute` * (`i_state_high` - `i_state_low`), 30 | * where `n_kpoints_compute` equals to total number of k-points if `n_kpoints_task` < 1, and 31 | * `n_kpoints_task` otherwise. The indices runs in the order of states, k-points and spins. 32 | */ 33 | std::vector 34 | compute_exx_orbital_energy_(int i_state_low, int i_state_high, 35 | int n_kpoints_task, const int *i_kpoints_task); 36 | 37 | } /* end of namespace app */ 38 | 39 | } /* end of namespace LIBRPA */ 40 | -------------------------------------------------------------------------------- /src/app_rpa.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace LIBRPA 6 | { 7 | 8 | namespace app 9 | { 10 | 11 | void get_rpa_correlation_energy_( 12 | std::complex &rpa_corr, 13 | std::vector> &rpa_corr_k_contrib 14 | ); 15 | 16 | 17 | } /* end of namespace app */ 18 | 19 | } /* end of namespace LIBRPA */ 20 | -------------------------------------------------------------------------------- /src/atomic_basis.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @file basis.h 3 | */ 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | 9 | namespace LIBRPA { 10 | 11 | class AtomicBasis 12 | { 13 | private: 14 | std::vector nbs_; 15 | std::vector part_range; 16 | void initialize(); 17 | public: 18 | std::size_t n_atoms; 19 | std::size_t nb_total; 20 | AtomicBasis(): nbs_(), part_range(), n_atoms(0), nb_total(0) {}; 21 | AtomicBasis(const std::vector& nbs); 22 | AtomicBasis(const std::vector& atoms, 23 | const std::map& map_atom_nb); 24 | AtomicBasis(const std::map& iatom_nbs); 25 | void set(const std::vector& nbs); 26 | void set(const std::map& iatom_nbs); 27 | std::size_t get_global_index(const int& i_atom, const std::size_t& i_loc_b) const; 28 | int get_i_atom(const std::size_t& i_glo_b) const; 29 | void get_local_index(const std::size_t& i_glo_b, int& i_atom, int& i_loc_b) const; 30 | int get_local_index(const std::size_t& i_glo_b, const int& i_atom) const; 31 | std::pair get_local_index(const std::size_t& i_glo_b) const; 32 | std::size_t get_atom_nb(const int& i_atom) const { return nbs_[i_atom]; } 33 | const std::vector& get_part_range() const { return part_range; } 34 | }; 35 | 36 | extern AtomicBasis atomic_basis_wfc; 37 | extern AtomicBasis atomic_basis_abf; 38 | 39 | } // namespace LIBRPA 40 | -------------------------------------------------------------------------------- /src/atoms.cpp: -------------------------------------------------------------------------------- 1 | #include "atoms.h" 2 | -------------------------------------------------------------------------------- /src/base_utility.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | constexpr static const double DOUBLE_EQUAL_THRES = 1e-10; 5 | 6 | typedef std::complex cplxdb; 7 | 8 | // check if passed template type argument is a complex value 9 | // from https://stackoverflow.com/questions/41438493/how-to-identifying-whether-a-template-argument-is-stdcomplex 10 | template 11 | struct is_complex_t: public std::false_type {}; 12 | 13 | template 14 | struct is_complex_t>: public std::true_type {}; 15 | 16 | template 17 | bool is_complex() { return is_complex_t::value; } 18 | 19 | template 20 | struct to_real { using type = T; }; 21 | template 22 | struct to_real> { using type = T; }; 23 | 24 | template 25 | struct to_cplx { using type = std::complex; }; 26 | template 27 | struct to_cplx> { using type = T; }; 28 | 29 | template 30 | inline void join_re_im(T &pt, const T &re, const T &im) { pt = re; } 31 | template 32 | inline void join_re_im(std::complex &pt, const T &re, const T &im) { pt = std::complex{re, im}; } 33 | 34 | template 35 | inline T get_real(const T& v) { return v; } 36 | template 37 | inline T get_real(const std::complex& v) { return v.real(); } 38 | template 39 | inline T get_imag(const T& v) { return T(0); } 40 | template 41 | inline T get_imag(const std::complex& v) { return v.imag(); } 42 | template 43 | inline T get_conj(const T& v) { return v; } 44 | template 45 | inline std::complex get_conj(const std::complex& v) { return std::conj(v); } 46 | 47 | template ::type> 48 | TR norm(const T v[], const T1 &n, const T2 &power) 49 | { 50 | T norm = 0; 51 | for (int i = 0; i < n; i++) 52 | norm += std::pow(std::fabs(v[i]), power); 53 | return std::pow(norm, 1./power); 54 | } 55 | 56 | -------------------------------------------------------------------------------- /src/constants.cpp: -------------------------------------------------------------------------------- 1 | #include "constants.h" 2 | #include 3 | 4 | const double PINF = INFINITY; 5 | const double NINF = - INFINITY; 6 | const double PI = M_PI; 7 | const double TWO_PI = 2.0 * PI; 8 | const double HA2EV = 27.211386245988; 9 | const double RY2EV = HA2EV * 0.5; 10 | const double ANG2BOHR = 1.889726127; 11 | const double BOHR2ANG2 = 1.0 / ANG2BOHR; 12 | -------------------------------------------------------------------------------- /src/constants.h: -------------------------------------------------------------------------------- 1 | #ifndef CONSTANTS_H 2 | #define CONSTANTS_H 3 | 4 | extern const double PINF; 5 | extern const double NINF; 6 | extern const double PI; 7 | extern const double TWO_PI; 8 | extern const double HA2EV; 9 | extern const double RY2EV; 10 | extern const double ANG2BOHR; 11 | extern const double BOHR2ANG; 12 | #endif 13 | -------------------------------------------------------------------------------- /src/coulmat.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file coulmat.h 3 | * @brief utilities for handling with Coulomb matrix 4 | */ 5 | #pragma once 6 | #include "ri.h" 7 | 8 | /*! 9 | * @brief perform Fourier transform of q/k-space Coulomb matrix to R-space 10 | * @param coulmat q/k-space Coulomb matrix by atom-pair index 11 | * @param Rlist vectors of R where the R-space Coulomb matrix should be computed 12 | * @param return_ordered_atom_pair ensure that the returned type 13 | * will always have keys of ordered atom pairs, 14 | * i.e. there always exists map[I][J] and map[J][I] for I not equal to J 15 | * @return atpair_R_mat_t 16 | */ 17 | atpair_R_mat_t FT_Vq(const atpair_k_cplx_mat_t &coulmat, 18 | vector> Rlist, 19 | bool return_ordered_atom_pair); 20 | -------------------------------------------------------------------------------- /src/dielecmodel.cpp: -------------------------------------------------------------------------------- 1 | #include "dielecmodel.h" 2 | 3 | #include 4 | 5 | const int DoubleHavriliakNegami::d_npar = 8; 6 | 7 | const std::function &)> 8 | DoubleHavriliakNegami::func_imfreq = [](double u, const std::vector &pars) 9 | { 10 | return 1.0 + (pars[0] - 1.0) / std::pow(1.0 + std::pow(u * pars[3], pars[1]), pars[2]) + 11 | (pars[4] - 1.0) / std::pow(1.0 + pow(u * pars[7], pars[5]), pars[6]); 12 | }; 13 | 14 | const std::function &, double, const std::vector &)> 15 | DoubleHavriliakNegami::grad_imfreq = 16 | [](std::vector &grads, double u, const std::vector &pars) 17 | { 18 | using std::pow; 19 | using std::log; 20 | grads[0] = 1.0 / pow(1.0 + pow(u * pars[3], pars[1]), pars[2]); 21 | grads[1] = (pars[0] - 1.0) * (-pars[2]) / pow(1.0 + pow(u * pars[3], pars[1]), pars[2] + 1) * 22 | log(u * pars[3]) * pow(u * pars[3], pars[1]); 23 | grads[2] = (1.0 - pars[0]) * log(1.0 + pow(u * pars[3], pars[1])) / 24 | pow(1.0 + pow(u * pars[3], pars[1]), pars[2]); 25 | grads[3] = (pars[0] - 1.0) * (-pars[2]) / pow(1.0 + pow(u * pars[3], pars[1]), pars[2] + 1) * 26 | pars[1] / pars[3] * pow(u * pars[3], pars[1]); 27 | grads[4] = 1.0 / pow(1.0 + pow(u * pars[7], pars[5]), pars[6]); 28 | grads[5] = (pars[4] - 1.0) * (-pars[6]) / pow(1.0 + pow(u * pars[7], pars[5]), pars[6] + 1) * 29 | log(u * pars[7]) * pow(u * pars[7], pars[5]); 30 | grads[6] = (1.0 - pars[4]) * log(1.0 + pow(u * pars[7], pars[5])) / 31 | pow(1.0 + pow(u * pars[7], pars[5]), pars[6]); 32 | grads[7] = (pars[4] - 1.0) * (-pars[6]) / pow(1.0 + pow(u * pars[7], pars[5]), pars[6] + 1) * 33 | pars[5] / pars[7] * pow(u * pars[7], pars[5]); 34 | }; 35 | -------------------------------------------------------------------------------- /src/dielecmodel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | //! double-dispersion Havriliak-Negami model 6 | struct DoubleHavriliakNegami 7 | { 8 | static const int d_npar; 9 | static const std::function &)> func_imfreq; 10 | static const std::function &, double, const std::vector &)> 11 | grad_imfreq; 12 | }; 13 | -------------------------------------------------------------------------------- /src/envs_dir.cpp: -------------------------------------------------------------------------------- 1 | #include "envs_dir.h" 2 | 3 | #include 4 | #include 5 | 6 | //! Get the directory name of absolute file path file_abspath 7 | /*! 8 | @param[in] file_abspath: absolute path of a file. Support UNIX only. 9 | */ 10 | static const char * get_dirname(const char * file_abspath) 11 | { 12 | char * fn = new char [std::strlen(file_abspath) + 1]; 13 | std::strcpy(fn, file_abspath); 14 | char *p; 15 | p = std::strrchr(fn, '/'); 16 | if(p) p[0] = '\0'; 17 | int l = std::strlen(fn); 18 | char * dn = new char [l + 1]; 19 | std::strcpy(dn, fn); 20 | return fn; 21 | } 22 | 23 | namespace LIBRPA 24 | { 25 | 26 | namespace envs 27 | { 28 | 29 | const char * source_dir = get_dirname(__FILE__); 30 | 31 | } /* end of namespace envs */ 32 | } /* end of namespace LIBRPA */ 33 | -------------------------------------------------------------------------------- /src/envs_dir.cpp.in: -------------------------------------------------------------------------------- 1 | #include "envs_dir.h" 2 | 3 | namespace LIBRPA 4 | { 5 | 6 | namespace envs 7 | { 8 | 9 | const char * source_dir = "${PROJECT_SOURCE_DIR}/src"; 10 | 11 | } /* end of namespace envs */ 12 | } /* end of namespace LIBRPA */ 13 | -------------------------------------------------------------------------------- /src/envs_dir.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace LIBRPA 4 | { 5 | 6 | namespace envs 7 | { 8 | 9 | //! The path of the source code directory 10 | extern const char * source_dir; 11 | 12 | } /* end of namespace envs */ 13 | } /* end of namespace LIBRPA */ 14 | -------------------------------------------------------------------------------- /src/envs_io.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace LIBRPA 5 | { 6 | 7 | namespace envs 8 | { 9 | 10 | extern std::ofstream ofs; 11 | 12 | //! File output stream handler of each process 13 | extern std::ofstream ofs_myid; 14 | 15 | //! Control whether to redirect stdout (cout, fmt print) to file 16 | extern bool redirect_stdout; 17 | 18 | //! File stream used by fprintf when stdout is redirected 19 | extern FILE *pfile_redirect; 20 | 21 | //! Initialize the IO environment of LibRPA 22 | /*! 23 | * @param [in] redirect_stdout_in flag to control to redirect stdout to file, useful when separating LibRPA output from the main program 24 | * @pram [in] filename name of file to redirect stdout 25 | */ 26 | void initialize_io(bool redirect_stdout_in = false, const char *filename = "LibRPA_output.txt"); 27 | 28 | //! Check the IO environment of LibRPA is correctly initialized 29 | bool is_io_initialized(); 30 | 31 | 32 | //! Finalize the IO environment of LibRPA 33 | void finalize_io(); 34 | 35 | } /* end of namespace envs */ 36 | 37 | 38 | } /* end of namespace LIBRPA */ 39 | -------------------------------------------------------------------------------- /src/envs_mpi.cpp: -------------------------------------------------------------------------------- 1 | #include "envs_mpi.h" 2 | 3 | #include 4 | 5 | namespace LIBRPA 6 | { 7 | 8 | namespace envs 9 | { 10 | 11 | int myid_global = 0; 12 | 13 | int size_global = 1; 14 | 15 | MPI_Comm mpi_comm_global; 16 | 17 | LIBRPA::MPI_COMM_handler mpi_comm_global_h; 18 | 19 | LIBRPA::BLACS_CTXT_handler blacs_ctxt_global_h; 20 | 21 | std::string procname = "not-init"; 22 | 23 | static bool librpa_mpi_initialized = false; 24 | 25 | void initialize_mpi(const MPI_Comm &mpi_comm_global_in) 26 | { 27 | int flag; 28 | MPI_Initialized(&flag); 29 | if (flag == 0) 30 | { 31 | throw std::runtime_error( 32 | std::string(__FILE__) + ":" + std::to_string(__LINE__) + ":" + std::string(__FUNCTION__) + ": " 33 | "MPI_Init or MPI_Init_thread must be called before " + std::string(__FUNCTION__)); 34 | } 35 | 36 | mpi_comm_global = mpi_comm_global_in; 37 | 38 | MPI_Comm_rank(mpi_comm_global, &myid_global); 39 | MPI_Comm_size(mpi_comm_global, &size_global); 40 | 41 | char name[MPI_MAX_PROCESSOR_NAME]; 42 | int length; 43 | MPI_Get_processor_name(name, &length); 44 | procname = name; 45 | 46 | // Initialize handlers of global MPI communicator and BLACS context 47 | mpi_comm_global_h.reset_comm(mpi_comm_global); 48 | mpi_comm_global_h.init(); 49 | 50 | blacs_ctxt_global_h.reset_comm(mpi_comm_global); 51 | blacs_ctxt_global_h.init(); 52 | 53 | /* 54 | * HACK: A close-to-square process grid is imposed. 55 | * This might subject to performance issue when 56 | * the number of processes is not dividable. 57 | */ 58 | blacs_ctxt_global_h.set_square_grid(); 59 | 60 | librpa_mpi_initialized = true; 61 | } 62 | 63 | bool is_mpi_initialized() 64 | { 65 | return librpa_mpi_initialized; 66 | } 67 | 68 | void finalize_mpi() 69 | { 70 | procname = "not-init"; 71 | librpa_mpi_initialized = false; 72 | } 73 | 74 | } /* end of namespace envs */ 75 | 76 | } /* end of namespace LIBRPA */ 77 | -------------------------------------------------------------------------------- /src/envs_mpi.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file envs_mpi.h 3 | * @brief Environment setup regarding MPI. 4 | * @author Min-Ye Zhang 5 | * @date 2024-07-02 6 | */ 7 | #pragma once 8 | #include 9 | #include 10 | 11 | #include "parallel_mpi.h" 12 | 13 | //! @namespace LIBRPA Global namespace for LibRPA functions and classes 14 | //! @namespace LIBRPA::envs Facilities regarding computation envrionment 15 | //! @namespace LIBRPA::utils Utilities functions 16 | //! @namespace LIBRPA::app Functions for applications, e.g. RPA correlation, exact-exchange matrix 17 | 18 | namespace LIBRPA 19 | { 20 | 21 | namespace envs 22 | { 23 | 24 | //! Global communicator 25 | extern MPI_Comm mpi_comm_global; 26 | 27 | //! Handler of the global communicator 28 | extern LIBRPA::MPI_COMM_handler mpi_comm_global_h; 29 | 30 | //! Handler of the global BLACS context 31 | extern LIBRPA::BLACS_CTXT_handler blacs_ctxt_global_h; 32 | 33 | //! Rank of process in the global communciator 34 | extern int myid_global; 35 | 36 | //! Number of processes in the global communciator 37 | extern int size_global; 38 | 39 | //! Name of process 40 | extern std::string procname; 41 | 42 | //! Initialize the MPI environment of LibRPA 43 | /*! 44 | * @param [in] mpi_comm_global_in Global MPI communicator 45 | */ 46 | void initialize_mpi(const MPI_Comm &mpi_comm_global_in); 47 | 48 | //! Check whether the MPI environment of LibRPA is correctly initialized 49 | bool is_mpi_initialized(); 50 | 51 | //! Finalize the MPI environment of LibRPA 52 | void finalize_mpi(); 53 | 54 | } /* end of namespace envs */ 55 | 56 | } /* end of namespace LIBRPA */ 57 | -------------------------------------------------------------------------------- /src/get_minimax.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //! \brief get the minimax frequency grids 4 | void get_minimax_grid_frequency(int ngrids, double e_min, double e_max, 5 | double *omega_points, double *omega_weights, 6 | int &ierr); 7 | 8 | //! \brief get the minimax time and frequency grids and related transformation matrices 9 | void get_minimax_grid(int ngrids, double e_min, double e_max, 10 | double *tau_points, double *tau_weights, 11 | double *omega_points, double *omega_weights, 12 | double *cosft_wt, double *cosft_tw, double *sinft_wt, 13 | double max_errors[3], double &cosft_duality_error, int &ierr); 14 | -------------------------------------------------------------------------------- /src/get_minimax_gx.cpp: -------------------------------------------------------------------------------- 1 | #include "get_minimax.h" 2 | 3 | #include "gx_minimax_wrp.h" 4 | 5 | // NOTE(MYZ): rescale frequency weights for number of grids below 6 | // some point due to inconsistency in greenx 7 | // NOTE(MYZ): Fixed upstream, so there is no need to do this any more 8 | // static const int ngrids_below_freqweight_inconsistent = 26; 9 | // static const double scale_inconsistent = 0.25; 10 | 11 | bool check_minimax_available(int ngrids) 12 | { 13 | bool avail = false; 14 | return avail; 15 | } 16 | 17 | void get_minimax_grid_frequency(int ngrids, double e_min, double e_max, 18 | double *omega_points, double *omega_weights, 19 | int &ierr) 20 | { 21 | gx_minimax_grid_frequency_wrp(&ngrids, &e_min, &e_max, omega_points, omega_weights, &ierr); 22 | // if (ngrids < ngrids_below_freqweight_inconsistent) 23 | // for (int i = 0; i != ngrids; i++) 24 | // omega_weights[i] *= scale_inconsistent; 25 | } 26 | 27 | void get_minimax_grid(int ngrids, double e_min, double e_max, 28 | double *tau_points, double *tau_weights, 29 | double *omega_points, double *omega_weights, 30 | double *cosft_wt, double *cosft_tw, double *sinft_wt, 31 | double max_errors[3], double &cosft_duality_error, 32 | int &ierr) 33 | { 34 | gx_minimax_grid_wrp(&ngrids, &e_min, &e_max, tau_points, tau_weights, 35 | omega_points, omega_weights, cosft_wt, cosft_tw, 36 | sinft_wt, max_errors, &cosft_duality_error, &ierr); 37 | // if (ngrids < ngrids_below_freqweight_inconsistent) 38 | // for (int i = 0; i != ngrids; i++) 39 | // omega_weights[i] *= scale_inconsistent; 40 | } 41 | -------------------------------------------------------------------------------- /src/gw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @file gw.h 3 | * @brief facilities to calculate self-energy operator. 4 | */ 5 | #pragma once 6 | #include "ri.h" 7 | #include "timefreq.h" 8 | #include "meanfield.h" 9 | #include "atoms.h" 10 | #include "matrix_m.h" 11 | 12 | namespace LIBRPA 13 | { 14 | 15 | class G0W0 16 | { 17 | private: 18 | bool d_sigc_built; 19 | public: 20 | const MeanField &mf; 21 | const vector>& kfrac_list; 22 | const TFGrids &tfg; 23 | //! frequency-domain reciprocal-space correlation self-energy, indices [ispin][freq][k][I][J](n_I, n_J) 24 | std::map, atom_mapping::pair_t_old>>> sigc_is_f_k_IJ; 25 | //! correlation self-energy matrix in the basis of KS states, indices [ispin][ik][freq](n_bands, n_bands) 26 | std::map>> sigc_is_ik_f_KS; 27 | public: 28 | G0W0(const MeanField &mf, 29 | const vector>& kfrac_list, 30 | const TFGrids &tfg); 31 | // delete copy/move constructors 32 | G0W0(const G0W0 &s_g0w0) = delete; 33 | G0W0(G0W0 &&s_g0w0) = delete; 34 | 35 | // delete assignment copy/move 36 | G0W0 operator=(const G0W0 &s_g0w0) const = delete; 37 | G0W0 operator=(G0W0 &&s_g0w0) = delete; 38 | 39 | //! using native tensor contraction 40 | // void build_spacetime( 41 | // const atpair_R_mat_t &LRI_Cs, 42 | // const map, 43 | // matrix_m>>>::pair_t_old> &Wc_freq_q, 44 | // const vector> &Rlist, 45 | // const Vector3_Order &R_period); 46 | 47 | //! using LibRI 48 | void build_spacetime_LibRI( 49 | const Cs_LRI &LRI_Cs, 50 | const map, 51 | matrix_m>>>::pair_t_old> &Wc_freq_q, 52 | const vector> &Rlist, 53 | const Vector3_Order &R_period); 54 | 55 | //! build the correlation self-energy matrix in Kohn-Sham basis 56 | void build_sigc_matrix_KS(); 57 | }; 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/gx_minimax_wrp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | void gx_minimax_grid_frequency_wrp(int *num_points, double *e_min, double *e_max, 7 | double *omega_points, double *omega_weights, 8 | int *ierr); 9 | 10 | void gx_minimax_grid_wrp(int *num_points, double *e_min, double *e_max, 11 | double *tau_points, double *tau_weights, 12 | double *omega_points, double *omega_weights, 13 | double *cosft_wt, double *cosft_tw, double *sinft_wt, 14 | double max_errors[3], double *cosft_duality_error, int *ierr); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /src/interpolate.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file interpolate.h 3 | * \brief Component to perform interpolation 4 | * \details This component includes basic functions to interpolate values from 5 | * available grid data. The implementation is probably naive. For better 6 | * performance and validity, it should be replaced by GSL or other GPL-licensed 7 | * library when license issue is resolved. 8 | */ 9 | #pragma once 10 | #include 11 | 12 | namespace LIBRPA 13 | { 14 | namespace utils 15 | { 16 | 17 | //! Class to perform cubic spline interolation 18 | class CubicSpline 19 | { 20 | private: 21 | const std::vector d_xs; 22 | const std::vector d_ys; 23 | std::vector d_a; 24 | std::vector d_b; 25 | std::vector d_c; 26 | std::vector d_d; 27 | public: 28 | // default constructor 29 | CubicSpline(const std::vector& xs, const std::vector& ys); 30 | // destructor 31 | ~CubicSpline() {}; 32 | // copy & move constructor 33 | CubicSpline(const CubicSpline& s) = delete; 34 | CubicSpline(CubicSpline&& s) = delete; 35 | // copy & move assignment operator 36 | CubicSpline& operator=(const CubicSpline& s) = delete; 37 | CubicSpline& operator=(CubicSpline&& s) = delete; 38 | 39 | //! interpolate on individual x 40 | double operator()(double x) const; 41 | //! interpolate on a list of x 42 | std::vector operator()(const std::vector& xs) const; 43 | }; /* end of class CubicSpline */ 44 | 45 | /*! 46 | * \brief Helper function to performance cubic spline interpolation 47 | * \param[in] x values of avaiable data points 48 | * \param[in] y values of avaiable data points 49 | * \param[in] x values of points to interpolate 50 | * \return y values of points to interpolate 51 | */ 52 | std::vector interp_cubic_spline(const std::vector &xs, 53 | const std::vector &ys, 54 | const std::vector &xs_new); 55 | 56 | } /* end of namepsace utils */ 57 | 58 | } /* end of namespace LIBRPA */ 59 | -------------------------------------------------------------------------------- /src/libri_stub.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @file libri_stub.h 3 | * @brief Stubbing classes and functions for LibRI 4 | * @author Min-Ye Zhang 5 | * @date 2024-07-08 6 | */ 7 | #pragma once 8 | #ifndef LIBRPA_USE_LIBRI 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | namespace RI 15 | { 16 | 17 | template 18 | class Tensor 19 | { 20 | public: 21 | Tensor() 22 | { throw std::logic_error("stub Tensor constructor is called"); }; 23 | 24 | Tensor(const std::vector &dimension, std::shared_ptr> data_in) 25 | { throw std::logic_error("stub Tensor constructor is called"); }; 26 | 27 | Tensor(const std::initializer_list &dimension, std::shared_ptr> data_in) 28 | { throw std::logic_error("stub Tensor constructor is called"); }; 29 | 30 | void clear() {}; 31 | }; 32 | 33 | } /* end of namespace RI */ 34 | #endif 35 | -------------------------------------------------------------------------------- /src/librpa_main.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBRPA_MAIN_H 2 | #define LIBRPA_MAIN_H 3 | 4 | void librpa_main(); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /src/minimax_grid/10/INFO.txt: -------------------------------------------------------------------------------- 1 | Freq_grid_num: 10 Range_x: 0.9998244000000001 90.0 err: 5.019746930567948e-06 2 | time_grid_num: 10 Range_x: 0.9998244000000001 90.0 err: 3.5311735313570125e-07 3 | Time_to_freq_transform Range_x: 0.9998244000000001 90.0 4 | Freq_point: 0.2891726828847699 transform_err: 8.194607115163954e-05 5 | Freq_point: 0.9732226579944868 transform_err: 0.0001470581083253819 6 | Freq_point: 2.0244285975776104 transform_err: 8.89009176808786e-05 7 | Freq_point: 3.8793608293009414 transform_err: 1.1768417072122173e-05 8 | Freq_point: 7.371996456455426 transform_err: 3.121555645677759e-05 9 | Freq_point: 14.205151475919566 transform_err: 4.127772544618852e-05 10 | Freq_point: 28.10233537671841 transform_err: 3.663815668092374e-05 11 | Freq_point: 58.6903540941467 transform_err: 3.237951086918975e-05 12 | Freq_point: 147.94631368916606 transform_err: 1.542158538382285e-05 13 | Freq_point: 4659.625022060654 transform_err: 1.4167140529416712e-07 14 | Finish! 15 | -------------------------------------------------------------------------------- /src/minimax_grid/10/freq_grid.txt: -------------------------------------------------------------------------------- 1 | 0.2891726828847699 0.18945180653213095 2 | 0.9732226579944868 0.25928525495452825 3 | 2.0244285975776104 0.43201418800888214 4 | 3.8793608293009414 0.7908618343712852 5 | 7.371996456455426 1.5177438033253585 6 | 14.205151475919566 3.0150582850605043 7 | 28.10233537671841 6.274009438513237 8 | 58.6903540941467 14.71735056210634 9 | 147.94631368916606 54.990075111518244 10 | 4659.625022060654 3.614022003321944 11 | -------------------------------------------------------------------------------- /src/minimax_grid/10/minimax_grid_main.py: -------------------------------------------------------------------------------- 1 | from modi_leastsq import main_freq 2 | from tau_grid import main_time 3 | from time2freq_transform_grid import main_trans 4 | 5 | Npoint=10 6 | R=90 7 | if __name__=='__main__': 8 | print("Run_freq_grid") 9 | main_freq(Npoint,R) 10 | print("Run_time_grid") 11 | main_time(Npoint,R) 12 | print("Run_transform_grid") 13 | main_trans(R) 14 | print("Finish_minimax_grid") 15 | -------------------------------------------------------------------------------- /src/minimax_grid/10/read_grid.py: -------------------------------------------------------------------------------- 1 | from scipy.optimize import minimize,Bounds,least_squares 2 | import numpy as np 3 | import matplotlib.pyplot as plt 4 | #from scipy.optimize import least_squares 5 | def Fun_minimax(x,args): # 定义拟合函数形式 6 | def eta(x,a): 7 | sum_x=0.0 8 | weight=x[:int(len(x)/2)] 9 | omega=x[int(len(x)/2):] 10 | i=0 11 | while i 3 | 4 | vector> construct_R_grid(const Vector3_Order &period) 5 | { 6 | // cout<<" begin to construct_R_grid"<> R_grid; 8 | R_grid.clear(); 9 | 10 | for (int x = -(period.x) / 2; x <= (period.x - 1) / 2; ++x) 11 | for (int y = -(period.y) / 2; y <= (period.y - 1) / 2; ++y) 12 | for (int z = -(period.z) / 2; z <= (period.z - 1) / 2; ++z) 13 | R_grid.push_back({x, y, z}); 14 | 15 | return R_grid; 16 | } 17 | 18 | int get_R_index(const vector> &Rlist, const Vector3_Order &R) 19 | { 20 | // v1: manual search 21 | // for ( int iR = 0; iR != Rlist.size(); iR++ ) 22 | // { 23 | // if (Rlist[iR] == R) return iR; 24 | // } 25 | // v2: use algorithm 26 | auto itr = std::find(Rlist.cbegin(), Rlist.cend(), R); 27 | if ( itr != Rlist.cend()) return distance(Rlist.cbegin(), itr); 28 | return -1; 29 | } 30 | 31 | bool is_gamma_point(const Vector3_Order &kpt) 32 | { 33 | double thres = 1.0e-5; 34 | return -thres < kpt.x && kpt.x < thres 35 | && -thres < kpt.y && kpt.y < thres 36 | && -thres < kpt.z && kpt.z < thres; 37 | } 38 | 39 | bool is_gamma_point(const Vector3_Order &kpt_int) 40 | { 41 | return kpt_int.x == 0 && kpt_int.y == 0 && kpt_int.z == 0; 42 | } 43 | 44 | int kv_nmp[3] = {1, 1, 1}; 45 | Vector3 *kvec_c; 46 | std::vector> klist; 47 | std::vector> klist_ibz; 48 | std::vector> kfrac_list; 49 | std::vector irk_point_id_mapping; 50 | map, vector>> map_irk_ks; 51 | Matrix3 latvec; 52 | std::array, 3> lat_array; 53 | Matrix3 G; 54 | -------------------------------------------------------------------------------- /src/pbc.h: -------------------------------------------------------------------------------- 1 | /*! 2 | @file pbc.h 3 | @brief Utilities to deal with periodic boundary conditions 4 | */ 5 | #pragma once 6 | #include 7 | #include 8 | #include 9 | #include "vector3_order.h" 10 | #include "matrix3.h" 11 | 12 | // TODO: make it into a template 13 | std::vector> construct_R_grid(const Vector3_Order &period); 14 | 15 | //! Get the index of R in an Rlist. If R is not found in the list, return a negative number 16 | int get_R_index(const std::vector> &Rlist, const Vector3_Order &R); 17 | 18 | bool is_gamma_point(const Vector3_Order &kpt); 19 | bool is_gamma_point(const Vector3_Order &kpt); 20 | 21 | extern int kv_nmp[3]; 22 | //! lattice vectors as a 3D-matrix, each row as a lattice vector 23 | extern Matrix3 latvec; 24 | //! same as latvec, but a nested array for LibRI call 25 | extern std::array, 3> lat_array; 26 | //! reciprocal lattice vectors as a 3D-matrix, each row as a reciprocal vector 27 | extern Matrix3 G; 28 | extern std::vector> klist; 29 | extern std::vector> klist_ibz; 30 | extern std::vector> kfrac_list; 31 | extern std::vector irk_point_id_mapping; 32 | extern map, vector>> map_irk_ks; 33 | extern Vector3 *kvec_c; 34 | -------------------------------------------------------------------------------- /src/qpe_solver.cpp: -------------------------------------------------------------------------------- 1 | #include "qpe_solver.h" 2 | 3 | #include 4 | // #include 5 | // #include 6 | 7 | namespace LIBRPA 8 | { 9 | 10 | int qpe_solver_pade_self_consistent( 11 | const AnalyContPade &pade, 12 | const double &e_mf, 13 | const double &e_fermi, 14 | const double &vxc, 15 | const double &sigma_x, 16 | double &e_qp, 17 | cplxdb &sigc, 18 | double thres) 19 | { 20 | int info = 0; 21 | const double escale = 0.1; 22 | const int n_iter_max = 200; 23 | int n_iter = 0; 24 | 25 | // initial guess of e_qp as input mean-field energy 26 | e_qp = e_mf; 27 | 28 | double diff = 1e-3; 29 | 30 | // std::cout << "QPE: " << e_mf << " " << e_fermi << " " << vxc << " " << sigma_x << "\n"; 31 | while (n_iter++ < n_iter_max) 32 | { 33 | e_qp = e_qp + escale * diff; 34 | sigc = pade.get(static_cast(e_qp - e_fermi)); 35 | diff = e_mf - vxc + sigma_x + sigc.real() - e_qp; 36 | if (std::abs(diff) < thres) 37 | { 38 | break; 39 | } 40 | } 41 | // std::cout << "Finished QPE solve: " << n_iter << " " << std::scientific << diff << " " << std::abs(diff) << "\n"; 42 | 43 | if (n_iter > n_iter_max) 44 | { 45 | info = 1; 46 | } 47 | 48 | return info; 49 | } 50 | 51 | } /* end of namespace LIBRPA */ 52 | -------------------------------------------------------------------------------- /src/qpe_solver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "analycont.h" 4 | 5 | namespace LIBRPA 6 | { 7 | 8 | /*! 9 | * \brief Solve quasi-particle equation self-consistently by computing self-energy on real freqeuncy through Pade Analytic continuation 10 | * 11 | * \param [in] pade AnalyContPade object, constructed from correlation self-energy at imaginary frequency 12 | * \param [in] e_mf Energy of the state of meanf-field calculation 13 | * \param [in] e_fermi Fermi energy 14 | * \param [in] vxc Exchange-correlation potential in the mean-field calculation 15 | * \param [in] sigma_x Exchange self-energy 16 | * \param [out] e_qp Quasi-particle energy as the solution of QPE 17 | * \param [out] sigc Correlation self-energy of the quasi-particle 18 | * \retval info 0 if QPE is solved successfully 19 | */ 20 | int qpe_solver_pade_self_consistent( 21 | const AnalyContPade &pade, 22 | const double &e_mf, 23 | const double &e_fermi, 24 | const double &vxc, 25 | const double &sigma_x, 26 | double &e_qp, 27 | cplxdb &sigc, 28 | double thres = 1.0e-5); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/stl_io_helper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | //! Print a set of objects 10 | template 11 | std::ostream& operator<<(std::ostream& os, const std::set &set_objs); 12 | 13 | //! Print a vector of objects 14 | template 15 | std::ostream& operator<<(std::ostream& os, const std::vector &vector_objs); 16 | 17 | //! Print a pair of objects 18 | template 19 | std::ostream& operator<<(std::ostream& os, const std::pair &pair_objs); 20 | 21 | //! Print an array containing N objects 22 | template 23 | std::ostream& operator<<(std::ostream& os, const std::array &arr_objs); 24 | 25 | //! Print a map 26 | template 27 | std::ostream& operator<<(std::ostream& os, const std::map &map_objs); 28 | 29 | //! Print a the keys of a nested map 30 | template 31 | void print_keys(std::ostream& os, const std::map> &nested_map); 32 | 33 | //! Get total number of elements 34 | template 35 | void print_keys(std::ostream& os, const std::map>> &nested_map); 36 | 37 | //! Get total number of elements 38 | template 39 | int get_num_keys(const std::map> &nested_map); 40 | 41 | //! Get total number of elements 42 | template 43 | int get_num_keys(const std::map>> &nested_map); 44 | 45 | #include "stl_io_helper.hpp" // IWYU pragma: export 46 | -------------------------------------------------------------------------------- /src/task.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace LIBRPA 4 | { 5 | 6 | enum class task_t { 7 | RPA, 8 | EXX, 9 | G0W0, 10 | Wc_Rf, 11 | print_minimax, 12 | }; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # a simple macro to add source, include, link main library and run test 2 | # see also 3 | # - https://stackoverflow.com/questions/53868015/avoid-repetitive-cmake-code-with-multiple-targets 4 | # - https://stackoverflow.com/questions/19278510/cmake-ctest-add-test-command-appends-extra-quotes-to-my-command-parameters 5 | macro(config_test TARGET NUMPROC) 6 | add_executable(${TARGET} ${TARGET}.cpp) 7 | target_link_libraries(${TARGET} PRIVATE rpa_lib ${math_libs} ${parallel_libs}) 8 | # TODO: separate libri test targets 9 | if(USE_LIBRI) 10 | target_include_directories(${TARGET} 11 | PRIVATE 12 | ${Cereal_INCLUDE_DIR} 13 | ${LibComm_INCLUDE_DIR} 14 | ${LibRI_INCLUDE_DIR} 15 | ) 16 | endif() 17 | if(${NUMPROC} GREATER 1) 18 | # message("parallel test") 19 | add_test( 20 | NAME ${TARGET} 21 | COMMAND mpirun -np ${NUMPROC} $ 22 | ) 23 | else() 24 | # message("serial test") 25 | add_test( 26 | NAME ${TARGET} 27 | COMMAND $ 28 | ) 29 | endif() 30 | endmacro() 31 | 32 | # add serial tests 33 | foreach(target 34 | test_analycont 35 | test_atoms 36 | test_atomic_basis 37 | test_timefreq 38 | test_librpa 39 | test_matrix 40 | test_matrix_m 41 | test_meanfield 42 | test_complexmatrix 43 | test_pbc 44 | test_fitting 45 | test_blas_lapack 46 | ) 47 | config_test(${target} 1) 48 | endforeach() 49 | 50 | # add 4-process tests 51 | foreach(target 52 | test_parallel_mpi 53 | test_matrix_m_parallel_utils 54 | ) 55 | config_test(${target} 4) 56 | endforeach() 57 | 58 | # TODO(minye): make use of GTest 59 | -------------------------------------------------------------------------------- /src/test/test_analycont.cpp: -------------------------------------------------------------------------------- 1 | #include "../analycont.h" 2 | 3 | #include 4 | #include "testutils.h" 5 | #include 6 | 7 | 8 | void test_analycont_pade() 9 | { 10 | using std::vector; 11 | using std::cout; 12 | 13 | int n = 6; 14 | // original function: y = -1 / (x - x0), x0 = {1.0, 1.0} 15 | const cplxdb x0 = {2.0, 2.0}; 16 | std::vector xs(n); 17 | std::vector data(n); 18 | for (int i = 0; i < n; i++) 19 | { 20 | xs[i] = {0.0, static_cast(i+1)}; 21 | data[i] = -1.0 / (xs[i] - x0); 22 | } 23 | cout << "Input x: " << xs << "\n"; 24 | cout << "Input y: " << data << "\n"; 25 | 26 | LIBRPA::AnalyContPade pade(n, xs, data); 27 | // std::cout << data << "\n"; 28 | const cplxdb test_x = {1.0, 1.0}; 29 | const cplxdb ref = -1.0 / (test_x - x0); 30 | cplxdb test_y = pade.get(test_x); 31 | cout << "Reference: "<< ref << "\n"; 32 | cout << " Test: "<< test_y << "\n"; 33 | assert(fequal(ref, test_y)); 34 | } 35 | 36 | int main(int argc, char *argv[]) 37 | { 38 | test_analycont_pade(); 39 | } 40 | -------------------------------------------------------------------------------- /src/test/test_atomic_basis.cpp: -------------------------------------------------------------------------------- 1 | #include "../atomic_basis.h" 2 | 3 | #include "testutils.h" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | void test_constuctor() 10 | { 11 | LIBRPA::AtomicBasis ab; 12 | assert(ab.n_atoms == 0); 13 | assert(ab.nb_total == 0); 14 | 15 | ab.set({5, 4, 3}); 16 | assert(ab.n_atoms == 3); 17 | assert(ab.nb_total == 12); 18 | 19 | // unordered iatom-nbasis set 20 | // 3 atoms 2, 5, 4 21 | ab.set({{1, 5}, {0, 2}, {4, 4}}); 22 | assert(ab.n_atoms == 3); 23 | assert(ab.nb_total == 11); 24 | assert(8 == ab.get_global_index(2, 1)); 25 | assert(4 == ab.get_global_index(1, 2)); 26 | 27 | LIBRPA::AtomicBasis ab_from_doublemap({0, 1, 1}, {{0, 4}, {1, 8}}); 28 | assert(ab_from_doublemap.n_atoms == 3); 29 | assert(ab_from_doublemap.nb_total == (4 + 2 * 8)); 30 | } 31 | 32 | void test_indexing() 33 | { 34 | LIBRPA::AtomicBasis ab({4, 4, 8, 8, 5}); 35 | assert(ab.nb_total == 29); 36 | std::unordered_map> map_go_I_lo 37 | { 38 | {0, {0, 0}}, 39 | {4, {1, 0}}, 40 | {6, {1, 2}}, 41 | {14, {2, 6}}, 42 | {24, {4, 0}}, 43 | {28, {4, 4}}, 44 | }; 45 | int I, ilo, igo; 46 | for (const auto& go_I_lo: map_go_I_lo) 47 | { 48 | igo = go_I_lo.first; 49 | ab.get_local_index(igo, I, ilo); 50 | assert(I == go_I_lo.second.first); 51 | assert(ilo == go_I_lo.second.second); 52 | assert(igo == ab.get_global_index(I, ilo)); 53 | } 54 | } 55 | 56 | int main (int argc, char *argv[]) 57 | { 58 | test_constuctor(); 59 | test_indexing(); 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /src/test/test_atoms.cpp: -------------------------------------------------------------------------------- 1 | #include "../atoms.h" 2 | #include 3 | 4 | int main (int argc, char *argv[]) 5 | { 6 | using namespace std; 7 | double non_double; 8 | atom_mapping::single_t a_double; 9 | atom_mapping::pair_t_old apair_double; 10 | a_double[1] = 1.0; 11 | a_double[8] = -1.0; 12 | for (auto &a: get_atom(a_double)) 13 | cout << a << endl; 14 | apair_double[1][1] = 1.0; 15 | apair_double[0][3] = 0.0; 16 | for (auto &a: get_atom_pair(apair_double)) 17 | cout << a.first << " " << a.second << endl; 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /src/test/test_base_utility.cpp: -------------------------------------------------------------------------------- 1 | #include "../base_utility.h" 2 | #include 3 | 4 | int main (int argc, char *argv[]) 5 | { 6 | 7 | assert(!is_complex()); 8 | assert(is_complex>()); 9 | 10 | bool b; 11 | b = std::is_same>::type>::value; 12 | assert(b); 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /src/test/test_fitting.cpp: -------------------------------------------------------------------------------- 1 | #include "../fitting.h" 2 | #include "testutils.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | void test_levmarq_sin() 10 | { 11 | LIBRPA::utils::LevMarqFitting levmarq; 12 | 13 | // sin(ax) 14 | auto f_sin = 15 | [](double x, const std::vector &pars) { return std::sin(x*pars[0]); }; 16 | // d sin(ax) / d a = x cos(ax) 17 | auto g_sin = 18 | [](std::vector &gs, double x, const std::vector &pars) { gs[0] = x * std::cos(x*pars[0]); }; 19 | const int npars = 1; 20 | std::vector pars(npars); 21 | 22 | int ndata = 100; 23 | std::vector xs(ndata); 24 | std::vector ys(ndata); 25 | 26 | std::vector alphas { 0.5, 1.5, 2.0, -2.0, }; 27 | for (const auto &a: alphas) 28 | { 29 | for (int i = 0; i != ndata; i++) 30 | { 31 | xs[i] = (double(i) / (ndata - 1) - 0.5) * M_PI; 32 | ys[i] = sin(a * xs[i]); 33 | } 34 | // initialize 35 | pars[0] = 1.0; 36 | levmarq.fit(pars, xs, ys, f_sin, g_sin); 37 | printf("Fitted params: %f\n", pars[0]); 38 | assert(fequal(pars[0], a, 1e-8)); 39 | } 40 | } 41 | 42 | int main(int argc, char *argv[]) 43 | { 44 | test_levmarq_sin(); 45 | } 46 | -------------------------------------------------------------------------------- /src/test/test_librpa.cpp: -------------------------------------------------------------------------------- 1 | #include "../librpa.h" 2 | #include 3 | 4 | void test_set_librpa_params() 5 | { 6 | LibRPAParams params; 7 | get_default_librpa_params(¶ms); 8 | strcpy(params.output_file, "LibRPA_output.txt"); // FAIL 9 | strcpy(params.output_dir, "librpa.d.new"); // OKAY 10 | params.nfreq = 16; 11 | set_librpa_params(¶ms); 12 | } 13 | 14 | int main(int argc, char *argv[]) 15 | { 16 | test_set_librpa_params(); 17 | } 18 | -------------------------------------------------------------------------------- /src/test/test_matrix.cpp: -------------------------------------------------------------------------------- 1 | #include "../matrix.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | bool double_equal(double a, double b) 8 | { 9 | double eqthres = 1e-14; 10 | return fabs(a - b) < eqthres; 11 | } 12 | 13 | void test_power_symat() 14 | { 15 | matrix a(2, 2); 16 | a(0, 0) = 2; 17 | a(1, 1) = 1; 18 | print_matrix("a", a); 19 | matrix b = power_symat(a, 2); 20 | print_matrix("sq_a", b); 21 | assert( double_equal(b(0, 0), 4) && 22 | double_equal(b(1, 1), 1) ); 23 | a = power_symat(b, 0.5); 24 | assert( double_equal(a(0, 0), 2) && 25 | double_equal(a(1, 1), 1) ); 26 | 27 | a.zero_out(); 28 | a(0, 1) = 1; 29 | a(1, 0) = 1; 30 | print_matrix("a", a); 31 | b = power_symat(a, 2); 32 | print_matrix("sq_a", b); 33 | assert( double_equal(b(0, 0), 1) && 34 | double_equal(b(1, 1), 1) && 35 | double_equal(b(1, 0), 0) && 36 | double_equal(b(0, 1), 0)); 37 | } 38 | 39 | int main (int argc, char *argv[]) 40 | { 41 | using namespace std; 42 | matrix m1(5, 6, true); 43 | srand(time(0)); 44 | for (int i = 0; i < m1.size; i++) 45 | m1.c[i] = rand(); 46 | 47 | matrix m2(m1); 48 | assert(m1.size == m2.size); 49 | for (int i = 0; i < m1.size; i++) 50 | if ( m1.c[i] != m2.c[i] ) throw logic_error("copy constructor fail"); 51 | if (! (m1 == m2 )) throw logic_error("direct compare fail"); 52 | 53 | test_power_symat(); 54 | 55 | return 0; 56 | 57 | } 58 | 59 | -------------------------------------------------------------------------------- /src/test/test_pbc.cpp: -------------------------------------------------------------------------------- 1 | #include "../pbc.h" 2 | #include 3 | 4 | void test_is_gamma_point() 5 | { 6 | assert(is_gamma_point(Vector3_Order{0.0, 0.0, 0.0})); 7 | assert(!is_gamma_point(Vector3_Order{0.3, 0.2, 0.1})); 8 | assert(is_gamma_point(Vector3_Order{0, 0, 0})); 9 | } 10 | 11 | void test_get_R_index() 12 | { 13 | Vector3_Order period{2, 2, 2}; 14 | vector> sc222 = construct_R_grid(period); 15 | for ( int i = 0; i != sc222.size(); i++ ) 16 | printf("i=%d: x %d, y %d, z %d\n", i, sc222[i].x, sc222[i].y, sc222[i].z); 17 | Vector3_Order R {-1, -1, -1}; 18 | printf(" R: x %d, y %d, z %d\n", R.x, R.y, R.z); 19 | auto mR = -R; 20 | printf("-R: x %d, y %d, z %d\n", mR.x, mR.y, mR.z); 21 | assert(get_R_index(sc222, R) == 0); 22 | assert(get_R_index(sc222, Vector3_Order{-1, 0, -1}) == 2); 23 | assert(get_R_index(sc222, Vector3_Order{3, 3, -1}) < 0); 24 | assert(get_R_index(sc222, Vector3_Order{3, 3, -1} % period) == 0); 25 | } 26 | 27 | int main (int argc, char *argv[]) 28 | { 29 | test_is_gamma_point(); 30 | test_get_R_index(); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /src/utils_io.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "envs_io.h" 4 | 5 | namespace LIBRPA 6 | { 7 | 8 | namespace utils 9 | { 10 | 11 | //! printf that handles the stdout redirect 12 | template 13 | void lib_printf(const char* format, Args&&... args) 14 | { 15 | envs::redirect_stdout ? 16 | (fprintf(envs::pfile_redirect, format, std::forward(args)...), fflush(envs::pfile_redirect)): 17 | printf(format, std::forward(args)...); 18 | } 19 | 20 | } /* end of name space utils */ 21 | 22 | } /* end of name space LIBRPA */ 23 | -------------------------------------------------------------------------------- /src/utils_mem.cpp: -------------------------------------------------------------------------------- 1 | #include "utils_mem.h" 2 | 3 | #include 4 | #if defined(__linux__)|| defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) 5 | #include 6 | #elif defined(__APPLE__) && defined(__MACH__) 7 | #include // for malloc_zone_pressure_relief and malloc_default_zone 8 | #endif 9 | 10 | namespace LIBRPA 11 | { 12 | 13 | namespace utils 14 | { 15 | 16 | void display_free_mem() 17 | { 18 | #if defined(__linux__) 19 | std::system("free -m"); 20 | #elif defined(__APPLE__) && defined(__MACH__) 21 | std::system("vm_stat | awk 'NR==1{page_size=$8} NR>1{gsub(\".\", \"\"); free+=$3} END {print \"Free memory (in MB): \" page_size*4096/1024/1024}'"); 22 | #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) 23 | std::system("sysctl hw.physmem hw.usermem"); 24 | #endif 25 | } 26 | 27 | void release_free_mem() 28 | { 29 | #if defined(__linux__)|| defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) 30 | malloc_trim(0); 31 | #elif defined(__APPLE__) && defined(__MACH__) 32 | malloc_zone_pressure_relief(malloc_default_zone(), 0); 33 | #endif 34 | } 35 | 36 | } /* end of namespace utils */ 37 | 38 | } /* end of namespace LIBRPA */ 39 | 40 | -------------------------------------------------------------------------------- /src/utils_mem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace LIBRPA 4 | { 5 | 6 | namespace utils 7 | { 8 | 9 | /*! 10 | * @brief Display the free memory of the system. 11 | */ 12 | void display_free_mem(); 13 | 14 | /*! 15 | * @brief Release system free memory. 16 | */ 17 | void release_free_mem(); 18 | 19 | } /* end of namespace utils */ 20 | 21 | } /* end of namespace LIBRPA */ 22 | 23 | -------------------------------------------------------------------------------- /src/utils_mpi_io.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "envs_io.h" 4 | #include "envs_mpi.h" 5 | 6 | namespace LIBRPA 7 | { 8 | 9 | namespace utils 10 | { 11 | 12 | //! simlar to lib_printf, but only proc 0 will dump 13 | template 14 | void lib_printf_root(const char* format, Args&&... args) 15 | { 16 | if (envs::myid_global == 0) 17 | { 18 | envs::redirect_stdout ? 19 | fprintf(envs::pfile_redirect, format, std::forward(args)...) : 20 | printf(format, std::forward(args)...); 21 | } 22 | } 23 | 24 | //! simlar to lib_printf, but all processes will print in the order of myid 25 | template 26 | void lib_printf_coll(const char* format, Args&&... args) 27 | { 28 | for (int i = 0; i < envs::size_global; i++) 29 | { 30 | if (envs::myid_global == i) 31 | { 32 | envs::redirect_stdout ? 33 | fprintf(envs::pfile_redirect, format, std::forward(args)...) : 34 | printf(format, std::forward(args)...); 35 | } 36 | MPI_Barrier(envs::mpi_comm_global); 37 | } 38 | } 39 | 40 | } /* end of name space utils */ 41 | 42 | } /* end of name space LIBRPA */ 43 | -------------------------------------------------------------------------------- /src/vector3_order.cpp: -------------------------------------------------------------------------------- 1 | #include "vector3_order.h" 2 | 3 | template<> 4 | bool operator< ( const Vector3_Order &v1, const Vector3_Order &v2 ) 5 | { 6 | constexpr double threshold = 1E-8; 7 | if ( v1.x < v2.x - threshold ) return true; 8 | else if ( v1.x > v2.x + threshold ) return false; 9 | if ( v1.y < v2.y - threshold ) return true; 10 | else if ( v1.y > v2.y + threshold ) return false; 11 | if ( v1.z < v2.z - threshold ) return true; 12 | else if ( v1.z > v2.z + threshold ) return false; 13 | return false; 14 | } 15 | 16 | template<> 17 | bool operator< ( const Vector3_Order &v1, const Vector3_Order &v2 ) 18 | { 19 | if ( v1.x < v2.x ) return true; 20 | else if ( v1.x > v2.x ) return false; 21 | if ( v1.y < v2.y ) return true; 22 | else if ( v1.y > v2.y ) return false; 23 | if ( v1.z < v2.z ) return true; 24 | else if ( v1.z > v2.z ) return false; 25 | return false; 26 | } 27 | 28 | template<> 29 | bool operator== ( const Vector3_Order &v1, const Vector3_Order &v2 ) 30 | { 31 | constexpr double threshold = 1E-8; 32 | if ( std::abs(v1.x - v2.x) > threshold ) return false; 33 | if ( std::abs(v1.y - v2.y) > threshold ) return false; 34 | if ( std::abs(v1.z - v2.z) > threshold ) return false; 35 | return true; 36 | } 37 | 38 | template<> 39 | bool operator== ( const Vector3_Order &v1, const Vector3_Order &v2 ) 40 | { 41 | return v1.x == v2.x && v1.y == v2.y && v1.z == v2.z; 42 | } 43 | -------------------------------------------------------------------------------- /src/version.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define LIBRPA_MAJOR_VERSION 0 4 | #define LIBRPA_MINOR_VERSION 3 5 | #define LIBRPA_MICRO_VERSION 0 6 | -------------------------------------------------------------------------------- /thirdparty/cereal-1.3.0/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | *.dylib 9 | 10 | # Compiled Static libraries 11 | *.lai 12 | *.la 13 | *.a 14 | 15 | # Visual studio cruft 16 | *.opensdf 17 | *.sdf 18 | *.suo 19 | *.user 20 | */x64 21 | *\Debug* 22 | *\Release* 23 | *.log 24 | *.tlog* 25 | *.obj 26 | *.VC.db 27 | *.VC.VC.opendb 28 | *.pdb 29 | *.idb 30 | *\build_* 31 | 32 | # misc files mostly used for testing 33 | out.txt 34 | ptr.txt 35 | test.txt 36 | boost_serialize 37 | arr.txt 38 | performance 39 | include_renamed 40 | .ycm_extra_conf.py* 41 | doc/html 42 | rtti.txt 43 | doc/latex 44 | portability64 45 | portability32 46 | file.json 47 | out.xml 48 | cereal_version.out 49 | xml_ordering.out 50 | build 51 | /out/ -------------------------------------------------------------------------------- /thirdparty/cereal-1.3.0/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of cereal nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /thirdparty/cereal-1.3.0/appveyor.yml: -------------------------------------------------------------------------------- 1 | # can use variables like {build} and {branch} 2 | version: 1.2.{build} 3 | pull_requests: 4 | do_not_increment_build_number: true 5 | 6 | branches: 7 | only: 8 | - master 9 | 10 | configuration: 11 | - Debug 12 | - Release 13 | 14 | environment: 15 | matrix: 16 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 17 | VS_VERSION_MAJOR: 12 18 | BOOST_ROOT: C:\Libraries\boost_1_58_0 19 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 20 | VS_VERSION_MAJOR: 14 21 | BOOST_ROOT: C:\Libraries\boost_1_60_0 22 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 23 | VS_VERSION_MAJOR: 15 24 | BOOST_ROOT: C:\Libraries\boost_1_66_0 25 | # - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 Preview 26 | # VS_VERSION_MAJOR: 16 27 | # BOOST_ROOT: C:\Libraries\boost_1_66_0 28 | 29 | platform: 30 | - Win32 31 | - x64 32 | 33 | before_build: "scripts\\appveyor.bat" 34 | 35 | build: 36 | parallel: true 37 | project: build/cereal.sln 38 | verbosity: minimal 39 | 40 | test_script: "scripts\\appveyor.bat test" 41 | 42 | artifacts: 43 | - path: build\Testing 44 | - path: out 45 | -------------------------------------------------------------------------------- /thirdparty/cereal-1.3.0/doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Doxygen) 2 | if(DOXYGEN_FOUND) 3 | 4 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doxygen.in" "${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg" @ONLY) 5 | add_custom_target(doc 6 | COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg" 7 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.." 8 | COMMENT "Generating API documentation with Doxygen" VERBATIM 9 | ) 10 | 11 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../scripts/updatedoc.in" "${CMAKE_CURRENT_BINARY_DIR}/updatedoc.sh" @ONLY) 12 | add_custom_target(update-doc 13 | COMMAND "${CMAKE_CURRENT_BINARY_DIR}/updatedoc.sh" 14 | DEPENDS doc 15 | COMMENT "Copying documentation to gh-pages branch" VERBATIM 16 | ) 17 | 18 | endif(DOXYGEN_FOUND) -------------------------------------------------------------------------------- /thirdparty/cereal-1.3.0/doc/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 14 | 19 | 20 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /thirdparty/cereal-1.3.0/include/cereal/external/rapidjson/internal/swap.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_INTERNAL_SWAP_H_ 16 | #define CEREAL_RAPIDJSON_INTERNAL_SWAP_H_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | #if defined(__clang__) 21 | CEREAL_RAPIDJSON_DIAG_PUSH 22 | CEREAL_RAPIDJSON_DIAG_OFF(c++98-compat) 23 | #endif 24 | 25 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 26 | namespace internal { 27 | 28 | //! Custom swap() to avoid dependency on C++ header 29 | /*! \tparam T Type of the arguments to swap, should be instantiated with primitive C++ types only. 30 | \note This has the same semantics as std::swap(). 31 | */ 32 | template 33 | inline void Swap(T& a, T& b) CEREAL_RAPIDJSON_NOEXCEPT { 34 | T tmp = a; 35 | a = b; 36 | b = tmp; 37 | } 38 | 39 | } // namespace internal 40 | CEREAL_RAPIDJSON_NAMESPACE_END 41 | 42 | #if defined(__clang__) 43 | CEREAL_RAPIDJSON_DIAG_POP 44 | #endif 45 | 46 | #endif // CEREAL_RAPIDJSON_INTERNAL_SWAP_H_ 47 | -------------------------------------------------------------------------------- /thirdparty/cereal-1.3.0/include/cereal/types/functional.hpp: -------------------------------------------------------------------------------- 1 | /*! \file functional.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2016, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_FUNCTIONAL_HPP_ 31 | #define CEREAL_TYPES_FUNCTIONAL_HPP_ 32 | 33 | #include 34 | 35 | namespace cereal 36 | { 37 | //! Saving for std::less 38 | template inline 39 | void serialize( Archive &, std::less & ) 40 | { } 41 | } // namespace cereal 42 | 43 | #endif // CEREAL_TYPES_FUNCTIONAL_HPP_ 44 | -------------------------------------------------------------------------------- /thirdparty/cereal-1.3.0/include/cereal/types/map.hpp: -------------------------------------------------------------------------------- 1 | /*! \file map.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_MAP_HPP_ 31 | #define CEREAL_TYPES_MAP_HPP_ 32 | 33 | #include "cereal/types/concepts/pair_associative_container.hpp" 34 | #include 35 | 36 | #endif // CEREAL_TYPES_MAP_HPP_ 37 | -------------------------------------------------------------------------------- /thirdparty/cereal-1.3.0/include/cereal/types/unordered_map.hpp: -------------------------------------------------------------------------------- 1 | /*! \file unordered_map.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_UNORDERED_MAP_HPP_ 31 | #define CEREAL_TYPES_UNORDERED_MAP_HPP_ 32 | 33 | #include "cereal/types/concepts/pair_associative_container.hpp" 34 | #include 35 | 36 | #endif // CEREAL_TYPES_UNORDERED_MAP_HPP_ 37 | -------------------------------------------------------------------------------- /thirdparty/cereal-1.3.0/sandbox/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(sandbox_shared_lib) 2 | 3 | add_executable(sandbox sandbox.cpp) 4 | add_executable(sandbox_json sandbox_json.cpp) 5 | add_executable(sandbox_rtti sandbox_rtti.cpp) 6 | 7 | add_executable(sandbox_vs sandbox_vs.cpp) 8 | target_link_libraries(sandbox_vs sandbox_vs_dll) 9 | include_directories(sandbox_shared_lib) 10 | 11 | if((Boost_FOUND) AND NOT SKIP_PERFORMANCE_COMPARISON) 12 | add_executable(performance performance.cpp) 13 | if(MSVC) 14 | set_target_properties(performance PROPERTIES COMPILE_DEFINITIONS "BOOST_SERIALIZATION_DYN_LINK") 15 | endif() 16 | target_link_libraries(performance ${Boost_LIBRARIES}) 17 | endif() 18 | -------------------------------------------------------------------------------- /thirdparty/cereal-1.3.0/sandbox/sandbox_shared_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(sandbox_vs_dll SHARED base.cpp derived.cpp) 2 | -------------------------------------------------------------------------------- /thirdparty/cereal-1.3.0/sandbox/sandbox_shared_lib/base.cpp: -------------------------------------------------------------------------------- 1 | #ifndef CEREAL_DLL_USE 2 | #define CEREAL_DLL_MAKE 3 | #endif 4 | #include "base.hpp" 5 | 6 | template void Base::serialize 7 | ( cereal::XMLOutputArchive & ar, std::uint32_t const version ); 8 | template void Base::serialize 9 | ( cereal::XMLInputArchive & ar, std::uint32_t const version ); 10 | -------------------------------------------------------------------------------- /thirdparty/cereal-1.3.0/sandbox/sandbox_shared_lib/base.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #if defined (_WINDLL) 9 | #define DECLSPECIFIER __declspec(dllexport) 10 | #elif defined(MSC_VER) 11 | #define DECLSPECIFIER __declspec(dllimport) 12 | #else 13 | #define DECLSPECIFIER 14 | #endif 15 | 16 | int doit(); 17 | 18 | class VersionTest 19 | { 20 | public: 21 | int x; 22 | template 23 | void serialize( Archive & ar, const std::uint32_t /* version */ ) 24 | { ar( x ); } 25 | }; 26 | 27 | class Base 28 | { 29 | public: 30 | friend class cereal::access; 31 | 32 | template < class Archive > 33 | void serialize(Archive &, std::uint32_t const) {} 34 | virtual ~Base() {} 35 | }; 36 | 37 | extern template DECLSPECIFIER void Base::serialize 38 | ( cereal::XMLInputArchive & ar, std::uint32_t const version ); 39 | 40 | extern template DECLSPECIFIER void Base::serialize 41 | ( cereal::XMLOutputArchive & ar, std::uint32_t const version ); 42 | 43 | CEREAL_CLASS_VERSION(VersionTest, 1) 44 | -------------------------------------------------------------------------------- /thirdparty/cereal-1.3.0/sandbox/sandbox_shared_lib/derived.cpp: -------------------------------------------------------------------------------- 1 | #ifndef CEREAL_DLL_USE 2 | #define CEREAL_DLL_MAKE 3 | #endif 4 | #include "derived.hpp" 5 | 6 | template void Derived::serialize 7 | ( cereal::XMLOutputArchive & ar, std::uint32_t const version ); 8 | 9 | template void Derived::serialize 10 | ( cereal::XMLInputArchive & ar, std::uint32_t const version ); 11 | -------------------------------------------------------------------------------- /thirdparty/cereal-1.3.0/sandbox/sandbox_shared_lib/derived.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "base.hpp" 3 | class Derived : public Base 4 | { 5 | public: 6 | virtual ~Derived() {} 7 | 8 | private: 9 | friend class cereal::access; 10 | template 11 | void serialize(Archive & ar, std::uint32_t const) 12 | { 13 | ar(cereal::base_class(this)); 14 | } 15 | }; 16 | 17 | extern template DECLSPECIFIER void Derived::serialize 18 | ( cereal::XMLOutputArchive & ar, std::uint32_t const version ); 19 | extern template DECLSPECIFIER void Derived::serialize 20 | ( cereal::XMLInputArchive & ar, std::uint32_t const version ); 21 | 22 | CEREAL_REGISTER_TYPE(Derived) 23 | -------------------------------------------------------------------------------- /thirdparty/cereal-1.3.0/scripts/add_rapidjson_prefix.sh: -------------------------------------------------------------------------------- 1 | # Applies renaming within all of the rapidjson source files to add a cereal prefix 2 | find ./../include/cereal/external/rapidjson/ -type f -name \*.h -exec sed -i "s/RAPIDJSON_/CEREAL_RAPIDJSON_/g" {} \; 3 | echo "Remember to backport any cereal specific changes not in this version of RapidJSON!" 4 | echo "See https://github.com/USCiLab/cereal/commits/develop/include/cereal/external/rapidjson" 5 | -------------------------------------------------------------------------------- /thirdparty/cereal-1.3.0/scripts/renameincludes.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | destdir="include_renamed" 4 | 5 | echo -n "New prefix: " 6 | read newprefix 7 | 8 | cp -r include ${destdir} 9 | 10 | newprefix=$(echo ${newprefix} | sed -e 's/\//\\\//') 11 | 12 | find ${destdir} -name '*.hpp' -exec sed -i "s/#include (); 35 | } 36 | 37 | TEST_CASE("json_unordered_loads") 38 | { 39 | test_unordered_loads(); 40 | } 41 | 42 | TEST_SUITE_END(); 43 | -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/.github/workflows/action.yml: -------------------------------------------------------------------------------- 1 | name: CI Tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | GNU: 7 | runs-on: ${{ matrix.os }} 8 | strategy: 9 | fail-fast: false 10 | matrix: 11 | os: [ubuntu-20.04] 12 | compiler: [gfortran-9] 13 | 14 | env: 15 | FC: ${{ matrix.compiler }} 16 | 17 | name: ${{ matrix.os }} / ${{ matrix.compiler }} 18 | steps: 19 | - name: Checkout 20 | uses: actions/checkout@v2 21 | with: 22 | fetch-depth: 1 23 | 24 | - uses: actions/setup-python@v1 25 | with: 26 | python-version: '3.7' 27 | 28 | - name: Install Cmake 29 | run: pip3 install cmake 30 | 31 | - name: Install python dependencies 32 | run: pip3 install numpy pytest 33 | 34 | - name: Install blas, lapack and other dependencies 35 | run: sudo apt-get install libblas-dev liblapack-dev doxygen 36 | 37 | - name: Install Zofu Test Framework 38 | run: | 39 | mkdir -p external && cd external 40 | git clone https://github.com/acroucher/zofu.git 41 | mkdir zofu/build && cd zofu/build 42 | cmake \ 43 | -DCMAKE_BUILD_TYPE=release \ 44 | -DCMAKE_INSTALL_PREFIX=/home/runner/work/greenX/greenX/external/zofu/install \ 45 | -DZOFU_FORTRAN_MODULE_INSTALL_DIR:PATH=include \ 46 | .. 47 | make -j 4 48 | make install 49 | 50 | - name: Build 51 | run: | 52 | mkdir -p build 53 | cd build 54 | cmake -DENABLE_UNITTESTS=ON -DZOFU_PATH=/home/runner/work/greenX/greenX/external/zofu/install ../ 55 | make -j$(nproc) VERBOSE=1 56 | 57 | - name: Run Tests 58 | run: | 59 | cd python && pip install -e . && cd ../ 60 | cd build 61 | ctest -j1 --output-on-failure 62 | # The build system exports GX_BUILD_DIR, but I do not know how to 63 | # propagate env vars between steps in Github Actions 64 | env: 65 | GX_BUILD_DIR: "/home/runner/work/greenX/greenX/build" 66 | -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/.gitignore: -------------------------------------------------------------------------------- 1 | # .gitignore for GreenX 2 | 3 | # Build files 4 | *.o 5 | *.mod 6 | 7 | # Build directories 8 | build/ 9 | cmake-build-debug/ 10 | cmake-build-release/ 11 | python/pygreenx.egg-info/ 12 | 13 | # Binaries 14 | *.exe 15 | 16 | # Libs 17 | *.a 18 | *.dylib 19 | 20 | # IDE files 21 | .idea/ 22 | .vscode/ 23 | .devcontainer/ 24 | 25 | # Python 26 | __pycache__/ 27 | 28 | # Backups 29 | *~ 30 | 31 | # MacOSX 32 | .DS_Store 33 | 34 | # Temporary files or directories 35 | tags 36 | _*.csv 37 | 38 | # vim files 39 | *.swp 40 | *.swo 41 | *.swn 42 | 43 | # Documentation 44 | documentation/ 45 | -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/GX-AnalyticContinuation/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ----------------------------------------------- 2 | # CMakeLists for Analytic Continuation Library 3 | # ----------------------------------------------- 4 | add_library(LibGXAC "") 5 | 6 | set_target_properties(LibGXAC 7 | PROPERTIES 8 | VERSION 0.0.1 9 | SOVERSION 0.0.1 10 | LIBRARY_OUTPUT_NAME gx_ac 11 | ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_Fortran_LIB_DIRECTORY} 12 | LIBRARY_OUTPUT_DIRECTORY ${CMAKE_Fortran_LIB_DIRECTORY} 13 | ) 14 | 15 | target_include_directories(LibGXAC PUBLIC src/) 16 | 17 | target_sources(LibGXAC PRIVATE 18 | src/pade_approximant.f90 19 | ) 20 | 21 | target_link_libraries(LibGXAC GXCommon) 22 | 23 | # # ----------------------------------------------- 24 | # # Library Installation 25 | # # ----------------------------------------------- 26 | # # Install library 27 | # # Destination relative to ${CMAKE_INSTALL_PREFIX}, defined in top-level CMake 28 | # install(TARGETS LibGXAC 29 | # ARCHIVE DESTINATION lib 30 | # LIBRARY DESTINATION lib) 31 | # 32 | # # Install modules 33 | # # Destination relative to ${CMAKE_INSTALL_PREFIX}, defined in top-level CMake 34 | # install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} 35 | # DESTINATION include) 36 | 37 | # ----------------------------------------------- 38 | # Unit Testing Set-up 39 | # ----------------------------------------------- 40 | if (${ENABLE_UNITTESTS}) 41 | # Create a directory in the build folder to place generated test drivers and binaries 42 | set(UNIT_TEST_DIR "${PROJECT_BINARY_DIR}/unit_tests/analytic-continuation") 43 | file(MAKE_DIRECTORY ${UNIT_TEST_DIR}) 44 | message("-- Analytic continuation unit tests written to: ${UNIT_TEST_DIR}") 45 | 46 | # Libraries on which the unit tests depend 47 | set(LIBS_FOR_UNIT_TESTS LibGXAC) 48 | 49 | # For unit tests for many modules, put this in a loop 50 | create_unit_test_executable(TARGET_TEST_DIR ${UNIT_TEST_DIR} 51 | TEST_NAME "test_pade_approximant" 52 | REQUIRED_LIBS ${LIBS_FOR_UNIT_TESTS}) 53 | endif() 54 | 55 | -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/GX-LAPW/README.md: -------------------------------------------------------------------------------- 1 | ## GreenX library - LAPW 2 | 3 | This directory is a placeholder for the development of the LAPW (Linearized Augmented Plane Wave) component of GreenX. 4 | See the [GreenX document](Documents/Green-X.md) for the structure of the library. 5 | -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/GX-LocalizedBasis/README.md: -------------------------------------------------------------------------------- 1 | ## GreenX library - LocalizedBasis 2 | 3 | This directory is a placeholder for the development of the LocalizedBasis component of GreenX. 4 | See the [GreenX document](Documents/Green-X.md) for the structure of the library. 5 | -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/GX-PAW/README.md: -------------------------------------------------------------------------------- 1 | ## GreenX library - PAW 2 | 3 | This directory is a placeholder for the development of the PAW (Projector Augmented Waves) component of GreenX. 4 | See the [GreenX document](Documents/Green-X.md) for the structure of the library. 5 | -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/GX-PlaneWaves/README.md: -------------------------------------------------------------------------------- 1 | ## GreenX library - PlaneWaves 2 | 3 | This directory is a placeholder for the development of the PlaneWaves component of GreenX. 4 | See the [GreenX document](Documents/Green-X.md) for the structure of the library. 5 | -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/GX-TimeFrequency/api/gx_minimax.f90: -------------------------------------------------------------------------------- 1 | !> Public API for minimax library 2 | !> 3 | !> Compute minimax grid for RPA energy and GW calculation on imaginary time/frequency domain. 4 | !> Usage: 5 | !> 6 | !> ``` 7 | !> call gx_minimax_grid(..., ierr) 8 | !> if (ierr /= 0) then 9 | !> call gx_get_error_message(msg) 10 | !> handle error 11 | !> end if 12 | !> ``` 13 | !> 14 | module gx_minimax 15 | use minimax_grids, only : gx_minimax_grid, gx_minimax_grid_frequency, & 16 | gx_minimax_grid_rpa 17 | use minimax_tau, only : tau_npoints_supported 18 | use api_utilites, only: gx_check_ntau, gx_get_error_message 19 | end module gx_minimax 20 | 21 | -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/GX-TimeFrequency/src/gx_common.h: -------------------------------------------------------------------------------- 1 | 2 | #ifdef HAVE_FC_LONG_LINES 3 | #define _REGISTER_EXC(msg) call register_exc(msg, filename=__FILE__, lineno=__LINE__) 4 | #else 5 | #define _REGISTER_EXC(msg) call register_exc(msg) 6 | #endif 7 | -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/GX-common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # CMakeLists.txt for GreenX Common Modules, required by all other libs in 2 | # the package 3 | 4 | add_library(GXCommon "") 5 | 6 | set_target_properties(GXCommon 7 | PROPERTIES 8 | VERSION 0.0.1 9 | SOVERSION 0.0.1 10 | LIBRARY_OUTPUT_NAME GXCommon 11 | ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_Fortran_LIB_DIRECTORY} 12 | LIBRARY_OUTPUT_DIRECTORY ${CMAKE_Fortran_LIB_DIRECTORY} 13 | ) 14 | 15 | target_include_directories(GXCommon PUBLIC src/) 16 | 17 | target_sources(GXCommon PRIVATE 18 | src/kinds.f90 19 | src/constants.f90 20 | src/unit_conversion.f90 21 | src/error_handling.f90 22 | ) 23 | 24 | # # Install library 25 | # # Destination relative to ${CMAKE_INSTALL_PREFIX}, defined in the top-level 26 | # # CMakeLists.txt 27 | # install(TARGETS GXCommon 28 | # ARCHIVE DESTINATION lib 29 | # LIBRARY DESTINATION lib) 30 | 31 | # # Install modules 32 | # # Destination relative to ${CMAKE_INSTALL_PREFIX}, defined in the top-level 33 | # ## CMakeLists.txt 34 | # install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} 35 | # DESTINATION include) 36 | -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/GX-common/src/constants.f90: -------------------------------------------------------------------------------- 1 | !> Physical constants (and pi), defined according to [CODATA 2018])(http://physics.nist.gov/constants) 2 | !> 3 | !> For all units, please: 4 | !> a) Define using CODATA 2018 (see reference below) 5 | !> b) Define using double precision (dp). For example, elec_mass = 9.10938370e-31_dp; 6 | !> c) Use descriptive naming 7 | !> 8 | !> See the 20th May 2019 redefinition of the SI units and CODATA 2018. 9 | !> Eite Tiesinga, Peter J. Mohr, David B. Newell, and Barry N. Taylor (2019) 10 | !> "The 2018 CODATA Recommended Values of the Fundamental Physical Constants" 11 | !> (Web Version 8.0). Database developed by J. Baker, M. Douma, and S. Kotochigova. 12 | !> Available at http://physics.nist.gov/constants, 13 | !> National Institute of Standards and Technology, Gaithersburg, MD 20899. 14 | module constants 15 | use kinds, only: dp 16 | implicit none 17 | private 18 | 19 | !> Pi 20 | real(kind=dp), parameter, public :: pi = 3.14159265358979323846264338_dp 21 | !> Fixed-length character 22 | character(len=1), parameter, public :: ch10 = char(10) 23 | !> Arbitrary error length 24 | integer, parameter, public :: err_len = 1024 25 | 26 | end module constants 27 | -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/GX-common/src/error_handling.f90: -------------------------------------------------------------------------------- 1 | module error_handling 2 | use constants, only: ch10, err_len 3 | implicit none 4 | private 5 | 6 | !> Error message 7 | character(len=err_len), public, protected :: error_message__ = "No Error reported so far" 8 | 9 | public :: register_exc 10 | 11 | contains 12 | 13 | !> Write an error to file. 14 | subroutine register_exc(msg, filename, line_number) 15 | 16 | !> Error message 17 | character(len=*), intent(in) :: msg 18 | !> File name 19 | character(len=*), optional, intent(in) :: filename 20 | !> Line number 21 | integer, optional, intent(in) :: line_number 22 | 23 | integer :: line_num 24 | character(len=err_len) :: my_filename 25 | 26 | my_filename = "Unknown File" 27 | if (present(filename)) then 28 | my_filename = trim(filename) 29 | end if 30 | 31 | line_num = 0 32 | if (present(line_number)) then 33 | line_num = line_number 34 | end if 35 | 36 | write (error_message__, '(7a,i0,7a)') ch10, & 37 | "--- ! ERROR", ch10, & 38 | "src_file: ", trim(my_filename), ch10, & 39 | "src_line: ", line_num, ch10, & 40 | "message: |", ch10, trim(msg), ch10, & 41 | "...", ch10 42 | 43 | end subroutine register_exc 44 | 45 | end module error_handling 46 | -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/GX-common/src/kinds.f90: -------------------------------------------------------------------------------- 1 | !> Precision constants 2 | module kinds 3 | implicit none 4 | 5 | !> Single precision 6 | integer, parameter, public :: sp = selected_real_kind(6, 30) 7 | !> Double precision 8 | integer, parameter, public :: dp = selected_real_kind(14, 200) 9 | !> Medium length character 10 | integer, parameter, public :: medium_char = 100 11 | !> Long length character 12 | integer, parameter, public :: long_char = 200 13 | 14 | end module kinds 15 | -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/GX-common/src/unit_conversion.f90: -------------------------------------------------------------------------------- 1 | !> Unit Conversion, defined according to [CODATA 2018])(http://physics.nist.gov/constants) 2 | !> 3 | !> For all units, please: 4 | !> a) Define using CODATA 2018 5 | !> b) Define using double precision (dp). For example, elec_mass = 9.10938370e-31_dp; 6 | !> c) Use descriptive naming 7 | !> 8 | !> See the 20th May 2019 redefinition of the SI units and CODATA 2018. 9 | !> Eite Tiesinga, Peter J. Mohr, David B. Newell, and Barry N. Taylor (2019) 10 | !> "The 2018 CODATA Recommended Values of the Fundamental Physical Constants" 11 | !> (Web Version 8.0). Database developed by J. Baker, M. Douma, and S. Kotochigova. 12 | !> Available at http://physics.nist.gov/constants, 13 | !> National Institute of Standards and Technology, Gaithersburg, MD 20899. 14 | ! 15 | module unit_conversion 16 | use kinds, only: dp 17 | implicit none 18 | private 19 | 20 | !> Bohr to angstrom 21 | real(kind=dp), parameter, public :: bohr_to_angstrom = 0.529177210903_dp 22 | 23 | end module 24 | -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/GX-q=0/README.md: -------------------------------------------------------------------------------- 1 | ## GreenX library - q=0 2 | 3 | This directory is a placeholder for the development of the q=0 (singularity treatment) component of GreenX. 4 | See the [GreenX document](Documents/Green-X.md) for the structure of the library. 5 | -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/cmake/StandardProjectSettings.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Check compiler is supported 3 | if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") 4 | if (NOT ${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER "6.9.9" ) 5 | message(FATAL_ERROR "The minimum supported version of GCC is 7.0.0") 6 | endif() 7 | elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") 8 | #TODO(Alex) Add minimum version for Intel 9 | endif() 10 | 11 | # MYZ: disable modifying CMAKE_BUILD_TYPE at sub-project level. 12 | # Otherwise segment fault is observed for test_complexmatrix. 13 | # Also the default build type to RelWithDebInfo will remove all asserts, 14 | # making current unit tests not working at all. 15 | # Note: 16 | # RelWithDebInfo will remove all asserts 17 | # # Set default build type if none was specified 18 | # if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 19 | # message( 20 | # STATUS "Setting build type to 'RelWithDebInfo' as none was specified.") 21 | # 22 | # # Sets the variable in the CACHE. Can view/modify with ccmake 23 | # # FORCE will overwrite if variable is already in the CACHE 24 | # set(CMAKE_BUILD_TYPE 25 | # RelWithDebInfo 26 | # CACHE STRING "Choose the type of build." FORCE) 27 | # 28 | # # Set the possible values of build type 29 | # set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" 30 | # "RelWithDebInfo") 31 | # endif() 32 | -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/developers.md: -------------------------------------------------------------------------------- 1 | # For Developers 2 | 3 | Documentation and points of discussion for GreenX developers. 4 | 5 | ## Portability 6 | 7 | * The minimax library has been tested on: 8 | - macOS Catalina, with GCC9 and openBLAS 9 | - Ubuntu-20.04, with GCC9 and blas/lapack 10 | 11 | * There has been no testing with Intel or MKL. This should be done. 12 | 13 | ## Testing 14 | 15 | The test framework is currently set up such that one: 16 | * Writes a .f90 test driver, which calls some GreenX API 17 | * Writes a .py file to: 18 | * Supply inputs to the .f90 driver 19 | * Execute the driver binary 20 | * Parse the outputs of the test 21 | * Make assertions 22 | 23 | This has some requirements, and some technical open questions associated with it. 24 | Two better approaches would be to: 25 | 26 | a). Replace a fortran unit testing framework. In most cases, this is more appropriate. 27 | This would remove the need for all I/O and path-setting. 28 | 29 | b). Call the respective fortran library directly from python, removing the need 30 | for the .f90 driver, and removing all the complications associated with 31 | consistent binary/file paths. 32 | 33 | ### Issues with the Test Set Up 34 | 35 | #### Test Binary Name 36 | 37 | * The fortran binary name is specified in the python test. 38 | - If one enforces the convention that the .f90 and .py files must have the same 39 | prefix, the binary name can automatically be retrieved by python 40 | `os.path.basename(__file__).py` 41 | 42 | #### Choice of Test Framework 43 | 44 | * One should test the library by directly calling from python, however Alex 45 | (thinks) memory allocation in the library prevents this. 46 | - Refactor the library, such that the caller handles the memory. 47 | 48 | * Using a fortran test framework OR calling the library from python removes 49 | all of the issues with the test set-up. -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/python/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Srlive1201/LibRPA/4676a0d845024e73aa6e92f4aca843a2bbb4c847/thirdparty/greenX-6ff8a00/python/__init__.py -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/python/pygreenx/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Srlive1201/LibRPA/4676a0d845024e73aa6e92f4aca843a2bbb4c847/thirdparty/greenX-6ff8a00/python/pygreenx/__init__.py -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/python/pygreenx/utilities.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | 4 | def find_test_binary(root, binary_name: str) -> Path: 5 | """ Recursively search the project for a `binary_name`. 6 | 7 | Reference: 8 | https://stackoverflow.com/questions/18394147/how-to-do-a-recursive-sub-folder-search-and-return-files-in-a-list 9 | This also has a generator option 10 | 11 | NOTE. This will get slow as one adds many tests. 12 | Would be better to pass the binary location to the test, however 13 | one has to deal with pytest's own set of command line args. 14 | 15 | :param root: Root directory in which to begin recursive search. 16 | :param binary_name: Binary name. 17 | :return: binary name prepended by its full path. 18 | """ 19 | found = [path for path in Path(root).rglob(binary_name) if path.is_file()] 20 | assert len(found) == 1, f"No binary, or multiple binaries were found with the same name: {found}" \ 21 | f"Began searching from root = {root}" 22 | return found[0] 23 | -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/python/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=42.0", "wheel"] 3 | build-backend = "setuptools.build_meta" -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/python/setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = pygreenx 3 | description = Python tools and API for the GreenX library 4 | author = Alexander Buccheri 5 | license = Apache 2 6 | platforms = unix, linux, osx 7 | version = 0.0.1 8 | 9 | [options] 10 | packages = pygreenx 11 | python_requires = >=3.7 12 | install_requires = 13 | numpy>=1.18.0 14 | pytest>=5.4.0 15 | package_dir = 16 | =. 17 | -------------------------------------------------------------------------------- /thirdparty/greenX-6ff8a00/python/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | if __name__ == "__main__": 4 | setup() --------------------------------------------------------------------------------