Skip to content

Wave Phase and Time-Dependent Loading

Overview

The phase loading module extends Fluidmec's member force and moment calculations to simultaneous multi-member hydrodynamic load histories.

It supports spatial wave phase differences, harmonic load combination, periodic peak detection, temporal refinement and directional load envelopes.

Coordinate conventions

  • Cartesian x and y coordinates are horizontal.
  • z is positive upwards.
  • The still water level is z = 0.
  • Wave directions are measured from +x towards +y.
  • Direction inputs are in degrees.
  • Wave phases are in radians.
  • All physical quantities use SI units.

Directional wave phase

The wave phase is

\[ \theta = k(x\cos\beta+y\sin\beta) -\omega t+\phi_0 \]

The spatial phase difference between two positions is

\[ \Delta\theta = k(\Delta x\cos\beta+\Delta y\sin\beta) \]

The signed wave travel delay is

\[ \Delta t=\frac{\Delta\theta}{\omega} \]

Harmonic load combination

For harmonic loads with a common angular frequency,

\[ F_j(t)=A_j\cos(\omega t-\phi_j) \]

the combined complex amplitude is

\[ Z=\sum_j A_j e^{i\phi_j} \]

The resultant amplitude and phase are obtained from the magnitude and argument of Z.

For two equal-amplitude harmonic loads,

\[ A_T=2A\left|\cos\frac{\Delta\theta}{2}\right| \]

This expression does not generally describe nonlinear Morison drag.

Simultaneous structural loading

Member force and moment histories are calculated using wave_current_member_force_moment.

All members are evaluated at common time samples and about a common global reference point.

\[ \mathbf F_T(t)=\sum_j\mathbf F_j(t) \]
\[ \mathbf M_T(t)=\sum_j\mathbf M_j(t) \]

The horizontal base shear and overturning moment are calculated from the signed vector sums.

Temporal sampling

One wave period is discretised into N samples:

\[ \Delta t=\frac{T}{N} \]

The repeated endpoint is excluded.

For sufficiently smooth maxima, sampled peak underestimation is bounded by a second-order temporal discretisation relationship.

Quadratic peak refinement

Three neighbouring samples are used to estimate a local quadratic maximum.

Periodic neighbours are used at the first and last samples.

The refinement is an interpolation estimate.

The directional envelope solver re-evaluates the physical member solver at candidate refined times and retains the larger physical objective value.

Directional load envelopes

For a given wave direction,

\[ M_{\mathrm{env}}(\beta)= \max_t M_{\mathrm{OT}}(t,\beta) \]

The critical sampled direction is determined by comparing the directional peak values.

The directional sweep is discrete and does not guarantee a continuous global maximum.

Vertical force and torsion envelopes use absolute magnitudes while preserving their signed values.

Engineering example

from fluidmec.hydrodynamics import (
    directional_load_envelope,
)

members = [
    {
        "name": "A",
        "start": [0, 0, -40],
        "end": [0, 0, 0],
        "diameter": 4,
    },
    {
        "name": "B",
        "start": [30, 0, -40],
        "end": [30, 0, 0],
        "diameter": 4,
    },
]

result = directional_load_envelope(
    members,
    directions=[0, 30, 60, 90],
    wave_height=2,
    period=8,
    depth=40,
    reference=[0, 0, -40],
    current_velocity=1,
    samples=256,
)

print(result["critical"]["overturning"])

Assumptions and limitations

  • Regular monochromatic linear waves.
  • Prescribed steady currents.
  • Fixed straight cylindrical members.
  • Mean submerged geometry.
  • No wave diffraction or wake shielding.
  • No instantaneous wetting and drying.
  • No structural dynamic response.
  • No irregular-wave spectra.
  • No wave-current dispersion coupling.
  • No fatigue or structural capacity assessment.

The calculated quantities are time-dependent applied hydrodynamic loads.

The moving wave surface in the animation is illustrative; it does not modify the mean submerged integration limits.

Displayed force vectors are positioned at member midpoints for visualisation only.

Numerical verification

