From dd391c7364cc3f2f090284a137631759a344aac5 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Tue, 10 Aug 2021 21:26:02 +0200 Subject: [PATCH 01/35] port over the parts from #141 --- src/libshowcase.cpp | 91 +++++++++++++++++++++++++++++++++++++++++++++ src/libshowcase.h | 4 ++ src/libshowcase.i | 11 ++++++ 3 files changed, 106 insertions(+) create mode 100644 src/libshowcase.cpp create mode 100644 src/libshowcase.h create mode 100644 src/libshowcase.i diff --git a/src/libshowcase.cpp b/src/libshowcase.cpp new file mode 100644 index 0000000..aa8c3dc --- /dev/null +++ b/src/libshowcase.cpp @@ -0,0 +1,91 @@ +#include +#include +#include + +//include the MARQOV library +#include "libmarqov/libmarqov.h" + +//include the RegularLattice +#include "lattice/regular_hypercubic.h" + +#include "hamiltonian/Heisenberg.h" +#include "hamiltonian/Ising.h" +#include "hamiltonian/Phi4.h" + +using namespace std; +using namespace MARQOV; + +int pyising(std::string path, int len, double beta, double J) +{ + RegularHypercubic mylatt(len, 2); //2D len x len lattice + + //MARQOV::Config stores a set of Monte Carlo related parameters + MARQOV::Config mp(path); + mp.setnmetro(5); + mp.setncluster(8/2); + mp.setwarmupsteps(500); + mp.setgameloopsteps(3000); + + // A section for setting our Hamiltonian parameters, J, and the inverse temperature beta + auto hp = make_tuple(beta, J); + //Let's create some parameters, a temperature scan for the scheduler to work on. + //prepare the arguments + auto args = make_tuple(std::ref(mylatt), mp, hp); + + //execute core + auto mysim = makeCore >(args); + mysim.init(); + mysim.wrmploop(); + mysim.gameloop(); + return 0; +} + +int pyHeisenberg(std::string path, int len, double beta, double J) +{ + RegularHypercubic mylatt(len, 2); //2D len x len lattice +//MARQOV::Config stores a set of Monte Carlo related parameters + MARQOV::Config mp(path); + mp.setnmetro(5); + mp.setncluster(8/2); + mp.setwarmupsteps(500); + mp.setgameloopsteps(3000); + + // A section for setting our Hamiltonian parameters, J, and the inverse temperature beta + auto hp = make_tuple(beta, J); + //Let's create some parameters, a temperature scan for the scheduler to work on. + //prepare the arguments + auto args = make_tuple(std::ref(mylatt), mp, hp); + + //execute core + auto mysim = makeCore >(args); + mysim.init(); + mysim.wrmploop(); + mysim.gameloop(); + return 0; +} + +int pyPhi4(std::string path, int len, double beta, double lambda, double mass) +{ + RegularHypercubic mylatt(len, 2); //2D len x len lattice + + //MARQOV::Config stores a set of Monte Carlo related parameters + MARQOV::Config mp(path); + mp.setnmetro(5); + mp.setncluster(8/2); + mp.setwarmupsteps(500); + mp.setgameloopsteps(3000); + + // A section for setting our Hamiltonian parameters, J, and the inverse temperature beta + auto hp = make_tuple(beta, beta, lambda, mass); + //Let's create some parameters, a temperature scan for the scheduler to work on. + //prepare the arguments + auto args = make_tuple(std::ref(mylatt), mp, hp); + + //execute core + auto mysim = makeCore >(args); + mysim.init(); + mysim.wrmploop(); + mysim.gameloop(); + return 0; +} +//} diff --git a/src/libshowcase.h b/src/libshowcase.h new file mode 100644 index 0000000..2c01acb --- /dev/null +++ b/src/libshowcase.h @@ -0,0 +1,4 @@ +#include +int pyising(std::string path, int len, double beta, double J); +int pyHeisenberg(std::string path, int len, double beta, double J); +int pyPhi4(std::string, int len, double beta, double lambda, double mass); diff --git a/src/libshowcase.i b/src/libshowcase.i new file mode 100644 index 0000000..6273ef9 --- /dev/null +++ b/src/libshowcase.i @@ -0,0 +1,11 @@ +%module showcase +/*SWIG has a library for doing the string mappings.*/ +%include "std_string.i" +%{ + +/* Includes the header in the wrapper code */ +#include "libshowcase.h" +%} + +/* Parse the header file to generate wrappers */ +%include "libshowcase.h" \ No newline at end of file -- GitLab From 44ce6586a1abbe67630777a4c02fe3a576eb4833 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Tue, 10 Aug 2021 21:36:37 +0200 Subject: [PATCH 02/35] find SWIG in cmake --- src/CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b0fdfb2..c3c47da 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,3 +48,16 @@ CHECK_FUNCTION_EXISTS(alphasort HAVE_ALPHASORT) CHECK_FUNCTION_EXISTS(readdir_r HAVE_READDIR_R) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libmarqov/util/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/libmarqov/util/config.h) + +# Let's check whether we have SWIG and can hence build the language bindings. + +if(CMAKE_VERSION VERSION_GREATER 3.7) + find_package(SWIG 3.0 COMPONENTS python) + if(SWIG_FOUND) + message("SWIG found: ${SWIG_EXECUTABLE}.") + #specific language queries not supported in cmake 3-16... + # if(NOT SWIG_python_FOUND) + # message(WARNING "SWIG python bindings cannot be generated") + # endif() + endif() +endif \ No newline at end of file -- GitLab From 05336b39ec5570c8e63ba460a5e2b1d91de284a9 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Tue, 10 Aug 2021 21:39:11 +0200 Subject: [PATCH 03/35] expose dimensionality --- src/libshowcase.cpp | 11 +++++------ src/libshowcase.h | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/libshowcase.cpp b/src/libshowcase.cpp index aa8c3dc..69da53c 100644 --- a/src/libshowcase.cpp +++ b/src/libshowcase.cpp @@ -15,9 +15,9 @@ using namespace std; using namespace MARQOV; -int pyising(std::string path, int len, double beta, double J) +int pyIsing(std::string path, int dim, int len, double beta, double J) { - RegularHypercubic mylatt(len, 2); //2D len x len lattice + RegularHypercubic mylatt(len, dim); //2D len x len lattice //MARQOV::Config stores a set of Monte Carlo related parameters MARQOV::Config mp(path); @@ -40,9 +40,9 @@ int pyising(std::string path, int len, double beta, double J) return 0; } -int pyHeisenberg(std::string path, int len, double beta, double J) +int pyHeisenberg(std::string path, int dim, int len, double beta, double J) { - RegularHypercubic mylatt(len, 2); //2D len x len lattice + RegularHypercubic mylatt(len, dim); //2D len x len lattice //MARQOV::Config stores a set of Monte Carlo related parameters MARQOV::Config mp(path); mp.setnmetro(5); @@ -64,7 +64,7 @@ int pyHeisenberg(std::string path, int len, double beta, double J) return 0; } -int pyPhi4(std::string path, int len, double beta, double lambda, double mass) +int pyPhi4(std::string path, int dim, int len, double beta, double lambda, double mass) { RegularHypercubic mylatt(len, 2); //2D len x len lattice @@ -88,4 +88,3 @@ int pyPhi4(std::string path, int len, double beta, double lambda, double mass) mysim.gameloop(); return 0; } -//} diff --git a/src/libshowcase.h b/src/libshowcase.h index 2c01acb..c2e8ff6 100644 --- a/src/libshowcase.h +++ b/src/libshowcase.h @@ -1,4 +1,4 @@ #include -int pyising(std::string path, int len, double beta, double J); -int pyHeisenberg(std::string path, int len, double beta, double J); -int pyPhi4(std::string, int len, double beta, double lambda, double mass); +int pyIsing(std::string path, int dim, int len, double beta, double J); +int pyHeisenberg(std::string path, int dim, int len, double beta, double J); +int pyPhi4(std::string path, int dim, int len, double beta, double lambda, double mass); -- GitLab From a945837b05f7ef29bc1a4d9683d7d3fbdc402613 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Tue, 10 Aug 2021 23:33:03 +0200 Subject: [PATCH 04/35] more models in the show case --- src/libshowcase.cpp | 140 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 134 insertions(+), 6 deletions(-) diff --git a/src/libshowcase.cpp b/src/libshowcase.cpp index 69da53c..c74ff8a 100644 --- a/src/libshowcase.cpp +++ b/src/libshowcase.cpp @@ -17,7 +17,7 @@ using namespace MARQOV; int pyIsing(std::string path, int dim, int len, double beta, double J) { - RegularHypercubic mylatt(len, dim); //2D len x len lattice + RegularHypercubic mylatt(len, dim); //nD len x len lattice //MARQOV::Config stores a set of Monte Carlo related parameters MARQOV::Config mp(path); @@ -28,7 +28,6 @@ int pyIsing(std::string path, int dim, int len, double beta, double J) // A section for setting our Hamiltonian parameters, J, and the inverse temperature beta auto hp = make_tuple(beta, J); - //Let's create some parameters, a temperature scan for the scheduler to work on. //prepare the arguments auto args = make_tuple(std::ref(mylatt), mp, hp); @@ -42,7 +41,7 @@ int pyIsing(std::string path, int dim, int len, double beta, double J) int pyHeisenberg(std::string path, int dim, int len, double beta, double J) { - RegularHypercubic mylatt(len, dim); //2D len x len lattice + RegularHypercubic mylatt(len, dim); //nD len x len lattice //MARQOV::Config stores a set of Monte Carlo related parameters MARQOV::Config mp(path); mp.setnmetro(5); @@ -52,7 +51,6 @@ int pyHeisenberg(std::string path, int dim, int len, double beta, double J) // A section for setting our Hamiltonian parameters, J, and the inverse temperature beta auto hp = make_tuple(beta, J); - //Let's create some parameters, a temperature scan for the scheduler to work on. //prepare the arguments auto args = make_tuple(std::ref(mylatt), mp, hp); @@ -66,7 +64,7 @@ int pyHeisenberg(std::string path, int dim, int len, double beta, double J) int pyPhi4(std::string path, int dim, int len, double beta, double lambda, double mass) { - RegularHypercubic mylatt(len, 2); //2D len x len lattice + RegularHypercubic mylatt(len, dim); //nD len x len lattice //MARQOV::Config stores a set of Monte Carlo related parameters MARQOV::Config mp(path); @@ -77,7 +75,6 @@ int pyPhi4(std::string path, int dim, int len, double beta, double lambda, doubl // A section for setting our Hamiltonian parameters, J, and the inverse temperature beta auto hp = make_tuple(beta, beta, lambda, mass); - //Let's create some parameters, a temperature scan for the scheduler to work on. //prepare the arguments auto args = make_tuple(std::ref(mylatt), mp, hp); @@ -88,3 +85,134 @@ int pyPhi4(std::string path, int dim, int len, double beta, double lambda, doubl mysim.gameloop(); return 0; } + +int pyAshkinTeller(std::string path, int dim, int len, double beta, double J, double K) +{ + RegularHypercubic mylatt(len, dim); //nD len x len lattice + + //MARQOV::Config stores a set of Monte Carlo related parameters + MARQOV::Config mp(path); + mp.setnmetro(5); + mp.setncluster(8/2); + mp.setwarmupsteps(500); + mp.setgameloopsteps(3000); + + // A section for setting our Hamiltonian parameters, and beta + auto hp = make_tuple(beta, beta, J, K); + + //prepare the arguments + auto args = make_tuple(std::ref(mylatt), mp, hp); + + //execute core + auto mysim = makeCore(args); + mysim.init(); + mysim.wrmploop(); + mysim.gameloop(); + return 0; +} + +int pyBlumeCapel(std::string path, int dim, int len, double beta, double J, double D) +{ + RegularHypercubic mylatt(len, dim); //nD len x len lattice + + //MARQOV::Config stores a set of Monte Carlo related parameters + MARQOV::Config mp(path); + mp.setnmetro(5); + mp.setncluster(8/2); + mp.setwarmupsteps(500); + mp.setgameloopsteps(3000); + + // A section for setting our Hamiltonian parameters, and beta + auto hp = make_tuple(beta, beta, J, D); + + //prepare the arguments + auto args = make_tuple(std::ref(mylatt), mp, hp); + + //execute core + auto mysim = makeCore >(args); + mysim.init(); + mysim.wrmploop(); + mysim.gameloop(); + return 0; +} + +int pyBEG(std::string path, int dim, int len, double beta, double J, double D, double K) +{ + RegularHypercubic mylatt(len, dim); //nD len x len lattice + + //MARQOV::Config stores a set of Monte Carlo related parameters + MARQOV::Config mp(path); + mp.setnmetro(5); + mp.setncluster(8/2); + mp.setwarmupsteps(500); + mp.setgameloopsteps(3000); + + // A section for setting our Hamiltonian parameters, and beta + auto hp = make_tuple(beta, beta, J, D, K); + + //prepare the arguments + auto args = make_tuple(std::ref(mylatt), mp, hp); + + //execute core + auto mysim = makeCore >(args); + mysim.init(); + mysim.wrmploop(); + mysim.gameloop(); + return 0; +} + +int pyPotts(int q, std::string path, int dim, int len, double beta, double J) +{ + RegularHypercubic mylatt(len, dim); //nD len x len lattice + + //MARQOV::Config stores a set of Monte Carlo related parameters + MARQOV::Config mp(path); + mp.setnmetro(5); + mp.setncluster(8/2); + mp.setwarmupsteps(500); + mp.setgameloopsteps(3000); + + // A section for setting our Hamiltonian parameters, and beta + auto hp = make_tuple(beta, beta, J); + + //prepare the arguments + auto args = make_tuple(std::ref(mylatt), mp, hp); + + //execute core + switch (q) + { + case 3: + { + auto mysim = makeCore >(args); + mysim.init(); + mysim.wrmploop(); + mysim.gameloop(); + } + break; + case 4: + { + auto mysim = makeCore >(args); + mysim.init(); + mysim.wrmploop(); + mysim.gameloop(); + } + break; + case 6: + { + auto mysim = makeCore >(args); + mysim.init(); + mysim.wrmploop(); + mysim.gameloop(); + } + break; + case 8: + { + auto mysim = makeCore >(args); + mysim.init(); + mysim.wrmploop(); + mysim.gameloop(); + } + break; + } + return 0; +} -- GitLab From b4d8081899fa2e5f0a701424f0f7c47e7af54e6a Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Wed, 11 Aug 2021 10:49:08 +0200 Subject: [PATCH 05/35] fix cmake --- src/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c3c47da..2ade028 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -55,9 +55,9 @@ if(CMAKE_VERSION VERSION_GREATER 3.7) find_package(SWIG 3.0 COMPONENTS python) if(SWIG_FOUND) message("SWIG found: ${SWIG_EXECUTABLE}.") - #specific language queries not supported in cmake 3-16... + endif() + # specific language queries not supported in cmake 3-16... # if(NOT SWIG_python_FOUND) # message(WARNING "SWIG python bindings cannot be generated") # endif() - endif() -endif \ No newline at end of file +endif() -- GitLab From aed2a86180207931edc4e41682bfeb24111dbad3 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Wed, 11 Aug 2021 20:19:43 +0200 Subject: [PATCH 06/35] fix AT --- src/hamiltonian/AshkinTeller.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hamiltonian/AshkinTeller.h b/src/hamiltonian/AshkinTeller.h index 2b5e274..3928f1c 100644 --- a/src/hamiltonian/AshkinTeller.h +++ b/src/hamiltonian/AshkinTeller.h @@ -90,9 +90,9 @@ class AshkinTeller_Initializer */ StateVector newsv(const StateVector& svold) { - cout << "This should not have happened!" << endl; - cout << "This Hamiltonian is not supposed to work with the generic Metropolis algorithm." << endl; - cout << "Use a specialized implementation instead!" << endl; + std::cout << "This should not have happened!" << std::endl; + std::cout << "This Hamiltonian is not supposed to work with the generic Metropolis algorithm." << std::endl; + std::cout << "Use a specialized implementation instead!" << std::endl; }; }; @@ -227,7 +227,7 @@ namespace MARQOV case 0: retval = ham.J - ham.K * (sv1[1]*sv2[1] + sv1[2]*sv2[2]); break; case 1: retval = ham.J - ham.K * (sv1[0]*sv2[0] + sv1[2]*sv2[2]); break; case 2: retval = ham.J - ham.K * (sv1[0]*sv2[0] + sv1[1]*sv2[1]); break; - default: cout << "invalid color!" << rcolor << endl; + default: std::cout << "invalid color!" << rcolor << std::endl; // default: throw std::invalid_argument("invalid color!"); // catch me! } } @@ -264,7 +264,7 @@ namespace MARQOV case 0: retval = ham.J - ham.K * (sv1[1]*sv2[1] + sv1[2]*sv2[2]); break; case 1: retval = ham.J - ham.K * (sv1[0]*sv2[0] + sv1[2]*sv2[2]); break; case 2: retval = ham.J - ham.K * (sv1[0]*sv2[0] + sv1[1]*sv2[1]); break; - default: cout << "invalid color!" << color << endl; + default: std::cout << "invalid color!" << color << std::endl; // default: throw std::invalid_argument("invalid color!"); // catch me! } return retval; -- GitLab From b99a36bbe645760221e28d049d515f2eb8ff9eac Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Wed, 11 Aug 2021 20:19:56 +0200 Subject: [PATCH 07/35] fixcompilation --- src/libshowcase.cpp | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/src/libshowcase.cpp b/src/libshowcase.cpp index c74ff8a..af4c0fd 100644 --- a/src/libshowcase.cpp +++ b/src/libshowcase.cpp @@ -11,13 +11,18 @@ #include "hamiltonian/Heisenberg.h" #include "hamiltonian/Ising.h" #include "hamiltonian/Phi4.h" +#include "hamiltonian/AshkinTeller.h" +#include "hamiltonian/BlumeCapel.h" +#include "hamiltonian/BlumeEmeryGriffiths.h" +#include "hamiltonian/Potts.h" using namespace std; using namespace MARQOV; -int pyIsing(std::string path, int dim, int len, double beta, double J) +template +static int instantiatesim(const std::string& path, Lattice& mylatt, const HamParameter& hp) { - RegularHypercubic mylatt(len, dim); //nD len x len lattice +// Lattice mylatt(len, dim); //nD len x len lattice //MARQOV::Config stores a set of Monte Carlo related parameters MARQOV::Config mp(path); @@ -26,8 +31,32 @@ int pyIsing(std::string path, int dim, int len, double beta, double J) mp.setwarmupsteps(500); mp.setgameloopsteps(3000); + //prepare the arguments + auto args = make_tuple(std::ref(mylatt), mp, hp); + + //execute core + auto mysim = makeCore >(args); + mysim.init(); + mysim.wrmploop(); + mysim.gameloop(); + return 0; +} + +int pyIsing(std::string path, int dim, int len, double beta, double J) +{ + RegularHypercubic mylatt(len, dim); //nD len x len lattice // A section for setting our Hamiltonian parameters, J, and the inverse temperature beta auto hp = make_tuple(beta, J); + return instantiatesim>(path, mylatt, hp); +/* + //MARQOV::Config stores a set of Monte Carlo related parameters + MARQOV::Config mp(path); + mp.setnmetro(5); + mp.setncluster(8/2); + mp.setwarmupsteps(500); + mp.setgameloopsteps(3000); + + //prepare the arguments auto args = make_tuple(std::ref(mylatt), mp, hp); @@ -36,7 +65,7 @@ int pyIsing(std::string path, int dim, int len, double beta, double J) mysim.init(); mysim.wrmploop(); mysim.gameloop(); - return 0; + return 0;*/ } int pyHeisenberg(std::string path, int dim, int len, double beta, double J) @@ -98,7 +127,7 @@ int pyAshkinTeller(std::string path, int dim, int len, double beta, double J, do mp.setgameloopsteps(3000); // A section for setting our Hamiltonian parameters, and beta - auto hp = make_tuple(beta, beta, J, K); + auto hp = make_tuple(beta, J, K); //prepare the arguments auto args = make_tuple(std::ref(mylatt), mp, hp); @@ -123,13 +152,13 @@ int pyBlumeCapel(std::string path, int dim, int len, double beta, double J, doub mp.setgameloopsteps(3000); // A section for setting our Hamiltonian parameters, and beta - auto hp = make_tuple(beta, beta, J, D); + auto hp = make_tuple(beta, J, D); //prepare the arguments auto args = make_tuple(std::ref(mylatt), mp, hp); //execute core - auto mysim = makeCore >(args); + auto mysim = makeCore >(args); mysim.init(); mysim.wrmploop(); mysim.gameloop(); @@ -148,7 +177,7 @@ int pyBEG(std::string path, int dim, int len, double beta, double J, double D, d mp.setgameloopsteps(3000); // A section for setting our Hamiltonian parameters, and beta - auto hp = make_tuple(beta, beta, J, D, K); + auto hp = make_tuple(beta, J, D, K); //prepare the arguments auto args = make_tuple(std::ref(mylatt), mp, hp); @@ -173,7 +202,7 @@ int pyPotts(int q, std::string path, int dim, int len, double beta, double J) mp.setgameloopsteps(3000); // A section for setting our Hamiltonian parameters, and beta - auto hp = make_tuple(beta, beta, J); + auto hp = make_tuple(beta, J); //prepare the arguments auto args = make_tuple(std::ref(mylatt), mp, hp); -- GitLab From 9f4b794f436f931f71db9782e9ff76a6b60de157 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Wed, 11 Aug 2021 20:35:40 +0200 Subject: [PATCH 08/35] reduce copy/paste programming --- src/libshowcase.cpp | 149 +++++--------------------------------------- 1 file changed, 15 insertions(+), 134 deletions(-) diff --git a/src/libshowcase.cpp b/src/libshowcase.cpp index af4c0fd..6987e30 100644 --- a/src/libshowcase.cpp +++ b/src/libshowcase.cpp @@ -35,7 +35,7 @@ static int instantiatesim(const std::string& path, Lattice& mylatt, const HamPar auto args = make_tuple(std::ref(mylatt), mp, hp); //execute core - auto mysim = makeCore >(args); + auto mysim = makeCore(args); mysim.init(); mysim.wrmploop(); mysim.gameloop(); @@ -48,151 +48,55 @@ int pyIsing(std::string path, int dim, int len, double beta, double J) // A section for setting our Hamiltonian parameters, J, and the inverse temperature beta auto hp = make_tuple(beta, J); return instantiatesim>(path, mylatt, hp); -/* - //MARQOV::Config stores a set of Monte Carlo related parameters - MARQOV::Config mp(path); - mp.setnmetro(5); - mp.setncluster(8/2); - mp.setwarmupsteps(500); - mp.setgameloopsteps(3000); - - - //prepare the arguments - auto args = make_tuple(std::ref(mylatt), mp, hp); - - //execute core - auto mysim = makeCore >(args); - mysim.init(); - mysim.wrmploop(); - mysim.gameloop(); - return 0;*/ } int pyHeisenberg(std::string path, int dim, int len, double beta, double J) { RegularHypercubic mylatt(len, dim); //nD len x len lattice -//MARQOV::Config stores a set of Monte Carlo related parameters - MARQOV::Config mp(path); - mp.setnmetro(5); - mp.setncluster(8/2); - mp.setwarmupsteps(500); - mp.setgameloopsteps(3000); - - // A section for setting our Hamiltonian parameters, J, and the inverse temperature beta - auto hp = make_tuple(beta, J); - //prepare the arguments - auto args = make_tuple(std::ref(mylatt), mp, hp); - - //execute core - auto mysim = makeCore >(args); - mysim.init(); - mysim.wrmploop(); - mysim.gameloop(); - return 0; + + // A section for setting our Hamiltonian parameters, J, and the inverse temperature beta + auto hp = make_tuple(beta, J); + return instantiatesim >(path, mylatt, hp); } int pyPhi4(std::string path, int dim, int len, double beta, double lambda, double mass) { RegularHypercubic mylatt(len, dim); //nD len x len lattice - - //MARQOV::Config stores a set of Monte Carlo related parameters - MARQOV::Config mp(path); - mp.setnmetro(5); - mp.setncluster(8/2); - mp.setwarmupsteps(500); - mp.setgameloopsteps(3000); - // A section for setting our Hamiltonian parameters, J, and the inverse temperature beta auto hp = make_tuple(beta, beta, lambda, mass); - //prepare the arguments - auto args = make_tuple(std::ref(mylatt), mp, hp); - //execute core - auto mysim = makeCore >(args); - mysim.init(); - mysim.wrmploop(); - mysim.gameloop(); - return 0; + return instantiatesim >(path, mylatt, hp); } int pyAshkinTeller(std::string path, int dim, int len, double beta, double J, double K) { RegularHypercubic mylatt(len, dim); //nD len x len lattice - - //MARQOV::Config stores a set of Monte Carlo related parameters - MARQOV::Config mp(path); - mp.setnmetro(5); - mp.setncluster(8/2); - mp.setwarmupsteps(500); - mp.setgameloopsteps(3000); - // A section for setting our Hamiltonian parameters, and beta auto hp = make_tuple(beta, J, K); - - //prepare the arguments - auto args = make_tuple(std::ref(mylatt), mp, hp); - - //execute core - auto mysim = makeCore(args); - mysim.init(); - mysim.wrmploop(); - mysim.gameloop(); - return 0; + return instantiatesim(path, mylatt, hp); } int pyBlumeCapel(std::string path, int dim, int len, double beta, double J, double D) { RegularHypercubic mylatt(len, dim); //nD len x len lattice - - //MARQOV::Config stores a set of Monte Carlo related parameters - MARQOV::Config mp(path); - mp.setnmetro(5); - mp.setncluster(8/2); - mp.setwarmupsteps(500); - mp.setgameloopsteps(3000); - // A section for setting our Hamiltonian parameters, and beta auto hp = make_tuple(beta, J, D); - - //prepare the arguments - auto args = make_tuple(std::ref(mylatt), mp, hp); - - //execute core - auto mysim = makeCore >(args); - mysim.init(); - mysim.wrmploop(); - mysim.gameloop(); - return 0; + return instantiatesim >(path, mylatt, hp); } int pyBEG(std::string path, int dim, int len, double beta, double J, double D, double K) { RegularHypercubic mylatt(len, dim); //nD len x len lattice - - //MARQOV::Config stores a set of Monte Carlo related parameters - MARQOV::Config mp(path); - mp.setnmetro(5); - mp.setncluster(8/2); - mp.setwarmupsteps(500); - mp.setgameloopsteps(3000); - // A section for setting our Hamiltonian parameters, and beta auto hp = make_tuple(beta, J, D, K); - - //prepare the arguments - auto args = make_tuple(std::ref(mylatt), mp, hp); - - //execute core - auto mysim = makeCore >(args); - mysim.init(); - mysim.wrmploop(); - mysim.gameloop(); - return 0; + return instantiatesim >(path, mylatt, hp); } int pyPotts(int q, std::string path, int dim, int len, double beta, double J) { RegularHypercubic mylatt(len, dim); //nD len x len lattice + // A section for setting our Hamiltonian parameters, and beta + auto hp = make_tuple(beta, J); //MARQOV::Config stores a set of Monte Carlo related parameters MARQOV::Config mp(path); @@ -200,9 +104,6 @@ int pyPotts(int q, std::string path, int dim, int len, double beta, double J) mp.setncluster(8/2); mp.setwarmupsteps(500); mp.setgameloopsteps(3000); - - // A section for setting our Hamiltonian parameters, and beta - auto hp = make_tuple(beta, J); //prepare the arguments auto args = make_tuple(std::ref(mylatt), mp, hp); @@ -211,36 +112,16 @@ int pyPotts(int q, std::string path, int dim, int len, double beta, double J) switch (q) { case 3: - { - auto mysim = makeCore >(args); - mysim.init(); - mysim.wrmploop(); - mysim.gameloop(); - } + return instantiatesim >(path, mylatt, hp); break; case 4: - { - auto mysim = makeCore >(args); - mysim.init(); - mysim.wrmploop(); - mysim.gameloop(); - } + return instantiatesim >(path, mylatt, hp); break; case 6: - { - auto mysim = makeCore >(args); - mysim.init(); - mysim.wrmploop(); - mysim.gameloop(); - } + return instantiatesim >(path, mylatt, hp); break; case 8: - { - auto mysim = makeCore >(args); - mysim.init(); - mysim.wrmploop(); - mysim.gameloop(); - } + return instantiatesim >(path, mylatt, hp); break; } return 0; -- GitLab From ae5445b1b03f65834f6414f56ffbd3c15a4e7636 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Wed, 11 Aug 2021 20:59:34 +0200 Subject: [PATCH 09/35] improve cmake --- src/CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2ade028..8040ddc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -52,10 +52,24 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libmarqov/util/config.h.in ${CMAKE_CU # Let's check whether we have SWIG and can hence build the language bindings. if(CMAKE_VERSION VERSION_GREATER 3.7) + cmake_policy(SET CMP0086 NEW) + cmake_policy(SET CMP0078 NEW) find_package(SWIG 3.0 COMPONENTS python) if(SWIG_FOUND) + FIND_PACKAGE(PythonLibs) + INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) + INCLUDE(${SWIG_USE_FILE}) message("SWIG found: ${SWIG_EXECUTABLE}.") + set_property(SOURCE libshowcase.i PROPERTY CPLUSPLUS ON) + + message("PYTHONLIBS_VERSION_STRING: ${PYTHONLIBS_VERSION_STRING}") + message("CMAKE_SWIG_FLAGS: ${CMAKE_SWIG_FLAGS}") + + swig_add_library(showcase TYPE SHARED LANGUAGE python SOURCES libshowcase.i) + SWIG_LINK_LIBRARIES(showcase ${PYTHON_LIBRARIES}) endif() + + # specific language queries not supported in cmake 3-16... # if(NOT SWIG_python_FOUND) # message(WARNING "SWIG python bindings cannot be generated") -- GitLab From 8bde9fdfc9c5491869cf2382f6975a3f32cd11eb Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Thu, 12 Aug 2021 15:09:59 +0200 Subject: [PATCH 10/35] strive to be a bit more portable --- src/CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8040ddc..b679aa1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -52,10 +52,11 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libmarqov/util/config.h.in ${CMAKE_CU # Let's check whether we have SWIG and can hence build the language bindings. if(CMAKE_VERSION VERSION_GREATER 3.7) - cmake_policy(SET CMP0086 NEW) - cmake_policy(SET CMP0078 NEW) - find_package(SWIG 3.0 COMPONENTS python) + find_package(SWIG 3.0 OPTIONAL_COMPONENTS python) + if(SWIG_FOUND) + cmake_policy(SET CMP0086 NEW) + cmake_policy(SET CMP0078 NEW) FIND_PACKAGE(PythonLibs) INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) INCLUDE(${SWIG_USE_FILE}) -- GitLab From 290975dc39ce254dd62c3658070d67476b26c175 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Mon, 16 Aug 2021 17:24:49 +0200 Subject: [PATCH 11/35] update header --- src/libshowcase.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libshowcase.h b/src/libshowcase.h index c2e8ff6..0047038 100644 --- a/src/libshowcase.h +++ b/src/libshowcase.h @@ -2,3 +2,8 @@ int pyIsing(std::string path, int dim, int len, double beta, double J); int pyHeisenberg(std::string path, int dim, int len, double beta, double J); int pyPhi4(std::string path, int dim, int len, double beta, double lambda, double mass); +int pyAshkinTeller(std::string path, int dim, int len, double beta, double J, double K) +int pyBlumeCapel(std::string path, int dim, int len, double beta, double J, double D) +int pyBEG(std::string path, int dim, int len, double beta, double J, double D, double K) +int pyPotts(int q, std::string path, int dim, int len, double beta, double J) + -- GitLab From d3ec4d7f74655ede2fe332dcb572f185e3124ed7 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Mon, 16 Aug 2021 17:25:01 +0200 Subject: [PATCH 12/35] throw for invalid q --- src/libshowcase.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libshowcase.cpp b/src/libshowcase.cpp index 6987e30..123d2bf 100644 --- a/src/libshowcase.cpp +++ b/src/libshowcase.cpp @@ -35,7 +35,7 @@ static int instantiatesim(const std::string& path, Lattice& mylatt, const HamPar auto args = make_tuple(std::ref(mylatt), mp, hp); //execute core - auto mysim = makeCore(args); + auto mysim = makeCore(args); mysim.init(); mysim.wrmploop(); mysim.gameloop(); @@ -123,6 +123,9 @@ int pyPotts(int q, std::string path, int dim, int len, double beta, double J) case 8: return instantiatesim >(path, mylatt, hp); break; + default: + throw(std::string("[MARQOV::Showcase] Supported q values 3,4,6, and 8. All others only from C++.")); + break; } return 0; } -- GitLab From 4586c0456088d2b5c3b8e3cd1c4770e8a9686c94 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Mon, 16 Aug 2021 18:09:44 +0200 Subject: [PATCH 13/35] fix compilation --- src/libshowcase.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libshowcase.h b/src/libshowcase.h index 0047038..165cfb9 100644 --- a/src/libshowcase.h +++ b/src/libshowcase.h @@ -2,8 +2,8 @@ int pyIsing(std::string path, int dim, int len, double beta, double J); int pyHeisenberg(std::string path, int dim, int len, double beta, double J); int pyPhi4(std::string path, int dim, int len, double beta, double lambda, double mass); -int pyAshkinTeller(std::string path, int dim, int len, double beta, double J, double K) -int pyBlumeCapel(std::string path, int dim, int len, double beta, double J, double D) -int pyBEG(std::string path, int dim, int len, double beta, double J, double D, double K) -int pyPotts(int q, std::string path, int dim, int len, double beta, double J) +int pyAshkinTeller(std::string path, int dim, int len, double beta, double J, double K); +int pyBlumeCapel(std::string path, int dim, int len, double beta, double J, double D); +int pyBEG(std::string path, int dim, int len, double beta, double J, double D, double K); +int pyPotts(int q, std::string path, int dim, int len, double beta, double J); -- GitLab From 6de545b77e45f4015dd18c5e0456bb11eba1a7d1 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Mon, 16 Aug 2021 20:08:32 +0200 Subject: [PATCH 14/35] cmake swig + python support --- src/CMakeLists.txt | 5 +++-- src/libmarqov/CMakeLists.txt | 2 +- src/libshowcase.i | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b679aa1..df86891 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -58,6 +58,7 @@ if(CMAKE_VERSION VERSION_GREATER 3.7) cmake_policy(SET CMP0086 NEW) cmake_policy(SET CMP0078 NEW) FIND_PACKAGE(PythonLibs) + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) INCLUDE(${SWIG_USE_FILE}) message("SWIG found: ${SWIG_EXECUTABLE}.") @@ -66,8 +67,8 @@ if(CMAKE_VERSION VERSION_GREATER 3.7) message("PYTHONLIBS_VERSION_STRING: ${PYTHONLIBS_VERSION_STRING}") message("CMAKE_SWIG_FLAGS: ${CMAKE_SWIG_FLAGS}") - swig_add_library(showcase TYPE SHARED LANGUAGE python SOURCES libshowcase.i) - SWIG_LINK_LIBRARIES(showcase ${PYTHON_LIBRARIES}) + swig_add_library(marqov_showcase TYPE SHARED LANGUAGE python SOURCES libshowcase.i libshowcase.cpp) + SWIG_LINK_LIBRARIES(marqov_showcase libmarqov ${PYTHON_LIBRARIES}) endif() diff --git a/src/libmarqov/CMakeLists.txt b/src/libmarqov/CMakeLists.txt index 81959a2..2b99106 100644 --- a/src/libmarqov/CMakeLists.txt +++ b/src/libmarqov/CMakeLists.txt @@ -49,7 +49,7 @@ endif() add_library(libmarqov marqov.cpp) target_include_directories(libmarqov PUBLIC ${MYHDF5INCLUDES}) target_link_libraries(libmarqov ${MYHDF5LIBS} Threads::Threads) -set_target_properties(libmarqov PROPERTIES CXX_STANDARD 14 CXX_STANDARD_REQUIRED YES) +set_target_properties(libmarqov PROPERTIES CXX_STANDARD 14 CXX_STANDARD_REQUIRED YES POSITION_INDEPENDENT_CODE ON) if(DEBIASINTEGERS) target_compile_definitions("DEBIASINTEGERS") endif() diff --git a/src/libshowcase.i b/src/libshowcase.i index 6273ef9..97af8ab 100644 --- a/src/libshowcase.i +++ b/src/libshowcase.i @@ -1,8 +1,8 @@ -%module showcase +%module marqov_showcase /*SWIG has a library for doing the string mappings.*/ %include "std_string.i" %{ - +#define SWIG_FILE_WITH_INIT /* Includes the header in the wrapper code */ #include "libshowcase.h" %} -- GitLab From 98cdc2d27e01cb7f5a0ef5b64dc8d51a09960493 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Mon, 16 Aug 2021 20:12:25 +0200 Subject: [PATCH 15/35] Add a test for generating the python bindings --- .gitlab-ci.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 503f86f..aed331d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,6 +5,7 @@ stages: - buildMPI - test - docs + - SWIG .src_except_template: &src_except_definition except: @@ -197,3 +198,15 @@ marqov_sphinx_docs: - apt-get update && apt-get install -y doxygen graphviz pdf2svg python3-breathe python3-sphinx python3-sphinx-rtd-theme git python3-numpy python3-colorama python3-h5py python3-matplotlib - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@git.physik.uni-wuerzburg.de/marqov/pymarqov.git - ./compilefulldocs.sh + +marqov_Bullseye_SWIG_python: + image: git.physik.uni-wuerzburg.de:25812/z03/pdi/debian:bullseye-gfortran-blas-lapack-fftw-hdf5-scipy3 + stage: SWIG + needs: ["MARQOV_Simple_Test"] + <<: *src_except_definition + script: + - apt-get update && apt-get install g++ swig + - cmake -E make_directory build + - cd build + - cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE .. + - make marqov_showcase VERBOSE=1 -- GitLab From e9abe3956ecb043d68ad5cee7235bec5403f91fd Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Mon, 16 Aug 2021 20:44:25 +0200 Subject: [PATCH 16/35] fixes --- src/CMakeLists.txt | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index df86891..7687d24 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -52,23 +52,45 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libmarqov/util/config.h.in ${CMAKE_CU # Let's check whether we have SWIG and can hence build the language bindings. if(CMAKE_VERSION VERSION_GREATER 3.7) - find_package(SWIG 3.0 OPTIONAL_COMPONENTS python) + find_package(SWIG 3.0 OPTIONAL_COMPONENTS python java lua) if(SWIG_FOUND) cmake_policy(SET CMP0086 NEW) cmake_policy(SET CMP0078 NEW) - FIND_PACKAGE(PythonLibs) - INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) - INCLUDE(${SWIG_USE_FILE}) message("SWIG found: ${SWIG_EXECUTABLE}.") set_property(SOURCE libshowcase.i PROPERTY CPLUSPLUS ON) - - message("PYTHONLIBS_VERSION_STRING: ${PYTHONLIBS_VERSION_STRING}") - message("CMAKE_SWIG_FLAGS: ${CMAKE_SWIG_FLAGS}") - - swig_add_library(marqov_showcase TYPE SHARED LANGUAGE python SOURCES libshowcase.i libshowcase.cpp) - SWIG_LINK_LIBRARIES(marqov_showcase libmarqov ${PYTHON_LIBRARIES}) + FIND_PACKAGE(PythonLibs) + if(PYTHONLIBS_FOUND) + message("Python found, building Python bindings") + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) + INCLUDE(${SWIG_USE_FILE}) + + message("PYTHONLIBS_VERSION_STRING: ${PYTHONLIBS_VERSION_STRING}") +# message("CMAKE_SWIG_FLAGS: ${CMAKE_SWIG_FLAGS}") + swig_add_library(marqov_showcase TYPE SHARED LANGUAGE python SOURCES libshowcase.i libshowcase.cpp) + SWIG_LINK_LIBRARIES(marqov_showcase libmarqov ${PYTHON_LIBRARIES}) + endif() + FIND_PACKAGE(Lua) + if(LUA_FOUND) + message("Lua found, building Lua bindings") + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + INCLUDE_DIRECTORIES(${LUA_INCLUDE_PATH}) + INCLUDE(${SWIG_USE_FILE}) + + swig_add_library(marqov_showcase TYPE SHARED LANGUAGE lua SOURCES libshowcase.i libshowcase.cpp) + SWIG_LINK_LIBRARIES(marqov_showcase libmarqov ${LUA_LIBRARIES}) + endif() + FIND_PACKAGE(JNI) + if(JNI_FOUND) + message("Java Development tools(JNI) found, building Java bindings") + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH}) + INCLUDE(${SWIG_USE_FILE}) + + swig_add_library(marqov_showcase TYPE SHARED LANGUAGE java SOURCES libshowcase.i libshowcase.cpp) + SWIG_LINK_LIBRARIES(marqov_showcase libmarqov ${JNI_LIBRARIES}) + endif() endif() -- GitLab From b5847bc603b57e7313125b828427c119e1bcbcf1 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Mon, 16 Aug 2021 20:52:45 +0200 Subject: [PATCH 17/35] avoid name collisions --- src/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7687d24..7320eba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -68,8 +68,8 @@ if(CMAKE_VERSION VERSION_GREATER 3.7) message("PYTHONLIBS_VERSION_STRING: ${PYTHONLIBS_VERSION_STRING}") # message("CMAKE_SWIG_FLAGS: ${CMAKE_SWIG_FLAGS}") - swig_add_library(marqov_showcase TYPE SHARED LANGUAGE python SOURCES libshowcase.i libshowcase.cpp) - SWIG_LINK_LIBRARIES(marqov_showcase libmarqov ${PYTHON_LIBRARIES}) + swig_add_library(pyShowcase TYPE SHARED LANGUAGE python SOURCES libshowcase.i libshowcase.cpp) + SWIG_LINK_LIBRARIES(pyShowcase libmarqov ${PYTHON_LIBRARIES}) endif() FIND_PACKAGE(Lua) if(LUA_FOUND) @@ -78,8 +78,8 @@ if(CMAKE_VERSION VERSION_GREATER 3.7) INCLUDE_DIRECTORIES(${LUA_INCLUDE_PATH}) INCLUDE(${SWIG_USE_FILE}) - swig_add_library(marqov_showcase TYPE SHARED LANGUAGE lua SOURCES libshowcase.i libshowcase.cpp) - SWIG_LINK_LIBRARIES(marqov_showcase libmarqov ${LUA_LIBRARIES}) + swig_add_library(LuaShowcase TYPE SHARED LANGUAGE lua SOURCES libshowcase.i libshowcase.cpp) + SWIG_LINK_LIBRARIES(LuaShowcase libmarqov ${LUA_LIBRARIES}) endif() FIND_PACKAGE(JNI) if(JNI_FOUND) @@ -88,8 +88,8 @@ if(CMAKE_VERSION VERSION_GREATER 3.7) INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH}) INCLUDE(${SWIG_USE_FILE}) - swig_add_library(marqov_showcase TYPE SHARED LANGUAGE java SOURCES libshowcase.i libshowcase.cpp) - SWIG_LINK_LIBRARIES(marqov_showcase libmarqov ${JNI_LIBRARIES}) + swig_add_library(JNIShowcase TYPE SHARED LANGUAGE java SOURCES libshowcase.i libshowcase.cpp) + SWIG_LINK_LIBRARIES(JNIShowcase libmarqov ${JNI_LIBRARIES}) endif() endif() -- GitLab From 837b0dc43563c7d04ac01286c5f31b4713e24ea5 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Mon, 16 Aug 2021 20:55:22 +0200 Subject: [PATCH 18/35] fix includes --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7320eba..aedef80 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -75,7 +75,7 @@ if(CMAKE_VERSION VERSION_GREATER 3.7) if(LUA_FOUND) message("Lua found, building Lua bindings") INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - INCLUDE_DIRECTORIES(${LUA_INCLUDE_PATH}) + INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR}) INCLUDE(${SWIG_USE_FILE}) swig_add_library(LuaShowcase TYPE SHARED LANGUAGE lua SOURCES libshowcase.i libshowcase.cpp) @@ -85,7 +85,7 @@ if(CMAKE_VERSION VERSION_GREATER 3.7) if(JNI_FOUND) message("Java Development tools(JNI) found, building Java bindings") INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) - INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH}) + INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2}) INCLUDE(${SWIG_USE_FILE}) swig_add_library(JNIShowcase TYPE SHARED LANGUAGE java SOURCES libshowcase.i libshowcase.cpp) -- GitLab From 5c9ae9cf12a756f4c224c2311d3ac1c291b6b85d Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Mon, 16 Aug 2021 21:11:58 +0200 Subject: [PATCH 19/35] moremoremcedit CMakeLists.txt --- src/CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aedef80..8e65a45 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -52,7 +52,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libmarqov/util/config.h.in ${CMAKE_CU # Let's check whether we have SWIG and can hence build the language bindings. if(CMAKE_VERSION VERSION_GREATER 3.7) - find_package(SWIG 3.0 OPTIONAL_COMPONENTS python java lua) + find_package(SWIG 3.0 OPTIONAL_COMPONENTS python java lua r ocaml) if(SWIG_FOUND) cmake_policy(SET CMP0086 NEW) @@ -91,6 +91,15 @@ if(CMAKE_VERSION VERSION_GREATER 3.7) swig_add_library(JNIShowcase TYPE SHARED LANGUAGE java SOURCES libshowcase.i libshowcase.cpp) SWIG_LINK_LIBRARIES(JNIShowcase libmarqov ${JNI_LIBRARIES}) endif() + + if(CMAKE_VERSION VERSION_GREATER 3.18) + if(SWIG_r_FOUND) +message("R found") + endif() + if(SWIG_ocaml_FOUND) +message("ocaml found") + endif() + endif() endif() -- GitLab From d1297bdb5a4c7e27bb8333849ec7c14d7b6cc8d6 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Mon, 16 Aug 2021 21:16:44 +0200 Subject: [PATCH 20/35] add some meat --- src/CMakeLists.txt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8e65a45..2a36f62 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -94,10 +94,22 @@ if(CMAKE_VERSION VERSION_GREATER 3.7) if(CMAKE_VERSION VERSION_GREATER 3.18) if(SWIG_r_FOUND) -message("R found") + message("R found, building R bindings") + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) +# INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2}) + INCLUDE(${SWIG_USE_FILE}) + + swig_add_library(JNIShowcase TYPE SHARED LANGUAGE R SOURCES libshowcase.i libshowcase.cpp) +# SWIG_LINK_LIBRARIES(JNIShowcase libmarqov ${JNI_LIBRARIES}) endif() if(SWIG_ocaml_FOUND) -message("ocaml found") +message("ocaml found, building OCaml bindings") + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) +# INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2}) + INCLUDE(${SWIG_USE_FILE}) + + swig_add_library(JNIShowcase TYPE SHARED LANGUAGE ocaml SOURCES libshowcase.i libshowcase.cpp) +# SWIG_LINK_LIBRARIES(JNIShowcase libmarqov ${JNI_LIBRARIES}) endif() endif() endif() -- GitLab From 100386789ab5ca09ad57f222ae170ad1d3e4ceb6 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Mon, 16 Aug 2021 21:17:26 +0200 Subject: [PATCH 21/35] bugfix --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2a36f62..7fd5376 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -99,7 +99,7 @@ if(CMAKE_VERSION VERSION_GREATER 3.7) # INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2}) INCLUDE(${SWIG_USE_FILE}) - swig_add_library(JNIShowcase TYPE SHARED LANGUAGE R SOURCES libshowcase.i libshowcase.cpp) + swig_add_library(RShowcase TYPE SHARED LANGUAGE R SOURCES libshowcase.i libshowcase.cpp) # SWIG_LINK_LIBRARIES(JNIShowcase libmarqov ${JNI_LIBRARIES}) endif() if(SWIG_ocaml_FOUND) @@ -108,7 +108,7 @@ message("ocaml found, building OCaml bindings") # INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2}) INCLUDE(${SWIG_USE_FILE}) - swig_add_library(JNIShowcase TYPE SHARED LANGUAGE ocaml SOURCES libshowcase.i libshowcase.cpp) + swig_add_library(ocamlShowcase TYPE SHARED LANGUAGE ocaml SOURCES libshowcase.i libshowcase.cpp) # SWIG_LINK_LIBRARIES(JNIShowcase libmarqov ${JNI_LIBRARIES}) endif() endif() -- GitLab From d87ab3041267edb0ac03f95581ef9b6e02fccf22 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Mon, 16 Aug 2021 21:31:51 +0200 Subject: [PATCH 22/35] get a bit further --- src/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7fd5376..e76a21e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -96,7 +96,7 @@ if(CMAKE_VERSION VERSION_GREATER 3.7) if(SWIG_r_FOUND) message("R found, building R bindings") INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) -# INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2}) + INCLUDE_DIRECTORIES("/usr/share/R/include/") # Debian Bullseye path, could also carry over to Ubuntu INCLUDE(${SWIG_USE_FILE}) swig_add_library(RShowcase TYPE SHARED LANGUAGE R SOURCES libshowcase.i libshowcase.cpp) @@ -109,6 +109,7 @@ message("ocaml found, building OCaml bindings") INCLUDE(${SWIG_USE_FILE}) swig_add_library(ocamlShowcase TYPE SHARED LANGUAGE ocaml SOURCES libshowcase.i libshowcase.cpp) + target_compile_options(ocamlShowcase PRIVATE "-fpermissive")# could work for gcc # SWIG_LINK_LIBRARIES(JNIShowcase libmarqov ${JNI_LIBRARIES}) endif() endif() -- GitLab From 0c8c114af4f0da1adf3dda79233c9198caaef54b Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Mon, 16 Aug 2021 21:33:14 +0200 Subject: [PATCH 23/35] get a bit further --- src/CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e76a21e..127285b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -100,17 +100,16 @@ if(CMAKE_VERSION VERSION_GREATER 3.7) INCLUDE(${SWIG_USE_FILE}) swig_add_library(RShowcase TYPE SHARED LANGUAGE R SOURCES libshowcase.i libshowcase.cpp) -# SWIG_LINK_LIBRARIES(JNIShowcase libmarqov ${JNI_LIBRARIES}) + SWIG_LINK_LIBRARIES(RShowcase libmarqov) endif() if(SWIG_ocaml_FOUND) message("ocaml found, building OCaml bindings") INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) -# INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2}) INCLUDE(${SWIG_USE_FILE}) swig_add_library(ocamlShowcase TYPE SHARED LANGUAGE ocaml SOURCES libshowcase.i libshowcase.cpp) target_compile_options(ocamlShowcase PRIVATE "-fpermissive")# could work for gcc -# SWIG_LINK_LIBRARIES(JNIShowcase libmarqov ${JNI_LIBRARIES}) + SWIG_LINK_LIBRARIES(ocamlShowcase libmarqov) endif() endif() endif() -- GitLab From 65abea08d920431fb01b7c1819436de1ef6aa312 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Mon, 16 Aug 2021 21:35:32 +0200 Subject: [PATCH 24/35] tidy up a bit --- src/CMakeLists.txt | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 127285b..b8bb2b0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -66,8 +66,6 @@ if(CMAKE_VERSION VERSION_GREATER 3.7) INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) INCLUDE(${SWIG_USE_FILE}) - message("PYTHONLIBS_VERSION_STRING: ${PYTHONLIBS_VERSION_STRING}") -# message("CMAKE_SWIG_FLAGS: ${CMAKE_SWIG_FLAGS}") swig_add_library(pyShowcase TYPE SHARED LANGUAGE python SOURCES libshowcase.i libshowcase.cpp) SWIG_LINK_LIBRARIES(pyShowcase libmarqov ${PYTHON_LIBRARIES}) endif() @@ -92,7 +90,7 @@ if(CMAKE_VERSION VERSION_GREATER 3.7) SWIG_LINK_LIBRARIES(JNIShowcase libmarqov ${JNI_LIBRARIES}) endif() - if(CMAKE_VERSION VERSION_GREATER 3.18) + if(CMAKE_VERSION VERSION_GREATER 3.18)# language specific checks from SWIG only available in newer cmake versions if(SWIG_r_FOUND) message("R found, building R bindings") INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) @@ -113,10 +111,4 @@ message("ocaml found, building OCaml bindings") endif() endif() endif() - - - # specific language queries not supported in cmake 3-16... - # if(NOT SWIG_python_FOUND) - # message(WARNING "SWIG python bindings cannot be generated") - # endif() endif() -- GitLab From e7d905ed03e633f79ed3e7392053e9ada89188c8 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Mon, 16 Aug 2021 21:38:10 +0200 Subject: [PATCH 25/35] add a test for the other language bindings that is allowed to fail --- .gitlab-ci.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aed331d..116835f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -209,4 +209,17 @@ marqov_Bullseye_SWIG_python: - cmake -E make_directory build - cd build - cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE .. - - make marqov_showcase VERBOSE=1 + - make pyShowcase VERBOSE=1 + +marqov_Bullseye_SWIG_optionals: + image: git.physik.uni-wuerzburg.de:25812/z03/pdi/debian:bullseye-gfortran-blas-lapack-fftw-hdf5-scipy3 + stage: SWIG + needs: ["MARQOV_Simple_Test"] + allow_failure: true + <<: *src_except_definition + script: + - apt-get update && apt-get install g++ swig lua5.4-dev default-jdk r-base-dev ocaml-4.11.1 + - cmake -E make_directory build + - cd build + - cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE .. + - make pyShowcase JNIShowcase LuaShowcase RShowcase ocamlShowcase VERBOSE=1 -- GitLab From 1d46503e1888cf28ff58f717610ecffce23aef2b Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Mon, 16 Aug 2021 21:47:26 +0200 Subject: [PATCH 26/35] fix CI --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 116835f..9853dd3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -205,7 +205,7 @@ marqov_Bullseye_SWIG_python: needs: ["MARQOV_Simple_Test"] <<: *src_except_definition script: - - apt-get update && apt-get install g++ swig + - apt-get update && apt-get install -y g++ swig - cmake -E make_directory build - cd build - cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE .. @@ -218,7 +218,7 @@ marqov_Bullseye_SWIG_optionals: allow_failure: true <<: *src_except_definition script: - - apt-get update && apt-get install g++ swig lua5.4-dev default-jdk r-base-dev ocaml-4.11.1 + - apt-get update && apt-get install -y g++ swig lua5.4-dev default-jdk r-base-dev ocaml-4.11.1 - cmake -E make_directory build - cd build - cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE .. -- GitLab From d768a4b8e68bf9e7b552ca2122becd8552d76c24 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Tue, 17 Aug 2021 13:33:27 +0200 Subject: [PATCH 27/35] Add to installation --- doc/installation.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/installation.rst b/doc/installation.rst index 9b29756..78e0b9a 100644 --- a/doc/installation.rst +++ b/doc/installation.rst @@ -7,6 +7,7 @@ MARQOV is light on dependencies: * A C++14 compiler * HDF5 * optionally MPI + * optionally SWIG, and a recent enough version of cmake(3.18) for generating the foreign language bindings. and cmake for executing the build and configure step. If you intend to build the documentation doxygen, breathe and sphinx are required. @@ -26,4 +27,5 @@ The build step follows the basic cmake procedure: cmake -DCMAKE_BUILD_TYPE=Release .. cmake --build . --target all --config Release -and you should find compiled examples in src. \ No newline at end of file +and you should find compiled examples in src. By executing the all target, we will greedily build as many tools as are supported on your system. +Type ``make help`` after cmake has finished to see the available targets on your system. \ No newline at end of file -- GitLab From 0541025b9079be155d9ae37195434ca0540d3667 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Tue, 17 Aug 2021 13:47:05 +0200 Subject: [PATCH 28/35] minor --- src/main.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f968eb1..f5b1ca5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -57,8 +57,6 @@ using std::ofstream; using namespace MARQOV; - - bool startswith(const std::string longword, const std::string shortword) { if (longword.rfind(shortword, 0) == 0) return true; -- GitLab From 25aff4f992d249098cd4f788137640739fd62be7 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Tue, 17 Aug 2021 17:37:14 +0200 Subject: [PATCH 29/35] start the graph like versions --- src/libshowcase.cpp | 13 ++++++++++--- src/libshowcase.h | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libshowcase.cpp b/src/libshowcase.cpp index 123d2bf..de350d4 100644 --- a/src/libshowcase.cpp +++ b/src/libshowcase.cpp @@ -7,6 +7,8 @@ //include the RegularLattice #include "lattice/regular_hypercubic.h" +//include the CSV graph +#include "lattice/graph_from_csv.h" #include "hamiltonian/Heisenberg.h" #include "hamiltonian/Ising.h" @@ -22,8 +24,6 @@ using namespace MARQOV; template static int instantiatesim(const std::string& path, Lattice& mylatt, const HamParameter& hp) { -// Lattice mylatt(len, dim); //nD len x len lattice - //MARQOV::Config stores a set of Monte Carlo related parameters MARQOV::Config mp(path); mp.setnmetro(5); @@ -50,10 +50,17 @@ int pyIsing(std::string path, int dim, int len, double beta, double J) return instantiatesim>(path, mylatt, hp); } +int pyIsingGraph(std::string outpath, std::string graphpath, double beta, double J) +{ + GraphFromCSV graph(graphpath);//load lattice from a graph specification + // A section for setting our Hamiltonian parameters, J, and the inverse temperature beta + auto hp = make_tuple(beta, J); + return instantiatesim>(path, graph, hp); +} + int pyHeisenberg(std::string path, int dim, int len, double beta, double J) { RegularHypercubic mylatt(len, dim); //nD len x len lattice - // A section for setting our Hamiltonian parameters, J, and the inverse temperature beta auto hp = make_tuple(beta, J); return instantiatesim >(path, mylatt, hp); diff --git a/src/libshowcase.h b/src/libshowcase.h index 165cfb9..9a578af 100644 --- a/src/libshowcase.h +++ b/src/libshowcase.h @@ -1,5 +1,6 @@ #include int pyIsing(std::string path, int dim, int len, double beta, double J); +int pyIsingGraph(std::string outpath, std::string graphpath, double beta, double J) int pyHeisenberg(std::string path, int dim, int len, double beta, double J); int pyPhi4(std::string path, int dim, int len, double beta, double lambda, double mass); int pyAshkinTeller(std::string path, int dim, int len, double beta, double J, double K); -- GitLab From d5082b7d2e0d4957dcc5009e58a86d4ddcec1f1f Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Tue, 17 Aug 2021 17:40:35 +0200 Subject: [PATCH 30/35] semicolon --- src/libshowcase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libshowcase.h b/src/libshowcase.h index 9a578af..e82a662 100644 --- a/src/libshowcase.h +++ b/src/libshowcase.h @@ -1,6 +1,6 @@ #include int pyIsing(std::string path, int dim, int len, double beta, double J); -int pyIsingGraph(std::string outpath, std::string graphpath, double beta, double J) +int pyIsingGraph(std::string outpath, std::string graphpath, double beta, double J); int pyHeisenberg(std::string path, int dim, int len, double beta, double J); int pyPhi4(std::string path, int dim, int len, double beta, double lambda, double mass); int pyAshkinTeller(std::string path, int dim, int len, double beta, double J, double K); -- GitLab From 6e8f123b1b6537fca6c1307a0df498d69f7cb8ef Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Tue, 17 Aug 2021 17:42:37 +0200 Subject: [PATCH 31/35] fix graph_from_csv --- src/lattice/graph_from_csv.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lattice/graph_from_csv.h b/src/lattice/graph_from_csv.h index facab01..45d2c95 100644 --- a/src/lattice/graph_from_csv.h +++ b/src/lattice/graph_from_csv.h @@ -23,6 +23,9 @@ #include "util/io.h" +#include +#include + /** Read minimal graph from csv file. * @note for format specifications see general documentation */ @@ -58,7 +61,7 @@ class GraphFromCSVwithCoords std::vector> neighbours; std::vector> grid; - GraphFromCSV(std::string filename, ncoords) + GraphFromCSVwithCoords(std::string filename, int ncoords) { npoints = import_geometry(filename, grid, neighbours, ncoords); } @@ -75,8 +78,4 @@ class GraphFromCSVwithCoords std::size_t size() const {return npoints;} }; - - - - #endif -- GitLab From 5adc566e011e0030154923733f943ea6a5111110 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Tue, 17 Aug 2021 17:59:44 +0200 Subject: [PATCH 32/35] fix compilation --- src/lattice/graph_from_csv.h | 2 +- src/libshowcase.cpp | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/lattice/graph_from_csv.h b/src/lattice/graph_from_csv.h index 45d2c95..ae8834f 100644 --- a/src/lattice/graph_from_csv.h +++ b/src/lattice/graph_from_csv.h @@ -63,7 +63,7 @@ class GraphFromCSVwithCoords GraphFromCSVwithCoords(std::string filename, int ncoords) { - npoints = import_geometry(filename, grid, neighbours, ncoords); + npoints = import_geometry(filename, grid, neighbours, ncoords, false); } std::vector nbrs(const int a, const int i) const diff --git a/src/libshowcase.cpp b/src/libshowcase.cpp index de350d4..1b59b3d 100644 --- a/src/libshowcase.cpp +++ b/src/libshowcase.cpp @@ -35,7 +35,7 @@ static int instantiatesim(const std::string& path, Lattice& mylatt, const HamPar auto args = make_tuple(std::ref(mylatt), mp, hp); //execute core - auto mysim = makeCore(args); + auto mysim = makeCore(args); mysim.init(); mysim.wrmploop(); mysim.gameloop(); @@ -52,10 +52,10 @@ int pyIsing(std::string path, int dim, int len, double beta, double J) int pyIsingGraph(std::string outpath, std::string graphpath, double beta, double J) { - GraphFromCSV graph(graphpath);//load lattice from a graph specification - // A section for setting our Hamiltonian parameters, J, and the inverse temperature beta - auto hp = make_tuple(beta, J); - return instantiatesim>(path, graph, hp); +// GraphFromCSV graph(graphpath);//load lattice from a graph specification +// // A section for setting our Hamiltonian parameters, J, and the inverse temperature beta +// auto hp = make_tuple(beta, J); +// return instantiatesim>(outpath, graph, hp); } int pyHeisenberg(std::string path, int dim, int len, double beta, double J) @@ -65,6 +65,14 @@ int pyHeisenberg(std::string path, int dim, int len, double beta, double J) auto hp = make_tuple(beta, J); return instantiatesim >(path, mylatt, hp); } + +int pyHeisenbergGraph(std::string outpath, std::string graphpath, double beta, double J) +{ + GraphFromCSV graph(graphpath);//load lattice from a graph specification + // A section for setting our Hamiltonian parameters, J, and the inverse temperature beta + auto hp = make_tuple(beta, J); + return instantiatesim>(outpath, graph, hp); +} int pyPhi4(std::string path, int dim, int len, double beta, double lambda, double mass) { -- GitLab From 2b907f7b7ec643f8530d3a17cee1a77a6edaf756 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Tue, 17 Aug 2021 18:01:02 +0200 Subject: [PATCH 33/35] function prototype --- src/libshowcase.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libshowcase.h b/src/libshowcase.h index e82a662..6316fc1 100644 --- a/src/libshowcase.h +++ b/src/libshowcase.h @@ -1,7 +1,10 @@ #include int pyIsing(std::string path, int dim, int len, double beta, double J); int pyIsingGraph(std::string outpath, std::string graphpath, double beta, double J); + int pyHeisenberg(std::string path, int dim, int len, double beta, double J); +int pyHeisenbergGraph(std::string outpath, std::string graphpath, double beta, double J) + int pyPhi4(std::string path, int dim, int len, double beta, double lambda, double mass); int pyAshkinTeller(std::string path, int dim, int len, double beta, double J, double K); int pyBlumeCapel(std::string path, int dim, int len, double beta, double J, double D); -- GitLab From 136f931786585a48c160f688207d9b3cc75dabde Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Tue, 17 Aug 2021 19:40:07 +0200 Subject: [PATCH 34/35] have interfaces that can utilize coordinate free graphs where possible --- src/libshowcase.cpp | 72 ++++++++++++++++++++++++++++++++------------- src/libshowcase.h | 13 ++++++-- 2 files changed, 62 insertions(+), 23 deletions(-) diff --git a/src/libshowcase.cpp b/src/libshowcase.cpp index 1b59b3d..9cbefd9 100644 --- a/src/libshowcase.cpp +++ b/src/libshowcase.cpp @@ -49,18 +49,19 @@ int pyIsing(std::string path, int dim, int len, double beta, double J) auto hp = make_tuple(beta, J); return instantiatesim>(path, mylatt, hp); } - +/* +/* int pyIsingGraph(std::string outpath, std::string graphpath, double beta, double J) { -// GraphFromCSV graph(graphpath);//load lattice from a graph specification -// // A section for setting our Hamiltonian parameters, J, and the inverse temperature beta -// auto hp = make_tuple(beta, J); -// return instantiatesim>(outpath, graph, hp); -} + GraphFromCSV graph(graphpath);//load lattice from a graph specification + // A section for setting our Hamiltonian parameters, J, and the inverse temperature beta + auto hp = make_tuple(beta, J); + return instantiatesim>(outpath, graph, hp); +}*/ int pyHeisenberg(std::string path, int dim, int len, double beta, double J) { - RegularHypercubic mylatt(len, dim); //nD len x len lattice + RegularHypercubic mylatt(len, dim); //nD len x len lattice // A section for setting our Hamiltonian parameters, J, and the inverse temperature beta auto hp = make_tuple(beta, J); return instantiatesim >(path, mylatt, hp); @@ -91,6 +92,14 @@ int pyAshkinTeller(std::string path, int dim, int len, double beta, double J, do return instantiatesim(path, mylatt, hp); } +int pyAshkinTellerGraph(std::string outpath, std::string graphpath, double beta, double J, double K) +{ + GraphFromCSV graph(graphpath);//load lattice from a graph specification + // A section for setting our Hamiltonian parameters, and beta + auto hp = make_tuple(beta, J, K); + return instantiatesim(outpath, graph, hp); +} + int pyBlumeCapel(std::string path, int dim, int len, double beta, double J, double D) { RegularHypercubic mylatt(len, dim); //nD len x len lattice @@ -99,6 +108,14 @@ int pyBlumeCapel(std::string path, int dim, int len, double beta, double J, doub return instantiatesim >(path, mylatt, hp); } +int pyBlumeCapelGraph(std::string outpath, std::string graphpath, double beta, double J, double D) +{ + GraphFromCSV graph(graphpath);//load lattice from a graph specification + // A section for setting our Hamiltonian parameters, and beta + auto hp = make_tuple(beta, J, D); + return instantiatesim >(outpath, graph, hp); +} + int pyBEG(std::string path, int dim, int len, double beta, double J, double D, double K) { RegularHypercubic mylatt(len, dim); //nD len x len lattice @@ -107,12 +124,9 @@ int pyBEG(std::string path, int dim, int len, double beta, double J, double D, d return instantiatesim >(path, mylatt, hp); } -int pyPotts(int q, std::string path, int dim, int len, double beta, double J) -{ - RegularHypercubic mylatt(len, dim); //nD len x len lattice - // A section for setting our Hamiltonian parameters, and beta - auto hp = make_tuple(beta, J); - +template +static int instantiatePotts(int q, const std::string& path, Lattice&& mylatt, const HamParms& hp) +{ //MARQOV::Config stores a set of Monte Carlo related parameters MARQOV::Config mp(path); mp.setnmetro(5); @@ -120,27 +134,43 @@ int pyPotts(int q, std::string path, int dim, int len, double beta, double J) mp.setwarmupsteps(500); mp.setgameloopsteps(3000); - //prepare the arguments - auto args = make_tuple(std::ref(mylatt), mp, hp); - //execute core switch (q) { case 3: - return instantiatesim >(path, mylatt, hp); + return instantiatesim::type, Potts<3> >(path, std::forward(mylatt), hp); break; case 4: - return instantiatesim >(path, mylatt, hp); + return instantiatesim::type, Potts<4> >(path, std::forward(mylatt), hp); break; case 6: - return instantiatesim >(path, mylatt, hp); + return instantiatesim::type, Potts<6> >(path, std::forward(mylatt), hp); break; case 8: - return instantiatesim >(path, mylatt, hp); + return instantiatesim::type, Potts<8> >(path, std::forward(mylatt), hp); break; default: - throw(std::string("[MARQOV::Showcase] Supported q values 3,4,6, and 8. All others only from C++.")); + throw(std::string("[MARQOV::Showcase] Supported Potts(q) values are q=3,4,6, and 8. All others only from C++.")); break; } return 0; + +} + +int pyPotts(int q, std::string path, int dim, int len, double beta, double J) +{ + RegularHypercubic mylatt(len, dim); //nD len x len lattice + // A section for setting our Hamiltonian parameters, and beta + auto hp = make_tuple(beta, J); + + return instantiatePotts(q, path, mylatt, hp); +} + +int pyPottsGraph(int q, std::string outpath, std::string graphpath, double beta, double J) +{ + GraphFromCSV mylatt(graphpath); //nD len x len lattice + // A section for setting our Hamiltonian parameters, and beta + auto hp = make_tuple(beta, J); + + return instantiatePotts(q, outpath, mylatt, hp); } diff --git a/src/libshowcase.h b/src/libshowcase.h index 6316fc1..3f10049 100644 --- a/src/libshowcase.h +++ b/src/libshowcase.h @@ -1,13 +1,22 @@ +/** @file libshowcase.h + * This file is for collecting the interfaces that will be used to generate + * foreign language interfaces by SWIG. + */ + #include int pyIsing(std::string path, int dim, int len, double beta, double J); -int pyIsingGraph(std::string outpath, std::string graphpath, double beta, double J); int pyHeisenberg(std::string path, int dim, int len, double beta, double J); -int pyHeisenbergGraph(std::string outpath, std::string graphpath, double beta, double J) +int pyHeisenbergGraph(std::string outpath, std::string graphpath, double beta, double J); int pyPhi4(std::string path, int dim, int len, double beta, double lambda, double mass); + int pyAshkinTeller(std::string path, int dim, int len, double beta, double J, double K); +int pyAshkinTellerGraph(std::string outpath, std::string graphpath, double beta, double J, double K); + int pyBlumeCapel(std::string path, int dim, int len, double beta, double J, double D); +int pyBlumeCapelGraph(std::string outpath, std::string graphpath, double beta, double J, double D); + int pyBEG(std::string path, int dim, int len, double beta, double J, double D, double K); int pyPotts(int q, std::string path, int dim, int len, double beta, double J); -- GitLab From 1a150fc9a7de8da677693a8a0a3d0f142f1e75a1 Mon Sep 17 00:00:00 2001 From: Florian Goth Date: Tue, 17 Aug 2021 19:44:21 +0200 Subject: [PATCH 35/35] forgot sth. --- src/libshowcase.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/libshowcase.cpp b/src/libshowcase.cpp index 9cbefd9..42661f1 100644 --- a/src/libshowcase.cpp +++ b/src/libshowcase.cpp @@ -165,12 +165,3 @@ int pyPotts(int q, std::string path, int dim, int len, double beta, double J) return instantiatePotts(q, path, mylatt, hp); } - -int pyPottsGraph(int q, std::string outpath, std::string graphpath, double beta, double J) -{ - GraphFromCSV mylatt(graphpath); //nD len x len lattice - // A section for setting our Hamiltonian parameters, and beta - auto hp = make_tuple(beta, J); - - return instantiatePotts(q, outpath, mylatt, hp); -} -- GitLab