Source code for pysubsea.viv_cf_tools

'''
This module provides the core class and functions for calculating normal
cross-flow VIV seabed and trench correction factors and onset reduced velocity.

**Features:**

- The `VIVCF` class calculates seabed proximity, trench, and onset velocity
  correction factors.
- Supports scalar and array inputs using NumPy broadcasting.
- Designed as a foundational calculation module; input grouping and other
  response orchestration remain the caller's responsibility.

All calculations use NumPy for vectorized operations.
'''

import numpy as np


[docs] class VIVCF: """ Class for normal cross-flow VIV onset velocity calculations. Supports both scalar and array inputs for calculations. Parameters ---------- outer_diameter : float or array-like, optional Pipe outer diameter. Default is 0. gap : float or array-like, optional Span gap. Default is 0. trench_depth : float or array-like, optional Trench depth. Default is 0. Geometry must use consistent length units. onset_safety_factor : float or array-like, optional Cross-flow onset safety factor. Default is 1. """ def __init__( self, *, outer_diameter=0.0, gap=0.0, trench_depth=0.0, onset_safety_factor=1.0, ): """ Initialize a VIVCF object with geometric and flow properties. """ self.outer_diameter = np.asarray(outer_diameter, dtype=float) self.gap = np.asarray(gap, dtype=float) self.trench_depth = np.asarray(trench_depth, dtype=float) self.onset_safety_factor = np.asarray(onset_safety_factor, dtype=float)
[docs] def seabed_proximity_correction_factor(self): """ Calculate the correction factor accounting for seabed proximity. Returns ------- proximity_correction_factor : np.ndarray Correction factor, broadcasting the gap and outer diameter. Examples -------- >>> outer_diameter=[0.2731, 0.3239] >>> gap=[0.15, 0.25] >>> response = VIVCF( ... outer_diameter=outer_diameter, ... gap=gap ... ) >>> response.seabed_proximity_correction_factor() array([0.93731234, 0.99296079]) """ return np.minimum(0.2 * (4.0 + 1.25 * self.gap / self.outer_diameter), 1.0)
[docs] def trench_onset_correction_factor(self): """ Calculate the onset correction factor accounting for a pipe in or over a trench. Returns ------- trench_onset_correction_factor : np.ndarray Correction factor, broadcasting the trench depth, gap, and outer diameter. Examples -------- >>> outer_diameter=[0.2731, 0.3239] >>> gap=[0.6, 0.8] >>> trench_depth=[0.3, 0.5] >>> response = VIVCF( ... outer_diameter=outer_diameter, ... gap=gap, ... trench_depth=trench_depth ... ) >>> response.trench_onset_correction_factor() array([0.58806298, 0.72985489]) """ return np.clip( 1.0 + 0.5 * (1.25 * self.trench_depth - self.gap) / self.outer_diameter, 0.0, 1.0, )
[docs] def onset_reduced_velocity(self): """ Calculate onset velocity corrected for seabed proximity and trench. Returns ------- onset_reduced_velocity : np.ndarray Onset reduced velocity, broadcasting geometry and onset factor. Examples -------- >>> outer_diameter=[0.2731, 0.3239] >>> gap=[0.6, 0.8] >>> trench_depth=[0.3, 0.5] >>> response = VIVCF( ... outer_diameter=outer_diameter, ... gap=gap, ... trench_depth=trench_depth ... ) >>> response.onset_reduced_velocity() array([1.76418894, 2.18956468]) """ proximity = self.seabed_proximity_correction_factor() trench = self.trench_onset_correction_factor() return 3.0 * proximity * trench / self.onset_safety_factor