Tests include:

  • Directional phase and Cartesian projection.
  • Signed wave travel delay.
  • Analytical harmonic load cancellation.
  • Periodic time grids.
  • Peak interpolation and periodic boundaries.
  • Controlled temporal convergence.
  • Independent member summation.
  • Horizontal and vertical moment decomposition.
  • Two-column inertia cancellation.
  • Uniform-current directional envelopes.

Visualisation

Run the complete engineering example:

python examples/phase_loading_example.py --animate

Results are saved under outputs/lesson32/.

API reference

fluidmec.hydrodynamics.phase_loading

Spatial phase and time-dependent hydrodynamic loading.

All physical quantities use SI units. Wave directions are measured from +x towards +y. Wave directions use degrees; wave phases use radians.

Structural load histories represent applied loads.

wave_direction_vector

wave_direction_vector(direction: ArrayLike) -> np.ndarray

Return horizontal wave propagation unit vectors.

Parameters:

Name Type Description Default
direction array_like

Propagation direction in degrees.

required

Returns:

Type Description
ndarray

Cartesian unit vectors with shape (..., 3).

Source code in src/fluidmec/hydrodynamics/phase_loading.py
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
def wave_direction_vector(
    direction: ArrayLike,
) -> np.ndarray:
    """Return horizontal wave propagation unit vectors.

    Parameters
    ----------
    direction : array_like
        Propagation direction in degrees.

    Returns
    -------
    ndarray
        Cartesian unit vectors with shape (..., 3).
    """
    angle = np.deg2rad(as_float_array(direction, "direction"))

    return np.stack(
        [
            np.cos(angle),
            np.sin(angle),
            np.zeros_like(angle),
        ],
        axis=-1,
    )

projected_wave_distance

projected_wave_distance(position: ArrayLike, direction: ArrayLike) -> float | np.ndarray

Project Cartesian positions onto the wave axis.

Returns signed distances in metres.

Source code in src/fluidmec/hydrodynamics/phase_loading.py
117
118
119
120
121
122
123
124
125
126
127
128
def projected_wave_distance(
    position: ArrayLike,
    direction: ArrayLike,
) -> float | np.ndarray:
    """Project Cartesian positions onto the wave axis.

    Returns signed distances in metres.
    """
    position = _vector(position, "position")
    axis = wave_direction_vector(direction)

    return format_output(np.sum(position * axis, axis=-1))

directional_wave_phase

directional_wave_phase(position: ArrayLike, time: ArrayLike, wave_number: ArrayLike, angular_frequency: ArrayLike, *, direction: ArrayLike = 0.0, phase_offset: ArrayLike = 0.0) -> float | np.ndarray

Return unwrapped directional wave phase in radians.

Inputs follow NumPy broadcasting rules.

Source code in src/fluidmec/hydrodynamics/phase_loading.py
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
def directional_wave_phase(
    position: ArrayLike,
    time: ArrayLike,
    wave_number: ArrayLike,
    angular_frequency: ArrayLike,
    *,
    direction: ArrayLike = 0.0,
    phase_offset: ArrayLike = 0.0,
) -> float | np.ndarray:
    """Return unwrapped directional wave phase in radians.

    Inputs follow NumPy broadcasting rules.
    """
    k = validate_positive(wave_number, "wave_number")

    omega = validate_positive(
        angular_frequency,
        "angular_frequency",
    )

    time = as_float_array(time, "time")

    offset = as_float_array(phase_offset, "phase_offset")

    distance = projected_wave_distance(position, direction)

    return format_output(k * distance - omega * time + offset)

spatial_phase_difference

spatial_phase_difference(first: ArrayLike, second: ArrayLike, wave_number: ArrayLike, *, direction: ArrayLike = 0.0) -> float | np.ndarray

Return signed phase(second) - phase(first).

