5.3.8.2. gemini_application.wims.model_optimization
CO2 corrosion model parameter optimization using SciPy minimize.
Classes
|
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:
objectCalibrate 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
- 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:
Filter the flow/pressure/temp data to [start_date, end_date)
Compute partial corrosion with a pairwise approach
Convert the sum of partial corrosion to [mm/year] over that interval
Store in a new column in self.outputs[‘modelled_corrosion_rate’]