Skip to content

Commit

Permalink
Fix all the Examples
Browse files Browse the repository at this point in the history
  • Loading branch information
srbhp committed Dec 15, 2023
1 parent 445240b commit 5479d22
Show file tree
Hide file tree
Showing 24 changed files with 667 additions and 599 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,11 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) # This is just for us, we do prefer pthreads
# Create Documentation
add_subdirectory("nrgcore")
add_subdirectory("docs")

#add_subdirectory("examples/entropySIAM")
# add all sub directories ..
# file(GLOB V_GLOB LIST_DIRECTORIES true "examples/*")
# foreach(item ${V_GLOB})
# if(IS_DIRECTORY ${item})
# add_subdirectory(${item})
# endif()
# endforeach()
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<h1 align="center">
<a href="https://srbhp.github.io/nrgplusplus/">Documentation</a> </h1>

</h1>
![Documentation](https://github.com/github/docs/actions/workflows/cmake.yml/badge.svg)

## ⚠ This is a work in progress repository


Expand Down
5 changes: 2 additions & 3 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ find_package(Sphinx REQUIRED)

# Find all the public headers
# get_target_property(NRGCore_PUBLIC_HEADER_DIR NRGCore INTERFACE_INCLUDE_DIRECTORIES)
file(GLOB_RECURSE NRGCore_PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*/*.hpp)
file(GLOB_RECURSE rst_dependent_files ${CMAKE_CURRENT_SOURCE_DIR}/*rst )

set(DOXYGEN_INPUT_DIR ${PROJECT_SOURCE_DIR}/nrgcore)
set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/doxygen)
Expand All @@ -19,12 +19,11 @@ file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR})

# Only regenerate Doxygen when the Doxyfile or public headers change
add_custom_command(OUTPUT ${DOXYGEN_INDEX_FILE}
DEPENDS ${NRGCore_PUBLIC_HEADERS}
DEPENDS ${rst_dependent_files}
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
COMMENT "Generating docs"
VERBATIM)

# Nice named target so we can run the job easily
add_custom_target(Doxygen ALL DEPENDS ${DOXYGEN_INDEX_FILE})

Expand Down
12 changes: 8 additions & 4 deletions examples/entropyKondo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

project(entropyKondo LANGUAGES CXX)
# project(entropySIAM LANGUAGES CXX)
# use folder name for the project name
get_filename_component(ProjectId ${CMAKE_CURRENT_LIST_DIR} NAME)
string(REPLACE " " "_" ProjectId ${ProjectId})
project(${ProjectId} C CXX)

##########Dependencies########
find_package(HDF5 COMPONENTS CXX HL)
include_directories(${HDF5_INCLUDE_DIR})
set(LINK_LIBS ${LINK_LIBS} ${HDF5_LIBRARIES})

########################################################################

################
Expand All @@ -23,11 +28,10 @@ target_link_libraries(
#openblas
#cblas
#lapack
hdf5
hdf5_cpp
HDF5::HDF5
# MKL::MKL
# mkl_intel_lp64 mkl_intel_thread mkl_core
mkl_intel_lp64 mkl_core mkl_intel_thread iomp5
mkl_intel_lp64 mkl_core mkl_intel_thread mkl_core iomp5
)


11 changes: 7 additions & 4 deletions examples/entropySIAM/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

project(entropySIAM LANGUAGES CXX)

# project(entropySIAM LANGUAGES CXX)
# use folder name for the project name
get_filename_component(ProjectId ${CMAKE_CURRENT_LIST_DIR} NAME)
string(REPLACE " " "_" ProjectId ${ProjectId})
project(${ProjectId} C CXX)

##########Dependencies########
find_package(HDF5 COMPONENTS CXX HL)
include_directories(${HDF5_INCLUDE_DIR})
set(LINK_LIBS ${LINK_LIBS} ${HDF5_LIBRARIES})

########################################################################

################
Expand All @@ -24,8 +28,7 @@ target_link_libraries(
#openblas
#cblas
#lapack
hdf5
hdf5_cpp
HDF5::HDF5
# MKL::MKL
# mkl_intel_lp64 mkl_intel_thread mkl_core
mkl_intel_lp64 mkl_core mkl_intel_thread mkl_core iomp5
Expand Down
25 changes: 17 additions & 8 deletions examples/fdmSpectrumSiam/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

project(fdmSpectrum LANGUAGES CXX)

# project(entropySIAM LANGUAGES CXX)
# use folder name for the project name
get_filename_component(ProjectId ${CMAKE_CURRENT_LIST_DIR} NAME)
string(REPLACE " " "_" ProjectId ${ProjectId})
project(${ProjectId} C CXX)

##########Dependencies########
find_package(HDF5 COMPONENTS CXX HL)
include_directories(${HDF5_INCLUDE_DIR})
set(LINK_LIBS ${LINK_LIBS} ${HDF5_LIBRARIES})
#lapack


########################################################################

################
file(GLOB sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
file(GLOB headers CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
######################################################

add_executable(${PROJECT_NAME}.out ${sources} ${headers})



target_link_libraries(
${PROJECT_NAME}.out NRG
#MKL::MKL
mkl_intel_lp64 mkl_intel_thread mkl_core
#openblas
#cblas
#lapack
hdf5
hdf5_cpp
HDF5::HDF5
# MKL::MKL
# mkl_intel_lp64 mkl_intel_thread mkl_core
mkl_intel_lp64 mkl_core mkl_intel_thread mkl_core iomp5
)


21 changes: 12 additions & 9 deletions examples/fdmSpectrumSiam/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#include "nrgcore/nrgcore.hpp"
#include "nrgcore/sysOperator.hpp"
#include <iostream>
double LAMBDA = 3.00; // Dont do this
double hopping(int site) {
const double LAMBDA = 3.00; // Dont do this
double hopping(int site) {
return 0.5 * (1.0 + 1.0 / LAMBDA) * (1. - std::pow(LAMBDA, -site - 1)) /
std::sqrt((1.0 - std::pow(LAMBDA, -2. * site - 1)) *
(1.0 - std::pow(LAMBDA, -2. * site - 3)));
(1.0 - std::pow(LAMBDA, -2. * site - 3)));
}
int main() {
h5stream::h5stream rfile("resultsTc.h5");
Expand Down Expand Up @@ -39,8 +39,9 @@ int main() {
// Bulla's RMP
std::vector<qOperator> dUpDownDagger; // Up and Down particle number
{
fermionBasis spinhalfBasis(2); // Number of fermion channels/spins
auto f_dag_raw = spinhalfBasis.get_raw_f_dag_operator();
fermionBasis spinhalfBasis(
2, fermionBasis::chargeAndSpin); // Number of fermion channels/spins
auto f_dag_raw = spinhalfBasis.get_raw_f_dag_operator();
// set f_operator
// Total Number of particle
auto ntotal = f_dag_raw[0].dot(f_dag_raw[0].cTranspose());
Expand Down Expand Up @@ -70,8 +71,9 @@ int main() {
// dUpDownDagger[0].display();
for (auto &aa : dUpDownDagger) {
for (const auto &[key, value] : *aa.getMap()) {
for (size_t i = 0; i < value.size(); i++)
sum += std::pow(value.at(i), 2);
for (double i : value) {
sum += std::pow(i, 2);
}
}
}
std::cout << "dUpDownDagger Sum :" << sum << std::endl;
Expand Down Expand Up @@ -122,8 +124,9 @@ int main() {
// dUpDownDagger[0].display();
for (auto &aa : dUpDownDagger) {
for (const auto &[key, value] : *aa.getMap()) {
for (size_t i = 0; i < value.size(); i++)
sum += std::pow(value.at(i), 2);
for (double i : value) {
sum += std::pow(i, 2);
}
}
}
std::cout << "dUpDownDagger Sum :" << sum << std::endl;
Expand Down
19 changes: 11 additions & 8 deletions examples/fdmSpectrumTwoChannel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

project(fdmSpectrum LANGUAGES CXX)

# project(entropySIAM LANGUAGES CXX)
# use folder name for the project name
get_filename_component(ProjectId ${CMAKE_CURRENT_LIST_DIR} NAME)
string(REPLACE " " "_" ProjectId ${ProjectId})
project(${ProjectId} C CXX)

##########Dependencies########
find_package(HDF5 COMPONENTS CXX HL)
include_directories(${HDF5_INCLUDE_DIR})
set(LINK_LIBS ${LINK_LIBS} ${HDF5_LIBRARIES})
#lapack
find_package(LAPACK)
find_package(BLAS)
set(BLA_VENDOR Intel10_64lp)

########################################################################

################
file(GLOB sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
file(GLOB headers CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
######################################################

add_executable(${PROJECT_NAME}.out ${sources} ${headers})


Expand All @@ -24,8 +28,7 @@ target_link_libraries(
#openblas
#cblas
#lapack
hdf5
hdf5_cpp
HDF5::HDF5
# MKL::MKL
# mkl_intel_lp64 mkl_intel_thread mkl_core
mkl_intel_lp64 mkl_core mkl_intel_thread mkl_core iomp5
Expand Down
11 changes: 6 additions & 5 deletions examples/fdmSpectrumTwoChannel/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#include "nrgcore/sysOperator.hpp"
#include <iostream>
#include <string>
double LAMBDA = 3.00; // Dont do this
double hopping(int site) {
const double LAMBDA = 3.00; // Dont do this
double hopping(int site) {
return 0.5 * (1.0 + 1.0 / LAMBDA) * (1. - std::pow(LAMBDA, -site - 1)) /
std::sqrt((1.0 - std::pow(LAMBDA, -2. * site - 1)) *
(1.0 - std::pow(LAMBDA, -2. * site - 3)));
(1.0 - std::pow(LAMBDA, -2. * site - 3)));
}
int main() {
timer mtime("Total time : ");
Expand Down Expand Up @@ -47,8 +47,9 @@ int main() {
// Bulla's RMP
std::vector<qOperator> dUpDownDagger; // Up and Down particle number
{
fermionBasis spinhalfBasis(2); // Number of fermion channels/spins
auto f_dag_raw = spinhalfBasis.get_raw_f_dag_operator();
fermionBasis spinhalfBasis(
2, fermionBasis::chargeAndSpin); // Number of fermion channels/spins
auto f_dag_raw = spinhalfBasis.get_raw_f_dag_operator();
// set f_operator
// Total Number of particle
auto ntotal = f_dag_raw[0].dot(f_dag_raw[0].cTranspose());
Expand Down
16 changes: 10 additions & 6 deletions examples/freeModel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

project(rgflowKondo LANGUAGES CXX)
# project(entropySIAM LANGUAGES CXX)
# use folder name for the project name
get_filename_component(ProjectId ${CMAKE_CURRENT_LIST_DIR} NAME)
string(REPLACE " " "_" ProjectId ${ProjectId})
project(${ProjectId} C CXX)

##########Dependencies########
find_package(HDF5 COMPONENTS CXX HL)
include_directories(${HDF5_INCLUDE_DIR})
set(LINK_LIBS ${LINK_LIBS} ${HDF5_LIBRARIES})
#lapack

########################################################################

################
Expand All @@ -24,10 +28,10 @@ target_link_libraries(
#openblas
#cblas
#lapack
hdf5
hdf5_cpp
MKL::MKL
mkl_intel_lp64 mkl_intel_thread mkl_core
HDF5::HDF5
# MKL::MKL
# mkl_intel_lp64 mkl_intel_thread mkl_core
mkl_intel_lp64 mkl_core mkl_intel_thread mkl_core iomp5
)


Loading

0 comments on commit 5479d22

Please sign in to comment.