bird.postprocess package

bird.postprocess.conditional_mean module

bird.postprocess.conditional_mean.compute_cond_mean(case_folder, vert_ind, field_name_list, window_ave, n_bins=32, diff_val_list=[], diff_name_list=[])
bird.postprocess.conditional_mean.save_cond(filename, fields_cond)
bird.postprocess.conditional_mean.sequencePlot(cond, folder_names, field_name, case_names=[], symbList=['-', '-d', '-^', '-.', '-s', '-o', '-+'])

bird.postprocess.early_pred module

bird.postprocess.early_pred.bayes_fit(data_dict, num_warmup=1000, num_samples=500)
bird.postprocess.early_pred.bayes_step(x, y=None, y_err=0.1)
bird.postprocess.early_pred.fit_and_ext(data_dict, func=<function sigm_fit>, bounds=([0, 0, 0, 0, 0, 0], [0.05, 1.7, inf, 0.015, 1.3, inf]))
bird.postprocess.early_pred.multi_data_load(data_root, tmax=600, data_files=None, color_files=None)
bird.postprocess.early_pred.plotAllEarly(data_dict, color_files=None, chop=False, extrap=False)
bird.postprocess.early_pred.plotAllEarly_uq(data_dict, color_files=None)
bird.postprocess.early_pred.sigm_fit(x, a, b, c, d, e, f)
bird.postprocess.early_pred.sigm_fit_jax(theta, x)
bird.postprocess.early_pred.smooth(y, box_pts)

bird.postprocess.kla_utils module

bird.postprocess.kla_utils.bayes_step(time_obs: ndarray | Array, concentration_obs: ndarray | Array)

Prior and likelihood definition for MCMC sampling

bird.postprocess.kla_utils.c_model(theta: list, t: ndarray | Array, t0: float, c0: float) ndarray | Array

Model of concentration vs time function involving kLa

bird.postprocess.kla_utils.check_data_size(time_obs: ndarray, concentration_obs: ndarray)

Sanity checks

bird.postprocess.kla_utils.compute_accuracy(hmc_samples: dict, time_obs: ndarray, concentration_obs: ndarray) float

Compute how well the sampled parameter explain the observed concentration data

bird.postprocess.kla_utils.compute_kla(data_t: ndarray, data_c: ndarray, num_warmup: int = 4000, num_samples: int = 1000, max_chop: int | None = None, bootstrap: bool = True) dict

Main loop to compute kla

bird.postprocess.kla_utils.hmc_samples_2_np_samples(hmc_samples: dict) ndarray

Convert hmc samples generated by numpyro to numpy

bird.postprocess.kla_utils.np_samples_2_pred(np_hmc_samples: ndarray, time_obs: ndarray, concentration_obs: ndarray) dict

Go from parameter samples to predictions. Useful for accuracy calculation and plotting.

bird.postprocess.kla_utils.post_cal(hmc_samples: dict, time_obs: ndarray, concentration_obs: ndarray) None

Plot MCMC results

bird.postprocess.kla_utils.print_res_dict(res_dict: dict) None

Log kla and cstar to screen

bird.postprocess.kla_utils.read_kla_cstar(hmc_samples: dict) dict

go from hmc samples generated by numpyro to relevant arrays

bird.postprocess.post_quantities module

bird.postprocess.post_quantities.compute_ave_bubble_diam(case_folder: str, time_folder: str, n_cells: int | None = None, volume_time: str | None = None, field_dict: dict | None = None) tuple[float, dict]

Calculate averaged bubble diameter over the liquid volume

\[\frac{1}{V_{\rm liq, tot}} \int_{V_{\rm liq}} d_{\rm gas} dV\]
where:
  • \(V_{\rm liq, tot}\) is the toal volume of liquid in \(m^3\)

  • \(d_{\rm gas}\) is the bubble diameter in \(m\)

  • \(V_{\rm liq}\) is the volume of liquid where \(d_{\rm gas}\) is measured in \(m^3\)

Parameters:
  • case_folder (str) – Path to case folder

  • time_folder (str) – Name of time folder to analyze

  • n_cells (int | None) – Number of cells in the domain. If None, it will deduced from the field reading

  • volume_time (str | None) – Time folder to read to get the cell volumes. If None, finds volume time automatically

  • field_dict (dict) – Dictionary of fields used to avoid rereading the same fields to calculate different quantities

Returns:

  • diam (float) – Volume averaged gas holdup

  • field_dict (dict) – Dictionary of fields read

