#[repr(C)]
pub struct Properties {
pub d: f64,
pub mm: f64,
pub z: f64,
pub dp_dd: f64,
pub d2p_dd2: f64,
pub dp_dt: f64,
pub u: f64,
pub h: f64,
pub s: f64,
pub cv: f64,
pub cp: f64,
pub w: f64,
pub g: f64,
pub jt: f64,
pub kappa: f64,
}
pub mod detail {
use super::*;
use crate::composition::{Composition, CompositionError};
use crate::detail::Detail;
use crate::DensityError;
#[no_mangle]
pub extern "C" fn aga8_new() -> *mut Detail {
Box::into_raw(Box::new(Detail::new()))
}
#[no_mangle]
pub unsafe extern "C" fn aga8_free(ptr: *mut Detail) {
if ptr.is_null() {
return;
}
drop(Box::from_raw(ptr));
}
#[no_mangle]
pub unsafe extern "C" fn aga8_set_composition(
ptr: *mut Detail,
composition: &Composition,
_err: &mut CompositionError,
) {
assert!(!ptr.is_null());
let aga8 = &mut *ptr;
match aga8.set_composition(composition) {
Ok(_) => *_err = CompositionError::Ok,
Err(e) => *_err = e,
}
}
#[no_mangle]
pub unsafe extern "C" fn aga8_set_pressure(ptr: *mut Detail, pressure: f64) {
assert!(!ptr.is_null());
let aga8 = &mut *ptr;
aga8.p = pressure;
}
#[no_mangle]
pub unsafe extern "C" fn aga8_get_pressure(ptr: *mut Detail) -> f64 {
assert!(!ptr.is_null());
let aga8 = &mut *ptr;
aga8.p
}
#[no_mangle]
pub unsafe extern "C" fn aga8_set_temperature(ptr: *mut Detail, temperature: f64) {
assert!(!ptr.is_null());
let aga8 = &mut *ptr;
aga8.t = temperature;
}
#[no_mangle]
pub unsafe extern "C" fn aga8_get_temperature(ptr: *mut Detail) -> f64 {
assert!(!ptr.is_null());
let aga8 = &mut *ptr;
aga8.t
}
#[no_mangle]
pub unsafe extern "C" fn aga8_set_density(ptr: *mut Detail, density: f64) {
assert!(!ptr.is_null());
let aga8 = &mut *ptr;
aga8.d = density;
}
#[no_mangle]
pub unsafe extern "C" fn aga8_get_density(ptr: *mut Detail) -> f64 {
assert!(!ptr.is_null());
let aga8 = &mut *ptr;
aga8.d
}
#[no_mangle]
pub unsafe extern "C" fn aga8_get_properties(ptr: *const Detail) -> Properties {
assert!(!ptr.is_null());
let aga8 = &*ptr;
Properties {
d: aga8.d, mm: aga8.mm,
z: aga8.z,
dp_dd: aga8.dp_dd,
d2p_dd2: aga8.d2p_dd2,
dp_dt: aga8.dp_dt,
u: aga8.u,
h: aga8.h,
s: aga8.s,
cv: aga8.cv,
cp: aga8.cp,
w: aga8.w,
g: aga8.g,
jt: aga8.jt,
kappa: aga8.kappa,
}
}
#[no_mangle]
pub unsafe extern "C" fn aga8_calculate_pressure(ptr: *mut Detail) -> f64 {
assert!(!ptr.is_null());
let aga8 = &mut *ptr;
aga8.pressure()
}
#[no_mangle]
pub unsafe extern "C" fn aga8_calculate_molar_mass(ptr: *mut Detail) -> f64 {
assert!(!ptr.is_null());
let aga8 = &mut *ptr;
aga8.molar_mass();
aga8.mm
}
#[no_mangle]
pub unsafe extern "C" fn aga8_calculate_density(ptr: *mut Detail, _err: &mut DensityError) {
assert!(!ptr.is_null());
let aga8 = &mut *ptr;
match aga8.density() {
Ok(_) => *_err = DensityError::Ok,
Err(e) => *_err = e,
}
}
#[no_mangle]
pub unsafe extern "C" fn aga8_calculate_properties(ptr: *mut Detail) {
assert!(!ptr.is_null());
let aga8 = &mut *ptr;
aga8.properties();
}
}
pub mod gerg2008 {
use super::*;
use crate::composition::{Composition, CompositionError};
use crate::gerg2008::Gerg2008;
use crate::DensityError;
#[no_mangle]
pub extern "C" fn gerg_new() -> *mut Gerg2008 {
Box::into_raw(Box::new(Gerg2008::new()))
}
#[no_mangle]
pub unsafe extern "C" fn gerg_free(ptr: *mut Gerg2008) {
if ptr.is_null() {
return;
}
drop(Box::from_raw(ptr));
}
#[no_mangle]
pub unsafe extern "C" fn gerg_set_composition(
ptr: *mut Gerg2008,
composition: &Composition,
_err: &mut CompositionError,
) {
assert!(!ptr.is_null());
let gerg = &mut *ptr;
match gerg.set_composition(composition) {
Ok(_) => *_err = CompositionError::Ok,
Err(e) => *_err = e,
}
}
#[no_mangle]
pub unsafe extern "C" fn gerg_set_pressure(ptr: *mut Gerg2008, pressure: f64) {
assert!(!ptr.is_null());
let gerg = &mut *ptr;
gerg.p = pressure;
}
#[no_mangle]
pub unsafe extern "C" fn gerg_get_pressure(ptr: *mut Gerg2008) -> f64 {
assert!(!ptr.is_null());
let gerg = &mut *ptr;
gerg.p
}
#[no_mangle]
pub unsafe extern "C" fn gerg_set_temperature(ptr: *mut Gerg2008, temperature: f64) {
assert!(!ptr.is_null());
let gerg = &mut *ptr;
gerg.t = temperature;
}
#[no_mangle]
pub unsafe extern "C" fn gerg_get_temperature(ptr: *mut Gerg2008) -> f64 {
assert!(!ptr.is_null());
let gerg = &mut *ptr;
gerg.t
}
#[no_mangle]
pub unsafe extern "C" fn gerg_set_density(ptr: *mut Gerg2008, density: f64) {
assert!(!ptr.is_null());
let gerg = &mut *ptr;
gerg.d = density;
}
#[no_mangle]
pub unsafe extern "C" fn gerg_get_density(ptr: *mut Gerg2008) -> f64 {
assert!(!ptr.is_null());
let gerg = &mut *ptr;
gerg.d
}
#[no_mangle]
pub unsafe extern "C" fn gerg_get_properties(ptr: *const Gerg2008) -> Properties {
assert!(!ptr.is_null());
let gerg = &*ptr;
Properties {
d: gerg.d, mm: gerg.mm,
z: gerg.z,
dp_dd: gerg.dp_dd,
d2p_dd2: gerg.d2p_dd2,
dp_dt: gerg.dp_dt,
u: gerg.u,
h: gerg.h,
s: gerg.s,
cv: gerg.cv,
cp: gerg.cp,
w: gerg.w,
g: gerg.g,
jt: gerg.jt,
kappa: gerg.kappa,
}
}
#[no_mangle]
pub unsafe extern "C" fn gerg_calculate_pressure(ptr: *mut Gerg2008) -> f64 {
assert!(!ptr.is_null());
let gerg = &mut *ptr;
gerg.pressure()
}
#[no_mangle]
pub unsafe extern "C" fn gerg_calculate_molar_mass(ptr: *mut Gerg2008) -> f64 {
assert!(!ptr.is_null());
let gerg = &mut *ptr;
gerg.molar_mass();
gerg.mm
}
#[no_mangle]
pub unsafe extern "C" fn gerg_calculate_density(ptr: *mut Gerg2008, iflag: i32, _err: &mut DensityError) {
assert!(!ptr.is_null());
let gerg = &mut *ptr;
match gerg.density(iflag) {
Ok(_) => *_err = DensityError::Ok,
Err(e) => *_err = e,
}
}
#[no_mangle]
pub unsafe extern "C" fn gerg_calculate_properties(ptr: *mut Gerg2008) {
assert!(!ptr.is_null());
let gerg = &mut *ptr;
gerg.properties();
}
}