diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ab9c105 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,24 @@ +name: Release + +on: + push: + tags: ["v*"] + +jobs: + release-crates-io: + name: Release crates.io + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: login + args: ${{ secrets.CRATES_IO_TOKEN }} + - uses: actions-rs/cargo@v1 + with: + command: publish diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3567162..a7f1074 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,9 +15,7 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Install openBLAS - run: sudo apt-get install -y libopenblas-dev - name: Build run: cargo build --release - name: Run tests - run: cargo test --release --features="openblas-system" + run: cargo test --release diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 41b3741..bd58f0c 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -18,9 +18,64 @@ jobs: maturin-version: latest manylinux: auto command: build - args: --release --out dist --no-sdist --cargo-extra-args="--features python --features openblas-static" + args: --release --out dist --no-sdist -m build_wheel/Cargo.toml - name: Upload wheels uses: actions/upload-artifact@v2 with: name: dist path: dist + macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.9 + architecture: x64 + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + default: true + - name: Build wheels - x86_64 + uses: messense/maturin-action@main + with: + target: x86_64 + args: --release --out dist --no-sdist -m build_wheel/Cargo.toml + - name: Build wheels - universal2 + uses: messense/maturin-action@main + with: + args: --release --universal2 --out dist --no-sdist -m build_wheel/Cargo.toml + - name: Upload wheels + uses: actions/upload-artifact@v2 + with: + name: dist + path: dist + windows: + runs-on: windows-latest + strategy: + matrix: + target: [x64, x86] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.9 + architecture: ${{ matrix.target }} + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + default: true + - name: Build wheels + uses: messense/maturin-action@main + with: + target: ${{ matrix.target }} + args: --release --out dist --no-sdist -m build_wheel/Cargo.toml + - name: Upload wheels + uses: actions/upload-artifact@v2 + with: + name: dist + path: dist \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..c58c610 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [0.1.0] - 2021-12-22 +### Added +- Initial release diff --git a/Cargo.toml b/Cargo.toml index 1f64051..6f06c12 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,42 +1,37 @@ [package] name = "feos-dft" version = "0.1.0" -authors = ["Philipp Rehner "] +authors = ["Philipp Rehner "] edition = "2018" +license = "MIT OR Apache-2.0" +description = "Generic classical DFT implementations for the `feos` project." +homepage = "https://github.com/feos-org" +readme = "README.md" +repository = "https://github.com/feos-org/feos-dft" +keywords = ["physics", "thermodynamics", "interfaces", "adsorption"] +categories = ["science"] +exclude = ["/.github/*", "*.ipynb"] -[lib] -name = "feos_dft" -crate-type = ["rlib", "cdylib"] +[package.metadata.docs.rs] +rustdoc-args = [ "--html-in-header", "./docs-header.html" ] [dependencies] -quantity = "0.3" +quantity = { version = "0.4", features = ["linalg"] } feos-core = "0.1" -num-dual = "0.3" +num-dual = "0.4" ndarray = { version = "0.15", features = ["serde", "rayon"] } -ndarray-linalg = "0.14" ndarray-stats = "0.5" rustdct = "0.6" rustfft = "6.0" log = "0.4" -special-fun = "0.2" ang = "0.5" num-traits = "0.2" -numpy = { version = "0.14", optional = true } libc = "0.2" gauss-quad = "0.1" petgraph = "0.6" - -[dependencies.pyo3] -version = "0.14" -features = ["extension-module", "abi3", "abi3-py36"] -optional = true +numpy = { version = "0.15", optional = true } +pyo3 = { version = "0.15", optional = true } [features] default = [] -python = ["pyo3", "numpy", "feos-core/python"] -openblas-system = ["feos-core/openblas-system"] -openblas-static = ["feos-core/openblas-static"] -intel-mkl-system = ["feos-core/intel-mkl-system"] -intel-mkl-static = ["feos-core/intel-mkl-static"] -netlib-system = ["feos-core/netlib-system"] -netlib-static = ["feos-core/netlib-static"] +python = ["pyo3", "numpy", "feos-core/python"] \ No newline at end of file diff --git a/README.md b/README.md index f2e8fe0..1522431 100644 --- a/README.md +++ b/README.md @@ -1 +1,24 @@ # FeOs-DFT + +[![crate](https://img.shields.io/crates/v/feos-dft.svg)](https://crates.io/crates/feos-dft) +[![documentation](https://docs.rs/feos-dft/badge.svg)](https://docs.rs/feos-dft) +[![minimum rustc 1.51](https://img.shields.io/badge/rustc-1.51+-red.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html) + +Generic classical DFT implementations for the `feos` project. + +## Installation + +Add this to your `Cargo.toml` + +```toml +[dependencies] +feos-dft = "0.1" +``` + +## Test building python wheel + +From within a Python virtual environment with `maturin` installed, type + +``` +maturin build --release --out dist --no-sdist -m build_wheel/Cargo.toml +``` diff --git a/build_wheel/Cargo.toml b/build_wheel/Cargo.toml new file mode 100644 index 0000000..9201bfd --- /dev/null +++ b/build_wheel/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "feos_dft" +version = "0.1.0" +authors = ["Philipp Rehner , m: &PyModule) -> PyResult<()> { + feos_dft(py, m) +} diff --git a/examples/FundamentalMeasureTheory.ipynb b/examples/FundamentalMeasureTheory.ipynb index c0f8869..920e961 100644 --- a/examples/FundamentalMeasureTheory.ipynb +++ b/examples/FundamentalMeasureTheory.ipynb @@ -39,14 +39,14 @@ "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 8.56 s, sys: 4.3 s, total: 12.9 s\n", - "Wall time: 7.2 s\n" + "CPU times: user 5.22 s, sys: 0 ns, total: 5.22 s\n", + "Wall time: 5.22 s\n" ] }, { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 3, @@ -180,9 +180,9 @@ ], "metadata": { "kernelspec": { - "display_name": "feos-dft", + "display_name": "feos", "language": "python", - "name": "feos-dft" + "name": "feos" }, "language_info": { "codemirror_mode": { diff --git a/src/convolver/transform.rs b/src/convolver/transform.rs index 6c8940d..3ec46f8 100644 --- a/src/convolver/transform.rs +++ b/src/convolver/transform.rs @@ -4,7 +4,6 @@ use ndarray::*; use num_dual::*; use rustdct::{DctNum, DctPlanner, TransformType2And3}; use rustfft::{num_complex::Complex, Fft, FftPlanner}; -use special_fun::FloatSpecial; use std::f64::consts::PI; use std::ops::{DivAssign, SubAssign}; use std::rc::Rc; @@ -250,14 +249,14 @@ impl + DctNum + ScalarOperand> PolarTransform { let mut j = Array1::from_shape_fn(2 * points, |i| { Complex::from(T::from( - (gamma * x0 * (alpha * ((i + 1) as f64 - points as f64)).exp()).besselj(1.0) + (gamma * x0 * (alpha * ((i + 1) as f64 - points as f64)).exp()).bessel_j1() / ((2 * points) as f64), )) }); ifft.process(j.as_slice_mut().unwrap()); let mut jv = Array1::from_shape_fn(2 * points, |i| { Complex::from(T::from( - (gamma * x0 * (alpha * ((i + 1) as f64 - points as f64)).exp()).besselj(2.0) + (gamma * x0 * (alpha * ((i + 1) as f64 - points as f64)).exp()).bessel_j2() / ((2 * points) as f64), )) }); diff --git a/src/solver.rs b/src/solver.rs index e6775c0..4ae52f1 100644 --- a/src/solver.rs +++ b/src/solver.rs @@ -1,6 +1,6 @@ use feos_core::{EosError, EosResult}; use ndarray::prelude::*; -use ndarray_linalg::{Norm, SolveH}; +use num_dual::linalg::{norm, LU}; use std::collections::VecDeque; use std::fmt; @@ -190,7 +190,7 @@ impl SolverParameter { } // check for convergence - let res = resm.norm() / (resm.len() as f64).sqrt(); + let res = norm(&resm) / (resm.len() as f64).sqrt(); if output { println!( "Picard iteration {:3} | {:>4} | {:.6e} | {}", @@ -257,7 +257,8 @@ impl SolverParameter { }); alpha = Array::zeros(m + 1); alpha[m] = 1.0; - r.solveh_inplace(&mut alpha)?; + alpha = LU::new(r)?.solve(&alpha); + // r.solveh_inplace(&mut alpha)?; // update solution x.fill(0.0); @@ -272,7 +273,7 @@ impl SolverParameter { // check for convergence let resv = &resm[m - 1]; - let res = resv.norm() / (resv.len() as f64).sqrt(); + let res = norm(resv) / (resv.len() as f64).sqrt(); if output { println!( "Anderson mixing {:3} | {:>4} | {:.6e} ",