bird.postprocess.post_quantities.compute_ave_conc_liq(case_folder: str, time_folder: str, species_name: str = 'CO2', n_cells: int | None = None, volume_time: str | None = None, field_dict: dict | None = None) tuple[float, dict]

Calculate liquid volume averaged concentration of a species at a given time

\[\frac{1}{V_{\rm liq, tot}} \int_{V_{\rm liq}} \rho_{\rm liq} Y / W dV_{\rm liq}\]
where:
  • \(V_{\rm liq, tot}\) is the toal volume of liquid

  • \(\rho_{\rm liq}\) is the liquid density

  • \(Y\) is the species mass fraction

  • \(W\) is the species molar mass

  • \(V_{\rm liq}\) is the volume of liquid where \(Y\) is measured

Parameters:
  • case_folder (str) – Path to case folder

  • time_folder (str) – Name of time folder to analyze

  • species_name (str) – Name of the species

  • n_cells (int | None) – Number of cells in the domain. If None, it will deduced from the field reading

  • volume_time (str | None) – Time folder to read to get the cell volumes. If None, finds volume time automatically

  • field_dict (dict) – Dictionary of fields used to avoid rereading the same fields to calculate different quantities

Returns:

  • conc_ave (float) – Liquid volume averaged species concentration

  • field_dict (dict) – Dictionary of fields read

bird.postprocess.post_quantities.compute_ave_y_liq(case_folder: str, time_folder: str, species_name: str = 'CO2', n_cells: int | None = None, volume_time: str | None = None, field_dict: dict | None = None) tuple[float, dict]

Calculate liquid volume averaged mass fraction of a species at a given time

\[\frac{1}{V_{\rm liq, tot}} \int_{V_{\rm liq}} Y dV_{\rm liq}\]
where:
  • \(V_{\rm liq, tot}\) is the toal volume of liquid

  • \(Y\) is the species mass fraction

  • \(V_{\rm liq}\) is the volume of liquid where \(Y\) is measured

Parameters:
  • case_folder (str) – Path to case folder

  • time_folder (str) – Name of time folder to analyze

  • n_cells (int | None) – Number of cells in the domain. If None, it will deduced from the field reading

  • volume_time (str | None) – Time folder to read to get the cell volumes. If None, finds volume time automatically

  • species_name (str) – Name of the species

  • field_dict (dict | None) – Dictionary of fields used to avoid rereading the same fields to calculate different quantities

Returns:

  • liq_ave_y (float) – Liquid volume averaged mass fraction

  • field_dict (dict) – Dictionary of fields read

bird.postprocess.post_quantities.compute_fitted_kla(case_folder: str, species_names: str | list[str], n_cells: int | None = None, volume_time: str | None = None, num_warmup: int = 4000, num_samples: int = 1000, field_dict: dict | None = None) tuple[dict, dict, dict]

Calculate \(kLa_{\rm spec}\) and saturation concentration (\(C^*_{\rm spec}\)) for a list of species from time series data (rather than instantaneously).

Given a time series of concentration of species, the following expression is fitted

\[[spec](t) = [spec]^* (1 - \operatorname{exp}(-{kLa}_{\rm spec} t)).\]

where

  • \(kLa_{\rm spec}\) is the mass transfer rate of species \(\rm spec\) in \(h^{-1}\)

  • \(t\) is the time in \(s\)

  • \([spec]^*\) is the estimated saturation concentration of species \(\rm spec\) in \(mol/m^3\)

  • \([spec](t)\) is the instantaneous liquid volume averaged concentration of species \(\rm spec\) in \(mol/m^3\)

Both \([spec]^*\) and \(kLa_{\rm spec}\) are fitted. The fit is done with Markov Chain Monte Carlo which outputs samples of the posterior PDF of \([spec]^*\) and \(kLa_{\rm spec}\).

Parameters:
  • case_folder (str) – Path to case folder

  • species_names (str | list[str]) – List of species name for which to compute kla

  • n_cells (int | None) – Number of cells in the domain. If None, it will deduced from the field reading

  • volume_time (str | None) – Time folder to read to get the cell volumes. If None, finds volume time automatically

  • num_warmup (int) – Number of MCMC samples in the warmup phase Defaults to 4000

  • num_samples (int) – Number of posterior MCMC samples generated Defaults to 1000

  • field_dict (dict) – Dictionary of fields used to avoid rereading the same fields to calculate different quantities

Returns:

  • kla_spec (dict) – Instantaneous volume averaged kLa for each species Keys are species names Values are dictionaries with key ‘mean’ (mean kLa value) and ‘std’ (1 standard deviation for the kLa value)

  • cstar_spec (dict) – Instantaneous volume averaged cstar for each species Keys are species names Values are dictionaries with key ‘mean’ (mean cstar value) and ‘std’ (1 standard deviation for the cstar value)

  • field_dict (dict) – Dictionary of fields read

