GaPFlow.models.WallStress#

class GaPFlow.models.WallStress(fc: Any, prop: dict, geo: dict, direction: str = 'x', data: Any | None = None, gp: dict | None = None)#

Bases: GaussianProcessSurrogate

Wall stress model (wall shear/stress in xz or yz direction).

This class can operate in two modes:

  • Deterministic: compute wall/boundary stresses from viscous models.

  • GP-based surrogate: train/predict wall stress using GaussianProcessSurrogate.

__init__(fc: Any, prop: dict, geo: dict, direction: str = 'x', data: Any | None = None, gp: dict | None = None) None#

Constructor

Parameters:
  • fc (muGrid.GlobalFieldCollection) – Field collection that provides access to ‘pressure’, ‘topography’, etc.

  • prop (dict) – Physical fluid properties (e.g., shear viscosity).

  • geo (dict) – Geometry parameters.

  • direction ({'x', 'y'}, optional) – Direction of the wall stress (‘x’ -> xz component (default), ‘y’ -> yz component).

  • data (Database or None, optional) – Training database if using GP surrogates.

  • gp (dict or None, optional) – GP configuration dictionary (if using GP surrogates).

Methods

__init__(fc, prop, geo[, direction, data, gp])

Constructor

build_gp(params, X, yerr)

Default GP build method.

init()

Run first training and inference.

init_database(dim)

Triggers the first database initialization.

predict([predictor, compute_var, cooldown])

Perform GP prediction, optionally updating the model via active learning (only in predictor step of the predictor-corrector time integration scheme)

save_state()

Log current GP hyperparameters and diagnostics.

update([predictor, compute_var, cooldown])

Update wall stress: compute deterministic stresses and, if enabled, perform GP prediction and place predicted mean and variance into the appropriate field entries.

Attributes

Xtest

Test inputs for shear stress GP (normalized).

Xtrain

Training inputs (normalized).

Xtrain_target

Training inputs (normalized).

Yerr

Observational error (normalized by Yscale).

Yscale

Output scaling factor used for normalization.

Yshift

Output scaling factor used for normalization.

Ytrain

Normalized training outputs for GP corresponding to the lower and upper wall stress.

cumtime_infer

Cumulative time spent for inference from the GP (making predictions)

cumtime_train

Cumulative time spent for training of the GP (fitting hyperparameters)

database

The database holding the training data for the GP surrogate model.

dp_dx

Partial derivative of pressure with respect to x (∂p/∂x).

dp_dy

Partial derivative of pressure with respect to y (∂p/∂y).

extra

Return constant extra field, which can be used as additional input.

full

Full wall stress field including upper and lower components.

has_multi_output

height

Return the gap height field.

height_and_slopes

Return the topography (height and gradients).

kernel_lengthscale

Return kernel lengthscale(s).

kernel_variance

Return kernel variance (JAX scalar or array).

last_fit_train_size

Size of the training database at the last fit.

lower

Lower-wall stress slice.

objective

Optimization objective (negative marginal log likelihood)

obs_stddev

Observation standard deviation (normalized).

pressure

Local pressure field.

solution

Return full solution field.

trusted

Return True if model predictive variance is below tolerance.

upper

Upper-wall stress slice.

variance

Variance of the shear stress field

name

is_gp_model

active_dims

use_active_learning

fix_noise

rtol

atol

tol

max_steps

pause_steps

similarity_check

allowed_skips

perturb_target

pause_on_high_residual

params_init

noise

prop

geo

property Xtest: Array#

Test inputs for shear stress GP (normalized).

property Xtrain: Array#

Training inputs (normalized).

property Xtrain_target: Array#

Training inputs (normalized).

property Yerr: Array#

Observational error (normalized by Yscale).

Returns:

Observation noise standard deviation normalized by Yscale.

Return type:

jax.Array

property Yscale: Array#

Output scaling factor used for normalization.

Returns:

Scalar-like array representing the maximum of selected Y scales.

Return type:

jax.Array

property Yshift: Array#

Output scaling factor used for normalization.

Returns:

Scalar-like array representing the maximum of selected Y scales.

Return type:

jax.Array

property Ytrain: Array#

Normalized training outputs for GP corresponding to the lower and upper wall stress.

Returns:

Concatenated array of training outputs (lower then upper).

