Skip to content

Commit

Permalink
Merge pull request #129 from TREX-CoE/rust
Browse files Browse the repository at this point in the history
Rust interface
  • Loading branch information
q-posev committed Oct 25, 2023
2 parents 537bb19 + 354d1cd commit 2d3080a
Show file tree
Hide file tree
Showing 26 changed files with 2,205 additions and 11 deletions.
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.

## 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])

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 <[email protected]>", "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

0 comments on commit 2d3080a

Please sign in to comment.