Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust interface #129

Merged
merged 43 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
59d14d0
Creating rust binding
scemama Oct 10, 2023
1427575
Check consistency of versions in OCaml
scemama Oct 11, 2023
94fb57b
Automate has functions
scemama Oct 11, 2023
0ad057f
Fixed string -> str in Jastrow
scemama Oct 11, 2023
c5f65ee
Scalars OK
scemama Oct 11, 2023
05f4837
Write array of strings OK
scemama Oct 11, 2023
b0dc33d
Improved test
scemama Oct 11, 2023
7e9a307
Improved usize
scemama Oct 11, 2023
6aeecd7
Better panic messages
scemama Oct 12, 2023
af9bc43
Errors with '?'
scemama Oct 12, 2023
06be52c
Using methods
scemama Oct 12, 2023
2afc616
Added bitfields
scemama Oct 12, 2023
1e7dfc8
Tests in bitfields
scemama Oct 13, 2023
601dfbb
Added bitfields
scemama Oct 13, 2023
3cf8a8c
write_determinant_list
scemama Oct 13, 2023
e6cc8fa
Created tests directory
scemama Oct 15, 2023
38946c8
Added sparse write
scemama Oct 16, 2023
000c83f
Introducing read test
scemama Oct 17, 2023
3a4726c
Introducing read test
scemama Oct 17, 2023
9d2866c
Need to check sparse read
scemama Oct 17, 2023
5f5267e
Tests pass
scemama Oct 18, 2023
dd3e864
Added documentation
scemama Oct 18, 2023
79cca2a
Improved documentation
scemama Oct 18, 2023
c577e61
Updated documentation
scemama Oct 18, 2023
44a03f5
Updated formatting
scemama Oct 18, 2023
8a2ded8
Improved with clippy
scemama Oct 18, 2023
fcedff4
Moving code generation in build.rs
scemama Oct 18, 2023
421581f
All build in rust
scemama Oct 23, 2023
ef2ad32
Cargo doc OK
scemama Oct 23, 2023
49462ad
Updated check_version
scemama Oct 23, 2023
6ff3fdf
Added json in trexio.h
scemama Oct 23, 2023
3c3c0e4
Searching for trexio.h
scemama Oct 23, 2023
9919d4d
Fixing cargo publish
scemama Oct 23, 2023
297a71f
Fixing publish
scemama Oct 23, 2023
ca02aa6
Removed version check
scemama Oct 24, 2023
ccdf359
Update version to 2.4.1
scemama Oct 24, 2023
d224396
Rust downloads TREXIO tar.gz
scemama Oct 24, 2023
92e71be
Added trex.json in tar.gz
scemama Oct 24, 2023
8a2067d
Bump version to 2.4.2
scemama Oct 24, 2023
9113da7
Fixing CI
scemama Oct 24, 2023
51afc12
Changeed version to 2.4.2 in OCaml, Rust Python and CMake. Added vers…
scemama Oct 25, 2023
c1c44e7
Add instructions for Rust and OCaml
scemama Oct 25, 2023
354d1cd
Removed JSON string in trexio.h
scemama Oct 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.16)

# Initialize the CMake project.
project(Trexio
VERSION 2.4.0
VERSION 2.4.2
DESCRIPTION "TREX I/O library"
LANGUAGES C Fortran
)
Expand Down
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ CHANGES

- Added state/energy
- Made state/id an index instead of an int
- Added JSON configuration data as a C variable in trexio.h
- Added JSON configuration file in tar.gz release
- Added Rust interface

2.3
---
Expand Down
56 changes: 53 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@

ACLOCAL_AMFLAGS = -I m4
CLEANFILES = trexio.mod
BUILT_SOURCES = trex.json
if HAVE_FORTRAN
BUILT_SOURCES = trexio.mod
else
BUILT_SOURCES =
BUILT_SOURCES += trexio.mod
endif
EXTRA_DIST = .git_hash

Expand Down Expand Up @@ -87,14 +86,63 @@ src_libtrexio_la_SOURCES = $(trexio_h) $(SOURCES)

# Include CMake-related files in the distribution.
EXTRA_DIST += CMakeLists.txt \
trex.json \
src/CMakeLists.txt \
tests/CMakeLists.txt \
tests/test_macros.h \
cmake/cmake_uninstall.cmake.in \
cmake/FindTREXIO.cmake


# =============== TESTS =============== #

