Skip to main content

Dopyqo-rs: Many-body matrix elements calculation using Rust

Project description

oooooooooo.                                                                                   
`888'   `Y8b                                                                                  
 888      888  .ooooo.  oo.ooooo.  oooo    ooo  .ooooo oo  .ooooo.          oooo d8b  .oooo.o 
 888      888 d88' `88b  888' `88b  `88.  .8'  d88' `888  d88' `88b         `888""8P d88(  "8 
 888      888 888   888  888   888   `88..8'   888   888  888   888 8888888  888     `"Y88b.  
 888     d88' 888   888  888   888    `888'    888   888  888   888          888     o.  )88b 
o888bood8P'   `Y8bod8P'  888bod8P'     .8'     `V8bod888  `Y8bod8P'         d888b    8""888P' 
                         888       .o..P'            888.                                     
                        o888o      `Y8P'             8P'                                      
                                                     "                                        
 
                      Many-body matrix elements calculation using Rust

Code for calculating Ewald sums and matrix elements of norm-conserving pseudopotentials in the basis of Kohn-Sham orbitals, expressed in plane-waves.

Installation as a python package

pip install dopyqo-rs

Make sure to have the following installed, otherwise errors will occur during installation:

Development environment instructions

Initilaizing PyO3 project

python3.11 -m venv .venv
source .venv/bin/activate
pip install maturin

For crate versions see notes in this section.

Building python package with maturin develop --release. This will build the package and install it into the Python virtualenv previously created and activated. The package is then ready to be used from python:

$ maturin develop --release
# lots of progress output as maturin runs the compilation...
$ python
>>> import dopyqo_rs

Rust crates version issues

!Do not upgarde ndarray, ndarray-linalg, pyo3 and numpy crates! pyo3 and numpy version 0.23.x depend on ndarray 0.16. ndarray-linalg does not yet support ndarray 0.16. This is also noted in the linalg example of the numpy crate (https://github.com/PyO3/rust-numpy/blob/main/examples/linalg/Cargo.lock). To make pyo3/numpy 0.23.x work with ndarray-linalg you have to manually tweak the Cargo.lock file as they do in the numpy example for linalg (link above). The fact that ndarray-linalg does not yet support ndarray 0.16 is discussed in the following issues on the ndarray-linalg github:

Apperantly ndarray-linalg is not actively maintained as of the 20.12.2024.

Maybe switch to nalgebra which seems to be actively maintained but seems less flexible than ndarray

This all means for now that you should use the following versions:

  • pyo3 0.21.0
  • numpy 0.21.0
  • ndarray 0.15.6
  • ndarray-linalg 16.0

Tested with Rust version 1.84.0

Performance testing

To get in-depth information about all function calls in the rust code and also get a bit more performance add the following to the Cargo.toml:

[profile.release]
debug = true       # Debug symbols for our profiler to get in-depth function call information.

then install py-spy via pip (pip install py-spy) and run the following to generate a flamegraph in profile.svg

maturin develop --release
py-spy record -i -n -o profile.svg -- python script_using_dopyqo_rs.py 

Authors

  • Erik Schultheis

Contact

Feel free to contact David Melching if you have any questions.

Citation

If you use portions of this code please cite our paper:

@misc{Schultheis2025ManyBody,
      title={Many-body post-processing of density functional calculations using the variational quantum eigensolver for Bader charge analysis}, 
      author={Erik Schultheis and Alexander Rehn and Gabriel Breuil},
      year={2025},
      eprint={-},
      archivePrefix={arXiv},
      primaryClass={quant-ph},
      url={https://arxiv.org/abs/-}, 
      doi={-}
}

Acknowledgment

This project was made possible by the DLR Quantum Computing Initiative and the Federal Ministry for Economic Affairs and Climate Action; https://qci.dlr.de/quanticom.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dopyqo_rs-0.0.4.tar.gz (49.9 kB view details)

Uploaded Source

File details

Details for the file dopyqo_rs-0.0.4.tar.gz.

File metadata

  • Download URL: dopyqo_rs-0.0.4.tar.gz
  • Upload date:
  • Size: 49.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for dopyqo_rs-0.0.4.tar.gz
Algorithm Hash digest
SHA256 a25a784d8a91320b2b8390f549b60c226a20d3dbc55e927fa87208d0c64a9b38
MD5 b712b23f4a99cab9c15ee5d956276378
BLAKE2b-256 6d699bed979941e4d10c192a8939ed6c4852c736ff8fe9097cc57824b2a237e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page