FELiCS.Fields.ModeCollection#

Module Contents#

Classes#

ModeCollection

Container for managing a collection of Mode objects.

Attributes#

FELiCS.Fields.ModeCollection.logger#
class FELiCS.Fields.ModeCollection.ModeCollection(femSpace, mesh, isStateVector=True, analysisType='Modal')#

Container for managing a collection of Mode objects.

This class provides methods to append, retrieve, and analyze modes, as well as to interface with legacy solution objects. It is designed to store and manage eigenmodes and their properties for further analysis.

Initialize the ModeCollection object

Parameters:
  • femSpace (dolfinx.fem.FunctionSpace) – The finite element space associated with the modes.

  • mesh (FELiCS.SpaceDisc.FELiCSMesh) – The mesh associated with the modes.

  • isStateVector (bool, optional) – If True, modes in this collection are treated as state vectors in a mixed space. Default is True.

  • analysisType (str, optional) – Type of analysis this collection belongs to. The string is mapped (case-insensitively) to AnalysisType (e.g. ‘Modal’, ‘Resolvent’, ‘Input_Output’). Default is 'Modal'.

Variables:
  • modeList (list) – List of Mode objects in the collection.

  • femSpace (dolfinx.fem.FunctionSpace) – The finite element space associated with the modes.

  • mesh (FELiCS.SpaceDisc.FELiCSMesh) – The mesh associated with the modes.

  • isStateVector (bool) – Indicates if modes are treated as state vectors.

  • analysisType (AnalysisType) – The specific analysis type enum associated with this collection.

describe()#

Print a description of the ModeCollection.

appendMode(mode)#

Append an existing Mode object to the collection.

Parameters:

mode (Mode) – The Mode object to append.

appendModeFromVector(vector, gain=None, eigenValue=None, guess=None, waveNumber=None, frequency=None, modeType=None, m=0)#

Create a Mode from a coefficient vector and properties, and append it to the collection.

Parameters:
  • vector (array-like) – Coefficient vector for the mode.

  • gain (float, optional) – Gain associated with the mode (mainly for resolvent analysis).

  • eigenValue (complex, optional) – Eigenvalue associated with the mode (for modal analysis).

  • guess (any, optional) – Initial guess or parameter used to obtain this mode.

  • waveNumber (float, optional) – Wave number associated with the mode.

  • frequency (float, optional) – Frequency associated with the mode (for resolvent / input–output).

  • modeType (str or None, optional) – Mode role within the chosen analysis type, mapped to ModeType (e.g. 'direct', 'adjoint', 'response', 'forcing'). If None, a default is chosen inside Mode based on the analysis type.

  • m (int, optional) – Azimuthal wavenumber associated with the mode. Default is 0.

appendSolutionOfEigenProblem(solution, guess, adjoint=False, name=None, m=0)#

Append all modes from an eigenproblem solution to the collection. This assumes that we are doing a ‘Modal’ analysis.

Parameters:
  • solution (tuple) – Tuple containing eigenvalues, eigenvectors, and errors.

  • guess (any) – Initial guess or parameter for the modes.

  • adjoint (bool, optional) – Whether the modes are adjoint modes (default is False).

  • name (str, optional) – A custom name for the mode.

  • m (int, optional) – Azimuthal wavenumber associated with the mode. Default is 0.

appendSolutionOfSVDProblem(forcingArray, omega, gains, resolventOperator, name=None, m=0)#

Append all forcing modes from a SVD solution to the collection for one frequency. Then compute the corresponding response modes and append them as well. This assumes that we are doing a ‘Resolvent’ analysis.

Parameters:
  • forcingArray (array-like) – The forcing array.

  • omega (float) – The frequency.

  • gains (array-like) – The gains from the SVD solution.

  • resolventOperator (FELiCS object) – The resolvent operator, instance of the ResolventOperator class.

  • name (str, optional) – The name of the mode.

  • m (int, optional) – Azimuthal wavenumber associated with the mode. Default is 0.

getMaximumError()#

Return the maximum error among all modes in the collection.

Returns:

The maximum error value.

Return type:

float

getDirectEigenValueSpectrum()#

Return the eigenvalue spectrum of direct (non-adjoint) modes.

Returns:

List of eigenvalues for direct modes.

Return type:

list

getSpectrum()#

Returns the spectrum for either Modal or Resolvent type of analysis.

Returns:#

spectrum: array-like

Array of eigenvalues or gains at each omega and either (i) Direct/Adjoint for ‘Modal’ or (ii) GainNumber for Resolvent.

header: list

List of headers corresponding to the spectrum values.

exportSpectrumToCSV(writer)#

Export the spectrum to a CSV file.

Parameters:

writer (FELiCS.IO.Writer object)

getNearestMode(gain=None, eigenValue=None, guess=None, waveNumber=None, frequency=None)#

Find the nearest mode to the specified parameters.

Parameters:
  • gain (float, optional) – Gain to match.

  • eigenValue (complex, optional) – Eigenvalue to match.

  • guess (any, optional) – Guess to match.

  • waveNumber (float, optional) – Wave number to match.

  • frequency (float, optional) – Frequency to match.

Notes

This method is not yet implemented and will be added in future releases.

getLeadingMode(adjoint=False)#

Return the leading mode based on the imaginary part of the eigenvalue.

For direct modes, returns the mode with the largest imaginary part. For adjoint modes, returns the mode with the smallest imaginary part.

Parameters:

adjoint (bool, optional) – Whether to search among adjoint modes (default is False).

Returns:

The leading Mode object, or None if not found.

Return type:

Mode or None

getOldSolutionObject(meanFlow, param, FEMSpaces)#

Create legacy fluctuation solution objects from the modes.

This is a wrapper for the old solution class and should be removed at the end of restructuring.

Parameters:
  • meanFlow (object) – Mean flow object.

  • param (object) – Parameter object containing case information.

  • FEMSpaces (object) – Finite element spaces.

Returns:

List of fluctuationSolutions objects.

Return type:

list

Notes

In future relases, this method will be deleted

getSize()#

Return the number of modes in the collection.

Returns:

Number of modes in the collection.

Return type:

int

popList()#

Remove and return the last mode in the collection.

Returns:

The last Mode object in the collection.

Return type:

Mode

exportModes(writer, onlyNewN=0)#

Export modes in the collection to HDF5 files.

Parameters:
  • writer (FELiCS.IO.Writer) – Writer object providing exportFieldToH5.

  • onlyNewN (int, optional) – If 0 (default), export all modes in the collection. If positive, export only the last onlyNewN modes that were added.

importData(reader, importFolder, omegas=None, modeType=None, gainNumber=None)#

Import mode collection data from a specified folder using a reader.

Parameters:
  • reader (Reader) – The Reader object used to read the mode data.

  • importFolder (str) – Path to the folder containing the mode files.

  • omegas (list of float, optional) – List of frequencies to import. If None, all frequencies found in the folder are considered (matching is done on rounded values).

  • modeType (str, optional) – Type of mode to import (e.g. ‘Direct’, ‘Adjoint’, ‘Response’, ‘Forcing’). If None, all detected types are imported.

  • gainNumber (int, optional) – Gain number to import (for Resolvent analysis). If None, all gain numbers are imported.