bird.postprocess.post_quantities.compute_gas_holdup(case_folder: str, time_folder: str, n_cells: int | None = None, volume_time: str | None = None, field_dict: dict | None = None) tuple[float, dict]

Calculate volume averaged gas hold up at a given time

\[\frac{1}{V_{\rm liq, tot}} \int_{V_{\rm liq}} (1-\alpha_{\rm liq}) dV\]
where:
  • \(V_{\rm liq, tot}\) is the total volume of liquid in \(m^3\)

  • \(\alpha_{\rm liq}\) is the liquid phase volume fraction

  • \(V\) is the volume of the cells where \(\alpha_{\rm liq}\) is measured in \(m^3\)

Parameters:
  • case_folder (str) – Path to case folder

  • time_folder (str) – Name of time folder to analyze

  • n_cells (int | None) – Number of cells in the domain. If None, it will deduced from the field reading

  • volume_time (str | None) – Time folder to read to get the cell volumes. If None, finds volume time automatically

  • field_dict (dict | None) – Dictionary of fields used to avoid rereading the same fields to calculate different quantities

Returns:

  • gas_holdup (float) – Volume averaged gas holdup

  • field_dict (dict) – Dictionary of fields read

bird.postprocess.post_quantities.compute_instantaneous_kla(case_folder: str, time_folder: str, species_names: str | list[str], n_cells: int | None = None, volume_time: str | None = None, field_dict: dict | None = None) tuple[dict, dict, dict]

Calculate \(kLa_{\rm spec}\) and saturation concentration (\(C^*_{\rm spec}\)) for a list of species from instantaneous data (rather than doing a fit over time).

\(kLa_{\rm spec}\) for the species computed from Eq 7 and 8 in “Computational fluid dynamics study of full-scale aerobic bioreactors: Evaluation of gas–liquid mass transfer, oxygen uptake, and dynamic oxygen distribution”, M. J. Rahimi, H. Sitaraman, D. Humbird, J. J. Stickel, Chem. Eng. Research and Design, Vol. 139, pp 293-295, 2018.

\[\frac{1}{V_{\rm liq, tot}} \int_{V_{\rm liq}} kLa_{\rm spec} dV\]
\[kLa_{\rm spec} = 3600 \sqrt{\frac{4 D_{\rm spec} |u_{\rm slip}|}{\pi d_{\rm gas}}} \frac{6 \alpha_{\rm gas}}{d_{\rm gas}}\]
\[kLa_{\rm spec} = (\frac{2}{\pi^{1/2}} \times 3600) Re^{1/2} \frac{\mu_{\rm liq}^{1/2}}{D_{\rm spec}^{1/2} \rho_{\rm liq}^{1/2}} \frac{D_{\rm spec}}{d_{\rm gas}} \frac{6}{d_{\rm gas}} \alpha_{\rm gas}\]
\[Re = \frac{\rho_{\rm liq} |u_{\rm slip}| d_{\rm gas}}{\mu_{\rm liq}}\]
where:
  • \(kLa_{\rm spec}\) is the mass transfer rate in \(h^{-1}\)

  • \(d_{\rm gas}\) is the bubble diameter in \(m\)

  • \(\alpha_{\rm gas}\) is the volume fraction of gas

  • \(\mu_{\rm liq}\) is the liquid viscosity in \(kg.m^{-1}.s^{-1}\)

  • \(\rho_{\rm liq}\) is the liquid density in \(kg.m^{-3}\)

  • \(D_{\rm spec}\) is the species molecular diffusivity in \(m^2.s^{-1}\)

  • \(|u_{\rm slip}|\) is the magnitude of the slip velocity in \(m.s^{-1}\)

  • \(V_{\rm liq}\) is the volume of liquid in \(m^3\)

\[\frac{1}{V_{\rm liq, tot}} \int_{V_{\rm liq}} C^*_{\rm spec} dV\]

\(C^*_{\rm spec}\) computed from Eq 10 in “Computational fluid dynamics study of full-scale aerobic bioreactors: Evaluation of gas–liquid mass transfer, oxygen uptake, and dynamic oxygen distribution”, M. J. Rahimi, H. Sitaraman, D. Humbird, J. J. Stickel, Chem. Eng. Research and Design, Vol. 139, pp 293-295, 2018.

