CADETProcess.simulator.Cadet#

class CADETProcess.simulator.Cadet(timeout, use_dll, time_resolution, resolution_cutoff, n_cycles, evaluate_stationarity, n_cycles_min, n_cycles_batch, n_cycles_max, raise_exception_on_max_cycles)[source]#

Bases: SimulatorBase

CADET class for running a simulation for given process objects.

Attributes:
install_path: str

Path to the root of the CADET installation

time_outUnsignedFloat

Maximum duration for simulations

model_solver_parametersModelSolverParameters

Container for solver parameters

unit_discretization_parametersUnitDiscretizationParameters

Container for unit discretization parameters

discretization_weno_parametersDiscretizationWenoParameters

Container for weno discretization parameters in units

adsorption_consistency_solver_parametersConsistencySolverParameters

Container for consistency solver parameters

solver_parametersSolverParameters

Container for general solver settings

time_integrator_parametersSolverTimeIntegratorParameters

Container for time integrator parameters

return_parametersReturnParameters

Container for return information of the system

..todo::

Implement method for loading CADET file that have not been generated with CADETProcess and create Process

add_inlet_section(model_units: Dict, sec_index: int, unit_index: int, coeffs: ndarray) None[source]#

Add piecewise cubic polynomial section to inlet.

add_parameter_section(model_units: Dict, sec_index: int, unit_index: int, unit_model: UnitBaseClass, parameter: str, state: ndarray) None[source]#

Add section value to parameter branch.

cadet_connections(flow_rates: dict, flow_sheet: FlowSheet) list[source]#

list: Connections matrix for flow_rates state.

Parameters:
flow_ratesdict

UnitOperations with outgoing flow rates.

flow_sheetFlowSheet

Object which hosts units (for getting unit index).

Returns:
lslist

Connections matrix for DESCRIPTION.

check_cadet() bool[source]#

Check if CADET installation can run a basic LWE example.

Returns:
bool

True if the test simulation completed successfully, False otherwise.

Raises:
CADETProcessError

If the simulation fails, an exception is raised with the error message.

Notes

This method tests the CADET installation by executing a basic LWE (Load, Wash, Elute) example. It creates a CADET model using the LWE data stored in an HDF5 file and runs the simulation. After the simulation, it checks the return code to determine if the test was successful.

create_lwe(file_path=None)[source]#

Create basic LWE example and loads the configuration into self.

Parameters:
file_pathPath, optional

Path to store HDF5 file. If None, temporary file will be created and deleted after simulation.

get_adsorption_config(binding: BindingBaseClass) Dict[source]#

Config branch /input/model/unit_xxx/adsorption for individual unit.

Binding model parameters are extracted and converted to CADET format.

Parameters:
bindingBindingBaseClass

Binding model

See also

get_unit_config
get_cadet_version() tuple[str, str][source]#

Get version and branch name of the currently instanced CADET build.

Returns:
tuple[str, str]

The CADET version as x.x.x and the branch name.

Raises:
ValueError

If version and branch name cannot be found in the output string.

RuntimeError

If any unhandled event during running the subprocess occurs.

get_input_model(process: Process) Dict[source]#

Config branch /input/model/.

See also

model_connections
model_solver
model_units
input_model_parameters

Notes

!!! External functions not implemented yet

get_input_return(process: Process) dict[source]#

Config branch /input/return.

get_input_sensitivity(process: Process) dict[source]#

Config branch /input/sensitivity.

get_input_solver(process: Process) Dict[source]#

Config branch /input/solver/.

See also

solver_sections
solver_time_integrator
get_model_connections(process: Process) Dict[source]#

Config branch /input/model/connections.

get_model_units(process: Process) Dict[source]#

Config branches for all units /input/model/unit_000 … unit_xxx.

get_new_cadet_instance() Cadet[source]#

Return new CadetAPI instance.

get_parameter_sensitivities(process: Process) Dict[source]#

Config branches for all parameter sensitivities /input/sensitivity/param_000 … param_xxx.

get_port_index(flow_sheet: FlowSheet, unit: UnitBaseClass, port: str) int[source]#

Return port index in CADET format xxx.

Parameters:
portstring

Indexed port

unitUnitOperation

port of unit

Returns:
port_indexindex

Return the port_index in CADET format xxx

get_process_config(process: Process) Dict[source]#

Create the CADET config.

Returns:
configDict

/

Notes

Sensitivities not implemented yet.

get_reaction_config(reaction: ReactionBaseClass) Dict[source]#

Config branch /input/model/unit_xxx/reaction for individual unit.

Reaction model parameters are extracted and converted to CADET format.

Parameters:
reactionReactionBaseClass

Reaction model

See also

get_unit_config
get_sensitivity_config(process: Process, sens: Dict) Dict[source]#

Return sensitivity config.

get_simulation_results(process: Process, cadet: Cadet, time_elapsed: float | None = None, return_information: dict | None = None) SimulationResults[source]#

Read simulation results from CADET configuration.

Parameters:
processProcess

Process that was simulated.

cadetCadetAPI

Cadet object with simulation results.

time_elapsedfloat

Time of simulation.

return_information: ReturnInformation

CADET-cli return information.

Returns:
resultsSimulationResults

Simulation results including process and solver configuration.

..todo::

Implement method to read .h5 files that have no process associated.

get_solver_sections(process: Process) Dict[source]#

Config branch /input/solver/sections.

get_tempfile_name() str[source]#

Return name of tempfile.

get_unit_config(unit: UnitBaseClass) Dict[source]#

Config branch /input/model/unit_xxx for individual unit.

The unit operation parameters are converted to CADET format

Notes

In CADET, the parameter unit_config[‘discretization’].NBOUND should be moved to binding config or unit config

get_unit_index(process: Process, unit: UnitBaseClass) str[source]#

Return unit index in CADET format unit_xxx.

Parameters:
processProcess

process to be simulated

unitUnitOperation

Indexed object

Returns:
unit_indexstr

Return the unit index in CADET format unit_XXX

get_unit_return_parameters(process: Process) Dict[source]#

Config branches for all units /input/return/unit_000 … unit_xxx.

load_from_h5(file_path: PathLike) Cadet[source]#

Load data from HDF5 file.

load_simulation_results(process: Process, file_path: PathLike) SimulationResults[source]#

Load simulation results.

locks_process() Callable[source]#

Lock process to enable caching.

run_h5(file_path: PathLike) Cadet[source]#

Load and run h5 file.

save_to_h5(process: Process, file_path: PathLike) None[source]#

Save process config as h5 file.

set_section_dependent_parameters(model_units: Dict, process: Process) None[source]#

Add time dependent model parameters to units.

property temp_dir: dict#

Return temp dir.

timeout#

Parameter descriptor for unsigned floating-point parameters.

use_dll#

Parameter descriptor constrained to boolean values.

Notes

This class also supports casting integers 0 and 1 to their boolean equivalents.

property version: str#

str: The version of the Cadet installation.