romtools.workflows.residual_evaluator#

Protocol for interfacing with external application to compute residual snapshots corresponding to existing state snapshots.

Functions

evaluate_and_load_steady_residual_and_jacobian_snapshots(...)

Core algorithm that takes a residual_evaluator, a list of steady full-order model snapshot directories, and a snapshot_filename, and computes the corresponding residual and Jacobian-basis product snapshots.

evaluate_and_load_steady_residual_snapshots(...)

Core algorithm that takes a residual_evaluator, a list of steady full-order model snapshot directories, and a snapshot_filename, and computes the corresponding residual snapshots.

evaluate_and_load_unsteady_residual_and_jacobian_snapshots(...)

Core algorithm that takes a residual_evaluator, a list of unsteady full-order model snapshot directories, and a snapshot_filename, and computes the corresponding residual snapshots.

evaluate_and_load_unsteady_residual_snapshots(...)

Core algorithm that takes a residual_evaluator, a list of unsteady full-order model snapshot directories, and a snapshot_filename, and computes the corresponding residual snapshots.

Classes

ResidualEvaluator(*args, **kwargs)

Baseline residual evaluator protocol

TransientResidualEvaluator(*args, **kwargs)

Baseline residual evaluator protocol

class romtools.workflows.residual_evaluator.ResidualEvaluator(*args, **kwargs)[source]#

Bases: Protocol

Baseline residual evaluator protocol

compute_reduced_states(filename)[source]#

Reads the full-order model solution(s) from the specified filename and computes the corresponding reduced state(s)

Parameters:

filename (str) – filename of the file containing the full-order model solution data

Returns:

The projected full-order solution in a 1- or 2-dimensional array. 1st dimension: reduced state, 2nd dimension: sample index corresponding full-model solution data file.

Return type:

np.ndarray

evaluate_full_residuals(run_directory, full_model_directory, reduced_states, parameter_sample)[source]#

Evaluate the full-order model residuals corresponding to full states reconstructed from an array of reduced states

Parameters:
  • run_directory (str) – Absolute path to directory in which residual is being computed.

  • full_model_directory (str) – Absolute path to directory in which the full model data was computed.

  • reduced_state (np.ndarray) – 2-dimensional reduced state vector. 1st dimension: reduced state,

  • dimension (2nd) – sample index

  • parameter_sample (dict) – Dictionary contatining parameter names and sample values

  • reduced_states (ndarray)

Returns:

The full-order residual in tensor form, should be 3-dimensional, even for a single sample

Return type:

np.ndarray

evaluate_full_residuals_and_jacobian_basis_products(run_directory, full_model_directory, reduced_states, parameter_sample)[source]#

Evaluate the full-order model residuals corresponding to full states reconstructed from an array of reduced states

Parameters:
  • run_directory (str) – Absolute path to directory in which residual is being computed.

  • full_model_directory (str) – Absolute path to directory in which the full model data was computed.

  • reduced_state (np.ndarray) – 2-dimensional reduced state vector. 1st dimension: reduced state,

  • dimension (2nd) – sample index

  • parameter_sample (dict) – Dictionary contatining parameter names and sample values

  • reduced_states (ndarray)

Returns:

The full-order residual in tensor form, should be 3-dimensional, even for a single sample np.ndarray: The full-order jacobian-basis product in tensor form, should be 4-dimensional, even for a single sample 1st dimension: sample index, 2nd dimension: variable index, 3rd dimension: spatial index, 4th dimension: modal index

Return type:

np.ndarray

class romtools.workflows.residual_evaluator.TransientResidualEvaluator(*args, **kwargs)[source]#

Bases: Protocol

Baseline residual evaluator protocol

compute_reduced_states(filename)[source]#

Reads the full-order model solution and time stamps from the specified filename and computes the corresponding reduced states

Parameters:

filename (str) – filename of the file containing the full-order model solution data

Returns:

The projected full-order solution in a 2- or 3-dimensional array. 1st dimension: reduced state, 2nd dimension: time, 3rd dimension: other states in time stencil. If the array is 2-dimensional, it is assumed that the states are sequential in time.

Return type:

np.ndarray

evaluate_full_residuals(run_directory, full_model_directory, reduced_states, parameter_sample, times)[source]#

Evaluate the full-order model residuals corresponding to full states reconstructed from an array of reduced states

Parameters:
  • run_directory (str) – Absolute path to directory in which residual is being computed.

  • full_model_directory (str) – Absolute path to directory in which the full model data was computed.

  • reduced_state (np.ndarray) – 2- or 3-dimensional reduced state vector. 1st dimension: reduced state,

  • dimension (2nd dimension is only needed if the reduced state array is 3-dimensional; the 2nd) – time, 3rd dimension: other states in time stencil. If the array is 2-dimensional, it

  • time. (is assumed that the states are sequential in)

  • parameter_sample (dict) – Dictionary contatining parameter names and sample values

  • times (np.ndarray) – 1-dimensional or 2-dimesional vector of time stamps. The optional

  • dimension

  • stamp. (contains the time stamps of the other states in the time-stencil for a given time)

  • reduced_states (ndarray)

