h2integrate.converters.hydrogen.geologic.inputs.curve_fit_processing_utilities#

Curve fitting utilities for ASPEN surface processing models.

This module contains all the curve fitting functions, data structures, and utilities needed to fit cost and performance curves to individual data points produced from Aspen processing modeling.

The main functions provided are: - refit_coeffs: Fit curves to ASPEN data and save coefficients - load_coeffs: Load pre-fitted coefficients from file - evaluate_performance_curves: Evaluate fitted curves for given inputs

Functions

double_power_function(xy, a1, a2, a3, a4, a5)

Two-variable curve fitting function with two power terms (only uses x variable).

evaluate_curve(xy, coeffs)

Evaluate a fitted curve using the appropriate function type.

evaluate_performance_curves(h2_conc, ...)

Evaluate all performance curves for given inputs.

exponential_power_function(xy, a1, a2, a3, ...)

Two-variable curve fitting function combining exponential and power terms.

fit_single_curve(output_name, scaled_output, ...)

Fit a single curve to the scaled data.

load_aspen_data(input_fn)

Load ASPEN modeling results from CSV file.

load_coeffs(coeff_fn, output_names)

Load pre-fitted curve coefficients from CSV file.

plot_curve_fit(output_name, coeffs, h2_conc, ...)

Plot the fitted curve surface and data points for validation.

refit_coeffs(input_fn, refit_coeff_fn, ...)

Fit performance and cost coefficients to ASPEN modeling data for surface processing model.

scale_variables(input_vars)

Scale variables to the range [0, 1] for better numerical conditioning during curve fitting.

Classes

CurveCoefficients(a1, a2, a3, a4, a5, ...)

Container for curve fitting coefficients and metadata.

class h2integrate.converters.hydrogen.geologic.inputs.curve_fit_processing_utilities.CurveCoefficients(a1, a2, a3, a4, a5, scale_x, scale_y, scale_z, fit_type)#

Container for curve fitting coefficients and metadata.

Parameters:
  • a1 (float)

  • a2 (float)

  • a3 (float)

  • a4 (float)

  • a5 (float)

  • scale_x (float)

  • scale_y (float)

  • scale_z (float)

  • fit_type (str)

a1: float#
a2: float#
a3: float#
a4: float#
a5: float#
scale_x: float#
scale_y: float#
scale_z: float#
fit_type: str#
to_dict()#

Convert to dictionary format.

Return type:

dict

h2integrate.converters.hydrogen.geologic.inputs.curve_fit_processing_utilities.scale_variables(input_vars)#

Scale variables to the range [0, 1] for better numerical conditioning during curve fitting.

Parameters:

input_vars (list[ndarray] | ndarray) – List of arrays to scale (must contain positive values).

Returns:

Tuple of (scaled_variables, scale_factors) where scale_factors are the max values.

Return type:

tuple[ndarray, list[float]]

h2integrate.converters.hydrogen.geologic.inputs.curve_fit_processing_utilities.exponential_power_function(xy, a1, a2, a3, a4, a5)#

Two-variable curve fitting function combining exponential and power terms.

Function form: f(x, y) = a1 * exp(x * a2) + a3 * y^a4 + a5

Parameters:
  • xy (tuple[ndarray, ndarray]) – Tuple of (x, y) input arrays.

  • a1 (float) – Curve fitting coefficients.

  • a2 (float) – Curve fitting coefficients.

  • a3 (float) – Curve fitting coefficients.

  • a4 (float) – Curve fitting coefficients.

  • a5 (float) – Curve fitting coefficients.

Returns:

Fitted output values.

Return type:

ndarray

h2integrate.converters.hydrogen.geologic.inputs.curve_fit_processing_utilities.double_power_function(xy, a1, a2, a3, a4, a5)#

Two-variable curve fitting function with two power terms (only uses x variable).

Function form: f(x, y) = a1 * x^a2 + a3 * x^a4 + a5 Note: y variable is kept for API consistency with exponential_power_function.

Parameters:
  • xy (tuple[ndarray, ndarray]) – Tuple of (x, y) input arrays (y is ignored).

  • a1 (float) – Curve fitting coefficients.

  • a2 (float) – Curve fitting coefficients.

  • a3 (float) – Curve fitting coefficients.

  • a4 (float) – Curve fitting coefficients.

  • a5 (float) – Curve fitting coefficients.

