feos-org / feos

FeOs - A Framework for Equations of State and Classical Density Functional Theory
Other
115 stars 22 forks source link

C/C++ interface #141

Open ianhbell opened 1 year ago

ianhbell commented 1 year ago

I would like to experiment with the very exciting uv-theory stuff in my code, and I can call that from Python, but to integrate with the tools I am developing, I need a C/C++ interface. Is it possible to develop such an interface easily with rust?

g-bauer commented 1 year ago

Technically, it is possible. Practically it would involve a lot of work. There are tools to generate C/C++ header files from the Rust library (cbindgen) but - similar to the Python interface - we would need to define wrapper functions with C compatible data types.

The amount of work needed depends on what functionalities of the library you need. I can create an example repository that showcases how such an interface could be built for the specific use case in question.

ianhbell commented 1 year ago

Yes, this is what I figured/feared. I hoped that the bright, shiny rust might have magical capabilities that have eluded C++ thus far.

What I need is the core derivatives of the residual Helmholtz energy with respect to temperature and density, up to high degrees, most especially to calculate speed of sound. I'm trying to find a model that can give good representations of speed of sound as well as densities and pressure, with accuracies on par with the multiparameter EOS implemented in REFPROP/CoolProp. So far the "old SAFT" models don't meet the brief, but I am hopeful about the newer approaches; SAFT-VR-Mie is the best candidate of the SAFT models so far that are implemented in Clapeyron.jl.