Source code in src/fluidmec/hydrodynamics/phase_loading.py
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
def spatial_phase_difference(
    first: ArrayLike,
    second: ArrayLike,
    wave_number: ArrayLike,
    *,
    direction: ArrayLike = 0.0,
) -> float | np.ndarray:
    """Return signed phase(second) - phase(first)."""
    first = _vector(first, "first")
    second = _vector(second, "second")

    k = validate_positive(wave_number, "wave_number")

    distance = projected_wave_distance(second - first, direction)

    return format_output(k * distance)

wave_phase_time_delay

wave_phase_time_delay(phase_difference: ArrayLike, angular_frequency: ArrayLike) -> float | np.ndarray

Convert signed phase difference to seconds.

Source code in src/fluidmec/hydrodynamics/phase_loading.py
178
179
180
181
182
183
184
185
186
187
188
189
190
def wave_phase_time_delay(
    phase_difference: ArrayLike,
    angular_frequency: ArrayLike,
) -> float | np.ndarray:
    """Convert signed phase difference to seconds."""
    phase = as_float_array(phase_difference, "phase_difference")

    omega = validate_positive(
        angular_frequency,
        "angular_frequency",
    )

    return format_output(phase / omega)

harmonic_load_resultant

harmonic_load_resultant(amplitudes: ArrayLike, phases: ArrayLike, *, axis: int = 0) -> tuple[float | np.ndarray, float | np.ndarray]

Combine harmonic loads using complex amplitudes.

The harmonic convention is

load(t) = amplitude * cos(omega*t - phase)

Amplitudes must be nonnegative. Phases are in radians.

Returns:

Type Description
(amplitude, phase)

Combined amplitude and phase.

Notes

Phase is mathematically undefined at zero resultant amplitude. Near complete numerical cancellation, the returned phase is set to zero.

Source code in src/fluidmec/hydrodynamics/phase_loading.py
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
def harmonic_load_resultant(
    amplitudes: ArrayLike,
    phases: ArrayLike,
    *,
    axis: int = 0,
) -> tuple[float | np.ndarray, float | np.ndarray]:
    """Combine harmonic loads using complex amplitudes.

    The harmonic convention is

        load(t) = amplitude * cos(omega*t - phase)

    Amplitudes must be nonnegative.
    Phases are in radians.

    Returns
    -------
    amplitude, phase
        Combined amplitude and phase.

    Notes
    -----
    Phase is mathematically undefined at zero
    resultant amplitude. Near complete numerical
    cancellation, the returned phase is set to zero.
    """
    amplitudes = validate_non_negative(amplitudes, "amplitudes")

    phases = as_float_array(phases, "phases")

    amplitudes, phases = np.broadcast_arrays(amplitudes, phases)

    if amplitudes.ndim == 0:
        amplitudes = amplitudes.reshape(1)
        phases = phases.reshape(1)

    real = np.sum(
        amplitudes * np.cos(phases),
        axis=axis,
    )

    imaginary = np.sum(
        amplitudes * np.sin(phases),
        axis=axis,
    )

    amplitude = np.hypot(real, imaginary)

    scale = np.sum(amplitudes, axis=axis)

    cancelled = amplitude <= 8 * np.finfo(float).eps * scale

    phase = np.where(
        cancelled,
        0.0,
        np.arctan2(imaginary, real),
    )

    amplitude = np.where(cancelled, 0.0, amplitude)

    return (
        format_output(amplitude),
        format_output(phase),
    )

periodic_time_grid

periodic_time_grid(period: float, samples: int = 256, *, start: float = 0.0) -> np.ndarray

Return equally spaced samples over one period.

The repeated endpoint is excluded.

Source code in src/fluidmec/hydrodynamics/phase_loading.py
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
def periodic_time_grid(
    period: float,
    samples: int = 256,
    *,
    start: float = 0.0,
) -> np.ndarray:
    """Return equally spaced samples over one period.

    The repeated endpoint is excluded.
    """
    period = _positive_scalar(period, "period")
    start = _scalar(start, "start")
    samples = _sample_count(samples)

    return np.linspace(
        start,
        start + period,
        samples,
        endpoint=False,
    )

simultaneous_load_sum

simultaneous_load_sum(histories: ArrayLike, *, axis: int = 0) -> np.ndarray

