15) -> Tuple[np.ndarray, np.ndarray]:
16 """Generate a pressure profile over time using analytic functions.
21 One of "linear", "exponential", or "power".
23 Initial pressure value (arbitrary units – caller handles unit conversion).
25 Final pressure value at t = duration.
27 Total time span in seconds.
29 Number of discrete samples (>= 2).
31 Additional shape parameters. Supported keys:
32 - decay_constant (exponential): positive float controlling curvature (default 3.0)
33 - power (power): exponent > 0 (default 2.0)
38 Array of monotonically increasing time values in seconds (size n_steps).
40 Pressure values corresponding to `times` (same units as inputs).
44 raise ValueError(
"n_steps must be at least 2 for time-series generation")
46 duration =
max(float(duration), 1e-6)
47 times = np.linspace(0.0, duration, n_steps)
50 profile_type_lower = profile_type.lower().strip()
52 if profile_type_lower ==
"linear":
54 elif profile_type_lower ==
"exponential":
55 decay_constant = float(params.get(
"decay_constant", 3.0))
56 decay_constant =
max(decay_constant, 1e-6)
57 numerator = 1.0 - np.exp(-decay_constant * x)
58 denominator = 1.0 - np.exp(-decay_constant)
59 if denominator <= 1e-9:
62 factor = numerator / denominator
63 elif profile_type_lower ==
"power":
64 power =
max(float(params.get(
"power", 2.0)), 1e-6)
67 raise ValueError(f
"Unsupported profile type '{profile_type}'.")
69 values = start_value + (end_value - start_value) * factor
Tuple[np.ndarray, np.ndarray] generate_pressure_profile(str profile_type, float start_value, float end_value, float duration, int n_steps, **params)