Skip to content
This repository was archived by the owner on Jun 14, 2022. It is now read-only.
This repository was archived by the owner on Jun 14, 2022. It is now read-only.

Use Verbosity in critical point calculations. #32

@g-bauer

Description

@g-bauer

In critical_point_binary, verbosity of VLEOptions is not used - neither in the final computation nor in the Brent optimization. We could add the option into the strut that implements ArgminOp. E.g.:

struct CritOp<U: EosUnit, E: EquationOfState> {
    eos: Rc<E>,
    tp: TPSpec<U>,
    opts: VLEOptions,
}

impl<U: EosUnit, E: EquationOfState> CritOp<U, E> {
    fn new(eos: &Rc<E>, tp: TPSpec<U>, opts: VLEOptions) -> Self {
        Self {
            eos: eos.clone(),
            tp,
            opts
        }
    }
}

yielding

    pub(crate) fn critical_point_binary(
        eos: &Rc<E>,
        tp: TPSpec<U>,
        options: VLEOptions,
    ) -> EosResult<Self>
    where
        QuantityScalar<U>: std::fmt::Display,
    {
        let solver = Brent::new(1e-10, 1.0 - 1e-10, options.tol.unwrap_or(TOL_CRIT_POINT));
        let cost = CritOp::new(eos, tp, options.clone());
        let x = Executor::new(cost, solver, 0.5)
            .max_iters(options.max_iter.unwrap_or(MAX_ITER_CRIT_POINT) as u64)
            .run()?
            .state
            .best_param;
        let moles = arr1(&[x, 1.0 - x]) * U::reference_moles();
        State::critical_point(eos, Some(&moles), None, options)
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions