Skip to content
This repository was archived by the owner on Jul 28, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
57 changes: 56 additions & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
37 changes: 16 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,42 +1,37 @@
[package]
name = "feos-dft"
version = "0.1.0"
authors = ["Philipp Rehner <rehner@itt.uni-stuttgart.de>"]
authors = ["Philipp Rehner <prehner@ethz.ch>"]
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"]
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```
13 changes: 13 additions & 0 deletions build_wheel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "feos_dft"
version = "0.1.0"
authors = ["Philipp Rehner <prehner@ethz.ch"]
edition = "2018"

[lib]
crate-type = ["cdylib"]

[dependencies]
feos-dft = { path = "..", features = ["python"] }
pyo3 = { version = "0.15", features = ["extension-module", "abi3", "abi3-py36"] }

7 changes: 7 additions & 0 deletions build_wheel/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use feos_dft::python::feos_dft;
use pyo3::prelude::*;

#[pymodule]
pub fn build_wheel(py: Python<'_>, m: &PyModule) -> PyResult<()> {
feos_dft(py, m)
}
10 changes: 5 additions & 5 deletions examples/FundamentalMeasureTheory.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
"<matplotlib.legend.Legend at 0x7fd0ebb7ff40>"
"<matplotlib.legend.Legend at 0x7f53cf1c8a30>"
]
},
"execution_count": 3,
Expand Down Expand Up @@ -180,9 +180,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "feos-dft",
"display_name": "feos",
"language": "python",
"name": "feos-dft"
"name": "feos"
},
"language_info": {
"codemirror_mode": {
Expand Down
5 changes: 2 additions & 3 deletions src/convolver/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -250,14 +249,14 @@ impl<T: DualNum<f64> + DctNum + ScalarOperand> PolarTransform<T> {

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),
))
});
Expand Down
9 changes: 5 additions & 4 deletions src/solver.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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} | {}",
Expand Down Expand Up @@ -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);
Expand All @@ -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} ",
Expand Down