Sum signed Cartesian load histories.

The final axis must contain Cartesian components. The summation axis must not be the Cartesian axis.

Source code in src/fluidmec/hydrodynamics/phase_loading.py
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
def simultaneous_load_sum(
    histories: ArrayLike,
    *,
    axis: int = 0,
) -> np.ndarray:
    """Sum signed Cartesian load histories.

    The final axis must contain Cartesian components.
    The summation axis must not be the Cartesian axis.
    """
    histories = _vector(histories, "histories")

    if histories.ndim < 2:
        raise ValueError("At least one member axis is required.")

    if not -histories.ndim <= axis < histories.ndim:
        raise ValueError("Invalid summation axis.")

    if axis % histories.ndim == histories.ndim - 1:
        raise ValueError("Cannot sum the Cartesian component axis.")

    return np.sum(histories, axis=axis)

sampled_peak

sampled_peak(time: ArrayLike, values: ArrayLike, *, absolute: bool = False) -> dict[str, float | int]

Locate the maximum of a scalar time history.

With absolute=True, the signed value at the maximum absolute magnitude is retained.

Source code in src/fluidmec/hydrodynamics/phase_loading.py
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
def sampled_peak(
    time: ArrayLike,
    values: ArrayLike,
    *,
    absolute: bool = False,
) -> dict[str, float | int]:
    """Locate the maximum of a scalar time history.

    With absolute=True, the signed value at the
    maximum absolute magnitude is retained.
    """
    time = as_float_array(time, "time")
    values = as_float_array(values, "values")

    if (
        time.ndim != 1
        or values.ndim != 1
        or time.shape != values.shape
        or time.size == 0
    ):
        raise ValueError(
            "time and values must be matching nonempty one-dimensional arrays."
        )

    if np.any(np.diff(time) <= 0):
        raise ValueError("time must be strictly increasing.")

    objective = np.abs(values) if absolute else values

    index = int(np.argmax(objective))

    return {
        "index": index,
        "time": float(time[index]),
        "value": float(values[index]),
        "objective": float(objective[index]),
    }

refine_periodic_peak

refine_periodic_peak(values: ArrayLike, period: float, *, start: float = 0.0, absolute: bool = False) -> dict[str, float | int]

Estimate a periodic peak using three samples.

Samples must be uniformly spaced over one period, with the repeated endpoint excluded.

The returned peak is an interpolation estimate, not a new physical solver evaluation.

Source code in src/fluidmec/hydrodynamics/phase_loading.py
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
def refine_periodic_peak(
    values: ArrayLike,
    period: float,
    *,
    start: float = 0.0,
    absolute: bool = False,
) -> dict[str, float | int]:
    """Estimate a periodic peak using three samples.

    Samples must be uniformly spaced over one period,
    with the repeated endpoint excluded.

    The returned peak is an interpolation estimate,
    not a new physical solver evaluation.
    """
    values = as_float_array(values, "values")

    if values.ndim != 1 or values.size < 3:
        raise ValueError("At least three scalar samples required.")

    period = _positive_scalar(period, "period")
    start = _scalar(start, "start")

    n = values.size
    dt = period / n

    objective = np.abs(values) if absolute else values

    index = int(np.argmax(objective))

    left = objective[(index - 1) % n]
    centre = objective[index]
    right = objective[(index + 1) % n]

    curvature = left - 2 * centre + right

    offset = 0.0
    peak = float(centre)

    scale = max(abs(left), abs(centre), abs(right))

    threshold = 8 * np.finfo(float).eps * scale

    if curvature < -threshold:
        offset = float(0.5 * (left - right) / curvature)

        offset = float(np.clip(offset, -0.5, 0.5))

        peak = float(
            centre + 0.5 * (right - left) * offset + 0.5 * curvature * offset**2
        )

    refined_time = start + ((index + offset) * dt) % period

    sign = np.sign(values[index]) if absolute else 1.0

    return {
        "index": index,
        "time": float(refined_time),
        "value": float(sign * peak),
        "objective": peak,
        "offset_samples": offset,
        "sampled_objective": float(centre),
    }

