mirror of
https://github.com/TREX-CoE/trexio.git
synced 2025-01-03 10:06:01 +01:00
Merge branch 'TREX-CoE:master' into master
This commit is contained in:
commit
7ed53ab71c
18
.github/workflows/actions.yml
vendored
18
.github/workflows/actions.yml
vendored
@ -112,8 +112,8 @@ jobs:
|
||||
run: make maintainer-clean
|
||||
|
||||
trexio_macos:
|
||||
name: x86 MacOS 11
|
||||
runs-on: macos-11
|
||||
name: x86 MacOS 12
|
||||
runs-on: macos-12
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791
|
||||
@ -121,19 +121,29 @@ jobs:
|
||||
- name: install dependencies
|
||||
run: |
|
||||
brew install emacs
|
||||
brew install hdf5
|
||||
brew install hdf5@1.12
|
||||
brew install automake
|
||||
brew --prefix hdf5
|
||||
|
||||
- name: configure with autotools
|
||||
run: |
|
||||
./autogen.sh
|
||||
./configure FC=gfortran-10 --enable-silent-rules
|
||||
./configure FC=gfortran-12 --enable-silent-rules
|
||||
|
||||
- name: compile TREXIO
|
||||
run: make -j3
|
||||
|
||||
- name: check TREXIO
|
||||
run: make -j3 check
|
||||
|
||||
- name: compile Python API
|
||||
run: |
|
||||
export H5_CFLAGS="-I$(brew --prefix hdf5)/include"
|
||||
export H5_LDFLAGS="-L$(brew --prefix hdf5)/lib"
|
||||
make python-install
|
||||
|
||||
- name: test Python API
|
||||
run: make python-test
|
||||
|
||||
- name: Archive test log file
|
||||
if: failure()
|
||||
|
37
.github/workflows/build-wheels.yml
vendored
37
.github/workflows/build-wheels.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
||||
message: ${{ steps.commit_message.outputs.message }}
|
||||
steps:
|
||||
- name: Checkout the repo
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
# Gets the correct commit message for pull request
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
@ -42,14 +42,14 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
strategy:
|
||||
matrix:
|
||||
manylinux_tag: [2010_x86_64, 2014_x86_64, 2_24_x86_64]
|
||||
manylinux_tag: [2014_x86_64, 2_24_x86_64]
|
||||
|
||||
steps:
|
||||
- name: Checkout the branch
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v1
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.9'
|
||||
|
||||
@ -103,22 +103,14 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-10.15]
|
||||
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
|
||||
# TODO: normally, one could include macos-11 and the OS list above but the produced wheels receive an error upon installation:
|
||||
# ERROR: trexio-1.1.0-cp39-cp39-macosx_11_0_x86_64.whl is not a supported wheel on this platform.
|
||||
# This happens even with the MACOSX_DEPLOYMENT_TARGET trick. Perhaps it can be solved by configuring the build system
|
||||
# to produce the wheels for MacOS-11 from the very beginning
|
||||
#exclude:
|
||||
# - os: macos-11
|
||||
env:
|
||||
H5_LDFLAGS: '-L/usr/local/Cellar/hdf5/1.12.1/lib'
|
||||
H5_CFLAGS: '-I/usr/local/Cellar/hdf5/1.12.1/include'
|
||||
os: [macos-12]
|
||||
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
@ -128,11 +120,6 @@ jobs:
|
||||
- name: Install HDF5
|
||||
run: brew install hdf5@1.12
|
||||
|
||||
# This step is needed to produce wheels with the correct platform tag for MacOS-11 (Big Sur)
|
||||
#- name: Set MACOSX_DEPLOYMENT_TARGET environment variable
|
||||
# if: ${{ matrix.os == 'macos-11' }}
|
||||
# run: echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> $GITHUB_ENV
|
||||
|
||||
- name: Compute the PYTREXIO_VERSION environment variable
|
||||
run: echo "PYTREXIO_VERSION=$(grep __version__ python/pytrexio/_version.py | cut -d\ -f3 | tr -d '"')" >> $GITHUB_ENV
|
||||
|
||||
@ -158,6 +145,8 @@ jobs:
|
||||
run: |
|
||||
mkdir wheelhouse/
|
||||
cd trexio-${{ env.PYTREXIO_VERSION }}/
|
||||
export H5_CFLAGS="-I$(brew --prefix hdf5)/include"
|
||||
export H5_LDFLAGS="-L$(brew --prefix hdf5)/lib"
|
||||
python -m build --wheel --outdir=./
|
||||
delocate-wheel trexio-*.whl
|
||||
mv trexio-*.whl ../wheelhouse/
|
||||
@ -186,10 +175,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout the branch
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v1
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.9'
|
||||
|
||||
|
@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
# Initialize the CMake project.
|
||||
project(Trexio
|
||||
VERSION 2.4.0
|
||||
VERSION 2.3.1
|
||||
DESCRIPTION "TREX I/O library"
|
||||
LANGUAGES C Fortran
|
||||
)
|
||||
|
@ -2,7 +2,7 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ([2.69])
|
||||
AC_INIT([trexio],[2.4.0],[https://github.com/TREX-CoE/trexio/issues])
|
||||
AC_INIT([trexio],[2.3.1],[https://github.com/TREX-CoE/trexio/issues])
|
||||
|
||||
AC_CONFIG_SRCDIR([Makefile.in])
|
||||
AC_CONFIG_HEADERS([include/config.h])
|
||||
|
@ -200,7 +200,7 @@ program print_energy
|
||||
#+begin_src f90
|
||||
call getarg(1, filename)
|
||||
|
||||
f = trexio_open (filename, 'r', TREXIO_HDF5, rc)
|
||||
f = trexio_open (filename, 'r', TREXIO_AUTO, rc)
|
||||
if (rc /= TREXIO_SUCCESS) then
|
||||
call trexio_string_of_error(rc, err_msg)
|
||||
print *, 'Error opening TREXIO file: '//trim(err_msg)
|
||||
@ -410,6 +410,139 @@ program print_energy
|
||||
end program
|
||||
#+end_src
|
||||
|
||||
** Python
|
||||
:PROPERTIES:
|
||||
:header-args: :tangle print_energy.py
|
||||
:END:
|
||||
|
||||
#+begin_src python
|
||||
import sys
|
||||
import trexio
|
||||
import numpy as np
|
||||
|
||||
BUFSIZE = 100000
|
||||
#+end_src
|
||||
|
||||
This program computes the energy as:
|
||||
|
||||
\[
|
||||
E = E_{\text{NN}} + \sum_{ij} \gamma_{ij}\, \langle j | h | i \rangle\,
|
||||
+\, \frac{1}{2} \sum_{ijkl} \Gamma_{ijkl}\, \langle k l | i j
|
||||
\rangle\; \textrm{ with } \; 0 < i,j,k,l \le n
|
||||
\]
|
||||
One needs to read from the TREXIO file:
|
||||
|
||||
- $n$ :: The number of molecular orbitals
|
||||
- $E_{\text{NN}}$ :: The nuclear repulsion energy
|
||||
- $\gamma_{ij}$ :: The one-body reduced density matrix
|
||||
- $\langle j |h| i \rangle$ :: The one-electron Hamiltonian integrals
|
||||
- $\Gamma_{ijkl}$ :: The two-body reduced density matrix
|
||||
- $\langle k l | i j \rangle$ :: The electron repulsion integrals
|
||||
|
||||
*** Obtain the name of the TREXIO file from the command line, and open it for reading
|
||||
|
||||
#+begin_src python
|
||||
filename = sys.argv[1]
|
||||
f = trexio.File(filename, 'r', trexio.TREXIO_AUTO)
|
||||
#+end_src
|
||||
|
||||
*** Read the nuclear repulsion energy
|
||||
|
||||
#+begin_src python
|
||||
E_nn = trexio.read_nucleus_repulsion(f)
|
||||
#+end_src
|
||||
|
||||
*** Read the number of molecular orbitals
|
||||
|
||||
#+begin_src python
|
||||
n = trexio.read_mo_num(f)
|
||||
#+end_src
|
||||
|
||||
*** Read one-electron quantities
|
||||
|
||||
#+begin_src python
|
||||
if not trexio.has_mo_1e_int_core_hamiltonian(f):
|
||||
print("No core hamiltonian in file")
|
||||
sys.exit(-1)
|
||||
|
||||
h0 = trexio.read_mo_1e_int_core_hamiltonian(f)
|
||||
|
||||
if not trexio.has_rdm_1e(f):
|
||||
print("No 1e RDM in file")
|
||||
sys.exit(-1)
|
||||
|
||||
D = trexio.read_rdm_1e(f)
|
||||
#+end_src
|
||||
|
||||
*** Read two-electron quantities
|
||||
|
||||
**** Electron repulsion integrals
|
||||
|
||||
#+begin_src python
|
||||
if not trexio.has_mo_2e_int_eri(f):
|
||||
print("No electron repulsion integrals in file")
|
||||
sys.exit(-1)
|
||||
|
||||
size_max = trexio.read_mo_2e_int_eri_size(f)
|
||||
|
||||
offset = 0
|
||||
icount = BUFSIZE
|
||||
feof = False
|
||||
W = np.zeros( (n,n,n,n) )
|
||||
while not feof:
|
||||
buffer_index, buffer_values, icount, feof = trexio.read_mo_2e_int_eri(f, offset, icount)
|
||||
for m in range(icount):
|
||||
i, j, k, l = buffer_index[m]
|
||||
W[i,j,k,l] = buffer_values[m]
|
||||
W[k,j,i,l] = buffer_values[m]
|
||||
W[i,l,k,j] = buffer_values[m]
|
||||
W[k,l,i,j] = buffer_values[m]
|
||||
W[j,i,l,k] = buffer_values[m]
|
||||
W[j,k,l,i] = buffer_values[m]
|
||||
W[l,i,j,k] = buffer_values[m]
|
||||
W[l,k,j,i] = buffer_values[m]
|
||||
#+end_src
|
||||
|
||||
**** Reduced density matrix
|
||||
|
||||
#+begin_src python
|
||||
if not trexio.has_rdm_2e(f):
|
||||
print("No two-body density matrix in file")
|
||||
|
||||
offset = 0
|
||||
icount = BUFSIZE
|
||||
feof = False
|
||||
G = np.zeros( (n,n,n,n) )
|
||||
while not feof:
|
||||
buffer_index, buffer_values, icount, feof = trexio.read_rdm_2e(f, offset, icount)
|
||||
for m in range(icount):
|
||||
i, j, k, l = buffer_index[m]
|
||||
G[i,j,k,l] = buffer_values[m]
|
||||
|
||||
#+end_src
|
||||
|
||||
*** Compute the energy
|
||||
|
||||
When the orbitals are real, we can use
|
||||
\begin{eqnarray*}
|
||||
E &=& E_{\text{NN}} + \sum_{ij} \gamma_{ij}\, \langle j | h | i \rangle\,
|
||||
+\, \frac{1}{2} \sum_{ijkl} \Gamma_{ijkl}\, \langle k l | i j
|
||||
\rangle \\
|
||||
&=& E_{\text{NN}} + \sum_{ij} \gamma_{ij}\, \langle i | h | j \rangle\,
|
||||
+\, \frac{1}{2} \sum_{ijkl} \Gamma_{ijkl}\, \langle i j | k l
|
||||
\rangle \\
|
||||
\end{eqnarray*}
|
||||
|
||||
#+begin_src python
|
||||
G = np.reshape(G, (n*n, n*n) )
|
||||
W = np.reshape(W, (n*n, n*n) )
|
||||
E = E_nn
|
||||
E += 0.5*sum( [ np.dot(G[:,l], W[:,l]) for l in range(n*n) ] )
|
||||
E += sum( [ np.dot(D[:,l], h0[:,l]) for l in range(n) ] )
|
||||
|
||||
print (f"Energy: {E}")
|
||||
#+end_src
|
||||
|
||||
* Reading determinants
|
||||
|
||||
** Fortran
|
||||
|
@ -1 +1 @@
|
||||
__version__ = "1.4.0"
|
||||
__version__ = "1.3.2"
|
||||
|
@ -1,4 +1,4 @@
|
||||
setuptools>=42
|
||||
pkgconfig
|
||||
numpy<1.23.0
|
||||
numpy<1.24.0
|
||||
numpy>=1.17.3
|
||||
|
@ -34,14 +34,14 @@
|
||||
num variable is modified by address
|
||||
*/
|
||||
/* Return num variables as part of the output tuple */
|
||||
%apply int *OUTPUT { int32_t* const num};
|
||||
%apply int *OUTPUT { int64_t* const num};
|
||||
%apply int *OUTPUT { int32_t* const num_up};
|
||||
%apply int *OUTPUT { int32_t* const num_dn};
|
||||
%apply int *OUTPUT { int64_t* const num_up};
|
||||
%apply int *OUTPUT { int64_t* const num_dn};
|
||||
%apply int32_t *OUTPUT { int32_t* const num};
|
||||
%apply int64_t *OUTPUT { int64_t* const num};
|
||||
%apply int32_t *OUTPUT { int32_t* const num_up};
|
||||
%apply int32_t *OUTPUT { int32_t* const num_dn};
|
||||
%apply int64_t *OUTPUT { int64_t* const num_up};
|
||||
%apply int64_t *OUTPUT { int64_t* const num_dn};
|
||||
%apply float *OUTPUT { float* const num};
|
||||
%apply float *OUTPUT { double* const num};
|
||||
%apply double *OUTPUT { double* const num};
|
||||
/* Return TREXIO exit code from trexio_open as part of the output tuple */
|
||||
%apply int *OUTPUT { trexio_exit_code* const rc_open};
|
||||
/* Return number of sparse data points stored in the file as part of the output tuple */
|
||||
|
Loading…
Reference in New Issue
Block a user