feos_campd/process/
mod.rs

1use crate::{solver::GeneralConstraint, ChemicalRecord};
2use feos_ad::{HelmholtzEnergyWrapper, ParametersAD};
3use feos_core::EosResult;
4use num_dual::DualNum;
5
6#[cfg(test)]
7mod orc;
8#[cfg(test)]
9pub use orc::OrganicRankineCycle;
10
11/// Information about bounds and initial values of continuous variables.
12#[derive(Clone, Copy)]
13pub struct ContinuousVariable {
14    pub lobnd: f64,
15    pub upbnd: f64,
16    pub init: f64,
17}
18
19impl ContinuousVariable {
20    pub fn new(lobnd: f64, upbnd: f64, init: f64) -> Self {
21        Self { lobnd, upbnd, init }
22    }
23}
24
25/// Generic process model to be used in an [IntegratedDesign](../IntegratedDesign).
26pub trait ProcessModel<E: ParametersAD, const N_X: usize, const N: usize> {
27    fn variables(&self) -> [ContinuousVariable; N_X];
28
29    fn constraints(&self) -> Vec<GeneralConstraint>;
30
31    fn evaluate<D: DualNum<f64> + Copy>(
32        &self,
33        eos: &HelmholtzEnergyWrapper<E, D, N>,
34        chemical_records: [&ChemicalRecord<D>; N],
35        x: [D; N_X],
36    ) -> EosResult<(D, Vec<D>)>;
37}