structure_load_history

structure_load_history(members: Sequence[Mapping], *, time: ArrayLike, wave_height: float, period: float, depth: float, reference: ArrayLike = (0.0, 0.0, 0.0), wave_direction: float = 0.0, **parameters) -> dict

Calculate simultaneous structural load histories.

Each member mapping requires start, end and diameter.

Optional member-specific keys: name, group, drag_coefficient, inertia_coefficient.

Other environmental parameters are passed to wave_current_member_force_moment.

Returns:

Type Description
dict

Total and individual member histories, group histories, base shear, overturning, vertical force and torsion.

Notes

This is an applied hydrodynamic load aggregator, not a structural dynamic response solver.

Source code in src/fluidmec/hydrodynamics/phase_loading.py
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
def structure_load_history(
    members: Sequence[Mapping],
    *,
    time: ArrayLike,
    wave_height: float,
    period: float,
    depth: float,
    reference: ArrayLike = (0.0, 0.0, 0.0),
    wave_direction: float = 0.0,
    **parameters,
) -> dict:
    """Calculate simultaneous structural load histories.

    Each member mapping requires start, end and diameter.

    Optional member-specific keys:
        name, group, drag_coefficient,
        inertia_coefficient.

    Other environmental parameters are passed to
    wave_current_member_force_moment.

    Returns
    -------
    dict
        Total and individual member histories,
        group histories, base shear, overturning,
        vertical force and torsion.

    Notes
    -----
    This is an applied hydrodynamic load aggregator,
    not a structural dynamic response solver.
    """
    time = as_float_array(time, "time")

    if time.ndim != 1 or time.size == 0:
        raise ValueError("time must be a nonempty 1D array.")

    if np.any(np.diff(time) <= 0):
        raise ValueError("time must be strictly increasing.")

    if len(members) == 0:
        raise ValueError("At least one member is required.")

    reference = _vector(reference, "reference")

    if reference.shape != (3,):
        raise ValueError("reference must have shape (3,).")

    allowed = {
        "start",
        "end",
        "diameter",
        "name",
        "group",
        "drag_coefficient",
        "inertia_coefficient",
    }

    required = {"start", "end", "diameter"}

    individual = []
    names = []
    groups = {}
    total = {}

    common = dict(parameters)

    common.update(
        time=time,
        wave_height=wave_height,
        period=period,
        depth=depth,
        reference=reference,
        wave_direction=wave_direction,
    )

    for index, member in enumerate(members):
        if not isinstance(member, Mapping):
            raise ValueError("Each member must be a mapping.")

        if not required.issubset(member):
            raise ValueError("Member requires start, end, diameter.")

        if set(member) - allowed:
            raise ValueError("Unrecognised member parameter.")

        name = str(member.get("name", f"member_{index}"))

        if name in names:
            raise ValueError(f"Duplicate member name: {name}")

        group = str(member.get("group", "Ungrouped"))

        local = common.copy()
        local["diameter"] = member["diameter"]

        for key in [
            "drag_coefficient",
            "inertia_coefficient",
        ]:
            if key in member:
                local[key] = member[key]

        result = wave_current_member_force_moment(
            member["start"],
            member["end"],
            **local,
        )

        names.append(name)
        individual.append(result)

        if group not in groups:
            groups[group] = {key: np.zeros_like(value) for key, value in result.items()}

        for key, value in result.items():
            if key not in total:
                total[key] = np.zeros_like(value)

            total[key] += value
            groups[group][key] += value

    force = total["total_force"]
    moment = total["total_moment"]

    return {
        "time": time,
        "member_names": names,
        "members": individual,
        "groups": groups,
        "total": total,
        "base_shear": base_shear(force),
        "overturning": overturning_moment(moment),
        "vertical_force": force[:, 2],
        "torsion": moment[:, 2],
    }

directional_load_envelope

directional_load_envelope(members: Sequence[Mapping], directions: ArrayLike, *, wave_height: float, period: float, depth: float, samples: int = 256, reference: ArrayLike = (0.0, 0.0, 0.0), refine: bool = True, **parameters) -> dict

