Skip to content

Chamber Rate Fitting

Particula-beta Index / Particula Beta / Data / Process / Chamber Rate Fitting

Auto-generated documentation for particula_beta.data.process.chamber_rate_fitting module.

ChamberParameters

Show source in chamber_rate_fitting.py:287

Data class for the chamber parameters.

Signature

class ChamberParameters: ...

calculate_optimized_rates

Show source in chamber_rate_fitting.py:428

Calculate the coagulation rates using the optimized parameters and return the rates and R2 score.

Arguments

  • radius_bins - Array of particle radii in meters.
  • concentration_pmf - 2D array of concentration PMF values.
  • wall_eddy_diffusivity - Optimized wall eddy diffusivity.
  • alpha_collision_efficiency - Optimized alpha collision efficiency.
  • chamber_params - ChamberParameters object containing chamber-related parameters.
  • time_derivative_concentration_pmf - Array of observed rate of change of the concentration PMF (optional).
  • w_correction - W correction of the particles (optional).

Returns

  • coagulation_loss - Loss rate due to coagulation.
  • coagulation_gain - Gain rate due to coagulation.
  • dilution_loss - Loss rate due to dilution.
  • wall_loss_rate - Loss rate due to wall deposition.
  • net_rate - Net rate considering all effects.
  • r2_value - R2 score between the net rate and the observed rate.
  • chi_squared - Chi-squared error between the net rate and the observed rate.

Signature

def calculate_optimized_rates(
    radius_bins: NDArray[np.float64],
    concentration_pmf: NDArray[np.float64],
    wall_eddy_diffusivity: float,
    alpha_collision_efficiency: float,
    w_correction: float,
    fractional_uncertainty: NDArray[np.float64],
    chamber_parameters: ChamberParameters,
    time_derivative_concentration_pmf: Optional[NDArray[np.float64]] = None,
) -> Tuple[float, float, float, float, float, float]: ...

See also

calculate_pmf_rates

Show source in chamber_rate_fitting.py:120

Calculate the coagulation, dilution, and wall loss rates, and return the net rate.

Arguments

  • radius_bins - Array of particle radii.
  • concentration_pmf - Array of particle concentration probability mass function.
  • temperature - Temperature in Kelvin.
  • pressure - Pressure in Pascals.
  • particle_density - Density of the particles in kg/m^3.
  • alpha_collision_efficiency - Collision efficiency factor.
  • volume - Volume of the chamber in m^3.
  • input_flow_rate - Input flow rate in m^3/s.
  • wall_eddy_diffusivity - Eddy diffusivity for wall loss in m^2/s.
  • chamber_dimensions - Dimensions of the chamber (length, width, height) in meters.
  • w_correction - W correction of the particles (optional).

Returns

  • coagulation_loss - Loss rate due to coagulation.
  • coagulation_gain - Gain rate due to coagulation.
  • dilution_loss - Loss rate due to dilution.
  • wall_loss_rate - Loss rate due to wall deposition.
  • net_rate - Net rate considering all effects.

Signature

def calculate_pmf_rates(
    radius_bins: NDArray[np.float64],
    concentration_pmf: NDArray[np.float64],
    temperature: float = 293.15,
    pressure: float = 101325,
    particle_density: float = 1000,
    alpha_collision_efficiency: float = 1,
    w_correction: float = 1,
    volume: float = 1,
    input_flow_rate: float = 1.6e-07,
    wall_eddy_diffusivity: float = 0.1,
    chamber_dimensions: Tuple[float, float, float] = (1, 1, 1),
) -> Tuple[
    NDArray[np.float64],
    NDArray[np.float64],
    NDArray[np.float64],
    NDArray[np.float64],
    NDArray[np.float64],
]: ...

chi_squared_error

Show source in chamber_rate_fitting.py:20

Calculate the chi-squared error between the observed and predicted values, accounting for uncertainties.

Arguments

  • observed - Array of observed values.
  • predicted - Array of predicted values.
  • fractional_uncertainty - Array or float of fractional uncertainty (e.g., 0.2 for 20%).

Returns

  • chi_squared - Chi-squared error between the observed and predicted values.

Signature

def chi_squared_error(
    observed: np.ndarray, predicted: np.ndarray, fractional_uncertainty: np.ndarray
) -> float: ...

coagulation_rates_cost_function

Show source in chamber_rate_fitting.py:225

Cost function for the optimization of the eddy diffusivity and alpha collision efficiency.

Signature

def coagulation_rates_cost_function(
    parameters: NDArray[np.float64],
    radius_bins: NDArray[np.float64],
    concentration_pmf: NDArray[np.float64],
    time_derivative_concentration_pmf: NDArray[np.float64],
    fractional_uncertainty: NDArray[np.float64],
    temperature: float = 293.15,
    pressure: float = 101325,
    particle_density: float = 1000,
    volume: float = 1,
    input_flow_rate: float = 1.6e-07,
    chamber_dimensions: Tuple[float, float, float] = (1, 1, 1),
) -> float: ...

create_guess_and_bounds

Show source in chamber_rate_fitting.py:298

Create the initial guess array and bounds list for the optimization.