TEST_FILES = \
tests/delete_group.c \
tests/delete_group_hdf5.c \
tests/delete_group_text.c \
tests/io_all.c \
tests/io_determinant.c \
tests/io_determinant_hdf5.c \
tests/io_determinant_text.c \
tests/io_dset_float.c \
tests/io_dset_float_hdf5.c \
tests/io_dset_float_text.c \
tests/io_dset_int.c \
tests/io_dset_int_hdf5.c \
tests/io_dset_int_text.c \
tests/io_dset_sparse.c \
tests/io_dset_sparse_hdf5.c \
tests/io_dset_sparse_text.c \
tests/io_dset_str.c \
tests/io_dset_str_hdf5.c \
tests/io_dset_str_text.c \
tests/io_jastrow.c \
tests/io_jastrow_hdf5.c \
tests/io_jastrow_text.c \
tests/io_num.c \
tests/io_num_hdf5.c \
tests/io_num_text.c \
tests/io_safe_dset_float.c \
tests/io_safe_dset_float_hdf5.c \
tests/io_safe_dset_float_text.c \
tests/io_str.c \
tests/io_str_hdf5.c \
tests/io_str_text.c \
tests/open.c \
tests/open_hdf5.c \
tests/open_text.c \
tests/overwrite_all.c \
tests/overwrite_all_hdf5.c \
tests/overwrite_all_text.c \
tests/pre_close.c \
tests/template_hdf5.c \
tests/template_text.c \
tests/test_f.f90 \
tests/test_macros.h \
tests/trexio_f.f90

EXTRA_DIST += $(TEST_FILES)

TESTS_C = \
tests/open_text \
tests/io_num_text \
Expand Down Expand Up @@ -221,6 +269,8 @@ src/trexio.c: $(trexio_h)
$(trexio_h): $(ORG_FILES) $(GENERATOR_FILES)
cd $(srcdir)/tools && ./build_trexio.sh

trex.json: $(trexio_h)