Evaluate peak loads across wave directions.

Directional maxima are sampled, not continuous optimisations over direction.

With refine=True, each interpolated critical time is re-evaluated using the physical member solver.

Current direction remains fixed unless the caller changes it between separate envelope calculations.

Source code in src/fluidmec/hydrodynamics/phase_loading.py
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
def directional_load_envelope(
    members: Sequence[Mapping],
    directions: ArrayLike,
    *,
    wave_height: float,
    period: float,
    depth: float,
    samples: int = 256,
    reference: ArrayLike = (0.0, 0.0, 0.0),
    refine: bool = True,
    **parameters,
) -> dict:
    """Evaluate peak loads across wave directions.

    Directional maxima are sampled, not continuous
    optimisations over direction.

    With refine=True, each interpolated critical time
    is re-evaluated using the physical member solver.

    Current direction remains fixed unless the caller
    changes it between separate envelope calculations.
    """
    directions = as_float_array(directions, "directions")

    if directions.ndim != 1 or directions.size == 0:
        raise ValueError("directions must be a nonempty 1D array.")

    directions = np.mod(directions, 360.0)

    if np.unique(directions).size != directions.size:
        raise ValueError("Directions must be unique modulo 360.")

    time = periodic_time_grid(period, samples)

    peaks = {
        "base_shear": [],
        "overturning": [],
        "vertical_force": [],
        "torsion": [],
    }

    peak_times = {key: [] for key in peaks}

    signed_values = {key: [] for key in peaks}

    for direction in directions:
        common = dict(parameters)

        common.update(
            wave_height=wave_height,
            period=period,
            depth=depth,
            reference=reference,
            wave_direction=float(direction),
        )

        history = structure_load_history(
            members,
            time=time,
            **common,
        )

        candidates = {}

        for key in peaks:
            absolute = key in {"vertical_force", "torsion"}

            initial = sampled_peak(
                time,
                history[key],
                absolute=absolute,
            )

            candidates[key] = initial

            if refine:
                estimate = refine_periodic_peak(
                    history[key],
                    period,
                    absolute=absolute,
                )

                candidates[key] = {
                    **initial,
                    "candidate_time": estimate["time"],
                }

        if refine:
            evaluation_times = np.unique(
                [item["candidate_time"] for item in candidates.values()]
            )

            refined = structure_load_history(
                members,
                time=evaluation_times,
                **common,
            )

        for key, candidate in candidates.items():
            value = candidate["value"]
            objective = candidate["objective"]
            peak_time = candidate["time"]

            if refine:
                trial_time = candidate["candidate_time"]

                index = int(np.searchsorted(evaluation_times, trial_time))

                trial_value = float(refined[key][index])

                trial_objective = (
                    abs(trial_value)
                    if key in {"vertical_force", "torsion"}
                    else trial_value
                )

                if trial_objective > objective:
                    objective = trial_objective
                    value = trial_value
                    peak_time = trial_time

            peaks[key].append(objective)
            peak_times[key].append(peak_time)
            signed_values[key].append(value)

    peaks = {key: np.asarray(value) for key, value in peaks.items()}

    peak_times = {key: np.asarray(value) for key, value in peak_times.items()}

    signed_values = {key: np.asarray(value) for key, value in signed_values.items()}

    critical = {}

    for key, values in peaks.items():
        index = int(np.argmax(values))

        critical[key] = {
            "index": index,
            "direction": float(directions[index]),
            "time": float(peak_times[key][index]),
            "magnitude": float(values[index]),
            "signed_value": float(signed_values[key][index]),
        }

    return {
        "directions": directions,
        "peaks": peaks,
        "peak_times": peak_times,
        "signed_values": signed_values,
        "critical": critical,
    }

References

  1. Dean and Dalrymple (1991). Water Wave Mechanics for Engineers and Scientists.

  2. Morison et al. (1950). The Force Exerted by Surface Waves on Piles.

  3. Sarpkaya (2010). Wave Forces on Offshore Structures.