Return type:

jax.Array

active_dims: list[int]#
allowed_skips: int#
atol: float#
build_gp(params: dict, X: Array, yerr: float | Array) GaussianProcess#

Default GP build method.

Parameters:
  • params (dict) – Dictionary with hyperparameters

  • X (jax.Array) – Input data.

  • yerr (jax.Array) – Observation noise (standard deviation).

Returns:

Single-output GP model.

Return type:

tinygp.GaussianProcess

property cumtime_infer#

Cumulative time spent for inference from the GP (making predictions)

property cumtime_train#

Cumulative time spent for training of the GP (fitting hyperparameters)

property database#

The database holding the training data for the GP surrogate model.

property dp_dx: ndarray[tuple[Any, ...], dtype[floating]]#

Partial derivative of pressure with respect to x (∂p/∂x).

Returns:

Gradient along x computed with jnp.gradient.

Return type:

ndarra

property dp_dy: ndarray[tuple[Any, ...], dtype[floating]]#

Partial derivative of pressure with respect to y (∂p/∂y).

Returns:

Gradient along y computed with jnp.gradient.

Return type:

ndarray

property extra#

Return constant extra field, which can be used as additional input.

fix_noise: bool#
property full: ndarray[tuple[Any, ...], dtype[floating]]#

Full wall stress field including upper and lower components.

Returns:

Array holding 12 components for wall stress (6 lower + 6 upper).

Return type:

ndarray

geo: dict#
property has_multi_output#
property height#

Return the gap height field.

property height_and_slopes: Array#

Return the topography (height and gradients).

init() None#

Run first training and inference.

init_database(dim: int) None#

Triggers the first database initialization.

Parameters:

dim (int) – Dimension of the fluid problem.

is_gp_model: bool#
property kernel_lengthscale: Array#

Return kernel lengthscale(s).

property kernel_variance: Array#

Return kernel variance (JAX scalar or array).

property last_fit_train_size#

Size of the training database at the last fit.

property lower: ndarray[tuple[Any, ...], dtype[floating]]#

Lower-wall stress slice.

Returns:

Lower half of the wall stress components (6 entries).

Return type:

ndarray

max_steps: int#
name: str#
noise: Tuple[float, float]#
property objective#

Optimization objective (negative marginal log likelihood)

property obs_stddev: Array#

Observation standard deviation (normalized).

params_init: dict#
pause_on_high_residual: bool#
pause_steps: int#
perturb_target: bool#
predict(predictor: bool = True, compute_var: bool = True, cooldown: bool = False) Tuple[Array, Array]#

Perform GP prediction, optionally updating the model via active learning (only in predictor step of the predictor-corrector time integration scheme)

Parameters:
  • predictor (bool, optional) – Whether to perform active learning updates (only in predictor step, default is True).

  • compute_var (bool, optional) – If true (default), preditive variance is re-computed.

  • cooldown (bool, optional) – If true, active learning is blocked to let the system cool down (default is False).

Returns:

  • m (jax.Array) – Predictive mean.

  • v (jax.Array) – Predictive variance.

property pressure: ndarray[tuple[Any, ...], dtype[floating]]#

Local pressure field.

Returns:

Pressure field from the field collection.

Return type:

ndarray

prop: dict#
rtol: float#
save_state() None#

Log current GP hyperparameters and diagnostics.

similarity_check: bool#
property solution#

Return full solution field.

tol: str#
property trusted: bool#

Return True if model predictive variance is below tolerance.

update(predictor: bool = False, compute_var: bool = False, cooldown: bool = False) None#

Update wall stress: compute deterministic stresses and, if enabled, perform GP prediction and place predicted mean and variance into the appropriate field entries.

Parameters:
  • predictor (bool, optional) – Whether this update is part of the predictor stage.

  • compute_var (bool, optional) – Flag for re-computing the variance (the default is False which uses the stored variance from previous steps).

  • cooldown (bool, optional) – If true, active learning is blocked to let the system cool down (default is False).

property upper: ndarray[tuple[Any, ...], dtype[floating]]#

Upper-wall stress slice.

Returns:

Upper half of the wall stress components (6 entries).

Return type:

ndarray

use_active_learning: bool#
property variance: ndarray[tuple[Any, ...], dtype[floating]]#

Variance of the shear stress field