\[C^*_{\rm spec} = \rho_{\rm gas} Y_{\rm spec, gas} He_{\rm spec} / W_{\rm spec}\]
and
  • \(C^{*}_{\rm spec}\) is the saturation concentration of species spec in \(mol.m^{-3}\)

  • \(\rho_{\rm gas}\) is the density of the gas in \(kg.m^{-3}\)

  • \(Y_{\rm spec, gas}\) is the mass fraction of species spec in the gas phase

  • \(He_{\rm spec}\) is the Henry’s constant of species spec

  • \(W_{\rm spec}\) is the molar mass of species spec in \(kg.mol^{-1}\)

Parameters:
  • case_folder (str) – Path to case folder

  • time_folder (str) – Name of time folder to analyze

  • species_names (str | list[str]) – List of species name for which to compute kla

  • n_cells (int | None) – Number of cells in the domain. If None, it will deduced from the field reading

  • volume_time (str | None) – Time folder to read to get the cell volumes. If None, finds volume time automatically

  • field_dict (dict) – Dictionary of fields used to avoid rereading the same fields to calculate different quantities

Returns:

  • kla_spec (dict) – Instantaneous volume averaged kLa for each species Keys are species names Values are the kLa values

  • cstar_spec (dict) – Instantaneous volume averaged cstar for each species Keys are species names Values are the cstar values

  • field_dict (dict) – Dictionary of fields read

bird.postprocess.post_quantities.compute_superficial_gas_velocity(case_folder: str, time_folder: str, n_cells: int | None = None, volume_time: str | None = None, direction: int | None = None, cell_centers_file: str | None = None, height: float | None = None, use_pv: bool = False, field_dict: dict | None = None) tuple[float, dict]

Calculate superficial gas velocity (in m/s) in a given direction at a given time

Without the paraview operations (use_pv==False)

\[\frac{1}{V_{\rm height, tot}} \int_{V_{\rm height}} U_{\rm gas} \alpha_{\rm gas} dV\]
where:
  • \(V_{\rm height, tot}\) is the total volume of cells near the axial location considered in \(m^3\)

  • \(\alpha_{\rm gas}\) is the gas phase volume fraction

  • \(U_{\rm gas}\) is the gas phase velocity along the axial direction in \(m.s^{-1}\)

  • \(V_{\rm height}\) is the local volume of the cells where \(U_{\rm gas} \alpha_{\rm gas}\) is measured (near the axial location considered) in \(m^3\)

With the paraview operations (use_pv==True)

\[\frac{1}{S_{\rm height, tot}} \int_{S_{\rm height}} U_{\rm gas} \alpha_{\rm gas} dS\]
where:
  • \(S_{\rm height, tot}\) is the total area of the slice at the axial location considered and normal tot the direction considered in \(m^2\)

  • \(\alpha_{\rm gas}\) is the gas phase volume fraction

  • \(U_{\rm gas}\) is the gas phase velocity along the axial direction in \(m.s^{-1}\)

  • \(S_{\rm height}\) is the local area of the slice where \(U_{\rm gas} \alpha_{\rm gas}\) is measured (near the axial location considered) in \(m^2\)

Parameters:
  • case_folder (str) – Path to case folder

  • time_folder (str) – Name of time folder to analyze

  • n_cells (int | None) – Number of cells in the domain. If None, it will deduced from the field reading

  • volume_time (str | None) – Time folder to read to get the cell volumes. If None, finds volume time automatically

  • direction (int | None) – Direction along which to calculate the superficial velocity. If None, assume y direction

  • cell_centers_file (str | None) – Filename of cell center data If None, finds cell center file automatically

  • height (float | None) – Axial location at which to compute the superficial velocity. If None, use the mid point of the liquid domain along the axial direction

  • use_pv (bool) – Use paraview to create a slice in the middle of the reactor Default to False

  • field_dict (dict | None) – Dictionary of fields used to avoid rereading the same fields to calculate different quantities

Returns:

  • sup_vel (float) – Superficial velocity (in m/s)

  • field_dict (dict) – Dictionary of fields read

bird.postprocess.stats module

bird.postprocess.stats.calc_mean(time_series: ndarray, time_values: ndarray | None = None) tuple[float, float]

Compute mean and the uncertainty about the mean, from a time-series

Parameters:
  • time_series (np.ndarray) – Time series of the signal

  • time_values (np.ndarray | None) – The time values over which the time series is sampled. If None, the time values are assumed equally spaced. Otherwise, time_values is used to create a new equally spaced time_values

Returns:

  • mean_val (float) – Mean value of the time_series

  • unc_val (float) – 68% uncertainty (1 sigma) about the mean