Returns:

Fitted output values.

Return type:

ndarray

h2integrate.converters.hydrogen.geologic.inputs.curve_fit_processing_utilities.evaluate_curve(xy, coeffs)#

Evaluate a fitted curve using the appropriate function type.

Parameters:
  • xy (tuple[ndarray, ndarray]) – Tuple of (x, y) scaled input arrays.

  • coeffs (CurveCoefficients) – Curve coefficients including fit type.

Returns:

Scaled output values.

Return type:

ndarray

h2integrate.converters.hydrogen.geologic.inputs.curve_fit_processing_utilities.load_aspen_data(input_fn)#

Load ASPEN modeling results from CSV file.

Parameters:

input_fn (str) – Filename of ASPEN results CSV in ./inputs directory.

Returns:

Tuple of (h2_concentration, flow_rate, dataframe).

Return type:

tuple[ndarray, ndarray, DataFrame]

h2integrate.converters.hydrogen.geologic.inputs.curve_fit_processing_utilities.fit_single_curve(output_name, scaled_output, fit_input_data, input_scale_factors, output_scale_factor)#

Fit a single curve to the scaled data.

Parameters:
  • output_name (str) – Name of the output variable.

  • scaled_output (ndarray) – Scaled output data.

  • fit_input_data (ndarray) – Scaled input data.

  • input_scale_factors (list[float]) – Scale factors for inputs.

  • output_scale_factor (float) – Scale factor for output.

Returns:

CurveCoefficients object with fitted parameters.

Return type:

CurveCoefficients

h2integrate.converters.hydrogen.geologic.inputs.curve_fit_processing_utilities.plot_curve_fit(output_name, coeffs, h2_conc, flow, actual_output, h2_out, h2_out_surf=None)#

Plot the fitted curve surface and data points for validation.

Parameters:
  • output_name (str) – Name of the output variable.

  • coeffs (CurveCoefficients) – Fitted curve coefficients.

  • h2_conc (ndarray) – H2 concentration data points.

  • flow (ndarray) – Flow rate data points.

  • actual_output (ndarray) – Actual output values.

  • h2_out (ndarray) – H2 output flow for normalization.

  • h2_out_surf (ndarray | None) – H2 output surface (for non-H2 flow variables).

Returns:

Updated h2_out_surf if output_name is “H2 Flow Out [kg/hr]”, else None.

Return type:

ndarray | None

h2integrate.converters.hydrogen.geologic.inputs.curve_fit_processing_utilities.refit_coeffs(input_fn, refit_coeff_fn, output_names, plot_flag=False)#

Fit performance and cost coefficients to ASPEN modeling data for surface processing model.

This fits three-dimensional surfaces with two inputs (H2 concentration and wellhead flow) and one output (cycling through variables in output_names).

Parameters:
  • input_fn (str) – Filename of ASPEN results CSV in ./inputs directory.

  • refit_coeff_fn (str | None) – Filename to save fitted coefficients to in ./inputs directory. If None, does not save the file.

  • output_names (list[str]) – List of output variable names to fit curves for.

  • plot_flag (bool) – Whether to plot fitted surfaces for visual validation.

Returns:

dict – Dictionary mapping output names to their fitted coefficients.

Return type:

dict[str, dict]

h2integrate.converters.hydrogen.geologic.inputs.curve_fit_processing_utilities.load_coeffs(coeff_fn, output_names)#

Load pre-fitted curve coefficients from CSV file.

Parameters:
  • coeff_fn (str) – Filename of coefficients CSV in ./inputs directory.

  • output_names (list[str]) – List of output variable names to load.

Returns:

dict – Dictionary mapping output names to their coefficient dictionaries.

Return type:

dict[str, dict]

h2integrate.converters.hydrogen.geologic.inputs.curve_fit_processing_utilities.evaluate_performance_curves(h2_conc, wellhead_cap, coeffs_dict, curve_names)#

Evaluate all performance curves for given inputs.

Parameters:
  • h2_conc (float) – H2 concentration (fraction, not %).

  • wellhead_cap (float) – Wellhead capacity in kg/hr.

  • coeffs_dict (dict) – Dictionary of curve coefficients.

  • curve_names (list[str]) – List of curve names to evaluate.

Returns:

dict – Dictionary mapping curve names to evaluated results.

Return type:

dict[str, float]