diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml index 02ab63ca..9c6855af 100644 --- a/.github/workflows/deploy_docs.yml +++ b/.github/workflows/deploy_docs.yml @@ -4,6 +4,7 @@ on: push: branches: - master + - develop - gh_actions # test branch - '!gh-pages' tags: '*' @@ -13,21 +14,21 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Inject slug/short variables - uses: rlespinasse/github-slug-action@v3.x + uses: rlespinasse/github-slug-action@v4.x - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: main - name: Checkout gh-pages - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ref: gh-pages path: gh-pages - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: 3.8 @@ -42,7 +43,7 @@ jobs: cmake -E make_directory build cd build cmake -DDocument=ON -DENABLE_MPI=OFF ../ - make doc-ja-html doc-en-html + make doc-ja-html doc-en-html tutorial-ja-html - name: Deploy Configuration run: | @@ -63,6 +64,11 @@ jobs: mkdir -p "gh-pages/doc/${TARGET_NAME}" cp -r "main/build/doc/${lang}/source/html" "gh-pages/doc/${TARGET_NAME}/${lang}" done + for lang in ja; do + rm -rf "gh-pages/doc/${TARGET_NAME}/tutorial/${lang}" + mkdir -p "gh-pages/doc/${TARGET_NAME}"/tutorial/ + cp -r "main/build/doc/tutorial/${lang}/source/html" "gh-pages/doc/${TARGET_NAME}/tutorial/${lang}" + done cd gh-pages git config --local user.name "${GIT_USER}" git config --local user.email "${GIT_EMAIL}" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b49b05fe..4f66d3a6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,6 +2,7 @@ name: CI on: push: + pull_request: schedule: - cron: '0 0 1,15 * *' # JST 9:00 on 1st and 15th every month @@ -32,7 +33,7 @@ jobs: - name: brew if: ${{ runner.os == 'macOS' }} run: | - brew install openmpi scalapack libomp + brew install openmpi scalapack libomp blis - name: Setup Python uses: actions/setup-python@v5 @@ -52,13 +53,10 @@ jobs: run: | if [ ${{ runner.os }} = "macOS" ] ; then # CONFIG=apple requires gfortran but macOS runner has not, but gfortran-11, 12, ... - ln -s `which gfortran-11` gfortran - env PATH=`pwd`:$PATH cmake -DCONFIG=apple -DCMAKE_VERBOSE_MAKEFILE=ON $GITHUB_WORKSPACE + cmake -DCONFIG=apple -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_Fortran_COMPILER=gfortran-14 $GITHUB_WORKSPACE else cmake -DCMAKE_VERBOSE_MAKEFILE=ON $GITHUB_WORKSPACE fi - env: - HOMEBREW_PREFIX: /opt/homebrew - name: build working-directory: ${{runner.workspace}}/build diff --git a/.gitmodules b/.gitmodules index 99e901f0..44e5b4ac 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,3 @@ -[submodule "src/pfaffine"] - path = src/pfaffine - url = https://github.com/xrq-phys/Pfaffine - branch = blis [submodule "src/blis"] path = src/blis url = https://github.com/xrq-phys/blis diff --git a/CMakeLists.txt b/CMakeLists.txt index 70851aa8..4308c5da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,9 @@ -cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.5 FATAL_ERROR) project(mVMC NONE) option(USE_SCALAPACK "Use Scalapack" OFF) option(PFAFFIAN_BLOCKED "Use blocked-update Pfaffian to speed up." OFF) +option(USE_GEMMT "Use GEMMT. Recommended regardless blocked-Pfaffian-update." ON) add_definitions(-D_mVMC) if(CONFIG) @@ -17,11 +18,10 @@ message(STATUS "Build type: " ${CMAKE_BUILD_TYPE}) option(BUILD_SHARED_LIBS "Build shared libraries" ON) option(GIT_SUBMODULE_UPDATE "execute `git submodule update` automatically" ON) -enable_language(C Fortran) -if(PFAFFIAN_BLOCKED) - enable_language(CXX) - set(CMAKE_CXX_STANDARD 11) -endif(PFAFFIAN_BLOCKED) + +# First, enables C language only. +# External packages only use their C API. +enable_language(C) set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") set(CMAKE_SKIP_BUILD_RPATH FALSE) @@ -29,6 +29,7 @@ set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_MACOSX_RPATH 1) +# TODO: Is this really needed? if("${CMAKE_BUILD_TYPE}" MATCHES "Debug") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG}") else() @@ -37,16 +38,19 @@ else() endif() if(CMAKE_C_COMPILER_ID STREQUAL "Intel") + # TODO: Really needs separation? if("${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "15.0.0.20140528") set(OMP_FLAG_Intel "-openmp") else() set(OMP_FLAG_Intel "-qopenmp") endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OMP_FLAG_Intel}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OMP_FLAG_Intel}") else() find_package(OpenMP) if(OPENMP_FOUND) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") endif(OPENMP_FOUND) endif() @@ -57,6 +61,9 @@ if(MPI_C_FOUND) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MPI_C_LINK_FLAGS}") endif(MPI_C_FOUND) +# BLAS/LAPACK/Pfapack77 needs Fortran interface. +enable_language(Fortran) + find_package(LAPACK) if(USE_SCALAPACK MATCHES OFF) if(LAPACK_FOUND) @@ -64,6 +71,34 @@ if(USE_SCALAPACK MATCHES OFF) endif(LAPACK_FOUND) endif() +if(PFAFFIAN_BLOCKED + OR USE_GEMMT) + set(Require_BLIS ON) +endif() + +if(BLA_VENDOR MATCHES "Intel10*" + OR BLAS_LIBRARIES MATCHES "/*mkl*") + # Don't require BLIS when MKL is used. + add_definitions(-DMKL) + add_definitions(-DBLAS_EXTERNAL) + add_definitions(-DF77_COMPLEX_RET_INTEL) + set(Require_BLIS OFF) +elseif(BLA_VENDOR MATCHES "FLA*" + OR BLAS_LIBRARIES MATCHES "/*blis*") + # Skip extra BLIS if it's already the BLAS vendor. + list(GET BLAS_LIBRARIES 0 BLIS_FIRST_LIB) + get_filename_component(BLIS_LIB_DIR ${BLIS_FIRST_LIB} DIRECTORY) + include_directories(${BLIS_LIB_DIR}/../include) + include_directories(${BLIS_LIB_DIR}/../include/blis) + set(Require_BLIS OFF) +else() + # BLAS vendor preference: + # External > BLIS > Reference + if(DEFINED BLA_VENDOR) + add_definitions(-DBLAS_EXTERNAL) + endif() +endif() + # Build and enable tests # testing setup # enable_testing() must be called in the top-level CMakeLists.txt before any add_subdirectory() is called. @@ -97,12 +132,23 @@ if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") endif() add_subdirectory("${STDFACE_DIR}") +# C++ support for pfupdates & ltl2inv. +enable_language(CXX) +set(CMAKE_CXX_STANDARD 11) + +if(Require_BLIS) + include("download_blis_artifact.cmake") +else(Require_BLIS) + # Use bundled blis.h + include_directories(src/common/deps) +endif(Require_BLIS) + if(PFAFFIAN_BLOCKED) add_definitions(-D_pf_block_update) - include("download_blis_artifact.cmake") - # Must set BLIS artifact BEFORE adding pfupdates target. add_subdirectory(src/pfupdates) - add_dependencies(pfupdates blis_include) + if(Require_BLIS) + add_dependencies(pfupdates blis_include) + endif(Require_BLIS) endif(PFAFFIAN_BLOCKED) if (Document) @@ -111,5 +157,9 @@ endif(Document) add_subdirectory(src/ComplexUHF) add_subdirectory(src/pfapack/fortran) +add_subdirectory(src/ltl2inv) + if(Require_BLIS) + add_dependencies(ltl2inv blis_include) + endif(Require_BLIS) add_subdirectory(src/mVMC) add_subdirectory(tool) diff --git a/config/aocc.cmake b/config/aocc.cmake index a53a783a..258d9772 100644 --- a/config/aocc.cmake +++ b/config/aocc.cmake @@ -9,6 +9,9 @@ set(CMAKE_C_FLAGS_RELEASE "-Wno-unknown-pragmas -O3 -DNDEBUG -DHAVE_SSE2" CACHE set(CMAKE_Fortran_COMPILER "flang" CACHE STRING "" FORCE) set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -DNDEBUG -DHAVE_SSE2" CACHE STRING "" FORCE) +# OpenMP, libatomic +set(CMAKE_EXE_LINKER_FLAGS "-fopenmp -latomic") + # for AOCL set(BLA_VENDOR "FLAME" CACHE STRING "" FORCE) diff --git a/config/apple.cmake b/config/apple.cmake index 73082407..37a7a290 100644 --- a/config/apple.cmake +++ b/config/apple.cmake @@ -2,7 +2,7 @@ # additional libomp and gfortran installation required # mac computers are suggested to use this configuration for better performance -if(NOT $ENV{HOMEBREW_PREFIX}) +if(NOT DEFINED ENV{HOMEBREW_PREFIX}) message(FATAL "Homebrew is not installed. Please install Homebrew first.") endif() @@ -10,7 +10,6 @@ set(CMAKE_C_COMPILER "clang" CACHE STRING "" FORCE) set(CMAKE_CXX_COMPILER "clang++" CACHE STRING "" FORCE) set(CMAKE_C_FLAGS_DEBUG "-g -O0 -Wall -Wformat -Werror=format-security") set(CMAKE_C_FLAGS_RELEASE "-O3 -Wno-unknown-pragmas -Wno-logical-not-parentheses") -# set(CMAKE_Fortran_COMPILER "gfortran" CACHE STRING "" FORCE) # OpenMP with libomp set(CMAKE_EXE_LINKER_FLAGS "-L$ENV{HOMEBREW_PREFIX}/opt/libomp/lib -lomp") diff --git a/config/gcc.cmake b/config/gcc.cmake index 751912d7..8a15d2dc 100644 --- a/config/gcc.cmake +++ b/config/gcc.cmake @@ -3,4 +3,5 @@ set(CMAKE_C_COMPILER "gcc" CACHE STRING "" FORCE) set(CMAKE_CXX_COMPILER "g++" CACHE STRING "" FORCE) set(CMAKE_C_FLAGS_DEBUG "-g -O0 -Wall -Wformat -Werror=format-security") set(CMAKE_C_FLAGS_RELEASE "-O3 -Wno-unknown-pragmas ") +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wno-unknown-pragmas ") set(CMAKE_Fortran_COMPILER "gfortran" CACHE STRING "" FORCE) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 4843b315..882d074d 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -1,4 +1,6 @@ add_subdirectory(en/source) add_subdirectory(ja/source) +add_subdirectory(tutorial/ja/source) add_custom_target(doc DEPENDS doc-ja doc-en) +add_custom_target(tutorial DEPENDS tutorial-ja) diff --git a/doc/en/source/algorithm.rst b/doc/en/source/algorithm.rst index 7ffaf523..c4fa620e 100644 --- a/doc/en/source/algorithm.rst +++ b/doc/en/source/algorithm.rst @@ -92,7 +92,7 @@ Properties of the Pfaffian-Slater determinant In this section, we explain some properties of the Pfaffian-Slater determinant. We derive the general relation between a Pfaffian-Slater determinant and a single Slater determinant in :ref:`Antiparallel Pfaffian ` -and :ref:`General Pfaffian ` . We also discuss the meaning of the singular value +and :ref:`General Pfaffian ` . We also discuss meaning of the singular value decomposition of coefficients :math:`f_{ij}` in :ref:`SVD `. @@ -190,7 +190,7 @@ redundancy. Relation between :math:`F_{IJ}` and :math:`\Phi_{In}` (the case of the general pairing) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -We extend the relationship between the Pfaffian-Slater wave function and the +We extend the relation between the Pfaffian-Slater wave function and the single Slater wave function into the general pairing case including the spin-parallel pairing. We define the Pfaffian-Slater wave function and the single Slater wave function as diff --git a/doc/en/source/expert.rst b/doc/en/source/expert.rst index 03eaf5e1..96fb2d99 100644 --- a/doc/en/source/expert.rst +++ b/doc/en/source/expert.rst @@ -75,11 +75,12 @@ listed in parentheses correspond to the file made by vmcdry.out. .. math:: \begin{aligned} - |\psi \rangle &= {\cal P}_G{\cal P}_J{\cal P}_{d-h}^{(2)}{\cal P}_{d-h}^{(4)}{\cal L}^S{\cal L}^K{\cal L}^P |\phi_{\rm pair} \rangle,\\ + |\psi \rangle &= {\cal N}_{General RBM} {\cal P}_G{\cal P}_J{\cal P}_{d-h}^{(2)}{\cal P}_{d-h}^{(4)}{\cal L}^S{\cal L}^K{\cal L}^P |\phi_{\rm pair} \rangle,\\ {\cal P}_G&=\exp\left[ \sum_i g_i n_{i\uparrow} n_{i\downarrow} \right],\\ {\cal P}_J&=\exp\left[\frac{1}{2} \sum_{i\neq j} v_{ij} (n_i-1)(n_j-1)\right],\\ {\cal P}_{d-h}^{(2)}&= \exp \left[ \sum_t \sum_{n=0}^2 (\alpha_{2nt}^d \sum_{i}\xi_{i2nt}^d+\alpha_{2nt}^h \sum_{i}\xi_{i2nt}^h)\right],\\ {\cal P}_{d-h}^{(4)}&= \exp \left[ \sum_t \sum_{n=0}^4 (\alpha_{4nt}^d \sum_{i}\xi_{i4nt}^d+\alpha_{4nt}^h \sum_{i}\xi_{i4nt}^h)\right],\\ + {\cal N}_{\rm General RBM}&= \exp \left[ \sum_i a_{i\sigma} n_{i\sigma} \right] \prod_k^{N_h} \cosh \left[ b_k + \sum_{i\sigma} W_{i\sigma k} n_{i\sigma} \right],\\ {\cal L}_S&=\frac{2S+1}{8 \pi^2}\int d\Omega P_s(\cos \beta) \hat{R}(\Omega),\\ {\cal L}_K&=\frac{1}{N_s}\sum_{{\boldsymbol R}}e^{i {\boldsymbol K} \cdot{\boldsymbol R} } \hat{T}_{\boldsymbol R},\\ {\cal L}_P&=\sum_{\alpha}p_{\alpha} \hat{G}_{\alpha},\end{aligned} @@ -122,6 +123,12 @@ listed in parentheses correspond to the file made by vmcdry.out. :math:`\alpha_{4nt}^{d(h)}` in :math:`{\cal P}_{d-h}^{(4)}` to be optimized. + **GeneralRBM_PhysLayer**: Set the target variational parameters :math:`a_{i\sigma}` in the RBM correlation factor :math:`{\cal N}_{\rm General RBM}`. + + **GeneralRBM_HiddenLayer**: Set the target variational parameters :math:`h_{k}` in the RBM correlation factor :math:`{\cal N}_{\rm General RBM}`. + + **GeneralRBM_PhysHidden**: Set the target variational parameters :math:`W_{i\sigma k}` in the RBM correlation factor :math:`{\cal N}_{\rm General RBM}`. + **Orbital/OrbitalAntiParallel (orbitalidx.def)**: Set the pair orbital with anti-parallel spins :math:`f_{i\uparrow j\downarrow}` in :math:`|\phi_{\rm pair} \rangle` to be optimized. @@ -155,6 +162,12 @@ listed in parentheses correspond to the file made by vmcdry.out. **InDH4**: Set the initial values of :math:`\alpha_{4nt}^{d(h)}` in :math:`{\cal P}_{d-h}^{(4)}`. + + **InGeneralRBM_PhysLayer**: Set the initial values of :math:`a_{i\sigma}` in the RBM correlation factor :math:`{\cal N}_{\rm General RBM}`. + + **InGeneralRBM_HiddenLayer**: Set the initial values of :math:`h_{k}` in the RBM correlation factor :math:`{\cal N}_{\rm General RBM}`. + + **InGeneralRBM_PhysHidden**: Set the initial values of :math:`W_{i\sigma k}` in the RBM correlation factor :math:`{\cal N}_{\rm General RBM}`. **InOrbital /InOrbitalAntiParallel**: Set the initial values of :math:`f_{i\uparrow j\downarrow}` in @@ -246,6 +259,10 @@ Gutzwiller Gutzwiller factors. Jastrow Charge Jastrow factors. DH2 2-site doublon-holon correlation factors. DH4 4-site doublon-holon correlation factors. +GeneralRBM_PhysLayer A part of the general RBM correlation factor including variational parameters in a physical layer :math:`\alpha_{i\sigma}`. + + GeneralRBM_HiddenLayer A part of the general RBM correlation factor including variational parameters in a hidden layer :math:`\h_{k}`. + GeneralRBM_PhysHidden A part of the general RBM correlation factor including variational parameters which connect physical and hidden layers :math:`\W_{i\sigma k}`. Orbital :math:`^*` Pair orbital factors with anti-parallel spins :math:`f_{i\uparrow j\downarrow}`. OrbitalAntiParallel Pair orbital factors with anti-parallel spins :math:`f_{i\uparrow j\downarrow}`. OrbitalParallel Pair orbital factors with parallel spins :math:`f_{i\sigma j\sigma}`. @@ -255,6 +272,9 @@ InGutzwiller Initial values of Gutzwiller factors. InJastrow Initial values of charge Jastrow factors. InDH2 Initial values of 2-site doublon-holon correlation factors. InDH4 Initial values of 4-site doublon-holon correlation factors. + InGeneralRBM_PhysLayer Initial values of variational parameters of the general RBM correlation factors in a physical layer :math:`\alpha_{i\sigma}`. + InGeneralRBM_HiddenLayer Initial values of variational parameters of the general RBM correlation factors in a hidden layer :math:`\h_{k}`. + InGeneralRBM_PhysHidden Initial values of variational parameters of the general RBM correlation factors which connect physical and hidden layers :math:`\W_{i\sigma k}`. InOrbital Initial values of pair orbital factors :math:`f_{i\uparrow j\downarrow}`. InOrbitalAntiParallel Initial values of pair orbital factors :math:`f_{i\uparrow j\downarrow}`. InOrbitalParallel Initial values of pair orbital factors :math:`f_{i\sigma j\sigma}`. @@ -1234,6 +1254,7 @@ The Hamiltonian for exchange couplings +c_ {i \downarrow}^{\dagger}c_{j\downarrow}c_{j \uparrow}^{\dagger}c_{i \uparrow}) is added to the whole Hamiltonian by setting :math:`J_{ij}^{\rm Ex}`. +Note that, for spin systems, the definition of the Exchange is different from that in HPhi. An example of the file format is shown as follows. :: @@ -1827,6 +1848,407 @@ User rules - A program is terminated, when [ int02 ] - [ int10 ] are out of range from the defined values. + +GeneralRBM_PhysLayer file +~~~~~~~~ +In the general RBM correlation factors, + +.. math:: + + {\cal N}_{\rm General RBM}= \exp \left[ \sum_i a_{i\sigma} n_{i\sigma} \right] \prod_k^{N_{\rm neuronGeneral}} \cosh \left[ b_k + \sum_{i\sigma} W_{i\sigma k} n_{i\sigma} \right] + + +this file sets the calculation conditions of :math:`\exp \left[ \sum_i a_{i\sigma} n_{i\sigma} \right] ` . +A site index :math:`i`, a spin index :math:`\sigma` and the variational parameters +:math:`a_{i \sigma}` are specified. An example of the file format is shown as +follows. + +:: + + -------------------- + NRBM_PhysLayerIdx 1 + ComplexType 1 + i s RBM_PhysLayer_Idx + -------------------- + 0 0 0 + 0 1 0 + 1 0 0 + 1 1 0 + (continue...) + 0 1 + +File format +^^^^^^^^^^^ + +In the following, we define the total number of sites as :math:`N_s` and +variational parameters as :math:`N_{v}`, respectively. + +- Line 1: Header + +- Line 2: [string01] [int01] + +- Line 3: [string02] [int02] + +- Lines 4 - 5: Header + +- Lines 6 - (5+ :math:`2N_s`): [int03] [int04] [int05] + +- Lines (6+ :math:`2N_s` ) - + (5+ :math:`2N_s` + :math:`N_v`): [int06] [int07] + +Parameters +^^^^^^^^^^ + +- [ string01 ] + + **Type :** string-type (blank parameter not allowed) + + **Description :** A keyword for total number of variational + parameters :math:`a_{i\sigma}`. You can freely give a name of the keyword. + +- [ int01 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer giving total number of variational + parameters :math:`a_{i\sigma}`. + +- [ string02 ] + + **Type :** string-type (blank parameter not allowed) + + **Description :** A keyword for indicating the double or complex type + of variational parameters :math:`a_{i\sigma}`. You can freely give a name + of the keyword. + +- [ int02 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer indicates the double or complex type of + variational parameters :math:`a_{i\sigma}` (0: double, 1: complex). + +- [ int03 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer giving a site index + (0 :math:`\leq` [ int03 ] :math:`<` ``Nsite``). + +- [ int04 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer giving a spin index + ([int04] = 0 or 1). + +- [ int05 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer setting kinds of variational parameters + :math:`v_{ij}` (0 :math:`\leq` [ int05 ] :math:`<` [ int01]). + +- [ int06 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer giving kinds of variational parameters + (0 :math:`\leq` [ int06 ] :math:`<` [ int01]). + +- [ int07 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer to select the target of variational + parameters indicated at [int06] to be optimized or not (0: not + optimize, 1: optimize). + +User rules +^^^^^^^^^^ + +- This function is a beta version. Please use it carefully. The file format and the implementation may be changed in the future release. + +- This function is available only for the VMC calculation with ``ComplexType=1`` and ``Orbital``. This function is not available for the Power Lanczos calculations. + +- Headers cannot be omitted. + +- A program is terminated, when [ int01 ] is + different from the total number of variational parameters defined in + this file. + +- A program is terminated, when [ int02 ] - + [ int07 ] are out of range from the defined values. + + +GeneralRBM_HiddenLayer file +~~~~~~~~ +In the general RBM correlation factors, + +.. math:: + + {\cal N}_{\rm General RBM}= \exp \left[ \sum_i a_{i\sigma} n_{i\sigma} \right] \prod_k^{N_{\rm neuronGeneral}} \cosh \left[ b_k + \sum_{i\sigma} W_{i\sigma k} n_{i\sigma} \right] + + +this file sets the calculation conditions of :math:`b_k` in :math:`\prod_k^{N_{\rm neuronGeneral}} \cosh \left[ b_k + \sum_{i\sigma} W_{i\sigma k} n_{i\sigma} \right] `. +A hidden neuron index :math:`k` and the variational parameters +:math:`h_{k}` are specified. An example of the file format is shown as +follows. + +:: + + -------------------- + NRBM_HiddenLayerIdx 2 + ComplexType 1 + k RBM_HiddenLayer_Idx + -------------------- + 0 0 + 1 0 + 2 0 + 3 0 + (continue...) + 0 1 + 1 1 + +File format +^^^^^^^^^^^ + +In the following, we define the total number of neurons as :math:`N_{\rm neuronGeneral}` and +variational parameters as :math:`N_{v}`, respectively. + +- Line 1: Header + +- Line 2: [string01] [int01] + +- Line 3: [string02] [int02] + +- Lines 4 - 5: Header + +- Lines 6 - (5+:math:`N_{\rm neuronGeneral}`): [int03] [int04] + +- Lines (6+ :math:`N_{\rm neuronGeneral}` ) - + (5+ :math:`N_{\rm neuronGeneral}` + :math:`N_v`): [int05] [int06] + +Parameters +^^^^^^^^^^ + +- [ string01 ] + + **Type :** string-type (blank parameter not allowed) + + **Description :** A keyword for total number of variational + parameters :math:`h_{k}`. You can freely give a name of the keyword. + +- [ int01 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer giving total number of variational + parameters :math:`h_{k}`. + +- [ string02 ] + + **Type :** string-type (blank parameter not allowed) + + **Description :** A keyword for indicating the double or complex type + of variational parameters :math:`h_{k}`. You can freely give a name + of the keyword. + +- [ int02 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer indicates the double or complex type of + variational parameters :math:`h_{k}` (0: double, 1: complex). + +- [ int03 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer giving a neuron index + (0 :math:`\leq` [ int03 ] :math:`<` ``NneuronGeneral``). + +- [ int04 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer setting kinds of variational parameters + :math:`h_{k}` (0 :math:`\leq` [ int05 ] :math:`<` [ int01]). + +- [ int05 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer giving kinds of variational parameters + (0 :math:`\leq` [ int06 ] :math:`<` [ int01]). + +- [ int06 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer to select the target of variational + parameters indicated at [int06] to be optimized or not (0: not + optimize, 1: optimize). + +User rules +^^^^^^^^^^ + +- This function is a beta version. Please use it carefully. The file format and the implementation may be changed in the future release. + +- This function is available only for the VMC calculation with ``ComplexType=1`` and ``Orbital``. This function is not available for the Power Lanczos calculations. + +- Headers cannot be omitted. + +- A program is terminated, when [ int01 ] is + different from the total number of variational parameters defined in + this file. + +- A program is terminated, when [ int02 ] - + [ int06 ] are out of range from the defined values. + + +GeneralRBM_PhysHidden file +~~~~~~~~ +In the general RBM correlation factors, + +.. math:: + + {\cal N}_{\rm General RBM}= \exp \left[ \sum_i a_{i\sigma} n_{i\sigma} \right] \prod_k^{N_{\rm neuronGeneral}} \cosh \left[ b_k + \sum_{i\sigma} W_{i\sigma k} n_{i\sigma} \right] + + +this file sets the calculation conditions of :math:`W_{i\sigma k}` in :math:`\prod_k^{N_{\rm neuronGeneral}} \cosh \left[ b_k + \sum_{i\sigma} W_{i\sigma k} n_{i\sigma} \right] `. +A site index :math:`i`, a spin index :math:`\sigma`, a hidden neuron index :math:`k` and the variational parameters +:math:`W_{i\sigma k}` are specified. An example of the file format is shown as +follows. + +:: + + -------------------- + NRBM_HiddenLayerIdx 32 + ComplexType 1 + i s k RBM_PhysHidden_Idx + -------------------- + 0 0 0 0 + 0 1 0 1 + 1 0 0 2 + 1 1 0 3 + 2 0 0 4 + 2 1 0 5 + (continue...) + 0 1 + 1 1 + (continue...) + +File format +^^^^^^^^^^^ + +In the following, we define the total number of sites as :math:`N_s`, the total number of neurons as :math:`N_{\rm neuronGeneral}` and +variational parameters as :math:`N_{v}`. + +- Line 1: Header + +- Line 2: [string01] [int01] + +- Line 3: [string02] [int02] + +- Lines 4 - 5: Header + +- Lines 6 - (5+:math:`2 N_s N_{\rm neuronGeneral}`): [int03] [int04] [int05] [int06] + +- Lines (6+ :math:`2 N_s N_{\rm neuronGeneral}` ) - + (5+ :math:`2 N_s N_{\rm neuronGeneral}` + :math:`N_v`): [int07] [int08] + +Parameters +^^^^^^^^^^ + +- [ string01 ] + + **Type :** string-type (blank parameter not allowed) + + **Description :** A keyword for total number of variational + parameters :math:`W_{i \sigma k}`. You can freely give a name of the keyword. + +- [ int01 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer giving total number of variational + parameters :math:`W_{i \sigma k}`. + +- [ string02 ] + + **Type :** string-type (blank parameter not allowed) + + **Description :** A keyword for indicating the double or complex type + of variational parameters :math:`W_{i \sigma k}`. You can freely give a name + of the keyword. + +- [ int02 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer indicates the double or complex type of + variational parameters :math:`W_{i \sigma k}` (0: double, 1: complex). + +- [ int03 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer giving a site index + (0 :math:`\leq` [ int03 ] :math:`<` ``Nsite``). + +- [ int04 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer giving a spin index + ([ int03 ] = 0 or 1 ). + +- [ int05 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer giving a neuron index + (0 :math:`\leq` [ int03 ] :math:`<` ``NneuronGeneral``). + +- [ int06 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer setting kinds of variational parameters + :math:`W_{i \sigma k}` (0 :math:`\leq` [ int05 ] :math:`<` [ int01]). + +- [ int07 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer giving kinds of variational parameters + (0 :math:`\leq` [ int06 ] :math:`<` [ int01]). + +- [ int08 ] + + **Type :** int-type (blank parameter not allowed) + + **Description :** An integer to select the target of variational + parameters indicated at [int06] to be optimized or not (0: not + optimize, 1: optimize). + +User rules +^^^^^^^^^^ + +- This function is a beta version. Please use it carefully. The file format and the implementation may be changed in the future release. + +- This function is available only for the VMC calculation with ``ComplexType=1`` and ``Orbital``. This function is not available for the Power Lanczos calculations. + +- Headers cannot be omitted. + +- A program is terminated, when [ int01 ] is + different from the total number of variational parameters defined in + this file. + +- A program is terminated, when [ int02 ] - + [ int06 ] are out of range from the defined values. + Orbital/OrbitalAntiParallel file (orbitalidx.def) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2374,7 +2796,7 @@ Files to set initial values of variational parameters This file sets the initial values of variational parameters. The kinds of variational parameters are specified by setting the following keywords in ``List`` file (namelist.def): -``InGutzwiller``, ``InJastrow``, ``InDH2``, ``InDH4``, ``InOrbital``, +``InGutzwiller``, ``InJastrow``, ``InDH2``, ``InDH4``, ``InGeneralRBM_PhysLayer``, ``InGeneralRBM_HiddenLayer``, ``InGeneralRBM_PhysHidden``, ``InOrbital``, ``InOrbitalAntiParallel``, ``InOrbitalParallel``, ``InOrbitalGeneral``. The file format is common and an example of the ``InJastrow`` file is diff --git a/doc/en/source/intro.rst b/doc/en/source/intro.rst index a36dd676..68d2631c 100644 --- a/doc/en/source/intro.rst +++ b/doc/en/source/intro.rst @@ -15,7 +15,7 @@ the low-energy effective models. One of the most reliable theoretical tools for treating the strongly correlated electron systems is the exact diagonalization method. However, applicable range of system size is strongly limited in the exact diagonalization method. Variational Monte -Carlo method [Gros_ ] is one of the promising ways to perform +Carlo method [Gros_ ] is one of promising way to perform the high-accuracy calculations for the larger system sizes beyond exact diagonalization method. Although the strong limitation of the variational wave function is the origin of the poor accuracy of the diff --git a/doc/en/source/output.rst b/doc/en/source/output.rst index 571fff72..743a277d 100644 --- a/doc/en/source/output.rst +++ b/doc/en/source/output.rst @@ -14,33 +14,39 @@ where both ``NDataIdxStart`` and ``NDataQtySmp`` are defined in ``ModPara`` file and zzz is a number given by ``NDataIdxStart`` in ``ModPara``. -+--------------------------------------+---------------------------------------------------------------+ -| Name | Details for corresponding files | -+======================================+===============================================================+ -| \*\*\*\_opt.dat | All optimized parameters. | -+--------------------------------------+---------------------------------------------------------------+ -| \*\*\*\_gutzwiller\_opt.dat | Optimized gutzwiller factors. | -+--------------------------------------+---------------------------------------------------------------+ -| \*\*\*\_jastrow\_opt.dat | Optimized jastrow factors. | -+--------------------------------------+---------------------------------------------------------------+ -| \*\*\*\_doublonHolon2site\_opt.dat | Optimized 2-site doublon-holon correlation factors. | -+--------------------------------------+---------------------------------------------------------------+ -| \*\*\*\_doublonHolon4site\_opt.dat | Optimized 4-site doublon-holon correlation factors. | -+--------------------------------------+---------------------------------------------------------------+ -| \*\*\*\_orbital\_opt.dat | Optimized pair orbital factors. | -+--------------------------------------+---------------------------------------------------------------+ -| xxx\_out\_yyy.dat | Energy and deviation. | -+--------------------------------------+---------------------------------------------------------------+ -| xxx\_var\_yyy.dat | Progress information for optimizing variational parameters. | -+--------------------------------------+---------------------------------------------------------------+ -| xxx\_CalcTimer.dat | Computation time for each processes. | -+--------------------------------------+---------------------------------------------------------------+ -| xxx\_time\_zzz.dat | Progress information for MonteCalro samplings. | -+--------------------------------------+---------------------------------------------------------------+ -| xxx\_cisajs\_yyy.dat | One body Green’s functions. | -+--------------------------------------+---------------------------------------------------------------+ -| xxx\_cisajscktalt\_yyy.dat | Correlation functions. | -+--------------------------------------+---------------------------------------------------------------+ ++------------------------------------------+------------------------------------------------------------------------------------------------------------------------+ +| Name | Details for corresponding files | ++==========================================+========================================================================================================================+ +| \*\*\*\_opt.dat | All optimized parameters. | ++------------------------------------------+------------------------------------------------------------------------------------------------------------------------+ +| \*\*\*\_gutzwiller\_opt.dat | Optimized gutzwiller factors. | ++------------------------------------------+------------------------------------------------------------------------------------------------------------------------+ +| \*\*\*\_jastrow\_opt.dat | Optimized jastrow factors. | ++------------------------------------------+------------------------------------------------------------------------------------------------------------------------+ +| \*\*\*\_doublonHolon2site\_opt.dat | Optimized 2-site doublon-holon correlation factors. | ++------------------------------------------+------------------------------------------------------------------------------------------------------------------------+ +| \*\*\*\_doublonHolon4site\_opt.dat | Optimized 4-site doublon-holon correlation factors. | ++------------------------------------------+------------------------------------------------------------------------------------------------------------------------+ +| \*\*\*\_generalRBM\_physlayer\_opt.dat | Optimized variational parameters of the general RBM correlation factors only in a physical layer. | ++------------------------------------------+------------------------------------------------------------------------------------------------------------------------+ +| \*\*\*\_generalRBM\_hiddenlayer\_opt.dat | Optimized variational parameters of the general RBM correlation factors only in a hidden layer. | ++------------------------------------------+------------------------------------------------------------------------------------------------------------------------+ +| \*\*\*\_orbital\_opt.dat | Optimized variational parameters of the general RBM correlation factors which connect physical and hidden layers. | ++------------------------------------------+------------------------------------------------------------------------------------------------------------------------+ +| \*\*\*\_orbital\_opt.dat | Optimized pair orbital factors. | ++------------------------------------------+------------------------------------------------------------------------------------------------------------------------+ +| xxx\_out\_yyy.dat | Energy and deviation. | ++------------------------------------------+------------------------------------------------------------------------------------------------------------------------+ +| xxx\_var\_yyy.dat | Progress information for optimizing variational parameters. | ++------------------------------------------+------------------------------------------------------------------------------------------------------------------------+ +| xxx\_CalcTimer.dat | Computation time for each processes. | ++------------------------------------------+------------------------------------------------------------------------------------------------------------------------+ +| xxx\_time\_zzz.dat | Progress information for Monte Carlo samplings. | ++------------------------------------------+------------------------------------------------------------------------------------------------------------------------+ +| xxx\_cisajs\_yyy.dat | One body Green’s functions. | ++------------------------------------------+------------------------------------------------------------------------------------------------------------------------+ +| xxx\_cisajscktalt\_yyy.dat | Correlation functions. | ++------------------------------------------+------------------------------------------------------------------------------------------------------------------------+ Output file for variational parameters (\*\*\*\_opt.dat) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -56,11 +62,11 @@ energy optimized by the SR method are outputted in the following order: The type of average values is a complex number, while that of the deviation is a real number. Since the initial values of all variational parameters are specified at the beginning of the calculation, the -calculation of physical quantities is done by using this file. +calculation of physical quantities is done by using this file file. Here, \*\*\* is the header indicated by ``CParaFileHead`` in ``ModPara`` file. -Output files for variational parameters at each step (xxx\_var\_yyy.dat) +Output files for variational parameters at each steps (xxx\_var\_yyy.dat) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The average and deviation values of variational parameters and the @@ -100,6 +106,13 @@ The optimized 4-site doublon-holon correlation factors by SR method are outputted. The file format is same as the ``InDH4`` file defined in Sec. :ref:`InputParam`. +Output files for general RBM factors(\*\*\*\_generalRBM\_physlayer\_opt.dat, \*\*\*\_generalRBM\_hiddenlayer\_opt.dat, \*\*\*\_generalRBM\_physhidden\_opt.dat) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The optimized general RBM correlation factors by SR method are outputted. +The file format is same as the ``InGeneralRBM_PhysLayer``, ``InGeneralRBM_HiddenLayer`` and ``InGeneralRBM_PhysHidden`` files defined in Sec. +:ref:`InputParam`. + Output file for pair orbitals (\*\*\*\_orbital\_opt.dat) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -138,9 +151,9 @@ where both ``NDataIdxStart`` and ``NDataQtySmp`` are defined in xxx\_CalcTimer.dat ~~~~~~~~~~~~~~~~~~~ -After finishing the calculation, the processing time is outputted in the -order of the name, the number assigned by the process, and the seconds at -each process. An example of outputted file is shown as follows. +After finishing calculation, the processing time is outputted in the +order of the name, the number assigned by the process and the seconds at +each processes. An example of outputted file is shown as follows. :: @@ -160,7 +173,7 @@ xxx\_time\_zzz.dat The calculation information at each bins are outputted in the order of the sampling number, the acceptance ratio for hopping and exchange term (acc\_hopp, acc\_ex), trial numbers to update for hopping and exchange -term (n\_hopp, n\_ex), and the time stamp. Here, xxx is the header +term (n\_hopp, n\_ex) and the time stamp. Here, xxx is the header indicated by ``CDataFileHead`` in ``ModPara`` file and zzz is a number given by ``NDataIdxStart`` in ``ModPara``. An example of outputted file is shown as follows. diff --git a/doc/en/source/standard.rst b/doc/en/source/standard.rst index 64fa0d01..a47072cb 100644 --- a/doc/en/source/standard.rst +++ b/doc/en/source/standard.rst @@ -42,7 +42,7 @@ An example of input file for the standard mode is shown below: 1. Parameters that must be specified (if not, ``vmcdry.out`` will stop with error messages), - 2. Parameters that are not necessary be specified (if not, default + 2. Parameters that is not necessary be specified (if not, default values are used), 3. Parameters that must not be specified (if specified, @@ -52,7 +52,7 @@ An example of input file for the standard mode is shown below: system. If you choose "model=spin", you should not specify ":math:`t`". -We explain each keyword as follows: +We explain each keywords as follows: Parameters about the kind of a calculation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -110,7 +110,7 @@ Parameters about the kind of a calculation [Eqn. :eq:`hubbard` ], the :math:`S_z`-unconserved Spin model [Eqn. :eq:`spin` ], and the :math:`S_z`-unconserved Kondo lattice model [Eqn. :eq:`kondo` ], respectively. Note: Although - these flags have a word "GC"(=grandcanonical), the number of electrons + these flags has a word "GC"(=grandcanonical), the number of electrons are conserved in these system. - ``lattice`` @@ -232,11 +232,11 @@ using the following two methods. **Type :** Integer **Description :** We can specify two vectors - (:math:`{\vec a}_0, {\vec a}_1`) that surround the numerical cell + (:math:`{\vec a}_0, {\vec a}_1`) that surrounds the numerical cell (Fig. :num:`unitlatticepng` ). These vectors should be specified in the Fractional coordinate. -If we use both of these methods, ``vmcdry.out`` stops. +If we use both of these method, ``vmcdry.out`` stops. We can check the shape of the numerical cell by using a file ``lattice.gp`` (only for square, trianguler, honeycomb, and kagome diff --git a/doc/en/source/start.rst b/doc/en/source/start.rst index a304b6f3..1ac589bc 100644 --- a/doc/en/source/start.rst +++ b/doc/en/source/start.rst @@ -268,7 +268,7 @@ We can calculate by using these modes as follows: #. Run - Run an executable ``vmc.out`` in terminal by specifying the name of + Run a executable ``vmc.out`` in terminal by specifying the name of input file written in previous step (option ``-s`` is required). .. code-block:: bash @@ -296,7 +296,7 @@ We can calculate by using these modes as follows: In the above case, the calculation starts as soon as input files for Expert mode are generated. If we only generate files without starting - the calculation, we can use an executable ``vmcdry.out`` as follows + the calculation, we can use a executable ``vmcdry.out`` as follows (MPI is not used in this step): .. code-block:: bash diff --git a/doc/en/source/tutorial.rst b/doc/en/source/tutorial.rst index 3922e84f..3b2e1aa3 100644 --- a/doc/en/source/tutorial.rst +++ b/doc/en/source/tutorial.rst @@ -267,7 +267,7 @@ The details of these outputted files are shown in :ref:`OutputFile`. Output results ^^^^^^^^^^^^^^ -After finishing the calculation normally, the files for the energy, the +After finishing calculation normally, the files for the energy, the deviation, the optimized variational parameters and the time of execution for each calculation steps are outputted in ``output/`` directory. In the following, the outputted files are shown diff --git a/doc/en/source/wannier/format.rst b/doc/en/source/wannier/format.rst index 5781980c..22a69992 100644 --- a/doc/en/source/wannier/format.rst +++ b/doc/en/source/wannier/format.rst @@ -27,9 +27,9 @@ By editing this file, we can modify the number of orbitals treated in HPhi/mVMC. * Line 4 - The number of orbitals per unit cell treated by mVMC/HPhi. + The number of orbitals par unit cell treated by mVMC/HPhi. When we reduce the number by editing this file, - the model includes the same number of orbitals from the top. + the model including the same number of orbitals from the top. * Line 5 - end diff --git a/doc/en/source/wannier/tutorial.rst b/doc/en/source/wannier/tutorial.rst index bb028e90..e7829060 100644 --- a/doc/en/source/wannier/tutorial.rst +++ b/doc/en/source/wannier/tutorial.rst @@ -10,7 +10,7 @@ We use QuantumESPRESSO for the DFT calculation. Input files are served in ``samples/Wannier/Sr2CuO3`` directory. -In actual studies, the input files, etc. of each solver should be modified for more high accuracy calculation. +In actual studies, the input files etc. of each solver should be modified for more high accuracy calculation. Please refer to the manuals of each solver for the details of the input files. SCF calculation of charge density @@ -107,9 +107,9 @@ Quantum lattice mode for HPhi/mVMC ---------------------------------- Using standard mode of HPhi/mVMC, the calculation will be done by reading the files in ``dir-model`` folder. -First, the files in ``dir-model`` directory should be moved to the current directory. +First, the files in ``dir-model`` directory should be moved to the current directry. Then, the calculation will be started by using standard mode. -For example, in HPhi, the calculation will be done by typing the following command: +For example, in HPhi, the calculation will be dobe by typing the following command: :download:`stan.in <../../../../samples/Wannier/Sr2CuO3/stan.in>` diff --git a/doc/ja/source/expert.rst b/doc/ja/source/expert.rst index a7262773..253f0783 100644 --- a/doc/ja/source/expert.rst +++ b/doc/ja/source/expert.rst @@ -74,11 +74,12 @@ .. math:: \begin{aligned} - |\psi \rangle &= {\cal P}_G{\cal P}_J{\cal P}_{d-h}^{(2)}{\cal P}_{d-h}^{(4)}{\cal L}^S{\cal L}^K{\cal L}^P |\phi_{\rm pair} \rangle,\\ + |\psi \rangle &= {\cal N}_{General RBM} {\cal P}_G{\cal P}_J{\cal P}_{d-h}^{(2)}{\cal P}_{d-h}^{(4)}{\cal L}^S{\cal L}^K{\cal L}^P |\phi_{\rm pair} \rangle,\\ {\cal P}_G&=\exp\left[ \sum_i g_i n_{i\uparrow} n_{i\downarrow} \right],\\ {\cal P}_J&=\exp\left[\frac{1}{2} \sum_{i\neq j} v_{ij} (n_i-1)(n_j-1)\right],\\ {\cal P}_{d-h}^{(2)}&= \exp \left[ \sum_t \sum_{n=0}^2 (\alpha_{2nt}^d \sum_{i}\xi_{i2nt}^d+\alpha_{2nt}^h \sum_{i}\xi_{i2nt}^h)\right],\\ {\cal P}_{d-h}^{(4)}&= \exp \left[ \sum_t \sum_{n=0}^4 (\alpha_{4nt}^d \sum_{i}\xi_{i4nt}^d+\alpha_{4nt}^h \sum_{i}\xi_{i4nt}^h)\right],\\ + {\cal N}_{\rm General RBM}&= \exp \left[ \sum_i a_{i\sigma} n_{i\sigma} \right] \prod_k^{N_h} \cosh \left[ b_k + \sum_{i\sigma} W_{i\sigma k} n_{i\sigma} \right],\\ {\cal L}_S&=\frac{2S+1}{8 \pi^2}\int d\Omega P_s(\cos \beta) \hat{R}(\Omega),\\ {\cal L}_K&=\frac{1}{N_s}\sum_{{\boldsymbol R}}e^{i {\boldsymbol K} \cdot{\boldsymbol R} } \hat{T}_{\boldsymbol R},\\ {\cal L}_P&=\sum_{\alpha}p_{\alpha} \hat{G}_{\alpha}, @@ -118,6 +119,15 @@ **DH4**: :math:`{\cal P}_{d-h}^{(4)}` で表される4サイトのダブロン・ホロン相関因子を指定します。 + + **GeneralRBM_PhysLayer**: + :math:`{\cal N}_{\rm General RBM}` で表されるRBM相関因子のうち、最適化の対象とする変分パラメータ :math:`a_{i\sigma}` を指定します。 + + **GeneralRBM_HiddenLayer**: + :math:`{\cal N}_{\rm General RBM}` で表されるRBM相関因子のうち、最適化の対象とする変分パラメータ :math:`h_{k}` を指定します。 + + **GeneralRBM_PhysHidden**: + :math:`{\cal N}_{\rm General RBM}` で表されるRBM相関因子のうち、最適化の対象とする変分パラメータ :math:`W_{i\sigma k}` を指定します。 **Orbital/OrbitalAntiParallel (orbitalidx.def)**: スピンが反平行のペア軌道 :math:`|\phi_{\rm pair} \rangle` を設定します。 @@ -149,6 +159,15 @@ **InDH4**: :math:`{\cal P}_{d-h}^{(4)}` 内の4サイトのダブロン・ホロン相関因子 :math:`\alpha_{4nt}^{d(h)}` の初期値を設定します。 + + **InGeneralRBM_PhysLayer**: + :math:`{\cal N}_{\rm General RBM}` で表されるRBM相関因子のうち、最適化の対象とする変分パラメータ :math:`a_{i\sigma}` の初期値を設定します。 + + **InGeneralRBM_HiddenLayer**: + :math:`{\cal N}_{\rm General RBM}` で表されるRBM相関因子のうち、最適化の対象とする変分パラメータ :math:`h_{k}` の初期値を設定します。 + + **InGeneralRBM_PhysHidden**: + :math:`{\cal N}_{\rm General RBM}` で表されるRBM相関因子のうち、最適化の対象とする変分パラメータ :math:`W_{i\sigma k}` の初期値を設定します。 **InOrbital/InOrbitalAntiParallel**: ペア軌道 :math:`|\phi_{\rm pair} \rangle` の :math:`f_{i\uparrow j\downarrow}` @@ -239,7 +258,10 @@ Gutzwiller 最適化するGutzwiller因子を設定します。 Jastrow 最適化する電荷Jastrow因子を指定します。 DH2 最適化する2サイトダブロン・ホロン相関因子を指定します。 - DH4 最適化する4サイトダブロン・ホロン相関因子を指定します。 + DH4 最適化する4サイトダブロン・ホロン相関因子を指定します。 + GeneralRBM_PhysLayer 一般的なRBM相関因子のうち、最適化する物理層での変分パラメータを指定します。 + GeneralRBM_HiddenLayer 一般的なRBM相関因子のうち、最適化する隠れ層での変分パラメータを指定します。 + GeneralRBM_PhysHidden 一般的なRBM相関因子のうち、最適化する物理層と隠れ層を繋ぐ変分パラメータを指定します。 Orbital :math:`^*` 反平行のスピンを持つペア軌道因子を指定します。 OrbitalAntiParallel 反平行のスピンを持つペア軌道因子を指定します。 OrbitalParallel 平行のスピンを持つペア軌道因子を指定します。 @@ -248,7 +270,10 @@ InGutzwiller Gutzwiller因子の初期値を設定します。 InJastrow 電荷Jastrow因子の初期値を設定します。 InDH2 2サイトダブロン・ホロン相関因子の初期値を設定します。 - InDH4 4サイトダブロン・ホロン相関因子の初期値を設定します。 + InDH4 4サイトダブロン・ホロン相関因子の初期値を設定します。 + InGeneralRBM_PhysLayer 一般的なRBM相関因子のうち、最適化する物理層での変分パラメータの初期値を設定します。 + InGeneralRBM_HiddenLayer 一般的なRBM相関因子のうち、最適化する隠れ層での変分パラメータの初期値を設定します。 + InGeneralRBM_PhysHidden 一般的なRBM相関因子のうち、最適化する物理層と隠れ層を繋ぐ変分パラメータの初期値を設定します。 InOrbital ペア軌道因子 :math:`f_{i\uparrow j\downarrow}` の初期値を設定します。 InOrbitalAntiParallel ペア軌道因子 :math:`f_{i\uparrow j\downarrow}` の初期値を設定します。 InOrbitalParallel ペア軌道因子 :math:`f_{i\sigma j\sigma}` の初期値を設定します。 @@ -294,7 +319,8 @@ ModParaファイル (modpara.def) NExUpdatePath 0 RndSeed 11272 NSplitSize 1 - NStore 1 + NStore 1 + NneuronGeneral 32 ファイル形式 ^^^^^^^^^^^^ @@ -552,6 +578,12 @@ ModParaファイル (modpara.def) を陽に構築せずに解くことでメモリを削減する [4]_ オプション[NeuscammanUmrigarChan_ ](1で機能On, ``NStore`` は1に固定されます)。 +- ``NneuronGeneral`` + + **形式 :** int型 (デフォルト値=0) + + **説明 :** RBMの隠れ層にあるニューロン数 :math:`N_{\rm General RBM}`を指定する整数。 + LocSpin指定ファイル(locspn.def) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1177,7 +1209,7 @@ PairHopカップリングをハミルトニアンに付け加えます。付け Exchange指定ファイル (exchange.def) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Exchangeカップリングをハミルトニアンに付け加えます。 電子系の場合には +Exchangeカップリングをハミルトニアンに付け加えます。 電子系,スピン系の両方の場合に .. math:: @@ -1185,13 +1217,7 @@ Exchangeカップリングをハミルトニアンに付け加えます。 電 (c_ {i \uparrow}^{\dagger}c_{j\uparrow}c_{j \downarrow}^{\dagger}c_{i \downarrow} +c_ {i \downarrow}^{\dagger}c_{j\downarrow}c_{j \uparrow}^{\dagger}c_{i \uparrow}) -が付け加えられ、スピン系の場合には - -.. math:: - - {\cal H}_E =\sum_{i,j}J_{ij}^{\rm Ex} (S_i^+S_j^-+S_i^-S_j^+) - -が付け加えられます。 以下にファイル例を記載します。 +が付け加えられます(スピン系の場合にHPhiとは定義が異なりますので注意してください)。 :: @@ -1757,6 +1783,383 @@ DH4指定ファイル - [ int02 ]-[ int10 ] を指定する際、範囲外の整数を指定した場合はエラー終了します。 +GeneralRBM_PhysLayer指定ファイル +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +RBM因子 + +.. math:: + + {\cal N}_{\rm General RBM}= \exp \left[ \sum_i a_{i\sigma} n_{i\sigma} \right] \prod_k^{N_{\rm neuronGeneral}} \cosh \left[ b_k + \sum_{i\sigma} W_{i\sigma k} n_{i\sigma} \right] + +のうち、 :math:`\exp \left[ \sum_i a_{i\sigma} n_{i\sigma} \right] ` の設定を行います。指定するパラメータはサイト番号 :math:`i`、スピン番号 :math:`\sigma`、および :math:`a_{i \sigma}` の変分パラメータの番号です。以下にファイル例を記載します。 + +:: + + -------------------- + NRBM_PhysLayerIdx 1 + ComplexType 1 + i s RBM_PhysLayer_Idx + -------------------- + 0 0 0 + 0 1 0 + 1 0 0 + 1 1 0 + (continue...) + 0 1 + +ファイル形式 +^^^^^^^^^^^^ + +以下のように行数に応じ異なる形式をとります( :math:`N_s` はサイト数、 :math:`N_v` は変分パラメータの種類の数)。 + +- 1行: ヘッダ(何が書かれても問題ありません)。 + +- 2行: [string01] [int01] + +- 3行: [string02] [int02] + +- 4-5行: ヘッダ(何が書かれても問題ありません)。 + +- 6 - (5+ :math:`2N_s`) 行: [int03] [int04] [int05] + +- (6+ :math:`2N_s` ) - + (5+ :math:`2N_s` + :math:`N_v`)行:[int06] [int07] + +パラメータ +^^^^^^^^^^ + +- [ string01 ] + + **形式 :** string型 (空白不可) + + **説明 :** + :math:`a_{i \sigma }` の変分パラメータの種類の総数のキーワード名を指定します(任意)。 + +- [ int01 ] + + **形式 :** int型 (空白不可) + + **説明 :** :math:`a_{i \sigma }` の変分パラメータの種類の総数を指定します。 + +- [ string02 ] + + **形式 :** string型 (空白不可) + + **説明 :** + :math:`a_{i \sigma }` の変分パラメータの型を指定するためのキーワード名を指定します(任意)。 + +- [ int02 ] + + **形式 :** int型 (空白不可) + + **説明 :** + :math:`a_{i \sigma }` の変分パラメータの型を指定します。0が実数、1が複素数に対応します。 + +- [ int03 ] + + **形式 :** int型 (空白不可) + + **説明 :** + サイト番号を指定する整数。0以上 ``Nsite`` 未満で指定します。 + +- [ int04 ] + + **形式 :** int型 (空白不可) + + **説明 :** + スピン番号を指定する整数。0もしくは1で指定します。 + +- [ int05 ] + + **形式 :** int型 (空白不可) + + **説明 :** + :math:`a_{i \sigma }` の変分パラメータの種類を表します。0以上[int01]未満で指定します。 + +- [ int06 ] + + **形式 :** int型 (空白不可) + + **説明 :** + :math:`a_{i \sigma }` の変分パラメータの種類を表します(最適化有無の設定用)。0以上[int01]未満で指定します。 + +- [ int07 ] + + **形式 :** int型 (空白不可) + + **説明 :** + [int06]で指定した :math:`a_{i \sigma }` の変分パラメータの最適化有無を設定します。最適化する場合は1、最適化しない場合は0とします。 + +使用ルール +^^^^^^^^^^ + +本ファイルを使用するにあたってのルールは以下の通りです。 + +- 本機能はベータ版のため、使用には十分注意してください。また、正式リリースした際に、ファイル形式や実装が変更される可能性があります。 + +- 本機能は ``ComplexType=1`` かつ ペア軌道のうち ``Orbital`` のみを指定したVMC計算のみ使用可能です。Power Lanczosの計算には対応していません。 + +- 行数固定で読み込みを行う為、ヘッダの省略はできません。 + +- [ int01 ] と定義されている変分パラメータの種類の総数が異なる場合はエラー終了します。 + +- [ int02 ]-[ int07 ] を指定する際、範囲外の整数を指定した場合はエラー終了します。 + + +GeneralRBM_HiddenLayer指定ファイル +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +RBM因子 + +.. math:: + + {\cal N}_{\rm General RBM}= \exp \left[ \sum_i a_{i\sigma} n_{i\sigma} \right] \prod_k^{N_{\rm neuronGeneral}} \cosh \left[ b_k + \sum_{i\sigma} W_{i\sigma k} n_{i\sigma} \right] + + +のうち、 :math:`\prod_k^{N_{\rm neuronGeneral}} \cosh \left[ b_k + \sum_{i\sigma} W_{i\sigma k} n_{i\sigma} \right] ` の隠れ層のみが関わる箇所の設定を行います。指定するパラメータは隠れニューロンの番号 :math:`k` と :math:`h_{k}` の変分パラメータの番号です。以下にファイル例を記載します。 + +:: + + -------------------- + NRBM_HiddenLayerIdx 2 + ComplexType 1 + k RBM_HiddenLayer_Idx + -------------------- + 0 0 + 1 0 + 2 0 + 3 0 + (continue...) + 0 1 + 1 1 + +ファイル形式 +^^^^^^^^^^^^ + +以下のように行数に応じ異なる形式をとります( :math:`N_{\rm neuronGeneral}` は隠れニューロンの数、 :math:`N_v` は変分パラメータの種類の数)。 + +- 1行: ヘッダ(何が書かれても問題ありません)。 + +- 2行: [string01] [int01] + +- 3行: [string02] [int02] + +- 4-5行: ヘッダ(何が書かれても問題ありません)。 + +- 6 - (5+ :math:`N_{\rm neuronGeneral}`) 行: [int03] [int04] + +- (6+ :math:`N_{\rm neuronGeneral}` ) - + (5+ :math:`N_{\rm neuronGeneral}` + :math:`N_v`)行:[int05] [int06] + +パラメータ +^^^^^^^^^^ + +- [ string01 ] + + **形式 :** string型 (空白不可) + + **説明 :** + :math:`h_{k}` の変分パラメータの種類の総数のキーワード名を指定します(任意)。 + +- [ int01 ] + + **形式 :** int型 (空白不可) + + **説明 :** :math:`h_{k}` の変分パラメータの種類の総数を指定します。 + +- [ string02 ] + + **形式 :** string型 (空白不可) + + **説明 :** + :math:`h_{k}` の変分パラメータの型を指定するためのキーワード名を指定します(任意)。 + +- [ int02 ] + + **形式 :** int型 (空白不可) + + **説明 :** + :math:`h_{k}` の変分パラメータの型を指定します。0が実数、1が複素数に対応します。 + +- [ int03 ] + + **形式 :** int型 (空白不可) + + **説明 :** + サイト番号を指定する整数。0以上 ``NneuronGeneral`` 未満で指定します。 + +- [ int04 ] + + **形式 :** int型 (空白不可) + + **説明 :** + :math:`h_{k}` の変分パラメータの種類を表します。0以上[int01]未満で指定します。 + +- [ int05 ] + + **形式 :** int型 (空白不可) + + **説明 :** + :math:`h_{k}` の変分パラメータの種類を表します(最適化有無の設定用)。0以上[int01]未満で指定します。 + +- [ int06 ] + + **形式 :** int型 (空白不可) + + **説明 :** + [int06]で指定した :math:`h_{k}` の変分パラメータの最適化有無を設定します。最適化する場合は1、最適化しない場合は0とします。 + +使用ルール +^^^^^^^^^^ + +本ファイルを使用するにあたってのルールは以下の通りです。 + +- 本機能はベータ版のため、使用には十分注意してください。また、正式リリースした際に、ファイル形式や実装が変更される可能性があります。 + +- 本機能は ``ComplexType=1`` かつ ペア軌道のうち ``Orbital`` のみを指定したVMC計算のみ使用可能です。Power Lanczosの計算には対応していません。 + +- 行数固定で読み込みを行う為、ヘッダの省略はできません。 + +- [ int01 ] と定義されている変分パラメータの種類の総数が異なる場合はエラー終了します。 + +- [ int02 ]-[ int06 ] を指定する際、範囲外の整数を指定した場合はエラー終了します。 + +GeneralRBM_PhysHidden指定ファイル +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +RBM因子 + +.. math:: + + {\cal N}_{\rm General RBM}= \exp \left[ \sum_i a_{i\sigma} n_{i\sigma} \right] \prod_k^{N_{\rm neuronGeneral}} \cosh \left[ b_k + \sum_{i\sigma} W_{i\sigma k} n_{i\sigma} \right] + + +のうち、 :math:`\prod_k^{N_{\rm neuronGeneral}} \cosh \left[ b_k + \sum_{i\sigma} W_{i\sigma k} n_{i\sigma} \right] ` の隠れ層と物理層どちらも関わる箇所の設定を行います。指定するパラメータはサイト番号、スピン番号、および隠れニューロンの番号 :math:`i \sigma k` と :math:`W_{i \sigma k}` の変分パラメータの番号です。以下にファイル例を記載します。 + +:: + + -------------------- + NRBM_HiddenLayerIdx 32 + ComplexType 1 + i s k RBM_PhysHidden_Idx + -------------------- + 0 0 0 0 + 0 1 0 1 + 1 0 0 2 + 1 1 0 3 + 2 0 0 4 + 2 1 0 5 + (continue...) + 0 1 + 1 1 + (continue...) + +ファイル形式 +^^^^^^^^^^^^ + +以下のように行数に応じ異なる形式をとります( :math:`N_s` はサイト数、:math:`N_{\rm neuronGeneral}` は隠れニューロンの数、 :math:`N_v` は変分パラメータの種類の数)。 + +- 1行: ヘッダ(何が書かれても問題ありません)。 + +- 2行: [string01] [int01] + +- 3行: [string02] [int02] + +- 4-5行: ヘッダ(何が書かれても問題ありません)。 + +- 6 - (5+ :math:`2 N_s N_{\rm neuronGeneral}`) 行: [int03] [int04] [int05] [int06] + +- (6+ :math:`2 N_s N_{\rm neuronGeneral}` ) - + (5+ :math:`2 N_s N_{\rm neuronGeneral}` + :math:`N_v`)行:[int07] [int08] + +パラメータ +^^^^^^^^^^ + +- [ string01 ] + + **形式 :** string型 (空白不可) + + **説明 :** + :math:`W_{i \sigma k}` の変分パラメータの種類の総数のキーワード名を指定します(任意)。 + +- [ int01 ] + + **形式 :** int型 (空白不可) + + **説明 :** :math:`W_{i \sigma k}` の変分パラメータの種類の総数を指定します。 + +- [ string02 ] + + **形式 :** string型 (空白不可) + + **説明 :** + :math:`W_{i \sigma k}` の変分パラメータの型を指定するためのキーワード名を指定します(任意)。 + +- [ int02 ] + + **形式 :** int型 (空白不可) + + **説明 :** + :math:`W_{i \sigma k}` の変分パラメータの型を指定します。0が実数、1が複素数に対応します。 + +- [ int03 ] + + **形式 :** int型 (空白不可) + + **説明 :** + サイト番号を指定する整数。0以上 ``Nsite`` 未満で指定します。 + +- [ int04 ] + + **形式 :** int型 (空白不可) + + **説明 :** + スピン番号を指定する整数。0もしくは1で指定します。 + +- [ int05 ] + + **形式 :** int型 (空白不可) + + **説明 :** + サイト番号を指定する整数。0以上 ``NneuronGeneral`` 未満で指定します。 + +- [ int06 ] + + **形式 :** int型 (空白不可) + + **説明 :** + :math:`W_{i \sigma k}` の変分パラメータの種類を表します。0以上[int01]未満で指定します。 + +- [ int07 ] + + **形式 :** int型 (空白不可) + + **説明 :** + :math:`W_{i \sigma k}` の変分パラメータの種類を表します(最適化有無の設定用)。0以上[int01]未満で指定します。 + +- [ int08 ] + + **形式 :** int型 (空白不可) + + **説明 :** + [int06]で指定した :math:`W_{i \sigma k}` の変分パラメータの最適化有無を設定します。最適化する場合は1、最適化しない場合は0とします。 + +使用ルール +^^^^^^^^^^ + +本ファイルを使用するにあたってのルールは以下の通りです。 + +- 本機能はベータ版のため、使用には十分注意してください。また、正式リリースした際に、ファイル形式や実装が変更される可能性があります。 + +- 本機能は ``ComplexType=1`` かつ ペア軌道のうち ``Orbital`` のみを指定したVMC計算のみ使用可能です。Power Lanczosの計算には対応していません。 + +- 行数固定で読み込みを行う為、ヘッダの省略はできません。 + +- [ int01 ] と定義されている変分パラメータの種類の総数が異なる場合はエラー終了します。 + +- [ int02 ]-[ int08 ] を指定する際、範囲外の整数を指定した場合はエラー終了します。 + Orbital/OrbitalAntiParallel指定ファイル(orbitalidx.def) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1864,7 +2267,7 @@ Orbital/OrbitalAntiParallel指定ファイル(orbitalidx.def) **形式 :** int型 (空白不可) **説明 :** - [int06]で指定した変分パラメータの最適化有無を設定します。最適化する場合は1、最適化しない場合は0とします。 + [int07]で指定した変分パラメータの最適化有無を設定します。最適化する場合は1、最適化しない場合は0とします。 使用ルール ^^^^^^^^^^ @@ -2234,7 +2637,7 @@ TransSym指定ファイル(qptransidx.def) 各変分パラメータの初期値を設定することが可能です。 変分パラメータの種類は :ref:`InputFileList` において -``InGutzwiller``, ``InJastrow``, ``InDH2``, ``InDH4``, ``InOrbital``, +``InGutzwiller``, ``InJastrow``, ``InDH2``, ``InDH4``, ``InGeneralRBM_PhysLayer``, ``InGeneralRBM_HiddenLayer``, ``InGeneralRBM_PhysHidden``, ``InOrbital``, ``InOrbitalAntiParallel``, ``InOrbitalParallel``, ``InOrbitalGeneral`` をキーワードとして指定することで区別します。なお、ファイルフォーマットは全て共通です。 以下、 ``InJastrow`` ファイルの例を記載します。 @@ -2301,6 +2704,8 @@ TransSym指定ファイル(qptransidx.def) 本ファイルを使用するにあたってのルールは以下の通りです。 +- RBM相関因子のインプット機能は、現バージョンではベータ版です。今後のバージョンアップにより、ファイル形式や実装が変更される可能性があります。本機能を使用する際は、十分な検証を行ってください。 + - 行数固定で読み込みを行う為、ヘッダの省略はできません。 - [ int01 ] と定義されている変分パラメータの総数が異なる場合はエラー終了します。 diff --git a/doc/ja/source/fourier/format.rst b/doc/ja/source/fourier/format.rst index 9dc217da..5791fda2 100644 --- a/doc/ja/source/fourier/format.rst +++ b/doc/ja/source/fourier/format.rst @@ -10,7 +10,7 @@ :ref:`tutorial` でのファイル名は ``geometry.dat`` . 各サイトの位置と軌道の情報は -mVMC/:math:`{\mathcal H}\Phi` のスタンダードモードを用いた場合には +mVMC/:math:`{\mathcal H}\Phi` のスタンンダードモードを用いた場合には 自動的に生成される. :: diff --git a/doc/ja/source/output.rst b/doc/ja/source/output.rst index e37d2566..3d31acf5 100644 --- a/doc/ja/source/output.rst +++ b/doc/ja/source/output.rst @@ -8,33 +8,41 @@ 出力ファイルの一覧は下記の通りです。\*\*\*には ``ModPara`` ファイルの ``CParaFileHead`` で指定されるヘッダが、xxxには ``CDataFileHead`` で指定されるヘッダが、yyyには ``ModPara`` ファイルの ``NDataIdxStart``, ``NDataQtySmp`` に従い ``NDataIdxStart`` :math:`\cdots` ``NDataIdxStart`` + ``NDataQtySmp`` の順に記載されます。また、zzzには ``ModPara`` ファイルの ``NDataIdxStart`` が記載されます。 -+--------------------------------------+-----------------------------------------------+ -| ファイル名 | 対応するファイルの中身 | -+======================================+===============================================+ -| \*\*\*\_opt.dat | 最適化された全パラメータ. | -+--------------------------------------+-----------------------------------------------+ -| \*\*\*\_gutzwiller\_opt.dat | 最適化されたGutzwiller因子. | -+--------------------------------------+-----------------------------------------------+ -| \*\*\*\_jastrow\_opt.dat | 最適化されたJastrow因子. | -+--------------------------------------+-----------------------------------------------+ -| \*\*\*\_doublonHolon2site\_opt.dat | 最適化された2サイトダブロン-ホロン相関因子. | -+--------------------------------------+-----------------------------------------------+ -| \*\*\*\_doublonHolon4site\_opt.dat | 最適化された4サイトダブロン-ホロン相関因子. | -+--------------------------------------+-----------------------------------------------+ -| \*\*\*\_orbital\_opt.dat | 最適化されたペア軌道因子. | -+--------------------------------------+-----------------------------------------------+ -| xxx\_out\_yyy.dat | エネルギーとその分散. | -+--------------------------------------+-----------------------------------------------+ -| xxx\_var\_yyy.dat | パラメータ最適化過程の情報. | -+--------------------------------------+-----------------------------------------------+ -| xxx\_CalcTimer.dat | 各プロセスに対する計算時間に関する情報. | -+--------------------------------------+-----------------------------------------------+ -| xxx\_time\_zzz.dat | モンテカルロサンプリングの過程に関する情報. | -+--------------------------------------+-----------------------------------------------+ -| xxx\_cisajs\_yyy.dat | 一体グリーン関数. | -+--------------------------------------+-----------------------------------------------+ -| xxx\_cisajscktalt\_yyy.dat | 二体グリーン関数. | -+--------------------------------------+-----------------------------------------------+ ++------------------------------------------+----------------------------------------------------------------------+ +| ファイル名 | 対応するファイルの中身 | ++==========================================+======================================================================+ +| \*\*\*\_opt.dat | 最適化された全パラメータ. | ++------------------------------------------+----------------------------------------------------------------------+ +| \*\*\*\_gutzwiller\_opt.dat | 最適化されたGutzwiller因子. | ++------------------------------------------+----------------------------------------------------------------------+ +| \*\*\*\_jastrow\_opt.dat | 最適化されたJastrow因子. | ++------------------------------------------+----------------------------------------------------------------------+ +| \*\*\*\_doublonHolon2site\_opt.dat | 最適化された2サイトダブロン-ホロン相関因子. | ++------------------------------------------+----------------------------------------------------------------------+ +| \*\*\*\_doublonHolon4site\_opt.dat | 最適化された4サイトダブロン-ホロン相関因子. | ++------------------------------------------+----------------------------------------------------------------------+ +| \*\*\*\_generalRBM\_physlayer\_opt.dat | 最適化されたRBM相関因子のうち、物理層のみに関わる変分パラメータ. | ++------------------------------------------+----------------------------------------------------------------------+ +| \*\*\*\_generalRBM\_hiddenlayer\_opt.dat | 最適化されたRBM相関因子のうち、隠れ層のみに関わる変分パラメータ. | ++------------------------------------------+----------------------------------------------------------------------+ +| \*\*\*\_generalRBM\_physhidden\_opt.dat | 最適化されたRBM相関因子のうち、物理層と隠れ層を繋ぐ変分パラメータ. | ++------------------------------------------+----------------------------------------------------------------------+ +| \*\*\*\_orbital\_opt.dat | 最適化されたペア軌道因子. | ++------------------------------------------+----------------------------------------------------------------------+ +| xxx\_out\_yyy.dat | エネルギーとその分散. | ++------------------------------------------+----------------------------------------------------------------------+ +| xxx\_SRinfo.dat | SR法に関連した情報. | ++------------------------------------------+----------------------------------------------------------------------+ +| xxx\_var\_yyy.dat | パラメータ最適化過程の情報. | ++------------------------------------------+----------------------------------------------------------------------+ +| xxx\_CalcTimer.dat | 各プロセスに対する計算時間に関する情報. | ++------------------------------------------+----------------------------------------------------------------------+ +| xxx\_time\_zzz.dat | モンテカルロサンプリングの過程に関する情報. | ++------------------------------------------+----------------------------------------------------------------------+ +| xxx\_cisajs\_yyy.dat | 一体グリーン関数. | ++------------------------------------------+----------------------------------------------------------------------+ +| xxx\_cisajscktalt\_yyy.dat | 二体グリーン関数. | ++------------------------------------------+----------------------------------------------------------------------+ 変分パラメータ出力ファイル(\*\*\*\_opt.dat) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -43,7 +51,7 @@ SR法で最適化された変分パラメータとエネルギーが一斉出力 変分パラメータが一斉に読み込めるため、変分パラメータ最適化後の物理量の計算を行う場合に使用します。 出力されるデータは -.. math:: \langle H \rangle, \langle H^2 \rangle, g_i, v_{ij}, \alpha_{2nt}^{d(h)}, \alpha_{4nt}^{d(h)}, f_{ij} \nonumber +.. math:: \langle H \rangle, \langle H^2 \rangle, g_i, v_{ij}, \alpha_{2nt}^{d(h)}, \alpha_{4nt}^{d(h)}, a_{i\sigma}, b_{k}, W_{i\sigma k}, f_{ij} \nonumber で、それぞれの平均値と標準偏差が出力されます(平均値は実数、虚数の順に、標準偏差は実数のみ出力)。 @@ -82,6 +90,12 @@ SR法で最適化された2サイトのdoublon-holon相関因子が出力され SR法で最適化された4サイトのdoublon-holon相関因子が出力されます。 出力形式は :ref:`InputParam` のInDH4指定ファイルと同じです。 +RBM相関因子出力ファイル(\*\*\*\_generalRBM\_physlayer\_opt.dat, \*\*\*\_generalRBM\_hiddenlayer\_opt.dat, \*\*\*\_generalRBM\_physhidden\_opt.dat) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +SR法で最適化されたRBM相関因子が出力されます。 +それぞれの出力形式は :ref:`InputParam` のInGeneralRBM_PhysLayer, InGeneralRBM_HiddenLayer, InGeneralRBM_PhysHidden指定ファイルと同じです。 + ペア軌道出力ファイル(\*\*\*\_orbital\_opt.dat) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -114,6 +128,23 @@ xxxには ``CDataFileHead`` で指定されるヘッダが、yyyには ``ModPara 2.072610167083121837e+02 2.029162857569105916e-01 … +xxx\_SRinfo.dat.dat +~~~~~~~~~~~~~~~~~~~~~ + +各最適化ステップごとに、 +変分パラメータ数 ``Npara`` 、S行列の次元数 ``Msize`` 、 ``Orbital`` などの入力ファイルで最適化しないと指定した実パラメータ数 ``optCut`` 、 ``ModPara`` ファイルの ``DSROptRedCut`` の値により削減された実パラメータ数 ``diagCut`` 、S行列の対角成分の最大値 ``sDiagMax`` と最小値 ``sDiagMin`` 、変分パラメータの変化量の最大値 ``absRmax`` とそのパラメータインデックス ``imax`` といったSR法による最適化情報が順に出力されます。 +xxxには ``ModPara`` ファイルの ``CDataFileHead`` で指定されるヘッダが記載されます。以下に出力例を記載します。なお、変分パラメータが実変数( ``ComplexType=0`` )として扱われた場合、虚部のパラメータ数は ``optCut`` にカウントされます。 + +:: + + #Npara Msize optCut diagCut sDiagMax sDiagMin absRmax imax + 4 4 4 0 4.17626e-02 0.00000e+00 -1.60883e-01 4 + 4 4 4 0 3.53941e-02 0.00000e+00 1.63056e-01 0 + 4 4 4 0 3.28032e-02 0.00000e+00 1.69939e-01 0 + 4 4 4 0 3.31451e-02 0.00000e+00 1.92363e-01 0 + … + + xxx\_CalcTimer.dat ~~~~~~~~~~~~~~~~~~~ diff --git a/doc/ja/source/start.rst b/doc/ja/source/start.rst index 04c6e1ad..43693657 100644 --- a/doc/ja/source/start.rst +++ b/doc/ja/source/start.rst @@ -253,7 +253,7 @@ mVMCは次の二つのいずれかのモードで動作します。 また、エキスパートモード用の入力ファイルを自動生成した後、計算をする前にそれらを手動で編集して より広範なモデルに対応させることも可能です。 -これらのモードを用いて次のように計算を行います。 +これらのモードを用いて次の用に計算を行います。 #. 計算用ディレクトリの作成 diff --git a/doc/tutorial/figs/tutorial1.1_es_opt.png b/doc/tutorial/figs/tutorial1.1_es_opt.png new file mode 100644 index 00000000..6a2652af Binary files /dev/null and b/doc/tutorial/figs/tutorial1.1_es_opt.png differ diff --git a/doc/tutorial/figs/tutorial1.1_gs_opt.png b/doc/tutorial/figs/tutorial1.1_gs_opt.png new file mode 100644 index 00000000..3f57a522 Binary files /dev/null and b/doc/tutorial/figs/tutorial1.1_gs_opt.png differ diff --git a/doc/tutorial/figs/tutorial1.1_gs_opt_zoom.png b/doc/tutorial/figs/tutorial1.1_gs_opt_zoom.png new file mode 100644 index 00000000..9eeada8b Binary files /dev/null and b/doc/tutorial/figs/tutorial1.1_gs_opt_zoom.png differ diff --git a/doc/tutorial/figs/tutorial1.2_sq.png b/doc/tutorial/figs/tutorial1.2_sq.png new file mode 100644 index 00000000..5f9be288 Binary files /dev/null and b/doc/tutorial/figs/tutorial1.2_sq.png differ diff --git a/doc/tutorial/figs/tutorial1.3_gs_opt.png b/doc/tutorial/figs/tutorial1.3_gs_opt.png new file mode 100644 index 00000000..28a9d34e Binary files /dev/null and b/doc/tutorial/figs/tutorial1.3_gs_opt.png differ diff --git a/doc/tutorial/figs/tutorial1.3_gs_opt_zoom.png b/doc/tutorial/figs/tutorial1.3_gs_opt_zoom.png new file mode 100644 index 00000000..4f831df2 Binary files /dev/null and b/doc/tutorial/figs/tutorial1.3_gs_opt_zoom.png differ diff --git a/doc/tutorial/figs/tutorial2.1_kondo.png b/doc/tutorial/figs/tutorial2.1_kondo.png new file mode 100644 index 00000000..f86caed4 Binary files /dev/null and b/doc/tutorial/figs/tutorial2.1_kondo.png differ diff --git a/doc/tutorial/figs/tutorial2.1_kondo_zoom.png b/doc/tutorial/figs/tutorial2.1_kondo_zoom.png new file mode 100644 index 00000000..26cd0e42 Binary files /dev/null and b/doc/tutorial/figs/tutorial2.1_kondo_zoom.png differ diff --git a/doc/tutorial/figs/tutorial2.1_spin.png b/doc/tutorial/figs/tutorial2.1_spin.png new file mode 100644 index 00000000..030e2b44 Binary files /dev/null and b/doc/tutorial/figs/tutorial2.1_spin.png differ diff --git a/doc/tutorial/figs/tutorial2.1_spin_zoom.png b/doc/tutorial/figs/tutorial2.1_spin_zoom.png new file mode 100644 index 00000000..2be804f7 Binary files /dev/null and b/doc/tutorial/figs/tutorial2.1_spin_zoom.png differ diff --git a/doc/tutorial/figs/tutorial2.2_sc_cor.png b/doc/tutorial/figs/tutorial2.2_sc_cor.png new file mode 100644 index 00000000..4f8d583f Binary files /dev/null and b/doc/tutorial/figs/tutorial2.2_sc_cor.png differ diff --git a/doc/tutorial/ja/source/CMakeLists.txt b/doc/tutorial/ja/source/CMakeLists.txt new file mode 100755 index 00000000..a9b848ab --- /dev/null +++ b/doc/tutorial/ja/source/CMakeLists.txt @@ -0,0 +1,48 @@ +find_program(SPHINX_EXECUTABLE NAMES sphinx-build + HINTS $ENV{SPHINX_DIR} + PATH_SUFFIXES bin + ) + +if(NOT SPHINX_EXECUTABLE) + message(FATAL_ERROR "SPHINX_EXECUTABLE (sphinx-build) is not found!") +endif() + +set(SPHINX_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/_build) +set(SPHINX_CACHE_DIR ${CMAKE_CURRENT_BINARY_DIR}/_doctrees) +set(SPHINX_HTML_DIR ${CMAKE_CURRENT_BINARY_DIR}/html) +set(SPHINX_PDF_DIR ${CMAKE_CURRENT_BINARY_DIR}/pdf) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf.py ${CMAKE_CURRENT_BINARY_DIR}) + +add_custom_target(tutorial-ja-html ALL + COMMAND + ${SPHINX_EXECUTABLE} + -b html + -d ${SPHINX_CACHE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${SPHINX_HTML_DIR} + ) + +add_custom_target(tutorial-ja-pdf ALL + COMMAND + ${SPHINX_EXECUTABLE} + -b latex + -d ${SPHINX_CACHE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${SPHINX_PDF_DIR} + COMMAND + cd pdf && make + ) + +add_custom_target(tutorial-ja DEPENDS tutorial-ja-html tutorial-ja-pdf) + +install(DIRECTORY ${SPHINX_HTML_DIR} + DESTINATION doc/tutorial/ja + PATTERN "_sources" EXCLUDE + PATTERN ".buildinfo" EXCLUDE + PATTERN "objects.inv" EXCLUDE + ) +install(DIRECTORY ${SPHINX_PDF_DIR} + DESTINATION doc/tutorial/ja + FILES_MATCHING PATTERN "*.pdf" + ) diff --git a/doc/tutorial/ja/source/advanced/index.rst b/doc/tutorial/ja/source/advanced/index.rst new file mode 100644 index 00000000..b4471b8e --- /dev/null +++ b/doc/tutorial/ja/source/advanced/index.rst @@ -0,0 +1,8 @@ +応用編 +=============================================== + +.. toctree:: + :maxdepth: 3 + + ./spin_gap.rst + ./sc_correlation.rst diff --git a/doc/tutorial/ja/source/advanced/sc_correlation.rst b/doc/tutorial/ja/source/advanced/sc_correlation.rst new file mode 100644 index 00000000..f1680606 --- /dev/null +++ b/doc/tutorial/ja/source/advanced/sc_correlation.rst @@ -0,0 +1,87 @@ +引力Hubbard模型における超伝導相関関数計算 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +mVMCは、任意の一体相関関数 :math:`c^{\dagger}_{i\sigma_i}c_{j\sigma_j}` および二体相関関数 :math:`c^{\dagger}_{i\sigma_i}c_{j\sigma_j} c^{\dagger}_{k\sigma_k}c_{l\sigma_l}` を測定できます。これらを組み合わせることで、これまでのチュートリアルで紹介してきたスピン構造因子などの物理量を求めることができます。 +このチュートリアルでは、ホールドープされた正方格子上の引力Hubbard模型における超伝導相関関数を計算する方法を説明します。 + +Hubbard模型は次のように定義されます。 + +.. math:: + + H = -t \sum_{\langle i,j\rangle, \sigma}c_{i\sigma}^{\dagger}c_{j\sigma} + U \sum_{i} n_{i\uparrow}n_{i\downarrow}. + +これまでのチュートリアルでは、相互作用項 :math:`U` を斥力項として取り扱ってきましたが、今回は :math:`U=-4` として引力項として取り扱います。各相互作用項を変更したい場合は、 ``stan_opt.in`` 等を直接修正してください。 + +なお、このチュートリアルは、 `ISSPデータリポジトリ `_ に登録されているチュートリアルがもとになっています。 + +これまでのチュートリアルと同様に、次のコマンドを実行すると本チュートリアルの内容が全て実行されます。:: + + sh run.sh + +実行スクリプトの中身は以下の通りです。 + +波動関数の最適化 +""""""""""""""""""""""""""""""""""""""""" +まず、乱数ペアリングの状態を初期状態として最適化を行います。 +今回のチュートリアルでは、 ``MakeInput.py`` を用いず、 ``tutorial_2.2`` ディレクトリにある ``stan_opt.in`` を使用します。スクリプトでは、次のコマンドを実行しています。:: + + ${VMCDRY} ./stan_opt.in + ${MPI} ${VMC} namelist.def + cp ./output/zqp_opt.dat . + mv output opt + +ここで ``${VMCDRY}`` は ``vmcdry.out`` 、 ``${VMC}`` は ``vmc.out`` へのパスを指定しています。 また、 ``${MPI}`` は MPI実行コマンドを指します。 +最適化が終わりましたら、 ``opt/zvo_out_001.dat`` をプロットしてみて、波動関数の最適化が収束していることを確認してください。 + +相関関数の測定 +""""""""""""""""""""""""""""""""""""""""" +続いて、最適化した波動関数を用いて相関関数を測定します。mVMCのスタンダードモードで生成される相関関数は、並進対照な波動関数に対して用いられるスピン構造因子と電荷構造因子が計算できるように設定されております。そのため、1sの超伝導相関関数を計算するためには、自分で相関関数を定義する必要があります。このチュートリアルでは、1sの超伝導相関関数を計算するために、 ``SCGreen.py`` というスクリプトを用意しています。このスクリプトを実行すると、 ``OneBodyG`` と ``TwoBodyG`` に対応する相関関数の定義ファイル ``green1`` と ``SC_1swave`` が生成されます。これらの定義ファイルを用いてmVMCの物理量測定を行います。測定が終わったら、出力ディレクトリを ``aft`` という名前に変更します。これらの一連の操作は、ジョブスクリプト ``run.sh`` 内の次のコマンドに対応しています。:: + + python3 SCGreen.py input.toml + ${VMCDRY} ./stan_aft.in + cp green1 greenone.def + cp SC_1swave greentwo.def + ${MPI} ${VMC} namelist.def ./zqp_opt.dat + mv output aft + + +超伝導相関関数の計算 +""""""""""""""""""""""""""""""""""""""""" +最後に、測定した相関関数を用いて1s超伝導相関関数を計算します。1s超伝導相関関数は次のように定義されます。 + + .. math:: + :label: sc_cor + + P(\boldsymbol{r}) = \frac{1}{N_s} \sum_{\boldsymbol{r}'} \langle \Delta^{\dagger} (\boldsymbol{r}') \Delta (\boldsymbol{r}'+\boldsymbol{r}) + \Delta (\boldsymbol{r}') \Delta^{\dagger} (\boldsymbol{r}'+\boldsymbol{r}) \rangle, + + .. math:: + + \Delta (\boldsymbol{r}) = \frac{1}{\sqrt{2}} \left( c_{\boldsymbol{r}\uparrow}c_{\boldsymbol{r}\downarrow} - c_{\boldsymbol{r}\downarrow} c_{\boldsymbol{r}\uparrow} \right), + + .. math:: + + \Delta^{\dagger} (\boldsymbol{r}) = \frac{1}{\sqrt{2}} \left( c^{\dagger}_{\boldsymbol{r}\downarrow}c^{\dagger}_{\boldsymbol{r}\uparrow} - c^{\dagger}_{\boldsymbol{r}\uparrow} c^{\dagger}_{\boldsymbol{r}\downarrow} \right). + +式 :eq:`sc_cor` を計算するために、このチュートリアルでは ``CalcSC.py`` というスクリプトを用意しています。 ``CalcSC.py`` を実行すると、距離 :math:`|\boldsymbol{r}|` に依存した1s超伝導相関関数の最大絶対値が ``Result_1swave.dat`` というファイルに出力されます。ジョブスクリプトでは、エネルギー等の計算と合わせて、次のコマンドで実行されます。:: + + python3 VMClocal.py input.toml + python3 CalcSC.py input.toml + +``gnuplot plot`` を実行することで、 厳密対角化の結果とともに ``Result_1swave.dat`` をプロットすることができます。 +計算が正常終了していると、次のような図が出力されます。 + +.. image:: ../../../figs/tutorial2.2_sc_cor.png + :scale: 125 % + :align: center + +紫丸がmVMCの結果を、緑線が厳密対角化の結果を表しています。mVMCの結果は厳密対角化での振る舞いを再現していることがわかります。 + + +演習 +----------------------- +- 引力相互作用を斥力にした場合、1sの超伝導相関関数がどのように変化するかを調べてください。 +- 1s超伝導相関関数の :math:`U` 依存性を調べてください。 + + +参考文献 +"""""""""""""""""""""" +#. `ISSPデータリポジトリ `_ diff --git a/doc/tutorial/ja/source/advanced/spin_gap.rst b/doc/tutorial/ja/source/advanced/spin_gap.rst new file mode 100644 index 00000000..2d062ac3 --- /dev/null +++ b/doc/tutorial/ja/source/advanced/spin_gap.rst @@ -0,0 +1,101 @@ +量子数射影を用いたスピンギャップ計算 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +量子数射影を用いることで、最適化する波動関数に対して特定の量子数を持たせることができます。このチュートリアルでは、一次元Heisenberg模型と一次元近藤格子模型を対象に、量子数射影をを用いてスピンギャップ :math:`\Delta_{\rm S}` を計算する方法を説明します。 + +スピンギャップ :math:`\Delta_{\rm S}=0` は、 :math:`S_{\rm tot}=0` 空間での最低エネルギーと :math:`S_{\rm tot}=1` 空間での最低エネルギーの差として定義されます。すなわち + +.. math:: + + \Delta_{\rm S} = E_{S_{\rm tot}=1} - E_{S_{\rm tot}=0}. + +を計算する必要があります。ここで、 :math:`E_{S_{\rm tot}=1}` と :math:`E_{S_{\rm tot}=0}` はそれぞれ、 :math:`S_{\rm tot}=1` での全エネルギー と :math:`S_{\rm tot}=0` での全エネルギーです。これらの全エネルギーは、mVMCで実装されているスピン量子数射影を用いれば計算することができます。 + + +一次元Heisenberg模型 +""""""""""""""""""""""""""""""""""""""""" +まず、システムサイズ :math:`L=8` での一次元Heisenberg模型におけるスピンギャプを計算します。一次元Heisenberg模型は次式で定義されます。 + +.. math:: + + H = J \sum_{\langle i,j\rangle}\boldsymbol{S}_{i} \cdot \boldsymbol{S}_{j},\ \boldsymbol{S}_{i} = \frac{1}{2} \sum_{\alpha,\beta} c_{i\alpha}^{\dagger} \boldsymbol{\sigma}_{\alpha\beta} c_{i\beta}. + +ここで、 :math:`\boldsymbol{\sigma}` はパウリ行列です。 :math:`S=1/2` の場合には、この模型の基底状態は :math:`\Delta_{\rm S}=0` であることが知られています。 + +次のコマンドを実行してください。:: + + sh run.sh spin + +コマンドを実行すると、 ``spin`` ディレクトリが作成され、その中に :math:`S_{\rm tot}=0` での最適化結果 ``output_s0`` と :math:`S_{\rm tot}=1` での最適化結果 ``output_s1`` が保存されています。 + + +最適化の結果を可視化するために、次のコマンドを実行してください。:: + + gnuplot plot_spin + +すると、次のような図が得られます。 + +.. image:: ../../../figs/tutorial2.1_spin.png + :scale: 125 % + :align: center + +紫点と緑点が、それぞれ :math:`S_{\rm tot}=0` 空間での最適化結果と :math:`S_{\rm tot}=1` 空間でのmVMCによる最適化結果です。水色線とオレンジ線は、厳密対角化によって得られたそれぞれの空間における最低エネルギーを示しています。 +次の図のように、最後の最適化付近を拡大してみると、mVMCは厳密対角化によって得られた結果とよく一致していることがわかります。このように、mVMCでは、量子数射影を用いることで、それぞれの空間における最低エネルギーを求めることができます。 + +.. image:: ../../../figs/tutorial2.1_spin_zoom.png + :scale: 125 % + :align: center + +この結果から、スピンギャップ :math:`\Delta_{\rm S}` を計算することができます。本来は最適化した波動関数を用いて物理量測定を行い、エネルギー期待値を求めるべきですが、ここでは最適化結果のエネルギーを直接用いて値を見積もります。 +最適化が正常終了すると、 ``output`` ディレクトリに ``zqp_opt.dat`` というファイルが出力されます。このファイルには、最後の最適化ステップから ``NSROptItrSmp`` 分の区間における最適化された波動関数のパラメータの平均値だけでなく、同区間におけるエネルギー値などといった物理量の平均値も出力されています。エネルギー(の実部)は、 ``zqp_opt.dat`` ファイルの初めに記載されています。 + +``spin/output_s0`` と ``spin/output_s1`` ディレクトリにある ``zqp_opt.dat`` ファイルからエネルギー値を習得した結果は ``spin/spin_gap.dat`` に出力されています。 ``spin_gap.dat`` の中身は次のようになっています。 :: + + #E0_from_zqp_opt.dat E1_from_zqp_opt.dat Delta_s=E1-E0 + -3.65109 -3.12842 .52267 + +ここで、最後の列がスピンギャップ :math:`\Delta_{\rm S}` の値となっています。 + + +演習 +----------------------- +- 物理量測定を行い、エネルギー期待値と誤差を求め、スピンギャップ値を計算してください。 +- システムサイズ :math:`L` を大きくしていき、スピンギャップ :math:`\Delta_{\rm S}` のシステムサイズ依存性を確認してください。 + + + +一次元近藤格子模型 +""""""""""""""""""""""""""""""""""""""""" +同じ計算をシステムサイズ :math:`L=4` でのハーフフィリングにおける一次元近藤格子模型に対して行います。近藤格子模型は、伝導層と局在スピン層が交換相互作用で結合している模型です。そのため、ユニットセルあたり2自由度あることになります。一次元近藤格子模型は次式で定義されます。 + +.. math:: + + H = -t \sum_{\langle i, j \rangle , \sigma} c^{\dagger}_{i\sigma {\rm c}} c_{j\sigma {\rm c}} + J \sum_{i}\boldsymbol{S}_{i {\rm c}} \cdot \boldsymbol{S}_{i {\rm s}}. + +ここで、 :math:`c^{\dagger}_{i\sigma {\rm c}}/c_{i\sigma {\rm c}}` は伝導層の生成/消滅演算子、 :math:`\boldsymbol{S}_{i {\rm c}}` は伝導層のスピン演算子、 :math:`\boldsymbol{S}_{i {\rm s}}` は局在スピン層のスピン演算子です。 :math:`S=1/2` の場合には、この模型の基底状態は :math:`\Delta_{\rm S} \neq 0` であることが知られています。(詳細は参考文献2を参照してください。) + +次のコマンドを実行した後、Heisenberg模型でのチュートリアル同様、最適化過程をプロットしてみてください。:: + + sh run.sh kondo + gnuplot plot_kondo + +すると、次のような図が得られます。 + +.. image:: ../../../figs/tutorial2.1_kondo.png + :scale: 125 % + :align: center + +.. image:: ../../../figs/tutorial2.1_kondo_zoom.png + :scale: 125 % + :align: center + +凡例はHeisenberg模型の場合と同じです。一次元近藤格子模型の場合においても、mVMCの最適化結果は厳密対角化によって得られた結果に収束していっていることがわかります。なお、最適化から得られたエネルギーをもとに計算したスピンギャップ :math:`\Delta_{\rm S}` の値は、 ``kondo/spin_gap.dat`` に出力されています。 + +演習 +----------------------- +- 物理量測定を行い、エネルギー期待値と誤差を求め、スピンギャップ値を計算してください。 +- システムサイズ :math:`L` を大きくしていき、スピンギャップ :math:`\Delta_{\rm S}` のシステムサイズ依存性を確認してください。 + +参考文献 +"""""""""""""""""""""" +#. `ISSPデータリポジトリ `_ +#. \H. Tsunetsugu, M. Sigrist, and K. Ueda, `Rev. Mod. Phys. 69, 809 (1997) `_ \ No newline at end of file diff --git a/doc/tutorial/ja/source/basic/hubbard_chain.rst b/doc/tutorial/ja/source/basic/hubbard_chain.rst new file mode 100644 index 00000000..f6366ea0 --- /dev/null +++ b/doc/tutorial/ja/source/basic/hubbard_chain.rst @@ -0,0 +1,125 @@ +一次元Hubbard模型 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +このチュートリアルでは、次の式で定義されるハーフフィリングにおける一次元Hubbard模型の基底状態とそのスピン・電荷相関を計算します。 + +.. math:: + + H = -t \sum_{\langle i,j\rangle, \sigma}c_{i\sigma}^{\dagger}c_{j\sigma} + U \sum_{i} n_{i\uparrow}n_{i\downarrow} + +このチュートリアルは、 `ISSPデータリポジトリ `_ に登録されているチュートリアルを元にしています。 +なお、 ``samples/tutorial_1.2`` にある ``run.sh`` を実行すると、これから説明する一連のコマンドが全て実行されます。 + + +スタンダードモードの入力ファイル生成 +""""""""""""""""""""""""""""""""""""""""" +まずは、スタンダードモードの入力ファイルを生成します。 +``samples/tutorial_1.2`` に移動したのち、次のコマンドを実行してください。:: + + python3 MakeInput.py input.toml + +実行すると、基底状態の最適化用入力ファイル ``stan_opt.in`` と物理量測定用入力ファイル ``stan_aft.in`` 、および物理量測定時に ``OneBodyG`` と ``TwoBodyG`` の入力として使われる ``green1`` と ``green2`` が生成されます。pythonスクリプト ``MakeInput.py`` の入力ファイル ``input.toml`` の中身は下記のとおりです:: + + [lattice] + Lx = 6 + Ly = 1 + Lz = 1 + orb_num = 1 + model_type = "Hubbard" + [mVMC] + sub_x = 2 + sub_y = 1 + sub_z = 1 + [mVMC_aft] + modpara = "modpara.def" + directory = "aft" + +このファイルはtoml形式で記述されています。 ``[lattice]`` には格子の情報が、 ``[mVMC]`` には波動関数に課す副格子構造を記載します。 ``[mVMC_aft]`` に記載されているパラメータは物理量測定計算の終了後の後処理スクリプトで使われます。 + +``[lattice]`` セクションの ``Lx`` は :math:`x` 方向の長さ、 ``Ly`` は :math:`y` 方向の長さ、 ``Lz`` は :math:`z` 方向の長さ、 ``orb_num`` はユニットセル内の軌道数(内部自由度)を指定します。 ``model_type`` は模型の種類を指定します。 ``Spin, Hubbard, Kondo`` の3つから選ぶ必要がありますが、ここではHubbard模型を指定しています。以上をまとめると、今回の計算では、ユニットセル内の自由度が1、長さが6格子点のHubbard鎖の系が指定されていることになります。 なお、相互作用などのその他のパラメータは、 ``MakeInput.py`` 内で直接指定されています。 このチュートリアルでは、 :math:`t=1` 、 :math:`U=4` としています。 + +``[mVMC]`` セクションの ``sub_x`` は :math:`x` 方向の副格子長、 ``sub_y`` は :math:`y` 方向の副格子長、 ``sub_z`` は :math:`z` 方向の副格子長を指定します。副格子構造を波動関数に課すことで変分パラメータ数を減らすことができるため、計算精度にあまり影響のない範囲で適切な副格子構造を課すことができれば効率の良い計算を実行できます。今回の計算では、反強磁性的な相関は取り入れたいので、2格子分の副格子を課しています。 + +``[mVMC_aft]`` セクションの ``modpara`` は物理量測定時に使われ +``ModPara`` で指定されるパラメータファイルを指定します。 ``directory`` は後処理スクリプトが読み込むディレクトリを指定しています。 + + +波動関数の最適化 +""""""""""""""""""""""""""""""" +次に、基底状態の最適化を行います。次のコマンドを実行してください。:: + + vmcdry.out ./stan_opt.in + vmc.out namelist.def + cp ./output/zqp_opt.dat . + mv output opt + +厳密対角化計算で得られた基底エネルギーは :math:`E_{0}=-3.668706` です。mVMCでの最適化過程が、この値に収束していくことを確認してください。 + + +物理量測定 +""""""""""""""""""""""""""""""" +波動関数の最適化では、エネルギーやバリアンスなどの情報は得られますが、状態を特徴づける相関関数は計算されません。物理量測定計算を行うことで、相関関数などの物理量を計算することができます。次のコマンドを実行してください。:: + + vmcdry.out ./stan_aft.in + cp green1 greenone.def + cp green2 greentwo.def + vmc.out namelist.def ./zqp_opt.dat + mv output aft + +2行目と3行目の ``cp`` コマンドを実行することで、 ``vmcdry.out`` で生成されるデフォルトの相関関数ファイルを上書きします。 + +物理量測定計算の結果は ``aft`` ディレクトリに格納されています。 ``zvo_cisajs_***.dat`` には ``OneBodyG`` で指定した一体相関関数 :math:`\langle {c^{\dagger}_{i\sigma_i} c_{j\sigma_j}} \rangle` の値が、 ``zvo_cisajscktalt_***.dat`` には ``TwoBodyG`` で指定した二体相関関数 :math:`\langle {c^{\dagger}_{i\sigma_i} c_{j\sigma_j} c^{\dagger}_{k\sigma_k} c_{l\sigma_l}} \rangle` の値が出力されています。( ``***`` はbin番号を表しています。) + + +後処理スクリプトの実行 +""""""""""""""""""""""""""""""" +最後に、後処理スクリプトを実行します。mVMCでは、物理量を測定する際にモンテカルロサンプリングを用います。また、出力される相関関数も :math:`\langle {c^{\dagger}_{i\sigma_i} c_{j\sigma_j} c^{\dagger}_{k\sigma_k} c_{l\sigma_l}} \rangle` のようにサイト・スピン番号に対して一般的な形式になっています。そのため、求めたい物理量を相関関数から計算した後で、それらを統計処理する必要があります。次のコマンドを実行してください。:: + + python3 VMClocal.py input.toml + python3 VMCcor.py input.toml + +``VMClocal.py`` を実行すると、統計処理したエネルギーと局所密度の値が ``Ene.dat`` と ``occ.dat`` にそれぞれ出力されます。mVMCは変分計算ですので、 mVMCで得られるエネルギー値は、厳密対角化計算で得られた基底エネルギーより高くなっているか、統計誤差の範囲で一致しているかのどちらかになっているはずです。 ``Ene.dat`` を確認してみると:: + + # Ene err_Ene Ene/(All_site) err_Ene/(All_site) + -3.664422 0.004452 -0.610737 0.000742 + +となっています。(並列数やサンプル数、環境等によって値が異なる可能性があります。)一列目が全エネルギーの期待値、二列目がその統計誤差、三列目が単位サイトあたりのエネルギー期待値、四列目がその統計誤差です。mVMCにより得られた全エネルギー値は、前述した厳密対角化法による真の基底エネルギー :math:`E_{0}=-3.668706` と統計誤差の範囲内で一致していることを確認できます。 + +``VMCcor.py`` を実行すると、相関関数から計算された物理量がいくつかのファイルに出力されます。例えば、 ``SqNq.dat`` には、スピンと電荷の構造因子が出力されています。 + + .. math:: + + S(q) = \frac{1}{L} \sum_{i,j} e^{iq(r_i-r_j)} \langle \boldsymbol{S}_i \cdot \boldsymbol{S}_j \rangle,\ + \boldsymbol{S}_i = \frac{1}{2} \sum_{\alpha, \beta} c^{\dagger}_{i\alpha} \boldsymbol{\sigma}_{\alpha\beta}c_{i\beta} + + .. math:: + + S^z(q) = \frac{1}{L} \sum_{i,j} e^{iq(r_i-r_j)} \langle S^z_i S^z_j \rangle + + .. math:: + + N(q) = \frac{1}{L} \sum_{i,j} e^{iq(r_i-r_j)} \langle n_i \cdot n_j \rangle,\ + n_i = n_{i\uparrow} + n_{i\downarrow} + +ここで、 :math:`L` は系のサイズを、 :math:`\boldsymbol{\sigma}_{\alpha\beta}` はパウリ行列を表しています。 +gnuplotを使って、 ``SqNq.dat`` に出力されているスピン構造因子 :math:`S(q)` をプロットしてみましょう。:: + + gnuplot + set xlabel "q/{/Symbol p}" + p "SqNq.dat" u ($1/3):3:4 w yerrorlines t "Spin structure factor S(q)" + +を実行すると、次のようなグラフが得られます。 + +.. image:: ../../../figs/tutorial1.2_sq.png + :scale: 125 % + :align: center + +波数 :math:`q=\pi` でスピン構造因子がピークを持っていることが確認できます。これは、反強磁性的な相関が発達していることを示しています。 + +演習 +----------------------- +厳密対角化ソフトウェアパッケージ :math:`\mathcal{H}\Phi` (https://www.pasums.issp.u-tokyo.ac.jp/hphi/) を用いて、基底状態のエネルギーと相関関数を計算し、mVMCの計算結果と比較してみてください。また、 ``MakeInput.py`` を修正して、相互作用パラメータ :math:`U` の値を変えた場合、スピン構造因子がどのように変化するのかを調べてみてください。 + + +参考文献 +"""""""""""""""""""""" +#. `ISSPデータリポジトリ `_ diff --git a/doc/tutorial/ja/source/basic/hubbard_dimer.rst b/doc/tutorial/ja/source/basic/hubbard_dimer.rst new file mode 100644 index 00000000..e8fab6c0 --- /dev/null +++ b/doc/tutorial/ja/source/basic/hubbard_dimer.rst @@ -0,0 +1,198 @@ +Hubbardダイマー +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +このチュートリアルでは、ハーフフィリングにおけるHubbardダイマーの基底状態と励起状態のエネルギーを計算します。 + +.. math:: + + H = -t \sum_{\sigma} \left( c_{0\sigma}^{\dagger}c_{1\sigma}+{\rm H.c.} \right) + +U \sum_{i=0,1} n_{i\uparrow}n_{i\downarrow} + +文献2に記載されているように、Hubbard dimerの基底状態 :math:`|{\rm GS} \rangle` は、 + +.. math:: + + \alpha=\frac{U}{\sqrt{U^2+16t^2}} + +を用いると、次のように表されます。 + +.. math:: + :label: exact_gs + + | {\rm GS} \rangle = \left[ \frac{\sqrt{1-\alpha}}{2} \left( c_{0\uparrow}^{\dagger}c_{0\downarrow}^{\dagger} + c_{1\uparrow}^{\dagger} c_{1\downarrow}^{\dagger} \right) + + \frac{\sqrt{1+\alpha}}{2} \left( c_{0\uparrow}^{\dagger}c_{1\downarrow}^{\dagger} - c_{0\downarrow}^{\dagger} c_{1\uparrow}^{\dagger} \right) \right] |0 \rangle + + + +ここで :math:`|0 \rangle` は真空状態を表しています。上記の状態はmVMCで実装されているペアリング波動関数で厳密に表現することができます。 + +波動関数の最適化 +""""""""""""""""""""""""""""""" + +スタンダードモード +-------------------------- +インプットファイル ``samples/tutorial_1.1/stan1.in`` を使って、基底状態のエネルギーを計算します。 +中身は次のようになっています:: + + L = 2 + Lsub = 2 + model = "FermionHubbard" + lattice = "chain" + t = 0.5 + U = 4.0 + ncond = 2 + NSPGaussLeg = 1 //default:8 + 2Sz = 0 + NSROptItrStep = 100 + NSROptItrSmp = 10 + NVMCSample = 100 + + +次のコマンドでmVMCを実行してください。 :: + + vmc.out -s stan.in + +計算結果は、 ``output`` ディレクトリに出力されます。 +エネルギーの最適化過程を確認するために、 ``output/zvo_out_001.dat`` を確認してみます。このファイルには、各最適化ステップごとにエネルギーなどの物理量が記載されています。エネルギーは一列目に出力されています。次のコマンドを実行してください:: + + gnuplot plot + +実行すると、下記のようなグラフが表示されます。 + +.. image:: ../../../figs/tutorial1.1_gs_opt.png + :scale: 125 % + :align: center + +紫の点がmVMCによるエネルギーの最適化過程を、黒の実線がHPhiを用いた厳密解の結果を示しています。ちゃんと収束していることを確認するには、最後のステップ数付近を拡大してみてください。モンテカルロサンプルリングをしているためエネルギー値に揺らぎがありますが、下記のようにエネルギーが落ち着いていたら収束しているといえます。 + +.. image:: ../../../figs/tutorial1.1_gs_opt_zoom.png + :scale: 125 % + :align: center + + +エキスパートモード +-------------------------- +Hubbard模型を含んだ遍歴電子系をスタンダードモードで取り扱う場合、指定した副格子構造を有したGutzwiller-Jastrow相関因子がデフォルトで使用されます。ここではスタンダードモードで生成した入力ファイルを元に、相関因子を用いないmVMC計算をエキスパートモードで実行します。 + +スタンダードモードで生成された入力ファイル ``namelist.def`` には、次のようにキーワードに対応したファイル名が記載されています。:: + + ModPara modpara.def + LocSpin locspn.def + Trans trans.def + CoulombIntra coulombintra.def + OneBodyG greenone.def + TwoBodyG greentwo.def + Gutzwiller gutzwilleridx.def + Jastrow jastrowidx.def + Orbital orbitalidx.def + TransSym qptransidx.def + +相関因子を使わないようにするには、GutzwillerとJastrowの行をコメントアウトする、もしくは削除する必要があります。(コメントアウトには#を用います。) +たとえば次のようなsedコマンドを使うと、 ``namelist.def`` 中のGutzwillerとJastrowの行をコメントアウトできます:: + + sed -i -e "s/Gutzwiller/#Gutzwiller/" namelist.def + sed -i -e "s/Jastrow/#Jastrow/" namelist.def + +``namelist.def`` を修正したら、:: + + vmc.out -e namelist.def + +もしくは:: + + vmc.out namelist.def + +を実行してください。計算が終了したら、スタンダードモードの時と同様にエネルギーの最適化過程を確認し、エネルギーが一定値に収束していることを確認してください。 + +最適化されたペアリング波動関数の情報は、``output/zqp_orbital_opt.dat`` に出力されています。次のコマンドを実行してください:: + + cat output/zqp_orbital_opt.dat + +結果は、大まかに次のようになっているかと思われます。:: + + ====================== + NOrbitalIdx 4 + ====================== + ====================== + ====================== + 0 -1.653588951124364659e+00 0.000000000000000000e+00 + 1 -3.983375054723054198e+00 0.000000000000000000e+00 + 2 -4.000000000000000000e+00 0.000000000000000000e+00 + 3 -1.653364791408409529e+00 0.000000000000000000e+00 + +5行目のヘッダ以降の数値が、最適化されたペアリング波動関数の情報です。一列目が変分パラメータのインデックス、二列目が変分パラメータの実部、三列目がその虚部です。今回は実数での計算になっているため、三列目は全て0が出力されています。なお、ここで出力されている値は、最適化の最終ステップから ``NSROptItrSmp`` ステップ数分前までの変分パラメータの平均値となっています。( ``NSROptItrSmp`` は ``modpara.def`` で設定できます。) + +変分パラメータのインデックスとペアリングの関係は、 ``orbitalidx.def`` に記載されています。次のコマンドを実行してください:: + + cat orbitalidx.def + +すると次のような出力が得られます。:: + + ============================================= + NOrbitalIdx 4 + ComplexType 0 + ============================================= + ============================================= + 0 0 0 + 0 1 1 + 1 0 2 + 1 1 3 + 0 1 + 1 1 + 2 1 + 3 1 + +5行目のヘッダ以降の数値が、ペアリング波動関数 :math:`\left(\sum_{i,j} f_{ij} c^{\dagger}_{i\uparrow} c^{\dagger}_{j\downarrow}\right) | 0 \rangle` に含まれる変分パラメータ :math:`f_{ij}` の情報です。一列目が変分パラメータ :math:`f_{ij}` の サイトインデックス :math:`i` 、二列目が :math:`f_{ij}` の :math:`j` 、三列目が :math:`f_{ij}` のインデックスです。 + +基底状態の厳密解 :eq:`exact_gs` によると、ペアリング波動関数の変分パラメータは次のようになることが期待されます。 + +.. math:: + + \frac{f_{00}}{f_{01}} = \frac{\sqrt{1-\alpha}}{\sqrt{1+\alpha}} + +上記の関係式を満たすよう変分パラメータが最適化されていそうかを確認してください。たとえば、 ``bc -l`` コマンドを使うと下記のように簡単に確認できます。:: + + $bc -l + >>> a=1/sqrt(2) + >>> sqrt(1-a)/sqrt(1+a) + .41421356237309504880 + >>> -1.653588951124364659/-3.983375054723054198 + .41512258534724672475 + +演習 +-------------------------- +ハーフフィリングにおけるHubbard dimerの基底エネルギーの厳密解は :math:`E=\frac{U}{2}\times(1 - \sqrt{(1+(4t/U)^2)})` となります。mVMCのスタンダードモード用の入力ファイル ``samples/tutorial_1.1/stan1.in`` を参考にして、厳密解の相互作用Uを再現できるか確かめてください。 + +初期状態の設定 +""""""""""""""""""""""""""""""" + +全スピンの大きさ :math:`S_{\rm tot}` が0の場合、一番エネルギーが高い励起状態 :math:`|{\rm ES} \rangle` とそのエネルギー :math:`E_{{\rm ES}}` は次のように表されます。 + +.. math:: + :label: exact_es + + |{\rm ES} \rangle = \left[ \frac{\sqrt{1+\alpha}}{2} \left( c_{0\uparrow}^{\dagger}c_{0\downarrow}^{\dagger} + c_{1\uparrow}^{\dagger} c_{1\downarrow}^{\dagger} \right) + - \frac{\sqrt{1-\alpha}}{2} \left( c_{0\uparrow}^{\dagger}c_{1\downarrow}^{\dagger} - c_{0\downarrow}^{\dagger} c_{1\uparrow}^{\dagger} \right) \right] |0 \rangle, + + +.. math:: + + E_{{\rm ES}}=\frac{U}{2}\times(1 + \sqrt{(1+(4t/U)^2)}) + +ここでは、励起状態 :eq:`exact_es` を初期状態として使って、基底状態最適化を行なってみます。これまでの計算では、変分パラメータ :math:`f_{ij}` の値を指定せずにmVMCを実行していました。指定しない場合、 :math:`f_{ij}` は乱数が自動的に振られるように実装されています。 + +今回のチュートリアルのように、ペアリング波動関数の初期状態を設定するためには、 ``namelist.def`` に ``InOrbital`` キーワードを追加してください。たとえば基底状態の最適化で得られた ``zqp_orbital_opt.dat`` を流用すると、次のような最適化過程を得られます。 + +.. figure:: ../../../figs/tutorial1.1_es_opt.png + :name: es_opt + :scale: 125 % + :align: center + +紫のデータ点がmVMCの最適化過程を、黒実線が厳密解のエネルギーを示しています。正しく設定できていると、最適化過程の初めのエネルギーが励起状態のエネルギーに近い値になっていることが確認できます。なお、初期状態が励起固有状態に近いほど、最適化過程では励起状態にトラップされてしまい、基底状態には収束しづらくなります。 + +演習 +-------------------------- +上述の説明やマニュアルを参考に、 準安定な励起状態を作ってみてください。 + +参考文献 +""""""""""""""""""""""""""""""" +1. HPhi tutorial, https://issp-center-dev.github.io/HPhi/manual/develop/tutorial/en/html/zero_temperature/hubbard_dimer.html +2. 高田康民, 多体問題特論 --第一原理からの多電子問題--, 朝倉書店 (2009). \ No newline at end of file diff --git a/doc/tutorial/ja/source/basic/hubbard_square.rst b/doc/tutorial/ja/source/basic/hubbard_square.rst new file mode 100644 index 00000000..b58340c7 --- /dev/null +++ b/doc/tutorial/ja/source/basic/hubbard_square.rst @@ -0,0 +1,65 @@ +二次元Hubbard模型 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +このチュートリアルでは、次の式で定義されるハーフフィリングにおける正方格子上の拡張Hubbard模型の基底状態を乱数ペアリングと平均場近似を元に構築した状態、それぞれを初期状態にして計算します。 + +.. math:: + + H = -t \sum_{\langle i,j\rangle, \sigma}c_{i\sigma}^{\dagger}c_{j\sigma} + U \sum_{i} n_{i\uparrow}n_{i\downarrow} + V \sum_{i`_ に登録されているチュートリアルを元にしています。 + + +乱数初期状態での最適化 +""""""""""""""""""""""""""""""""""""""""" +まず、乱数ペアリングの状態を初期状態として最適化を行います。mVMCの場合、初期状態を指定しないと自動的に乱数ペアリング状態が初期状態として用いられます。次のコマンドを実行してください。:: + + sh run.sh + +このコマンドを実行すると、tutorial_1.2 一次元Hubbard模型で説明した内容が全て実行されます。 + +演習 +----------------------- +- 得られた ``SqNq.dat`` を使って、スピン構造因子 :math:`S(\boldsymbol{q})` をプロットし、 :math:`\boldsymbol{q}=(\pi, \pi)` にピークを持つことを確認してください。 +- ``MakeInput.py`` を修正して、相互作用パラメータ :math:`U` と :math:`V` の値を変えた場合、スピン構造因子がどのように変化するのかを調べてみてください。 + + +UHF初期状態での最適化 +""""""""""""""""""""""""""""""" +次に、UHF (Unrestricted Hartree-Fock) 近似で得られた :math:`\prod_n (\sum_{i\sigma} \Phi_{in\sigma} c^{\dagger}_{i\sigma}) |0\rangle` からペアリング関数 :math:`(\sum_{i,j} f_{ij} c^{\dagger}_{i\uparrow} c^{\dagger}_{j\downarrow})^{N} |0\rangle` を構築し、それをmVMCの初期状態として最適化を行ってみます。詳細は論文等(例えば文献2を参照)で紹介されているので割愛しますが、次の関係式から構築することができます。 + + .. math:: + + f_{ij} = \sum_{n} \Phi_{in\uparrow} \Phi_{jn\downarrow} + +ここで、 :math:`\Phi_{in\sigma}` はUHF近似で得られた一電子軌道を、 :math:`n` はUHF近似の固有状態のインデックスを表しています。mVMCパッケージに含まれているUHFコードを使用することで、上述の式に基づいて ``InOrbital`` の形式に合わせた :math:`f_{ij}` を出力してくれます。 + +``sh run.sh`` を実行した後で、次のコマンドを実行してください。:: + + sh run_uhf.sh + +``run_uhf.sh`` は ``run.sh`` とほとんど同じです。主な違いは15、16行目の:: + + ${UHF} namelist.def + echo " InOrbital zqp_APOrbital_opt.dat " >> namelist.def + +です。一行目ではUHFコードを実行し、二行目ではUHFコードで構築された :math:`f_{ij}` が出力されたファイル ``zqp_APOrbital_opt.dat`` をmVMCの入力ファイル ``namelist.def`` に追記しています。 + +正常に実行された場合、 ``gnuplot plot`` を実行すると、次のようなグラフが得られます。 + +.. image:: ../../../figs/tutorial1.3_gs_opt.png + :scale: 125 % + :align: center + +.. image:: ../../../figs/tutorial1.3_gs_opt_zoom.png + :scale: 125 % + :align: center + +下図は、上図を拡大したものになっています。 +紫点が乱数ペアリングを初期状態にした結果、緑点がUHF近似から構築した状態を初期状態にした結果です。水色線と黒線は、それぞれ、UHFで得られたエネルギーと厳密対角化で得られるエネルギーです。UHF近似による初期状態を使ったほうが、初期ステップでのエネルギー値が低く、少ない最適化ステップ数で収束していることがわかります。 + +参考文献 +"""""""""""""""""""""" +#. `ISSPデータリポジトリ `_ +#. https://issp-center-dev.github.io/mVMC/doc/master/ja/algorithm.html#puffandslater \ No newline at end of file diff --git a/doc/tutorial/ja/source/basic/index.rst b/doc/tutorial/ja/source/basic/index.rst new file mode 100644 index 00000000..a0c35442 --- /dev/null +++ b/doc/tutorial/ja/source/basic/index.rst @@ -0,0 +1,9 @@ +基本編 +=============================================== + +.. toctree:: + :maxdepth: 3 + + ./hubbard_dimer.rst + ./hubbard_chain.rst + ./hubbard_square.rst diff --git a/doc/tutorial/ja/source/conf.py b/doc/tutorial/ja/source/conf.py new file mode 100644 index 00000000..cec33d5a --- /dev/null +++ b/doc/tutorial/ja/source/conf.py @@ -0,0 +1,188 @@ +# -*- coding: utf-8 -*- +# +# mVMC documentation build configuration file, created by +# sphinx-quickstart on Tue Nov 21 16:51:35 2017. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = ['sphinx.ext.mathjax'] +mathjax_pass = ['https://cdnjs.com/'] +math_number_all = True +spelling_lang='ja' +spelling_word_list_filename='spelling_wordlist.txt' +numfig = True + +# locale_dirs = ["locale"] +# gettext_compact = False + +highlight_language = 'none' + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'mVMC Tutorial' +copyright = u'2020-, The University of Tokyo' +author = u'The University of Tokyo' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '1.2' +# The full version, including alpha/beta/rc tags. +release = u'' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = 'ja' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This patterns also effect to html_static_path and html_extra_path +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = False + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +html_theme_options = { + 'logo': 'mVMC.png', + 'font_family': 'Georgia', + 'sidebar_search_button': 'pink_1' +} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static', '../../../figs'] + +# Custom sidebar templates, must be a dictionary that maps document names +# to template names. +# +# This is required for the alabaster theme +# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars +html_sidebars = { + '**': [ + 'relations.html', # needs 'show_related': True theme option to display + 'searchbox.html', + ] +} + + +# -- Options for HTMLHelp output ------------------------------------------ + +# Output file base name for HTML help builder. +htmlhelp_basename = 'tutorial_mVMC_endoc' + + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ('index', 'tutorial_mVMC.tex', u'mVMC Tutorial', + u'University of Tokyo', 'manual', 'True'), +] + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'tutorial_mVMC', u'mVMC Tutorial', + [author], 1) +] + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'tutorial_mVMC', u'mVMC Tutorial', + author, 'userguide_mVMC', 'One line description of project.', + 'Miscellaneous'), +] + +html_sidebars = { + '**': [ + 'about.html', + 'navigation.html', + 'relations.html', + 'searchbox.html', + 'donate.html', + ] +} diff --git a/doc/tutorial/ja/source/index.rst b/doc/tutorial/ja/source/index.rst new file mode 100644 index 00000000..694a0f16 --- /dev/null +++ b/doc/tutorial/ja/source/index.rst @@ -0,0 +1,42 @@ +##################################################### +Welcome to mVMC's tutorial! +##################################################### + +mVMC's tutorialについて +--------------------------------- + +本ページでは、量子スピン系や遍歴電子系といった様々な量子格子系を解析できる変分モンテカルロ法が実装されたオープンソースソフトウェアmVMCの使い方を解説します。 +mVMCについては、公式ページ https://github.com/issp-center-dev/mVMC +もしくは論文 `Comp. Phys. Commun. 235 447-462 (2019). `_ をご参照ください。 + + +ライセンス +-------------- +mVMCのマニュアルおよびソースコード一式はGNU General +Public License version 3(GPL v3)に準じて下記リンク先で配布されています。 + +| URL: https://github.com/issp-center-dev/mVMC + +mVMCの引用文献としては、下記の論文をご記載ください。 + +| mVMCの論文: Takahiro Misawa, Satoshi Morita, Kazuyoshi Yoshimi, Mitsuaki Kawamura, Yuichi Motoyama, + Kota Ido, Takahiro Ohgoe, Masatoshi, and Takeo Kato, `Comp. Phys. Commun. 235 447-462 (2019). `_ + + + + +チュートリアル +-------- +.. toctree:: + :maxdepth: 3 + :numbered: 4 + + basic/index + advanced/index + +.. Indices and tables +.. ================== + +.. * :ref:`genindex` +.. * :ref:`modindex` +.. * :ref:`search` diff --git a/doc/tutorial/ja/source/spell_check.sh b/doc/tutorial/ja/source/spell_check.sh new file mode 100644 index 00000000..f50abef5 --- /dev/null +++ b/doc/tutorial/ja/source/spell_check.sh @@ -0,0 +1 @@ +sphinx-build -b spelling -d _build/doctrees . _build_spelling diff --git a/doc/tutorial/ja/source/spelling_wordlist.txt b/doc/tutorial/ja/source/spelling_wordlist.txt new file mode 100644 index 00000000..89fe8161 --- /dev/null +++ b/doc/tutorial/ja/source/spelling_wordlist.txt @@ -0,0 +1,159 @@ +bd +ba +fd +yoshimi +bd +ba +fd +ccf +fe +Hidetoshi +Nishimori +Daisuke +Tahara +Lanczos +diagonalization +ver +Yuichi +Motoyama +Yasuyuki +Kato +Takeo +Hoshi +Tomohiro +Sogabe +Krylov +Bogoliubov +doi +JPSJ +subdiagonal +Mersenne +dSFMT +Iwanami +ies +Shoten +Sugiura +Shimizu +wavefunctions +wavefunction +mTPQ +Lett +Takahiro +Misawa +CalcType +CalcModel +Hund +Ising +CalcMod +ModPara +LocSpin +xxx +Kondo +dat +isite +tmp +idim +mem +Flct +doublon +stp +TMcomponents +TimeKeeper +EigenVector +TPQ +spni +spnj +cisajs +OneBodyG +eigen +cisajscktalt +TwoBodyG +eigenvec +Sz +eigenvetor +Nup +Ndown +recalcvec +tmpvec +onsite +Kagome +Offsite +hoppings +offdiagonal +Yamamoto +Zhang +Fujiwara +LOBCG +BiCG +eigenenergy +Eqn +GC +Yamaji +Knyazev +Yamada +Imamura +Machida +OpenMP +MPI +sdry +mpirun +mpiexec +HPhi +gz +sekirei +maki +fortran +CMake +gcc +hamiltonians +Mitsuaki +Kawamura +Kazuyoshi +Youhei +Todo +Naoki +Kawashima +diagonalizations +Dzyaloshinskii +Moriya +Kitaev +Dagotto +Imada +Takahashi +Jaklič +Prelovšek +Raedt +Nomura +Kurita +Arita +namelist +locspn +zTrans +zInterall +greenone +greentwo +antiferromagnetic +eigenenergies +zvo +eigennumber +indices +Acknowledgement +Sugihara +Murota +http +titech +www +jp +nishimori +titpack +html +hiroshima +SFMT +sz +offsite +modpara +DynamicalGreen +countings +Frommer +calcmod + diff --git a/mVMCconfig.sh b/mVMCconfig.sh index f731ccc7..0b7e1d62 100755 --- a/mVMCconfig.sh +++ b/mVMCconfig.sh @@ -40,7 +40,7 @@ F90 = frt FFLAGS = -DNDEBUG -DFUJITSU -Kfast CFLAGS = -DNDEBUG -Ofast -fopenmp CXXFLAGS = -DNDEBUG -Ofast -fopenmp -CFLAGS += -D_lapack -D_pf_block_update # -D_pfaffine +CFLAGS += -D_lapack -D_pf_block_update CXXFLAGS += -DBLAS_EXTERNAL BLIS_ROOT = ${PWD}/src/blis-install @@ -74,7 +74,7 @@ F90 = ifort FFLAGS = -O3 -implicitnone CFLAGS = -O3 -qopenmp -Wno-unknown-pragmas CXXFLAGS = -O3 -std=gnu++14 -fpic -qopenmp -CFLAGS += -D_lapack -D_pf_block_update -D_pfaffine +CFLAGS += -D_lapack -D_pf_block_update CXXFLAGS += -DMKL -DBLAS_EXTERNAL -DF77_COMPLEX_RET_INTEL BLIS_ROOT = ${PWD}/src/blis-install @@ -100,7 +100,7 @@ F90 = ifort FFLAGS = -O3 -implicitnone CFLAGS = -O3 -qopenmp -Wno-unknown-pragmas CXXFLAGS = -O3 -std=gnu++14 -fpic -qopenmp -CFLAGS += -D_lapack -D_pf_block_update -D_pfaffine +CFLAGS += -D_lapack -D_pf_block_update CXXFLAGS += -DMKL -DBLAS_EXTERNAL -DF77_COMPLEX_RET_INTEL BLIS_ROOT = ${PWD}/src/blis-install @@ -124,7 +124,7 @@ F90 = flang FFLAGS = -O3 CFLAGS = -O3 -fopenmp CXXFLAGS = -O3 -fPIC -CFLAGS += -D_lapack -D_pf_block_update -D_pfaffine +CFLAGS += -D_lapack -D_pf_block_update CXXFLAGS += BLIS_ROOT = ${PWD}/src/blis-install @@ -148,7 +148,7 @@ F90 = gfortran FFLAGS = -O3 -fimplicit-none CFLAGS = -O3 -fopenmp CXXFLAGS = -O3 -fPIC -CFLAGS += -D_lapack -D_pf_block_update -D_pfaffine +CFLAGS += -D_lapack -D_pf_block_update CXXFLAGS += BLIS_ROOT = ${PWD}/src/blis-install @@ -172,7 +172,7 @@ F90 = gfortran FFLAGS = -O3 -fimplicit-none CFLAGS = -O3 -fopenmp CXXFLAGS = -O3 -CFLAGS += -D_lapack -D_pf_block_update -D_pfaffine +CFLAGS += -D_lapack -D_pf_block_update CXXFLAGS += -DMKL -DBLAS_EXTERNAL -DF77_COMPLEX_RET_INTEL BLIS_ROOT = ${PWD}/src/blis-install @@ -196,7 +196,7 @@ F90 = gfortran FFLAGS = -O3 -fimplicit-none CFLAGS = -O3 -fopenmp CXXFLAGS = -O3 -CFLAGS += -D_lapack -D_pf_block_update -D_pfaffine +CFLAGS += -D_lapack -D_pf_block_update CXXFLAGS += BLIS_ROOT = ${PWD}/src/blis-install @@ -220,7 +220,7 @@ F90 = gfortran FFLAGS = -O3 -fimplicit-none CFLAGS = -O3 -fopenmp CXXFLAGS = -O3 -CFLAGS += -D_lapack -D_pf_block_update -D_pfaffine +CFLAGS += -D_lapack -D_pf_block_update CXXFLAGS += # -DBLAS_EXTERNAL # -DF77_COMPLEX_RET_INTEL # For Apple. BLIS_ROOT = ${PWD}/src/blis-install @@ -242,7 +242,6 @@ EOF cat src/make.sys cat src/make-ext.sys ln -s $PWD/src/make.sys src/StdFace/make.sys; - ln -s $PWD/src/make.sys src/pfaffine/make.inc; ln -s $PWD/src/make.sys src/pfapack/fortran/make.inc; cat > makefile < max_Sq: + max_Sq = ave_Sq[kx][ky] + max_Sq_err = err_Sq[kx][ky] + max_Sq_kx = kx + max_Sq_ky = ky + # + if ave_Nq[kx][ky] > max_Nq: + max_Nq = ave_Nq[kx][ky] + max_Nq_err = err_Nq[kx][ky] + max_Nq_kx = kx + max_Nq_ky = ky + print("%d %d %12.8f %12.8f %12.8f %12.8f %12.8f %12.8f" % (kx,ky,ave_Sq[kx][ky],err_Sq[kx][ky],ave_Sz[kx][ky],err_Sz[kx][ky],ave_Nq[kx][ky],err_Nq[kx][ky]), file=f) + elif dim_type==2: + for ky in range(0,list_org[1]+1): + if ave_Sq[kx][ky] > max_Sq: + max_Sq = ave_Sq[kx][ky] + max_Sq_err = err_Sq[kx][ky] + max_Sq_kx = kx + max_Sq_ky = ky + # + if ave_Nq[kx][ky] > max_Nq: + max_Nq = ave_Nq[kx][ky] + max_Nq_err = err_Nq[kx][ky] + max_Nq_kx = kx + max_Nq_ky = ky + print("%d %d %12.8f %12.8f %12.8f %12.8f %12.8f %12.8f" % (kx,ky,ave_Sq[kx][ky],err_Sq[kx][ky],ave_Sz[kx][ky],err_Sz[kx][ky],ave_Nq[kx][ky],err_Nq[kx][ky]), file=f) + print(" " , file=f) + elif dim_type==3: + print("not implemented yet") + with open("MaxSq.dat", 'w') as f: + print("%12.8f %12.8f %d %d " % (max_Sq,max_Sq_err,max_Sq_kx,max_Sq_ky), file=f) + with open("MaxNq.dat", 'w') as f: + print("%12.8f %12.8f %d %d " % (max_Nq,max_Nq_err,max_Nq_kx,max_Nq_ky), file=f) + #[e] Sq,Nq + +def OutputNk(list_org,all_Nk,dim_type): + max_cnt = all_Nk.shape[0] + #[s] Nk + ave_Nk = np.mean(all_Nk,axis=0) + err_Nk = np.std(all_Nk,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + with open("Nk.dat", 'w') as f: + print(" %s " % ("# kx ky Nk err_Nk "), file=f) + for kx in range(-int(list_org[0]/2),int(list_org[0]/2)+1): + if kx <0: + tmp_kx = kx+list_org[0] + else: + tmp_kx = kx + if dim_type==1: + ky = 0 + tmp_ky = 0 + print("%d %d %12.8f %12.8f " % (kx,ky,ave_Nk[tmp_kx][tmp_ky],err_Nk[tmp_kx][tmp_ky]), file=f) + elif dim_type==2: + for ky in range(-list_org[1],list_org[1]+1): + if ky <0: + tmp_ky = ky+list_org[1] + else: + tmp_ky = ky + print("%d %d %12.8f %12.8f " % (kx,ky,ave_Nk[tmp_kx][tmp_ky],err_Nk[tmp_kx][tmp_ky]), file=f) + print(" " , file=f) + elif dim_type==3: + print("Not implemented yet") + #[e] Nk + +def ReadGreen(list_org,max_cnt,dir_name): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + orb_num = list_org[3] + All_N = Lx*Ly*Lz*orb_num + #[s] allocate + G1 = np.zeros((max_cnt,All_N,All_N,2),dtype=np.float64) + G2_ex = np.full((max_cnt,All_N,All_N,2,2),-100,dtype=np.float64) + G2_sz = np.full((max_cnt,All_N,All_N,2,2),-100,dtype=np.float64) + #[e] allocate + for num_bin in range(max_cnt): + file_name ="%s/zvo_cisajs_00%d.dat" %(dir_name,num_bin) + + with open(file_name) as f: + tmp_G1 = f.read() + tmp_G1 = tmp_G1.split("\n") + #[s] count not empty elements + cnt = 0 + for i in range(0,len(tmp_G1)): + if tmp_G1[i]: # if data[i] is not empty + cnt += 1 + #print(cnt) + cnt_max = cnt + #[e] count not empty elements + for cnt in range(0,cnt_max): + tmp = tmp_G1[cnt].split() + all_i = int(tmp[0]) + all_j = int(tmp[2]) + spn = int(tmp[1]) + #print(tmp) + G1[num_bin][all_i][all_j][spn] = float(tmp[4]) + + file_name ="%s/zvo_cisajscktalt_00%d.dat" %(dir_name,num_bin) + with open(file_name) as f: + data = f.read() + data = data.split("\n") + #[s] count not empty elements + cnt = 0 + for i in range(0,len(data)): + if data[i]: # if data[i] is not empty + cnt += 1 + #print(cnt) + cnt_max = cnt + #[e] count not empty elements + for cnt in range(0,cnt_max): + tmp = data[cnt].split() + all_i = int(tmp[0]) + all_j = int(tmp[2]) + all_k = int(tmp[4]) + all_l = int(tmp[6]) + spn_0 = int(tmp[1]) + spn_1 = int(tmp[5]) + if all_i == all_j and all_k == all_l and all_i==all_k: + G2_sz[num_bin][all_i][all_j][spn_0][spn_1] = float(tmp[8]) + G2_ex[num_bin][all_i][all_j][spn_0][spn_1] = float(tmp[8]) + elif all_i == all_j and all_k == all_l: + G2_sz[num_bin][all_i][all_k][spn_0][spn_1] = float(tmp[8]) + elif all_i == all_l and all_j == all_k: + G2_ex[num_bin][all_i][all_j][spn_0][spn_1] = float(tmp[8]) + else: + print("fatal error in 2-body Green functions") + return G1,G2_sz,G2_ex + +def CalcSq_tot(list_org,G1,G2_sz,G2_ex,dir_name,max_cnt): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + orb_num = list_org[3] + All_N = Lx*Ly*Lz*orb_num + All_site = Lx*Ly*Lz + all_Sq = np.full((max_cnt,list_org[0]+1,list_org[1]+1),-100,dtype=np.float64) + all_Sz = np.full((max_cnt,list_org[0]+1,list_org[1]+1),-100,dtype=np.float64) + all_Nq = np.full((max_cnt,list_org[0]+1,list_org[1]+1),-100,dtype=np.float64) + all_Nk = np.full((max_cnt,list_org[0]+1,list_org[1]+1),-100,dtype=np.float64) + + for num_bin in range(max_cnt): + with open("%s/total_SqNq_%d.dat" % (dir_name,num_bin), 'w') as f: + for kx in range(0,Lx+1): + for ky in range(0,Ly+1): + tmp_Sq = 0.0 + tmp_Sz = 0.0 + tmp_Nq = 0.0 + tmp_Nk = 0.0 + Ncond = 0 + for all_i in range(0,All_N): + Ncond+= G1[num_bin][all_i][all_i][0] + Ncond+= G1[num_bin][all_i][all_i][1] + for all_j in range(0,All_N): + list_site = qlms_lattice.get_site(all_i,list_org) + i_x = list_site[0] + i_y = list_site[1] + # + list_site = qlms_lattice.get_site(all_j,list_org) + j_x = list_site[0] + j_y = list_site[1] + + theta = 2*math.pi*kx*(i_x-j_x)/Lx+2*math.pi*ky*(i_y-j_y)/Ly + # + tmp_uu = G2_sz[num_bin][all_i][all_j][0][0] + tmp_ud = G2_sz[num_bin][all_i][all_j][0][1] + tmp_du = G2_sz[num_bin][all_i][all_j][1][0] + tmp_dd = G2_sz[num_bin][all_i][all_j][1][1] + + # + tmp_Nk += G1[num_bin][all_i][all_j][0]*math.cos(theta) + tmp_Nk += G1[num_bin][all_i][all_j][1]*math.cos(theta) + # + tmp_Nq += tmp_uu*math.cos(theta) + tmp_Nq += tmp_dd*math.cos(theta) + tmp_Sq += 0.25*tmp_uu*math.cos(theta) + tmp_Sq += 0.25*tmp_dd*math.cos(theta) + tmp_Sz += 0.25*tmp_uu*math.cos(theta) + tmp_Sz += 0.25*tmp_dd*math.cos(theta) + # + tmp_Nq += tmp_ud*math.cos(theta) + tmp_Nq += tmp_du*math.cos(theta) + tmp_Sq += -0.25*tmp_ud*math.cos(theta) + tmp_Sq += -0.25*tmp_du*math.cos(theta) + tmp_Sz += -0.25*tmp_ud*math.cos(theta) + tmp_Sz += -0.25*tmp_du*math.cos(theta) + # + tmp_Sq += -0.5*G2_ex[num_bin][all_i][all_j][0][1]*math.cos(theta) + tmp_Sq += -0.5*G2_ex[num_bin][all_i][all_j][1][0]*math.cos(theta) + tmp_Sq += Ncond/2 + if kx%Lx == 0 and ky%Ly ==0: + tmp_Nq = tmp_Nq- Ncond**2 + tmp_Sq = tmp_Sq/(All_site) + tmp_Sz = tmp_Sz/(All_site) + tmp_Nq = tmp_Nq/(All_site) + tmp_Nk = tmp_Nk/(All_site) + all_Sq[num_bin][kx][ky] = tmp_Sq + #print(num_bin,kx,ky) + all_Sz[num_bin][kx][ky] = tmp_Sz + all_Nq[num_bin][kx][ky] = tmp_Nq + all_Nk[num_bin][kx][ky] = tmp_Nk + #print(kx,ky,tmp_Sq,tmp_Sz,tmp_Nq) + print("%d %d %12.8f %12.8f %12.8f " % (kx,ky,tmp_Sq,tmp_Sz,tmp_Nq), file=f) + print(" " , file=f) + #print(" ") + return all_Sq,all_Sz,all_Nq,all_Nk + +if __name__ == "__main__": + main() diff --git a/samples/tutorial_1.2/VMClocal.py b/samples/tutorial_1.2/VMClocal.py new file mode 100644 index 00000000..6486f96c --- /dev/null +++ b/samples/tutorial_1.2/VMClocal.py @@ -0,0 +1,116 @@ +import cmath +import math +import sys + +import numpy as np +import toml + +import MakeInput +import qlms_lattice + + +def main(): + #[s] tolm load + input_file = sys.argv[1] + list_org,list_sub,input_dict = MakeInput.read_toml(input_file) + + ini_cnt,max_cnt,calcmode = ReadModpara(input_dict) + All_N = list_org[0]*list_org[1]*list_org[2]*list_org[3] + All_site = list_org[0]*list_org[1]*list_org[2] + orb_num = list_org[3] + dir_name = input_dict["mVMC_aft"]["directory"] + + tot_Ene = np.zeros([max_cnt], dtype=np.float64) + tot_occ = np.zeros([max_cnt,orb_num], dtype=np.float64) + tot_AF = np.zeros([max_cnt,orb_num], dtype=np.float64) + for i_smp in range(ini_cnt,ini_cnt+max_cnt): + file_name = "%s/zvo_cisajs_00%d.dat" % (dir_name,i_smp) + occ,AF = ReadG1(file_name,list_org,i_smp) + for orb_i in range(orb_num): + tot_occ[i_smp][orb_i] = occ[orb_i] + tot_AF[i_smp][orb_i] = AF[orb_i] + # + file_name = "%s/zvo_out_00%d.dat" % (dir_name,i_smp) + tot_Ene[i_smp] = ReadEne(file_name,list_org,i_smp) + + Ave_Ene = np.mean(tot_Ene,axis=0) + Err_Ene = np.std(tot_Ene,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + # + Ave_occ = np.mean(tot_occ,axis=0) + Err_occ = np.std(tot_occ,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + Ave_AF = np.mean(tot_AF,axis=0) + Err_AF = np.std(tot_AF,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + + with open("Ene.dat", 'w') as f: + print("%s " % ("# Ene err_Ene Ene/(All_site) err_Ene/(All_site)"),file=f) + print("%f %f %f %f" % (Ave_Ene,Err_Ene,Ave_Ene/(All_site),Err_Ene/(All_site)),file=f) + with open("occ.dat", 'w') as f: + print("%s " % ("# occ err_occ AF err_AF"),file=f) + for orb_i in range(orb_num): + print("%f %f %f %f" % (Ave_occ[orb_i],Err_occ[orb_i],Ave_AF[orb_i],Err_AF[orb_i]),end="",file=f) + print(" " ,file=f) + +def ReadModpara(input_dict): + file_name = input_dict["mVMC_aft"]["modpara"] + with open(file_name) as f: + data = f.read() + data = data.split("\n") + for i in range(0,len(data)): + if data[i]: # if data[i] is not empty + tmp = data[i].split() + if tmp[0] == "NDataIdxStart": + ini_cnt = int(tmp[1]) + if tmp[0] == "NDataQtySmp": + max_cnt = int(tmp[1]) + if tmp[0] == "NVMCCalMode": + calcmode = int(tmp[1]) + return ini_cnt,max_cnt,calcmode + + +def ReadEne(file_name,list_org,i_smp): + with open(file_name) as f: + data = f.read() + data = data.split("\n") + #print(len(data)) + tmp = data[0].split() + tmp_Ene = tmp[0] + return tmp_Ene + + +def ReadG1(file_name,list_org,i_smp): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + orb_num = list_org[3] + #file_name = "output/zvo_aft_cisajs_001.dat" + with open(file_name) as f: + data = f.read() + data = data.split("\n") + #print(len(data)) + #[s] count not empty elements + occ = np.zeros([orb_num], dtype=np.float64) + AF = np.zeros([orb_num], dtype=np.float64) + for i in range(0,len(data)): + if data[i]: # if data[i] is not empty + tmp = data[i].split() + if tmp[0] == tmp[2]: + all_i = int(tmp[0]) + list_site = qlms_lattice.get_site(all_i,list_org) + x_i = list_site[0] + y_i = list_site[1] + orb_i = list_site[3] + sgn = math.cos(math.pi*x_i+math.pi*y_i) + if tmp[1] == tmp[3] and int(tmp[1]) == 0: + occ[orb_i] += float(tmp[4]) + AF[orb_i] += sgn*float(tmp[4]) + if tmp[1] == tmp[3] and int(tmp[1]) == 1: + occ[orb_i] += float(tmp[4]) + AF[orb_i] += -sgn*float(tmp[4]) + #[e] count not empty elements + occ = occ/(Lx*Ly*Lz) + AF = AF/(Lx*Ly*Lz) + return occ,AF + + +if __name__ == "__main__": + main() diff --git a/samples/tutorial_1.2/input.toml b/samples/tutorial_1.2/input.toml new file mode 100644 index 00000000..2e22a527 --- /dev/null +++ b/samples/tutorial_1.2/input.toml @@ -0,0 +1,13 @@ +[lattice] +Lx = 6 +Ly = 1 +Lz = 1 +orb_num = 1 +model_type = "Hubbard" +[mVMC] +sub_x = 2 +sub_y = 1 +sub_z = 1 +[mVMC_aft] +modpara = "modpara.def" +directory = "aft" diff --git a/samples/tutorial_1.2/qlms_lattice.py b/samples/tutorial_1.2/qlms_lattice.py new file mode 100644 index 00000000..89aa61cd --- /dev/null +++ b/samples/tutorial_1.2/qlms_lattice.py @@ -0,0 +1,44 @@ +def get_site(all_i,list_org): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + orb_num = list_org[3] + + orb = all_i%orb_num + site = (all_i-orb)/orb_num + x = site%Lx + tmp = (site-x)/Lx + y = tmp%Ly + z = (tmp-y)/Ly + list_site = [int(x),int(y),int(z),int(orb)] + return list_site + +def func_strans(list_trans,list_site,list_org): + x_j = int((list_site[0]+list_trans[0]+list_org[0])%list_org[0]) + y_j = int((list_site[1]+list_trans[1]+list_org[1])%list_org[1]) + z_j = int((list_site[2]+list_trans[2]+list_org[2])%list_org[2]) + all_j = list_trans[3]+(x_j+y_j*list_org[0]+z_j*list_org[0]*list_org[1])*list_org[3] + return all_j + +def func_strans_2D(list_trans,list_site,list_org): + x_j = int((list_site[0]+list_trans[0]+list_org[0])%list_org[0]) + y_j = int((list_site[1]+list_trans[1]+list_org[1])%list_org[1]) + all_j = list_trans[3]+(x_j+y_j*list_org[0])*list_org[3] + return all_j + +def get_site_Kondo(all_i,list_org): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + site_num = Lx*Ly*Lz + orb_num = list_org[3] + + site = all_i%site_num + orb = (all_i-site)/site_num + x = site%Lx + tmp = (site-x)/Lx + y = tmp%Ly + z = (tmp-y)/Ly + list_site = [int(x),int(y),int(z),int(orb)] + return list_site + diff --git a/samples/tutorial_1.2/run.sh b/samples/tutorial_1.2/run.sh new file mode 100644 index 00000000..52ee82e2 --- /dev/null +++ b/samples/tutorial_1.2/run.sh @@ -0,0 +1,26 @@ +#[s] definitions of executions +MPI=" " +VMC="path2vmc.out" +VMCDRY="path2vmcdry.out" +#[e] definitions of executions + +python3 MakeInput.py input.toml +#[s] opt + ${VMCDRY} ./stan_opt.in + ${MPI} ${VMC} namelist.def + cp ./output/zqp_opt.dat . + mv output opt +#[e] opt + +#[s] aft + ${VMCDRY} ./stan_aft.in + cp green1 greenone.def + cp green2 greentwo.def + ${MPI} ${VMC} namelist.def ./zqp_opt.dat + mv output aft +#[e] aft + +#[s] post process + python3 VMClocal.py input.toml + python3 VMCcor.py input.toml +#[e] post process diff --git a/samples/tutorial_1.2/stan_hphi.in b/samples/tutorial_1.2/stan_hphi.in new file mode 100644 index 00000000..bb4b7c15 --- /dev/null +++ b/samples/tutorial_1.2/stan_hphi.in @@ -0,0 +1,9 @@ +L = 6 +model = "Hubbard" +lattice = "chain" +method = "CG" +U = 4.0 +t = 1.0 +2Sz = 0 +nelec = 6 +exct = 8 diff --git a/samples/tutorial_1.3/Clean.sh b/samples/tutorial_1.3/Clean.sh new file mode 100644 index 00000000..6eb81c03 --- /dev/null +++ b/samples/tutorial_1.3/Clean.sh @@ -0,0 +1,12 @@ +rm *.def +rm *.dat +rm *.gp +rm mVMC.* +rm -r tmpUHF +rm -r opt* +rm -r aft* +rm -r output +rm -r __pycache__ +rm green* +rm stan_aft.in stan_opt.in +rm -r uhf random diff --git a/samples/tutorial_1.3/MakeInput.py b/samples/tutorial_1.3/MakeInput.py new file mode 100644 index 00000000..1e3372d4 --- /dev/null +++ b/samples/tutorial_1.3/MakeInput.py @@ -0,0 +1,176 @@ +import numpy as np +import math +import cmath +import toml +import sys + +def main(): + #[s] tolm load + input_file = sys.argv[1] + list_org,list_sub,input_dict = read_toml(input_file) + #[e] tolm load + #[s] output StdFace files + OutputStdFace(list_org,list_sub,input_dict) + #[s] output StdFace files + #[s] output StdFace files + OutputGreen(list_org) + #[s] output StdFace files + +def read_toml(input_file): + input_dict = toml.load(input_file) + #[e] tolm load + #[s]define constants + Lx = int(input_dict["lattice"]["Lx"]) + Ly = int(input_dict["lattice"]["Ly"]) + Lz = int(input_dict["lattice"]["Lz"]) + orb_num = int(input_dict["lattice"]["orb_num"]) + sub_x = int(input_dict["mVMC"]["sub_x"]) + sub_y = int(input_dict["mVMC"]["sub_y"]) + sub_z = int(input_dict["mVMC"]["sub_z"]) + #[e]define constants + All_N = Lx*Ly*Lz*orb_num + print('Lx = ',Lx) + print('Ly = ',Ly) + print('Ly = ',Lz) + print('orb_num = ',orb_num) + print('sub_x = ',sub_x) + print('sub_y = ',sub_y) + print('sub_z = ',sub_z) + + #[s] initialize + list_org = [Lx,Ly,Lz,orb_num] + list_sub = [sub_x,sub_y,sub_z] + #[e] initialize + + return list_org,list_sub,input_dict + +def CalcDim(list_org): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + orb_num = list_org[3] + + #[s] calc dim_type + if Ly == 1 and Lz == 1: + dim_type = 1 + elif Lz == 1: + dim_type = 2 + elif Lx>1 and Ly > 1 and Lz>1: + dim_type = 3 + else : + print(" Possible error in Lx, Ly, Lz") + print(" This script supports chain,square, and cubic in the following way: ") + print(" Lx>1 Ly=Lz=1 -> chain") + print(" Lx>1 Ly>1 Lz=1 -> square") + print(" Lx>1 Ly>1 Lz>1 -> cubic") + print(" Input Lx=%d Ly=%d Lz=%d do not meet above conditions." %(Lx,Ly,Lz)) + #[e] calc dim_type + return dim_type + +def OutputStdFace(list_org,list_sub,input_dict): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + orb_num = list_org[3] + Ncond = Lx*Ly*Lz*orb_num + sub_x = list_sub[0] + sub_y = list_sub[1] + sub_z = list_sub[2] + model_type = input_dict["lattice"]["model_type"] + + dim_type = CalcDim(list_org) + + #[s] make stan_com + stan_com = [] + if dim_type == 1: + stan_com.append("L = %d "%(Lx)) + stan_com.append("Lsub = %d "%(sub_x)) + stan_com.append("lattice = \"chain\"") + elif dim_type == 2: + stan_com.append("W = %d "%(Lx)) + stan_com.append("Wsub = %d "%(sub_x)) + stan_com.append("L = %d "%(Ly)) + stan_com.append("Lsub = %d "%(sub_y)) + stan_com.append("lattice = \"square\"") + elif dim_type == 3: + stan_com.append("W = %d "%(Lx)) + stan_com.append("Wsub = %d "%(sub_x)) + stan_com.append("L = %d "%(Ly)) + stan_com.append("Lsub = %d "%(sub_y)) + stan_com.append("Height = %d "%(Lz)) + stan_com.append("Hsub = %d "%(sub_z)) + stan_com.append("lattice = \"cubic\"") + + if model_type == "Spin": + stan_com.append("model = \"%s\" "%(model_type)) + stan_com.append("J = 1.0 ") + elif model_type == "Hubbard": + stan_com.append("model = \"%s\" "%(model_type)) + stan_com.append("t = 1.0 ") + stan_com.append("U = 4.0 ") + stan_com.append("V = 0.0 ") + stan_com.append("ncond = %d " %(Ncond)) + elif model_type == "Kondo": + stan_com.append("model = \"%s\" "%(model_type)) + stan_com.append("t = 1.0 ") + stan_com.append("J = 1.0 ") + stan_com.append("ncond = %d " %(int(Ncond/2))) + else: + print("This scropt only support Spin, Hubbard, Kondo") + + stan_com.append("2Sz = 0 ") + stan_com.append("NVMCSample = 200 ") + stan_com.append("NSROptItrStep = 600 ") + stan_com.append("NMPTrans = 1 ") + stan_com.append("NSPStot = 0 ") + #[e] make stan_com + + with open("stan_opt.in", 'w') as f: + for cnt_std in stan_com: + print(cnt_std,file=f) + + with open("stan_aft.in", 'w') as f: + for cnt_std in stan_com: + print(cnt_std,file=f) + print("NVMCCalMode = 1 ",file=f) + print("NDataIdxStart = 0 ",file=f) + print("NDataQtySmp = 10 ",file=f) + + + +def OutputGreen(list_org): + All_N = list_org[0]*list_org[1]*list_org[2]*list_org[3] + + with open("green1", 'w') as f: + print("==================", file=f) + print("onebody %d "%(2*All_N**2), file=f) + print("==================", file=f) + print("==================", file=f) + print("==================", file=f) + for all_i in range(0,All_N): + for all_j in range(0,All_N): + print(" %d %d %d %d "% (all_i,0,all_j,0), file=f) + print(" %d %d %d %d "% (all_i,1,all_j,1), file=f) + + with open("green2", 'w') as f: + print("==================", file=f) + print("twobody %d "%(6*All_N**2), file=f) + print("==================", file=f) + print("==================", file=f) + print("==================", file=f) + for all_i in range(0,All_N): + for all_j in range(0,All_N): + print(" %d %d %d %d %d %d %d %d"% (all_i,0,all_i,0,all_j,0,all_j,0), file=f) + print(" %d %d %d %d %d %d %d %d"% (all_i,0,all_i,0,all_j,1,all_j,1), file=f) + print(" %d %d %d %d %d %d %d %d"% (all_i,1,all_i,1,all_j,0,all_j,0), file=f) + print(" %d %d %d %d %d %d %d %d"% (all_i,1,all_i,1,all_j,1,all_j,1), file=f) + # + print(" %d %d %d %d %d %d %d %d"% (all_i,0,all_j,0,all_j,1,all_i,1), file=f) + print(" %d %d %d %d %d %d %d %d"% (all_i,1,all_j,1,all_j,0,all_i,0), file=f) + + + + + +if __name__ == "__main__": + main() diff --git a/samples/tutorial_1.3/VMCcor.py b/samples/tutorial_1.3/VMCcor.py new file mode 100755 index 00000000..51977bd2 --- /dev/null +++ b/samples/tutorial_1.3/VMCcor.py @@ -0,0 +1,331 @@ +import cmath +import math +import sys + +import numpy as np +import toml + +import MakeInput +import qlms_lattice +import VMClocal + +def main(): + #[s] tolm load + input_file = sys.argv[1] + list_org,list_sub,input_dict = MakeInput.read_toml(input_file) + dir_name = input_dict["mVMC_aft"]["directory"] + model_type = input_dict["lattice"]["model_type"] + dim_type = MakeInput.CalcDim(list_org) + #[e] tolm load + + ini_cnt,max_cnt,calcmode = VMClocal.ReadModpara(input_dict) + + #[s] read Green + G1,G2_sz,G2_ex = ReadGreen(list_org,max_cnt,dir_name) + #[e] read Green + + #[s] calc Sq,Sz,Nq,Nk + all_Sq,all_Sz,all_Nq,all_Nk = CalcSq_tot(list_org,G1,G2_sz,G2_ex,dir_name,max_cnt) + OutputSqSzNq(list_org,all_Sq,all_Sz,all_Nq,dim_type) + if model_type == "Hubbard": + OutputNk(list_org,all_Nk,dim_type) #Nk is output only Hubbard + #[e] calc Sq,Sz,Nq,Nk + OutputReal(list_org,G1,max_cnt,dim_type) + OutputSij(list_org,G1,G2_sz,G2_ex,max_cnt) + +def OutputSij(list_org,G1,G2_sz,G2_ex,max_cnt): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + orb_num = list_org[3] + All_N = Lx*Ly*Lz*orb_num + tot_S = np.zeros((max_cnt,All_N,All_N),dtype=np.float64) + Sxy = np.zeros((max_cnt,All_N,All_N),dtype=np.float64) + Sz = np.zeros((max_cnt,All_N,All_N),dtype=np.float64) + for num_bin in range(0,max_cnt): + for all_i in range(0,All_N): + for all_j in range(0,All_N): + tmp_Sz = G2_sz[num_bin][all_i][all_j][0][0] + tmp_Sz += -G2_sz[num_bin][all_i][all_j][1][0] + tmp_Sz += -G2_sz[num_bin][all_i][all_j][0][1] + tmp_Sz += G2_sz[num_bin][all_i][all_j][1][1] + tmp_Sz = 0.25*tmp_Sz + tmp_Sxy = -0.5*G2_ex[num_bin][all_i][all_j][0][1] + tmp_Sxy += -0.5*G2_ex[num_bin][all_i][all_j][1][0] + if all_i == all_j: + tmp_Sxy += 0.5*G1[num_bin][all_i][all_i][0] + tmp_Sxy += 0.5*G1[num_bin][all_i][all_i][1] + tot_S[num_bin][all_i][all_j] = tmp_Sxy+tmp_Sz + Sxy[num_bin][all_i][all_j] = tmp_Sxy + Sz[num_bin][all_i][all_j] = tmp_Sz + # + ave_tot_S = np.mean(tot_S,axis=0) + err_tot_S = np.std(tot_S,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + ave_Sxy = np.mean(Sxy,axis=0) + err_Sxy = np.std(Sxy,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + ave_Sz = np.mean(Sz,axis=0) + err_Sz = np.std(Sz,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + with open("Sij.dat", 'w') as f: + print(" %s " % ("# i j tot_S err_tot_S Sxy err_Sxy Sz err_Sz "), file=f) + for all_i in range(All_N): + for all_j in range(All_N): + print("%d %d %12.8f %12.8f %12.8f %12.8f %12.8f %12.8f " % (all_i,all_j,\ + ave_tot_S[all_i][all_j],err_tot_S[all_i][all_j],\ + ave_Sxy[all_i][all_j],err_Sxy[all_i][all_j],\ + ave_Sz[all_i][all_j],err_Sz[all_i][all_j]), file=f) + print(" ", file=f) + +def OutputReal(list_org,G1,max_cnt,dim_type): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + orb_num = list_org[3] + All_N = Lx*Ly*Lz*orb_num + charge = np.zeros((max_cnt,All_N),dtype=np.float64) + spin = np.zeros((max_cnt,All_N),dtype=np.float64) + for num_bin in range(0,max_cnt): + for all_i in range(0,All_N): + charge[num_bin][all_i] = G1[num_bin][all_i][all_i][0]+G1[num_bin][all_i][all_i][1] + spin[num_bin][all_i] = G1[num_bin][all_i][all_i][0]-G1[num_bin][all_i][all_i][1] + # + ave_charge = np.mean(charge,axis=0) + err_charge = np.std(charge,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + ave_spin = np.mean(spin,axis=0) + err_spin = np.std(spin,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + with open("Real.dat", 'w') as f: + print(" %s " % ("# x y charge err_charge spin err_spin"), file=f) + for i_x in range(0,list_org[0]): + if dim_type == 1: + i_y = 0 + all_i = i_x + i_y*list_org[0] + print("%d %d %12.8f %12.8f %12.8f %12.8f" % (i_x,i_y,ave_charge[all_i],err_charge[all_i],ave_spin[all_i],err_spin[all_i]), file=f) + elif dim_type == 2: + for i_y in range(0,list_org[1]): + all_i = i_x + i_y*list_org[0] + print("%d %d %12.8f %12.8f %12.8f %12.8f" % (i_x,i_y,ave_charge[all_i],err_charge[all_i],ave_spin[all_i],err_spin[all_i]), file=f) + print(" " , file=f) + + +def OutputSqSzNq(list_org,all_Sq,all_Sz,all_Nq,dim_type): + max_cnt = all_Sq.shape[0] + #[s] Sq,Sz,Nq + ave_Sq = np.mean(all_Sq,axis=0) + err_Sq = np.std(all_Sq,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + ave_Sz = np.mean(all_Sz,axis=0) + err_Sz = np.std(all_Sz,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + ave_Nq = np.mean(all_Nq,axis=0) + err_Nq = np.std(all_Nq,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + max_Sq = 0.0 + max_Nq = 0.0 + with open("SqNq.dat", 'w') as f: + print(" %s " % ("# kx ky Sq err_Sq Sz err_Sz Nq err_Nq"), file=f) + for kx in range(0,list_org[0]+1): + if dim_type==1: + ky = 0 + if ave_Sq[kx][ky] > max_Sq: + max_Sq = ave_Sq[kx][ky] + max_Sq_err = err_Sq[kx][ky] + max_Sq_kx = kx + max_Sq_ky = ky + # + if ave_Nq[kx][ky] > max_Nq: + max_Nq = ave_Nq[kx][ky] + max_Nq_err = err_Nq[kx][ky] + max_Nq_kx = kx + max_Nq_ky = ky + print("%d %d %12.8f %12.8f %12.8f %12.8f %12.8f %12.8f" % (kx,ky,ave_Sq[kx][ky],err_Sq[kx][ky],ave_Sz[kx][ky],err_Sz[kx][ky],ave_Nq[kx][ky],err_Nq[kx][ky]), file=f) + elif dim_type==2: + for ky in range(0,list_org[1]+1): + if ave_Sq[kx][ky] > max_Sq: + max_Sq = ave_Sq[kx][ky] + max_Sq_err = err_Sq[kx][ky] + max_Sq_kx = kx + max_Sq_ky = ky + # + if ave_Nq[kx][ky] > max_Nq: + max_Nq = ave_Nq[kx][ky] + max_Nq_err = err_Nq[kx][ky] + max_Nq_kx = kx + max_Nq_ky = ky + print("%d %d %12.8f %12.8f %12.8f %12.8f %12.8f %12.8f" % (kx,ky,ave_Sq[kx][ky],err_Sq[kx][ky],ave_Sz[kx][ky],err_Sz[kx][ky],ave_Nq[kx][ky],err_Nq[kx][ky]), file=f) + print(" " , file=f) + elif dim_type==3: + print("not implemented yet") + with open("MaxSq.dat", 'w') as f: + print("%12.8f %12.8f %d %d " % (max_Sq,max_Sq_err,max_Sq_kx,max_Sq_ky), file=f) + with open("MaxNq.dat", 'w') as f: + print("%12.8f %12.8f %d %d " % (max_Nq,max_Nq_err,max_Nq_kx,max_Nq_ky), file=f) + #[e] Sq,Nq + +def OutputNk(list_org,all_Nk,dim_type): + max_cnt = all_Nk.shape[0] + #[s] Nk + ave_Nk = np.mean(all_Nk,axis=0) + err_Nk = np.std(all_Nk,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + with open("Nk.dat", 'w') as f: + print(" %s " % ("# kx ky Nk err_Nk "), file=f) + for kx in range(-int(list_org[0]/2),int(list_org[0]/2)+1): + if kx <0: + tmp_kx = kx+list_org[0] + else: + tmp_kx = kx + if dim_type==1: + ky = 0 + tmp_ky = 0 + print("%d %d %12.8f %12.8f " % (kx,ky,ave_Nk[tmp_kx][tmp_ky],err_Nk[tmp_kx][tmp_ky]), file=f) + elif dim_type==2: + for ky in range(-list_org[1],list_org[1]+1): + if ky <0: + tmp_ky = ky+list_org[1] + else: + tmp_ky = ky + print("%d %d %12.8f %12.8f " % (kx,ky,ave_Nk[tmp_kx][tmp_ky],err_Nk[tmp_kx][tmp_ky]), file=f) + print(" " , file=f) + elif dim_type==3: + print("Not implemented yet") + #[e] Nk + +def ReadGreen(list_org,max_cnt,dir_name): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + orb_num = list_org[3] + All_N = Lx*Ly*Lz*orb_num + #[s] allocate + G1 = np.zeros((max_cnt,All_N,All_N,2),dtype=np.float64) + G2_ex = np.full((max_cnt,All_N,All_N,2,2),-100,dtype=np.float64) + G2_sz = np.full((max_cnt,All_N,All_N,2,2),-100,dtype=np.float64) + #[e] allocate + for num_bin in range(max_cnt): + file_name ="%s/zvo_cisajs_00%d.dat" %(dir_name,num_bin) + + with open(file_name) as f: + tmp_G1 = f.read() + tmp_G1 = tmp_G1.split("\n") + #[s] count not empty elements + cnt = 0 + for i in range(0,len(tmp_G1)): + if tmp_G1[i]: # if data[i] is not empty + cnt += 1 + #print(cnt) + cnt_max = cnt + #[e] count not empty elements + for cnt in range(0,cnt_max): + tmp = tmp_G1[cnt].split() + all_i = int(tmp[0]) + all_j = int(tmp[2]) + spn = int(tmp[1]) + #print(tmp) + G1[num_bin][all_i][all_j][spn] = float(tmp[4]) + + file_name ="%s/zvo_cisajscktalt_00%d.dat" %(dir_name,num_bin) + with open(file_name) as f: + data = f.read() + data = data.split("\n") + #[s] count not empty elements + cnt = 0 + for i in range(0,len(data)): + if data[i]: # if data[i] is not empty + cnt += 1 + #print(cnt) + cnt_max = cnt + #[e] count not empty elements + for cnt in range(0,cnt_max): + tmp = data[cnt].split() + all_i = int(tmp[0]) + all_j = int(tmp[2]) + all_k = int(tmp[4]) + all_l = int(tmp[6]) + spn_0 = int(tmp[1]) + spn_1 = int(tmp[5]) + if all_i == all_j and all_k == all_l and all_i==all_k: + G2_sz[num_bin][all_i][all_j][spn_0][spn_1] = float(tmp[8]) + G2_ex[num_bin][all_i][all_j][spn_0][spn_1] = float(tmp[8]) + elif all_i == all_j and all_k == all_l: + G2_sz[num_bin][all_i][all_k][spn_0][spn_1] = float(tmp[8]) + elif all_i == all_l and all_j == all_k: + G2_ex[num_bin][all_i][all_j][spn_0][spn_1] = float(tmp[8]) + else: + print("fatal error in 2-body Green functions") + return G1,G2_sz,G2_ex + +def CalcSq_tot(list_org,G1,G2_sz,G2_ex,dir_name,max_cnt): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + orb_num = list_org[3] + All_N = Lx*Ly*Lz*orb_num + All_site = Lx*Ly*Lz + all_Sq = np.full((max_cnt,list_org[0]+1,list_org[1]+1),-100,dtype=np.float64) + all_Sz = np.full((max_cnt,list_org[0]+1,list_org[1]+1),-100,dtype=np.float64) + all_Nq = np.full((max_cnt,list_org[0]+1,list_org[1]+1),-100,dtype=np.float64) + all_Nk = np.full((max_cnt,list_org[0]+1,list_org[1]+1),-100,dtype=np.float64) + + for num_bin in range(max_cnt): + with open("%s/total_SqNq_%d.dat" % (dir_name,num_bin), 'w') as f: + for kx in range(0,Lx+1): + for ky in range(0,Ly+1): + tmp_Sq = 0.0 + tmp_Sz = 0.0 + tmp_Nq = 0.0 + tmp_Nk = 0.0 + Ncond = 0 + for all_i in range(0,All_N): + Ncond+= G1[num_bin][all_i][all_i][0] + Ncond+= G1[num_bin][all_i][all_i][1] + for all_j in range(0,All_N): + list_site = qlms_lattice.get_site(all_i,list_org) + i_x = list_site[0] + i_y = list_site[1] + # + list_site = qlms_lattice.get_site(all_j,list_org) + j_x = list_site[0] + j_y = list_site[1] + + theta = 2*math.pi*kx*(i_x-j_x)/Lx+2*math.pi*ky*(i_y-j_y)/Ly + # + tmp_uu = G2_sz[num_bin][all_i][all_j][0][0] + tmp_ud = G2_sz[num_bin][all_i][all_j][0][1] + tmp_du = G2_sz[num_bin][all_i][all_j][1][0] + tmp_dd = G2_sz[num_bin][all_i][all_j][1][1] + + # + tmp_Nk += G1[num_bin][all_i][all_j][0]*math.cos(theta) + tmp_Nk += G1[num_bin][all_i][all_j][1]*math.cos(theta) + # + tmp_Nq += tmp_uu*math.cos(theta) + tmp_Nq += tmp_dd*math.cos(theta) + tmp_Sq += 0.25*tmp_uu*math.cos(theta) + tmp_Sq += 0.25*tmp_dd*math.cos(theta) + tmp_Sz += 0.25*tmp_uu*math.cos(theta) + tmp_Sz += 0.25*tmp_dd*math.cos(theta) + # + tmp_Nq += tmp_ud*math.cos(theta) + tmp_Nq += tmp_du*math.cos(theta) + tmp_Sq += -0.25*tmp_ud*math.cos(theta) + tmp_Sq += -0.25*tmp_du*math.cos(theta) + tmp_Sz += -0.25*tmp_ud*math.cos(theta) + tmp_Sz += -0.25*tmp_du*math.cos(theta) + # + tmp_Sq += -0.5*G2_ex[num_bin][all_i][all_j][0][1]*math.cos(theta) + tmp_Sq += -0.5*G2_ex[num_bin][all_i][all_j][1][0]*math.cos(theta) + tmp_Sq += Ncond/2 + if kx%Lx == 0 and ky%Ly ==0: + tmp_Nq = tmp_Nq- Ncond**2 + tmp_Sq = tmp_Sq/(All_site) + tmp_Sz = tmp_Sz/(All_site) + tmp_Nq = tmp_Nq/(All_site) + tmp_Nk = tmp_Nk/(All_site) + all_Sq[num_bin][kx][ky] = tmp_Sq + #print(num_bin,kx,ky) + all_Sz[num_bin][kx][ky] = tmp_Sz + all_Nq[num_bin][kx][ky] = tmp_Nq + all_Nk[num_bin][kx][ky] = tmp_Nk + #print(kx,ky,tmp_Sq,tmp_Sz,tmp_Nq) + print("%d %d %12.8f %12.8f %12.8f " % (kx,ky,tmp_Sq,tmp_Sz,tmp_Nq), file=f) + print(" " , file=f) + #print(" ") + return all_Sq,all_Sz,all_Nq,all_Nk + +if __name__ == "__main__": + main() diff --git a/samples/tutorial_1.3/VMClocal.py b/samples/tutorial_1.3/VMClocal.py new file mode 100644 index 00000000..6486f96c --- /dev/null +++ b/samples/tutorial_1.3/VMClocal.py @@ -0,0 +1,116 @@ +import cmath +import math +import sys + +import numpy as np +import toml + +import MakeInput +import qlms_lattice + + +def main(): + #[s] tolm load + input_file = sys.argv[1] + list_org,list_sub,input_dict = MakeInput.read_toml(input_file) + + ini_cnt,max_cnt,calcmode = ReadModpara(input_dict) + All_N = list_org[0]*list_org[1]*list_org[2]*list_org[3] + All_site = list_org[0]*list_org[1]*list_org[2] + orb_num = list_org[3] + dir_name = input_dict["mVMC_aft"]["directory"] + + tot_Ene = np.zeros([max_cnt], dtype=np.float64) + tot_occ = np.zeros([max_cnt,orb_num], dtype=np.float64) + tot_AF = np.zeros([max_cnt,orb_num], dtype=np.float64) + for i_smp in range(ini_cnt,ini_cnt+max_cnt): + file_name = "%s/zvo_cisajs_00%d.dat" % (dir_name,i_smp) + occ,AF = ReadG1(file_name,list_org,i_smp) + for orb_i in range(orb_num): + tot_occ[i_smp][orb_i] = occ[orb_i] + tot_AF[i_smp][orb_i] = AF[orb_i] + # + file_name = "%s/zvo_out_00%d.dat" % (dir_name,i_smp) + tot_Ene[i_smp] = ReadEne(file_name,list_org,i_smp) + + Ave_Ene = np.mean(tot_Ene,axis=0) + Err_Ene = np.std(tot_Ene,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + # + Ave_occ = np.mean(tot_occ,axis=0) + Err_occ = np.std(tot_occ,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + Ave_AF = np.mean(tot_AF,axis=0) + Err_AF = np.std(tot_AF,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + + with open("Ene.dat", 'w') as f: + print("%s " % ("# Ene err_Ene Ene/(All_site) err_Ene/(All_site)"),file=f) + print("%f %f %f %f" % (Ave_Ene,Err_Ene,Ave_Ene/(All_site),Err_Ene/(All_site)),file=f) + with open("occ.dat", 'w') as f: + print("%s " % ("# occ err_occ AF err_AF"),file=f) + for orb_i in range(orb_num): + print("%f %f %f %f" % (Ave_occ[orb_i],Err_occ[orb_i],Ave_AF[orb_i],Err_AF[orb_i]),end="",file=f) + print(" " ,file=f) + +def ReadModpara(input_dict): + file_name = input_dict["mVMC_aft"]["modpara"] + with open(file_name) as f: + data = f.read() + data = data.split("\n") + for i in range(0,len(data)): + if data[i]: # if data[i] is not empty + tmp = data[i].split() + if tmp[0] == "NDataIdxStart": + ini_cnt = int(tmp[1]) + if tmp[0] == "NDataQtySmp": + max_cnt = int(tmp[1]) + if tmp[0] == "NVMCCalMode": + calcmode = int(tmp[1]) + return ini_cnt,max_cnt,calcmode + + +def ReadEne(file_name,list_org,i_smp): + with open(file_name) as f: + data = f.read() + data = data.split("\n") + #print(len(data)) + tmp = data[0].split() + tmp_Ene = tmp[0] + return tmp_Ene + + +def ReadG1(file_name,list_org,i_smp): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + orb_num = list_org[3] + #file_name = "output/zvo_aft_cisajs_001.dat" + with open(file_name) as f: + data = f.read() + data = data.split("\n") + #print(len(data)) + #[s] count not empty elements + occ = np.zeros([orb_num], dtype=np.float64) + AF = np.zeros([orb_num], dtype=np.float64) + for i in range(0,len(data)): + if data[i]: # if data[i] is not empty + tmp = data[i].split() + if tmp[0] == tmp[2]: + all_i = int(tmp[0]) + list_site = qlms_lattice.get_site(all_i,list_org) + x_i = list_site[0] + y_i = list_site[1] + orb_i = list_site[3] + sgn = math.cos(math.pi*x_i+math.pi*y_i) + if tmp[1] == tmp[3] and int(tmp[1]) == 0: + occ[orb_i] += float(tmp[4]) + AF[orb_i] += sgn*float(tmp[4]) + if tmp[1] == tmp[3] and int(tmp[1]) == 1: + occ[orb_i] += float(tmp[4]) + AF[orb_i] += -sgn*float(tmp[4]) + #[e] count not empty elements + occ = occ/(Lx*Ly*Lz) + AF = AF/(Lx*Ly*Lz) + return occ,AF + + +if __name__ == "__main__": + main() diff --git a/samples/tutorial_1.3/input.toml b/samples/tutorial_1.3/input.toml new file mode 100644 index 00000000..f23f3518 --- /dev/null +++ b/samples/tutorial_1.3/input.toml @@ -0,0 +1,13 @@ +[lattice] +Lx = 4 +Ly = 4 +Lz = 1 +orb_num = 1 +model_type = "Hubbard" +[mVMC] +sub_x = 4 +sub_y = 4 +sub_z = 1 +[mVMC_aft] +modpara = "modpara.def" +directory = "aft" diff --git a/samples/tutorial_1.3/plot b/samples/tutorial_1.3/plot new file mode 100644 index 00000000..25b97259 --- /dev/null +++ b/samples/tutorial_1.3/plot @@ -0,0 +1,8 @@ +set xlabel "optimization step" +set ylabel "total energy" +p[:][:] \ +"random/opt/zvo_out_001.dat" u 1 t "Random initial", \ +"uhf/opt/zvo_out_001.dat" u 1 t "UHF initial", \ +-12.566554520605 w l t "UHF", \ +-13.621855 w l lc -1 t "exact diagonalization" +pause -1 diff --git a/samples/tutorial_1.3/qlms_lattice.py b/samples/tutorial_1.3/qlms_lattice.py new file mode 100644 index 00000000..89aa61cd --- /dev/null +++ b/samples/tutorial_1.3/qlms_lattice.py @@ -0,0 +1,44 @@ +def get_site(all_i,list_org): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + orb_num = list_org[3] + + orb = all_i%orb_num + site = (all_i-orb)/orb_num + x = site%Lx + tmp = (site-x)/Lx + y = tmp%Ly + z = (tmp-y)/Ly + list_site = [int(x),int(y),int(z),int(orb)] + return list_site + +def func_strans(list_trans,list_site,list_org): + x_j = int((list_site[0]+list_trans[0]+list_org[0])%list_org[0]) + y_j = int((list_site[1]+list_trans[1]+list_org[1])%list_org[1]) + z_j = int((list_site[2]+list_trans[2]+list_org[2])%list_org[2]) + all_j = list_trans[3]+(x_j+y_j*list_org[0]+z_j*list_org[0]*list_org[1])*list_org[3] + return all_j + +def func_strans_2D(list_trans,list_site,list_org): + x_j = int((list_site[0]+list_trans[0]+list_org[0])%list_org[0]) + y_j = int((list_site[1]+list_trans[1]+list_org[1])%list_org[1]) + all_j = list_trans[3]+(x_j+y_j*list_org[0])*list_org[3] + return all_j + +def get_site_Kondo(all_i,list_org): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + site_num = Lx*Ly*Lz + orb_num = list_org[3] + + site = all_i%site_num + orb = (all_i-site)/site_num + x = site%Lx + tmp = (site-x)/Lx + y = tmp%Ly + z = (tmp-y)/Ly + list_site = [int(x),int(y),int(z),int(orb)] + return list_site + diff --git a/samples/tutorial_1.3/run.sh b/samples/tutorial_1.3/run.sh new file mode 100644 index 00000000..52ee82e2 --- /dev/null +++ b/samples/tutorial_1.3/run.sh @@ -0,0 +1,26 @@ +#[s] definitions of executions +MPI=" " +VMC="path2vmc.out" +VMCDRY="path2vmcdry.out" +#[e] definitions of executions + +python3 MakeInput.py input.toml +#[s] opt + ${VMCDRY} ./stan_opt.in + ${MPI} ${VMC} namelist.def + cp ./output/zqp_opt.dat . + mv output opt +#[e] opt + +#[s] aft + ${VMCDRY} ./stan_aft.in + cp green1 greenone.def + cp green2 greentwo.def + ${MPI} ${VMC} namelist.def ./zqp_opt.dat + mv output aft +#[e] aft + +#[s] post process + python3 VMClocal.py input.toml + python3 VMCcor.py input.toml +#[e] post process diff --git a/samples/tutorial_1.3/run_uhf.sh b/samples/tutorial_1.3/run_uhf.sh new file mode 100644 index 00000000..3178e7e6 --- /dev/null +++ b/samples/tutorial_1.3/run_uhf.sh @@ -0,0 +1,38 @@ +#[s] definitions of executions +MPI=" " +VMC="path2vmc.out" +VMCDRY="path2vmcdry.out" +UHF="path2UHF" +#[e] definitions of executions + +mkdir random +mv opt random +mv aft random +mv Ene.dat MaxSq.dat Real.dat SqNq.dat occ.dat MaxNq.dat Nk.dat Sij.dat random + +#[s] opt + ${VMCDRY} ./stan_opt.in + ${UHF} namelist.def + echo " InOrbital zqp_APOrbital_opt.dat " >> namelist.def + ${MPI} ${VMC} namelist.def + cp ./output/zqp_opt.dat . + mv output opt +#[e] opt + +#[s] aft + ${VMCDRY} ./stan_aft.in + cp green1 greenone.def + cp green2 greentwo.def + ${MPI} ${VMC} namelist.def ./zqp_opt.dat + mv output aft +#[e] aft + +#[s] post process + python3 VMClocal.py input.toml + python3 VMCcor.py input.toml +#[e] post process + +mkdir uhf +mv opt uhf +mv aft uhf +mv Ene.dat MaxSq.dat Real.dat SqNq.dat occ.dat MaxNq.dat Nk.dat Sij.dat uhf diff --git a/samples/tutorial_1.3/stan_hphi.in b/samples/tutorial_1.3/stan_hphi.in new file mode 100644 index 00000000..2e942eab --- /dev/null +++ b/samples/tutorial_1.3/stan_hphi.in @@ -0,0 +1,10 @@ +L = 4 +W = 4 +model = "Hubbard" +lattice = "square" +method = "CG" +U = 4.0 +t = 1.0 +2Sz = 0 +nelec = 16 +exct = 2 diff --git a/samples/tutorial_2.1/Clean.sh b/samples/tutorial_2.1/Clean.sh new file mode 100644 index 00000000..c8b87b2f --- /dev/null +++ b/samples/tutorial_2.1/Clean.sh @@ -0,0 +1,8 @@ +rm *.def +rm *.dat +rm -r spin kondo +#rm -r aft* +rm -r __pycache__ +rm green* +rm *.gp +#rm stan_aft.in stan_opt.in diff --git a/samples/tutorial_2.1/plot_kondo b/samples/tutorial_2.1/plot_kondo new file mode 100644 index 00000000..1a766ef6 --- /dev/null +++ b/samples/tutorial_2.1/plot_kondo @@ -0,0 +1,8 @@ +set xlabel "optimization step" +set ylabel "total energy" +p \ +"kondo/output_s0/zvo_out_001.dat" u 1 t "mVMC, S=0", \ +"kondo/output_s1/zvo_out_001.dat" u 1 t "mVMC, S=1", \ +-19.0251276267899421 w l lw 2 t "exact diagonalization, S=0", \ +-16.1561048387100463 w l lw 2 t "exact diagonalization, S=1" +pause -1 diff --git a/samples/tutorial_2.1/plot_spin b/samples/tutorial_2.1/plot_spin new file mode 100644 index 00000000..bec2bdfe --- /dev/null +++ b/samples/tutorial_2.1/plot_spin @@ -0,0 +1,8 @@ +set xlabel "optimization step" +set ylabel "total energy" +p \ +"spin/output_s0/zvo_out_001.dat" u 1 t "mVMC, S=0", \ +"spin/output_s1/zvo_out_001.dat" u 1 t "mVMC, S=1", \ +-3.651093 w l lw 2 t "exact diagonalization, S=0", \ +-3.128419 w l lw 2 t "exact diagonalization, S=1" +pause -1 diff --git a/samples/tutorial_2.1/run.sh b/samples/tutorial_2.1/run.sh new file mode 100644 index 00000000..74c4cfb4 --- /dev/null +++ b/samples/tutorial_2.1/run.sh @@ -0,0 +1,21 @@ +#[s] definitions of executions +MPI=" " +VMC="path2vmc.out" +#[e] definitions of executions + +target=$1 + +mkdir ${target} +${MPI} ${VMC} -s stan_${target}_S0.in +mv output $target/output_s0 + +${MPI} ${VMC} -s stan_${target}_S1.in +mv output ${target}/output_s1 + +E0=$(awk ' {print +$1}' ${target}/output_s0/zqp_opt.dat) +E1=$(awk ' {print +$1}' ${target}/output_s1/zqp_opt.dat) +Delta_s=`echo "${E1} - ${E0}" | bc -l` + +echo "#E0_from_zqp_opt.dat E1_from_zqp_opt.dat Delta_s=E1-E0" > spin_gap.dat +echo $E0 $E1 $Delta_s >> spin_gap.dat +mv spin_gap.dat ${target} diff --git a/samples/tutorial_2.1/stan_kondo_S0.in b/samples/tutorial_2.1/stan_kondo_S0.in new file mode 100644 index 00000000..809c114e --- /dev/null +++ b/samples/tutorial_2.1/stan_kondo_S0.in @@ -0,0 +1,17 @@ +L = 6 +Lsub = 2 +model = "Kondo" +lattice = "chain" +t = 1 +J = 4 +ncond = 6 +NSPGaussLeg = 8 +2Sz = 0 +NSPStot = 0 +NSROptItrStep = 600 +NSROptItrSmp = 100 +NVMCSample = 1000 +DSROptRedCut = 1e-8 +DSROptStaDel = 1e-2 +DSROptStepDt = 1e-2 +//NVMCCalMode = 1 diff --git a/samples/tutorial_2.1/stan_kondo_S1.in b/samples/tutorial_2.1/stan_kondo_S1.in new file mode 100644 index 00000000..123733b7 --- /dev/null +++ b/samples/tutorial_2.1/stan_kondo_S1.in @@ -0,0 +1,17 @@ +L = 6 +Lsub = 2 +model = "Kondo" +lattice = "chain" +t = 1 +J = 4 +ncond = 6 +NSPGaussLeg = 8 +2Sz = 0 +NSPStot = 1 +NSROptItrStep = 600 +NSROptItrSmp = 100 +NVMCSample = 1000 +DSROptRedCut = 1e-8 +DSROptStaDel = 1e-2 +DSROptStepDt = 1e-2 +//NVMCCalMode = 1 diff --git a/samples/tutorial_2.1/stan_kondo_hphi.in b/samples/tutorial_2.1/stan_kondo_hphi.in new file mode 100644 index 00000000..b6b33889 --- /dev/null +++ b/samples/tutorial_2.1/stan_kondo_hphi.in @@ -0,0 +1,9 @@ +L = 6 +model = "Kondo" +method = "CG" +lattice = "chain" +t = 1 +J = 4 +ncond = 6 +2Sz = 0 +exct = 2 diff --git a/samples/tutorial_2.1/stan_spin_S0.in b/samples/tutorial_2.1/stan_spin_S0.in new file mode 100644 index 00000000..aa2022ac --- /dev/null +++ b/samples/tutorial_2.1/stan_spin_S0.in @@ -0,0 +1,15 @@ +L = 8 +Lsub = 2 +model = "Spin" +lattice = "chain" +J = 1 +NSPGaussLeg = 8 +2Sz = 0 +NSPStot = 0 +NSROptItrStep = 600 +NSROptItrSmp = 100 +NVMCSample = 1000 +DSROptRedCut = 1e-8 +DSROptStaDel = 1e-2 +DSROptStepDt = 1e-2 +//NVMCCalMode = 1 diff --git a/samples/tutorial_2.1/stan_spin_S1.in b/samples/tutorial_2.1/stan_spin_S1.in new file mode 100644 index 00000000..9ba4a30f --- /dev/null +++ b/samples/tutorial_2.1/stan_spin_S1.in @@ -0,0 +1,15 @@ +L = 8 +Lsub = 2 +model = "Spin" +lattice = "chain" +J = 1 +NSPGaussLeg = 8 +2Sz = 0 +NSPStot = 1 +NSROptItrStep = 600 +NSROptItrSmp = 100 +NVMCSample = 1000 +DSROptRedCut = 1e-8 +DSROptStaDel = 1e-2 +DSROptStepDt = 1e-2 +//NVMCCalMode = 1 diff --git a/samples/tutorial_2.1/stan_spin_hphi.in b/samples/tutorial_2.1/stan_spin_hphi.in new file mode 100644 index 00000000..13cfc53d --- /dev/null +++ b/samples/tutorial_2.1/stan_spin_hphi.in @@ -0,0 +1,6 @@ +L = 8 +model = "Spin" +method = "FullDiag" +lattice = "chain" +J = 1 +2Sz = 0 diff --git a/samples/tutorial_2.2/CalcSC.py b/samples/tutorial_2.2/CalcSC.py new file mode 100644 index 00000000..43781b11 --- /dev/null +++ b/samples/tutorial_2.2/CalcSC.py @@ -0,0 +1,174 @@ +import numpy as np +import math +import cmath +import toml +import sys +import SCGreen +import MakeInput +import VMClocal + +def main(): + + #[s] tolm load + input_file = sys.argv[1] + list_org,list_sub,input_dict = MakeInput.read_toml(input_file) + ini_cnt,max_cnt,calcmode = VMClocal.ReadModpara(input_dict) + dir_name = input_dict["mVMC_aft"]["directory"] + All_N = list_org[0]*list_org[1]*list_org[2]*list_org[3] + #[e] tolm load + + trans_1x,trans_1y,trans_2x,trans_2y,trans_3x,trans_3y = SCGreen.MakeFormFactor() + print(trans_2x) + print(trans_2y) + #[s] output misc files + Ini_site = SCGreen.MakeIniSite(list_org,list_sub,"full") + print(Ini_site) + + G1 = read_G1(All_N,max_cnt,dir_name) + # + G2_swave = read_G2_swave(All_N,max_cnt,dir_name,G1,trans_1x,trans_1y) + ave_SC_swave,err_SC_swave = ave_swave_G2(list_org,max_cnt,dir_name,G2_swave) + Output_SC(list_org,Ini_site,ave_SC_swave,err_SC_swave,"Result_1swave.dat") + # + +def ave_swave_G2(list_org,max_cnt,dir_name,G2): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + orb_num = list_org[3] + All_site = Lx*Ly*Lz + + SC_swave = np.zeros((max_cnt,All_site),dtype=np.float64) + for num_bin in range(0,max_cnt): + for site_i in range(0,All_site): + vec_x_i = site_i %Lx + vec_y_i = int((site_i-vec_x_i)/Lx) + all_i = site_i + tmp = 0.0 + for site_j in range(0,All_site): + ini_x_j = site_j %Lx + ini_y_j = int((site_j-ini_x_j)/Lx) + ini_all_j = site_j + x_j = (ini_x_j+vec_x_i+Lx)%Lx + y_j = (ini_y_j+vec_y_i+Ly)%Ly + all_j = x_j+y_j*Lx + #if all_i == 0 : + # print(num_bin,all_i,all_j, G2[num_bin][all_j][all_i][0][0], G2[num_bin][all_j][all_i][0][1]) + tmp += G2[num_bin][ini_all_j][all_j][0][0]+G2[num_bin][ini_all_j][all_j][0][1] + SC_swave[num_bin][site_i] = tmp/(4.0*All_site) + print(SC_swave[0][0]) + ave_G2 = np.mean(SC_swave,axis=0) + err_G2 = np.std(SC_swave,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + #for all_i in range(0,All_N,2): + # for all_j in range(0,All_N,2): + # print(all_i,all_j,ave_G2[all_i][all_j]) + return ave_G2,err_G2 + #print(ave_G2) + +def read_G2_swave(All_N,max_cnt,dir_name,G1,trans_x,trans_y): + num_neighbor = len(trans_x)*len(trans_y) + print("num_neighbor",num_neighbor) + G2 = np.zeros((max_cnt,All_N,All_N,num_neighbor,2),dtype=np.float64) + for num_bin in range(0,max_cnt): + file_name ="{}".format(dir_name)+"/zvo_cisajscktalt_00"+"{0:1d}".format(num_bin)+".dat" + + with open(file_name) as f: + data = f.read() + data = data.split("\n") + print(len(data)) + #[s] count not empty elements + cnt = 0 + for i in range(0,len(data)): + if data[i]: # if data[i] is not empty + cnt += 1 + #print(cnt) + cnt_max = cnt + print("G2",cnt_max) + #[e] count not empty elements + for cnt_neighbor in range(num_neighbor): + for cnt in range(0,cnt_max,2): + tmp = data[cnt].split() + all_i = int(tmp[0]) + all_j = int(tmp[2]) + til_all_i = int(tmp[4]) + til_all_j = int(tmp[6]) + delta_0 = 0.0 + delta_1 = 0.0 + delta_2 = 0.0 + delta_3 = 0.0 + tmp = data[cnt].split() + G2[num_bin][all_i][all_j][cnt_neighbor][0] = float(tmp[8]) + + if all_i == all_j: + delta_0 = 1.0 + if til_all_i == til_all_j: + delta_1 = 1.0 + if all_i == til_all_j: + delta_2 = 1.0 + if til_all_i == all_j: + delta_3 = 1.0 + + tmp_2 = data[cnt+1].split() + tmp_G = delta_0*delta_1-delta_1*G1[num_bin][all_j][all_i][0]-delta_0*G1[num_bin][til_all_j][til_all_i][1] + #print(all_i,all_j,til_all_i,til_all_j,1,tmp_G) + G2[num_bin][all_i][all_j][cnt_neighbor][1] = float(tmp_2[8])+tmp_G + return G2 + +def read_G1(All_N,max_cnt,dir_name): + G1 = np.zeros((max_cnt,All_N,All_N,2),dtype=np.float64) + for num_bin in range(0,max_cnt): + file_name ="{}".format(dir_name)+"/zvo_cisajs_00"+"{0:1d}".format(num_bin)+".dat" + with open(file_name) as f: + tmp_G1 = f.read() + tmp_G1 = tmp_G1.split("\n") + print(len(tmp_G1)) + #[s] count not empty elements + cnt = 0 + for i in range(0,len(tmp_G1)): + if tmp_G1[i]: # if data[i] is not empty + cnt += 1 + #print(cnt) + cnt_max = cnt + #[e] count not empty elements + for cnt in range(0,cnt_max): + tmp = tmp_G1[cnt].split() + all_i = int(tmp[0]) + all_j = int(tmp[2]) + spn = int(tmp[1]) + #print(tmp) + G1[num_bin][all_i][all_j][spn] = float(tmp[4]) + return G1 + +def Output_SC(list_org,Ini_site,ave_SC,err_SC,name_file): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + orb_num = list_org[3] + ini_site_max = len(Ini_site) + site_max = Lx*Ly*Lz + + max_num_dis = (int(Lx/2)+1)**2+(int(Ly/2)+1)**2 + ave_SC_dis = np.zeros(max_num_dis,dtype=np.float64) + err_SC_dis = np.zeros(max_num_dis,dtype=np.float64) + for site_j in range(site_max): + x_j = site_j%Lx + y_j = int((site_j-x_j)/Lx) + diff_x = abs(x_j) + if diff_x > Lx/2: + diff_x = diff_x - Lx + diff_y = abs(y_j) + if diff_y > Ly/2: + diff_y = diff_y-Ly + tmp_dis = diff_x**2+diff_y**2 + #print(x_i,y_i,diff_x,x_j,y_j,diff_y,tmp_dis,max_cnt) + if abs(ave_SC[site_j]) > abs(ave_SC_dis[tmp_dis]): + ave_SC_dis[tmp_dis] = ave_SC[site_j] + err_SC_dis[tmp_dis] = err_SC[site_j] + + with open("%s" % (name_file) , 'w') as f: + for cnt in range(max_num_dis): + if abs(ave_SC_dis[cnt])>1e-12: + print(" %f %f %f %d " % (math.sqrt(cnt),abs(ave_SC_dis[cnt]),err_SC_dis[cnt],cnt) , file=f) + +if __name__ == "__main__": + main() diff --git a/samples/tutorial_2.2/Clean.sh b/samples/tutorial_2.2/Clean.sh new file mode 100644 index 00000000..a13201f7 --- /dev/null +++ b/samples/tutorial_2.2/Clean.sh @@ -0,0 +1,7 @@ +rm *.def +rm *.dat +rm *.gp +rm -r opt* +rm -r aft +rm -r __pycache__ + diff --git a/samples/tutorial_2.2/MakeInput.py b/samples/tutorial_2.2/MakeInput.py new file mode 100644 index 00000000..99c848aa --- /dev/null +++ b/samples/tutorial_2.2/MakeInput.py @@ -0,0 +1,175 @@ +import numpy as np +import math +import cmath +import toml +import sys + +def main(): + #[s] tolm load + input_file = sys.argv[1] + list_org,list_sub,input_dict = read_toml(input_file) + #[e] tolm load + #[s] output StdFace files + OutputStdFace(list_org,list_sub,input_dict) + #[s] output StdFace files + #[s] output StdFace files + OutputGreen(list_org) + #[s] output StdFace files + +def read_toml(input_file): + input_dict = toml.load(input_file) + #[e] tolm load + #[s]define constants + Lx = int(input_dict["lattice"]["Lx"]) + Ly = int(input_dict["lattice"]["Ly"]) + Lz = int(input_dict["lattice"]["Lz"]) + orb_num = int(input_dict["lattice"]["orb_num"]) + sub_x = int(input_dict["mVMC"]["sub_x"]) + sub_y = int(input_dict["mVMC"]["sub_y"]) + sub_z = int(input_dict["mVMC"]["sub_z"]) + #[e]define constants + All_N = Lx*Ly*Lz*orb_num + print('Lx = ',Lx) + print('Ly = ',Ly) + print('Ly = ',Lz) + print('orb_num = ',orb_num) + print('sub_x = ',sub_x) + print('sub_y = ',sub_y) + print('sub_z = ',sub_z) + + #[s] initialize + list_org = [Lx,Ly,Lz,orb_num] + list_sub = [sub_x,sub_y,sub_z] + #[e] initialize + + return list_org,list_sub,input_dict + +def CalcDim(list_org): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + orb_num = list_org[3] + + #[s] calc dim_type + if Ly == 1 and Lz == 1: + dim_type = 1 + elif Lz == 1: + dim_type = 2 + elif Lx>1 and Ly > 1 and Lz>1: + dim_type = 3 + else : + print(" Possible error in Lx, Ly, Lz") + print(" This script supports chain,square, and cubic in the following way: ") + print(" Lx>1 Ly=Lz=1 -> chain") + print(" Lx>1 Ly>1 Lz=1 -> square") + print(" Lx>1 Ly>1 Lz>1 -> cubic") + print(" Input Lx=%d Ly=%d Lz=%d do not meet above conditions." %(Lx,Ly,Lz)) + #[e] calc dim_type + return dim_type + +def OutputStdFace(list_org,list_sub,input_dict): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + orb_num = list_org[3] + Ncond = Lx*Ly*Lz*orb_num + sub_x = list_sub[0] + sub_y = list_sub[1] + sub_z = list_sub[2] + model_type = input_dict["lattice"]["model_type"] + + dim_type = CalcDim(list_org) + + #[s] make stan_com + stan_com = [] + if dim_type == 1: + stan_com.append("L = %d "%(Lx)) + stan_com.append("Lsub = %d "%(sub_x)) + stan_com.append("lattice = \"chain\"") + elif dim_type == 2: + stan_com.append("W = %d "%(Lx)) + stan_com.append("Wsub = %d "%(sub_x)) + stan_com.append("L = %d "%(Ly)) + stan_com.append("Lsub = %d "%(sub_y)) + stan_com.append("lattice = \"square\"") + elif dim_type == 3: + stan_com.append("W = %d "%(Lx)) + stan_com.append("Wsub = %d "%(sub_x)) + stan_com.append("L = %d "%(Ly)) + stan_com.append("Lsub = %d "%(sub_y)) + stan_com.append("Height = %d "%(Lz)) + stan_com.append("Hsub = %d "%(sub_z)) + stan_com.append("lattice = \"cubic\"") + + if model_type == "Spin": + stan_com.append("model = \"%s\" "%(model_type)) + stan_com.append("J = 1.0 ") + elif model_type == "Hubbard": + stan_com.append("model = \"%s\" "%(model_type)) + stan_com.append("t = 1.0 ") + stan_com.append("U = 4.0 ") + stan_com.append("ncond = %d " %(Ncond)) + elif model_type == "Kondo": + stan_com.append("model = \"%s\" "%(model_type)) + stan_com.append("t = 1.0 ") + stan_com.append("J = 1.0 ") + stan_com.append("ncond = %d " %(int(Ncond/2))) + else: + print("This scropt only support Spin, Hubbard, Kondo") + + stan_com.append("2Sz = 0 ") + stan_com.append("NVMCSample = 200 ") + stan_com.append("NSROptItrStep = 600 ") + stan_com.append("NMPTrans = 1 ") + stan_com.append("NSPStot = 0 ") + #[e] make stan_com + + with open("stan_opt.in", 'w') as f: + for cnt_std in stan_com: + print(cnt_std,file=f) + + with open("stan_aft.in", 'w') as f: + for cnt_std in stan_com: + print(cnt_std,file=f) + print("NVMCCalMode = 1 ",file=f) + print("NDataIdxStart = 0 ",file=f) + print("NDataQtySmp = 5 ",file=f) + + + +def OutputGreen(list_org): + All_N = list_org[0]*list_org[1]*list_org[2]*list_org[3] + + with open("green1", 'w') as f: + print("==================", file=f) + print("onebody %d "%(2*All_N**2), file=f) + print("==================", file=f) + print("==================", file=f) + print("==================", file=f) + for all_i in range(0,All_N): + for all_j in range(0,All_N): + print(" %d %d %d %d "% (all_i,0,all_j,0), file=f) + print(" %d %d %d %d "% (all_i,1,all_j,1), file=f) + + with open("green2", 'w') as f: + print("==================", file=f) + print("twobody %d "%(6*All_N**2), file=f) + print("==================", file=f) + print("==================", file=f) + print("==================", file=f) + for all_i in range(0,All_N): + for all_j in range(0,All_N): + print(" %d %d %d %d %d %d %d %d"% (all_i,0,all_i,0,all_j,0,all_j,0), file=f) + print(" %d %d %d %d %d %d %d %d"% (all_i,0,all_i,0,all_j,1,all_j,1), file=f) + print(" %d %d %d %d %d %d %d %d"% (all_i,1,all_i,1,all_j,0,all_j,0), file=f) + print(" %d %d %d %d %d %d %d %d"% (all_i,1,all_i,1,all_j,1,all_j,1), file=f) + # + print(" %d %d %d %d %d %d %d %d"% (all_i,0,all_j,0,all_j,1,all_i,1), file=f) + print(" %d %d %d %d %d %d %d %d"% (all_i,1,all_j,1,all_j,0,all_i,0), file=f) + + + + + +if __name__ == "__main__": + main() diff --git a/samples/tutorial_2.2/SCGreen.py b/samples/tutorial_2.2/SCGreen.py new file mode 100644 index 00000000..d2bee115 --- /dev/null +++ b/samples/tutorial_2.2/SCGreen.py @@ -0,0 +1,150 @@ +import numpy as np +import math +import cmath +import toml +import sys + +import MakeInput + +def main(): + #[s] tolm load + #[s] tolm load + input_file = sys.argv[1] + list_org,list_sub,input_dict = MakeInput.read_toml(input_file) + #[e] tolm load + + trans_1x,trans_1y,trans_2x,trans_2y,trans_3x,trans_3y = MakeFormFactor() + #[s] output green files + Ini_site = MakeIniSite(list_org,list_sub,"full") + Output_SC(list_org,Ini_site,trans_1x,trans_1y,"swave","SC_1swave") + #Output_SC(list_org,Ini_site,trans_2x,trans_2y,"diagonal","SC_2s2d.def") for 2s-wave and 2d-wave + #[e] output green files + +def MakeIniSite(list_org,list_sub,type_ini): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + if type_ini == "full": + site_max = Lx*Ly*Lz + Ini_site = np.zeros(site_max, dtype=np.int64) + for cnt_i in range(site_max): + Ini_site[cnt_i] = cnt_i + elif type_ini == "reduce": + sub_Lx = list_sub[0] + sub_Ly = list_sub[1] + site_max = sub_Lx*sub_Ly + Ini_site = np.zeros(site_max, dtype=np.int64) + for cnt_i in range(site_max): + tmp_x_i = cnt_i%sub_Lx + tmp_y_i = int((cnt_i-tmp_x_i)/sub_Lx) + all_i = tmp_x_i+tmp_y_i*Lx + Ini_site[cnt_i] = all_i + return Ini_site + + +def MakeFormFactor(): + trans_1x = np.zeros([1], dtype=np.int64) + trans_1y = np.zeros([1], dtype=np.int64) + # + trans_2x = np.zeros([4], dtype=np.int64) + trans_2y = np.zeros([4], dtype=np.int64) + # + trans_3x = np.zeros([4], dtype=np.int64) + trans_3y = np.zeros([4], dtype=np.int64) + # + trans_1x[0] = 0 + trans_1y[0] = 0 + # + trans_2x[0] = 1 + trans_2y[0] = 0 + # + trans_2x[1] = -1 + trans_2y[1] = 0 + # + trans_2x[2] = 0 + trans_2y[2] = 1 + # + trans_2x[3] = 0 + trans_2y[3] = -1 + # + trans_3x[0] = 1 + trans_3y[0] = 1 + # + trans_3x[1] = -1 + trans_3y[1] = -1 + # + trans_3x[2] = 1 + trans_3y[2] = -1 + # + trans_3x[3] = -1 + trans_3y[3] = 1 + + return trans_1x,trans_1y,trans_2x,trans_2y,trans_3x,trans_3y + + +def Output_SC(list_org,Ini_site,trans_x,trans_y,type_of_orbital,name_file): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + orb_num = list_org[3] + ini_site_max = len(Ini_site) + site_max = Lx*Ly*Lz + num_trans = len(trans_x) + if type_of_orbital == "diagonal": + tot_orb = int(orb_num) + cnt_max = 8*(site_max*ini_site_max)*(num_trans**2)*tot_orb + elif type_of_orbital == "swave": + tot_orb = int(orb_num) + cnt_max = 2*(site_max*ini_site_max)*tot_orb*tot_orb + else: + print("fatal error type_or_orbital should be diagonal or swave") + #print(' cnt_V = ',cnt_V) + with open("%s" % (name_file), 'w') as f: + print("====== ", file=f) + print("%s %d " % ('N', cnt_max), file=f) + print("====== ", file=f) + print("====== ", file=f) + print("====== ", file=f) + if type_of_orbital == "swave": + for tmp_site_i in range(ini_site_max): + site_i = Ini_site[tmp_site_i] + x_i = site_i%Lx + y_i = int((site_i-x_i)/Lx) + for orb_i in range(orb_num): + all_i = orb_i + site_i*orb_num + for all_j in range(site_max*orb_num): + print(" %8d %8d %8d %8d %8d %8d %8d %8d " % (all_i,0,all_j,0,all_i,1,all_j,1), file=f) + print(" %8d %8d %8d %8d %8d %8d %8d %8d " % (all_j,0,all_i,0,all_j,1,all_i,1), file=f) + + if type_of_orbital == "diagonal": + for tmp_site_i in range(ini_site_max): + site_i = Ini_site[tmp_site_i] + x_i = site_i%Lx + y_i = int((site_i-x_i)/Lx) + for site_j in range(site_max): + x_j = site_j%Lx + y_j = int((site_j-x_j)/Lx) + for cnt_i in range(len(trans_x)): + til_site_i = ((x_i+trans_x[cnt_i]+Lx)%Lx)+((y_i+trans_y[cnt_i]+Ly)%Ly)*Lx + for cnt_j in range(len(trans_x)): + til_site_j = ((x_j+trans_x[cnt_j]+Lx)%Lx)+((y_j+trans_y[cnt_j]+Ly)%Ly)*Lx + for orb_i in range(orb_num): + all_i = orb_i + site_i*orb_num + til_all_i = orb_i + til_site_i*orb_num + all_j = orb_i + site_j*orb_num + til_all_j = orb_i + til_site_j*orb_num + print(" %8d %8d %8d %8d %8d %8d %8d %8d " % (all_i,0,all_j,0,til_all_i,1,til_all_j,1), file=f) + print(" %8d %8d %8d %8d %8d %8d %8d %8d " % (all_j,0,all_i,0,til_all_j,1,til_all_i,1), file=f) + # + print(" %8d %8d %8d %8d %8d %8d %8d %8d " % (all_i,0,til_all_j,0,til_all_i,1,all_j,1), file=f) + print(" %8d %8d %8d %8d %8d %8d %8d %8d " % (til_all_j,0,all_i,0,all_j,1,til_all_i,1), file=f) + # + print(" %8d %8d %8d %8d %8d %8d %8d %8d " % (til_all_i,0,all_j,0,all_i,1,til_all_j,1), file=f) + print(" %8d %8d %8d %8d %8d %8d %8d %8d " % (all_j,0,til_all_i,0,til_all_j,1,all_i,1), file=f) + # + print(" %8d %8d %8d %8d %8d %8d %8d %8d " % (til_all_i,0,til_all_j,0,all_i,1,all_j,1), file=f) + print(" %8d %8d %8d %8d %8d %8d %8d %8d " % (til_all_j,0,til_all_i,0,all_j,1,all_i,1), file=f) + + +if __name__ == "__main__": + main() diff --git a/samples/tutorial_2.2/SC_1swave b/samples/tutorial_2.2/SC_1swave new file mode 100644 index 00000000..f9a1e716 --- /dev/null +++ b/samples/tutorial_2.2/SC_1swave @@ -0,0 +1,517 @@ +====== +N 512 +====== +====== +====== + 0 0 0 0 0 1 0 1 + 0 0 0 0 0 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+ 11 0 10 0 11 1 10 1 + 10 0 12 0 10 1 12 1 + 12 0 10 0 12 1 10 1 + 10 0 13 0 10 1 13 1 + 13 0 10 0 13 1 10 1 + 10 0 14 0 10 1 14 1 + 14 0 10 0 14 1 10 1 + 10 0 15 0 10 1 15 1 + 15 0 10 0 15 1 10 1 + 11 0 0 0 11 1 0 1 + 0 0 11 0 0 1 11 1 + 11 0 1 0 11 1 1 1 + 1 0 11 0 1 1 11 1 + 11 0 2 0 11 1 2 1 + 2 0 11 0 2 1 11 1 + 11 0 3 0 11 1 3 1 + 3 0 11 0 3 1 11 1 + 11 0 4 0 11 1 4 1 + 4 0 11 0 4 1 11 1 + 11 0 5 0 11 1 5 1 + 5 0 11 0 5 1 11 1 + 11 0 6 0 11 1 6 1 + 6 0 11 0 6 1 11 1 + 11 0 7 0 11 1 7 1 + 7 0 11 0 7 1 11 1 + 11 0 8 0 11 1 8 1 + 8 0 11 0 8 1 11 1 + 11 0 9 0 11 1 9 1 + 9 0 11 0 9 1 11 1 + 11 0 10 0 11 1 10 1 + 10 0 11 0 10 1 11 1 + 11 0 11 0 11 1 11 1 + 11 0 11 0 11 1 11 1 + 11 0 12 0 11 1 12 1 + 12 0 11 0 12 1 11 1 + 11 0 13 0 11 1 13 1 + 13 0 11 0 13 1 11 1 + 11 0 14 0 11 1 14 1 + 14 0 11 0 14 1 11 1 + 11 0 15 0 11 1 15 1 + 15 0 11 0 15 1 11 1 + 12 0 0 0 12 1 0 1 + 0 0 12 0 0 1 12 1 + 12 0 1 0 12 1 1 1 + 1 0 12 0 1 1 12 1 + 12 0 2 0 12 1 2 1 + 2 0 12 0 2 1 12 1 + 12 0 3 0 12 1 3 1 + 3 0 12 0 3 1 12 1 + 12 0 4 0 12 1 4 1 + 4 0 12 0 4 1 12 1 + 12 0 5 0 12 1 5 1 + 5 0 12 0 5 1 12 1 + 12 0 6 0 12 1 6 1 + 6 0 12 0 6 1 12 1 + 12 0 7 0 12 1 7 1 + 7 0 12 0 7 1 12 1 + 12 0 8 0 12 1 8 1 + 8 0 12 0 8 1 12 1 + 12 0 9 0 12 1 9 1 + 9 0 12 0 9 1 12 1 + 12 0 10 0 12 1 10 1 + 10 0 12 0 10 1 12 1 + 12 0 11 0 12 1 11 1 + 11 0 12 0 11 1 12 1 + 12 0 12 0 12 1 12 1 + 12 0 12 0 12 1 12 1 + 12 0 13 0 12 1 13 1 + 13 0 12 0 13 1 12 1 + 12 0 14 0 12 1 14 1 + 14 0 12 0 14 1 12 1 + 12 0 15 0 12 1 15 1 + 15 0 12 0 15 1 12 1 + 13 0 0 0 13 1 0 1 + 0 0 13 0 0 1 13 1 + 13 0 1 0 13 1 1 1 + 1 0 13 0 1 1 13 1 + 13 0 2 0 13 1 2 1 + 2 0 13 0 2 1 13 1 + 13 0 3 0 13 1 3 1 + 3 0 13 0 3 1 13 1 + 13 0 4 0 13 1 4 1 + 4 0 13 0 4 1 13 1 + 13 0 5 0 13 1 5 1 + 5 0 13 0 5 1 13 1 + 13 0 6 0 13 1 6 1 + 6 0 13 0 6 1 13 1 + 13 0 7 0 13 1 7 1 + 7 0 13 0 7 1 13 1 + 13 0 8 0 13 1 8 1 + 8 0 13 0 8 1 13 1 + 13 0 9 0 13 1 9 1 + 9 0 13 0 9 1 13 1 + 13 0 10 0 13 1 10 1 + 10 0 13 0 10 1 13 1 + 13 0 11 0 13 1 11 1 + 11 0 13 0 11 1 13 1 + 13 0 12 0 13 1 12 1 + 12 0 13 0 12 1 13 1 + 13 0 13 0 13 1 13 1 + 13 0 13 0 13 1 13 1 + 13 0 14 0 13 1 14 1 + 14 0 13 0 14 1 13 1 + 13 0 15 0 13 1 15 1 + 15 0 13 0 15 1 13 1 + 14 0 0 0 14 1 0 1 + 0 0 14 0 0 1 14 1 + 14 0 1 0 14 1 1 1 + 1 0 14 0 1 1 14 1 + 14 0 2 0 14 1 2 1 + 2 0 14 0 2 1 14 1 + 14 0 3 0 14 1 3 1 + 3 0 14 0 3 1 14 1 + 14 0 4 0 14 1 4 1 + 4 0 14 0 4 1 14 1 + 14 0 5 0 14 1 5 1 + 5 0 14 0 5 1 14 1 + 14 0 6 0 14 1 6 1 + 6 0 14 0 6 1 14 1 + 14 0 7 0 14 1 7 1 + 7 0 14 0 7 1 14 1 + 14 0 8 0 14 1 8 1 + 8 0 14 0 8 1 14 1 + 14 0 9 0 14 1 9 1 + 9 0 14 0 9 1 14 1 + 14 0 10 0 14 1 10 1 + 10 0 14 0 10 1 14 1 + 14 0 11 0 14 1 11 1 + 11 0 14 0 11 1 14 1 + 14 0 12 0 14 1 12 1 + 12 0 14 0 12 1 14 1 + 14 0 13 0 14 1 13 1 + 13 0 14 0 13 1 14 1 + 14 0 14 0 14 1 14 1 + 14 0 14 0 14 1 14 1 + 14 0 15 0 14 1 15 1 + 15 0 14 0 15 1 14 1 + 15 0 0 0 15 1 0 1 + 0 0 15 0 0 1 15 1 + 15 0 1 0 15 1 1 1 + 1 0 15 0 1 1 15 1 + 15 0 2 0 15 1 2 1 + 2 0 15 0 2 1 15 1 + 15 0 3 0 15 1 3 1 + 3 0 15 0 3 1 15 1 + 15 0 4 0 15 1 4 1 + 4 0 15 0 4 1 15 1 + 15 0 5 0 15 1 5 1 + 5 0 15 0 5 1 15 1 + 15 0 6 0 15 1 6 1 + 6 0 15 0 6 1 15 1 + 15 0 7 0 15 1 7 1 + 7 0 15 0 7 1 15 1 + 15 0 8 0 15 1 8 1 + 8 0 15 0 8 1 15 1 + 15 0 9 0 15 1 9 1 + 9 0 15 0 9 1 15 1 + 15 0 10 0 15 1 10 1 + 10 0 15 0 10 1 15 1 + 15 0 11 0 15 1 11 1 + 11 0 15 0 11 1 15 1 + 15 0 12 0 15 1 12 1 + 12 0 15 0 12 1 15 1 + 15 0 13 0 15 1 13 1 + 13 0 15 0 13 1 15 1 + 15 0 14 0 15 1 14 1 + 14 0 15 0 14 1 15 1 + 15 0 15 0 15 1 15 1 + 15 0 15 0 15 1 15 1 diff --git a/samples/tutorial_2.2/VMClocal.py b/samples/tutorial_2.2/VMClocal.py new file mode 100644 index 00000000..6486f96c --- /dev/null +++ b/samples/tutorial_2.2/VMClocal.py @@ -0,0 +1,116 @@ +import cmath +import math +import sys + +import numpy as np +import toml + +import MakeInput +import qlms_lattice + + +def main(): + #[s] tolm load + input_file = sys.argv[1] + list_org,list_sub,input_dict = MakeInput.read_toml(input_file) + + ini_cnt,max_cnt,calcmode = ReadModpara(input_dict) + All_N = list_org[0]*list_org[1]*list_org[2]*list_org[3] + All_site = list_org[0]*list_org[1]*list_org[2] + orb_num = list_org[3] + dir_name = input_dict["mVMC_aft"]["directory"] + + tot_Ene = np.zeros([max_cnt], dtype=np.float64) + tot_occ = np.zeros([max_cnt,orb_num], dtype=np.float64) + tot_AF = np.zeros([max_cnt,orb_num], dtype=np.float64) + for i_smp in range(ini_cnt,ini_cnt+max_cnt): + file_name = "%s/zvo_cisajs_00%d.dat" % (dir_name,i_smp) + occ,AF = ReadG1(file_name,list_org,i_smp) + for orb_i in range(orb_num): + tot_occ[i_smp][orb_i] = occ[orb_i] + tot_AF[i_smp][orb_i] = AF[orb_i] + # + file_name = "%s/zvo_out_00%d.dat" % (dir_name,i_smp) + tot_Ene[i_smp] = ReadEne(file_name,list_org,i_smp) + + Ave_Ene = np.mean(tot_Ene,axis=0) + Err_Ene = np.std(tot_Ene,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + # + Ave_occ = np.mean(tot_occ,axis=0) + Err_occ = np.std(tot_occ,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + Ave_AF = np.mean(tot_AF,axis=0) + Err_AF = np.std(tot_AF,axis=0,ddof=1)/math.sqrt(1.0*max_cnt) + + with open("Ene.dat", 'w') as f: + print("%s " % ("# Ene err_Ene Ene/(All_site) err_Ene/(All_site)"),file=f) + print("%f %f %f %f" % (Ave_Ene,Err_Ene,Ave_Ene/(All_site),Err_Ene/(All_site)),file=f) + with open("occ.dat", 'w') as f: + print("%s " % ("# occ err_occ AF err_AF"),file=f) + for orb_i in range(orb_num): + print("%f %f %f %f" % (Ave_occ[orb_i],Err_occ[orb_i],Ave_AF[orb_i],Err_AF[orb_i]),end="",file=f) + print(" " ,file=f) + +def ReadModpara(input_dict): + file_name = input_dict["mVMC_aft"]["modpara"] + with open(file_name) as f: + data = f.read() + data = data.split("\n") + for i in range(0,len(data)): + if data[i]: # if data[i] is not empty + tmp = data[i].split() + if tmp[0] == "NDataIdxStart": + ini_cnt = int(tmp[1]) + if tmp[0] == "NDataQtySmp": + max_cnt = int(tmp[1]) + if tmp[0] == "NVMCCalMode": + calcmode = int(tmp[1]) + return ini_cnt,max_cnt,calcmode + + +def ReadEne(file_name,list_org,i_smp): + with open(file_name) as f: + data = f.read() + data = data.split("\n") + #print(len(data)) + tmp = data[0].split() + tmp_Ene = tmp[0] + return tmp_Ene + + +def ReadG1(file_name,list_org,i_smp): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + orb_num = list_org[3] + #file_name = "output/zvo_aft_cisajs_001.dat" + with open(file_name) as f: + data = f.read() + data = data.split("\n") + #print(len(data)) + #[s] count not empty elements + occ = np.zeros([orb_num], dtype=np.float64) + AF = np.zeros([orb_num], dtype=np.float64) + for i in range(0,len(data)): + if data[i]: # if data[i] is not empty + tmp = data[i].split() + if tmp[0] == tmp[2]: + all_i = int(tmp[0]) + list_site = qlms_lattice.get_site(all_i,list_org) + x_i = list_site[0] + y_i = list_site[1] + orb_i = list_site[3] + sgn = math.cos(math.pi*x_i+math.pi*y_i) + if tmp[1] == tmp[3] and int(tmp[1]) == 0: + occ[orb_i] += float(tmp[4]) + AF[orb_i] += sgn*float(tmp[4]) + if tmp[1] == tmp[3] and int(tmp[1]) == 1: + occ[orb_i] += float(tmp[4]) + AF[orb_i] += -sgn*float(tmp[4]) + #[e] count not empty elements + occ = occ/(Lx*Ly*Lz) + AF = AF/(Lx*Ly*Lz) + return occ,AF + + +if __name__ == "__main__": + main() diff --git a/samples/tutorial_2.2/green1 b/samples/tutorial_2.2/green1 new file mode 100644 index 00000000..1369b0df --- /dev/null +++ b/samples/tutorial_2.2/green1 @@ -0,0 +1,517 @@ +================== +onebody 512 +================== +================== +================== + 0 0 0 0 + 0 1 0 1 + 0 0 1 0 + 0 1 1 1 + 0 0 2 0 + 0 1 2 1 + 0 0 3 0 + 0 1 3 1 + 0 0 4 0 + 0 1 4 1 + 0 0 5 0 + 0 1 5 1 + 0 0 6 0 + 0 1 6 1 + 0 0 7 0 + 0 1 7 1 + 0 0 8 0 + 0 1 8 1 + 0 0 9 0 + 0 1 9 1 + 0 0 10 0 + 0 1 10 1 + 0 0 11 0 + 0 1 11 1 + 0 0 12 0 + 0 1 12 1 + 0 0 13 0 + 0 1 13 1 + 0 0 14 0 + 0 1 14 1 + 0 0 15 0 + 0 1 15 1 + 1 0 0 0 + 1 1 0 1 + 1 0 1 0 + 1 1 1 1 + 1 0 2 0 + 1 1 2 1 + 1 0 3 0 + 1 1 3 1 + 1 0 4 0 + 1 1 4 1 + 1 0 5 0 + 1 1 5 1 + 1 0 6 0 + 1 1 6 1 + 1 0 7 0 + 1 1 7 1 + 1 0 8 0 + 1 1 8 1 + 1 0 9 0 + 1 1 9 1 + 1 0 10 0 + 1 1 10 1 + 1 0 11 0 + 1 1 11 1 + 1 0 12 0 + 1 1 12 1 + 1 0 13 0 + 1 1 13 1 + 1 0 14 0 + 1 1 14 1 + 1 0 15 0 + 1 1 15 1 + 2 0 0 0 + 2 1 0 1 + 2 0 1 0 + 2 1 1 1 + 2 0 2 0 + 2 1 2 1 + 2 0 3 0 + 2 1 3 1 + 2 0 4 0 + 2 1 4 1 + 2 0 5 0 + 2 1 5 1 + 2 0 6 0 + 2 1 6 1 + 2 0 7 0 + 2 1 7 1 + 2 0 8 0 + 2 1 8 1 + 2 0 9 0 + 2 1 9 1 + 2 0 10 0 + 2 1 10 1 + 2 0 11 0 + 2 1 11 1 + 2 0 12 0 + 2 1 12 1 + 2 0 13 0 + 2 1 13 1 + 2 0 14 0 + 2 1 14 1 + 2 0 15 0 +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 + 9 0 6 0 + 9 1 6 1 + 9 0 7 0 + 9 1 7 1 + 9 0 8 0 + 9 1 8 1 + 9 0 9 0 + 9 1 9 1 + 9 0 10 0 + 9 1 10 1 + 9 0 11 0 + 9 1 11 1 + 9 0 12 0 + 9 1 12 1 + 9 0 13 0 + 9 1 13 1 + 9 0 14 0 + 9 1 14 1 + 9 0 15 0 + 9 1 15 1 + 10 0 0 0 + 10 1 0 1 + 10 0 1 0 + 10 1 1 1 + 10 0 2 0 + 10 1 2 1 + 10 0 3 0 + 10 1 3 1 + 10 0 4 0 + 10 1 4 1 + 10 0 5 0 + 10 1 5 1 + 10 0 6 0 + 10 1 6 1 + 10 0 7 0 + 10 1 7 1 + 10 0 8 0 + 10 1 8 1 + 10 0 9 0 + 10 1 9 1 + 10 0 10 0 + 10 1 10 1 + 10 0 11 0 + 10 1 11 1 + 10 0 12 0 + 10 1 12 1 + 10 0 13 0 + 10 1 13 1 + 10 0 14 0 + 10 1 14 1 + 10 0 15 0 + 10 1 15 1 + 11 0 0 0 + 11 1 0 1 + 11 0 1 0 + 11 1 1 1 + 11 0 2 0 + 11 1 2 1 + 11 0 3 0 + 11 1 3 1 + 11 0 4 0 + 11 1 4 1 + 11 0 5 0 + 11 1 5 1 + 11 0 6 0 + 11 1 6 1 + 11 0 7 0 + 11 1 7 1 + 11 0 8 0 + 11 1 8 1 + 11 0 9 0 + 11 1 9 1 + 11 0 10 0 + 11 1 10 1 + 11 0 11 0 + 11 1 11 1 + 11 0 12 0 + 11 1 12 1 + 11 0 13 0 + 11 1 13 1 + 11 0 14 0 + 11 1 14 1 + 11 0 15 0 + 11 1 15 1 + 12 0 0 0 + 12 1 0 1 + 12 0 1 0 + 12 1 1 1 + 12 0 2 0 + 12 1 2 1 + 12 0 3 0 + 12 1 3 1 + 12 0 4 0 + 12 1 4 1 + 12 0 5 0 + 12 1 5 1 + 12 0 6 0 + 12 1 6 1 + 12 0 7 0 + 12 1 7 1 + 12 0 8 0 + 12 1 8 1 + 12 0 9 0 + 12 1 9 1 + 12 0 10 0 + 12 1 10 1 + 12 0 11 0 + 12 1 11 1 + 12 0 12 0 + 12 1 12 1 + 12 0 13 0 + 12 1 13 1 + 12 0 14 0 + 12 1 14 1 + 12 0 15 0 + 12 1 15 1 + 13 0 0 0 + 13 1 0 1 + 13 0 1 0 + 13 1 1 1 + 13 0 2 0 + 13 1 2 1 + 13 0 3 0 + 13 1 3 1 + 13 0 4 0 + 13 1 4 1 + 13 0 5 0 + 13 1 5 1 + 13 0 6 0 + 13 1 6 1 + 13 0 7 0 + 13 1 7 1 + 13 0 8 0 + 13 1 8 1 + 13 0 9 0 + 13 1 9 1 + 13 0 10 0 + 13 1 10 1 + 13 0 11 0 + 13 1 11 1 + 13 0 12 0 + 13 1 12 1 + 13 0 13 0 + 13 1 13 1 + 13 0 14 0 + 13 1 14 1 + 13 0 15 0 + 13 1 15 1 + 14 0 0 0 + 14 1 0 1 + 14 0 1 0 + 14 1 1 1 + 14 0 2 0 + 14 1 2 1 + 14 0 3 0 + 14 1 3 1 + 14 0 4 0 + 14 1 4 1 + 14 0 5 0 + 14 1 5 1 + 14 0 6 0 + 14 1 6 1 + 14 0 7 0 + 14 1 7 1 + 14 0 8 0 + 14 1 8 1 + 14 0 9 0 + 14 1 9 1 + 14 0 10 0 + 14 1 10 1 + 14 0 11 0 + 14 1 11 1 + 14 0 12 0 + 14 1 12 1 + 14 0 13 0 + 14 1 13 1 + 14 0 14 0 + 14 1 14 1 + 14 0 15 0 + 14 1 15 1 + 15 0 0 0 + 15 1 0 1 + 15 0 1 0 + 15 1 1 1 + 15 0 2 0 + 15 1 2 1 + 15 0 3 0 + 15 1 3 1 + 15 0 4 0 + 15 1 4 1 + 15 0 5 0 + 15 1 5 1 + 15 0 6 0 + 15 1 6 1 + 15 0 7 0 + 15 1 7 1 + 15 0 8 0 + 15 1 8 1 + 15 0 9 0 + 15 1 9 1 + 15 0 10 0 + 15 1 10 1 + 15 0 11 0 + 15 1 11 1 + 15 0 12 0 + 15 1 12 1 + 15 0 13 0 + 15 1 13 1 + 15 0 14 0 + 15 1 14 1 + 15 0 15 0 + 15 1 15 1 diff --git a/samples/tutorial_2.2/green2 b/samples/tutorial_2.2/green2 new file mode 100644 index 00000000..3a2b11bb --- /dev/null +++ b/samples/tutorial_2.2/green2 @@ -0,0 +1,1541 @@ +================== +twobody 1536 +================== +================== +================== + 0 0 0 0 0 0 0 0 + 0 0 0 0 0 1 0 1 + 0 1 0 1 0 0 0 0 + 0 1 0 1 0 1 0 1 + 0 0 0 0 0 1 0 1 + 0 1 0 1 0 0 0 0 + 0 0 0 0 1 0 1 0 + 0 0 0 0 1 1 1 1 + 0 1 0 1 1 0 1 0 + 0 1 0 1 1 1 1 1 + 0 0 1 0 1 1 0 1 + 0 1 1 1 1 0 0 0 + 0 0 0 0 2 0 2 0 + 0 0 0 0 2 1 2 1 + 0 1 0 1 2 0 2 0 + 0 1 0 1 2 1 2 1 + 0 0 2 0 2 1 0 1 + 0 1 2 1 2 0 0 0 + 0 0 0 0 3 0 3 0 + 0 0 0 0 3 1 3 1 + 0 1 0 1 3 0 3 0 + 0 1 0 1 3 1 3 1 + 0 0 3 0 3 1 0 1 + 0 1 3 1 3 0 0 0 + 0 0 0 0 4 0 4 0 + 0 0 0 0 4 1 4 1 + 0 1 0 1 4 0 4 0 + 0 1 0 1 4 1 4 1 + 0 0 4 0 4 1 0 1 + 0 1 4 1 4 0 0 0 + 0 0 0 0 5 0 5 0 + 0 0 0 0 5 1 5 1 + 0 1 0 1 5 0 5 0 + 0 1 0 1 5 1 5 1 + 0 0 5 0 5 1 0 1 + 0 1 5 1 5 0 0 0 + 0 0 0 0 6 0 6 0 + 0 0 0 0 6 1 6 1 + 0 1 0 1 6 0 6 0 + 0 1 0 1 6 1 6 1 + 0 0 6 0 6 1 0 1 + 0 1 6 1 6 0 0 0 + 0 0 0 0 7 0 7 0 + 0 0 0 0 7 1 7 1 + 0 1 0 1 7 0 7 0 + 0 1 0 1 7 1 7 1 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1 9 1 15 0 15 0 + 9 1 9 1 15 1 15 1 + 9 0 15 0 15 1 9 1 + 9 1 15 1 15 0 9 0 + 10 0 10 0 0 0 0 0 + 10 0 10 0 0 1 0 1 + 10 1 10 1 0 0 0 0 + 10 1 10 1 0 1 0 1 + 10 0 0 0 0 1 10 1 + 10 1 0 1 0 0 10 0 + 10 0 10 0 1 0 1 0 + 10 0 10 0 1 1 1 1 + 10 1 10 1 1 0 1 0 + 10 1 10 1 1 1 1 1 + 10 0 1 0 1 1 10 1 + 10 1 1 1 1 0 10 0 + 10 0 10 0 2 0 2 0 + 10 0 10 0 2 1 2 1 + 10 1 10 1 2 0 2 0 + 10 1 10 1 2 1 2 1 + 10 0 2 0 2 1 10 1 + 10 1 2 1 2 0 10 0 + 10 0 10 0 3 0 3 0 + 10 0 10 0 3 1 3 1 + 10 1 10 1 3 0 3 0 + 10 1 10 1 3 1 3 1 + 10 0 3 0 3 1 10 1 + 10 1 3 1 3 0 10 0 + 10 0 10 0 4 0 4 0 + 10 0 10 0 4 1 4 1 + 10 1 10 1 4 0 4 0 + 10 1 10 1 4 1 4 1 + 10 0 4 0 4 1 10 1 + 10 1 4 1 4 0 10 0 + 10 0 10 0 5 0 5 0 + 10 0 10 0 5 1 5 1 + 10 1 10 1 5 0 5 0 + 10 1 10 1 5 1 5 1 + 10 0 5 0 5 1 10 1 + 10 1 5 1 5 0 10 0 + 10 0 10 0 6 0 6 0 + 10 0 10 0 6 1 6 1 + 10 1 10 1 6 0 6 0 + 10 1 10 1 6 1 6 1 + 10 0 6 0 6 1 10 1 + 10 1 6 1 6 0 10 0 + 10 0 10 0 7 0 7 0 + 10 0 10 0 7 1 7 1 + 10 1 10 1 7 0 7 0 + 10 1 10 1 7 1 7 1 + 10 0 7 0 7 1 10 1 + 10 1 7 1 7 0 10 0 + 10 0 10 0 8 0 8 0 + 10 0 10 0 8 1 8 1 + 10 1 10 1 8 0 8 0 + 10 1 10 1 8 1 8 1 + 10 0 8 0 8 1 10 1 + 10 1 8 1 8 0 10 0 + 10 0 10 0 9 0 9 0 + 10 0 10 0 9 1 9 1 + 10 1 10 1 9 0 9 0 + 10 1 10 1 9 1 9 1 + 10 0 9 0 9 1 10 1 + 10 1 9 1 9 0 10 0 + 10 0 10 0 10 0 10 0 + 10 0 10 0 10 1 10 1 + 10 1 10 1 10 0 10 0 + 10 1 10 1 10 1 10 1 + 10 0 10 0 10 1 10 1 + 10 1 10 1 10 0 10 0 + 10 0 10 0 11 0 11 0 + 10 0 10 0 11 1 11 1 + 10 1 10 1 11 0 11 0 + 10 1 10 1 11 1 11 1 + 10 0 11 0 11 1 10 1 + 10 1 11 1 11 0 10 0 + 10 0 10 0 12 0 12 0 + 10 0 10 0 12 1 12 1 + 10 1 10 1 12 0 12 0 + 10 1 10 1 12 1 12 1 + 10 0 12 0 12 1 10 1 + 10 1 12 1 12 0 10 0 + 10 0 10 0 13 0 13 0 + 10 0 10 0 13 1 13 1 + 10 1 10 1 13 0 13 0 + 10 1 10 1 13 1 13 1 + 10 0 13 0 13 1 10 1 + 10 1 13 1 13 0 10 0 + 10 0 10 0 14 0 14 0 + 10 0 10 0 14 1 14 1 + 10 1 10 1 14 0 14 0 + 10 1 10 1 14 1 14 1 + 10 0 14 0 14 1 10 1 + 10 1 14 1 14 0 10 0 + 10 0 10 0 15 0 15 0 + 10 0 10 0 15 1 15 1 + 10 1 10 1 15 0 15 0 + 10 1 10 1 15 1 15 1 + 10 0 15 0 15 1 10 1 + 10 1 15 1 15 0 10 0 + 11 0 11 0 0 0 0 0 + 11 0 11 0 0 1 0 1 + 11 1 11 1 0 0 0 0 + 11 1 11 1 0 1 0 1 + 11 0 0 0 0 1 11 1 + 11 1 0 1 0 0 11 0 + 11 0 11 0 1 0 1 0 + 11 0 11 0 1 1 1 1 + 11 1 11 1 1 0 1 0 + 11 1 11 1 1 1 1 1 + 11 0 1 0 1 1 11 1 + 11 1 1 1 1 0 11 0 + 11 0 11 0 2 0 2 0 + 11 0 11 0 2 1 2 1 + 11 1 11 1 2 0 2 0 + 11 1 11 1 2 1 2 1 + 11 0 2 0 2 1 11 1 + 11 1 2 1 2 0 11 0 + 11 0 11 0 3 0 3 0 + 11 0 11 0 3 1 3 1 + 11 1 11 1 3 0 3 0 + 11 1 11 1 3 1 3 1 + 11 0 3 0 3 1 11 1 + 11 1 3 1 3 0 11 0 + 11 0 11 0 4 0 4 0 + 11 0 11 0 4 1 4 1 + 11 1 11 1 4 0 4 0 + 11 1 11 1 4 1 4 1 + 11 0 4 0 4 1 11 1 + 11 1 4 1 4 0 11 0 + 11 0 11 0 5 0 5 0 + 11 0 11 0 5 1 5 1 + 11 1 11 1 5 0 5 0 + 11 1 11 1 5 1 5 1 + 11 0 5 0 5 1 11 1 + 11 1 5 1 5 0 11 0 + 11 0 11 0 6 0 6 0 + 11 0 11 0 6 1 6 1 + 11 1 11 1 6 0 6 0 + 11 1 11 1 6 1 6 1 + 11 0 6 0 6 1 11 1 + 11 1 6 1 6 0 11 0 + 11 0 11 0 7 0 7 0 + 11 0 11 0 7 1 7 1 + 11 1 11 1 7 0 7 0 + 11 1 11 1 7 1 7 1 + 11 0 7 0 7 1 11 1 + 11 1 7 1 7 0 11 0 + 11 0 11 0 8 0 8 0 + 11 0 11 0 8 1 8 1 + 11 1 11 1 8 0 8 0 + 11 1 11 1 8 1 8 1 + 11 0 8 0 8 1 11 1 + 11 1 8 1 8 0 11 0 + 11 0 11 0 9 0 9 0 + 11 0 11 0 9 1 9 1 + 11 1 11 1 9 0 9 0 + 11 1 11 1 9 1 9 1 + 11 0 9 0 9 1 11 1 + 11 1 9 1 9 0 11 0 + 11 0 11 0 10 0 10 0 + 11 0 11 0 10 1 10 1 + 11 1 11 1 10 0 10 0 + 11 1 11 1 10 1 10 1 + 11 0 10 0 10 1 11 1 + 11 1 10 1 10 0 11 0 + 11 0 11 0 11 0 11 0 + 11 0 11 0 11 1 11 1 + 11 1 11 1 11 0 11 0 + 11 1 11 1 11 1 11 1 + 11 0 11 0 11 1 11 1 + 11 1 11 1 11 0 11 0 + 11 0 11 0 12 0 12 0 + 11 0 11 0 12 1 12 1 + 11 1 11 1 12 0 12 0 + 11 1 11 1 12 1 12 1 + 11 0 12 0 12 1 11 1 + 11 1 12 1 12 0 11 0 + 11 0 11 0 13 0 13 0 + 11 0 11 0 13 1 13 1 + 11 1 11 1 13 0 13 0 + 11 1 11 1 13 1 13 1 + 11 0 13 0 13 1 11 1 + 11 1 13 1 13 0 11 0 + 11 0 11 0 14 0 14 0 + 11 0 11 0 14 1 14 1 + 11 1 11 1 14 0 14 0 + 11 1 11 1 14 1 14 1 + 11 0 14 0 14 1 11 1 + 11 1 14 1 14 0 11 0 + 11 0 11 0 15 0 15 0 + 11 0 11 0 15 1 15 1 + 11 1 11 1 15 0 15 0 + 11 1 11 1 15 1 15 1 + 11 0 15 0 15 1 11 1 + 11 1 15 1 15 0 11 0 + 12 0 12 0 0 0 0 0 + 12 0 12 0 0 1 0 1 + 12 1 12 1 0 0 0 0 + 12 1 12 1 0 1 0 1 + 12 0 0 0 0 1 12 1 + 12 1 0 1 0 0 12 0 + 12 0 12 0 1 0 1 0 + 12 0 12 0 1 1 1 1 + 12 1 12 1 1 0 1 0 + 12 1 12 1 1 1 1 1 + 12 0 1 0 1 1 12 1 + 12 1 1 1 1 0 12 0 + 12 0 12 0 2 0 2 0 + 12 0 12 0 2 1 2 1 + 12 1 12 1 2 0 2 0 + 12 1 12 1 2 1 2 1 + 12 0 2 0 2 1 12 1 + 12 1 2 1 2 0 12 0 + 12 0 12 0 3 0 3 0 + 12 0 12 0 3 1 3 1 + 12 1 12 1 3 0 3 0 + 12 1 12 1 3 1 3 1 + 12 0 3 0 3 1 12 1 + 12 1 3 1 3 0 12 0 + 12 0 12 0 4 0 4 0 + 12 0 12 0 4 1 4 1 + 12 1 12 1 4 0 4 0 + 12 1 12 1 4 1 4 1 + 12 0 4 0 4 1 12 1 + 12 1 4 1 4 0 12 0 + 12 0 12 0 5 0 5 0 + 12 0 12 0 5 1 5 1 + 12 1 12 1 5 0 5 0 + 12 1 12 1 5 1 5 1 + 12 0 5 0 5 1 12 1 + 12 1 5 1 5 0 12 0 + 12 0 12 0 6 0 6 0 + 12 0 12 0 6 1 6 1 + 12 1 12 1 6 0 6 0 + 12 1 12 1 6 1 6 1 + 12 0 6 0 6 1 12 1 + 12 1 6 1 6 0 12 0 + 12 0 12 0 7 0 7 0 + 12 0 12 0 7 1 7 1 + 12 1 12 1 7 0 7 0 + 12 1 12 1 7 1 7 1 + 12 0 7 0 7 1 12 1 + 12 1 7 1 7 0 12 0 + 12 0 12 0 8 0 8 0 + 12 0 12 0 8 1 8 1 + 12 1 12 1 8 0 8 0 + 12 1 12 1 8 1 8 1 + 12 0 8 0 8 1 12 1 + 12 1 8 1 8 0 12 0 + 12 0 12 0 9 0 9 0 + 12 0 12 0 9 1 9 1 + 12 1 12 1 9 0 9 0 + 12 1 12 1 9 1 9 1 + 12 0 9 0 9 1 12 1 + 12 1 9 1 9 0 12 0 + 12 0 12 0 10 0 10 0 + 12 0 12 0 10 1 10 1 + 12 1 12 1 10 0 10 0 + 12 1 12 1 10 1 10 1 + 12 0 10 0 10 1 12 1 + 12 1 10 1 10 0 12 0 + 12 0 12 0 11 0 11 0 + 12 0 12 0 11 1 11 1 + 12 1 12 1 11 0 11 0 + 12 1 12 1 11 1 11 1 + 12 0 11 0 11 1 12 1 + 12 1 11 1 11 0 12 0 + 12 0 12 0 12 0 12 0 + 12 0 12 0 12 1 12 1 + 12 1 12 1 12 0 12 0 + 12 1 12 1 12 1 12 1 + 12 0 12 0 12 1 12 1 + 12 1 12 1 12 0 12 0 + 12 0 12 0 13 0 13 0 + 12 0 12 0 13 1 13 1 + 12 1 12 1 13 0 13 0 + 12 1 12 1 13 1 13 1 + 12 0 13 0 13 1 12 1 + 12 1 13 1 13 0 12 0 + 12 0 12 0 14 0 14 0 + 12 0 12 0 14 1 14 1 + 12 1 12 1 14 0 14 0 + 12 1 12 1 14 1 14 1 + 12 0 14 0 14 1 12 1 + 12 1 14 1 14 0 12 0 + 12 0 12 0 15 0 15 0 + 12 0 12 0 15 1 15 1 + 12 1 12 1 15 0 15 0 + 12 1 12 1 15 1 15 1 + 12 0 15 0 15 1 12 1 + 12 1 15 1 15 0 12 0 + 13 0 13 0 0 0 0 0 + 13 0 13 0 0 1 0 1 + 13 1 13 1 0 0 0 0 + 13 1 13 1 0 1 0 1 + 13 0 0 0 0 1 13 1 + 13 1 0 1 0 0 13 0 + 13 0 13 0 1 0 1 0 + 13 0 13 0 1 1 1 1 + 13 1 13 1 1 0 1 0 + 13 1 13 1 1 1 1 1 + 13 0 1 0 1 1 13 1 + 13 1 1 1 1 0 13 0 + 13 0 13 0 2 0 2 0 + 13 0 13 0 2 1 2 1 + 13 1 13 1 2 0 2 0 + 13 1 13 1 2 1 2 1 + 13 0 2 0 2 1 13 1 + 13 1 2 1 2 0 13 0 + 13 0 13 0 3 0 3 0 + 13 0 13 0 3 1 3 1 + 13 1 13 1 3 0 3 0 + 13 1 13 1 3 1 3 1 + 13 0 3 0 3 1 13 1 + 13 1 3 1 3 0 13 0 + 13 0 13 0 4 0 4 0 + 13 0 13 0 4 1 4 1 + 13 1 13 1 4 0 4 0 + 13 1 13 1 4 1 4 1 + 13 0 4 0 4 1 13 1 + 13 1 4 1 4 0 13 0 + 13 0 13 0 5 0 5 0 + 13 0 13 0 5 1 5 1 + 13 1 13 1 5 0 5 0 + 13 1 13 1 5 1 5 1 + 13 0 5 0 5 1 13 1 + 13 1 5 1 5 0 13 0 + 13 0 13 0 6 0 6 0 + 13 0 13 0 6 1 6 1 + 13 1 13 1 6 0 6 0 + 13 1 13 1 6 1 6 1 + 13 0 6 0 6 1 13 1 + 13 1 6 1 6 0 13 0 + 13 0 13 0 7 0 7 0 + 13 0 13 0 7 1 7 1 + 13 1 13 1 7 0 7 0 + 13 1 13 1 7 1 7 1 + 13 0 7 0 7 1 13 1 + 13 1 7 1 7 0 13 0 + 13 0 13 0 8 0 8 0 + 13 0 13 0 8 1 8 1 + 13 1 13 1 8 0 8 0 + 13 1 13 1 8 1 8 1 + 13 0 8 0 8 1 13 1 + 13 1 8 1 8 0 13 0 + 13 0 13 0 9 0 9 0 + 13 0 13 0 9 1 9 1 + 13 1 13 1 9 0 9 0 + 13 1 13 1 9 1 9 1 + 13 0 9 0 9 1 13 1 + 13 1 9 1 9 0 13 0 + 13 0 13 0 10 0 10 0 + 13 0 13 0 10 1 10 1 + 13 1 13 1 10 0 10 0 + 13 1 13 1 10 1 10 1 + 13 0 10 0 10 1 13 1 + 13 1 10 1 10 0 13 0 + 13 0 13 0 11 0 11 0 + 13 0 13 0 11 1 11 1 + 13 1 13 1 11 0 11 0 + 13 1 13 1 11 1 11 1 + 13 0 11 0 11 1 13 1 + 13 1 11 1 11 0 13 0 + 13 0 13 0 12 0 12 0 + 13 0 13 0 12 1 12 1 + 13 1 13 1 12 0 12 0 + 13 1 13 1 12 1 12 1 + 13 0 12 0 12 1 13 1 + 13 1 12 1 12 0 13 0 + 13 0 13 0 13 0 13 0 + 13 0 13 0 13 1 13 1 + 13 1 13 1 13 0 13 0 + 13 1 13 1 13 1 13 1 + 13 0 13 0 13 1 13 1 + 13 1 13 1 13 0 13 0 + 13 0 13 0 14 0 14 0 + 13 0 13 0 14 1 14 1 + 13 1 13 1 14 0 14 0 + 13 1 13 1 14 1 14 1 + 13 0 14 0 14 1 13 1 + 13 1 14 1 14 0 13 0 + 13 0 13 0 15 0 15 0 + 13 0 13 0 15 1 15 1 + 13 1 13 1 15 0 15 0 + 13 1 13 1 15 1 15 1 + 13 0 15 0 15 1 13 1 + 13 1 15 1 15 0 13 0 + 14 0 14 0 0 0 0 0 + 14 0 14 0 0 1 0 1 + 14 1 14 1 0 0 0 0 + 14 1 14 1 0 1 0 1 + 14 0 0 0 0 1 14 1 + 14 1 0 1 0 0 14 0 + 14 0 14 0 1 0 1 0 + 14 0 14 0 1 1 1 1 + 14 1 14 1 1 0 1 0 + 14 1 14 1 1 1 1 1 + 14 0 1 0 1 1 14 1 + 14 1 1 1 1 0 14 0 + 14 0 14 0 2 0 2 0 + 14 0 14 0 2 1 2 1 + 14 1 14 1 2 0 2 0 + 14 1 14 1 2 1 2 1 + 14 0 2 0 2 1 14 1 + 14 1 2 1 2 0 14 0 + 14 0 14 0 3 0 3 0 + 14 0 14 0 3 1 3 1 + 14 1 14 1 3 0 3 0 + 14 1 14 1 3 1 3 1 + 14 0 3 0 3 1 14 1 + 14 1 3 1 3 0 14 0 + 14 0 14 0 4 0 4 0 + 14 0 14 0 4 1 4 1 + 14 1 14 1 4 0 4 0 + 14 1 14 1 4 1 4 1 + 14 0 4 0 4 1 14 1 + 14 1 4 1 4 0 14 0 + 14 0 14 0 5 0 5 0 + 14 0 14 0 5 1 5 1 + 14 1 14 1 5 0 5 0 + 14 1 14 1 5 1 5 1 + 14 0 5 0 5 1 14 1 + 14 1 5 1 5 0 14 0 + 14 0 14 0 6 0 6 0 + 14 0 14 0 6 1 6 1 + 14 1 14 1 6 0 6 0 + 14 1 14 1 6 1 6 1 + 14 0 6 0 6 1 14 1 + 14 1 6 1 6 0 14 0 + 14 0 14 0 7 0 7 0 + 14 0 14 0 7 1 7 1 + 14 1 14 1 7 0 7 0 + 14 1 14 1 7 1 7 1 + 14 0 7 0 7 1 14 1 + 14 1 7 1 7 0 14 0 + 14 0 14 0 8 0 8 0 + 14 0 14 0 8 1 8 1 + 14 1 14 1 8 0 8 0 + 14 1 14 1 8 1 8 1 + 14 0 8 0 8 1 14 1 + 14 1 8 1 8 0 14 0 + 14 0 14 0 9 0 9 0 + 14 0 14 0 9 1 9 1 + 14 1 14 1 9 0 9 0 + 14 1 14 1 9 1 9 1 + 14 0 9 0 9 1 14 1 + 14 1 9 1 9 0 14 0 + 14 0 14 0 10 0 10 0 + 14 0 14 0 10 1 10 1 + 14 1 14 1 10 0 10 0 + 14 1 14 1 10 1 10 1 + 14 0 10 0 10 1 14 1 + 14 1 10 1 10 0 14 0 + 14 0 14 0 11 0 11 0 + 14 0 14 0 11 1 11 1 + 14 1 14 1 11 0 11 0 + 14 1 14 1 11 1 11 1 + 14 0 11 0 11 1 14 1 + 14 1 11 1 11 0 14 0 + 14 0 14 0 12 0 12 0 + 14 0 14 0 12 1 12 1 + 14 1 14 1 12 0 12 0 + 14 1 14 1 12 1 12 1 + 14 0 12 0 12 1 14 1 + 14 1 12 1 12 0 14 0 + 14 0 14 0 13 0 13 0 + 14 0 14 0 13 1 13 1 + 14 1 14 1 13 0 13 0 + 14 1 14 1 13 1 13 1 + 14 0 13 0 13 1 14 1 + 14 1 13 1 13 0 14 0 + 14 0 14 0 14 0 14 0 + 14 0 14 0 14 1 14 1 + 14 1 14 1 14 0 14 0 + 14 1 14 1 14 1 14 1 + 14 0 14 0 14 1 14 1 + 14 1 14 1 14 0 14 0 + 14 0 14 0 15 0 15 0 + 14 0 14 0 15 1 15 1 + 14 1 14 1 15 0 15 0 + 14 1 14 1 15 1 15 1 + 14 0 15 0 15 1 14 1 + 14 1 15 1 15 0 14 0 + 15 0 15 0 0 0 0 0 + 15 0 15 0 0 1 0 1 + 15 1 15 1 0 0 0 0 + 15 1 15 1 0 1 0 1 + 15 0 0 0 0 1 15 1 + 15 1 0 1 0 0 15 0 + 15 0 15 0 1 0 1 0 + 15 0 15 0 1 1 1 1 + 15 1 15 1 1 0 1 0 + 15 1 15 1 1 1 1 1 + 15 0 1 0 1 1 15 1 + 15 1 1 1 1 0 15 0 + 15 0 15 0 2 0 2 0 + 15 0 15 0 2 1 2 1 + 15 1 15 1 2 0 2 0 + 15 1 15 1 2 1 2 1 + 15 0 2 0 2 1 15 1 + 15 1 2 1 2 0 15 0 + 15 0 15 0 3 0 3 0 + 15 0 15 0 3 1 3 1 + 15 1 15 1 3 0 3 0 + 15 1 15 1 3 1 3 1 + 15 0 3 0 3 1 15 1 + 15 1 3 1 3 0 15 0 + 15 0 15 0 4 0 4 0 + 15 0 15 0 4 1 4 1 + 15 1 15 1 4 0 4 0 + 15 1 15 1 4 1 4 1 + 15 0 4 0 4 1 15 1 + 15 1 4 1 4 0 15 0 + 15 0 15 0 5 0 5 0 + 15 0 15 0 5 1 5 1 + 15 1 15 1 5 0 5 0 + 15 1 15 1 5 1 5 1 + 15 0 5 0 5 1 15 1 + 15 1 5 1 5 0 15 0 + 15 0 15 0 6 0 6 0 + 15 0 15 0 6 1 6 1 + 15 1 15 1 6 0 6 0 + 15 1 15 1 6 1 6 1 + 15 0 6 0 6 1 15 1 + 15 1 6 1 6 0 15 0 + 15 0 15 0 7 0 7 0 + 15 0 15 0 7 1 7 1 + 15 1 15 1 7 0 7 0 + 15 1 15 1 7 1 7 1 + 15 0 7 0 7 1 15 1 + 15 1 7 1 7 0 15 0 + 15 0 15 0 8 0 8 0 + 15 0 15 0 8 1 8 1 + 15 1 15 1 8 0 8 0 + 15 1 15 1 8 1 8 1 + 15 0 8 0 8 1 15 1 + 15 1 8 1 8 0 15 0 + 15 0 15 0 9 0 9 0 + 15 0 15 0 9 1 9 1 + 15 1 15 1 9 0 9 0 + 15 1 15 1 9 1 9 1 + 15 0 9 0 9 1 15 1 + 15 1 9 1 9 0 15 0 + 15 0 15 0 10 0 10 0 + 15 0 15 0 10 1 10 1 + 15 1 15 1 10 0 10 0 + 15 1 15 1 10 1 10 1 + 15 0 10 0 10 1 15 1 + 15 1 10 1 10 0 15 0 + 15 0 15 0 11 0 11 0 + 15 0 15 0 11 1 11 1 + 15 1 15 1 11 0 11 0 + 15 1 15 1 11 1 11 1 + 15 0 11 0 11 1 15 1 + 15 1 11 1 11 0 15 0 + 15 0 15 0 12 0 12 0 + 15 0 15 0 12 1 12 1 + 15 1 15 1 12 0 12 0 + 15 1 15 1 12 1 12 1 + 15 0 12 0 12 1 15 1 + 15 1 12 1 12 0 15 0 + 15 0 15 0 13 0 13 0 + 15 0 15 0 13 1 13 1 + 15 1 15 1 13 0 13 0 + 15 1 15 1 13 1 13 1 + 15 0 13 0 13 1 15 1 + 15 1 13 1 13 0 15 0 + 15 0 15 0 14 0 14 0 + 15 0 15 0 14 1 14 1 + 15 1 15 1 14 0 14 0 + 15 1 15 1 14 1 14 1 + 15 0 14 0 14 1 15 1 + 15 1 14 1 14 0 15 0 + 15 0 15 0 15 0 15 0 + 15 0 15 0 15 1 15 1 + 15 1 15 1 15 0 15 0 + 15 1 15 1 15 1 15 1 + 15 0 15 0 15 1 15 1 + 15 1 15 1 15 0 15 0 diff --git a/samples/tutorial_2.2/hphi_Ene b/samples/tutorial_2.2/hphi_Ene new file mode 100644 index 00000000..bf9b6042 --- /dev/null +++ b/samples/tutorial_2.2/hphi_Ene @@ -0,0 +1,10 @@ +State 0 + Energy -32.7335961543715115 + Doublon 2.8888338568160847 + Sz 0.0000000000000000 + +State 1 + Energy -31.5989509881486903 + Doublon 3.0938231226969819 + Sz 0.0000000000000000 + diff --git a/samples/tutorial_2.2/hphi_Result_1swave b/samples/tutorial_2.2/hphi_Result_1swave new file mode 100644 index 00000000..122b3e64 --- /dev/null +++ b/samples/tutorial_2.2/hphi_Result_1swave @@ -0,0 +1,6 @@ + 0.000000 0.184026 0.000000 0 + 1.000000 0.041498 0.000000 1 + 1.414214 0.018053 0.000000 2 + 2.000000 0.018053 0.000000 4 + 2.236068 0.019450 0.000000 5 + 2.828427 0.045197 0.000000 8 diff --git a/samples/tutorial_2.2/input.toml b/samples/tutorial_2.2/input.toml new file mode 100644 index 00000000..8090f22d --- /dev/null +++ b/samples/tutorial_2.2/input.toml @@ -0,0 +1,13 @@ +[lattice] +Lx = 4 +Ly = 4 +Lz = 1 +orb_num = 1 +model_type = "Hubbard" +[mVMC] +sub_x = 2 +sub_y = 2 +sub_z = 1 +[mVMC_aft] +modpara = "modpara.def" +directory = "aft" diff --git a/samples/tutorial_2.2/job_ohtaka.sh b/samples/tutorial_2.2/job_ohtaka.sh new file mode 100644 index 00000000..0931872e --- /dev/null +++ b/samples/tutorial_2.2/job_ohtaka.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +#SBATCH -J TMTTF +#SBATCH -p i8cpu +#SBATCH --time=00:30:00 +#SBATCH -N 4 +#SBATCH -n 64 +#SBATCH -c 8 +#SBATCH -o log.%j +#SBATCH -e log.%j + +source /home/issp/materiapps/intel/mvmc/mvmcvars.sh +export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK} + +#[s] definitions of executions +MPI="srun " +VMC="vmc.out" #Pre-installed +VMCDRY="vmcdry.out" #Pre-installed +#[e] definitions of executions + +#python3 MakeInput.py input.toml +#[s] opt + ${VMCDRY} ./stan_opt.in + ${MPI} ${VMC} namelist.def + cp ./output/zqp_opt.dat . + mv output opt +#[e] opt + +#[s] aft + python3 SCGreen.py input.toml + ${VMCDRY} ./stan_aft.in + cp green1 greenone.def + cp SC_1swave greentwo.def + ${MPI} ${VMC} namelist.def ./zqp_opt.dat + mv output aft +#[e] aft + +#[s] post process + python3 VMClocal.py input.toml + python3 CalcSC.py input.toml +#[e] post process diff --git a/samples/tutorial_2.2/plot b/samples/tutorial_2.2/plot new file mode 100644 index 00000000..9f73b194 --- /dev/null +++ b/samples/tutorial_2.2/plot @@ -0,0 +1,7 @@ +set log y +set xlabel "distance" +set ylabel "1s-SC cor" +p \ +"Result_1swave.dat" u 1:2:3 w ye pt 6 ps 2 t "mVMC", \ +"hphi_Result_1swave" u 1:2:3 w lp t "exact diagonalizaqtion" +pause -1 diff --git a/samples/tutorial_2.2/qlms_lattice.py b/samples/tutorial_2.2/qlms_lattice.py new file mode 100644 index 00000000..89aa61cd --- /dev/null +++ b/samples/tutorial_2.2/qlms_lattice.py @@ -0,0 +1,44 @@ +def get_site(all_i,list_org): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + orb_num = list_org[3] + + orb = all_i%orb_num + site = (all_i-orb)/orb_num + x = site%Lx + tmp = (site-x)/Lx + y = tmp%Ly + z = (tmp-y)/Ly + list_site = [int(x),int(y),int(z),int(orb)] + return list_site + +def func_strans(list_trans,list_site,list_org): + x_j = int((list_site[0]+list_trans[0]+list_org[0])%list_org[0]) + y_j = int((list_site[1]+list_trans[1]+list_org[1])%list_org[1]) + z_j = int((list_site[2]+list_trans[2]+list_org[2])%list_org[2]) + all_j = list_trans[3]+(x_j+y_j*list_org[0]+z_j*list_org[0]*list_org[1])*list_org[3] + return all_j + +def func_strans_2D(list_trans,list_site,list_org): + x_j = int((list_site[0]+list_trans[0]+list_org[0])%list_org[0]) + y_j = int((list_site[1]+list_trans[1]+list_org[1])%list_org[1]) + all_j = list_trans[3]+(x_j+y_j*list_org[0])*list_org[3] + return all_j + +def get_site_Kondo(all_i,list_org): + Lx = list_org[0] + Ly = list_org[1] + Lz = list_org[2] + site_num = Lx*Ly*Lz + orb_num = list_org[3] + + site = all_i%site_num + orb = (all_i-site)/site_num + x = site%Lx + tmp = (site-x)/Lx + y = tmp%Ly + z = (tmp-y)/Ly + list_site = [int(x),int(y),int(z),int(orb)] + return list_site + diff --git a/samples/tutorial_2.2/run.sh b/samples/tutorial_2.2/run.sh new file mode 100644 index 00000000..0697209e --- /dev/null +++ b/samples/tutorial_2.2/run.sh @@ -0,0 +1,27 @@ +#[s] definitions of executions +MPI=" " +VMC="path2vmc.out" +VMCDRY="path2vmcdry.out" +#[e] definitions of executions + +#python3 MakeInput.py input.toml +#[s] opt + ${VMCDRY} ./stan_opt.in + ${MPI} ${VMC} namelist.def + cp ./output/zqp_opt.dat . + mv output opt +#[e] opt + +#[s] aft + python3 SCGreen.py input.toml + ${VMCDRY} ./stan_aft.in + cp green1 greenone.def + cp SC_1swave greentwo.def + ${MPI} ${VMC} namelist.def ./zqp_opt.dat + mv output aft +#[e] aft + +#[s] post process + python3 VMClocal.py input.toml + python3 CalcSC.py input.toml +#[e] post process diff --git a/samples/tutorial_2.2/stan_aft.in b/samples/tutorial_2.2/stan_aft.in new file mode 100644 index 00000000..6ee7b7fe --- /dev/null +++ b/samples/tutorial_2.2/stan_aft.in @@ -0,0 +1,17 @@ +W = 4 +Wsub = 2 +L = 4 +Lsub = 2 +lattice = "square" +model = "Hubbard" +t = 1.0 +U = -4.0 +ncond = 10 +2Sz = 0 +NVMCSample = 5000 +NSROptItrStep = 100 +NMPTrans = 1 +NSPStot = 0 +NVMCCalMode = 1 +NDataIdxStart = 0 +NDataQtySmp = 5 diff --git a/samples/tutorial_2.2/stan_opt.in b/samples/tutorial_2.2/stan_opt.in new file mode 100644 index 00000000..d349bdf0 --- /dev/null +++ b/samples/tutorial_2.2/stan_opt.in @@ -0,0 +1,14 @@ +W = 4 +Wsub = 2 +L = 4 +Lsub = 2 +lattice = "square" +model = "Hubbard" +t = 1.0 +U = -4.0 +ncond = 10 +2Sz = 0 +NVMCSample = 200 +NSROptItrStep = 600 +NMPTrans = 1 +NSPStot = 0 diff --git a/src/StdFace b/src/StdFace index c9e24dbe..92967761 160000 --- a/src/StdFace +++ b/src/StdFace @@ -1 +1 @@ -Subproject commit c9e24dbe8c200cd9f06cc2fd51ace8abd8ac08c0 +Subproject commit 92967761b56e6ddf69b1039102dbf0d09256242c diff --git a/src/common/blalink.hh b/src/common/blalink.hh new file mode 100644 index 00000000..2750c34c --- /dev/null +++ b/src/common/blalink.hh @@ -0,0 +1,518 @@ +/** + * \file blalink.hh + * C++ to C type wrapper for BLIS type-apis. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +#pragma once +#include +#include +typedef std::complex ccscmplx; +typedef std::complex ccdcmplx; +// BLIS definitions. +#include "blis.h" +// BLAS definitions +#include "blalink_fort.h" + +// error info +typedef enum { + Pfaffine_SIGN_ERR = 1, + Pfaffine_OUT_OF_BOUND, + Pfaffine_BAD_SCRATCHPAD, + Pfaffine_BAD_REPRESENTATION, + Pfaffine_INTEGER_OVERFLOW, + Pfaffine_DOUBLE_NAN_DETECTED, + Pfaffine_NOT_IMPLEMNTED, + Pfaffine_NUM_ERROR_TYPE +} skpfa_error_t; +inline signed err_info(signed type, signed pos) +{ return type * Pfaffine_NUM_ERROR_TYPE + pos; } + +// gemm +template +inline void gemm(trans_t transa, trans_t transb, + dim_t m, dim_t n, dim_t k, + T alpha, + T *a, inc_t lda, + T *b, inc_t ldb, + T beta, + T *c, inc_t ldc); +#ifndef BLAS_EXTERNAL +#define BLALINK_MAC(cctype, ctype, cchar) \ + template <> inline void gemm(trans_t transa, trans_t transb, \ + dim_t m, dim_t n, dim_t k, \ + cctype alpha, \ + cctype *a, inc_t lda, \ + cctype *b, inc_t ldb, \ + cctype beta, \ + cctype *c, inc_t ldc) \ + { \ + bli_##cchar##gemm(transa, transb, \ + m, n, k, \ + (ctype *)&alpha, \ + (ctype *)a, 1, lda, \ + (ctype *)b, 1, ldb, \ + (ctype *)&beta, \ + (ctype *)c, 1, ldc); \ + } +#else +#define BLALINK_MAC(cctype, ctype, cchar) \ + template <> inline void gemm(trans_t transa, trans_t transb, \ + dim_t m, dim_t n, dim_t k, \ + cctype alpha, \ + cctype *a, inc_t lda, \ + cctype *b, inc_t ldb, \ + cctype beta, \ + cctype *c, inc_t ldc) \ + { \ + char ta = trans2char(transa), \ + tb = trans2char(transb); \ + cchar##gemm_(&ta, &tb, &m, &n, &k, \ + (ctype *)&alpha, \ + (ctype *)a, &lda, \ + (ctype *)b, &ldb, \ + (ctype *)&beta, \ + (ctype *)c, &ldc); \ + } +#endif +BLALINK_MAC( float, float, s ) +BLALINK_MAC( double, double, d ) +BLALINK_MAC( ccscmplx, scomplex, c ) +BLALINK_MAC( ccdcmplx, dcomplex, z ) +#undef BLALINK_MAC + + +// ger +template +inline void ger(dim_t m, dim_t n, + T alpha, + T *x, inc_t incx, + T *y, inc_t incy, + T *a, inc_t lda); +#ifndef BLAS_EXTERNAL +#define BLALINK_MAC(cctype, ctype, cchar, cfunc) \ + template <> inline void ger(dim_t m, dim_t n, \ + cctype alpha, \ + cctype *x, inc_t incx, \ + cctype *y, inc_t incy, \ + cctype *a, inc_t lda) \ + { \ + bli_##cchar##ger(BLIS_NO_CONJUGATE, \ + BLIS_NO_CONJUGATE, \ + m, n, \ + (ctype *)&alpha, \ + (ctype *)x, incx, \ + (ctype *)y, incy, \ + (ctype *)a, 1, lda); \ + } +#else +#define BLALINK_MAC(cctype, ctype, cchar, cfunc) \ + template <> inline void ger(dim_t m, dim_t n, \ + cctype alpha, \ + cctype *x, inc_t incx, \ + cctype *y, inc_t incy, \ + cctype *a, inc_t lda) \ + { \ + cchar##cfunc##_(&m, &n, \ + (ctype *)&alpha, \ + (ctype *)x, &incx, \ + (ctype *)y, &incy, \ + (ctype *)a, &lda); \ + } +#endif +BLALINK_MAC( float, float, s, ger ) +BLALINK_MAC( double, double, d, ger ) +BLALINK_MAC( ccscmplx, scomplex, c, geru ) +BLALINK_MAC( ccdcmplx, dcomplex, z, geru ) +#undef BLALINK_MAC + + +// gemv +template +inline void gemv(trans_t trans, + dim_t m, dim_t n, + T alpha, + T *a, inc_t lda, + T *x, inc_t incx, + T beta, + T *y, inc_t incy); +#ifndef BLAS_EXTERNAL +#define BLALINK_MAC(cctype, ctype, cchar) \ + template <> inline void gemv(trans_t trans, \ + dim_t m, dim_t n, \ + cctype alpha, \ + cctype *a, inc_t lda, \ + cctype *x, inc_t incx, \ + cctype beta, \ + cctype *y, inc_t incy) \ + { \ + bli_##cchar##gemv(trans, \ + BLIS_NO_CONJUGATE, \ + m, n, \ + (ctype *)&alpha, \ + (ctype *)a, 1, lda, \ + (ctype *)x, incx, \ + (ctype *)&beta, \ + (ctype *)y, incy); \ + } +#else +#define BLALINK_MAC(cctype, ctype, cchar) \ + template <> inline void gemv(trans_t trans, \ + dim_t m, dim_t n, \ + cctype alpha, \ + cctype *a, inc_t lda, \ + cctype *x, inc_t incx, \ + cctype beta, \ + cctype *y, inc_t incy) \ + { \ + char t = trans2char(trans); \ + cchar##gemv_(&t, &m, &n, \ + (ctype *)&alpha, \ + (ctype *)a, &lda, \ + (ctype *)x, &incx, \ + (ctype *)&beta, \ + (ctype *)y, &incy); \ + } +#endif +BLALINK_MAC( float, float, s ) +BLALINK_MAC( double, double, d ) +BLALINK_MAC( ccscmplx, scomplex, c ) +BLALINK_MAC( ccdcmplx, dcomplex, z ) +#undef BLALINK_MAC + + +// trmm +template +inline void trmm(side_t sidea, + uplo_t uploa, + trans_t transa, + diag_t diaga, + dim_t m, dim_t n, + T alpha, + T *a, inc_t lda, + T *b, inc_t ldb); +#ifndef BLAS_EXTERNAL +#define BLALINK_MAC(cctype, ctype, cchar) \ + template <> inline void trmm(side_t sidea, uplo_t uploa, trans_t transa, diag_t diaga, \ + dim_t m, dim_t n, \ + cctype alpha, \ + cctype *a, inc_t lda, \ + cctype *b, inc_t ldb) \ + { \ + bli_##cchar##trmm(sidea, uploa, transa, diaga, \ + m, n, \ + (ctype *)&alpha, \ + (ctype *)a, 1, lda, \ + (ctype *)b, 1, ldb); \ + } +#else +#define BLALINK_MAC(cctype, ctype, cchar) \ + template <> inline void trmm(side_t sidea, uplo_t uploa, trans_t transa, diag_t diaga, \ + dim_t m, dim_t n, \ + cctype alpha, \ + cctype *a, inc_t lda, \ + cctype *b, inc_t ldb) \ + { \ + char ul = uplo2char(uploa), \ + si = side2char(sidea), \ + tr = trans2char(transa), \ + dg = diag2char(diaga); \ + cchar##trmm_(&si, &ul, &tr, &dg, \ + &m, &n, \ + (ctype *)&alpha, \ + (ctype *)a, &lda, \ + (ctype *)b, &ldb); \ + } +#endif +BLALINK_MAC( float, float, s ) +BLALINK_MAC( double, double, d ) +BLALINK_MAC( ccscmplx, scomplex, c ) +BLALINK_MAC( ccdcmplx, dcomplex, z ) +#undef BLALINK_MAC + + +// trmv +template +inline void trmv(uplo_t uploa, + trans_t transa, + dim_t m, + T alpha, + T *a, inc_t lda, + T *x, inc_t incx); +#ifndef BLAS_EXTERNAL +#define BLALINK_MAC(cctype, ctype, cchar) \ + template <> inline void trmv(uplo_t uploa, trans_t transa, dim_t m, \ + cctype alpha, \ + cctype *a, inc_t lda, \ + cctype *x, inc_t incx) \ + { \ + bli_##cchar##trmv(uploa, transa, \ + BLIS_NONUNIT_DIAG, m, \ + (ctype *)&alpha, \ + (ctype *)a, 1, lda, \ + (ctype *)x, incx); \ + } +#else +#define BLALINK_MAC(cctype, ctype, cchar) \ + template <> inline void trmv(uplo_t uploa, trans_t transa, dim_t m, \ + cctype alpha, \ + cctype *a, inc_t lda, \ + cctype *x, inc_t incx) \ + { \ + char ul = uplo2char(uploa), \ + tr = trans2char(transa), \ + dg = 'N'; \ + /* + * TRMV has alpha in its templated interface, which is absent in BLAS. + */ \ + assert(alpha == cctype(1.0)); \ + cchar##trmv_(&ul, &tr, &dg, &m, \ + (ctype *)a, &lda, \ + (ctype *)x, &incx); \ + } +#endif +BLALINK_MAC( float, float, s ) +BLALINK_MAC( double, double, d ) +BLALINK_MAC( ccscmplx, scomplex, c ) +BLALINK_MAC( ccdcmplx, dcomplex, z ) +#undef BLALINK_MAC + + +// swap +template +inline void swap(dim_t n, + T *x, inc_t incx, + T *y, inc_t incy); +#ifndef BLAS_EXTERNAL +#define BLALINK_MAC(cctype, ctype, cchar) \ + template <> inline void swap(dim_t n, \ + cctype *x, inc_t incx, \ + cctype *y, inc_t incy) \ + { \ + bli_##cchar##swapv(n, \ + (ctype *)x, incx, \ + (ctype *)y, incy); \ + } +#else +#define BLALINK_MAC(cctype, ctype, cchar) \ + template <> inline void swap(dim_t n, \ + cctype *x, inc_t incx, \ + cctype *y, inc_t incy) \ + { \ + cchar##swap_(&n, \ + (ctype *)x, &incx, \ + (ctype *)y, &incy); \ + } +#endif +BLALINK_MAC( float, float, s ) +BLALINK_MAC( double, double, d ) +BLALINK_MAC( ccscmplx, scomplex, c ) +BLALINK_MAC( ccdcmplx, dcomplex, z ) +#undef BLALINK_MAC + + +// axpy +template +inline void axpy(dim_t n, + T alpha, + T *x, inc_t incx, + T *y, inc_t incy); +#ifndef BLAS_EXTERNAL +#define BLALINK_MAC(cctype, ctype, cchar) \ + template <> inline void axpy(dim_t n, \ + cctype alpha, \ + cctype *x, inc_t incx, \ + cctype *y, inc_t incy) \ + { \ + bli_##cchar##axpyv(BLIS_NO_CONJUGATE, n, \ + (ctype *)&alpha, \ + (ctype *)x, incx, \ + (ctype *)y, incy); \ + } +#else +#define BLALINK_MAC(cctype, ctype, cchar) \ + template <> inline void axpy(dim_t n, \ + cctype alpha, \ + cctype *x, inc_t incx, \ + cctype *y, inc_t incy) \ + { \ + cchar##axpy_(&n, \ + (ctype *)&alpha, \ + (ctype *)x, &incx, \ + (ctype *)y, &incy); \ + } +#endif +BLALINK_MAC( float, float, s ) +BLALINK_MAC( double, double, d ) +BLALINK_MAC( ccscmplx, scomplex, c ) +BLALINK_MAC( ccdcmplx, dcomplex, z ) +#undef BLALINK_MAC + +// dot +template +inline T dot(dim_t n, + T *sx, inc_t incx, + T *sy, inc_t incy); +#ifndef BLAS_EXTERNAL +#define BLALINK_MAC(cctype, ctype, cchar, cfunc) \ + template <> inline cctype dot(dim_t n, \ + cctype *sx, inc_t incx, \ + cctype *sy, inc_t incy) \ + { \ + cctype rho; \ + bli_##cchar##dotv(BLIS_NO_CONJUGATE, \ + BLIS_NO_CONJUGATE, \ + n, \ + (ctype *)sx, incx, \ + (ctype *)sy, incy, \ + (ctype *)&rho); \ + return rho; \ + } +#else +#define BLALINK_MAC(cctype, ctype, cchar, cfunc) \ + template <> inline cctype dot(dim_t n, \ + cctype *sx, inc_t incx, \ + cctype *sy, inc_t incy) \ + { \ + ctype rho = cchar##cfunc##_(&n, \ + (ctype *)sx, &incx, \ + (ctype *)sy, &incy); \ + return *((cctype *)&rho); \ + } +#endif +BLALINK_MAC( float, float, s, dot ) +BLALINK_MAC( double, double, d, dot ) +#if defined(BLAS_EXTERNAL) && defined(F77_COMPLEX_RET_INTEL) +// Intel style complex return. +#undef BLALINK_MAC +#define BLALINK_MAC(cctype, ctype, cchar, cfunc) \ + template <> inline cctype dot(dim_t n, \ + cctype *sx, inc_t incx, \ + cctype *sy, inc_t incy) \ + { \ + cctype rho; \ + cchar##cfunc##_((ctype *)&rho, &n, \ + (ctype *)sx, &incx, \ + (ctype *)sy, &incy); \ + return rho; \ + } +#endif +BLALINK_MAC( ccscmplx, scomplex, c, dotu ) +BLALINK_MAC( ccdcmplx, dcomplex, z, dotu ) +#undef BLALINK_MAC + + + +// [LAPACK] lacpy +template +inline void lacpy(uplo_t uploa, + dim_t m, dim_t n, + T *a, inc_t lda, + T *b, inc_t ldb); +#define BLALINK_MAC(cctype, ctype, cchar) \ + template <> inline void lacpy(uplo_t uploa, \ + dim_t m, dim_t n, \ + cctype *a, inc_t lda, \ + cctype *b, inc_t ldb) \ + { \ + char ul = uplo2char(uploa); \ + cchar##lacpy_(&ul, &m, &n, a, &lda, b, &ldb); \ + } +BLALINK_MAC( float, float, s ) +BLALINK_MAC( double, double, d ) +BLALINK_MAC( ccscmplx, scomplex, c ) +BLALINK_MAC( ccdcmplx, dcomplex, z ) +#undef BLALINK_MAC + +// [LAPACK] trtri +template +inline int trtri(uplo_t uploa, + diag_t diaga, + dim_t n, + T *a, inc_t lda); +#define BLALINK_MAC(cctype, ctype, cchar) \ + template <> inline int trtri(uplo_t uploa, \ + diag_t diaga, \ + dim_t n, \ + cctype *a, inc_t lda) \ + { \ + char ul = uplo2char(uploa); \ + char dg = diag2char(diaga); \ + int info; \ + cchar##trtri_(&ul, &dg, &n, a, &lda, &info); \ + return info; \ + } +BLALINK_MAC( float, float, s ) +BLALINK_MAC( double, double, d ) +BLALINK_MAC( ccscmplx, scomplex, c ) +BLALINK_MAC( ccdcmplx, dcomplex, z ) +#undef BLALINK_MAC + +// [PFAPACK] sktrf +template +inline int sktrf(uplo_t uploa, + dim_t n, + T *a, inc_t lda, + int *ipiv, + T *work, dim_t lwork); +#define BLALINK_MAC(cctype, ctype, cchar) \ + template <> inline int sktrf(uplo_t uploa, \ + dim_t n, \ + cctype *a, inc_t lda, \ + int *ipiv, \ + cctype *work, dim_t lwork) \ + { \ + char ul = uplo2char(uploa); \ + char mode = 'N'; \ + int info; \ + cchar##sktrf_(&ul, &mode, &n, a, &lda, ipiv, work, &lwork, &info); \ + return info; \ + } +BLALINK_MAC( float, float, s ) +BLALINK_MAC( double, double, d ) +BLALINK_MAC( ccscmplx, scomplex, c ) +BLALINK_MAC( ccdcmplx, dcomplex, z ) +#undef BLALINK_MAC + +// [PFAPACK] skpfa +template +inline int skpfa(uplo_t uploa, + dim_t n, + T *a, inc_t lda, + T *pfa, int *ipiv, + T *work, dim_t lwork); +#define BLALINK_MAC(cctype, ctype, cchar) \ + template <> inline int skpfa(uplo_t uploa, \ + dim_t n, \ + cctype *a, inc_t lda, \ + cctype *pfa, int *ipiv, \ + cctype *work, dim_t lwork) \ + { \ + char ul = uplo2char(uploa); \ + char mthd = 'P'; \ + int info; \ + cchar##skpfa_(&ul, &mthd, &n, a, &lda, pfa, ipiv, work, &lwork, &info); \ + return info; \ + } +BLALINK_MAC( float, float, s ) +BLALINK_MAC( double, double, d ) +#undef BLALINK_MAC +#define BLALINK_MAC(cctype, ctype, cchar) \ + template <> inline int skpfa(uplo_t uploa, \ + dim_t n, \ + cctype *a, inc_t lda, \ + cctype *pfa, int *ipiv, \ + cctype *work, dim_t lwork) \ + { \ + char ul = uplo2char(uploa); \ + char mthd = 'P'; \ + int info; \ + cchar##skpfa_(&ul, &mthd, &n, a, &lda, pfa, ipiv, work, &lwork, 0, &info); \ + return info; \ + } +BLALINK_MAC( ccscmplx, scomplex, c ) +BLALINK_MAC( ccdcmplx, dcomplex, z ) +#undef BLALINK_MAC + diff --git a/src/common/blalink_fort.h b/src/common/blalink_fort.h new file mode 100644 index 00000000..eb0b3a39 --- /dev/null +++ b/src/common/blalink_fort.h @@ -0,0 +1,184 @@ +/** + * \file blalink_fort.hh + * Wrapper for external BLAS. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +#pragma once +#include +#include "blis.h" + + +// converter from BLIS enum to BLAS char. +BLIS_INLINE char trans2char(trans_t t) +{ + switch (t) { + case BLIS_NO_TRANSPOSE: + return 'N'; + case BLIS_TRANSPOSE: + return 'T'; + case BLIS_CONJ_NO_TRANSPOSE: + return 'C'; + default: + abort(); + } +} +BLIS_INLINE char uplo2char(uplo_t t) +{ + switch (t) { + case BLIS_UPPER: + return 'U'; + case BLIS_LOWER: + return 'L'; + default: + abort(); + } +} +BLIS_INLINE char side2char(side_t t) +{ + switch (t) { + case BLIS_LEFT: + return 'L'; + case BLIS_RIGHT: + return 'R'; + default: + abort(); + } +} +BLIS_INLINE char diag2char(diag_t t) +{ + switch (t) { + case BLIS_UNIT_DIAG: + return 'U'; + case BLIS_NONUNIT_DIAG: + return 'N'; + } +} + + +#ifdef __cplusplus +extern "C" +{ +#endif + +// BLAS { +#ifdef BLAS_EXTERNAL + +// gemm +void sgemm_(char *transa, char *transb, dim_t *m, dim_t *n, dim_t *k, float *alpha, + float *a, dim_t *lda, float *b, dim_t *ldb, float *beta, float *c, dim_t *ldc); +void dgemm_(char *transa, char *transb, dim_t *m, dim_t *n, dim_t *k, double *alpha, + double *a, dim_t *lda, double *b, dim_t *ldb, double *beta, double *c, dim_t *ldc); +void cgemm_(char *transa, char *transb, dim_t *m, dim_t *n, dim_t *k, void *alpha, + void *a, dim_t *lda, void *b, dim_t *ldb, void *beta, void *c, dim_t *ldc); +void zgemm_(char *transa, char *transb, dim_t *m, dim_t *n, dim_t *k, void *alpha, + void *a, dim_t *lda, void *b, dim_t *ldb, void *beta, void *c, dim_t *ldc); + + +// ger +void sger_(dim_t *m, dim_t *n, float *alpha, + float *x, dim_t *incx, float *y, dim_t *incy, float *a, dim_t *lda); +void dger_(dim_t *m, dim_t *n, double *alpha, + double *x, dim_t *incx, double *y, dim_t *incy, double *a, dim_t *lda); +void cgeru_(dim_t *m, dim_t *n, void *alpha, + void *x, dim_t *incx, void *y, dim_t *incy, void *a, dim_t *lda); +void zgeru_(dim_t *m, dim_t *n, void *alpha, + void *x, dim_t *incx, void *y, dim_t *incy, void *a, dim_t *lda); + + +// gemv +void sgemv_(char *trans, dim_t *m, dim_t *n, float *alpha, float *a, dim_t *lda, + float *x, dim_t *incx, float *beta, float *y, dim_t *incy); +void dgemv_(char *trans, dim_t *m, dim_t *n, double *alpha, double *a, dim_t *lda, + double *x, dim_t *incx, double *beta, double *y, dim_t *incy); +void cgemv_(char *trans, dim_t *m, dim_t *n, void *alpha, void *a, dim_t *lda, + void *x, dim_t *incx, void *beta, void *y, dim_t *incy); +void zgemv_(char *trans, dim_t *m, dim_t *n, void *alpha, void *a, dim_t *lda, + void *x, dim_t *incx, void *beta, void *y, dim_t *incy); + + +// trmm +void strmm_(char *side, char *uplo, char *transa, char *diag, dim_t *m, dim_t *n, + float *alpha, float *a, inc_t *lda, float *b, inc_t *ldb); +void dtrmm_(char *side, char *uplo, char *transa, char *diag, dim_t *m, dim_t *n, + double *alpha, double *a, inc_t *lda, double *b, inc_t *ldb); +void ctrmm_(char *side, char *uplo, char *transa, char *diag, dim_t *m, dim_t *n, + void *alpha, void *a, inc_t *lda, void *b, inc_t *ldb); +void ztrmm_(char *side, char *uplo, char *transa, char *diag, dim_t *m, dim_t *n, + void *alpha, void *a, inc_t *lda, void *b, inc_t *ldb); + + +// trmv +void strmv_(char *uplo, char *transa, char *diag, dim_t *n, + float *a, inc_t *lda, float *b, inc_t *ldb); +void dtrmv_(char *uplo, char *transa, char *diag, dim_t *n, + double *a, inc_t *lda, double *b, inc_t *ldb); +void ctrmv_(char *uplo, char *transa, char *diag, dim_t *n, + void *a, inc_t *lda, void *b, inc_t *ldb); +void ztrmv_(char *uplo, char *transa, char *diag, dim_t *n, + void *a, inc_t *lda, void *b, inc_t *ldb); + +// swap +void sswap_(dim_t *n, float *sx, dim_t *incx, float *sy, dim_t *incy); +void dswap_(dim_t *n, double *sx, dim_t *incx, double *sy, dim_t *incy); +void cswap_(dim_t *n, void *sx, dim_t *incx, void *sy, dim_t *incy); +void zswap_(dim_t *n, void *sx, dim_t *incx, void *sy, dim_t *incy); + +// axpy +void saxpy_(dim_t *n, float *alpha, float *sx, dim_t *incx, float *sy, dim_t *incy); +void daxpy_(dim_t *n, double *alpha, double *sx, dim_t *incx, double *sy, dim_t *incy); +void caxpy_(dim_t *n, void *alpha, void *sx, dim_t *incx, void *sy, dim_t *incy); +void zaxpy_(dim_t *n, void *alpha, void *sx, dim_t *incx, void *sy, dim_t *incy); + +// dot +float sdot_(dim_t *n, float *sx, dim_t *incx, float *sy, dim_t *incy); +double ddot_(dim_t *n, double *sx, dim_t *incx, double *sy, dim_t *incy); +scomplex cdotc_(dim_t *n, void *sx, dim_t *incx, void *sy, dim_t *incy); +dcomplex zdotc_(dim_t *n, void *sx, dim_t *incx, void *sy, dim_t *incy); +#ifndef F77_COMPLEX_RET_INTEL +scomplex cdotu_(dim_t *n, void *sx, dim_t *incx, void *sy, dim_t *incy); +dcomplex zdotu_(dim_t *n, void *sx, dim_t *incx, void *sy, dim_t *incy); +#else +void cdotu_(scomplex *rho, dim_t *n, void *sx, dim_t *incx, void *sy, dim_t *incy); +void zdotu_(dcomplex *rho, dim_t *n, void *sx, dim_t *incx, void *sy, dim_t *incy); +#endif + +// } +#endif + +// LAPACK { + +// lacpy +void slacpy_(char *uplo, dim_t *m, dim_t *n, float *a, inc_t *lda, float *b, inc_t *ldb); +void dlacpy_(char *uplo, dim_t *m, dim_t *n, double *a, inc_t *lda, double *b, inc_t *ldb); +void clacpy_(char *uplo, dim_t *m, dim_t *n, void *a, inc_t *lda, void *b, inc_t *ldb); +void zlacpy_(char *uplo, dim_t *m, dim_t *n, void *a, inc_t *lda, void *b, inc_t *ldb); + +// trtri +void strtri_(char *uplo, char *diag, dim_t *n, float *a, inc_t *lda, int *info); +void dtrtri_(char *uplo, char *diag, dim_t *n, double *a, inc_t *lda, int *info); +void ctrtri_(char *uplo, char *diag, dim_t *n, void *a, inc_t *lda, int *info); +void ztrtri_(char *uplo, char *diag, dim_t *n, void *a, inc_t *lda, int *info); + +// } + +// PFAPACK77 { + +void ssktrf_(char *uplo, char *mode, dim_t *n, float *a, dim_t *lda, int *ipiv, float *work, dim_t *lwork, int *info); +void dsktrf_(char *uplo, char *mode, dim_t *n, double *a, dim_t *lda, int *ipiv, double *work, dim_t *lwork, int *info); +void csktrf_(char *uplo, char *mode, dim_t *n, void *a, dim_t *lda, int *ipiv, void *work, dim_t *lwork, int *info); +void zsktrf_(char *uplo, char *mode, dim_t *n, void *a, dim_t *lda, int *ipiv, void *work, dim_t *lwork, int *info); + +void sskpfa_(char *uplo, char *mthd, dim_t *n, float *a, dim_t *lda, float *pfa, int *ipiv, float *work, dim_t *lwork, int *info); +void dskpfa_(char *uplo, char *mthd, dim_t *n, double *a, dim_t *lda, double *pfa, int *ipiv, double *work, dim_t *lwork, int *info); +void cskpfa_(char *uplo, char *mthd, dim_t *n, void *a, dim_t *lda, void *pfa, int *ipiv, void *work, dim_t *lwork, void *rwork, int *info); +void zskpfa_(char *uplo, char *mthd, dim_t *n, void *a, dim_t *lda, void *pfa, int *ipiv, void *work, dim_t *lwork, void *rwork, int *info); + +// } + +#ifdef __cplusplus +} +#endif + diff --git a/src/common/colmaj.hh b/src/common/colmaj.hh new file mode 100644 index 00000000..d9a03c1e --- /dev/null +++ b/src/common/colmaj.hh @@ -0,0 +1,26 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +#pragma once + +template +struct colmaj +{ + T *dat; + int ld; + + colmaj() = delete; + colmaj(T *dat_, int ld_) + : dat(dat_), ld(ld_) { } + + T &operator()(int i, int j) + { + return dat[ i + j * ld ]; + } + T &operator()() + { + return dat[ 0 ]; + } +}; diff --git a/src/common/deps/blis.h b/src/common/deps/blis.h new file mode 100644 index 00000000..0627afe2 --- /dev/null +++ b/src/common/deps/blis.h @@ -0,0 +1,552 @@ +/* + * blis.h + This header is cut out from BLIS v0.8.0, + containing necessary type definitions & macros. + User can use this file to avert BLIS dependency + if their BLAS library vendors a GEMMT implementation. + Here begins 3-clause BSD-style license of BLIS: + + BLIS + An object-based framework for developing high-performance BLAS-like + libraries. + + Copyright (C) 2014, The University of Texas at Austin + Copyright (C) 2016, Hewlett Packard Enterprise Development LP + Copyright (C) 2020, Advanced Micro Devices, Inc. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name(s) of the copyright holder(s) nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#ifndef BLIS_H +#define BLIS_H + + +// Allow C++ users to include this header file in their source code. However, +// we make the extern "C" conditional on whether we're using a C++ compiler, +// since regular C compilers don't understand the extern "C" construct. +#ifdef __cplusplus +extern "C" { +#endif + +// NOTE: PLEASE DON'T CHANGE THE ORDER IN WHICH HEADERS ARE INCLUDED UNLESS +// YOU ARE SURE THAT IT DOESN'T BREAK INTER-HEADER MACRO DEPENDENCIES. + +#include // skipped +#include // skipped +#include // skipped +#include // skipped +#include // skipped +#include // skipped +#include // skipped +#include // skipped +#include // skipped + +// -- STATIC INLINE FUNCTIONS -------------------------------------------------- + +// C and C++ have different semantics for defining "inline" functions. In C, +// the keyword phrase "static inline" accomplishes this, though the "inline" +// is optional. In C++, the "inline" keyword is required and obviates "static" +// altogether. Why does this matter? While BLIS is compiled in C99, blis.h may +// be #included by a source file that is compiled with C++. +#ifdef __cplusplus + #define BLIS_INLINE inline +#else + //#define BLIS_INLINE static inline + #define BLIS_INLINE static +#endif + +// -- Common BLIS definitions -- + +// begin bli_type_defs.h + + +#ifndef BLIS_TYPE_DEFS_H +#define BLIS_TYPE_DEFS_H + + +// +// -- BLIS basic types --------------------------------------------------------- +// + +#ifdef __cplusplus + // For C++, include stdint.h. +#include // skipped +#elif __STDC_VERSION__ >= 199901L + // For C99 (or later), include stdint.h. +#include // skipped +#include // skipped +#else + // When stdint.h is not available, manually typedef the types we will use. + #ifdef _WIN32 + typedef __int32 int32_t; + typedef unsigned __int32 uint32_t; + typedef __int64 int64_t; + typedef unsigned __int64 uint64_t; + #else + #error "Attempting to compile on pre-C99 system without stdint.h." + #endif +#endif + +// -- General-purpose integers -- + +// If BLAS integers are 64 bits, mandate that BLIS integers also be 64 bits. +// NOTE: This cpp guard will only meaningfully change BLIS's behavior on +// systems where the BLIS integer size would have been automatically selected +// to be 32 bits, since explicit selection of 32 bits is prohibited at +// configure-time (and explicit or automatic selection of 64 bits is fine +// and would have had the same result). +#if BLIS_BLAS_INT_SIZE == 64 + #undef BLIS_INT_TYPE_SIZE + #define BLIS_INT_TYPE_SIZE 64 +#endif + +// Define integer types depending on what size integer was requested. +#if BLIS_INT_TYPE_SIZE == 32 +typedef int32_t gint_t; +typedef uint32_t guint_t; +#elif BLIS_INT_TYPE_SIZE == 64 +typedef int64_t gint_t; +typedef uint64_t guint_t; +#else +typedef signed long int gint_t; +typedef unsigned long int guint_t; +#endif + +// -- Boolean type -- + +// NOTE: bool_t is no longer used and has been replaced with C99's bool type. +//typedef bool bool_t; + +// BLIS uses TRUE and FALSE macro constants as possible boolean values, but we +// define these macros in terms of true and false, respectively, which are +// defined by C99 in stdbool.h. +#ifndef TRUE + #define TRUE true +#endif + +#ifndef FALSE + #define FALSE false +#endif + +// -- Special-purpose integers -- + +// This cpp guard provides a temporary hack to allow libflame +// interoperability with BLIS. +#ifndef _DEFINED_DIM_T +#define _DEFINED_DIM_T +typedef gint_t dim_t; // dimension type +#endif +typedef gint_t inc_t; // increment/stride type +typedef gint_t doff_t; // diagonal offset type +typedef guint_t siz_t; // byte size type +typedef uint32_t objbits_t; // object information bit field + +// -- Real types -- + +// Define the number of floating-point types supported, and the size of the +// largest type. +#define BLIS_NUM_FP_TYPES 4 +#define BLIS_MAX_TYPE_SIZE sizeof(dcomplex) + +// There are some places where we need to use sizeof() inside of a C +// preprocessor #if conditional, and so here we define the various sizes +// for those purposes. +#define BLIS_SIZEOF_S 4 // sizeof(float) +#define BLIS_SIZEOF_D 8 // sizeof(double) +#define BLIS_SIZEOF_C 8 // sizeof(scomplex) +#define BLIS_SIZEOF_Z 16 // sizeof(dcomplex) + +// -- Complex types -- + +#ifdef BLIS_ENABLE_C99_COMPLEX + + #if __STDC_VERSION__ >= 199901L +#include // skipped + + // Typedef official complex types to BLIS complex type names. + typedef float complex scomplex; + typedef double complex dcomplex; + #else + #error "Configuration requested C99 complex types, but C99 does not appear to be supported." + #endif + +#else // ifndef BLIS_ENABLE_C99_COMPLEX + + // This cpp guard provides a temporary hack to allow libflame + // interoperability with BLIS. + #ifndef _DEFINED_SCOMPLEX + #define _DEFINED_SCOMPLEX + typedef struct + { + float real; + float imag; + } scomplex; + #endif + + // This cpp guard provides a temporary hack to allow libflame + // interoperability with BLIS. + #ifndef _DEFINED_DCOMPLEX + #define _DEFINED_DCOMPLEX + typedef struct + { + double real; + double imag; + } dcomplex; + #endif + +#endif // BLIS_ENABLE_C99_COMPLEX + +// -- Atom type -- + +// Note: atom types are used to hold "bufferless" scalar object values. Note +// that it needs to be as large as the largest possible scalar value we might +// want to hold. Thus, for now, it is a dcomplex. +typedef dcomplex atom_t; + +// -- Fortran-77 types -- + +// Note: These types are typically only used by BLAS compatibility layer, but +// we must define them even when the compatibility layer isn't being built +// because they also occur in bli_slamch() and bli_dlamch(). + +// Define f77_int depending on what size of integer was requested. +#if BLIS_BLAS_INT_TYPE_SIZE == 32 +typedef int32_t f77_int; +#elif BLIS_BLAS_INT_TYPE_SIZE == 64 +typedef int64_t f77_int; +#else +typedef long int f77_int; +#endif + +typedef char f77_char; +typedef float f77_float; +typedef double f77_double; +typedef scomplex f77_scomplex; +typedef dcomplex f77_dcomplex; + +// -- Void function pointer types -- + +// Note: This type should be used in any situation where the address of a +// *function* will be conveyed or stored prior to it being typecast back +// to the correct function type. It does not need to be used when conveying +// or storing the address of *data* (such as an array of float or double). + +//typedef void (*void_fp)( void ); +typedef void* void_fp; + + +// +// -- BLIS info bit field offsets ---------------------------------------------- +// + + + +// info +#define BLIS_DATATYPE_SHIFT 0 +#define BLIS_DOMAIN_SHIFT 0 +#define BLIS_PRECISION_SHIFT 1 +#define BLIS_CONJTRANS_SHIFT 3 +#define BLIS_TRANS_SHIFT 3 +#define BLIS_CONJ_SHIFT 4 +#define BLIS_UPLO_SHIFT 5 +#define BLIS_UPPER_SHIFT 5 +#define BLIS_DIAG_SHIFT 6 +#define BLIS_LOWER_SHIFT 7 +#define BLIS_UNIT_DIAG_SHIFT 8 +#define BLIS_INVERT_DIAG_SHIFT 9 +#define BLIS_TARGET_DT_SHIFT 10 +#define BLIS_TARGET_DOMAIN_SHIFT 10 +#define BLIS_TARGET_PREC_SHIFT 11 +#define BLIS_EXEC_DT_SHIFT 13 +#define BLIS_EXEC_DOMAIN_SHIFT 13 +#define BLIS_EXEC_PREC_SHIFT 14 +#define BLIS_PACK_SCHEMA_SHIFT 16 +#define BLIS_PACK_RC_SHIFT 16 +#define BLIS_PACK_PANEL_SHIFT 17 +#define BLIS_PACK_FORMAT_SHIFT 18 +#define BLIS_PACK_SHIFT 22 +#define BLIS_PACK_REV_IF_UPPER_SHIFT 23 +#define BLIS_PACK_REV_IF_LOWER_SHIFT 24 +#define BLIS_PACK_BUFFER_SHIFT 25 +#define BLIS_STRUC_SHIFT 27 +#define BLIS_COMP_DT_SHIFT 29 +#define BLIS_COMP_DOMAIN_SHIFT 29 +#define BLIS_COMP_PREC_SHIFT 30 + +// info2 +#define BLIS_SCALAR_DT_SHIFT 0 +#define BLIS_SCALAR_DOMAIN_SHIFT 0 +#define BLIS_SCALAR_PREC_SHIFT 1 + +// +// -- BLIS info bit field masks ------------------------------------------------ +// + +// info +#define BLIS_DATATYPE_BITS ( 0x7 << BLIS_DATATYPE_SHIFT ) +#define BLIS_DOMAIN_BIT ( 0x1 << BLIS_DOMAIN_SHIFT ) +#define BLIS_PRECISION_BIT ( 0x1 << BLIS_PRECISION_SHIFT ) +#define BLIS_CONJTRANS_BITS ( 0x3 << BLIS_CONJTRANS_SHIFT ) +#define BLIS_TRANS_BIT ( 0x1 << BLIS_TRANS_SHIFT ) +#define BLIS_CONJ_BIT ( 0x1 << BLIS_CONJ_SHIFT ) +#define BLIS_UPLO_BITS ( 0x7 << BLIS_UPLO_SHIFT ) +#define BLIS_UPPER_BIT ( 0x1 << BLIS_UPPER_SHIFT ) +#define BLIS_DIAG_BIT ( 0x1 << BLIS_DIAG_SHIFT ) +#define BLIS_LOWER_BIT ( 0x1 << BLIS_LOWER_SHIFT ) +#define BLIS_UNIT_DIAG_BIT ( 0x1 << BLIS_UNIT_DIAG_SHIFT ) +#define BLIS_INVERT_DIAG_BIT ( 0x1 << BLIS_INVERT_DIAG_SHIFT ) +#define BLIS_TARGET_DT_BITS ( 0x7 << BLIS_TARGET_DT_SHIFT ) +#define BLIS_TARGET_DOMAIN_BIT ( 0x1 << BLIS_TARGET_DOMAIN_SHIFT ) +#define BLIS_TARGET_PREC_BIT ( 0x1 << BLIS_TARGET_PREC_SHIFT ) +#define BLIS_EXEC_DT_BITS ( 0x7 << BLIS_EXEC_DT_SHIFT ) +#define BLIS_EXEC_DOMAIN_BIT ( 0x1 << BLIS_EXEC_DOMAIN_SHIFT ) +#define BLIS_EXEC_PREC_BIT ( 0x1 << BLIS_EXEC_PREC_SHIFT ) +#define BLIS_PACK_SCHEMA_BITS ( 0x7F << BLIS_PACK_SCHEMA_SHIFT ) +#define BLIS_PACK_RC_BIT ( 0x1 << BLIS_PACK_RC_SHIFT ) +#define BLIS_PACK_PANEL_BIT ( 0x1 << BLIS_PACK_PANEL_SHIFT ) +#define BLIS_PACK_FORMAT_BITS ( 0xF << BLIS_PACK_FORMAT_SHIFT ) +#define BLIS_PACK_BIT ( 0x1 << BLIS_PACK_SHIFT ) +#define BLIS_PACK_REV_IF_UPPER_BIT ( 0x1 << BLIS_PACK_REV_IF_UPPER_SHIFT ) +#define BLIS_PACK_REV_IF_LOWER_BIT ( 0x1 << BLIS_PACK_REV_IF_LOWER_SHIFT ) +#define BLIS_PACK_BUFFER_BITS ( 0x3 << BLIS_PACK_BUFFER_SHIFT ) +#define BLIS_STRUC_BITS ( 0x3 << BLIS_STRUC_SHIFT ) +#define BLIS_COMP_DT_BITS ( 0x7 << BLIS_COMP_DT_SHIFT ) +#define BLIS_COMP_DOMAIN_BIT ( 0x1 << BLIS_COMP_DOMAIN_SHIFT ) +#define BLIS_COMP_PREC_BIT ( 0x1 << BLIS_COMP_PREC_SHIFT ) + +// info2 +#define BLIS_SCALAR_DT_BITS ( 0x7 << BLIS_SCALAR_DT_SHIFT ) +#define BLIS_SCALAR_DOMAIN_BIT ( 0x1 << BLIS_SCALAR_DOMAIN_SHIFT ) +#define BLIS_SCALAR_PREC_BIT ( 0x1 << BLIS_SCALAR_PREC_SHIFT ) + + +// +// -- BLIS enumerated type value definitions ----------------------------------- +// + +#define BLIS_BITVAL_REAL 0x0 +#define BLIS_BITVAL_COMPLEX BLIS_DOMAIN_BIT +#define BLIS_BITVAL_SINGLE_PREC 0x0 +#define BLIS_BITVAL_DOUBLE_PREC BLIS_PRECISION_BIT +#define BLIS_BITVAL_FLOAT_TYPE 0x0 +#define BLIS_BITVAL_SCOMPLEX_TYPE BLIS_DOMAIN_BIT +#define BLIS_BITVAL_DOUBLE_TYPE BLIS_PRECISION_BIT +#define BLIS_BITVAL_DCOMPLEX_TYPE ( BLIS_DOMAIN_BIT | BLIS_PRECISION_BIT ) +#define BLIS_BITVAL_INT_TYPE 0x04 +#define BLIS_BITVAL_CONST_TYPE 0x05 +#define BLIS_BITVAL_NO_TRANS 0x0 +#define BLIS_BITVAL_TRANS BLIS_TRANS_BIT +#define BLIS_BITVAL_NO_CONJ 0x0 +#define BLIS_BITVAL_CONJ BLIS_CONJ_BIT +#define BLIS_BITVAL_CONJ_TRANS ( BLIS_CONJ_BIT | BLIS_TRANS_BIT ) +#define BLIS_BITVAL_ZEROS 0x0 +#define BLIS_BITVAL_UPPER ( BLIS_UPPER_BIT | BLIS_DIAG_BIT ) +#define BLIS_BITVAL_LOWER ( BLIS_LOWER_BIT | BLIS_DIAG_BIT ) +#define BLIS_BITVAL_DENSE BLIS_UPLO_BITS +#define BLIS_BITVAL_NONUNIT_DIAG 0x0 +#define BLIS_BITVAL_UNIT_DIAG BLIS_UNIT_DIAG_BIT +#define BLIS_BITVAL_INVERT_DIAG BLIS_INVERT_DIAG_BIT +#define BLIS_BITVAL_NOT_PACKED 0x0 +#define BLIS_BITVAL_4MI ( 0x1 << BLIS_PACK_FORMAT_SHIFT ) +#define BLIS_BITVAL_3MI ( 0x2 << BLIS_PACK_FORMAT_SHIFT ) +#define BLIS_BITVAL_4MS ( 0x3 << BLIS_PACK_FORMAT_SHIFT ) +#define BLIS_BITVAL_3MS ( 0x4 << BLIS_PACK_FORMAT_SHIFT ) +#define BLIS_BITVAL_RO ( 0x5 << BLIS_PACK_FORMAT_SHIFT ) +#define BLIS_BITVAL_IO ( 0x6 << BLIS_PACK_FORMAT_SHIFT ) +#define BLIS_BITVAL_RPI ( 0x7 << BLIS_PACK_FORMAT_SHIFT ) +#define BLIS_BITVAL_1E ( 0x8 << BLIS_PACK_FORMAT_SHIFT ) +#define BLIS_BITVAL_1R ( 0x9 << BLIS_PACK_FORMAT_SHIFT ) +#define BLIS_BITVAL_PACKED_UNSPEC ( BLIS_PACK_BIT ) +#define BLIS_BITVAL_PACKED_ROWS ( BLIS_PACK_BIT ) +#define BLIS_BITVAL_PACKED_COLUMNS ( BLIS_PACK_BIT | BLIS_PACK_RC_BIT ) +#define BLIS_BITVAL_PACKED_ROW_PANELS ( BLIS_PACK_BIT | BLIS_PACK_PANEL_BIT ) +#define BLIS_BITVAL_PACKED_COL_PANELS ( BLIS_PACK_BIT | BLIS_PACK_PANEL_BIT | BLIS_PACK_RC_BIT ) +#define BLIS_BITVAL_PACKED_ROW_PANELS_4MI ( BLIS_PACK_BIT | BLIS_BITVAL_4MI | BLIS_PACK_PANEL_BIT ) +#define BLIS_BITVAL_PACKED_COL_PANELS_4MI ( BLIS_PACK_BIT | BLIS_BITVAL_4MI | BLIS_PACK_PANEL_BIT | BLIS_PACK_RC_BIT ) +#define BLIS_BITVAL_PACKED_ROW_PANELS_3MI ( BLIS_PACK_BIT | BLIS_BITVAL_3MI | BLIS_PACK_PANEL_BIT ) +#define BLIS_BITVAL_PACKED_COL_PANELS_3MI ( BLIS_PACK_BIT | BLIS_BITVAL_3MI | BLIS_PACK_PANEL_BIT | BLIS_PACK_RC_BIT ) +#define BLIS_BITVAL_PACKED_ROW_PANELS_4MS ( BLIS_PACK_BIT | BLIS_BITVAL_4MS | BLIS_PACK_PANEL_BIT ) +#define BLIS_BITVAL_PACKED_COL_PANELS_4MS ( BLIS_PACK_BIT | BLIS_BITVAL_4MS | BLIS_PACK_PANEL_BIT | BLIS_PACK_RC_BIT ) +#define BLIS_BITVAL_PACKED_ROW_PANELS_3MS ( BLIS_PACK_BIT | BLIS_BITVAL_3MS | BLIS_PACK_PANEL_BIT ) +#define BLIS_BITVAL_PACKED_COL_PANELS_3MS ( BLIS_PACK_BIT | BLIS_BITVAL_3MS | BLIS_PACK_PANEL_BIT | BLIS_PACK_RC_BIT ) +#define BLIS_BITVAL_PACKED_ROW_PANELS_RO ( BLIS_PACK_BIT | BLIS_BITVAL_RO | BLIS_PACK_PANEL_BIT ) +#define BLIS_BITVAL_PACKED_COL_PANELS_RO ( BLIS_PACK_BIT | BLIS_BITVAL_RO | BLIS_PACK_PANEL_BIT | BLIS_PACK_RC_BIT ) +#define BLIS_BITVAL_PACKED_ROW_PANELS_IO ( BLIS_PACK_BIT | BLIS_BITVAL_IO | BLIS_PACK_PANEL_BIT ) +#define BLIS_BITVAL_PACKED_COL_PANELS_IO ( BLIS_PACK_BIT | BLIS_BITVAL_IO | BLIS_PACK_PANEL_BIT | BLIS_PACK_RC_BIT ) +#define BLIS_BITVAL_PACKED_ROW_PANELS_RPI ( BLIS_PACK_BIT | BLIS_BITVAL_RPI | BLIS_PACK_PANEL_BIT ) +#define BLIS_BITVAL_PACKED_COL_PANELS_RPI ( BLIS_PACK_BIT | BLIS_BITVAL_RPI | BLIS_PACK_PANEL_BIT | BLIS_PACK_RC_BIT ) +#define BLIS_BITVAL_PACKED_ROW_PANELS_1E ( BLIS_PACK_BIT | BLIS_BITVAL_1E | BLIS_PACK_PANEL_BIT ) +#define BLIS_BITVAL_PACKED_COL_PANELS_1E ( BLIS_PACK_BIT | BLIS_BITVAL_1E | BLIS_PACK_PANEL_BIT | BLIS_PACK_RC_BIT ) +#define BLIS_BITVAL_PACKED_ROW_PANELS_1R ( BLIS_PACK_BIT | BLIS_BITVAL_1R | BLIS_PACK_PANEL_BIT ) +#define BLIS_BITVAL_PACKED_COL_PANELS_1R ( BLIS_PACK_BIT | BLIS_BITVAL_1R | BLIS_PACK_PANEL_BIT | BLIS_PACK_RC_BIT ) +#define BLIS_BITVAL_PACK_FWD_IF_UPPER 0x0 +#define BLIS_BITVAL_PACK_REV_IF_UPPER BLIS_PACK_REV_IF_UPPER_BIT +#define BLIS_BITVAL_PACK_FWD_IF_LOWER 0x0 +#define BLIS_BITVAL_PACK_REV_IF_LOWER BLIS_PACK_REV_IF_LOWER_BIT +#define BLIS_BITVAL_BUFFER_FOR_A_BLOCK 0x0 +#define BLIS_BITVAL_BUFFER_FOR_B_PANEL ( 0x1 << BLIS_PACK_BUFFER_SHIFT ) +#define BLIS_BITVAL_BUFFER_FOR_C_PANEL ( 0x2 << BLIS_PACK_BUFFER_SHIFT ) +#define BLIS_BITVAL_BUFFER_FOR_GEN_USE ( 0x3 << BLIS_PACK_BUFFER_SHIFT ) +#define BLIS_BITVAL_GENERAL 0x0 +#define BLIS_BITVAL_HERMITIAN ( 0x1 << BLIS_STRUC_SHIFT ) +#define BLIS_BITVAL_SYMMETRIC ( 0x2 << BLIS_STRUC_SHIFT ) +#define BLIS_BITVAL_TRIANGULAR ( 0x3 << BLIS_STRUC_SHIFT ) + + +// +// -- BLIS enumerated type definitions ----------------------------------------- +// + +// -- Operational parameter types -- + +typedef enum +{ + BLIS_NO_TRANSPOSE = 0x0, + BLIS_TRANSPOSE = BLIS_BITVAL_TRANS, + BLIS_CONJ_NO_TRANSPOSE = BLIS_BITVAL_CONJ, + BLIS_CONJ_TRANSPOSE = BLIS_BITVAL_CONJ_TRANS +} trans_t; + +typedef enum +{ + BLIS_NO_CONJUGATE = 0x0, + BLIS_CONJUGATE = BLIS_BITVAL_CONJ +} conj_t; + +typedef enum +{ + BLIS_ZEROS = BLIS_BITVAL_ZEROS, + BLIS_LOWER = BLIS_BITVAL_LOWER, + BLIS_UPPER = BLIS_BITVAL_UPPER, + BLIS_DENSE = BLIS_BITVAL_DENSE +} uplo_t; + +typedef enum +{ + BLIS_LEFT = 0x0, + BLIS_RIGHT +} side_t; + +typedef enum +{ + BLIS_NONUNIT_DIAG = 0x0, + BLIS_UNIT_DIAG = BLIS_BITVAL_UNIT_DIAG +} diag_t; + +typedef enum +{ + BLIS_NO_INVERT_DIAG = 0x0, + BLIS_INVERT_DIAG = BLIS_BITVAL_INVERT_DIAG +} invdiag_t; + +typedef enum +{ + BLIS_GENERAL = BLIS_BITVAL_GENERAL, + BLIS_HERMITIAN = BLIS_BITVAL_HERMITIAN, + BLIS_SYMMETRIC = BLIS_BITVAL_SYMMETRIC, + BLIS_TRIANGULAR = BLIS_BITVAL_TRIANGULAR +} struc_t; + + +// -- Data type -- + +typedef enum +{ + BLIS_FLOAT = BLIS_BITVAL_FLOAT_TYPE, + BLIS_DOUBLE = BLIS_BITVAL_DOUBLE_TYPE, + BLIS_SCOMPLEX = BLIS_BITVAL_SCOMPLEX_TYPE, + BLIS_DCOMPLEX = BLIS_BITVAL_DCOMPLEX_TYPE, + BLIS_INT = BLIS_BITVAL_INT_TYPE, + BLIS_CONSTANT = BLIS_BITVAL_CONST_TYPE, + BLIS_DT_LO = BLIS_FLOAT, + BLIS_DT_HI = BLIS_DCOMPLEX +} num_t; + +typedef enum +{ + BLIS_REAL = BLIS_BITVAL_REAL, + BLIS_COMPLEX = BLIS_BITVAL_COMPLEX +} dom_t; + +typedef enum +{ + BLIS_SINGLE_PREC = BLIS_BITVAL_SINGLE_PREC, + BLIS_DOUBLE_PREC = BLIS_BITVAL_DOUBLE_PREC +} prec_t; + +#endif +// end bli_type_defs.h + +// begin bli_param_map.h +BLIS_INLINE void bli_param_map_netlib_to_blis_side( char side, side_t* blis_side ) +{ + if ( side == 'l' || side == 'L' ) *blis_side = BLIS_LEFT; + else if ( side == 'r' || side == 'R' ) *blis_side = BLIS_RIGHT; + else + { + *blis_side = BLIS_LEFT; + } +} + +BLIS_INLINE void bli_param_map_netlib_to_blis_uplo( char uplo, uplo_t* blis_uplo ) +{ + if ( uplo == 'l' || uplo == 'L' ) *blis_uplo = BLIS_LOWER; + else if ( uplo == 'u' || uplo == 'U' ) *blis_uplo = BLIS_UPPER; + else + { + *blis_uplo = BLIS_LOWER; + } +} + +BLIS_INLINE void bli_param_map_netlib_to_blis_trans( char trans, trans_t* blis_trans ) +{ + if ( trans == 'n' || trans == 'N' ) *blis_trans = BLIS_NO_TRANSPOSE; + else if ( trans == 't' || trans == 'T' ) *blis_trans = BLIS_TRANSPOSE; + else if ( trans == 'c' || trans == 'C' ) *blis_trans = BLIS_CONJ_TRANSPOSE; + else + { + *blis_trans = BLIS_NO_TRANSPOSE; + } +} + +BLIS_INLINE void bli_param_map_netlib_to_blis_diag( char diag, diag_t* blis_diag ) +{ + if ( diag == 'n' || diag == 'N' ) *blis_diag = BLIS_NONUNIT_DIAG; + else if ( diag == 'u' || diag == 'U' ) *blis_diag = BLIS_UNIT_DIAG; + else + { + *blis_diag = BLIS_NONUNIT_DIAG; + } +} +// end bli_param_map.h + +// End extern "C" construct block. +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/ltl2inv/CMakeLists.txt b/src/ltl2inv/CMakeLists.txt new file mode 100644 index 00000000..88a55025 --- /dev/null +++ b/src/ltl2inv/CMakeLists.txt @@ -0,0 +1,16 @@ +# include guard +cmake_minimum_required(VERSION 2.8.0 ) + +if(${CMAKE_PROJECT_NAME} STREQUAL "Project") + message(FATAL_ERROR "cmake should be executed not for 'src' subdirectory, but for the top directory of mVMC.") +endif(${CMAKE_PROJECT_NAME} STREQUAL "Project") + +if("${ARCHITECTURE}" STREQUAL "x86_64") + add_definitions(-DF77_COMPLEX_RET_INTEL) +endif() +include_directories(../common) + +# TODO: Move blalink_gemmt.c to other subprojects? +add_library(ltl2inv STATIC ltl2inv.cc blalink_gemmt.c ilaenv_lauum.cc ilaenv_wrap.f90) +target_compile_definitions(ltl2inv PRIVATE -D_CC_IMPL) + diff --git a/src/ltl2inv/blalink_gemmt.c b/src/ltl2inv/blalink_gemmt.c new file mode 100644 index 00000000..fbaee562 --- /dev/null +++ b/src/ltl2inv/blalink_gemmt.c @@ -0,0 +1,42 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +#include "blis.h" +#include "blalink_fort.h" + +#if !( defined(BLAS_EXTERNAL) && defined(MKL) ) +// Redefine GEMMT Fortran from BLIS (which is built without BLAS API). +// Required by Pfapack77. +#define BLAGEN_MAC(cctype, ctype, cchar) \ + void cchar##gemmt_(const char *uplo_, \ + const char *transa_, \ + const char *transb_, \ + const int *m, const int *k, \ + const ctype *alpha, \ + const ctype *a, const int *lda, \ + const ctype *b, const int *ldb, \ + const ctype *beta, ctype *c, const int *ldc) \ + { \ + uplo_t uploc; \ + trans_t transa; \ + trans_t transb; \ + bli_param_map_netlib_to_blis_uplo(*uplo_, &uploc) ; \ + bli_param_map_netlib_to_blis_trans(*transa_, &transa) ; \ + bli_param_map_netlib_to_blis_trans(*transb_, &transb) ; \ + bli_##cchar##gemmt(uploc, \ + transa, transb, \ + *m, *k, \ + alpha, \ + a, 1, *lda, \ + b, 1, *ldb, \ + beta, \ + c, 1, *ldc); \ + } +BLAGEN_MAC( float, float, s ) +BLAGEN_MAC( double, double, d ) +BLAGEN_MAC( ccscmplx, scomplex, c ) +BLAGEN_MAC( ccdcmplx, dcomplex, z ) +#undef BLAGEN_MAC +#endif diff --git a/src/ltl2inv/blalink_gemmt.hh b/src/ltl2inv/blalink_gemmt.hh new file mode 100644 index 00000000..52bb2c45 --- /dev/null +++ b/src/ltl2inv/blalink_gemmt.hh @@ -0,0 +1,80 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +#pragma once +#include "blalink.hh" + + +// gemmt is not part of BLAS standard. +// It's currently know as exposed by BLIS and MKL. +template +inline void gemmt(uplo_t uploc, + trans_t transa, trans_t transb, + dim_t m, dim_t k, + T alpha, + T *a, inc_t lda, + T *b, inc_t ldb, + T beta, + T *c, inc_t ldc); +#if !( defined(BLAS_EXTERNAL) && defined(MKL) ) +#define BLALINK_MAC(cctype, ctype, cchar) \ + template <> inline void gemmt(uplo_t uploc, \ + trans_t transa, trans_t transb, \ + dim_t m, dim_t k, \ + cctype alpha, \ + cctype *a, inc_t lda, \ + cctype *b, inc_t ldb, \ + cctype beta, \ + cctype *c, inc_t ldc) \ + { \ + bli_##cchar##gemmt(uploc, \ + transa, transb, \ + m, k, \ + (ctype *)&alpha, \ + (ctype *)a, 1, lda, \ + (ctype *)b, 1, ldb, \ + (ctype *)&beta, \ + (ctype *)c, 1, ldc); \ + } +#else +#define BLALINK_MAC(cctype, ctype, cchar) \ + template <> inline void gemmt(uplo_t uploc, \ + trans_t transa, trans_t transb, \ + dim_t m, dim_t k, \ + cctype alpha, \ + cctype *a, inc_t lda, \ + cctype *b, inc_t ldb, \ + cctype beta, \ + cctype *c, inc_t ldc) \ + { \ + char ul = uplo2char(uploc); \ + char ta = trans2char(transa); \ + char tb = trans2char(transb); \ + cchar##gemmt_(&ul, \ + &ta, &tb, \ + &m, &k, \ + (ctype *)&alpha, \ + (ctype *)a, &lda, \ + (ctype *)b, &ldb, \ + (ctype *)&beta, \ + (ctype *)c, &ldc); \ + } +extern "C" { +void sgemmt_(char *uplo, char *transa, char *transb, dim_t *m, dim_t *k, float *alpha, + float *a, dim_t *lda, float *b, dim_t *ldb, float *beta, float *c, dim_t *ldc); +void dgemmt_(char *uplo, char *transa, char *transb, dim_t *m, dim_t *k, double *alpha, + double *a, dim_t *lda, double *b, dim_t *ldb, double *beta, double *c, dim_t *ldc); +void cgemmt_(char *uplo, char *transa, char *transb, dim_t *m, dim_t *k, void *alpha, + void *a, dim_t *lda, void *b, dim_t *ldb, void *beta, void *c, dim_t *ldc); +void zgemmt_(char *uplo, char *transa, char *transb, dim_t *m, dim_t *k, void *alpha, + void *a, dim_t *lda, void *b, dim_t *ldb, void *beta, void *c, dim_t *ldc); +} +#endif +BLALINK_MAC( float, float, s ) +BLALINK_MAC( double, double, d ) +BLALINK_MAC( ccscmplx, scomplex, c ) +BLALINK_MAC( ccdcmplx, dcomplex, z ) +#undef BLALINK_MAC + diff --git a/src/ltl2inv/ilaenv.h b/src/ltl2inv/ilaenv.h new file mode 100644 index 00000000..f4762491 --- /dev/null +++ b/src/ltl2inv/ilaenv.h @@ -0,0 +1,18 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +#pragma once +#ifdef __cplusplus +extern "C" { +#endif + +/* +int ilaenv_(const int *ispec, const char *name, const char *opts, const int *n1, const int *n2, const int *n3, const int *n4); +*/ +int ilaenv_wrap(int ispec, const char *name, const char *opts, int n1, int n2, int n3, int n4); + +#ifdef __cplusplus +} +#endif diff --git a/src/ltl2inv/ilaenv_lauum.cc b/src/ltl2inv/ilaenv_lauum.cc new file mode 100644 index 00000000..fa6beaff --- /dev/null +++ b/src/ltl2inv/ilaenv_lauum.cc @@ -0,0 +1,52 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +#include "blalink.hh" +#include "ilaenv.h" +#include "ilaenv_lauum.hh" + +/* + * sloppy version exploits that + * ILAENV(ispec=1, xLAUUM, "", dummy, dummy, dummy, dummy) + * returns 64 for x=S,D,C,Z . + */ + +#undef SLOPPY_ILAENV +// #define SLOPPY_ILAENV + +/* +#define EXPANDMAC(cctype, name) \ +template <> int ilaenv_lauum(uplo_t uplo, int n) \ +{ \ + char uplo_ = uplo2char(uplo); \ + int ispec = 1; \ + int dummy = 0; \ + return ilaenv_(&ispec, #name, &uplo_, &n, &dummy, &dummy, &dummy); \ +} +*/ + +#ifndef SLOPPY_ILAENV +#define EXPANDMAC(cctype, name) \ +template <> int ilaenv_lauum(uplo_t uplo, int n) \ +{ \ + char uplo_ = uplo2char(uplo); \ + int ispec = 1; \ + int dummy = -1; \ + return ilaenv_wrap(ispec, #name, &uplo_, n, dummy, dummy, dummy); \ +} +#else +#define EXPANDMAC(cctype, name) \ +template <> int ilaenv_lauum(uplo_t uplo, int n) \ +{ \ + return 64; \ +} +#endif + +EXPANDMAC( float, SLAUUM ) +EXPANDMAC( double, DLAUUM ) +EXPANDMAC( ccscmplx, CLAUUM ) +EXPANDMAC( ccdcmplx, ZLAUUM ) +#undef EXPANDMAC + diff --git a/src/ltl2inv/ilaenv_lauum.hh b/src/ltl2inv/ilaenv_lauum.hh new file mode 100644 index 00000000..68d89b57 --- /dev/null +++ b/src/ltl2inv/ilaenv_lauum.hh @@ -0,0 +1,11 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +#pragma once +#include "blalink.hh" + +template +int ilaenv_lauum(uplo_t uplo, int n); + diff --git a/src/ltl2inv/ilaenv_wrap.f90 b/src/ltl2inv/ilaenv_wrap.f90 new file mode 100644 index 00000000..f4e62167 --- /dev/null +++ b/src/ltl2inv/ilaenv_wrap.f90 @@ -0,0 +1,37 @@ +module wrapper + use, intrinsic :: iso_c_binding + implicit none +contains + function c_charptr_to_f_charptr(ccp) result(result) + type(c_ptr),intent(in),value :: ccp + character(:,c_char),pointer :: result + interface + function strlen(p) bind(c) + import c_ptr, c_size_t + type(c_ptr),value :: p + integer(c_size_t) strlen + end function strlen + end interface + result => convert_cptr(ccp,strlen(ccp)) + contains + function convert_cptr(p, len) + type(c_ptr),intent(in) :: p + integer(c_size_t),intent(in) :: len + character(len, c_char),pointer :: convert_cptr + call c_f_pointer(p, convert_cptr) + end function convert_cptr + end function c_charptr_to_f_charptr + + integer function ilaenv_wrap(ispec, name, opts, n1, n2, n3, n4) bind(c, name="ilaenv_wrap") + implicit none + integer,intent(in),value :: ispec, n1, n2, n3, n4 + type(c_ptr),intent(in),value :: name, opts + character(:,c_char),pointer :: namef, optsf + integer ilaenv + + namef => c_charptr_to_f_charptr(name) + optsf => c_charptr_to_f_charptr(opts) + + ilaenv_wrap = ILAENV(ispec, namef, optsf, n1, n2, n3, n4) + end function ilaenv_wrap +end module wrapper diff --git a/src/ltl2inv/invert.tcc b/src/ltl2inv/invert.tcc new file mode 100644 index 00000000..0b11edf1 --- /dev/null +++ b/src/ltl2inv/invert.tcc @@ -0,0 +1,132 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +#pragma once +#include "colmaj.hh" +#include "blalink.hh" +#include "trmmt.tcc" + +template +void sktdsmx(int n, T *vT, T *B_, int ldB, T *C_, int ldC) +{ + colmaj B(B_, ldB); + colmaj C(C_, ldC); + + for (int j = 0; j < n; ++j) + C(1, j) = B(0, j) / -vT[0]; + for (int i = 2; i < n; i += 2) + for (int j = 0; j < n; ++j) + C(i+1, j) = (B(i, j) - C(i-1, j) * vT[i-1]) / -vT[i]; + + for (int j = 0; j < n; ++j) + C(n-2, j) = B(n-1, j) / vT[n-2]; + for (int i = n-3; i >= 0; i -= 2) + for (int j = 0; j < n; ++j) + C(i-1, j) = (B(i, j) + C(i+1, j) * vT[i]) / vT[i-1]; +} + +template +void ltl2inv(int n, T *A_, int ldA, int *iPiv, T *vT, T *M_, int ldM) +{ + colmaj A(A_, ldA); + colmaj M(M_, ldM); + + int npanel_trmm = ilaenv_lauum(BLIS_LOWER, n); + int full = npanel_trmm <= 1 || npanel_trmm >= n; + + // Set M. + for (int j = 0; j < n; ++j) + for (int i = 0; i < n; ++i) + M(i, j) = T(!(i - j)); + + trtri(BLIS_LOWER, BLIS_UNIT_DIAG, n-1, &A(1, 0), ldA); + lacpy(BLIS_LOWER, n-2, n-2, &A(2, 0), ldA, &M(2, 1), ldM); + + for (int i = 0; i < n-1; ++i) + vT[i] = A(i+1, i); + sktdsmx(n, vT, &M(0, 0), ldM, &A(0, 0), ldA); + + if (!full) { + trmmt(BLIS_LOWER, BLIS_UNIT_DIAG, n, T(1.0), M, A); + for (int j = 0; j < n; ++j) { + A(j, j) = 0.0; + for (int i = 0; i < j; ++i) + A(i, j) = -A(j, i); + } + } + + // In-place permute columns. + for (int j = n-1; j >= 0; --j) + if (iPiv[j]-1 != j) + swap(n, &A(0, j), 1, &A(0, iPiv[j]-1), 1); + + if (full) + trmm(BLIS_LEFT, BLIS_LOWER, BLIS_TRANSPOSE, BLIS_UNIT_DIAG, + n, n, T(1.0), &M(0, 0), ldM, &A(0, 0), ldA); + + // In-place permute rows. + for (int i = n-1; i >= 0; --i) + if (iPiv[i]-1 != i) + swap(n, &A(i, 0), ldA, &A(iPiv[i]-1, 0), ldA); +} + +template +void utu2inv(int n, T *A_, int ldA, int *iPiv, T *vT, T *M_, int ldM) +{ + colmaj A(A_, ldA); + colmaj M(M_, ldM); + + int npanel_trmm = ilaenv_lauum(BLIS_UPPER, n); + int full = npanel_trmm <= 1 || npanel_trmm >= n; + + // Set M. + for (int j = 0; j < n; ++j) + for (int i = 0; i < n; ++i) + M(i, j) = T(!(i - j)); + + trtri(BLIS_UPPER, BLIS_UNIT_DIAG, n-1, &A(0, 1), ldA); + lacpy(BLIS_UPPER, n-2, n-2, &A(0, 2), ldA, &M(0, 1), ldM); + + for (int i = 0; i < n-1; ++i) + vT[i] = -A(i, i+1); + sktdsmx(n, vT, &M(0, 0), ldM, &A(0, 0), ldA); + + if (!full) { + trmmt(BLIS_UPPER, BLIS_UNIT_DIAG, n, T(1.0), M, A); + for (int j = 0; j < n; ++j) { + A(j, j) = 0.0; + for (int i = j + 1; i < n; ++i) + A(i, j) = -A(j, i); + } + } + + // In-place permute columns. + for (int j = 0; j < n; ++j) + if (iPiv[j]-1 != j) + swap(n, &A(0, j), 1, &A(0, iPiv[j]-1), 1); + + if (full) + trmm(BLIS_LEFT, BLIS_UPPER, BLIS_TRANSPOSE, BLIS_UNIT_DIAG, + n, n, T(1.0), &M(0, 0), ldM, &A(0, 0), ldA); + + // In-place permute rows. + for (int i = 0; i < n; ++i) + if (iPiv[i]-1 != i) + swap(n, &A(i, 0), ldA, &A(iPiv[i]-1, 0), ldA); +} + +template +void ltl2inv(uplo_t uplo, int n, T *A_, int ldA, int *iPiv, T *vT, T *M_, int ldM) +{ + switch (uplo) { + case BLIS_LOWER: + ltl2inv(n, A_, ldA, iPiv, vT, M_, ldM); break; + case BLIS_UPPER: + utu2inv(n, A_, ldA, iPiv, vT, M_, ldM); break; + default: + break; + } +} + diff --git a/src/ltl2inv/ltl2inv.cc b/src/ltl2inv/ltl2inv.cc new file mode 100644 index 00000000..19f10256 --- /dev/null +++ b/src/ltl2inv/ltl2inv.cc @@ -0,0 +1,33 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +#include "pfaffian.tcc" +#include "invert.tcc" + + + +extern "C" { + +void ltl2inv_s(int n, float *A_, int ldA, int *iPiv, float *vT, float *M_, int ldM) { ltl2inv(n, A_, ldA, iPiv, vT, M_, ldM); } +void ltl2inv_d(int n, double *A_, int ldA, int *iPiv, double *vT, double *M_, int ldM) { ltl2inv(n, A_, ldA, iPiv, vT, M_, ldM); } +void ltl2inv_c(int n, ccscmplx *A_, int ldA, int *iPiv, ccscmplx *vT, ccscmplx *M_, int ldM) { ltl2inv(n, A_, ldA, iPiv, vT, M_, ldM); } +void ltl2inv_z(int n, ccdcmplx *A_, int ldA, int *iPiv, ccdcmplx *vT, ccdcmplx *M_, int ldM) { ltl2inv(n, A_, ldA, iPiv, vT, M_, ldM); } +void utu2inv_s(int n, float *A_, int ldA, int *iPiv, float *vT, float *M_, int ldM) { utu2inv(n, A_, ldA, iPiv, vT, M_, ldM); } +void utu2inv_d(int n, double *A_, int ldA, int *iPiv, double *vT, double *M_, int ldM) { utu2inv(n, A_, ldA, iPiv, vT, M_, ldM); } +void utu2inv_c(int n, ccscmplx *A_, int ldA, int *iPiv, ccscmplx *vT, ccscmplx *M_, int ldM) { utu2inv(n, A_, ldA, iPiv, vT, M_, ldM); } +void utu2inv_z(int n, ccdcmplx *A_, int ldA, int *iPiv, ccdcmplx *vT, ccdcmplx *M_, int ldM) { utu2inv(n, A_, ldA, iPiv, vT, M_, ldM); } + + +void ltl2pfa_s(int n, float *A_, int ldA, int *iPiv, float *Pfa) { *Pfa = ltl2pfa(n, A_, ldA, iPiv); } +void ltl2pfa_d(int n, double *A_, int ldA, int *iPiv, double *Pfa) { *Pfa = ltl2pfa(n, A_, ldA, iPiv); } +void ltl2pfa_c(int n, ccscmplx *A_, int ldA, int *iPiv, ccscmplx *Pfa) { *Pfa = ltl2pfa(n, A_, ldA, iPiv); } +void ltl2pfa_z(int n, ccdcmplx *A_, int ldA, int *iPiv, ccdcmplx *Pfa) { *Pfa = ltl2pfa(n, A_, ldA, iPiv); } +void utu2pfa_s(int n, float *A_, int ldA, int *iPiv, float *Pfa) { *Pfa = utu2pfa(n, A_, ldA, iPiv); } +void utu2pfa_d(int n, double *A_, int ldA, int *iPiv, double *Pfa) { *Pfa = utu2pfa(n, A_, ldA, iPiv); } +void utu2pfa_c(int n, ccscmplx *A_, int ldA, int *iPiv, ccscmplx *Pfa) { *Pfa = utu2pfa(n, A_, ldA, iPiv); } +void utu2pfa_z(int n, ccdcmplx *A_, int ldA, int *iPiv, ccdcmplx *Pfa) { *Pfa = utu2pfa(n, A_, ldA, iPiv); } + +} + diff --git a/src/ltl2inv/makefile_ltl2inv b/src/ltl2inv/makefile_ltl2inv new file mode 100644 index 00000000..8c76afb1 --- /dev/null +++ b/src/ltl2inv/makefile_ltl2inv @@ -0,0 +1,29 @@ +include ../make.sys + +OBJ = ltl2inv.o blalink_gemmt.o ilaenv_lauum.o +SRC = ltl2inv.cc blalink_gemmt.c ilaenv_lauum.cc +HDR = invert.tcc pfaffian.tcc \ + ../common/blalink.hh ../common/blalink_fort.h ../common/colmaj.hh + +ltl2inv.a: $(OBJ) + $(AR) rvu $@ $(OBJ) + +clean: + rm -f $(OBJ) + +SUFFIXES: .o .c + +.c.o: $(HDR) + $(CC) $(OPTION) $(CFLAGS) -c $< -o $@ \ + -Wno-incompatible-pointer-types-discards-qualifiers \ + -I../common \ + -I$(BLIS_ROOT)/include \ + -I$(BLIS_ROOT)/include/blis + +SUFFIXES: .o .cc + +.cc.o: $(HDR) + $(CXX) $(CXXFLAGS) -D_CC_IMPL -c $< -o $@ \ + -I../common \ + -I$(BLIS_ROOT)/include \ + -I$(BLIS_ROOT)/include/blis diff --git a/src/ltl2inv/pfaffian.tcc b/src/ltl2inv/pfaffian.tcc new file mode 100644 index 00000000..ed028524 --- /dev/null +++ b/src/ltl2inv/pfaffian.tcc @@ -0,0 +1,52 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +#pragma once +#include "colmaj.hh" +#include "blalink.hh" + +template +T ltl2pfa(int n, T *A_, int ldA, int *iPiv) +{ + T pfa = 1.0; + colmaj A(A_, ldA); + + for (int i = 0; i < n; i += 2) { + pfa *= -A(i+1, i); + + if (iPiv[i ]-1 != i ) pfa = -pfa; + if (iPiv[i+1]-1 != i+1) pfa = -pfa; + } + return pfa; +} + +template +T utu2pfa(int n, T *A_, int ldA, int *iPiv) +{ + T pfa = 1.0; + colmaj A(A_, ldA); + + for (int i = 0; i < n; i += 2) { + pfa *= A(i, i+1); + + if (iPiv[i ]-1 != i ) pfa = -pfa; + if (iPiv[i+1]-1 != i+1) pfa = -pfa; + } + return pfa; +} + +template +T ltl2pfa(uplo_t uplo, int n, T *A_, int ldA, int *iPiv) +{ + switch (uplo) { + case BLIS_LOWER: + return ltl2pfa(n, A_, ldA, iPiv); + case BLIS_UPPER: + return utu2pfa(n, A_, ldA, iPiv); + default: + return 0.0; + } +} + diff --git a/src/ltl2inv/testinv.cc b/src/ltl2inv/testinv.cc new file mode 100644 index 00000000..c7cbc358 --- /dev/null +++ b/src/ltl2inv/testinv.cc @@ -0,0 +1,125 @@ +#include +#include +#include +#include + +#include "colmaj.hh" +#include "invert.tcc" + +struct info_t { + double err; + long long tim; +}; + +template +info_t test_decomp2inv(uplo_t uplo, int n) +{ + using namespace std::chrono; + + colmaj A(new T[n * n], n); + colmaj M(new T[n * n], n); + colmaj X(new T[n * n], n); + int *ipiv = new int[n]; + T *vT = new T[n-1]; + + assert(&A(0, 0)); + assert(&M(0, 0)); + assert(&X(0, 0)); + assert(ipiv); + assert(vT); + + for (int j = 0; j < n; ++j) { + A(j, j) = 0.0; + X(j, j) = 0.0; + + for (int i = j+1; i < n; ++i) { + A(i, j) = rand(); + A(i, j) /= RAND_MAX; + + A(j, i) = -A(i, j); + switch (uplo) { + case BLIS_LOWER: + X(i, j) = A(i, j); break; + case BLIS_UPPER: + X(j, i) = A(j, i); break; + default: + break; + } + } + } + + auto start = high_resolution_clock::now(); + + sktrf(uplo, n, &X(0, 0), n, ipiv, &M(0, 0), n*n); + switch (uplo) { + case BLIS_LOWER: + ltl2inv(n, &X(0, 0), n, ipiv, vT, &M(0, 0), n); break; + case BLIS_UPPER: + utu2inv(n, &X(0, 0), n, ipiv, vT, &M(0, 0), n); break; + default: + break; + } + + auto tim = duration_cast(high_resolution_clock::now() - start).count(); + + gemm(BLIS_NO_TRANSPOSE, BLIS_NO_TRANSPOSE, + n, n, n, + 1.0, + &A(0, 0), n, + &X(0, 0), n, + 0.0, + &M(0, 0), n); + +#ifdef VERBOSE + printf("iPiv = [ "); + for (int i = 0; i < n; ++i) + printf("%d ", ipiv[i]); + printf("]\n"); + printf("vT = [ "); + for (int i = 0; i < n-1; ++i) + printf("%f ", vT[i]); + printf("]\n"); + + printf("A*inv(A) =\n"); + for (int i = 0; i < n; ++i) { + for (int j = 0; j < n; ++j) + printf("%10.6f ", M(i, j)); + printf("\n"); + } +#endif + + double err = 0.0; + for (int j = 0; j < n; ++j) + for (int i = 0; i < n; ++i) + err += std::abs(M(i, j) - double(!(i - j))); + err /= n; // sqrt(n*n); + + delete[] &A(0, 0); + delete[] &M(0, 0); + delete[] &X(0, 0); + delete[] ipiv; + delete[] vT; + + return info_t{ err, tim }; +} + +int main(void) +{ + info_t info; int n; + n= 10; info = test_decomp2inv (BLIS_LOWER, n); printf("double n=%5d lower err=%e at %6lfgflops.\n", n, info.err, 1.33*std::pow(10 ,3)/info.tim); + n= 10; info = test_decomp2inv (BLIS_LOWER, n); printf("float n=%5d lower err=%e at %6lfgflops.\n", n, info.err, 1.33*std::pow(10 ,3)/info.tim); + n= 10; info = test_decomp2inv(BLIS_LOWER, n); printf("dcomplex n=%5d lower err=%e at %6lfgflops.\n", n, info.err, 5.33*std::pow(10 ,3)/info.tim); + n=200; info = test_decomp2inv (BLIS_LOWER, n); printf("double n=%5d lower err=%e at %6lfgflops.\n", n, info.err, 1.33*std::pow(200,3)/info.tim); + n=200; info = test_decomp2inv (BLIS_LOWER, n); printf("float n=%5d lower err=%e at %6lfgflops.\n", n, info.err, 1.33*std::pow(200,3)/info.tim); + n=200; info = test_decomp2inv(BLIS_LOWER, n); printf("dcomplex n=%5d lower err=%e at %6lfgflops.\n", n, info.err, 5.33*std::pow(200,3)/info.tim); + + n= 10; info = test_decomp2inv (BLIS_UPPER, n); printf("double n=%5d upper err=%e at %6lfgflops.\n", n, info.err, 1.33*std::pow(10 ,3)/info.tim); + n= 10; info = test_decomp2inv (BLIS_UPPER, n); printf("float n=%5d upper err=%e at %6lfgflops.\n", n, info.err, 1.33*std::pow(10 ,3)/info.tim); + n= 10; info = test_decomp2inv(BLIS_UPPER, n); printf("dcomplex n=%5d upper err=%e at %6lfgflops.\n", n, info.err, 5.33*std::pow(10 ,3)/info.tim); + n=200; info = test_decomp2inv (BLIS_UPPER, n); printf("double n=%5d upper err=%e at %6lfgflops.\n", n, info.err, 1.33*std::pow(200,3)/info.tim); + n=200; info = test_decomp2inv (BLIS_UPPER, n); printf("float n=%5d upper err=%e at %6lfgflops.\n", n, info.err, 1.33*std::pow(200,3)/info.tim); + n=200; info = test_decomp2inv(BLIS_UPPER, n); printf("dcomplex n=%5d upper err=%e at %6lfgflops.\n", n, info.err, 5.33*std::pow(200,3)/info.tim); + + return 0; +} + diff --git a/src/ltl2inv/trmmt.tcc b/src/ltl2inv/trmmt.tcc new file mode 100644 index 00000000..79bc7170 --- /dev/null +++ b/src/ltl2inv/trmmt.tcc @@ -0,0 +1,35 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +#pragma once +#include "colmaj.hh" +#include "blalink.hh" +#include "ilaenv_lauum.hh" + + +template +inline void trmmt(uplo_t uploab, diag_t diaga, int n, T alpha, colmaj &A, colmaj &B) +{ + int npanel = ilaenv_lauum(uploab, n); + + if (uploab == BLIS_UPPER) { + // A upper => A' lower -> write to UPPER part of B. + for (int j = 0; j < n; j += npanel) { + int nloc = std::min(npanel, n - j); + + trmm(BLIS_LEFT, BLIS_UPPER, BLIS_TRANSPOSE, diaga, + j+nloc, nloc, alpha, &A(0, 0), A.ld, &B(0, j), B.ld); + } + } else { + // A lower => A' upper -> write to LOWER part of B. + for (int j = 0; j < n; j += npanel) { + int nloc = std::min(npanel, n - j); + + trmm(BLIS_LEFT, BLIS_LOWER, BLIS_TRANSPOSE, diaga, + n-j, nloc, alpha, &A(j, j), A.ld, &B(j, j), B.ld); + } + } +} + diff --git a/src/mVMC/CMakeLists.txt b/src/mVMC/CMakeLists.txt index f80471ca..44ae92cf 100644 --- a/src/mVMC/CMakeLists.txt +++ b/src/mVMC/CMakeLists.txt @@ -27,9 +27,13 @@ target_link_libraries(vmcdry.out StdFace m) add_executable(vmc.out ${SOURCES_vmcmain} ${SOURCES_sfmt}) target_link_libraries(vmc.out StdFace) target_link_libraries(vmc.out pfapack) +target_link_libraries(vmc.out ltl2inv) if(PFAFFIAN_BLOCKED) - target_link_libraries(vmc.out pfupdates blis pthread) + target_link_libraries(vmc.out pfupdates) endif(PFAFFIAN_BLOCKED) +if(Require_BLIS) + target_link_libraries(vmc.out blis pthread) +endif(Require_BLIS) target_link_libraries(vmc.out ${LAPACK_LIBRARIES} m) if(USE_SCALAPACK) diff --git a/src/mVMC/avevar.c b/src/mVMC/avevar.c index e7157d48..99e7d06e 100644 --- a/src/mVMC/avevar.c +++ b/src/mVMC/avevar.c @@ -146,6 +146,81 @@ void OutputOptData() { count_i +=2*5*NDoublonHolon4siteIdx; } +//RBM + if(NChargeRBM_PhysLayerIdx != 0){ + sprintf(fileName, "%s_chargeRBM_physlayer_opt.dat", CParaFileHead); + Child_OutputOptData(fp, fileName, "NChargeRBM_PhysLayerIdx", + NChargeRBM_PhysLayerIdx, NChargeRBM_PhysLayerIdx, + count_i, n); + count_i += NChargeRBM_PhysLayerIdx; + } + + if(NSpinRBM_PhysLayerIdx != 0){ + sprintf(fileName, "%s_spinRBM_physlayer_opt.dat", CParaFileHead); + Child_OutputOptData(fp, fileName, "NSpinRBM_PhysLayerIdx", + NSpinRBM_PhysLayerIdx, NSpinRBM_PhysLayerIdx, + count_i, n); + count_i += NSpinRBM_PhysLayerIdx; + } + + if(NGeneralRBM_PhysLayerIdx != 0){ + sprintf(fileName, "%s_generalRBM_physlayer_opt.dat", CParaFileHead); + Child_OutputOptData(fp, fileName, "NGeneralRBM_PhysLayerIdx", + NGeneralRBM_PhysLayerIdx, NGeneralRBM_PhysLayerIdx, + count_i, n); + count_i += NGeneralRBM_PhysLayerIdx; + } + + if(NChargeRBM_HiddenLayerIdx != 0){ + sprintf(fileName, "%s_chargeRBM_hiddenlayer_opt.dat", CParaFileHead); + Child_OutputOptData(fp, fileName, "NChargeRBM_HiddenLayerIdx", + NChargeRBM_HiddenLayerIdx, NChargeRBM_HiddenLayerIdx, + count_i, n); + count_i += NChargeRBM_HiddenLayerIdx; + } + + if(NSpinRBM_HiddenLayerIdx != 0){ + sprintf(fileName, "%s_spinRBM_hiddenlayer_opt.dat", CParaFileHead); + Child_OutputOptData(fp, fileName, "NSpinRBM_HiddenLayerIdx", + NSpinRBM_HiddenLayerIdx, NSpinRBM_HiddenLayerIdx, + count_i, n); + count_i += NSpinRBM_HiddenLayerIdx; + } + + if(NGeneralRBM_HiddenLayerIdx != 0){ + sprintf(fileName, "%s_generalRBM_hiddenlayer_opt.dat", CParaFileHead); + Child_OutputOptData(fp, fileName, "NGeneralRBM_HiddenLayerIdx", + NGeneralRBM_HiddenLayerIdx, NGeneralRBM_HiddenLayerIdx, + count_i, n); + count_i += NGeneralRBM_HiddenLayerIdx; + } + + + if(NChargeRBM_PhysHiddenIdx != 0){ + sprintf(fileName, "%s_chargeRBM_physhidden_opt.dat", CParaFileHead); + Child_OutputOptData(fp, fileName, "NChargeRBM_PhysHiddenIdx", + NChargeRBM_PhysHiddenIdx, NChargeRBM_PhysHiddenIdx, + count_i, n); + count_i += NChargeRBM_PhysHiddenIdx; + } + + if(NSpinRBM_PhysHiddenIdx != 0){ + sprintf(fileName, "%s_spinRBM_physhidden_opt.dat", CParaFileHead); + Child_OutputOptData(fp, fileName, "NSpinRBM_PhysHiddenIdx", + NSpinRBM_PhysHiddenIdx, NSpinRBM_PhysHiddenIdx, + count_i, n); + count_i += NSpinRBM_PhysHiddenIdx; + } + + if(NGeneralRBM_PhysHiddenIdx != 0){ + sprintf(fileName, "%s_generalRBM_physhidden_opt.dat", CParaFileHead); + Child_OutputOptData(fp, fileName, "NGeneralRBM_PhysHiddenIdx", + NGeneralRBM_PhysHiddenIdx, NGeneralRBM_PhysHiddenIdx, + count_i, n); + count_i += NGeneralRBM_PhysHiddenIdx; + } +//RBM + if(NSlater != 0){ if(iFlgOrbitalGeneral==0) { sprintf(fileName, "%s_orbital_opt.dat", CParaFileHead); diff --git a/src/mVMC/calgrn.c b/src/mVMC/calgrn.c index 16fc3864..708a186d 100644 --- a/src/mVMC/calgrn.c +++ b/src/mVMC/calgrn.c @@ -30,25 +30,28 @@ along with this program. If not, see http://www.gnu.org/licenses/. #define _CALGRN_SRC void CalculateGreenFunc(const double w, const double complex ip, int *eleIdx, int *eleCfg, - int *eleNum, int *eleProjCnt) { + int *eleNum, int *eleProjCnt, const double complex *rbmCnt) { int idx,idx0,idx1; int ri,rj,s,rk,rl,t; double complex tmp; int *myEleIdx, *myEleNum, *myProjCntNew; double complex *myBuffer; + double complex *myRBMCntNew; RequestWorkSpaceThreadInt(Nsize+Nsite2+NProj); - RequestWorkSpaceThreadComplex(NQPFull+2*Nsize); + RequestWorkSpaceThreadComplex(NQPFull+2*Nsize + FlagRBM*NRBM_PhysLayerIdx+Nneuron); + //RequestWorkSpaceThreadComplex(NQPFull+2*Nsize); /* GreenFunc1: NQPFull, GreenFunc2: NQPFull+2*Nsize */ - #pragma omp parallel default(shared) \ - private(myEleIdx,myEleNum,myProjCntNew,myBuffer,idx) +#pragma omp parallel default(shared) \ + private(myRBMCntNew, myEleIdx,myEleNum,myProjCntNew,myBuffer,idx) { myEleIdx = GetWorkSpaceThreadInt(Nsize); myEleNum = GetWorkSpaceThreadInt(Nsite2); myProjCntNew = GetWorkSpaceThreadInt(NProj); myBuffer = GetWorkSpaceThreadComplex(NQPFull+2*Nsize); + myRBMCntNew = GetWorkSpaceThreadComplex(NRBM_PhysLayerIdx+Nneuron); #pragma loop noalias for(idx=0;idx4.0 [ip] MUST be specified. // Hence we have to fall back to default(shared) here. #pragma omp parallel default(shared) \ - private(myEleIdx,myEleNum,myProjCntNew,myBuffer,myEnergy, idx, ri, rj, rk, rl, s, t) \ - firstprivate(Nsize, Nsite2, NProj, NQPFull, NCoulombIntra, CoulombIntra, ParaCoulombIntra, \ + private(myRBMCntNew, myEleIdx,myEleNum,myProjCntNew,myBuffer,myEnergy, idx, ri, rj, rk, rl, s, t) \ + firstprivate(NRBM_PhysLayerIdx, Nneuron, Nsize, Nsite2, NProj, NQPFull, NCoulombIntra, CoulombIntra, ParaCoulombIntra, \ NCoulombInter, CoulombInter, ParaCoulombInter, NHundCoupling, HundCoupling, ParaHundCoupling, \ NTransfer, Transfer, ParaTransfer, NPairHopping, PairHopping, ParaPairHopping, \ NExchangeCoupling, ExchangeCoupling, ParaExchangeCoupling, NInterAll, InterAll, ParaInterAll, n0, n1) \ - shared(eleCfg, eleProjCnt, eleIdx, eleNum) reduction(+:e) + shared(eleCfg, eleProjCnt, eleIdx, eleNum, rbmCnt, FlagRBM) reduction(+:e) { myEleIdx = GetWorkSpaceThreadInt(Nsize); myEleNum = GetWorkSpaceThreadInt(Nsite2); myProjCntNew = GetWorkSpaceThreadInt(NProj); + if (FlagRBM) { + myRBMCntNew = GetWorkSpaceThreadComplex(NRBM_PhysLayerIdx+Nneuron); + } myBuffer = GetWorkSpaceThreadComplex(NQPFull+2*Nsize); #pragma loop noalias @@ -135,7 +139,7 @@ double complex CalculateHamiltonian(const double complex ip, int *eleIdx, const s = Transfer[idx][3]; myEnergy -= ParaTransfer[idx] - * GreenFunc1(ri,rj,s,ip,myEleIdx,eleCfg,myEleNum,eleProjCnt,myProjCntNew,myBuffer); + * GreenFunc1(ri,rj,s,ip,myEleIdx,eleCfg,myEleNum,eleProjCnt,myProjCntNew,rbmCnt, myRBMCntNew, myBuffer); /* Caution: negative sign */ } @@ -149,7 +153,7 @@ double complex CalculateHamiltonian(const double complex ip, int *eleIdx, const rj = PairHopping[idx][1]; myEnergy += ParaPairHopping[idx] - * GreenFunc2(ri,rj,ri,rj,0,1,ip,myEleIdx,eleCfg,myEleNum,eleProjCnt,myProjCntNew,myBuffer); + * GreenFunc2(ri,rj,ri,rj,0,1,ip,myEleIdx,eleCfg,myEleNum,eleProjCnt,myProjCntNew,rbmCnt,myRBMCntNew,myBuffer); } /* Exchange Coupling */ @@ -157,9 +161,9 @@ double complex CalculateHamiltonian(const double complex ip, int *eleIdx, const for(idx=0;idx void CalculateGreenFunc(const double w, const double complex ip, int *eleIdx, int *eleCfg, - int *eleNum, int *eleProjCnt); + int *eleNum, int *eleProjCnt, const double complex *rbmCnt); void CalculateGreenFuncBF(const double w, const double ip, int *eleIdx, int *eleCfg, int *eleNum, int *eleProjCnt, const int *eleProjBFCnt); -#endif +#endif \ No newline at end of file diff --git a/src/mVMC/include/calham.h b/src/mVMC/include/calham.h index 44bff34f..ae7ab542 100644 --- a/src/mVMC/include/calham.h +++ b/src/mVMC/include/calham.h @@ -2,7 +2,8 @@ #define _CALHAM #include -double complex CalculateHamiltonian(const double complex ip, int *eleIdx, const int *eleCfg, int *eleNum, const int *eleProjCnt); +double complex CalculateHamiltonian(const double complex ip, int *eleIdx, const int *eleCfg, + int *eleNum, const int *eleProjCnt, const double complex *rbmCnt); double complex CalculateHamiltonian0(const int *eleNum); diff --git a/src/mVMC/include/global.h b/src/mVMC/include/global.h index fb93b97a..40f312ba 100644 --- a/src/mVMC/include/global.h +++ b/src/mVMC/include/global.h @@ -130,6 +130,20 @@ int iFlgOrbitalGeneral=0; int iNOrbitalParallel=0; int iNOrbitalAntiParallel=0; +/* restricted Boltzman Machine for variational parameters */ +int Nneuron,NneuronGeneral,NneuronCharge,NneuronSpin; +int NRBM_HiddenLayerIdx,NRBM_PhysLayerIdx,NRBM_PhysHiddenIdx; +int NGeneralRBM_HiddenLayerIdx, *GeneralRBM_HiddenLayerIdx; /* [Nneuron] */ +int NGeneralRBM_PhysLayerIdx, *GeneralRBM_PhysLayerIdx; /* [Nsite2] */ +int NGeneralRBM_PhysHiddenIdx, **GeneralRBM_PhysHiddenIdx; /* [Nsite2][Nneuron] */ +int NChargeRBM_HiddenLayerIdx, *ChargeRBM_HiddenLayerIdx; /* [Nneuron] */ +int NChargeRBM_PhysLayerIdx, *ChargeRBM_PhysLayerIdx; /* [Nsite] */ +int NChargeRBM_PhysHiddenIdx, **ChargeRBM_PhysHiddenIdx; /* [Nsite][Nneuron] */ +int NSpinRBM_HiddenLayerIdx, *SpinRBM_HiddenLayerIdx; /* [Nneuron] */ +int NSpinRBM_PhysLayerIdx, *SpinRBM_PhysLayerIdx; /* [Nsite] */ +int NSpinRBM_PhysHiddenIdx, **SpinRBM_PhysHiddenIdx; /* [Nsite][Nneuron] */ +int NBlockSize_RBMRatio; /* block size for RBMRatio function. It is Tuning for performance. */ + /* zqptransidx.def */ int NQPTrans, **QPTrans, **QPTransInv; /* [NQPTrans][Nsite] */ int **QPTransSgn; /* QPTransSgn[NQPTrans][NSite] = +1 or -1 */ @@ -150,6 +164,9 @@ int **iOneBodyGIdx; /* For GF2 indirect measurement */ int *OptFlag; /* [NPara] 1: optimized, 0 or 2: fixed */ int AllComplexFlag;/* 0 -> all real variables, !=0-> including complex variables*/ +/* flag for RBM */ +int FlagRBM=0; + /* flag for anti-periodic boundry condition */ int APFlag; /* 0: periodic, 1: anti-periodic */ @@ -171,6 +188,7 @@ int NFileFlushInterval=1; /***** Variational Parameters *****/ int NPara; /* the total number of variational prameters NPara= NProj + NSlater+ NOptTrans */ int NProj; /* the number of correlation factor */ +int NRBM, NRBM_PhysLayerIdx, NRBM_HiddenLayerIdx; int NProjBF; /* the number of correlation factor */ int NSlater; /* the number of pair orbital (f_ij) = NOrbitalIdx */ int NOptTrans; /* the number of weights for OptTrans. This is used only for variatonal parameters */ @@ -178,6 +196,7 @@ int NOptTrans; /* the number of weights for OptTrans. This is used only for vari int **etaFlag; /* Back Flow correlation factor (eta = 1.0 or ProjBF[0])*/ double complex *Para; /* variatonal parameters */ double complex *Proj; /* correlation factor (Proj =Para) */ +double complex *RBM; /* (Proj =Para) */ double complex *ProjBF; /* Back flow correlation factor (Proj =Para) */ double complex *Slater; /* pair orbital (Slater =Para+NProj) */ double complex *OptTrans; /* weights (OptTrans=Para+NProj+NSlater) */ @@ -196,6 +215,7 @@ int *EleNum; /* EleIdx[sample][ri+si*Nsite] */ int *EleProjCnt; /* EleProjCnt[sample][proj] */ //[s] MERGE BY TM int *EleSpn; /* EleIdx[sample][mi+si*Ne] */ //fsz +double complex *RBMCnt; int *EleProjBFCnt; /* EleProjCnt[sample][proj] */ //[e] MERGE BY TM double *logSqPfFullSlater; /* logSqPfFullSlater[sample] */ @@ -213,12 +233,14 @@ int *TmpEleProjCnt; int *TmpEleSpn; int *TmpEleProjBFCnt; //[e] MERGE BY TM +double complex *TmpRBMCnt; int *BurnEleIdx; int *BurnEleCfg; int *BurnEleNum; int *BurnEleProjCnt; int *BurnEleSpn; +double complex *BurnRBMCnt; int BurnFlag=0; /* 0: off, 1: on */ /***** Slater Elements ******/ @@ -320,6 +342,7 @@ FILE *FileLSCisAjsCktAltDC; /***** HitachiTimer *****/ const int NTimer=1000; double Timer[1000], TimerStart[1000]; +double ccc[100]; /* flag for SROptimization*/ int SRFlag; /* 0: periodic, 1: Diagonalization */ diff --git a/src/mVMC/include/locgrn.h b/src/mVMC/include/locgrn.h index d103d294..b856e463 100644 --- a/src/mVMC/include/locgrn.h +++ b/src/mVMC/include/locgrn.h @@ -5,17 +5,18 @@ double complex GreenFunc1(const int ri, const int rj, const int s, const double complex ip, int *eleIdx, const int *eleCfg, int *eleNum, const int *eleProjCnt, - int *projCntNew, double complex *buffer); + int *projCntNew, const double complex *rbmCnt, double complex *rbmCntNew, double complex *buffer); + double complex GreenFunc2(const int ri, const int rj, const int rk, const int rl, const int s, const int t, const double complex ip, int *eleIdx, const int *eleCfg, int *eleNum, const int *eleProjCnt, - int *projCntNew, double complex *buffer); + int *projCntNew, const double complex *rbmCnt, double complex *rbmCntNew, double complex *buffer); double complex GreenFuncN(const int n, int *rsi, int *rsj, const double complex ip, int *eleIdx, const int *eleCfg, int *eleNum, const int *eleProjCnt, - double complex *buffer, int *bufferInt); + const double complex *rbmCnt, double complex *rbmCntNew, double complex *buffer, int *bufferInt); double complex GreenFunc1BF(const int ri, const int rj, const int s, const double complex ip, double complex* bufM, int *eleIdx, int *eleCfg, int *eleNum, const int *eleProjCnt, int *projCntNew, const int *eleProjBFCnt,int *projBFCntNew, double complex* buffer); -#endif +#endif \ No newline at end of file diff --git a/src/mVMC/include/lslocgrn.h b/src/mVMC/include/lslocgrn.h index dd1b5f32..27dd2414 100644 --- a/src/mVMC/include/lslocgrn.h +++ b/src/mVMC/include/lslocgrn.h @@ -3,9 +3,8 @@ #include #include "global.h" -void LSLocalQ(const double complex h1, const double complex ip, int *eleIdx, int *eleCfg, int *eleNum, int *eleProjCnt, double complex* _LSLocalQ); +void LSLocalQ(const double complex h1, const double complex ip, int *eleIdx, int *eleCfg, int *eleNum, int *eleProjCnt, double complex *rbmCnt, double complex* _LSLocalQ); -void LSLocalCisAjs(const double complex h1, const double complex ip, int *eleIdx, int *eleCfg, int *eleNum, int *eleProjCnt); +void LSLocalCisAjs(const double complex h1, const double complex ip, int *eleIdx, int *eleCfg, int *eleNum, int *eleProjCnt, double complex *rbmCnt); - -#endif +#endif \ No newline at end of file diff --git a/src/mVMC/include/rbm.h b/src/mVMC/include/rbm.h new file mode 100644 index 00000000..387882b7 --- /dev/null +++ b/src/mVMC/include/rbm.h @@ -0,0 +1,22 @@ +#ifndef _RBM_ +#define _RBM_ + +extern inline double complex WeightRBM(const double complex *rbmCnt); +extern inline double complex LogWeightRBM(const double complex *rbmCnt); +extern inline double complex RBMRatio(const double complex *rbmCntNew, const double complex *rbmCntOld); +extern inline double complex LogRBMRatio(const double complex *rbmCntNew, const double complex *rbmCntOld); + +void copyFromBurnSampleRBM(double complex *rbmCnt); +void copyToBurnSampleRBM(double complex *rbmCnt); +void saveRBMCnt(const int sample, const double complex *rbmCnt); + +void RBMDiff(double complex *srOptO, const double complex *rbmCnt, const int *eleNum); + + +void MakeRBMCnt(double complex *rbmCnt, const int *eleNum); +void UpdateRBMCnt(const int ri, const int rj, const int s, + double complex *rbmCntNew, const double complex *rbmCntOld, const int *eleNum); + +void UpdateRBMCnt_fsz(const int ri, const int rj, const int s, const int t, + double complex *rbmCntNew, const double complex *rbmCntOld) ; +#endif diff --git a/src/mVMC/include/readdef.h b/src/mVMC/include/readdef.h index 478e1797..bf86c42f 100644 --- a/src/mVMC/include/readdef.h +++ b/src/mVMC/include/readdef.h @@ -35,10 +35,22 @@ static char cKWListOfFileNameList[][D_CharTmpReadDef]={ "Trans", "CoulombIntra", "CoulombInter", "Hund", "PairHop", "Exchange", "Gutzwiller", "Jastrow", - "DH2", "DH4", "Orbital", "OrbitalAntiParallel", + "DH2", "DH4", + //RBM + "ChargeRBM_HiddenLayer","ChargeRBM_PhysLayer", "ChargeRBM_PhysHidden", + "SpinRBM_HiddenLayer","SpinRBM_PhysLayer", "SpinRBM_PhysHidden", + "GeneralRBM_HiddenLayer","GeneralRBM_PhysLayer", "GeneralRBM_PhysHidden", + //RBM + "Orbital", "OrbitalAntiParallel", "OrbitalParallel", "OrbitalGeneral", "TransSym", "InGutzwiller", "InJastrow", - "InDH2", "InDH4", "InOrbital", "InOrbitalAntiParallel", + "InDH2", "InDH4", + //RBM + "InChargeRBM_HiddenLayer","InChargeRBM_PhysLayer", "InChargeRBM_PhysHidden", + "InSpinRBM_HiddenLayer","InSpinRBM_PhysLayer", "InSpinRBM_PhysHidden", + "InGeneralRBM_HiddenLayer","InGeneralRBM_PhysLayer", "InGeneralRBM_PhysHidden", + //RBM + "InOrbital", "InOrbitalAntiParallel", "InOrbitalParallel", "InOrbitalGeneral", "OneBodyG", "TwoBodyG", "TwoBodyGEx", "InterAll", "OptTrans", "InOptTrans", @@ -53,10 +65,22 @@ enum KWIdxInt{ KWTrans, KWCoulombIntra,KWCoulombInter, KWHund, KWPairHop, KWExchange, KWGutzwiller, KWJastrow, - KWDH2, KWDH4, KWOrbital, KWOrbitalAntiParallel, + KWDH2, KWDH4, + //RBM + KWChargeRBM_HiddenLayer,KWChargeRBM_PhysLayer,KWChargeRBM_PhysHidden, + KWSpinRBM_HiddenLayer,KWSpinRBM_PhysLayer,KWSpinRBM_PhysHidden, + KWGeneralRBM_HiddenLayer,KWGeneralRBM_PhysLayer,KWGeneralRBM_PhysHidden, + //RBM + KWOrbital, KWOrbitalAntiParallel, KWOrbitalParallel, KWOrbitalGeneral, KWTransSym, KWInGutzwiller, KWInJastrow, - KWInDH2, KWInDH4, KWInOrbital,KWInOrbitalAntiParallel, + KWInDH2, KWInDH4, + //RBM + KWInChargeRBM_HiddenLayer,KWInChargeRBM_PhysLayer,KWInChargeRBM_PhysHidden, + KWInSpinRBM_HiddenLayer,KWInSpinRBM_PhysLayer,KWInSpinRBM_PhysHidden, + KWInGeneralRBM_HiddenLayer,KWInGeneralRBM_PhysLayer,KWInGeneralRBM_PhysHidden, + //RBM + KWInOrbital,KWInOrbitalAntiParallel, KWInOrbitalParallel, KWInorbitalGeneral, KWOneBodyG, KWTwoBodyG, KWTwoBodyGEx, KWInterAll, KWOptTrans, KWInOptTrans, @@ -73,6 +97,9 @@ static char (*cFileNameListFile)[D_CharTmpReadDef]; enum ParamIdxInt{ IdxVMCCalcMode, IdxLanczosMode, IdxDataIdxStart, IdxDataQtySmp, IdxNsite, IdxNe, + //RBM + IdxNneuron, IdxNneuronCharge, IdxNneuronSpin,IdxNneuronGeneral, + //RBM IdxSPGaussLeg, IdxSPStot, IdxMPTrans, IdxSROptItrStep, IdxSROptItrSmp, IdxSROptFixSmp, IdxVMCWarmUp, IdxVMCInterval, IdxVMCSample, @@ -80,7 +107,14 @@ enum ParamIdxInt{ IdxNLocSpin,IdxNTrans,IdxNCoulombIntra, IdxNCoulombInter, IdxNHund, IdxNPairHop, IdxNExchange, IdxNGutz, IdxNJast, - IdxNDH2, IdxNDH4, IdxNOrbit, IdxNOrbitGeneral, + IdxNDH2, IdxNDH4, + //RBM + IdxNChargeRBM_HiddenLayer,IdxNChargeRBM_PhysLayer, IdxNChargeRBM_PhysHidden, + IdxNSpinRBM_HiddenLayer,IdxNSpinRBM_PhysLayer, IdxNSpinRBM_PhysHidden, + IdxNGeneralRBM_HiddenLayer,IdxNGeneralRBM_PhysLayer, IdxNGeneralRBM_PhysHidden, + IdxNBlockSize_RBMRatio, + //RBM + IdxNOrbit, IdxNOrbitGeneral, IdxNQPTrans, IdxNOneBodyG, IdxNTwoBodyG, IdxNTwoBodyGEx, IdxNInterAll, IdxNQPOptTrans, IdxSROptCGMaxIter, @@ -113,3 +147,14 @@ int iComplexFlgOrbital=0; int iComplexFlgOrbitalAntiParallel=0; int iComplexFlgOrbitalParallel=0; int iComplexFlgOrbitalGeneral=0; +//RBM +int iComplexFlgGeneralRBM_PhysLayer=0; +int iComplexFlgGeneralRBM_HiddenLayer=0; +int iComplexFlgGeneralRBM_PhysHidden=0; +int iComplexFlgChargeRBM_PhysLayer=0; +int iComplexFlgChargeRBM_HiddenLayer=0; +int iComplexFlgChargeRBM_PhysHidden=0; +int iComplexFlgSpinRBM_PhysLayer=0; +int iComplexFlgSpinRBM_HiddenLayer=0; +int iComplexFlgSpinRBM_PhysHidden=0; +//RBM diff --git a/src/mVMC/include/version.h b/src/mVMC/include/version.h index 0e89e120..2a7f91d0 100644 --- a/src/mVMC/include/version.h +++ b/src/mVMC/include/version.h @@ -29,7 +29,7 @@ along with this program. If not, see http://www.gnu.org/licenses/. /* ..- */ #define VERSION_MAJOR 1 #define VERSION_MINOR 2 -#define VERSION_PATCH 0 +#define VERSION_PATCH 1 #define VERSION_PRERELEASE "" /* "alpha", "beta.1", etc. */ diff --git a/src/mVMC/include/vmcmain.h b/src/mVMC/include/vmcmain.h index 090c7b69..e8bb1db8 100644 --- a/src/mVMC/include/vmcmain.h +++ b/src/mVMC/include/vmcmain.h @@ -115,4 +115,6 @@ extern int omp_get_thread_num(void); #include "../vmccal.c" #include "../vmccal_fsz.c" +#include "../rbm.c" + #endif /* _VMC_INCLUDE_FILES */ diff --git a/src/mVMC/locgrn.c b/src/mVMC/locgrn.c index 0f8837c3..f9af4300 100644 --- a/src/mVMC/locgrn.c +++ b/src/mVMC/locgrn.c @@ -28,6 +28,7 @@ along with this program. If not, see http://www.gnu.org/licenses/. #pragma once #include "locgrn.h" #include "projection.h" +#include "rbm.h" #include "pfupdate.h" #include "pfupdate_two_fcmp.h" #include "qp.h" @@ -39,7 +40,7 @@ double complex calculateNewPfMN_child(const int qpidx, const int n, const int *m /* buffer size = NQPFull */ double complex GreenFunc1(const int ri, const int rj, const int s, const double complex ip, int *eleIdx, const int *eleCfg, int *eleNum, const int *eleProjCnt, - int *projCntNew, double complex *buffer) { + int *projCntNew, const double complex *rbmCnt, double complex *rbmCntNew, double complex *buffer) { double complex z; int mj,msj,rsi,rsj; double complex *pfMNew = buffer; /* NQPFull */ @@ -57,7 +58,16 @@ double complex GreenFunc1(const int ri, const int rj, const int s, const double eleNum[rsj] = 0; eleNum[rsi] = 1; UpdateProjCnt(rj, ri, s, projCntNew, eleProjCnt, eleNum); + + if (FlagRBM) { + UpdateRBMCnt(rj, ri, s, rbmCntNew, rbmCnt, eleNum); + z = ProjRatio(projCntNew,eleProjCnt); + z *= RBMRatio(rbmCntNew,rbmCnt); + } + else { + UpdateProjCnt(rj, ri, s, projCntNew, eleProjCnt, eleNum); z = ProjRatio(projCntNew,eleProjCnt); + } /* calculate Pfaffian */ CalculateNewPfM(mj, s, pfMNew, eleIdx, 0, NQPFull); @@ -76,7 +86,7 @@ double complex GreenFunc1(const int ri, const int rj, const int s, const double double complex GreenFunc2(const int ri, const int rj, const int rk, const int rl, const int s, const int t, const double complex ip, int *eleIdx, const int *eleCfg, int *eleNum, const int *eleProjCnt, - int *projCntNew, double complex *buffer) { + int *projCntNew, const double complex *rbmCnt, double complex *rbmCntNew, double complex *buffer) { double complex z; int mj,msj,ml,mtl; int rsi,rsj,rtk,rtl; @@ -92,36 +102,36 @@ double complex GreenFunc2(const int ri, const int rj, const int rk, const int rl if(rk==rl) { /* CisAjsNks */ if(eleNum[rtk]==0) return 0.0; else return GreenFunc1(ri,rj,s,ip,eleIdx,eleCfg,eleNum, - eleProjCnt,projCntNew,buffer); /* CisAjs */ + eleProjCnt,projCntNew,rbmCnt,rbmCntNew,buffer); /* CisAjs */ }else if(rj==rl) { return 0.0; /* CisAjsCksAjs (j!=k) */ }else if(ri==rl) { /* AjsCksNis */ if(eleNum[rsi]==0) return 0.0; else if(rj==rk) return 1.0-eleNum[rsj]; else return -GreenFunc1(rk,rj,s,ip,eleIdx,eleCfg,eleNum, - eleProjCnt,projCntNew,buffer); /* -CksAjs */ + eleProjCnt,projCntNew,rbmCnt,rbmCntNew,buffer); /* -CksAjs */ }else if(rj==rk) { /* CisAls(1-Njs) */ if(eleNum[rsj]==1) return 0.0; else if(ri==rl) return eleNum[rsi]; else return GreenFunc1(ri,rl,s,ip,eleIdx,eleCfg,eleNum, - eleProjCnt,projCntNew,buffer); /* CisAls */ + eleProjCnt,projCntNew,rbmCnt,rbmCntNew,buffer); /* CisAls */ }else if(ri==rk) { return 0.0; /* CisAjsCisAls (i!=j) */ }else if(ri==rj) { /* NisCksAls (i!=k,l) */ if(eleNum[rsi]==0) return 0.0; else return GreenFunc1(rk,rl,s,ip,eleIdx,eleCfg,eleNum, - eleProjCnt,projCntNew,buffer); /* CksAls */ + eleProjCnt,projCntNew,rbmCnt,rbmCntNew,buffer); /* CksAls */ } }else{ if(rk==rl) { /* CisAjsNkt */ if(eleNum[rtk]==0) return 0.0; else if(ri==rj) return eleNum[rsi]; else return GreenFunc1(ri,rj,s,ip,eleIdx,eleCfg,eleNum, - eleProjCnt,projCntNew,buffer); /* CisAjs */ + eleProjCnt,projCntNew,rbmCnt,rbmCntNew,buffer); /* CisAjs */ }else if(ri==rj) { /* NisCktAlt */ if(eleNum[rsi]==0) return 0.0; else return GreenFunc1(rk,rl,t,ip,eleIdx,eleCfg,eleNum, - eleProjCnt,projCntNew,buffer); /* CktAlt */ + eleProjCnt,projCntNew,rbmCnt,rbmCntNew,buffer); /* CktAlt */ } } @@ -137,12 +147,21 @@ double complex GreenFunc2(const int ri, const int rj, const int rk, const int rl eleNum[rtl] = 0; eleNum[rtk] = 1; UpdateProjCnt(rl, rk, t, projCntNew, eleProjCnt, eleNum); + if (FlagRBM) { + UpdateRBMCnt(rl, rk, t, rbmCntNew, rbmCnt, eleNum); + } eleIdx[msj] = ri; eleNum[rsj] = 0; eleNum[rsi] = 1; UpdateProjCnt(rj, ri, s, projCntNew, projCntNew, eleNum); + if (FlagRBM) { + UpdateRBMCnt(rj, ri, s, rbmCntNew, rbmCntNew, eleNum); + } z = ProjRatio(projCntNew,eleProjCnt); + if (FlagRBM) { + z *= RBMRatio(rbmCntNew,rbmCnt); + } /* calculate Pfaffian */ CalculateNewPfMTwo_fcmp(ml, t, mj, s, pfMNew, eleIdx, 0, NQPFull, bufV); @@ -172,7 +191,7 @@ double complex GreenFunc2(const int ri, const int rj, const int rk, const int rl double complex GreenFuncN(const int n, int *rsi, int *rsj, const double complex ip, int *eleIdx, const int *eleCfg, int *eleNum, const int *eleProjCnt, - double complex *buffer, int *bufferInt){ + const double complex *rbmCnt, double complex *rbmCntNew, double complex *buffer, int *bufferInt){ int ri,rj,rk,rl,si,sj,sk,mj; int k,l,m,rsk; double complex z,x; @@ -195,7 +214,7 @@ double complex GreenFuncN(const int n, int *rsi, int *rsj, const double complex ri = rsi[0]%Nsite; rj = rsj[0]%Nsite; si = rsi[0]/Nsite; - return GreenFunc1(ri,rj,si,ip,eleIdx,eleCfg,eleNum,eleProjCnt,projCntNew,buffer); + return GreenFunc1(ri,rj,si,ip,eleIdx,eleCfg,eleNum,eleProjCnt,projCntNew,rbmCnt,rbmCntNew,buffer); } else if(n==2) { ri = rsi[0]%Nsite; rj = rsj[0]%Nsite; @@ -203,7 +222,7 @@ double complex GreenFuncN(const int n, int *rsi, int *rsj, const double complex rk = rsi[1]%Nsite; rl = rsj[1]%Nsite; sk = rsi[1]/Nsite; - return GreenFunc2(ri,rj,rk,rl,si,sk,ip,eleIdx,eleCfg,eleNum,eleProjCnt,projCntNew,buffer); + return GreenFunc2(ri,rj,rk,rl,si,sk,ip,eleIdx,eleCfg,eleNum,eleProjCnt,projCntNew,rbmCnt,rbmCntNew,buffer); } /* reduction */ @@ -218,7 +237,7 @@ double complex GreenFuncN(const int n, int *rsi, int *rsj, const double complex rsi[m] = rsi[m+1]; rsj[m] = rsj[m+1]; } - return GreenFuncN(n-1,rsi,rsj,ip,eleIdx,eleCfg,eleNum,eleProjCnt,buffer,bufferInt); + return GreenFuncN(n-1,rsi,rsj,ip,eleIdx,eleCfg,eleNum,eleProjCnt,rbmCnt,rbmCntNew,buffer,bufferInt); } /* rsj[k] == rsj[l] */ if(rsk==rsj[l]) return 0; @@ -234,7 +253,7 @@ double complex GreenFuncN(const int n, int *rsi, int *rsj, const double complex rsi[m] = rsi[m+1]; rsj[m] = rsj[m+1]; } - return GreenFuncN(n-1,rsi,rsj,ip,eleIdx,eleCfg,eleNum,eleProjCnt,buffer,bufferInt); + return GreenFuncN(n-1,rsi,rsj,ip,eleIdx,eleCfg,eleNum,eleProjCnt,rbmCnt,rbmCntNew,buffer,bufferInt); } for(l=k+1;l/ */ -void LSLocalQ(const double complex h1, const double complex ip, int *eleIdx, int *eleCfg, int *eleNum, int *eleProjCnt, double complex *_LSLQ) +void LSLocalQ(const double complex h1, const double complex ip, int *eleIdx, int *eleCfg, int *eleNum, int *eleProjCnt, double complex *rbmCnt, double complex *_LSLQ) { double complex e0,h2; e0 = CalculateHamiltonian0(eleNum); /* V */ h2 = h1*e0; /* HV = (V+K+W)V */ - h2 += calculateHK(h1,ip,eleIdx,eleCfg,eleNum,eleProjCnt); - h2 += calculateHW(h1,ip,eleIdx,eleCfg,eleNum,eleProjCnt); + h2 += calculateHK(h1,ip,eleIdx,eleCfg,eleNum,eleProjCnt,rbmCnt); + h2 += calculateHW(h1,ip,eleIdx,eleCfg,eleNum,eleProjCnt,rbmCnt); /* calculate local Q (IQ) */ _LSLQ[0] = 1.0; /* I */ @@ -96,7 +95,7 @@ void LSLocalQ(const double complex h1, const double complex ip, int *eleIdx, int } /* Calculate / */ -void LSLocalCisAjs(const double complex h1, const double complex ip, int *eleIdx, int *eleCfg, int *eleNum, int *eleProjCnt) { +void LSLocalCisAjs(const double complex h1, const double complex ip, int *eleIdx, int *eleCfg, int *eleNum, int *eleProjCnt, double complex *rbmCnt) { const int nCisAjs=NCisAjs; double complex*lsLCisAjs = LSLCisAjs; double complex*localCisAjs = LocalCisAjs; @@ -115,13 +114,13 @@ void LSLocalCisAjs(const double complex h1, const double complex ip, int *eleIdx s = CisAjsIdx[idx][3]; /* calculate local HCisAjs */ - LSLCisAjs[idx+nCisAjs] = calHCA(ri,rj,s,h1,ip,eleIdx,eleCfg,eleNum,eleProjCnt); + LSLCisAjs[idx+nCisAjs] = calHCA(ri,rj,s,h1,ip,eleIdx,eleCfg,eleNum,eleProjCnt,rbmCnt); } return; } double complex calculateHK(const double complex h1, const double complex ip, int *eleIdx, int *eleCfg, - int *eleNum, int *eleProjCnt) { + int *eleNum, int *eleProjCnt, double complex *rbmCnt) { int idx,ri,rj,s; double complex val=0.0; @@ -129,8 +128,8 @@ double complex calculateHK(const double complex h1, const double complex ip, int ri = Transfer[idx][0]; rj = Transfer[idx][2]; s = Transfer[idx][3]; - - val -= ParaTransfer[idx] * calHCA(ri,rj,s,h1,ip,eleIdx,eleCfg,eleNum,eleProjCnt); + + val -= ParaTransfer[idx] * calHCA(ri,rj,s,h1,ip,eleIdx,eleCfg,eleNum,eleProjCnt,rbmCnt); /* Caution: negative sign */ } @@ -138,7 +137,7 @@ double complex calculateHK(const double complex h1, const double complex ip, int } double complex calculateHW(const double complex h1, const double complex ip, int *eleIdx, int *eleCfg, - int *eleNum, int *eleProjCnt) { + int *eleNum, int *eleProjCnt, double complex *rbmCnt) { int idx,ri,rj,s,rk,rl,t; double complex val=0.0,tmp; @@ -148,16 +147,16 @@ double complex calculateHW(const double complex h1, const double complex ip, int rj = PairHopping[idx][1]; val += ParaPairHopping[idx] - * calHCACA(ri,rj,ri,rj,0,1,h1,ip,eleIdx,eleCfg,eleNum,eleProjCnt); + * calHCACA(ri,rj,ri,rj,0,1,h1,ip,eleIdx,eleCfg,eleNum,eleProjCnt,rbmCnt); } /* Exchange Coupling */ for(idx=0;idx/ */ double complex calHCA(const int ri, const int rj, const int s, const double complex h1, const double complex ip, int *eleIdx, int *eleCfg, - int *eleNum, int *eleProjCnt) { + int *eleNum, int *eleProjCnt, double complex *rbmCnt) { int rsi=ri+s*Nsite; int rsj=rj+s*Nsite; double complex val; @@ -197,9 +196,9 @@ double complex calHCA(const int ri, const int rj, const int s, g = checkGF1(ri,rj,s,ip,eleIdx,eleCfg,eleNum); if(cabs(g)>1.0e-12) { - val = calHCA1(ri,rj,s,ip,eleIdx,eleCfg,eleNum,eleProjCnt); + val = calHCA1(ri,rj,s,ip,eleIdx,eleCfg,eleNum,eleProjCnt,rbmCnt); } else { - val = calHCA2(ri,rj,s,ip,eleIdx,eleCfg,eleNum,eleProjCnt); + val = calHCA2(ri,rj,s,ip,eleIdx,eleCfg,eleNum,eleProjCnt,rbmCnt); } return val; @@ -236,10 +235,11 @@ double complex checkGF1(const int ri, const int rj, const int s, const double co /* calculate / = / * / */ double complex calHCA1(const int ri, const int rj, const int s, const double complex ip, int *eleIdx, int *eleCfg, - int *eleNum, int *eleProjCnt) { + int *eleNum, int *eleProjCnt, double complex *rbmCnt) { complex double *oldInvM; /* [NQPFull*Nsize*Nsize;] */ complex double *oldPfM; /* [NQPFull] */ int *projCntNew; + double complex *rbmCntNew; int rsi=ri+s*Nsite; int rsj=rj+s*Nsite; @@ -247,11 +247,14 @@ double complex calHCA1(const int ri, const int rj, const int s, double complex ipNew,z,e; RequestWorkSpaceInt(NProj); - RequestWorkSpaceComplex(NQPFull*(Nsize*Nsize+1)); + RequestWorkSpaceComplex(NQPFull*(Nsize*Nsize+1) + FlagRBM*(NRBM_PhysLayerIdx+Nneuron)); projCntNew = GetWorkSpaceInt(NProj); oldInvM = GetWorkSpaceComplex(NQPFull*Nsize*Nsize); oldPfM = GetWorkSpaceComplex(NQPFull); + if (FlagRBM) { + rbmCntNew = GetWorkSpaceComplex(NRBM_PhysLayerIdx + Nneuron); + } /* copy InvM and PfM */ copyMAll(InvM,PfM,oldInvM,oldPfM); @@ -265,12 +268,18 @@ double complex calHCA1(const int ri, const int rj, const int s, eleNum[rsi] = 1; UpdateProjCnt(rj, ri, s, projCntNew, eleProjCnt, eleNum); + if (FlagRBM) { + UpdateRBMCnt(rj, ri, s, rbmCntNew, rbmCnt, eleNum); + } z = ProjRatio(projCntNew,eleProjCnt); + if (FlagRBM) { + z *= RBMRatio(rbmCntNew,rbmCnt); + } UpdateMAll(mj,s,eleIdx,0,NQPFull); ipNew = CalculateIP_fcmp(PfM,0,NQPFull,MPI_COMM_SELF); - e = CalculateHamiltonian(ipNew,eleIdx,eleCfg,eleNum,projCntNew); + e = CalculateHamiltonian(ipNew,eleIdx,eleCfg,eleNum,projCntNew,rbmCntNew); /* revert hopping */ eleIdx[mj+s*Ne] = rj; @@ -291,7 +300,7 @@ double complex calHCA1(const int ri, const int rj, const int s, /* Assuming ri!=rj, eleNum[rsi]=1, eleNum[rsj]=0 */ double complex calHCA2(const int ri, const int rj, const int s, const double complex ip, int *eleIdx, int *eleCfg, - int *eleNum, int *eleProjCnt) { + int *eleNum, int *eleProjCnt, double complex *rbmCnt) { const int nsize=Nsize; const int nsite2=Nsite2; @@ -310,18 +319,22 @@ double complex calHCA2(const int ri, const int rj, const int s, double complex *myBuffer; double complex myValue=0; double complex v=0.0; + double complex *rbmCntNew, *myRBMCntNew; RequestWorkSpaceInt(NProj); /* for GreenFunc1 */ - RequestWorkSpaceComplex(NQPFull); /* for GreenFunc1 */ + RequestWorkSpaceComplex(NQPFull + FlagRBM*(NRBM_PhysLayerIdx+Nneuron)); /* for GreenFunc1 */ RequestWorkSpaceThreadInt(Nsize+Nsite2+NProj+6); - RequestWorkSpaceThreadComplex(NQPFull+3*Nsize); + RequestWorkSpaceThreadComplex(NQPFull+3*Nsize + FlagRBM*(NRBM_PhysLayerIdx+Nneuron)); bufferInt = GetWorkSpaceInt(NProj); buffer = GetWorkSpaceComplex(NQPFull); + if (FlagRBM) { + rbmCntNew = GetWorkSpaceComplex(NRBM_PhysLayerIdx+Nneuron); + } /* H0 term */ /* / = H0(x') / */ - g = GreenFunc1(ri,rj,s,ip,eleIdx,eleCfg,eleNum,eleProjCnt,bufferInt,buffer); + g = GreenFunc1(ri,rj,s,ip,eleIdx,eleCfg,eleNum,eleProjCnt,bufferInt,rbmCnt,rbmCntNew,buffer); /* hopping */ eleNum[rsi] = 1; @@ -336,7 +349,7 @@ double complex calHCA2(const int ri, const int rj, const int s, /* end of H0 term */ #pragma omp parallel default(shared)\ - private(myEleIdx,myEleNum,myBufferInt,myBuffer,myValue,myRsi,myRsj) \ + private(myRBMCntNew,myEleIdx,myEleNum,myBufferInt,myBuffer,myValue,myRsi,myRsj) \ reduction(+:v) { myEleIdx = GetWorkSpaceThreadInt(Nsize); @@ -345,6 +358,9 @@ double complex calHCA2(const int ri, const int rj, const int s, myRsi = GetWorkSpaceThreadInt(3); myRsj = GetWorkSpaceThreadInt(3); myBuffer = GetWorkSpaceThreadComplex(NQPFull+3*Nsize); + if (FlagRBM) { + myRBMCntNew = GetWorkSpaceThreadComplex(NRBM_PhysLayerIdx+Nneuron); + } #pragma loop noalias for(idx=0;idx1.0e-12) { - val = calHCACA1(ri,rj,rk,rl,si,sk,ip,eleIdx,eleCfg,eleNum,eleProjCnt); + val = calHCACA1(ri,rj,rk,rl,si,sk,ip,eleIdx,eleCfg,eleNum,eleProjCnt,rbmCnt); } else { - val = calHCACA2(ri,rj,rk,rl,si,sk,ip,eleIdx,eleCfg,eleNum,eleProjCnt); + val = calHCACA2(ri,rj,rk,rl,si,sk,ip,eleIdx,eleCfg,eleNum,eleProjCnt,rbmCnt); } return val; @@ -532,10 +548,11 @@ double complex checkGF2(const int ri, const int rj, const int rk, const int rl, double complex calHCACA1(const int ri, const int rj, const int rk, const int rl, const int si,const int sk, const double complex ip, int *eleIdx, int *eleCfg, - int *eleNum, int *eleProjCnt) { + int *eleNum, int *eleProjCnt, double complex *rbmCnt) { double complex *oldInvM; /* [NQPFull*Nsize*Nsize;] */ double complex *oldPfM; /* [NQPFull] */ int *projCntNew; + double complex *rbmCntNew; int rsi=ri+si*Nsite; int rsj=rj+si*Nsite; @@ -545,11 +562,14 @@ double complex calHCACA1(const int ri, const int rj, const int rk, const int rl, double complex ipNew,z,e; RequestWorkSpaceInt(NProj); - RequestWorkSpaceComplex(NQPFull*(Nsize*Nsize+1)); + RequestWorkSpaceComplex(NQPFull*(Nsize*Nsize+1) + FlagRBM*(NRBM_PhysLayerIdx+Nneuron)); projCntNew = GetWorkSpaceInt(NProj); oldInvM = GetWorkSpaceComplex(NQPFull*Nsize*Nsize); oldPfM = GetWorkSpaceComplex(NQPFull); + if (FlagRBM) { + rbmCntNew = GetWorkSpaceComplex(NRBM_PhysLayerIdx + Nneuron); + } /* copy InvM and PfM */ copyMAll(InvM,PfM,oldInvM,oldPfM); @@ -562,6 +582,9 @@ double complex calHCACA1(const int ri, const int rj, const int rk, const int rl, eleNum[rsl] = 0; eleNum[rsk] = 1; UpdateProjCnt(rl, rk, sk, projCntNew, eleProjCnt, eleNum); + if (FlagRBM) { + UpdateRBMCnt(rl, rk, sk, rbmCntNew, rbmCnt, eleNum); + } /* The mj-th electron with spin si hops from rj to ri */ mj = eleCfg[rsj]; @@ -571,13 +594,19 @@ double complex calHCACA1(const int ri, const int rj, const int rk, const int rl, eleNum[rsj] = 0; eleNum[rsi] = 1; UpdateProjCnt(rj, ri, si, projCntNew, projCntNew, eleNum); + if (FlagRBM) { + UpdateRBMCnt(rj, ri, si, rbmCntNew, rbmCntNew, eleNum); + } z = ProjRatio(projCntNew,eleProjCnt); + if (FlagRBM) { + z *= RBMRatio(rbmCntNew,rbmCnt); + } UpdateMAllTwo_fcmp(ml, sk, mj, si, rl, rj, eleIdx, 0, NQPFull); ipNew = CalculateIP_fcmp(PfM,0,NQPFull,MPI_COMM_SELF); - e = CalculateHamiltonian(ipNew,eleIdx,eleCfg,eleNum,projCntNew); + e = CalculateHamiltonian(ipNew,eleIdx,eleCfg,eleNum,projCntNew,rbmCnt); /* revert hopping */ eleIdx[mj+si*Ne] = rj; @@ -597,14 +626,19 @@ double complex calHCACA1(const int ri, const int rj, const int rk, const int rl, ReleaseWorkSpaceInt(); ReleaseWorkSpaceComplex(); - return e*z*ipNew/ip; + if (FlagRBM) { + return e*conj(z*ipNew/ip); + } + else { + return e*z*ipNew/ip; + } } /* calculate / for /=0 */ /* Assuming ri,rj,rk,rl are different, eleNum[rsi]=1, eleNum[rsj]=0, eleNum[rsk]=1, eleNum[rsl]=0 */ double complex calHCACA2(const int ri, const int rj, const int rk, const int rl, const int si,const int sk, - const double complex ip, int *eleIdx, int *eleCfg, int *eleNum, int *eleProjCnt) { + const double complex ip, int *eleIdx, int *eleCfg, int *eleNum, int *eleProjCnt, double complex *rbmCnt) { const int nsize=Nsize; const int nsite2=Nsite2; @@ -625,19 +659,23 @@ double complex calHCACA2(const int ri, const int rj, const int rk, const int rl, double complex *myBuffer; double complex myValue=0.0; double complex v=0.0; + double complex *rbmCntNew, *myRBMCntNew; RequestWorkSpaceInt(NProj); /* for GreenFunc2 */ - RequestWorkSpaceComplex(NQPFull+2*Nsize); /* for GreenFunc2 */ + RequestWorkSpaceComplex(NQPFull+2*Nsize + FlagRBM * (NRBM_PhysLayerIdx+Nneuron)); /* for GreenFunc1 */ RequestWorkSpaceThreadInt(Nsize+Nsite2+NProj+8); - RequestWorkSpaceThreadComplex(NQPFull+3*Nsize); + RequestWorkSpaceThreadComplex(NQPFull+3*Nsize + FlagRBM * (NRBM_PhysLayerIdx+Nneuron)); bufferInt = GetWorkSpaceInt(NProj); buffer = GetWorkSpaceComplex(NQPFull+2*Nsize); + if (FlagRBM) { + rbmCntNew = GetWorkSpaceComplex(NRBM_PhysLayerIdx+Nneuron); + } /* H0 term */ /* / = H0(x') / */ g = GreenFunc2(ri,rj,rk,rl,si,sk,ip, - eleIdx,eleCfg,eleNum,eleProjCnt,bufferInt,buffer); + eleIdx,eleCfg,eleNum,eleProjCnt,bufferInt,rbmCnt,myRBMCntNew,buffer); /* hopping */ eleNum[rsi] = 1; @@ -656,7 +694,7 @@ double complex calHCACA2(const int ri, const int rj, const int rk, const int rl, /* end of H0 term */ #pragma omp parallel default(shared)\ - private(myEleIdx,myEleNum,myBufferInt,myBuffer,myValue,myRsi,myRsj) \ + private(myRBMCntNew,myEleIdx,myEleNum,myBufferInt,myBuffer,myValue,myRsi,myRsj) \ reduction(+:v) { myEleIdx = GetWorkSpaceThreadInt(Nsize); @@ -665,6 +703,9 @@ double complex calHCACA2(const int ri, const int rj, const int rk, const int rl, myRsi = GetWorkSpaceThreadInt(4); myRsj = GetWorkSpaceThreadInt(4); myBuffer = GetWorkSpaceThreadComplex(NQPFull+4*Nsize); + if (FlagRBM) { + myRBMCntNew = GetWorkSpaceThreadComplex(NRBM_PhysLayerIdx+Nneuron); + } #pragma loop noalias for(idx=0;idxcreal(optSize2)) ? (int)creal(optSize1) : (int)creal(optSize2); return lwork; @@ -135,7 +129,6 @@ int calculateMAll_child_fsz(const int *eleIdx,const int *eleSpn, const int qpSta int msi,msj; int rsi,rsj; - char uplo='U', mthd='P'; int m,n,nsq,one,lda,info=0; //int nspn = 2*Ne+2*Nsite+2*Nsite+NProj; this is useful? double complex pfaff,minus_one; @@ -147,60 +140,40 @@ int calculateMAll_child_fsz(const int *eleIdx,const int *eleSpn, const int qpSta const double complex *sltE_i; double complex *invM = InvM + qpidx*Nsize*Nsize; - double complex *invM_i; - - double complex *bufM_i, *bufM_i2; + double complex *invM_i, *invM_i2; m=n=lda=Nsize; nsq=n*n; one=1; minus_one=-1.0; - /* store bufM */ - /* Note that bufM is column-major and skew-symmetric. */ - /* bufM[msj][msi] = -sltE[rsi][rsj] */ + /* store invM */ + /* Note that invM is column-major and skew-symmetric. */ + /* invM[msj][msi] = -sltE[rsi][rsj] */ #pragma loop noalias for(msi=0;msi InvM(T) -> -InvM */ M_ZSCAL(&nsq, &minus_one, invM, &one); -#endif return info; } @@ -254,7 +227,6 @@ int calculateMAll_child_fsz_real(const int *eleIdx,const int *eleSpn, const int int msi,msj; int rsi,rsj; - char uplo='U', mthd='P'; int m,n,lda,one,nsq,info=0; //int nspn = 2*Ne+2*Nsite+2*Nsite+NProj; this is useful? double pfaff,minus_one; @@ -266,61 +238,41 @@ int calculateMAll_child_fsz_real(const int *eleIdx,const int *eleSpn, const int const double *sltE_i; double *invM = InvM_real + qpidx*Nsize*Nsize; - double *invM_i; - - double *bufM_i, *bufM_i2; + double *invM_i, *invM_i2; m=n=lda=Nsize; nsq=n*n; one=1; minus_one=-1.0; - /* store bufM */ - /* Note that bufM is column-major and skew-symmetric. */ - /* bufM[msj][msi] = -sltE[rsi][rsj] */ + /* store invM */ + /* Note that invM is column-major and skew-symmetric. */ + /* invM[msj][msi] = -sltE[rsi][rsj] */ #pragma loop noalias for(msi=0;msi InvM(T) -> -InvM */ M_DSCAL(&nsq, &minus_one, invM, &one); -#endif return info; } @@ -384,7 +336,6 @@ int calculateMAll_child_fcmp(const int *eleIdx, const int qpStart, const int qpE int msi,msj; int rsi,rsj; - char uplo='U', mthd='P'; int m,n,nsq,lda,one,info=0; double complex pfaff,minus_one; @@ -395,61 +346,42 @@ int calculateMAll_child_fcmp(const int *eleIdx, const int qpStart, const int qpE const double complex *sltE_i; double complex *invM = InvM + qpidx*Nsize*Nsize; - double complex *invM_i; - - double complex *bufM_i, *bufM_i2; + double complex *invM_i, *invM_i2; m=n=lda=Nsize; nsq=n*n; one=1; minus_one=-1.0; - /* store bufM */ - /* Note that bufM is column-major and skew-symmetric. */ - /* bufM[msj][msi] = -sltE[rsi][rsj] */ + /* store invM */ + /* Note that invM is column-major and skew-symmetric. */ + /* invM[msj][msi] = -sltE[rsi][rsj] */ #pragma loop noalias for(msi=0;msi -InvM according antisymmetric properties. */ M_ZSCAL(&nsq, &minus_one, invM, &one); -#endif return info; } @@ -553,10 +485,6 @@ int calculateMAll_BF_fcmp_child( } } -#ifdef _pfaffine - info=0; /* Fused Pfaffian/inverse computation. */ - M_ZSKPFA(&uplo, &mthd, &n, bufM, &lda, &pfaff, iwork, work, &lwork/*, rwork*/, &info); -#else /* Pfaffian/inverse computed separately. */ /* Copy bufM to invM before using bufM to compute Pfaffian. */ for(msi=0;msi InvM(T) -> -InvM */ M_ZSCAL(&nsq, &minus_one, invM, &one); -#endif return info; } @@ -634,8 +554,6 @@ int CalculateMAll_real(const int *eleIdx, const int qpStart, const int qpEnd) { return info; } -//int calculateMAll_child_real(const int *eleIdx, const int qpStart, const int qpEnd, const int qpidx, -// double *bufM, int *iwork, double *work, int lwork) { int calculateMAll_child_real(const int *eleIdx, const int qpStart, const int qpEnd, const int qpidx, double *bufM, int *iwork, double *work, int lwork, double* PfM_real, double *InvM_real) { #pragma procedure serial @@ -654,60 +572,43 @@ int calculateMAll_child_real(const int *eleIdx, const int qpStart, const int qpE const double *sltE_i; double *invM = InvM_real + qpidx*Nsize*Nsize; - double *invM_i; - - double *bufM_i, *bufM_i2; + double *invM_i, *invM_i2; m=n=lda=Nsize; nsq=n*n; one=1; minus_one=-1.0; - /* store bufM */ - /* Note that bufM is column-major and skew-symmetric. */ - /* bufM[msj][msi] = -sltE[rsi][rsj] */ + /* store invM */ + /* Note that invM is column-major and skew-symmetric. */ + /* invM[msj][msi] = -sltE[rsi][rsj] */ #pragma loop noalias for(msi=0;msi InvM' = -InvM + // TODO: Include this in ltl2inv M_DSCAL(&nsq, &minus_one, invM, &one); -#endif return info; } @@ -793,14 +694,10 @@ int calculateMAll_BF_real_child(const int *eleIdx, const int qpStart, const int } } -#ifdef _pfaffine - info=0; /* Fused Pfaffian/inverse computation. */ -#else /* Pfaffian/inverse computed separately. */ /* Copy bufM to invM before using bufM to compute Pfaffian. */ for(msi=0;msi InvM' = -InvM M_DSCAL(&nsq, &minus_one, invM, &one); -#endif return info; } diff --git a/src/mVMC/parameter.c b/src/mVMC/parameter.c index 9167c941..56c7cf8d 100644 --- a/src/mVMC/parameter.c +++ b/src/mVMC/parameter.c @@ -37,9 +37,31 @@ void InitParameter() { //printf("AllComplexFlag=%d \n",AllComplexFlag); #pragma omp parallel for default(shared) private(i) for(i=0;i 0){ //TBC + RBM[i] = 0.01*(genrand_real2() -0.5)/(double)Nneuron; /* uniform distribution [0,1) */ + } else { + RBM[i] = 0.0; + } + } + }else{ + for(i=0;i 0){ //TBC + RBM[i] = 1e-2*genrand_real2()*cexp(2.0*I*M_PI*genrand_real2()); + //RBM[i] = 1e-2*genrand_real2()*cexp(2.0*I*M_PI*genrand_real2())/(double)Nneuron; + } else { + RBM[i] = 0.0; + } + } + } + } + if(AllComplexFlag==0){ for(i=0;i 0){ //TBC + if(OptFlag[2*i+2*NProj + 2*FlagRBM*NRBM] > 0){ //TBC Slater[i] = 2*(genrand_real2()-0.5); /* uniform distribution [-1,1) */ //Slater[i] = 1*genrand_real2(); /* uniform distribution [0,1) */ //Slater[i] += 1*I*genrand_real2(); /* uniform distribution [0,1) */ @@ -51,7 +73,7 @@ void InitParameter() { } else{ for(i=0;i 0){ //TBC + if(OptFlag[2*i+2*NProj + 2*FlagRBM*NRBM] > 0){ //TBC Slater[i] = 2*(genrand_real2()-0.5); /* uniform distribution [-1,1) */ Slater[i] += 2*I*(genrand_real2()-0.5); /* uniform distribution [-1,1) */ Slater[i] /=sqrt(2.0); @@ -60,8 +82,8 @@ void InitParameter() { Slater[i] = 0.0; } } - } + for(i=0;i Nneuron) hiend = Nneuron; + zz=1.0; +#pragma omp parallel default(shared) private(hi,RbmCntNew,RbmCntOld,zzTmp,icnt) firstprivate(NRBM_PhysLayerIdx,Nneuron) reduction(+:z) reduction(*:zz) + { + icnt=0; +#pragma loop swp +#pragma omp for + for(hi=hist;hi Nneuron) hiend = Nneuron; + zz=1.0; +#pragma omp parallel default(shared) private(hi,RbmCntNew,RbmCntOld,zzTmp,icnt) firstprivate(NRBM_PhysLayerIdx,Nneuron) reduction(+:z) reduction(*:zz) + { + icnt=0; +#pragma loop swp +#pragma omp for + for(hi=hist;hi0) { + for(ri=0;ri0) { + offset = NChargeRBM_PhysLayerIdx; + for(ri=0;ri0) { + offset = NChargeRBM_PhysLayerIdx + NSpinRBM_PhysLayerIdx; + for(ri=0;ri