Returns:

The full-order residual in tensor form, should be 3-dimensional, even for a single time step

Return type:

np.ndarray

evaluate_full_residuals_and_jacobian_basis_products(run_directory, full_model_directory, reduced_states, parameter_sample, times)[source]#

Evaluate the full-order model residuals corresponding to full states reconstructed from an array of reduced states

Parameters:
  • run_directory (str) – Absolute path to directory in which residual is being computed.

  • full_model_directory (str) – Absolute path to directory in which the full model data was computed.

  • reduced_state (np.ndarray) – 2- or 3-dimensional reduced state vector. 1st dimension: reduced state,

  • dimension (2nd dimension is only needed if the reduced state array is 3-dimensional; the 2nd) – time, 3rd dimension: other states in time stencil. If the array is 2-dimensional, it

  • time. (is assumed that the states are sequential in)

  • parameter_sample (dict) – Dictionary contatining parameter names and sample values

  • times (np.ndarray) – 1-dimensional or 2-dimesional vector of time stamps. The optional

  • dimension

  • stamp. (contains the time stamps of the other states in the time-stencil for a given time)

  • reduced_states (ndarray)

Returns:

The full-order residual in tensor form, should be 3-dimensional, even for a single time step. np.ndarray: The full-order jacobian-basis product in tensor form, should be 4-dimensional, even for a single sample 1st dimension: sample index, 2nd dimension: variable index, 3rd dimension: spatial index, 4th dimension: modal index

Return type:

np.ndarray

get_times(filename)[source]#

Reads and outputs time stamps from the specified filename

Parameters:

filename (str) – filename of the file containing the full-order model solution data

Returns:

The corresponding solution time stamps in a 1- or 2-dimensional array. The optional 2nd dimension is only needed if the reduced projected full-order solution array is 3-dimensional; the 2nd dimension contains the time stamps of the other states in the time-stencil for a given time stamp.

Return type:

np.ndarray

romtools.workflows.residual_evaluator.evaluate_and_load_steady_residual_and_jacobian_snapshots(residual_evaluator, full_state_directories, state_filename, absolute_run_directory)[source]#

Core algorithm that takes a residual_evaluator, a list of steady full-order model snapshot directories, and a snapshot_filename, and computes the corresponding residual and Jacobian-basis product snapshots.

Parameters:
  • residual_evaluator (ResidualEvaluator) – steady residual evaluator we wish to use

  • full_state_directories (list[str]) – list of directories containing full state data

  • state_filename (str) – filename or base filename of file containing state data

  • absolute_run_directory (str) – absolute path to base directory in which residuals are evaluated

Returns:

The full-order residual snapshots in tensor form. np.ndarray: The full-order Jacobian-basis product snapshots in tensor form.

Return type:

np.ndarray

romtools.workflows.residual_evaluator.evaluate_and_load_steady_residual_snapshots(residual_evaluator, full_state_directories, state_filename, absolute_run_directory)[source]#

Core algorithm that takes a residual_evaluator, a list of steady full-order model snapshot directories, and a snapshot_filename, and computes the corresponding residual snapshots.

Parameters:
  • residual_evaluator (ResidualEvaluator) – steady residual evaluator we wish to use

  • full_state_directories (list[str]) – list of directories containing full state data

  • state_filename (str) – filename or base filename of file containing state data

  • absolute_run_directory (str) – absolute path to base directory in which residuals are evaluated

Returns:

The full-order residual snapshots in tensor form.

Return type:

np.ndarray

romtools.workflows.residual_evaluator.evaluate_and_load_unsteady_residual_and_jacobian_snapshots(residual_evaluator, full_state_directories, state_filename, absolute_run_directory)[source]#

Core algorithm that takes a residual_evaluator, a list of unsteady full-order model snapshot directories, and a snapshot_filename, and computes the corresponding residual snapshots.

Parameters:
  • residual_evaluator (TransientResidualEvaluator) – transient residual evaluator we wish to use

  • full_state_directories (list[str]) – list of directories containing full state data

  • state_filename (str) – filename or base filename of file containing state data

  • absolute_run_directory (str) – absolute path to base directory in which residuals are evaluated

Returns:

The full-order residual snapshots in tensor form. np.ndarray: The full-order Jacobian-basis product snapshots in tensor form.

Return type:

np.ndarray

romtools.workflows.residual_evaluator.evaluate_and_load_unsteady_residual_snapshots(residual_evaluator, full_state_directories, state_filename, absolute_run_directory)[source]#

Core algorithm that takes a residual_evaluator, a list of unsteady full-order model snapshot directories, and a snapshot_filename, and computes the corresponding residual snapshots.

Parameters:
  • residual_evaluator (TransientResidualEvaluator) – transient residual evaluator we wish to use

  • full_state_directories (list[str]) – list of directories containing full state data

  • state_filename (str) – filename or base filename of file containing state data

  • absolute_run_directory (str) – absolute path to base directory in which residuals are evaluated

Returns:

The full-order residual snapshots in tensor form.

Return type:

np.ndarray