5.3.8.2. gemini_application.wims.model_optimization

CO2 corrosion model parameter optimization using SciPy minimize.

Classes

OptCO2Corrosion(inputs, outputs, VLP, unit, ...)

Calibrate CO2 Corrosion Model parameters against measured data.

class gemini_application.wims.model_optimization.OptCO2Corrosion(inputs, outputs, VLP, unit, co2_models, joint_corrosion_models_opt)[source]

Bases: object

Calibrate CO2 Corrosion Model parameters against measured data.

Uses SciPy’s minimize function for optimization.

Initialize CO2 corrosion optimization model.

calibrate_cobyla()[source]

Calibrate parameters for all models in normalized space.

Optimize parameters for all models at once, in normalized [0..1] space. Then denormalize the final solution, push it back to the model, and show final measured vs. modeled rates.

calibrate_slsqp()[source]

Calibrate parameters for all models in normalized space.

Optimize parameters for all models at once, in normalized [0..1] space. Then denormalize the final solution, push it back to the model, and show final measured vs. modeled rates.

coarsen_timeseries_by_change_point(df1, df2, df3, value_col='value', pen=3, plot=False)[source]

Coarsen a time series by detecting segments where the values do not change much.

Parameters:
  • df (pd.DataFrame) – DataFrame with a DateTime index.

  • value_col (str) – The column name containing the values to analyze.

  • pen (float or int) – Penalty parameter for the PELT change-point detection algorithm.

  • plot (bool) – If True, plot the original time series with detected change points.

Returns:

A DataFrame with columns [‘start_date’, ‘end_date’,

’mean_value’] for each segment.

Return type:

pd.DataFrame

denormalize_params(norm_params)[source]

Convert normalized parameters [0,1] to real-valued.

get_constraints()[source]

Define constraints for optimization.

Example method to define constraints for optimization. Returns None if not used.

get_corrosion_rate_from_models_segmented(calibrated_interval, init_run=False)[source]

Compute modelled corrosion in multiple intervals.

  • Nominal (baseline) date -> 1st log date

  • 1st log date -> 2nd log date

  • 2nd log date -> 3rd log date

For each interval, we:

  1. Filter the flow/pressure/temp data to [start_date, end_date)

  2. Compute partial corrosion with a pairwise approach

  3. Convert the sum of partial corrosion to [mm/year] over that interval

  4. Store in a new column in self.outputs[‘modelled_corrosion_rate’]

normalize_params(real_params)[source]

Convert real-valued parameters to normalized [0,1].

objective_function(norm_param_vector, calibrated_interval=None, *args)[source]

Objective function to be minimized during calibration.

Sum of squared errors (SSE) between modelled and measured corrosion.

plot()[source]

Plot optimization results.