MEEM Engine

Conceptual Overview

The MEEMEngine is the central processing unit of the OpenFLASH package. It takes one or more MEEMProblem objects and orchestrates the entire simulation process, from assembling the mathematical system to calculating the final physical results.

The engine is designed around an internal caching system (ProblemCache) that significantly optimizes performance, especially when running simulations over multiple frequencies. It pre-calculates parts of the system that are frequency-independent and stores functions to efficiently compute the frequency-dependent parts.

Primary Workflows

There are two primary ways to use the MEEMEngine:

  1. Single Frequency Analysis: This workflow is ideal for detailed inspection of the system at a single wave frequency. The user typically calls solve_linear_system_multi() to get the solution vector, then uses that vector with post-processing methods like calculate_potentials() or calculate_velocities() to generate spatial field data for visualization.

  2. Frequency Sweep Analysis: This is the most common and powerful workflow. The user configures a MEEMProblem with a range of frequencies and then makes a single call to the run_and_store_results() method. The engine handles the entire loop internally, solving the system for each frequency and packaging all the hydrodynamic coefficients into a convenient Results object.

API Reference

class openflash.meem_engine.MEEMEngine(problem_list: List[MEEMProblem])[source]

Manages multiple MEEMProblem instances and performs actions such as solving systems of equations, assembling matrices, and visualizing results.

Core Solver Methods

These are the main methods for running simulations.

solve_linear_system_multi(problem: MEEMProblem, m0) ndarray[source]
run_and_store_results(problem_index: int) Results[source]

Post-Processing & Analysis Methods

These methods are used after solving the system to compute physical quantities.

compute_hydrodynamic_coefficients(problem, X, m0, modes_to_calculate: ndarray | None = None, rho: float | None = None)[source]

Computes the hydrodynamic coefficients (Added Mass and Damping) from the solution vector X.

Parameters:

rho (float, optional) – Density of fluid. Defaults to value from multi_constants.

calculate_potentials(problem, solution_vector: ndarray, m0, spatial_res, sharp, R_range: ndarray | None = None, Z_range: ndarray | None = None) Dict[str, Any][source]

Calculate full spatial potentials phiH, phiP, and total phi on a meshgrid for visualization.

Parameters: - problem: MEEMProblem instance containing domain and geometry info - solution_vector: solution vector X from linear system solve - spatial_res: resolution of spatial grid for R and Z (default=50) - sharp: whether to refine meshgrid near boundaries (default=True)

Returns: - Dictionary containing meshgrid arrays R,Z and potentials phiH, phiP, phi

calculate_velocities(problem, solution_vector: ndarray, m0, spatial_res, sharp, R_range: ndarray | None = None, Z_range: ndarray | None = None) Dict[str, Any][source]

Utility & Visualization Methods

reformat_coeffs(x: ndarray, NMK, boundary_count) list[ndarray][source]
visualize_potential(field, R, Z, title)[source]