vorlap.computations module

Utility functions for the VorLap package.

vorlap.computations.compute_thrust_torque_spectrum_optimized(components: List[Component], affts: Dict[str, AirfoilFFT], viv_params: VIV_Params, natfreqs: ndarray) Tuple[ndarray, ndarray, ndarray, ndarray, ndarray][source]

Optimized version of compute_thrust_torque_spectrum using cached interpolators and vectorized operations.

Same interface and outputs as the original function, but with significant performance improvements.

Parameters:
  • components – List of structural components including geometry, orientation, and segment-wise parameters.

  • affts – Dictionary mapping airfoil IDs to their FFT-derived lift/drag/moment spectra.

  • viv_params – Encapsulates all analysis parameters, including inflow, rotation axis, fluid properties, and plotting settings.

  • natfreqs – Natural frequencies to compare against.

Returns:

  • percdiff_matrix: Matrix of percent differences between shedding frequencies and natural frequencies.

  • percdiff_info: Matrix of strings with information about the worst percent differences.

  • total_global_force_vector: Total global force vector for each inflow speed and azimuth.

  • total_global_moment_vector: Total global moment vector for each inflow speed and azimuth.

  • global_force_vector_nodes: Global force vector for each node over time.

Return type:

Tuple containing

vorlap.computations.compute_thrust_torque_spectrum(components: List[Component], affts: Dict[str, AirfoilFFT], viv_params: VIV_Params, natfreqs: ndarray) Tuple[ndarray, ndarray, ndarray, ndarray, ndarray][source]

Computes the mean thrust and torque, as well as their frequency-domain spectra, over a range of inflow speeds and azimuthal orientations.

Parameters:
  • components – List of structural components including geometry, orientation, and segment-wise parameters.

  • affts – Dictionary mapping airfoil IDs to their FFT-derived lift/drag/moment spectra.

  • viv_params – Encapsulates all analysis parameters, including inflow, rotation axis, fluid properties, and plotting settings.

  • natfreqs – Natural frequencies to compare against.

Returns:

Matrix of percent differences between shedding frequencies and natural frequencies. percdiff_info: Matrix of strings with information about the worst percent differences. total_global_force_vector: Total global force vector for each inflow speed and azimuth. total_global_moment_vector: Total global moment vector for each inflow speed and azimuth. global_force_vector_nodes: Global force vector for each node over time.

Return type:

percdiff_matrix

Notes

  • Airfoil FFT data is interpolated by Reynolds number and angle of attack.

  • The segment’s local AOA determines how CL and CD spectra are rotated into global inflow and torque components.

vorlap.computations.reconstruct_signal(freqs: ndarray, amps: ndarray, phases: ndarray, tvec: ndarray) ndarray[source]

Reconstruct a time-domain signal from frequency, peak amplitude, and phase (radians).

Assumptions / conventions:
  • DC term(s): entries where freqs == 0 carry the mean value in amps; all such entries are summed.

  • For f > 0, amps are peak amplitudes (not RMS) and phases follow a cosine convention: cos(ωt + φ).

  • Negative frequencies, if present, are ignored (assumed redundant w.r.t. positive freqs + phases).

Parameters:
  • freqs – Array of frequencies [Hz].

  • amps – Array of peak amplitudes corresponding to each frequency.

  • phases – Array of phase offsets [rad] corresponding to each frequency.

  • tvec – Time vector [s] (must have at least 2 samples).

Returns:

Reconstructed time-domain signal (float64), shape = (len(tvec),).

vorlap.computations.rotate_vector(vec: ndarray, axis: ndarray, angle_deg: float) ndarray[source]

Rotate a 3D vector around a given axis using Rodrigues’ rotation formula.

Parameters:
  • vec – Vector to rotate (length-3, any direction).

  • axis – Rotation axis (length-3, not required to be normalized).

  • angle_deg – Rotation angle in degrees (positive is right-hand rule about the axis).

Returns:

Rotated 3D vector (length-3).

vorlap.computations.rotationMatrix(euler: ndarray) ndarray[source]

Compute a 3×3 rotation matrix from Euler angles using the ZYX convention (yaw–pitch–roll).

The angles are provided in degrees and applied in Z–Y–X order (extrinsic frame), meaning:
  1. Rotate about global Z axis (yaw)

  2. Then about the global Y axis (pitch)

  3. Then about the global X axis (roll)

Parameters:

euler – Euler angles [roll, pitch, yaw] in degrees.

Returns:

A 3×3 rotation matrix for transforming a local vector into the global frame.

Example

>>> euler = np.array([30.0, 15.0, 60.0])  # roll, pitch, yaw in degrees
>>> R = rotationMatrix(euler)
>>> v_local = np.array([1.0, 0.0, 0.0])
>>> v_global = R @ v_local
vorlap.computations.interpolate_fft_spectrum(afft, Re_val, AOA_val, field, n_freq_depth=None)[source]

Wrapper function to avoid circular imports.

The actual implementation is in interpolation.py.

Parameters:
  • afft – AirfoilFFT struct containing FFT results.

  • Re_val – Desired Reynolds number.

  • AOA_val – Desired angle of attack (degrees).

  • field – String (‘CL’, ‘CD’, ‘CM’, or ‘CF’) indicating which force coefficient to interpolate.

  • n_freq_depth – Optional number of frequencies to return.

Returns:

Tuple of (freqs, amp_out, phase_out) arrays.