Skip to content
This repository was archived by the owner on Sep 14, 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
14 changes: 6 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@ categories = ["science"]
exclude = ["/.github/*", "*.ipynb", "/examples/*", "/parameters/*"]

[dependencies]
quantity = "0.4"
feos-core = "0.1"
feos-dft = "0.1"
num-dual = "0.4"
num = "0.4"
quantity = "0.5"
feos-core = { git = "https://github.com/feos-org/feos-core" }
feos-dft = { git = "https://github.com/feos-org/feos-dft", branch = "v0.2.0" }
num-dual = "0.5"
num-traits = "0.2"
ndarray = { version = "0.15", features=["approx"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
indexmap = "1.8"
lazy_static = "1.4"
thiserror = "1.0"
numpy = { version = "0.15", optional = true }
pyo3 = { version = "0.15", optional = true }
numpy = { version = "0.16", optional = true }
pyo3 = { version = "0.16", optional = true }

[dev-dependencies]
approx = "0.4"
Expand Down
6 changes: 5 additions & 1 deletion build_wheel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ edition = "2018"
crate-type = ["cdylib"]

[dependencies]
quantity = "0.5"
feos-core = { git = "https://github.com/feos-org/feos-core" }
feos-dft = { git = "https://github.com/feos-org/feos-dft", branch = "v0.2.0" }
feos-pcsaft = { path = "..", features = ["python"] }
pyo3 = { version = "0.15", features = ["extension-module", "abi3", "abi3-py37"] }
pyo3 = { version = "0.16", features = ["extension-module", "abi3", "abi3-py37"] }
numpy = "0.16"
26 changes: 8 additions & 18 deletions src/python/dft.rs → build_wheel/src/dft.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
use super::parameters::*;
use crate::dft::PcSaftFunctional;
use feos_core::python::{PyContributions, PyVerbosity};
use feos_core::utils::{
DataSet, EquilibriumLiquidDensity, Estimator, LiquidDensity, VaporPressure,
};
use feos_core::*;
use feos_dft::adsorption::*;
use feos_dft::fundamental_measure_theory::FMTVersion;
use feos_dft::interface::*;
use feos_dft::python::*;
use feos_dft::solvation::*;
use feos_dft::*;
use feos_pcsaft::python::*;
use feos_pcsaft::PcSaftFunctional;
use numpy::*;
use pyo3::exceptions::PyValueError;
use pyo3::prelude::*;
Expand Down Expand Up @@ -55,10 +52,10 @@ impl PyPcSaftFunctional {
/// PcSaftFunctional
#[staticmethod]
#[pyo3(text_signature = "(parameters, fmt_version)")]
fn new_full(parameters: PyPcSaftParameters, fmt_version: PyFMTVersion) -> Self {
fn new_full(parameters: PyPcSaftParameters, fmt_version: FMTVersion) -> Self {
Self(Rc::new(PcSaftFunctional::new_full(
parameters.0,
fmt_version.0,
fmt_version,
)))
}
}
Expand All @@ -69,8 +66,6 @@ impl_state!(DFT<PcSaftFunctional>, PyPcSaftFunctional);
impl_state_molarweight!(DFT<PcSaftFunctional>, PyPcSaftFunctional);
impl_vle_state!(DFT<PcSaftFunctional>, PyPcSaftFunctional);

impl_estimator!(DFT<PcSaftFunctional>, PyPcSaftFunctional);

impl_planar_interface!(PcSaftFunctional);
impl_surface_tension_diagram!(PcSaftFunctional);

Expand All @@ -81,15 +76,15 @@ impl_pair_correlation!(PcSaftFunctional);
impl_solvation_profile!(PcSaftFunctional);

#[pymodule]
pub fn dft(py: Python<'_>, m: &PyModule) -> PyResult<()> {
pub fn dft(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_class::<PyPcSaftFunctional>()?;
m.add_class::<PyState>()?;
m.add_class::<PyPhaseDiagramPure>()?;
m.add_class::<PyPhaseDiagramBinary>()?;
m.add_class::<PyPhaseDiagramHetero>()?;
m.add_class::<PyPhaseEquilibrium>()?;
m.add_class::<PyPlanarInterface>()?;
m.add_class::<PyGeometry>()?;
m.add_class::<Geometry>()?;
m.add_class::<PyPore1D>()?;
m.add_class::<PyPore3D>()?;
m.add_class::<PyPairCorrelation>()?;
Expand All @@ -99,11 +94,6 @@ pub fn dft(py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_class::<PySurfaceTensionDiagram>()?;
m.add_class::<PyDFTSolver>()?;
m.add_class::<PySolvationProfile>()?;
m.add_class::<PyFMTVersion>()?;

let utils = PyModule::new(py, "utils")?;
utils.add_class::<PyDataSet>()?;
utils.add_class::<PyEstimator>()?;
m.add_submodule(utils)?;
m.add_class::<FMTVersion>()?;
Ok(())
}
27 changes: 3 additions & 24 deletions src/python/eos.rs → build_wheel/src/eos.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
use super::parameters::PyPcSaftParameters;
use crate::eos::polar::DQVariants;
use crate::eos::{PcSaft, PcSaftOptions};
use feos_core::python::{PyContributions, PyVerbosity};
use feos_core::utils::{
DataSet, EquilibriumLiquidDensity, Estimator, LiquidDensity, VaporPressure,
};
use feos_core::*;
use feos_pcsaft::python::PyPcSaftParameters;
use feos_pcsaft::{PcSaft, PcSaftOptions};
use numpy::convert::ToPyArray;
use numpy::{PyArray1, PyArray2};
use pyo3::exceptions::PyValueError;
Expand All @@ -15,16 +10,6 @@ use quantity::si::*;
use std::collections::HashMap;
use std::rc::Rc;

impl From<&str> for DQVariants {
fn from(str: &str) -> Self {
match str {
"dq35" => Self::DQ35,
"dq44" => Self::DQ44,
_ => panic!("dq_variant must be either \"dq35\" or \"dq44\""),
}
}
}

/// Initialize PC-SAFT equation of state.
///
/// Parameters
Expand Down Expand Up @@ -83,20 +68,14 @@ impl_state!(PcSaft, PyPcSaft);
impl_state_molarweight!(PcSaft, PyPcSaft);
impl_state_entropy_scaling!(PcSaft, PyPcSaft);
impl_vle_state!(PcSaft, PyPcSaft);
impl_estimator!(PcSaft, PyPcSaft);

#[pymodule]
pub fn eos(py: Python<'_>, m: &PyModule) -> PyResult<()> {
pub fn eos(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_class::<PyPcSaft>()?;
m.add_class::<PyState>()?;
m.add_class::<PyPhaseDiagramPure>()?;
m.add_class::<PyPhaseDiagramBinary>()?;
m.add_class::<PyPhaseDiagramHetero>()?;
m.add_class::<PyPhaseEquilibrium>()?;

let utils = PyModule::new(py, "utils")?;
utils.add_class::<PyDataSet>()?;
utils.add_class::<PyEstimator>()?;
m.add_submodule(utils)?;
Ok(())
}
48 changes: 45 additions & 3 deletions build_wheel/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,49 @@
use feos_pcsaft::python::feos_pcsaft;
use feos_core::python::joback::PyJobackRecord;
use feos_core::python::parameter::*;
use feos_core::{Contributions, Verbosity};
use feos_pcsaft::python::*;
use pyo3::prelude::*;
use pyo3::wrap_pymodule;
use quantity::python::__PYO3_PYMODULE_DEF_QUANTITY;

mod dft;
mod eos;
use dft::__PYO3_PYMODULE_DEF_DFT;
use eos::__PYO3_PYMODULE_DEF_EOS;

#[pymodule]
pub fn build_wheel(py: Python<'_>, m: &PyModule) -> PyResult<()> {
feos_pcsaft(py, m)
pub fn feos_pcsaft(py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_class::<PyIdentifier>()?;
m.add_class::<Verbosity>()?;
m.add_class::<Contributions>()?;
m.add_class::<PyChemicalRecord>()?;
m.add_class::<PyJobackRecord>()?;

m.add_class::<PyPcSaftRecord>()?;
m.add_class::<PyPureRecord>()?;
m.add_class::<PySegmentRecord>()?;
m.add_class::<PyBinaryRecord>()?;
m.add_class::<PyBinarySegmentRecord>()?;
m.add_class::<PyPcSaftParameters>()?;

m.add_wrapped(wrap_pymodule!(eos))?;
m.add_wrapped(wrap_pymodule!(dft))?;
m.add_wrapped(wrap_pymodule!(quantity))?;

py.run(
"\
import sys
sys.modules['feos_pcsaft.eos'] = eos
sys.modules['feos_pcsaft.dft'] = dft
quantity.SINumber.__module__ = 'feos_pcsaft.si'
quantity.SIArray1.__module__ = 'feos_pcsaft.si'
quantity.SIArray2.__module__ = 'feos_pcsaft.si'
quantity.SIArray3.__module__ = 'feos_pcsaft.si'
quantity.SIArray4.__module__ = 'feos_pcsaft.si'
sys.modules['feos_pcsaft.si'] = quantity
",
None,
Some(m.dict()),
)?;
Ok(())
}
46 changes: 25 additions & 21 deletions examples/PhaseDiagramBinary.ipynb

Large diffs are not rendered by default.

37 changes: 20 additions & 17 deletions examples/adsorption_isotherms.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"metadata": {},
"outputs": [],
"source": [
"params = PcSaftParameters.from_json([\"methanol\"], \"adsorption_params.json\")\n",
"params = PcSaftParameters.from_json([\"methanol\"], \"../parameters/rehner2020.json\")\n",
"func = PcSaftFunctional(params)"
]
},
Expand All @@ -42,8 +42,18 @@
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 20.2 s, sys: 90.2 ms, total: 20.3 s\n",
"Wall time: 20.2 s\n"
]
}
],
"source": [
"%%time\n",
"potential = ExternalPotential.LJ93(3.0, 100.0, 0.08)\n",
"pore = Pore1D(Geometry.Cartesian, 20*ANGSTROM, potential)\n",
"\n",
Expand Down Expand Up @@ -201,7 +211,7 @@
" return isotherm.pressure, isotherm.total_adsorption\n",
"\n",
"L_vec = SIArray1.linspace(10*ANGSTROM,40*ANGSTROM,7)\n",
"with ProcessPoolExecutor() as ex:\n",
"with ProcessPoolExecutor(1) as ex:\n",
" isotherms = [i for i in ex.map(plt_iso, L_vec)]"
]
},
Expand Down Expand Up @@ -249,8 +259,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 12.7 ms, sys: 40.1 ms, total: 52.8 ms\n",
"Wall time: 8.65 s\n"
"CPU times: user 14.1 ms, sys: 37.6 ms, total: 51.7 ms\n",
"Wall time: 8.7 s\n"
]
}
],
Expand Down Expand Up @@ -392,9 +402,9 @@
"metadata": {},
"outputs": [],
"source": [
"mix = PcSaftFunctional(PcSaftParameters.from_json([\"methanol\", \"ethanol\"], \"adsorption_params.json\"))\n",
"methanol = PcSaftFunctional(PcSaftParameters.from_json([\"methanol\"], \"adsorption_params.json\"))\n",
"ethanol = PcSaftFunctional(PcSaftParameters.from_json([\"ethanol\"], \"adsorption_params.json\"))"
"mix = PcSaftFunctional(PcSaftParameters.from_json([\"methanol\", \"ethanol\"], \"../parameters/rehner2020.json\"))\n",
"methanol = PcSaftFunctional(PcSaftParameters.from_json([\"methanol\"], \"../parameters/rehner2020.json\"))\n",
"ethanol = PcSaftFunctional(PcSaftParameters.from_json([\"ethanol\"], \"../parameters/rehner2020.json\"))"
]
},
{
Expand Down Expand Up @@ -519,7 +529,7 @@
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x7f3a497ba520>]"
"[<matplotlib.lines.Line2D at 0x7f87ce846fd0>]"
]
},
"execution_count": 20,
Expand Down Expand Up @@ -570,7 +580,7 @@
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x7f3a497f67c0>]"
"[<matplotlib.lines.Line2D at 0x7f87d6a55460>]"
]
},
"execution_count": 22,
Expand Down Expand Up @@ -630,13 +640,6 @@
"solver = DFTSolver().picard_iteration(tol=1e-5).anderson_mixing(max_iter=400)\n",
"solver"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
42 changes: 0 additions & 42 deletions examples/adsorption_params.json

This file was deleted.

Loading