$(htmlizer): $(ORG_FILES) $(srcdir)/src/README.org
touch $(htmlizer)
cd $(srcdir)/tools && ./build_doc.sh
Expand Down
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![build](https://github.com/TREX-CoE/trexio/actions/workflows/actions.yml/badge.svg)](https://github.com/TREX-CoE/trexio/actions/workflows/actions.yml)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/TREX-CoE/trexio)

TREXIO is an open-source file format and library developed for the storage and manipulation of data produced by quantum chemistry calculations. It is designed with the goal of providing a reliable and efficient method of storing and exchanging wave function parameters and matrix elements, making it an important tool for researchers in the field of quantum chemistry. In this work, we present an overview of the TREXIO file format and library. The library consists of a front-end implemented in the C programming language and two different back-ends: a text back-end and a binary back-end utilizing the HDF5 library which enables fast read and write operations. It is compatible with a variety of platforms and has interfaces for the Fortran, Python, and OCaml programming languages. In addition, a suite of tools has been developed to facilitate the use of the TREXIO format and library, including converters for popular quantum chemistry codes and utilities for validating and manipulating data stored in TREXIO files. The simplicity, versatility, and ease of use of TREXIO make it a valuable resource for researchers working with quantum chemistry data.
TREXIO is an open-source file format and library developed for the storage and manipulation of data produced by quantum chemistry calculations. It is designed with the goal of providing a reliable and efficient method of storing and exchanging wave function parameters and matrix elements. The library consists of a front-end implemented in the C programming language and two different back-ends: a text back-end and a binary back-end utilizing the HDF5 library which enables fast read and write operations. It is compatible with a variety of platforms and has interfaces for the Fortran, Python, OCaml and Rust programming languages.

scemama marked this conversation as resolved.
Show resolved Hide resolved
## Minimal requirements (for users):

Expand Down Expand Up @@ -191,6 +191,34 @@ make python-test
We highly recommend to use virtual environments to avoid compatibility issues and to improve reproducibility.


## Rust API

The Rust API is available on Crates.io, so you can simply run
```
cargo add trexio
```
to your Rust project.

If you prefer to install the Rust API provided with this repository:
```
cargo add --path /path/to/trexio/rust/trexio
```

## OCaml API

The TREXIO OCaml API is available in OPAM:
```
opam install trexio
```

If you prefer to install it from this repository,

```
cd ocaml/trexio
make
opam install .
```

## Tutorial

TREXIO tutorials in Jupyter notebook format can be found in the
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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.4.2],[https://github.com/TREX-CoE/trexio/issues])
scemama marked this conversation as resolved.
Show resolved Hide resolved

AC_CONFIG_SRCDIR([Makefile.in])
AC_CONFIG_HEADERS([include/config.h])
Expand Down
1 change: 1 addition & 0 deletions ocaml/trexio/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ lib/trexio.h:
sources: lib/trexio.ml lib/trexio.h

clean:
rm lib/trexio.h lib/trexio.ml lib/trexio.mli lib/trexio_stubs.c
dune clean

.PHONY: sources default
2 changes: 1 addition & 1 deletion ocaml/trexio/dune-project
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(lang dune 3.1)

(name trexio)
(version 2.3.2)
(version 2.4.2)

(generate_opam_files false)

Expand Down
17 changes: 17 additions & 0 deletions ocaml/trexio/read_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@
ml_file = "trexio.ml"
mli_file = ml_file+"i"

def check_version():
with open('trexio.opam','r') as f:
for line in f:
if line.startswith("version"):
ocaml_version = line.split(':')[1].strip()[1:-1]
break
with open('../../configure.ac','r') as f:
for line in f:
if line.startswith("AC_INIT"):
trexio_version = line.split(',')[1].strip()[1:-1]
break
if ocaml_version != trexio_version:
print(f"Inconsistent versions:\nTREXIO:{trexio_version}\nOCaml: {ocaml_version}\n")
raise

def write_stubs(data):

with open("src/"+stubs_file,'r') as f:
Expand Down Expand Up @@ -643,10 +658,12 @@ def write_ml(data):

def main():

check_version()
with open(json_file,'r') as f:
data = json.load(f)
for group in data:
for element in data[group]:
print(f"{group}_{element}")
if data[group][element][0] == "str":
data[group][element][0] = "string"

Expand Down
Binary file removed ocaml/trexio/trexio-2.3.2.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion ocaml/trexio/trexio.opam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
version: "2.3.2"
version: "2.4.2"
synopsis: "Binding for the TREXIO Input/Output library"
description:
"TREXIO is a file format and library for storing wave functions and integrals for quantum chemistry."
Expand Down
2 changes: 1 addition & 1 deletion python/pytrexio/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.4.0"
__version__ = "2.4.2"
5 changes: 5 additions & 0 deletions rust/trexio/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Cargo.lock
src/generated.rs
target/
wrapper.h

26 changes: 26 additions & 0 deletions rust/trexio/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "trexio"
version = "2.4.2"
edition = "2021"
license = "BSD-3-Clause"
authors = ["Anthony Scemama <scemama@irsamc.ups-tlse.fr>", "Evgeny Posenitskiy"]
description = "TREXIO is an open-source file format and library developed for the storage and manipulation of data produced by quantum chemistry calculations. It is designed with the goal of providing a reliable and efficient method of storing and exchanging wave function parameters and matrix elements."
repository = "https://github.com/trex-coe/trexio"
keywords = ["quantum", "chemistry"]
readme = "README.md"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
bindgen = "0.65.1"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
reqwest = { version = "0.11", features = ["blocking", "rustls-tls"] }
tar = "0.4"
flate2 = "1.0"

[lib]
doctest = false

[dependencies]
hdf5 = "0.8.1"
10 changes: 10 additions & 0 deletions rust/trexio/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
default: src/generated.rs
cargo build
cargo test

src/generated.rs: build.py
python3 build.py

test: default
- cargo test -- --show-output

42 changes: 42 additions & 0 deletions rust/trexio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# TREXIO
<img src="https://trex-coe.eu/sites/default/files/styles/responsive_no_crop/public/2022-01/TREXIO%20Code.png" width=200>

TREXIO is an open-source file format and library developed for the storage and
manipulation of data produced by quantum chemistry calculations. It is designed
with the goal of providing a reliable and efficient method of storing and
exchanging wave function parameters and matrix elements.

This crate is the Rust binding for the TREXIO C library:
![GitHub release (latest by date)](https://img.shields.io/github/v/release/TREX-CoE/trexio)


## Documentation

[TREXIO Documentation.](https://trex-coe.github.io/trexio/)


## Citation

The journal article reference describing TREXIO can be cited as follows:

```
@article{10.1063/5.0148161,
author = {Posenitskiy, Evgeny and Chilkuri, Vijay Gopal and Ammar, Abdallah and Hapka, Michał and Pernal, Katarzyna and Shinde, Ravindra and Landinez Borda, Edgar Josué and Filippi, Claudia and Nakano, Kosuke and Kohulák, Otto and Sorella, Sandro and de Oliveira Castro, Pablo and Jalby, William and Ríos, Pablo López and Alavi, Ali and Scemama, Anthony},
title = "{TREXIO: A file format and library for quantum chemistry}",
journal = {The Journal of Chemical Physics},
volume = {158},
number = {17},
year = {2023},
month = {05},
issn = {0021-9606},
doi = {10.1063/5.0148161},
url = {https://doi.org/10.1063/5.0148161},
note = {174801},
eprint = {https://pubs.aip.org/aip/jcp/article-pdf/doi/10.1063/5.0148161/17355866/174801\_1\_5.0148161.pdf},
}
```

Journal paper: [![doi](https://img.shields.io/badge/doi-10.1063/5.0148161-5077AB.svg)](https://doi.org/10.1063/5.0148161)

ArXiv paper: [![arXiv](https://img.shields.io/badge/arXiv-2302.14793-b31b1b.svg)](https://arxiv.org/abs/2302.14793)

Loading
Loading