Arguments

  • guess_eddy_diffusivity - Initial guess for eddy diffusivity.
  • guess_alpha_collision_efficiency - Initial guess for alpha collision efficiency.
  • bounds_eddy_diffusivity - Bounds for eddy diffusivity.
  • bounds_alpha_collision_efficiency - Bounds for alpha collision efficiency.
  • guess_w_correction - Initial guess for the W correction, optional. Typical range between 1 and 3.
  • bounds_w_correction - Bounds for the W correction.

Returns

  • initial_guess - Numpy array of the initial guess values.
  • bounds - List of tuples representing the bounds for each parameter.

Signature

def create_guess_and_bounds(
    guess_eddy_diffusivity: float,
    guess_alpha_collision_efficiency: float,
    bounds_eddy_diffusivity: Tuple[float, float],
    bounds_alpha_collision_efficiency: Tuple[float, float],
    guess_w_correction: float,
    bounds_w_correction: Tuple[float, float],
) -> Tuple[NDArray[np.float64], List[Tuple[float, float]]]: ...

hessian_standard_error

Show source in chamber_rate_fitting.py:49

Calculate the standard error for the optimized parameters using Hessian estimation with regularization and fallback to diagonal approximation.

Arguments

  • objective_function - The objective function.
  • parameters - Array of optimized parameters.
  • epsilon - Step size for numerical differentiation.
  • regularization - Regularization term for Hessian inversion.

Returns

  • standard_errors - Standard errors of the optimized parameters.

Signature

def hessian_standard_error(
    objective_function: Callable,
    parameters: np.ndarray,
    epsilon: float = 0.0001,
    regularization: float = 1e-08,
) -> np.ndarray: ...

optimize_and_calculate_rates_looped

Show source in chamber_rate_fitting.py:513

Perform optimization and calculate rates for each time point in the stream.

Arguments

  • pmf_stream - Stream object containing the fitted PMF data.
  • pmf_derivative_stream - Stream object containing the derivative of the PMF data.
  • chamber_parameters - ChamberParameters object containing chamber-related parameters.
  • fit_guess - Initial guess for the optimization.
  • fit_bounds - Bounds for the optimization parameters.

Returns

  • result_stream - Stream containing the optimization results for each time point.
  • coagulation_loss_stream - Stream containing coagulation loss rates.
  • coagulation_gain_stream - Stream containing coagulation gain rates.
  • coagulation_net_stream - Stream containing net coagulation rates.
  • dilution_loss_stream - Stream containing dilution loss rates.
  • wall_loss_rate_stream - Stream containing wall loss rates.
  • total_rate_stream - Stream containing total rates.

Signature

def optimize_and_calculate_rates_looped(
    pmf_stream: Stream,
    pmf_derivative_stream: Stream,
    chamber_parameters: ChamberParameters,
    fit_guess: NDArray[np.float64],
    fit_bounds: List[Tuple[float, float]],
    fractional_uncertainty: NDArray[np.float64],
    epsilon_hessian_estimation: float = 0.0001,
) -> Tuple[Stream, Stream, Stream, Stream, Stream, Stream, Stream]: ...

See also

optimize_chamber_parameters

Show source in chamber_rate_fitting.py:357

Optimize the eddy diffusivity and alpha collision efficiency parameters for a given particle size distribution and its time derivative.

Arguments

  • radius_bins - Array of particle size bins in meters.
  • concentration_pmf - Array of particle mass fractions (PMF) concentrations at each radius bin.
  • time_derivative_concentration_pmf - Array of time derivatives of the PMF concentrations, representing the rate of change in concentration over time.
  • chamber_params - ChamberParameters object containing the physical properties of the chamber, including temperature, pressure, particle density, volume, input flow rate, and chamber dimensions.
  • fit_guess - Initial guess for the optimization parameters (eddy diffusivity and alpha collision efficiency).
  • fit_bounds - List of tuples specifying the bounds for the optimization parameters (lower and upper bounds for each parameter).
  • minimize_method - Optimization method to be used. Default is "L-BFGS-B". The following methods from scipy.optimize.minimize accept bounds, "L-BFGS-B", "TNC", "SLSQP", "Powell", "trust-constr".

Returns

  • wall_eddy_diffusivity_optimized - Optimized value of the wall eddy diffusivity (in 1/s).
  • alpha_collision_efficiency_optimized - Optimized value of the alpha collision efficiency (dimensionless).

Signature

def optimize_chamber_parameters(
    radius_bins: NDArray[np.float64],
    concentration_pmf: NDArray[np.float64],
    time_derivative_concentration_pmf: NDArray[np.float64],
    fractional_uncertainty: NDArray[np.float64],
    chamber_parameters: ChamberParameters,
    fit_guess: NDArray[np.float64],
    fit_bounds: List[Tuple[float, float]],
    minimize_method: str = "L-BFGS-B",
    epsilon_hessian_estimation: float = 0.0001,
) -> Union[Tuple[float, float, float], Tuple[float, float, float]]: ...

See also

optimize_parameters

Show source in chamber_rate_fitting.py:340

Get the optimized parameters using the given cost function.

Signature

def optimize_parameters(
    cost_function: ignore,
    initial_guess: NDArray[np.float64],
    bounds: List[Tuple[float, float]],
    method: str,
) -> Tuple[float, float, float]: ...