diff --git a/.github/actions/build-wheel/entrypoint.sh b/.github/actions/build-wheel/entrypoint.sh index 2d1c0b32..b4dbb8af 100755 --- a/.github/actions/build-wheel/entrypoint.sh +++ b/.github/actions/build-wheel/entrypoint.sh @@ -21,6 +21,8 @@ elif [ "${PYTHON_VERSION}" = "3.11" ]; then PY_VER=cp311-cp311 elif [ "${PYTHON_VERSION}" = "3.12" ]; then PY_VER=cp312-cp312 +elif [ "${PYTHON_VERSION}" = "3.13-dev" ]; then + PY_VER=cp313-cp313 fi PY_EXE=/opt/python/"${PY_VER}"/bin/python3 @@ -35,9 +37,9 @@ $(cat $(which auditwheel) | head -1 | awk -F'!' '{print $2}') -m pip install set if [ "${PARALLEL}" = "mpi" ]; then yum install -y wget openssh-clients openssh-server - wget https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.6.tar.gz - tar zxf openmpi-4.1.6.tar.gz - cd openmpi-4.1.6 + wget https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-5.0.5.tar.gz + tar zxf openmpi-5.0.5.tar.gz + cd openmpi-5.0.5 ./configure --prefix=/usr/local |& tee config.out make -j 4 |& tee make.out make install |& tee install.out diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ad387b25..ef7acd00 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,12 +23,14 @@ jobs: strategy: matrix: - os: [ ubuntu-20.04, macos-12, windows-2022 ] - python: [ 3.12 ] + os: [ ubuntu-20.04, macos-13, macos-14, windows-2022 ] + python: [ '3.13-dev' ] plat: [ x86_64 ] - parallel: [ mpi, serial, serial-pytest, any-symm-pytest ] + parallel: [ mpi, serial, serial-pytest, any-symm-pytest, main-test ] exclude: - - os: macos-12 + - os: macos-13 + parallel: mpi + - os: macos-14 parallel: mpi - os: windows-2022 parallel: mpi @@ -41,13 +43,19 @@ jobs: python-version: ${{ matrix.python }} - name: install requirements (linux / macos) - if: matrix.os == 'macos-12' || matrix.os == 'ubuntu-20.04' + if: matrix.os == 'macos-13' || matrix.os == 'ubuntu-20.04' env: MKLROOT: ~/.local run: | python -m pip install pip build twine setuptools --upgrade python -m pip install mkl==2021.4 mkl-include intel-openmp numpy 'cmake>=3.19' pybind11==2.12.0 + - name: install requirements (linux / macos) + if: matrix.os == 'macos-14' + run: | + python -m pip install pip build twine setuptools --upgrade + python -m pip install numpy 'cmake>=3.19' pybind11==2.12.0 + - name: install requirements (linux / mpi) if: matrix.parallel == 'mpi' && matrix.os == 'ubuntu-20.04' run: | @@ -110,7 +118,7 @@ jobs: getconf LONG_BIT - name: build gtest (macos) - if: matrix.os == 'macos-12' + if: matrix.os == 'macos-13' env: HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 run: | @@ -123,11 +131,25 @@ jobs: brew install libomp cp /usr/local/opt/libomp/include/*.h /usr/local/include/ + - name: build gtest (macos) + if: matrix.os == 'macos-14' + env: + GTESTROOT: ~/gtest + HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 + run: | + git clone -b release-1.8.0 https://github.com/google/googletest + cd googletest + cmake CMakeLists.txt -DCMAKE_INSTALL_PREFIX=${GTESTROOT} + make + make install + brew update + brew install libomp + - name: build test (serial-pytest, linux | macos) - if: matrix.parallel == 'serial-pytest' && (matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-12') + if: (matrix.parallel == 'serial-pytest' || matrix.parallel == 'main-test') && (matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-13') env: MKLROOT: ~/.local - MACOSX_DEPLOYMENT_TARGET: '10.9' + MACOSX_DEPLOYMENT_TARGET: '11.0' CC: gcc-9 CXX: g++-9 run: | @@ -137,8 +159,24 @@ jobs: cmake .. -DUSE_MKL=ON -DBUILD_LIB=ON -DLARGE_BOND=ON -DUSE_COMPLEX=ON -DUSE_SG=ON make -j 2 + - name: build test (serial-pytest, macos-arm64) + if: (matrix.parallel == 'serial-pytest' || matrix.parallel == 'main-test') && matrix.os == 'macos-14' + env: + MACOSX_DEPLOYMENT_TARGET: '11.0' + CC: gcc-9 + CXX: g++-9 + run: | + mkdir build + cd build + cmake --version + export OMPROOT=$(brew --prefix libomp) + cmake .. -DUSE_MKL=OFF -DARCH_ARM64=ON -DCMAKE_CXX_FLAGS=-I${OMPROOT}/include -DOMP_LIB=OMP \ + -DBUILD_LIB=ON -DLARGE_BOND=ON -DUSE_COMPLEX=ON -DUSE_SG=ON -DFORCE_LIB_ABS_PATH=OFF \ + -DAPPLE_ACC_SINGLE_PREC=OFF + make -j 2 + - name: build test (serial-pytest, windows) - if: matrix.parallel == 'serial-pytest' && matrix.os == 'windows-2022' + if: (matrix.parallel == 'serial-pytest' || matrix.parallel == 'main-test') && matrix.os == 'windows-2022' env: BLAS_ROOT: D:\a\openblas run: | @@ -150,10 +188,10 @@ jobs: cmake --build . -j 2 --config Release -- '/v:d' - name: build test (any-symm-pytest, linux | macos) - if: matrix.parallel == 'any-symm-pytest' && (matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-12') + if: matrix.parallel == 'any-symm-pytest' && (matrix.os == 'ubuntu-20.04' || matrix.os == 'macos-13') env: MKLROOT: ~/.local - MACOSX_DEPLOYMENT_TARGET: '10.9' + MACOSX_DEPLOYMENT_TARGET: '11.0' CC: gcc-9 CXX: g++-9 run: | @@ -163,6 +201,22 @@ jobs: cmake .. -DUSE_MKL=ON -DBUILD_LIB=ON -DLARGE_BOND=ON -DUSE_COMPLEX=ON -DUSE_SU2SZ=OFF -DUSE_SANY=ON make -j 2 + - name: build test (any-symm-pytest, macos-arm64) + if: matrix.parallel == 'any-symm-pytest' && matrix.os == 'macos-14' + env: + MACOSX_DEPLOYMENT_TARGET: '11.0' + CC: gcc-9 + CXX: g++-9 + run: | + mkdir build + cd build + cmake --version + export OMPROOT=$(brew --prefix libomp) + cmake .. -DUSE_MKL=OFF -DARCH_ARM64=ON -DCMAKE_CXX_FLAGS=-I${OMPROOT}/include -DBUILD_LIB=ON -DOMP_LIB=OMP \ + -DLARGE_BOND=ON -DUSE_COMPLEX=ON -DUSE_SU2SZ=OFF -DUSE_SANY=ON -DFORCE_LIB_ABS_PATH=OFF \ + -DAPPLE_ACC_SINGLE_PREC=OFF + make -j 2 + - name: build test (any-symm-pytest, windows) if: matrix.parallel == 'any-symm-pytest' && matrix.os == 'windows-2022' env: @@ -201,10 +255,10 @@ jobs: make -j 2 - name: build test (serial, macos) - if: matrix.parallel == 'serial' && matrix.os == 'macos-12' + if: matrix.parallel == 'serial' && matrix.os == 'macos-13' env: MKLROOT: ~/.local - MACOSX_DEPLOYMENT_TARGET: '10.9' + MACOSX_DEPLOYMENT_TARGET: '11.0' run: | mkdir build_test cd build_test @@ -212,6 +266,21 @@ jobs: cmake .. -DUSE_MKL=ON -DBUILD_TEST=ON -DLARGE_BOND=ON -DUSE_COMPLEX=ON -DUSE_SINGLE_PREC=ON -DUSE_SG=ON make -j 2 + - name: build test (serial, macos-arm64) + if: matrix.parallel == 'serial' && matrix.os == 'macos-14' + env: + GTESTROOT: ~/gtest + MACOSX_DEPLOYMENT_TARGET: '11.0' + run: | + mkdir build_test + cd build_test + cmake --version + export OMPROOT=$(brew --prefix libomp) + cmake .. -DUSE_MKL=OFF -DARCH_ARM64=ON -DCMAKE_CXX_FLAGS=-I${OMPROOT}/include -DBUILD_TEST=ON -DOMP_LIB=OMP \ + -DLARGE_BOND=ON -DUSE_COMPLEX=ON -DUSE_SINGLE_PREC=OFF -DUSE_SG=ON -DGTEST_ROOT=${GTESTROOT} \ + -DFORCE_LIB_ABS_PATH=OFF -DSIMPLE_TEST=ON + make -j 2 + - name: run test (serial, windows) if: matrix.parallel == 'serial' && matrix.os == 'windows-2022' env: @@ -238,7 +307,7 @@ jobs: ./block2_tests - name: run test (serial, macos) - if: matrix.parallel == 'serial' && matrix.os == 'macos-12' + if: matrix.parallel == 'serial' && (matrix.os == 'macos-13' || matrix.os == 'macos-14') run: | cd build_test ./block2_tests @@ -250,7 +319,7 @@ jobs: run: | $vcpath = Get-ChildItem 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC' $dumpbin = "$($vcpath[0].FullName)\bin\Hostx64\x64\dumpbin.exe" - & $dumpbin /DEPENDENTS .\build\Release\block2.cp312-win_amd64.pyd + & $dumpbin /DEPENDENTS .\build\Release\block2.cp313-win_amd64.pyd $xpwd = Get-Location $env:PYTHONPATH = "${xpwd};${xpwd}\build\Release;" + $env:PYTHONPATH $env:PATH = "${env:BLAS_ROOT}\bin;" + $env:PATH @@ -263,7 +332,7 @@ jobs: - name: run test (serial-pytest, linux) if: matrix.parallel == 'serial-pytest' && matrix.os == 'ubuntu-20.04' run: | - python -m pip install pytest 'pyscf==2.5.0' 'scipy==1.12.0' + python -m pip install pytest 'pyscf==2.6.2' 'scipy==1.14.1' export PYTHONPATH=$(pwd)/build:$(pwd):${PYTHONPATH} export CPUTYPE=$(lscpu | grep 'Vendor ID' | awk '{print $3}') if [ "$CPUTYPE" = "AuthenticAMD" ]; then @@ -273,12 +342,54 @@ jobs: py.test -s pyblock2/unit_test/*.py - name: run test (serial-pytest, macos) - if: matrix.parallel == 'serial-pytest' && matrix.os == 'macos-12' + if: matrix.parallel == 'serial-pytest' && (matrix.os == 'macos-13' || matrix.os == 'macos-14') run: | - python -m pip install pytest 'pyscf==2.5.0' 'scipy==1.12.0' + python -m pip install pytest 'pyscf==2.6.2' 'scipy==1.14.1' export PYTHONPATH=$(pwd)/build:$(pwd):${PYTHONPATH} py.test -s pyblock2/unit_test/*.py + - name: run test (main-test, windows) + if: matrix.parallel == 'main-test' && matrix.os == 'windows-2022' + env: + BLAS_ROOT: D:\a\openblas + run: | + $vcpath = Get-ChildItem 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC' + $dumpbin = "$($vcpath[0].FullName)\bin\Hostx64\x64\dumpbin.exe" + & $dumpbin /DEPENDENTS .\build\Release\block2.cp313-win_amd64.pyd + $xpwd = Get-Location + $env:PYTHONPATH = "${xpwd};${xpwd}\build\Release;" + $env:PYTHONPATH + $env:PATH = "${env:BLAS_ROOT}\bin;" + $env:PATH + $env:PATH = "${env:Python_ROOT_DIR}\Library\bin;" + $env:PATH + $env:PATH = "${env:Python_ROOT_DIR};" + $env:PATH + $env:PATH = "$($vcpath[0].FullName)\bin\Hostx64\x64;" + $env:PATH + $env:block2main = "${xpwd}\pyblock2\driver\block2main" + python -m pip install 'scipy==1.14.1' + cd pyblock2\main_test + .\run-test.ps1 + + - name: run test (main-test, linux) + if: matrix.parallel == 'main-test' && matrix.os == 'ubuntu-20.04' + run: | + python -m pip install pytest 'pyscf==2.6.2' 'scipy==1.14.1' + export PYTHONPATH=$(pwd)/build:$(pwd):${PYTHONPATH} + export PATH=$(pwd)/pyblock2/driver:$PATH + export CPUTYPE=$(lscpu | grep 'Vendor ID' | awk '{print $3}') + if [ "$CPUTYPE" = "AuthenticAMD" ]; then + export LD_PRELOAD=$PWD/libfixcpu.so + fi + echo $LD_PRELOAD + cd pyblock2/main_test + ./run-test.sh + + - name: run test (main-test, macos) + if: matrix.parallel == 'main-test' && (matrix.os == 'macos-13' || matrix.os == 'macos-14') + run: | + python -m pip install pytest 'pyscf==2.6.2' 'scipy==1.14.1' + export PYTHONPATH=$(pwd)/build:$(pwd):${PYTHONPATH} + export PATH=$(pwd)/pyblock2/driver:$PATH + cd pyblock2/main_test + ./run-test.sh + - name: run test (any-symm-pytest, windows) if: matrix.parallel == 'any-symm-pytest' && matrix.os == 'windows-2022' env: @@ -286,7 +397,7 @@ jobs: run: | $vcpath = Get-ChildItem 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC' $dumpbin = "$($vcpath[0].FullName)\bin\Hostx64\x64\dumpbin.exe" - & $dumpbin /DEPENDENTS .\build\Release\block2.cp312-win_amd64.pyd + & $dumpbin /DEPENDENTS .\build\Release\block2.cp313-win_amd64.pyd $xpwd = Get-Location $env:PYTHONPATH = "${xpwd};${xpwd}\build\Release;" + $env:PYTHONPATH $env:PATH = "${env:BLAS_ROOT}\bin;" + $env:PATH @@ -299,7 +410,7 @@ jobs: - name: run test (any-symm-pytest, linux) if: matrix.parallel == 'any-symm-pytest' && matrix.os == 'ubuntu-20.04' run: | - python -m pip install pytest 'pyscf==2.5.0' 'scipy==1.12.0' + python -m pip install pytest 'pyscf==2.6.2' 'scipy==1.14.1' export PYTHONPATH=$(pwd)/build:$(pwd):${PYTHONPATH} export CPUTYPE=$(lscpu | grep 'Vendor ID' | awk '{print $3}') if [ "$CPUTYPE" = "AuthenticAMD" ]; then @@ -309,9 +420,9 @@ jobs: py.test -s pyblock2/unit_test/*.py --symm sany - name: run test (any-symm-pytest, macos) - if: matrix.parallel == 'any-symm-pytest' && matrix.os == 'macos-12' + if: matrix.parallel == 'any-symm-pytest' && (matrix.os == 'macos-13' || matrix.os == 'macos-14') run: | - python -m pip install pytest 'pyscf==2.5.0' 'scipy==1.12.0' + python -m pip install pytest 'pyscf==2.6.2' 'scipy==1.14.1' export PYTHONPATH=$(pwd)/build:$(pwd):${PYTHONPATH} py.test -s pyblock2/unit_test/*.py --symm sany @@ -342,17 +453,17 @@ jobs: strategy: matrix: - os: [ ubuntu-20.04, macos-12, windows-2022, macos-14 ] - python: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ] + os: [ ubuntu-20.04, macos-13, windows-2022, macos-14 ] + python: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13-dev' ] manylinux: [ 2014 ] plat: [ x86_64, arm64 ] parallel: [ mpi, serial ] exclude: - - os: macos-12 + - os: macos-13 parallel: mpi - os: macos-14 parallel: mpi - - os: macos-12 + - os: macos-13 plat: arm64 - os: macos-14 plat: x86_64 @@ -373,7 +484,7 @@ jobs: python-version: ${{ matrix.python }} - name: install requirements (linux / macos) - if: matrix.os == 'macos-12' || matrix.os == 'ubuntu-20.04' + if: matrix.os == 'macos-13' || matrix.os == 'ubuntu-20.04' env: MKLROOT: ~/.local run: | @@ -430,10 +541,10 @@ jobs: delvewheel repair "$($rr[0].FullName)" -v -w dist - name: build wheels (macos-x86_64) - if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'macos-12' && matrix.plat == 'x86_64' + if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'macos-13' && matrix.plat == 'x86_64' env: TAG_STRING: ${{ github.event.ref }} - MACOSX_DEPLOYMENT_TARGET: '10.9' + MACOSX_DEPLOYMENT_TARGET: '11.0' HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 run: | brew update @@ -534,7 +645,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.12 + python-version: '3.13-dev' - name: build source dist (serial) env: @@ -596,7 +707,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.12 + python-version: '3.13-dev' - name: build source dist (serial) env: diff --git a/CMakeLists.txt b/CMakeLists.txt index 8879d231..f0de56bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,7 @@ OPTION(USE_PCH "Build precompiled headers" ON) OPTION(FORCE_LIB_ABS_PATH "Using absolute path when linking libraries" ON) # For BUILD_CLIB, local static variables may vaiolate ODR in .so and .exe. OPTION(USE_GLOBAL_VARIABLE "Use global variable instead of local static ones" ON) +OPTION(SIMPLE_TEST "Only compile basic unit tests" OFF) IF (NOT ${USE_DMRG}) SET(USE_BIG_SITE OFF) @@ -785,7 +786,11 @@ IF (${BUILD_TEST}) FIND_PACKAGE(GTest REQUIRED) INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS}) - FILE(GLOB TSRCS unit_test/test_*.cpp) + IF (${SIMPLE_TEST}) + FILE(GLOB TSRCS unit_test/test_wick_*.cpp unit_test/test_npdm_*.cpp unit_test/test_dmrg_*.cpp) + ELSE() + FILE(GLOB TSRCS unit_test/test_*.cpp) + ENDIF() MESSAGE(STATUS "TSRCS = ${TSRCS}") IF ((NOT APPLE) AND (NOT WIN32)) diff --git a/README.md b/README.md index 1bd55781..3eede7a7 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ One can install ``block2`` using ``pip`` (note: for very new Python versions, th pip install block2 -* Hybrid openMP/MPI version (requiring openMPI 4.1.x) +* Hybrid openMP/MPI version (requiring openMPI 5.0.x for ``block2-mpi >= 0.5.3`` or 4.1.x for ``block2-mpi <= 0.5.2`` and ``block2-mpi <= 0.5.3rc19``) pip install block2-mpi diff --git a/docs/source/user/advanced.rst b/docs/source/user/advanced.rst index 280b41bf..de69cc9e 100644 --- a/docs/source/user/advanced.rst +++ b/docs/source/user/advanced.rst @@ -104,6 +104,7 @@ The following input file is used for this step: :: spin 0 irrep 1 + hf_occ integral schedule 0 1000 0 0 end diff --git a/docs/source/user/installation.rst b/docs/source/user/installation.rst index 0f4c662f..2ad6f371 100644 --- a/docs/source/user/installation.rst +++ b/docs/source/user/installation.rst @@ -15,7 +15,7 @@ One can install ``block2`` using ``pip``: pip install block2 -* Hybrid openMP/MPI version (requiring openMPI 4.1.x) :: +* Hybrid openMP/MPI version (requiring openMPI 5.0.x for ``block2-mpi >= 0.5.3`` or 4.1.x for ``block2-mpi <= 0.5.2`` and ``block2-mpi <= 0.5.3rc19``) :: pip install block2-mpi diff --git a/pyblock2/driver/block2main b/pyblock2/driver/block2main index eebbe9aa..28b407fd 100755 --- a/pyblock2/driver/block2main +++ b/pyblock2/driver/block2main @@ -26,6 +26,14 @@ Author: Zhi-Hao Cui """ +import os +import sys + +if os.name == "nt" and sys.version_info[1] >= 8: + for path in os.environ["PATH"].split(";"): + if path != "" and os.path.exists(os.path.abspath(path)): + os.add_dll_directory(os.path.abspath(path)) + from block2 import SZ, SU2, SZK, SU2K, SGF, DoubleFPCodec as FPCodec from block2 import Global, OpNamesSet, NoiseTypes, DecompositionTypes, Threading, ThreadingTypes from block2 import init_memory, release_memory, set_mkl_num_threads, read_occ, TruncationTypes @@ -1431,7 +1439,7 @@ if "statespecific" in dic and "proj_weights" in dic: # prepare mps if len(mps_tags) > 1 or ("compression" in dic and "random_mps_init" not in dic) \ - or "stopt_sampling" in dic: + or "stopt_sampling" in dic or "delta_t" in dic: nroots = len(mps_tags) mps = None mps_info = None @@ -2599,7 +2607,7 @@ if not pre_run: '--', linewidth=1, color='#5FA8AB') plt.plot(ext_dws, ext_eners, 'o', color='#38686A', markerfacecolor='white', markersize=5) - plt.text(ddw / 12, emax, "$E(M=\\infty) = %.6f \pm %.6f \\mathrm{\\ Hartree}$" % + plt.text(ddw / 12, emax, "$E(M=\\infty) = %.6f \\pm %.6f \\mathrm{\\ Hartree}$" % (reg.intercept, abs(reg.intercept - emin) / 5), color='#38686A', fontsize=12) plt.text(ddw / 12, emax - de / 12, "$R^2 = %.6f$" % (reg.rvalue ** 2), color='#38686A', fontsize=12) @@ -4366,9 +4374,34 @@ if not pre_run: "A tag name must be given for the keyword copy_mps/restart_copy_mps!") if "trans_mps_to_sz" in dic: assert "nonspinadapted" not in dic - mps.info.load_mutable() - mps.load_mutable() - cp_mps = trans_mps(UnfusedMPS(mps), copy_tag, mpo.tf.opf.cg) + + if mps.center != 0: + xmps = mps.deep_copy(copy_tag + "@TMP") + _print('change canonical form ...') + cf = str(xmps.canonical_form) + ime = MovingEnvironment(impo, xmps, xmps, "IEX") + ime.delayed_contraction = OpNamesSet.normal_ops() + ime.cached_contraction = cached_contraction + ime.init_environments(False) + if not complex_mps: + expect = Expect(ime, xmps.info.bond_dim, xmps.info.bond_dim) + else: + expect = ComplexExpect(ime, xmps.info.bond_dim, xmps.info.bond_dim) + expect.iprint = max(min(outputlevel, 3), 0) + expect.solve(True, xmps.center == 0) + if MPI is not None: + MPI.barrier() + xmps.save_data() + if MPI is not None: + MPI.barrier() + _print(cf + ' -> ' + xmps.canonical_form) + else: + xmps = mps + + xmps.info.load_mutable() + xmps.load_mutable() + targetz = TrSX(xmps.info.target.n, xmps.info.target.twos, xmps.info.target.pg) + cp_mps = trans_mps(UnfusedMPS(xmps), copy_tag, mpo.tf.opf.cg, targetz) if "resolve_twosz" in dic: res_twosz = int(dic["resolve_twosz"]) cp_mps.resolve_singlet_embedding(res_twosz) diff --git a/pyblock2/main_test/.gitignore b/pyblock2/main_test/.gitignore new file mode 100644 index 00000000..fa929750 --- /dev/null +++ b/pyblock2/main_test/.gitignore @@ -0,0 +1 @@ +*.out \ No newline at end of file diff --git a/pyblock2/main_test/000-check.py b/pyblock2/main_test/000-check.py new file mode 100644 index 00000000..fe4783dc --- /dev/null +++ b/pyblock2/main_test/000-check.py @@ -0,0 +1,9 @@ +import sys + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.654122447525) < 1E-6 diff --git a/pyblock2/main_test/000-main.in b/pyblock2/main_test/000-main.in new file mode 100644 index 00000000..d548b549 --- /dev/null +++ b/pyblock2/main_test/000-main.in @@ -0,0 +1,15 @@ +# Ground State DMRG + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 \ No newline at end of file diff --git a/pyblock2/main_test/001-check.py b/pyblock2/main_test/001-check.py new file mode 100644 index 00000000..36ae7608 --- /dev/null +++ b/pyblock2/main_test/001-check.py @@ -0,0 +1,9 @@ +import sys + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -106.959626154680) < 1E-6 diff --git a/pyblock2/main_test/001-main.in b/pyblock2/main_test/001-main.in new file mode 100644 index 00000000..ed1f5970 --- /dev/null +++ b/pyblock2/main_test/001-main.in @@ -0,0 +1,15 @@ +# DMRG Targeting States + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 4 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 diff --git a/pyblock2/main_test/002-check.py b/pyblock2/main_test/002-check.py new file mode 100644 index 00000000..ef9e02ca --- /dev/null +++ b/pyblock2/main_test/002-check.py @@ -0,0 +1,14 @@ +import sys, struct + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.654122447525) < 1E-6 + +with open('node0/dmrg.e', 'rb') as f: + a, b = struct.unpack('dd', f.read()) + assert abs(a - -107.654122447525) < 1E-5 + assert abs(b - -106.959626154680) < 1E-5 diff --git a/pyblock2/main_test/002-main.in b/pyblock2/main_test/002-main.in new file mode 100644 index 00000000..a7b160d5 --- /dev/null +++ b/pyblock2/main_test/002-main.in @@ -0,0 +1,17 @@ +# State-Average DMRG + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 +nroots 2 +weights 0.5 0.5 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 diff --git a/pyblock2/main_test/003-check.py b/pyblock2/main_test/003-check.py new file mode 100644 index 00000000..1a02d153 --- /dev/null +++ b/pyblock2/main_test/003-check.py @@ -0,0 +1,11 @@ +import sys + +energies = [0.0] * 2 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy for root'): + idx = int(l.split()[-3]) + energies[idx] = float(l.split()[-1]) + +assert abs(energies[0] - -107.654122447525) < 1E-5 +assert abs(energies[1] - -106.959626154680) < 1E-5 diff --git a/pyblock2/main_test/003-main.in b/pyblock2/main_test/003-main.in new file mode 100644 index 00000000..ae68f830 --- /dev/null +++ b/pyblock2/main_test/003-main.in @@ -0,0 +1,19 @@ +# State-Specific DMRG (ortho) +#DEP 2 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 +nroots 2 +weights 0.5 0.5 +statespecific + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 diff --git a/pyblock2/main_test/004-check.py b/pyblock2/main_test/004-check.py new file mode 100644 index 00000000..1a02d153 --- /dev/null +++ b/pyblock2/main_test/004-check.py @@ -0,0 +1,11 @@ +import sys + +energies = [0.0] * 2 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy for root'): + idx = int(l.split()[-3]) + energies[idx] = float(l.split()[-1]) + +assert abs(energies[0] - -107.654122447525) < 1E-5 +assert abs(energies[1] - -106.959626154680) < 1E-5 diff --git a/pyblock2/main_test/004-main.in b/pyblock2/main_test/004-main.in new file mode 100644 index 00000000..ba503984 --- /dev/null +++ b/pyblock2/main_test/004-main.in @@ -0,0 +1,20 @@ +# State-Specific DMRG (level-shift) +#DEP 2 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 +nroots 2 +weights 0.5 0.5 +statespecific +proj_weights 5 5 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 diff --git a/pyblock2/main_test/005-check.py b/pyblock2/main_test/005-check.py new file mode 100644 index 00000000..fe4783dc --- /dev/null +++ b/pyblock2/main_test/005-check.py @@ -0,0 +1,9 @@ +import sys + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.654122447525) < 1E-6 diff --git a/pyblock2/main_test/005-main.in b/pyblock2/main_test/005-main.in new file mode 100644 index 00000000..f018652d --- /dev/null +++ b/pyblock2/main_test/005-main.in @@ -0,0 +1,16 @@ +# Direct level-shift DMRG ground state + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +mps_tags KET1 +num_thrds 4 +sweep_tol 1E-14 diff --git a/pyblock2/main_test/006-check.py b/pyblock2/main_test/006-check.py new file mode 100644 index 00000000..36ae7608 --- /dev/null +++ b/pyblock2/main_test/006-check.py @@ -0,0 +1,9 @@ +import sys + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -106.959626154680) < 1E-6 diff --git a/pyblock2/main_test/006-main.in b/pyblock2/main_test/006-main.in new file mode 100644 index 00000000..68eb2a42 --- /dev/null +++ b/pyblock2/main_test/006-main.in @@ -0,0 +1,20 @@ +# Direct level-shift DMRG 1st excited state +#DEP 5 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +mps_tags KET2 +num_thrds 4 +sweep_tol 1E-14 + +proj_mps_tags KET1 +proj_weights 5 \ No newline at end of file diff --git a/pyblock2/main_test/007-check.py b/pyblock2/main_test/007-check.py new file mode 100644 index 00000000..dc5b5ff6 --- /dev/null +++ b/pyblock2/main_test/007-check.py @@ -0,0 +1,9 @@ +import sys + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -106.94375693899154) < 1E-6 diff --git a/pyblock2/main_test/007-main.in b/pyblock2/main_test/007-main.in new file mode 100644 index 00000000..f1553a10 --- /dev/null +++ b/pyblock2/main_test/007-main.in @@ -0,0 +1,20 @@ +# Direct level-shift DMRG 2st excited state +#DEP 5 6 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +mps_tags KET3 +num_thrds 4 +sweep_tol 1E-14 + +proj_mps_tags KET1 KET2 +proj_weights 5 5 \ No newline at end of file diff --git a/pyblock2/main_test/008-check.py b/pyblock2/main_test/008-check.py new file mode 100644 index 00000000..ef9e02ca --- /dev/null +++ b/pyblock2/main_test/008-check.py @@ -0,0 +1,14 @@ +import sys, struct + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.654122447525) < 1E-6 + +with open('node0/dmrg.e', 'rb') as f: + a, b = struct.unpack('dd', f.read()) + assert abs(a - -107.654122447525) < 1E-5 + assert abs(b - -106.959626154680) < 1E-5 diff --git a/pyblock2/main_test/008-main.in b/pyblock2/main_test/008-main.in new file mode 100644 index 00000000..37e55dd7 --- /dev/null +++ b/pyblock2/main_test/008-main.in @@ -0,0 +1,21 @@ +# DMRG Mixed with State-Average (step 1) + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 +nroots 2 +weights 0.5 0.5 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +mps_tags KET +num_thrds 4 +sweep_tol 1E-14 + +copy_mps +split_states diff --git a/pyblock2/main_test/009-check.py b/pyblock2/main_test/009-check.py new file mode 100644 index 00000000..dc84295c --- /dev/null +++ b/pyblock2/main_test/009-check.py @@ -0,0 +1,15 @@ +import sys, struct + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -106.94375693899154) < 1E-6 + +with open('node0/dmrg.e', 'rb') as f: + a, b, c = struct.unpack('ddd', f.read()) + assert abs(a - -106.9437569390) < 1E-5 + assert abs(b - -106.9304278080) < 1E-5 + assert abs(c - -106.8426967564) < 1E-5 diff --git a/pyblock2/main_test/009-main.in b/pyblock2/main_test/009-main.in new file mode 100644 index 00000000..be553779 --- /dev/null +++ b/pyblock2/main_test/009-main.in @@ -0,0 +1,25 @@ +# DMRG Mixed with State-Average (step 2) +#DEP 8 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 +nroots 3 +weights 0.5 0.5 0.5 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +mps_tags EXKET +num_thrds 4 +sweep_tol 1E-14 + +proj_mps_tags KET-0 KET-1 +proj_weights 5 5 + +copy_mps +split_states \ No newline at end of file diff --git a/pyblock2/main_test/010-check.py b/pyblock2/main_test/010-check.py new file mode 100644 index 00000000..1b78e590 --- /dev/null +++ b/pyblock2/main_test/010-check.py @@ -0,0 +1,9 @@ +import sys, struct + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -106.795333598887609) < 1E-6 diff --git a/pyblock2/main_test/010-main.in b/pyblock2/main_test/010-main.in new file mode 100644 index 00000000..1cfe09dc --- /dev/null +++ b/pyblock2/main_test/010-main.in @@ -0,0 +1,20 @@ +# DMRG Mixed with State-Average (step 3) +#DEP 8 9 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +mps_tags EXXKET +num_thrds 4 +sweep_tol 1E-14 + +proj_mps_tags KET-0 KET-1 EXKET-0 EXKET-1 EXKET-2 +proj_weights 5 5 5 5 5 diff --git a/pyblock2/main_test/011-check.py b/pyblock2/main_test/011-check.py new file mode 100644 index 00000000..965d5ebe --- /dev/null +++ b/pyblock2/main_test/011-check.py @@ -0,0 +1,43 @@ +import sys, os + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.654122447525) < 1E-6 + +if os.name == "nt": + quit() # pyscf not available on windows + +from pyblock2.driver.core import DMRGDriver, SymmetryTypes +from pyscf import fci +from pyscf.tools import fcidump +import numpy as np + +driver = DMRGDriver(scratch="./nodex", symm_type=SymmetryTypes.SU2, n_threads=4) +driver.read_fcidump(filename='../../data/N2.STO3G.FCIDUMP', pg='d2h', iprint=0) +driver.initialize_system(n_sites=driver.n_sites, n_elec=driver.n_elec, + spin=driver.spin, orb_sym=driver.orb_sym) +h1e, g2e, ecore = driver.h1e, driver.g2e, driver.ecore + +mf = fcidump.to_scf('../../data/N2.STO3G.FCIDUMP', molpro_orbsym=True) +mf.mol.symmetry = True + +mx = fci.FCI(mf) +mx.kernel(h1e, g2e, driver.n_sites, driver.n_elec, tol=1e-12, + wfnsym=0, orbsym=np.array(driver.orb_sym)) +assert abs(mx.e_tot + ecore - -107.654122447525) < 1E-6 + +dm1, dm2 = mx.make_rdm12(mx.ci, mf.mol.nao, mf.mol.nelec) + +xdm1 = np.load('./node0/1pdm.npy') +xdm1 = xdm1[0] + xdm1[1] + +assert np.linalg.norm(dm1 - xdm1) < 1E-5 + +xdm2 = np.load('./node0/2pdm.npy') +xdm2 = xdm2[0] + xdm2[2] + xdm2[1] + xdm2[1].transpose(1, 0, 3, 2) + +assert np.linalg.norm(dm2 - xdm2.transpose(0, 3, 1, 2)) < 1E-4 diff --git a/pyblock2/main_test/011-main.in b/pyblock2/main_test/011-main.in new file mode 100644 index 00000000..5566e0a4 --- /dev/null +++ b/pyblock2/main_test/011-main.in @@ -0,0 +1,18 @@ +# DMRG with 1PDM 2PDM + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +onepdm +twopdm \ No newline at end of file diff --git a/pyblock2/main_test/012-check.py b/pyblock2/main_test/012-check.py new file mode 100644 index 00000000..dd8321b6 --- /dev/null +++ b/pyblock2/main_test/012-check.py @@ -0,0 +1,50 @@ +import sys, struct, os + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.654122447525) < 1E-6 + +with open('node0/dmrg.e', 'rb') as f: + a, b = struct.unpack('dd', f.read()) + assert abs(a - -107.654122447525) < 1E-5 + assert abs(b - -106.959626154680) < 1E-5 + +if os.name == "nt": + quit() # pyscf not available on windows + +from pyblock2.driver.core import DMRGDriver, SymmetryTypes +from pyscf import fci +from pyscf.tools import fcidump +import numpy as np + +driver = DMRGDriver(scratch="./nodex", symm_type=SymmetryTypes.SU2, n_threads=4) +driver.read_fcidump(filename='../../data/N2.STO3G.FCIDUMP', pg='d2h', iprint=0) +driver.initialize_system(n_sites=driver.n_sites, n_elec=driver.n_elec, + spin=driver.spin, orb_sym=driver.orb_sym) +h1e, g2e, ecore = driver.h1e, driver.g2e, driver.ecore + +mf = fcidump.to_scf('../../data/N2.STO3G.FCIDUMP', molpro_orbsym=True) +mf.mol.symmetry = True + +mx = fci.addons.fix_spin_(fci.FCI(mf), ss=0) +mx.kernel(h1e, g2e, driver.n_sites, driver.n_elec, tol=1e-12, + wfnsym=0, orbsym=np.array(driver.orb_sym), nroots=4) +assert abs(mx.e_tot[0] + ecore - -107.654122447525) < 1E-6 +assert abs(mx.e_tot[1] + ecore - -106.959626154680) < 1E-6 + +for ir in range(2): + dm1, dm2 = mx.make_rdm12(mx.ci[ir], mf.mol.nao, mf.mol.nelec) + + xdm1 = np.load('./node0/1pdm-%d-%d.npy' % (ir, ir)) + xdm1 = xdm1[0] + xdm1[1] + + assert np.linalg.norm(dm1 - xdm1) < 1E-5 + + xdm2 = np.load('./node0/2pdm-%d-%d.npy' % (ir, ir)) + xdm2 = xdm2[0] + xdm2[2] + xdm2[1] + xdm2[1].transpose(1, 0, 3, 2) + + assert np.linalg.norm(dm2 - xdm2.transpose(0, 3, 1, 2)) < 1E-4 diff --git a/pyblock2/main_test/012-main.in b/pyblock2/main_test/012-main.in new file mode 100644 index 00000000..b558fb2d --- /dev/null +++ b/pyblock2/main_test/012-main.in @@ -0,0 +1,20 @@ +# DMRG with 1PDM 2PDM state-average + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 +nroots 2 +weights 0.5 0.5 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +onepdm +twopdm \ No newline at end of file diff --git a/pyblock2/main_test/013-check.py b/pyblock2/main_test/013-check.py new file mode 100644 index 00000000..d0417dca --- /dev/null +++ b/pyblock2/main_test/013-check.py @@ -0,0 +1,49 @@ +import sys, struct, os + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.654122447525) < 1E-6 + +with open('node0/dmrg.e', 'rb') as f: + a, b = struct.unpack('dd', f.read()) + assert abs(a - -107.654122447525) < 1E-5 + assert abs(b - -106.959626154680) < 1E-5 + +if os.name == "nt": + quit() # pyscf not available on windows + +from pyblock2.driver.core import DMRGDriver, SymmetryTypes +from pyscf import fci +from pyscf.tools import fcidump +import numpy as np + +driver = DMRGDriver(scratch="./nodex", symm_type=SymmetryTypes.SU2, n_threads=4) +driver.read_fcidump(filename='../../data/N2.STO3G.FCIDUMP', pg='d2h', iprint=0) +driver.initialize_system(n_sites=driver.n_sites, n_elec=driver.n_elec, + spin=driver.spin, orb_sym=driver.orb_sym) +h1e, g2e, ecore = driver.h1e, driver.g2e, driver.ecore + +mf = fcidump.to_scf('../../data/N2.STO3G.FCIDUMP', molpro_orbsym=True) +mf.mol.symmetry = True + +mx = fci.addons.fix_spin_(fci.FCI(mf), ss=0) +mx.kernel(h1e, g2e, driver.n_sites, driver.n_elec, tol=1e-12, + wfnsym=0, orbsym=np.array(driver.orb_sym), nroots=4) +assert abs(mx.e_tot[0] + ecore - -107.654122447525) < 1E-6 +assert abs(mx.e_tot[1] + ecore - -106.959626154680) < 1E-6 + +dm1, dm2 = mx.trans_rdm12(mx.ci[0], mx.ci[1], mf.mol.nao, mf.mol.nelec) + +xdm1 = np.load('./node0/1pdm-%d-%d.npy' % (0, 1)) +xdm1 = xdm1[0] + xdm1[1] + +assert min(np.linalg.norm(dm1 - f * xdm1) for f in [1, -1]) < 1E-5 + +xdm2 = np.load('./node0/2pdm-%d-%d.npy' % (0, 1)) +xdm2 = xdm2[0] + xdm2[2] + xdm2[1] + xdm2[1].transpose(1, 0, 3, 2) + +assert min(np.linalg.norm(dm2 - f * xdm2.transpose(0, 3, 1, 2)) for f in [1, -1]) < 1E-4 diff --git a/pyblock2/main_test/013-main.in b/pyblock2/main_test/013-main.in new file mode 100644 index 00000000..99e353ca --- /dev/null +++ b/pyblock2/main_test/013-main.in @@ -0,0 +1,20 @@ +# DMRG with trans 2PDM state-average + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 +nroots 2 +weights 0.5 0.5 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +tran_onepdm +tran_twopdm \ No newline at end of file diff --git a/pyblock2/main_test/014-check.py b/pyblock2/main_test/014-check.py new file mode 100644 index 00000000..c1d2af4d --- /dev/null +++ b/pyblock2/main_test/014-check.py @@ -0,0 +1,46 @@ +import sys, os + +energies = [0.0] * 2 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy for root'): + idx = int(l.split()[-3]) + energies[idx] = float(l.split()[-1]) + +assert abs(energies[0] - -107.654122447525) < 1E-5 +assert abs(energies[1] - -106.959626154680) < 1E-5 + +if os.name == "nt": + quit() # pyscf not available on windows + +from pyblock2.driver.core import DMRGDriver, SymmetryTypes +from pyscf import fci +from pyscf.tools import fcidump +import numpy as np + +driver = DMRGDriver(scratch="./nodex", symm_type=SymmetryTypes.SU2, n_threads=4) +driver.read_fcidump(filename='../../data/N2.STO3G.FCIDUMP', pg='d2h', iprint=0) +driver.initialize_system(n_sites=driver.n_sites, n_elec=driver.n_elec, + spin=driver.spin, orb_sym=driver.orb_sym) +h1e, g2e, ecore = driver.h1e, driver.g2e, driver.ecore + +mf = fcidump.to_scf('../../data/N2.STO3G.FCIDUMP', molpro_orbsym=True, verbose=0) +mf.mol.symmetry = True + +mx = fci.addons.fix_spin_(fci.FCI(mf), ss=0) +mx.kernel(h1e, g2e, driver.n_sites, driver.n_elec, tol=1e-12, + wfnsym=0, orbsym=np.array(driver.orb_sym), nroots=4) +assert abs(mx.e_tot[0] + ecore - -107.654122447525) < 1E-6 +assert abs(mx.e_tot[1] + ecore - -106.959626154680) < 1E-6 + +dm1, dm2 = mx.trans_rdm12(mx.ci[0], mx.ci[1], mf.mol.nao, mf.mol.nelec) + +xdm1 = np.load('./node0/1pdm-%d-%d.npy' % (0, 1)) +xdm1 = xdm1[0] + xdm1[1] + +assert min(np.linalg.norm(dm1 - f * xdm1) for f in [1, -1]) < 1E-5 + +xdm2 = np.load('./node0/2pdm-%d-%d.npy' % (0, 1)) +xdm2 = xdm2[0] + xdm2[2] + xdm2[1] + xdm2[1].transpose(1, 0, 3, 2) + +assert min(np.linalg.norm(dm2 - f * xdm2.transpose(0, 3, 1, 2)) for f in [1, -1]) < 1E-4 diff --git a/pyblock2/main_test/014-main.in b/pyblock2/main_test/014-main.in new file mode 100644 index 00000000..f7479c31 --- /dev/null +++ b/pyblock2/main_test/014-main.in @@ -0,0 +1,22 @@ +# DMRG with trans 2PDM refined +#DEP 13 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 +nroots 2 +weights 0.5 0.5 +statespecific + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +tran_onepdm +tran_twopdm \ No newline at end of file diff --git a/pyblock2/main_test/015-check.py b/pyblock2/main_test/015-check.py new file mode 100644 index 00000000..94d527b3 --- /dev/null +++ b/pyblock2/main_test/015-check.py @@ -0,0 +1,9 @@ +import sys + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.654) < 1E-3 diff --git a/pyblock2/main_test/015-main.in b/pyblock2/main_test/015-main.in new file mode 100644 index 00000000..f8ccdae7 --- /dev/null +++ b/pyblock2/main_test/015-main.in @@ -0,0 +1,18 @@ +# DMRG restart (first step) + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule +0 50 1E-4 1E-3 +4 70 1E-4 1E-3 +end +twodot_to_onedot 6 +maxiter 10 +num_thrds 4 +sweep_tol 1E-14 diff --git a/pyblock2/main_test/016-check.py b/pyblock2/main_test/016-check.py new file mode 100644 index 00000000..fe4783dc --- /dev/null +++ b/pyblock2/main_test/016-check.py @@ -0,0 +1,9 @@ +import sys + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.654122447525) < 1E-6 diff --git a/pyblock2/main_test/016-main.in b/pyblock2/main_test/016-main.in new file mode 100644 index 00000000..3074366f --- /dev/null +++ b/pyblock2/main_test/016-main.in @@ -0,0 +1,22 @@ +# DMRG restart (second step) +#DEP 15 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule +0 70 1E-4 1E-3 +4 200 1E-5 1E-6 +8 500 1E-8 0E+0 +end +twodot_to_onedot 10 +maxiter 16 +num_thrds 4 +sweep_tol 1E-14 + +fullrestart \ No newline at end of file diff --git a/pyblock2/main_test/017-check.py b/pyblock2/main_test/017-check.py new file mode 100644 index 00000000..d6813ef0 --- /dev/null +++ b/pyblock2/main_test/017-check.py @@ -0,0 +1,31 @@ + +import os + +if os.name == "nt": + quit() # pyscf not available on windows + +from pyblock2.driver.core import DMRGDriver, SymmetryTypes +from pyscf import fci +from pyscf.tools import fcidump +import numpy as np + +driver = DMRGDriver(scratch="./nodex", symm_type=SymmetryTypes.SU2, n_threads=4) +driver.read_fcidump(filename='../../data/N2.STO3G.FCIDUMP', pg='d2h', iprint=0) +driver.initialize_system(n_sites=driver.n_sites, n_elec=driver.n_elec, + spin=driver.spin, orb_sym=driver.orb_sym) +h1e, g2e, ecore = driver.h1e, driver.g2e, driver.ecore + +mf = fcidump.to_scf('../../data/N2.STO3G.FCIDUMP', molpro_orbsym=True) +mf.mol.symmetry = True + +mx = fci.FCI(mf) +mx.kernel(h1e, g2e, driver.n_sites, driver.n_elec, tol=1e-12, + wfnsym=0, orbsym=np.array(driver.orb_sym)) +assert abs(mx.e_tot + ecore - -107.654122447525) < 1E-6 + +dm1, dm2 = mx.make_rdm12(mx.ci, mf.mol.nao, mf.mol.nelec) + +xdm2 = np.load('./node0/2pdm.npy') +xdm2 = xdm2[0] + xdm2[2] + xdm2[1] + xdm2[1].transpose(1, 0, 3, 2) + +assert np.linalg.norm(dm2 - xdm2.transpose(0, 3, 1, 2)) < 1E-4 diff --git a/pyblock2/main_test/017-main.in b/pyblock2/main_test/017-main.in new file mode 100644 index 00000000..d2c70597 --- /dev/null +++ b/pyblock2/main_test/017-main.in @@ -0,0 +1,18 @@ +# DMRG restart for 2pdm +#DEP 0 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +restart_twopdm \ No newline at end of file diff --git a/pyblock2/main_test/018-check.py b/pyblock2/main_test/018-check.py new file mode 100644 index 00000000..5a0083ec --- /dev/null +++ b/pyblock2/main_test/018-check.py @@ -0,0 +1,41 @@ +import struct, os + +with open('node0/dmrg.e', 'rb') as f: + a, b = struct.unpack('dd', f.read()) + assert abs(a - -107.654122447525) < 1E-5 + assert abs(b - -106.959626154680) < 1E-5 + +if os.name == "nt": + quit() # pyscf not available on windows + +from pyblock2.driver.core import DMRGDriver, SymmetryTypes +from pyscf import fci +from pyscf.tools import fcidump +import numpy as np + +driver = DMRGDriver(scratch="./nodex", symm_type=SymmetryTypes.SU2, n_threads=4) +driver.read_fcidump(filename='../../data/N2.STO3G.FCIDUMP', pg='d2h', iprint=0) +driver.initialize_system(n_sites=driver.n_sites, n_elec=driver.n_elec, + spin=driver.spin, orb_sym=driver.orb_sym) +h1e, g2e, ecore = driver.h1e, driver.g2e, driver.ecore + +mf = fcidump.to_scf('../../data/N2.STO3G.FCIDUMP', molpro_orbsym=True) +mf.mol.symmetry = True + +mx = fci.addons.fix_spin_(fci.FCI(mf), ss=0) +mx.kernel(h1e, g2e, driver.n_sites, driver.n_elec, tol=1e-12, + wfnsym=0, orbsym=np.array(driver.orb_sym), nroots=4) +assert abs(mx.e_tot[0] + ecore - -107.654122447525) < 1E-6 +assert abs(mx.e_tot[1] + ecore - -106.959626154680) < 1E-6 + +dm1, dm2 = mx.trans_rdm12(mx.ci[0], mx.ci[1], mf.mol.nao, mf.mol.nelec) + +xdm1 = np.load('./node0/1pdm-%d-%d.npy' % (0, 1)) +xdm1 = xdm1[0] + xdm1[1] + +assert min(np.linalg.norm(dm1 - f * xdm1) for f in [1, -1]) < 1E-5 + +xdm2 = np.load('./node0/2pdm-%d-%d.npy' % (0, 1)) +xdm2 = xdm2[0] + xdm2[2] + xdm2[1] + xdm2[1].transpose(1, 0, 3, 2) + +assert min(np.linalg.norm(dm2 - f * xdm2.transpose(0, 3, 1, 2)) for f in [1, -1]) < 1E-4 diff --git a/pyblock2/main_test/018-main.in b/pyblock2/main_test/018-main.in new file mode 100644 index 00000000..6d49af4b --- /dev/null +++ b/pyblock2/main_test/018-main.in @@ -0,0 +1,21 @@ +# State-Averaged DMRG restart for tran 2pdm +#DEP 2 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 +nroots 2 +weights 0.5 0.5 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +restart_tran_onepdm +restart_tran_twopdm \ No newline at end of file diff --git a/pyblock2/main_test/019-check.py b/pyblock2/main_test/019-check.py new file mode 100644 index 00000000..303ac8bd --- /dev/null +++ b/pyblock2/main_test/019-check.py @@ -0,0 +1,9 @@ +import sys + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.116397543375) < 1E-6 diff --git a/pyblock2/main_test/019-main.in b/pyblock2/main_test/019-main.in new file mode 100644 index 00000000..69fd6d76 --- /dev/null +++ b/pyblock2/main_test/019-main.in @@ -0,0 +1,17 @@ +# DMRG tran 2pdm (diff irrep, step 1) + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 2 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +mps_tags KET \ No newline at end of file diff --git a/pyblock2/main_test/020-check.py b/pyblock2/main_test/020-check.py new file mode 100644 index 00000000..fe4783dc --- /dev/null +++ b/pyblock2/main_test/020-check.py @@ -0,0 +1,9 @@ +import sys + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.654122447525) < 1E-6 diff --git a/pyblock2/main_test/020-main.in b/pyblock2/main_test/020-main.in new file mode 100644 index 00000000..8acb599b --- /dev/null +++ b/pyblock2/main_test/020-main.in @@ -0,0 +1,17 @@ +# DMRG tran 2pdm (diff irrep, step 2) + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +mps_tags BRA \ No newline at end of file diff --git a/pyblock2/main_test/021-check.py b/pyblock2/main_test/021-check.py new file mode 100644 index 00000000..f18959cb --- /dev/null +++ b/pyblock2/main_test/021-check.py @@ -0,0 +1,41 @@ + +import os + +if os.name == "nt": + quit() # pyscf not available on windows + +from pyblock2.driver.core import DMRGDriver, SymmetryTypes +from pyscf import fci +from pyscf.tools import fcidump +import numpy as np + +driver = DMRGDriver(scratch="./nodex", symm_type=SymmetryTypes.SU2, n_threads=4) +driver.read_fcidump(filename='../../data/N2.STO3G.FCIDUMP', pg='d2h', iprint=0) +driver.initialize_system(n_sites=driver.n_sites, n_elec=driver.n_elec, + spin=driver.spin, orb_sym=driver.orb_sym) +h1e, g2e, ecore = driver.h1e, driver.g2e, driver.ecore + +mf = fcidump.to_scf('../../data/N2.STO3G.FCIDUMP', molpro_orbsym=True) +mf.mol.symmetry = True + +mx = fci.addons.fix_spin_(fci.FCI(mf), ss=0) +mx.kernel(h1e, g2e, driver.n_sites, driver.n_elec, tol=1e-12, + wfnsym=7, orbsym=np.array(driver.orb_sym), nroots=1) + +mx2 = fci.addons.fix_spin_(fci.FCI(mf), ss=0) +mx2.kernel(h1e, g2e, driver.n_sites, driver.n_elec, tol=1e-12, + wfnsym=0, orbsym=np.array(driver.orb_sym), nroots=1) +assert abs(mx2.e_tot + ecore - -107.654122447525) < 1E-6 +assert abs(mx.e_tot + ecore - -107.116397543375) < 1E-6 + +dm1, dm2 = mx.trans_rdm12(mx.ci, mx2.ci, mf.mol.nao, mf.mol.nelec) + +xdm1 = np.load('./node0/1pdm-%d-%d.npy' % (0, 1)) +xdm1 = xdm1[0] + xdm1[1] + +assert min(np.linalg.norm(dm1 - f * xdm1) for f in [1, -1]) < 1E-5 + +xdm2 = np.load('./node0/2pdm-%d-%d.npy' % (0, 1)) +xdm2 = xdm2[0] + xdm2[2] + xdm2[1] + xdm2[1].transpose(1, 0, 3, 2) + +assert min(np.linalg.norm(dm2 - f * xdm2.transpose(3, 0, 2, 1)) for f in [1, -1]) < 1E-4 diff --git a/pyblock2/main_test/021-main.in b/pyblock2/main_test/021-main.in new file mode 100644 index 00000000..36c4138a --- /dev/null +++ b/pyblock2/main_test/021-main.in @@ -0,0 +1,21 @@ +# DMRG tran 2pdm (diff irrep, step 3) +#DEP 19 20 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 +mps_tags BRA KET + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +restart_tran_onepdm +restart_tran_twopdm +conventional_npdm \ No newline at end of file diff --git a/pyblock2/main_test/022-check.py b/pyblock2/main_test/022-check.py new file mode 100644 index 00000000..36a347ac --- /dev/null +++ b/pyblock2/main_test/022-check.py @@ -0,0 +1,47 @@ +import sys, os + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.654122447525) < 1E-6 + +if os.name == "nt": + quit() # pyscf not available on windows + +from pyblock2.driver.core import DMRGDriver, SymmetryTypes +from pyscf import fci +from pyscf.tools import fcidump +import numpy as np + +driver = DMRGDriver(scratch="./nodex", symm_type=SymmetryTypes.SU2, n_threads=4) +driver.read_fcidump(filename='../../data/N2.STO3G.FCIDUMP', pg='d2h', iprint=0) +driver.initialize_system(n_sites=driver.n_sites, n_elec=driver.n_elec, + spin=driver.spin, orb_sym=driver.orb_sym) +h1e, g2e, ecore = driver.h1e, driver.g2e, driver.ecore + +mf = fcidump.to_scf('../../data/N2.STO3G.FCIDUMP', molpro_orbsym=True) +mf.mol.symmetry = True + +mx = fci.FCI(mf) +mx.kernel(h1e, g2e, driver.n_sites, driver.n_elec, tol=1e-12, + wfnsym=0, orbsym=np.array(driver.orb_sym)) +assert abs(mx.e_tot + ecore - -107.654122447525) < 1E-6 + +dm1, dm2 = mx.make_rdm12(mx.ci, mf.mol.nao, mf.mol.nelec) + +xdm1 = np.load('./node0/1pdm.npy') +xdm1 = xdm1[0] + xdm1[1] + +assert np.linalg.norm(dm1 - xdm1) < 1E-5 + +_e_pqqp = np.load('./node0/e_pqqp.npy') +_e_pqpq = np.load('./node0/e_pqpq.npy') +_2pdm_spat = dm2.transpose(0, 2, 3, 1) +_2pdm_spat_pqqp = np.einsum('pqqp->pq', _2pdm_spat) +_2pdm_spat_pqpq = np.einsum('pqpq->pq', _2pdm_spat) + +assert np.linalg.norm(_e_pqqp - _2pdm_spat_pqqp) < 1E-5 +assert np.linalg.norm(_e_pqpq - _2pdm_spat_pqpq) < 1E-5 diff --git a/pyblock2/main_test/022-main.in b/pyblock2/main_test/022-main.in new file mode 100644 index 00000000..f0963aa9 --- /dev/null +++ b/pyblock2/main_test/022-main.in @@ -0,0 +1,17 @@ +# DMRG diag 2pdm + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +diag_twopdm \ No newline at end of file diff --git a/pyblock2/main_test/023-check.py b/pyblock2/main_test/023-check.py new file mode 100644 index 00000000..fe4783dc --- /dev/null +++ b/pyblock2/main_test/023-check.py @@ -0,0 +1,9 @@ +import sys + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.654122447525) < 1E-6 diff --git a/pyblock2/main_test/023-main.in b/pyblock2/main_test/023-main.in new file mode 100644 index 00000000..926726e6 --- /dev/null +++ b/pyblock2/main_test/023-main.in @@ -0,0 +1,23 @@ +# Ground State DMRG (custom schedule) + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule +0 100 1E-4 1E-3 +4 250 1E-4 1E-3 +8 400 1E-5 1E-4 +10 600 1E-6 1E-5 +12 800 1E-7 1E-6 +14 1000 1E-8 1E-7 +16 1000 1E-8 0E+0 +end +twodot_to_onedot 18 +maxiter 100 +num_thrds 4 +sweep_tol 1E-14 \ No newline at end of file diff --git a/pyblock2/main_test/024-check.py b/pyblock2/main_test/024-check.py new file mode 100644 index 00000000..e545ddb7 --- /dev/null +++ b/pyblock2/main_test/024-check.py @@ -0,0 +1,20 @@ +import sys + +eners, dws = [], [] + +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if "DW" in l: + eners.append(float(l.split()[7])) + dws.append(float(l.split()[-1])) + +eners, dws = eners[3::4], dws[3::4] + +import scipy.stats +reg = scipy.stats.linregress(dws, eners) + +assert abs(eners[0] - -107.6541224474) < 1E-6 +assert abs(eners[1] - -107.6541224425) < 1E-6 +assert abs(eners[2] - -107.6541223606) < 1E-6 +assert abs(eners[3] - -107.6541219540) < 1E-6 +assert abs(reg.intercept - -107.654122447525) < 1E-6 diff --git a/pyblock2/main_test/024-main.in b/pyblock2/main_test/024-main.in new file mode 100644 index 00000000..e8fedc70 --- /dev/null +++ b/pyblock2/main_test/024-main.in @@ -0,0 +1,22 @@ +# Ground State DMRG (reverse schedule) +#DEP 23 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +twodot +schedule +0 35 1E-8 0E+0 +4 30 1E-8 0E+0 +8 25 1E-8 0E+0 +12 20 1E-8 0E+0 +end +maxiter 16 +num_thrds 4 +sweep_tol 0.0 +fullrestart \ No newline at end of file diff --git a/pyblock2/main_test/025-check.py b/pyblock2/main_test/025-check.py new file mode 100644 index 00000000..b848c747 --- /dev/null +++ b/pyblock2/main_test/025-check.py @@ -0,0 +1,13 @@ +import sys + +energy = 0 +nat_occ = [] +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + if l.startswith('REORDERED NAT OCC ='): + nat_occ = [float(x) for x in l.split()[4:]] + +assert abs(energy - -107.654122447525) < 1E-6 +assert abs(nat_occ[0] - 1.999995) < 1E-4 diff --git a/pyblock2/main_test/025-main.in b/pyblock2/main_test/025-main.in new file mode 100644 index 00000000..93eeeefa --- /dev/null +++ b/pyblock2/main_test/025-main.in @@ -0,0 +1,21 @@ +# Orbital Rotation (step 1) + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +onepdm +irrep_reorder +nat_orbs ./nodex/N2.NAT.FCIDUMP +nat_km_reorder +nat_positive_def \ No newline at end of file diff --git a/pyblock2/main_test/026-check.py b/pyblock2/main_test/026-check.py new file mode 100644 index 00000000..49dfc92d --- /dev/null +++ b/pyblock2/main_test/026-check.py @@ -0,0 +1,7 @@ +import sys + +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if '' in l: + norm_sq = float(l.split()[-1]) + assert abs(norm_sq - 1.0) < 1E-6 diff --git a/pyblock2/main_test/026-main.in b/pyblock2/main_test/026-main.in new file mode 100644 index 00000000..3e2fb1de --- /dev/null +++ b/pyblock2/main_test/026-main.in @@ -0,0 +1,21 @@ +# Orbital Rotation (step 2) +#DEP 25 + +sym d2h + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule + 0 1000 0 0 +end +num_thrds 4 + +mps_tags BRA +orbital_rotation +delta_t 0.05 +outputlevel 1 +noreorder + diff --git a/pyblock2/main_test/027-check.py b/pyblock2/main_test/027-check.py new file mode 100644 index 00000000..69e01457 --- /dev/null +++ b/pyblock2/main_test/027-check.py @@ -0,0 +1,9 @@ +import sys + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('OH Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.654122447525) < 1E-6 diff --git a/pyblock2/main_test/027-main.in b/pyblock2/main_test/027-main.in new file mode 100644 index 00000000..0ebe6cfc --- /dev/null +++ b/pyblock2/main_test/027-main.in @@ -0,0 +1,21 @@ +# Orbital Rotation (step 3) +#DEP 25 26 + +sym d2h +orbitals ./nodex/N2.NAT.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +mps_tags BRA +restart_oh +restart_onepdm +noreorder diff --git a/pyblock2/main_test/028-check.py b/pyblock2/main_test/028-check.py new file mode 100644 index 00000000..fe4783dc --- /dev/null +++ b/pyblock2/main_test/028-check.py @@ -0,0 +1,9 @@ +import sys + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.654122447525) < 1E-6 diff --git a/pyblock2/main_test/028-main.in b/pyblock2/main_test/028-main.in new file mode 100644 index 00000000..84bcbe44 --- /dev/null +++ b/pyblock2/main_test/028-main.in @@ -0,0 +1,18 @@ +# MPS SU2 to SZ (step 1) + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +irrep_reorder +mps_tags KET \ No newline at end of file diff --git a/pyblock2/main_test/029-check.py b/pyblock2/main_test/029-check.py new file mode 100644 index 00000000..e69de29b diff --git a/pyblock2/main_test/029-main.in b/pyblock2/main_test/029-main.in new file mode 100644 index 00000000..828fd6fc --- /dev/null +++ b/pyblock2/main_test/029-main.in @@ -0,0 +1,21 @@ +# MPS SU2 to SZ (step 2) +#DEP 28 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +irrep_reorder +mps_tags KET +restart_copy_mps ZKET +trans_mps_to_sz diff --git a/pyblock2/main_test/030-check.py b/pyblock2/main_test/030-check.py new file mode 100644 index 00000000..69e01457 --- /dev/null +++ b/pyblock2/main_test/030-check.py @@ -0,0 +1,9 @@ +import sys + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('OH Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.654122447525) < 1E-6 diff --git a/pyblock2/main_test/030-main.in b/pyblock2/main_test/030-main.in new file mode 100644 index 00000000..49d7d4de --- /dev/null +++ b/pyblock2/main_test/030-main.in @@ -0,0 +1,21 @@ +# MPS SU2 to SZ (step 3) +#DEP 28 29 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +irrep_reorder +mps_tags ZKET +restart_oh +nonspinadapted diff --git a/pyblock2/main_test/031-check.py b/pyblock2/main_test/031-check.py new file mode 100644 index 00000000..43b0797c --- /dev/null +++ b/pyblock2/main_test/031-check.py @@ -0,0 +1,13 @@ +import sys + +energy = 0 +quantum = '' +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + elif l.startswith('MPS ='): + quantum = l.split('< ')[-1].split(' >')[0] + +assert abs(energy - -106.939132859667396) < 1E-6 +assert quantum == 'N=14 S=1 PG=0' diff --git a/pyblock2/main_test/031-main.in b/pyblock2/main_test/031-main.in new file mode 100644 index 00000000..dc52dd53 --- /dev/null +++ b/pyblock2/main_test/031-main.in @@ -0,0 +1,18 @@ +# DMRG Non-singlet-embedding + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 2 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +irrep_reorder +mps_tags KET \ No newline at end of file diff --git a/pyblock2/main_test/032-check.py b/pyblock2/main_test/032-check.py new file mode 100644 index 00000000..947bec38 --- /dev/null +++ b/pyblock2/main_test/032-check.py @@ -0,0 +1,13 @@ +import sys + +energy = 0 +quantum = '' +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + elif l.startswith('MPS ='): + quantum = l.split('< ')[-1].split(' >')[0] + +assert abs(energy - -106.939132859667396) < 1E-6 +assert quantum == 'N=16 S=0 PG=0' diff --git a/pyblock2/main_test/032-main.in b/pyblock2/main_test/032-main.in new file mode 100644 index 00000000..43d6fc29 --- /dev/null +++ b/pyblock2/main_test/032-main.in @@ -0,0 +1,19 @@ +# DMRG Singlet-embedding (even sweeps) + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 2 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 0 + +irrep_reorder +mps_tags SEKET +singlet_embedding \ No newline at end of file diff --git a/pyblock2/main_test/033-check.py b/pyblock2/main_test/033-check.py new file mode 100644 index 00000000..e69de29b diff --git a/pyblock2/main_test/033-main.in b/pyblock2/main_test/033-main.in new file mode 100644 index 00000000..2da6f40c --- /dev/null +++ b/pyblock2/main_test/033-main.in @@ -0,0 +1,21 @@ +# DMRG SE to NSE +#DEP 32 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 2 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +irrep_reorder +mps_tags SEKET +restart_copy_mps TKET +trans_mps_from_singlet_embedding \ No newline at end of file diff --git a/pyblock2/main_test/034-check.py b/pyblock2/main_test/034-check.py new file mode 100644 index 00000000..7584e4e8 --- /dev/null +++ b/pyblock2/main_test/034-check.py @@ -0,0 +1,9 @@ +import sys + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('OH Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -106.939132859667396) < 1E-6 diff --git a/pyblock2/main_test/034-main.in b/pyblock2/main_test/034-main.in new file mode 100644 index 00000000..c60edd8a --- /dev/null +++ b/pyblock2/main_test/034-main.in @@ -0,0 +1,20 @@ +# DMRG NSE Expectation +#DEP 32 33 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 2 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +irrep_reorder +mps_tags TKET +restart_oh \ No newline at end of file diff --git a/pyblock2/main_test/035-check.py b/pyblock2/main_test/035-check.py new file mode 100644 index 00000000..e69de29b diff --git a/pyblock2/main_test/035-main.in b/pyblock2/main_test/035-main.in new file mode 100644 index 00000000..3cdda9d0 --- /dev/null +++ b/pyblock2/main_test/035-main.in @@ -0,0 +1,23 @@ +# DMRG SE SU2 to SZ +#DEP 32 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 2 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +irrep_reorder +mps_tags SEKET +restart_copy_mps ZKETM2 +trans_mps_to_sz +resolve_twosz -2 +normalize_mps \ No newline at end of file diff --git a/pyblock2/main_test/036-check.py b/pyblock2/main_test/036-check.py new file mode 100644 index 00000000..7584e4e8 --- /dev/null +++ b/pyblock2/main_test/036-check.py @@ -0,0 +1,9 @@ +import sys + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('OH Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -106.939132859667396) < 1E-6 diff --git a/pyblock2/main_test/036-main.in b/pyblock2/main_test/036-main.in new file mode 100644 index 00000000..c2137b74 --- /dev/null +++ b/pyblock2/main_test/036-main.in @@ -0,0 +1,21 @@ +# DMRG SE SU2 to SZ Expectation +#DEP 32 35 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin -2 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +irrep_reorder +mps_tags ZKETM2 +restart_oh +nonspinadapted \ No newline at end of file diff --git a/pyblock2/main_test/037-check.py b/pyblock2/main_test/037-check.py new file mode 100644 index 00000000..947bec38 --- /dev/null +++ b/pyblock2/main_test/037-check.py @@ -0,0 +1,13 @@ +import sys + +energy = 0 +quantum = '' +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + elif l.startswith('MPS ='): + quantum = l.split('< ')[-1].split(' >')[0] + +assert abs(energy - -106.939132859667396) < 1E-6 +assert quantum == 'N=16 S=0 PG=0' diff --git a/pyblock2/main_test/037-main.in b/pyblock2/main_test/037-main.in new file mode 100644 index 00000000..68e1ee10 --- /dev/null +++ b/pyblock2/main_test/037-main.in @@ -0,0 +1,19 @@ +# DMRG Singlet-embedding (odd sweeps) + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 2 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 29 +num_thrds 4 +sweep_tol 0 + +irrep_reorder +mps_tags SEKET +singlet_embedding \ No newline at end of file diff --git a/pyblock2/main_test/038-check.py b/pyblock2/main_test/038-check.py new file mode 100644 index 00000000..e69de29b diff --git a/pyblock2/main_test/038-main.in b/pyblock2/main_test/038-main.in new file mode 100644 index 00000000..0cf428c0 --- /dev/null +++ b/pyblock2/main_test/038-main.in @@ -0,0 +1,23 @@ +# DMRG SE SU2 to SZ (odd sweeps) +#DEP 37 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 2 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +irrep_reorder +mps_tags SEKET +restart_copy_mps ZKETM2 +trans_mps_to_sz +resolve_twosz -2 +normalize_mps \ No newline at end of file diff --git a/pyblock2/main_test/039-check.py b/pyblock2/main_test/039-check.py new file mode 100644 index 00000000..7584e4e8 --- /dev/null +++ b/pyblock2/main_test/039-check.py @@ -0,0 +1,9 @@ +import sys + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('OH Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -106.939132859667396) < 1E-6 diff --git a/pyblock2/main_test/039-main.in b/pyblock2/main_test/039-main.in new file mode 100644 index 00000000..db7b0d50 --- /dev/null +++ b/pyblock2/main_test/039-main.in @@ -0,0 +1,21 @@ +# DMRG SE SU2 to SZ Expectation (odd sweeps) +#DEP 37 38 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin -2 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +irrep_reorder +mps_tags ZKETM2 +restart_oh +nonspinadapted \ No newline at end of file diff --git a/pyblock2/main_test/040-check.py b/pyblock2/main_test/040-check.py new file mode 100644 index 00000000..7c1a7113 --- /dev/null +++ b/pyblock2/main_test/040-check.py @@ -0,0 +1,18 @@ +import sys + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.654122447525) < 1E-6 + +import numpy as np + +dets = np.load('node0/sample-dets.npy') +vals = np.load('node0/sample-vals.npy') + +idx = np.argsort(np.abs(vals))[-1] +assert np.all(dets[idx] == [3] * 5 + [0, 3] * 2 + [0]) +assert abs(abs(vals[idx]) - 0.957506527063957) < 1E-4 diff --git a/pyblock2/main_test/040-main.in b/pyblock2/main_test/040-main.in new file mode 100644 index 00000000..e9bff7d2 --- /dev/null +++ b/pyblock2/main_test/040-main.in @@ -0,0 +1,19 @@ +# DMRG CSF Coefficients + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +irrep_reorder +mps_tags KET +sample 0.05 \ No newline at end of file diff --git a/pyblock2/main_test/041-check.py b/pyblock2/main_test/041-check.py new file mode 100644 index 00000000..7c1a7113 --- /dev/null +++ b/pyblock2/main_test/041-check.py @@ -0,0 +1,18 @@ +import sys + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.654122447525) < 1E-6 + +import numpy as np + +dets = np.load('node0/sample-dets.npy') +vals = np.load('node0/sample-vals.npy') + +idx = np.argsort(np.abs(vals))[-1] +assert np.all(dets[idx] == [3] * 5 + [0, 3] * 2 + [0]) +assert abs(abs(vals[idx]) - 0.957506527063957) < 1E-4 diff --git a/pyblock2/main_test/041-main.in b/pyblock2/main_test/041-main.in new file mode 100644 index 00000000..0fde2cd3 --- /dev/null +++ b/pyblock2/main_test/041-main.in @@ -0,0 +1,20 @@ +# DMRG DET Coefficients + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +irrep_reorder +mps_tags KET +sample 0.05 +nonspinadapted \ No newline at end of file diff --git a/pyblock2/main_test/042-check.py b/pyblock2/main_test/042-check.py new file mode 100644 index 00000000..4688cebb --- /dev/null +++ b/pyblock2/main_test/042-check.py @@ -0,0 +1,9 @@ +import sys + +ovlp = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('Compression overlap ='): + ovlp = float(l.split()[-1]) + +assert abs(ovlp - 0.957506527014452) < 1E-6 diff --git a/pyblock2/main_test/042-main.in b/pyblock2/main_test/042-main.in new file mode 100644 index 00000000..46b5726f --- /dev/null +++ b/pyblock2/main_test/042-main.in @@ -0,0 +1,31 @@ +# MPS Compression +#DEP 40 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule +0 250 0 0 +2 125 0 0 +4 62 0 0 +6 31 0 0 +8 15 0 0 +10 7 0 0 +12 3 0 0 +14 1 0 0 +end +maxiter 16 +num_thrds 4 +sweep_tol 0 + +compression +overlap +read_mps_tags KET +mps_tags BRA + +irrep_reorder diff --git a/pyblock2/main_test/043-check.py b/pyblock2/main_test/043-check.py new file mode 100644 index 00000000..fe4783dc --- /dev/null +++ b/pyblock2/main_test/043-check.py @@ -0,0 +1,9 @@ +import sys + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.654122447525) < 1E-6 diff --git a/pyblock2/main_test/043-main.in b/pyblock2/main_test/043-main.in new file mode 100644 index 00000000..9179f673 --- /dev/null +++ b/pyblock2/main_test/043-main.in @@ -0,0 +1,21 @@ +# DMRG occ init + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nelec 14 +spin 0 +irrep 1 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +irrep_reorder + +warmup occ +occ 2.000 1.991 1.985 2.000 1.986 0.020 1.931 0.077 1.931 0.077 +cbias 0.2 diff --git a/pyblock2/main_test/044-check.py b/pyblock2/main_test/044-check.py new file mode 100644 index 00000000..ef9e02ca --- /dev/null +++ b/pyblock2/main_test/044-check.py @@ -0,0 +1,14 @@ +import sys, struct + +energy = 0 +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('DMRG Energy ='): + energy = float(l.split()[-1]) + +assert abs(energy - -107.654122447525) < 1E-6 + +with open('node0/dmrg.e', 'rb') as f: + a, b = struct.unpack('dd', f.read()) + assert abs(a - -107.654122447525) < 1E-5 + assert abs(b - -106.959626154680) < 1E-5 diff --git a/pyblock2/main_test/044-main.in b/pyblock2/main_test/044-main.in new file mode 100644 index 00000000..bc2a8403 --- /dev/null +++ b/pyblock2/main_test/044-main.in @@ -0,0 +1,15 @@ +# Time-dependent DMRG (step 1 - init) + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nroots 2 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +noreorder diff --git a/pyblock2/main_test/045-check.py b/pyblock2/main_test/045-check.py new file mode 100644 index 00000000..e69de29b diff --git a/pyblock2/main_test/045-main.in b/pyblock2/main_test/045-main.in new file mode 100644 index 00000000..aa8f474a --- /dev/null +++ b/pyblock2/main_test/045-main.in @@ -0,0 +1,19 @@ +# Time-dependent DMRG (step 2 - split) +#DEP 44 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +nroots 2 + +hf_occ integral +schedule default +maxM 500 +maxiter 30 +num_thrds 4 +sweep_tol 1E-14 + +restart_copy_mps +split_states +trans_mps_to_complex +noreorder diff --git a/pyblock2/main_test/046-check.py b/pyblock2/main_test/046-check.py new file mode 100644 index 00000000..4d1c6505 --- /dev/null +++ b/pyblock2/main_test/046-check.py @@ -0,0 +1,10 @@ +import sys, struct + +energies = [] +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('T = RE'): + energies.append(float(l.split()[9]) / float(l.split()[-1])) + +for energy in energies: + assert abs(energy - -107.654122447525) < 1E-6 diff --git a/pyblock2/main_test/046-main.in b/pyblock2/main_test/046-main.in new file mode 100644 index 00000000..70e2dbaf --- /dev/null +++ b/pyblock2/main_test/046-main.in @@ -0,0 +1,20 @@ +# Time-dependent DMRG (step 3 - root 0 td) +#DEP 44 45 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +hf_occ integral +schedule +0 40 0 0 +end +maxiter 10 +num_thrds 4 +sweep_tol 1E-14 + +read_mps_tags KET-CPX-0 +mps_tags BRA +delta_t 0.05i +target_t 0.20i +complex_mps +noreorder diff --git a/pyblock2/main_test/047-check.py b/pyblock2/main_test/047-check.py new file mode 100644 index 00000000..a2cd1982 --- /dev/null +++ b/pyblock2/main_test/047-check.py @@ -0,0 +1,10 @@ +import sys, struct + +energies = [] +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('T = RE'): + energies.append(float(l.split()[9]) / float(l.split()[-1])) + +for energy in energies: + assert abs(energy - -106.959626154680) < 1E-6 diff --git a/pyblock2/main_test/047-main.in b/pyblock2/main_test/047-main.in new file mode 100644 index 00000000..6ad0b0da --- /dev/null +++ b/pyblock2/main_test/047-main.in @@ -0,0 +1,20 @@ +# Time-dependent DMRG (step 4 - root 1 td) +#DEP 44 45 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +hf_occ integral +schedule +0 40 0 0 +end +maxiter 10 +num_thrds 4 +sweep_tol 1E-14 + +read_mps_tags KET-CPX-1 +mps_tags BRAEX +delta_t 0.05i +target_t 0.20i +complex_mps +noreorder diff --git a/pyblock2/main_test/048-check.py b/pyblock2/main_test/048-check.py new file mode 100644 index 00000000..5cdecb7f --- /dev/null +++ b/pyblock2/main_test/048-check.py @@ -0,0 +1,23 @@ +import sys +import numpy as np + +energies = np.zeros((4, 4), dtype=complex) +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('OH Energy'): + a, b = [int(c) for c in l.split()[2:5:2]] + energies[a, b] = float(l.split()[-1]) * 1j + float(l.split()[-4]) + +np.save('node0/ovlps.npy', energies) + +x = energies[1, 0] / (energies[0, 0] * energies[1, 1]) ** 0.5 +ang = -107.654122447525 * 0.2 % (2 * np.pi) + +assert abs(np.abs(x) - 1.0) < 1E-6 +assert abs(abs(np.angle(x) - ang) - 2 * np.pi) < 1E-6 + +x = energies[3, 2] / (energies[2, 2] * energies[3, 3]) ** 0.5 +ang = -106.959626154680 * 0.2 % (2 * np.pi) + +assert abs(np.abs(x) - 1.0) < 1E-6 +assert abs(abs(np.angle(x) - ang) - 2 * np.pi) < 1E-6 diff --git a/pyblock2/main_test/048-main.in b/pyblock2/main_test/048-main.in new file mode 100644 index 00000000..23280f7a --- /dev/null +++ b/pyblock2/main_test/048-main.in @@ -0,0 +1,19 @@ +# Time-dependent DMRG (step 5 - overlap) +#DEP 44 45 46 47 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +hf_occ integral +schedule +0 40 0 0 +end +maxiter 10 +num_thrds 4 +sweep_tol 1E-14 + +mps_tags KET-CPX-0 BRA KET-CPX-1 BRAEX +restart_tran_oh +complex_mps +overlap +noreorder diff --git a/pyblock2/main_test/049-check.py b/pyblock2/main_test/049-check.py new file mode 100644 index 00000000..fc3dc181 --- /dev/null +++ b/pyblock2/main_test/049-check.py @@ -0,0 +1,16 @@ +import sys +import numpy as np + +energies = np.zeros((4, 4), dtype=complex) +with open(sys.argv[1], 'r') as f: + for l in f.readlines(): + if l.startswith('OH Energy'): + a, b = [int(c) for c in l.split()[2:5:2]] + energies[a, b] = float(l.split()[-1]) * 1j + float(l.split()[-4]) + +ovlps = np.load('node0/ovlps.npy') + +assert abs(energies[0, 0] / ovlps[0, 0] - -107.654122447525) < 1E-5 +assert abs(energies[1, 1] / ovlps[1, 1] - -107.654122447525) < 1E-5 +assert abs(energies[2, 2] / ovlps[2, 2] - -106.959626154680) < 1E-5 +assert abs(energies[3, 3] / ovlps[3, 3] - -106.959626154680) < 1E-5 diff --git a/pyblock2/main_test/049-main.in b/pyblock2/main_test/049-main.in new file mode 100644 index 00000000..36059db4 --- /dev/null +++ b/pyblock2/main_test/049-main.in @@ -0,0 +1,18 @@ +# Time-dependent DMRG (step 6 - energy) +#DEP 44 45 46 47 48 + +sym d2h +orbitals ../../data/N2.STO3G.FCIDUMP + +hf_occ integral +schedule +0 40 0 0 +end +maxiter 10 +num_thrds 4 +sweep_tol 1E-14 + +mps_tags KET-CPX-0 BRA KET-CPX-1 BRAEX +restart_tran_oh +complex_mps +noreorder diff --git a/pyblock2/main_test/run-test.ps1 b/pyblock2/main_test/run-test.ps1 new file mode 100755 index 00000000..23ffcb7e --- /dev/null +++ b/pyblock2/main_test/run-test.ps1 @@ -0,0 +1,47 @@ +#!/usr/bin/env pwsh + +for ($i = 0; $i -le 49; $i++) { + $formattedI = "{0:D3}" -f $i + $inputFile = "$formattedI-main.in" + $outputFile = "$formattedI-main.out" + + Write-Output "TEST $formattedI $(Get-Content -First 1 $inputFile)" + + $depLine = Get-Content $inputFile | Select-String -Pattern "#DEP" + $depLineProcessed = $depLine -replace "#DEP", "" -replace "^\s+", "" + $deps = $depLineProcessed -split "\s+" + + foreach ($j in $deps) { + $formattedJ = "{0:D3}" -f [int]$j + $depInputFile = "$formattedJ-main.in" + $depOutputFile = "$formattedJ-main.out" + + Write-Output "-- DEP $formattedJ $(Get-Content -First 1 $depInputFile)" + + python $env:block2main $depInputFile > $depOutputFile + if ($LASTEXITCODE -ne 0) { + Get-Content $depOutputFile | Write-Output + Write-Output "$formattedJ DEP FAILED!" + exit 3 + } + + python "$formattedJ-check.py" $depOutputFile + Remove-Item $depOutputFile + } + + python $env:block2main $inputFile > $outputFile + if ($LASTEXITCODE -ne 0) { + Get-Content $outputFile | Write-Output + Write-Output "$formattedI RUN FAILED!" + exit 1 + } + + python "$formattedI-check.py" $outputFile + if ($LASTEXITCODE -ne 0) { + Get-Content $outputFile | Write-Output + Write-Output "$formattedI WRONG NUMBER!" + exit 2 + } + + Remove-Item -Recurse $outputFile, "node0", "nodex" +} diff --git a/pyblock2/main_test/run-test.sh b/pyblock2/main_test/run-test.sh new file mode 100755 index 00000000..47c5c2a3 --- /dev/null +++ b/pyblock2/main_test/run-test.sh @@ -0,0 +1,35 @@ +#! /usr/bin/env bash + +if [ "x$1" != "x" ]; then + RANGE=$1 +else + RANGE=$(seq 0 49) +fi + +for i in $RANGE; do + echo "TEST $(printf "%03d" $i) " $(head -n 1 $(printf "%03d" $i)-main.in) + for j in $(grep "#DEP" $(printf "%03d" $i)-main.in | awk '{$1=""; print $0}'); do + echo -- DEP $(printf "%03d" $j) $(head -n 1 $(printf "%03d" $j)-main.in) + block2main $(printf "%03d" $j)-main.in > $(printf "%03d" $j)-main.out + if [ $? -ne 0 ]; then + cat $(printf "%03d" $j)-main.out + echo "$(printf "%03d" $j) DEP FAILED!" + exit 3 + fi + python3 $(printf "%03d" $j)-check.py $(printf "%03d" $j)-main.out + rm $(printf "%03d" $j)-main.out + done + block2main $(printf "%03d" $i)-main.in > $(printf "%03d" $i)-main.out + if [ $? -ne 0 ]; then + cat $(printf "%03d" $i)-main.out + echo "$(printf "%03d" $i) RUN FAILED!" + exit 1 + fi + python3 $(printf "%03d" $i)-check.py $(printf "%03d" $i)-main.out + if [ $? -ne 0 ]; then + cat $(printf "%03d" $i)-main.out + echo "$(printf "%03d" $i) WRONG NUMBER!" + exit 2 + fi + rm -r $(printf "%03d" $i)-main.out node0 nodex +done