Solver

The Solvers package defines the OpenSTREAM core solver modules and their associated superclasses. Each solver is tailored to simulate specific regimes of one-dimensional, two-phase flow, with increasing levels of physical detail and complexity.

Explore the available solver frameworks:

The following is a list of associated superclasses, each with its respective properties and methods. These foundational components provide shared functionality and structure across solver implementations.


class Solvers.SolverState

Bases: uint16

SOLVERSTATE Enumeration of solver execution states

This enumeration defines the possible states a solver can be in during or after execution. It is used to track solver execution and convergence status.

States:

  • UNSOLVED — Solver has not yet run

  • SOLVEDCONVERGED — Solver completed and converged successfully

  • SOLVEDNOTCONVERGED — Solver completed but did not converge

  • INITIALSTEPCONVERGED — Initial steady-state step completed and converged

  • INITIALSTEPNOTCONVERGED — Initial steady-state step completed but did not converge

class Solvers.SolverPlotter(titles, WallIdxs, opts)

Bases: handle

SOLVERPLOTTER Framework for generating solver plots

This class provides a flexible plotting interface for visualizing solver results. It supports tiled layouts, animated series, and customizable plot styles. It also includes UI controls for animation playback and export.

Constructor Summary
SolverPlotter(titles, WallIdxs, opts)

SOLVERPLOTTER Constructor method to initialize plotter objects and layout

Property Summary
FontSize = 13

Font size of text in plots

Grid = 'on'

Grid display option

Title = ""

Title of the figure

Ts = []

Time series [s]

WallIdx = 1

Wall index for multi-wall simulations

Zs = []

Axial positions [m]

currentAhIdx = NaN

Index of current active axes

Method Summary
addTile(plotters, opts)

ADDTILE Method to add a new tile to the layout or retrieve existing one by title

static fieldName2plotStyle(fieldName)

FIELDNAME2PLOTSTYLE Static method to map field names to plot styles (color, line, marker)

gca(plotters)

GCA Get Method to retrieve current axes handle

gcf(plotters)

GCF Method to retrieve current plotter handle

legend(plotters, varargin)

legend Method to add legend to current axes

newTile(plotters, opts)

NEWTILE Method to create a new tile with labels and formatting

plotK(plotters, klocZ, ah)

PLOTK Method to plot obstruction elevation indicators

plotOAF(plotters, oafZ)

PLOTOAF Method to plot onset of annular flow boundary indicator

plotz(plotters, YData, fieldName, opts)

PLOTZ Method to plot spatial or temporal data (YData) on the current axes

resizeFigure(plotters, scaleFactor)

resizeFigure Resizes the figure based on tiledlayout rows/columns Keeps top-left fixed and goes full-screen if size exceeds screen resolution.

Usage:

  • plotters.resizeFigure() — Default scaleFactor = 1

  • plotters.resizeFigure(1.2) — Tiles 20% larger

  • plotters.resizeFigure(0.8) — Tiles 20% smaller

setZs(plotters, Zs)

SETZS Method to assign the parameter(space or time) on the plotter x-axis

xlim(plotters, newLim)

xlim Method to get or set x-axis limits for current axes

ylabels(plotters, labels)

YLABEL Method to set y-axis tick labels

ylim(plotters, newLim)

YLIM Method to get or set y-axis limits for current axes

class Solvers.AbstractSolver(inputSet)

Bases: handle

ABSTRACTSOLVER Defines the base interface and shared functionality for all solver classes.

Subclasses must implement the abstract methods and properties defined here.

Constructor Summary
AbstractSolver(inputSet)

ABSTRACTSOLVER Constructor for AbstractSolver

Initializes the solver with a given Inputs.InputSet and applies solver-specific properties.

Property Summary
STATE

Solver state, defined by Solvers.SolverState enumeration

inputSet

Input configuration object of type Inputs.InputSet

Method Summary
static CreateITR(NZ, ITRFields)

CreateITR Create a structure for inner iteration values

Inputs:

  • NZ — Number of axial nodes (scalar)

  • ITRFields — (string array) Names of fields to include in the struct

Output:

  • ITR — Struct with fields initialized to zero vectors of length NZ

log(solver, varargin)

LOG Log messages to the session log

save(solver, opts)

SAVE Save the solver object to a .mat file with a customizable name.

Inputs:

  • solver — The solver object to be saved.

  • opts.name — (string) Name of the variable under which to save the solver. Default set to solver name

  • opts.showpath — (logical) Whether to display the save path. Default: true.

solverName(solver)

SOLVERNAME Returns the name of the solver

class Solvers.AbstractFilm(inputSet, fluid)

Bases: Solvers.AbstractField

ABSTRACTFILM Base class for liquid film models in three- and four-field solvers

This abstract class defines shared methods and properties for liquid film modeling. It includes calculations for film thickness, entrainment, shear forces, and velocity models. Specific entrainment models (e.g., Okawa, Govan) and friction models are implemented.

Constructor Summary
AbstractFilm(inputSet, fluid)

AbstractFilm Constructor for AbstractFilm class

Initializes Inputs.InputSet and Inputs.FluidProperties

Property Summary
DZ = 0

Axial step size [m]

fluid

Inputs.FluidProperties object containing fluid thermophysical properties

inputSet

Inputs.InputSet object containing geometry, model, and boundary conditions

mix = NaN

Solvers.Mixture.Mixture object of the mixture solver

Method Summary
CV(absfilm, zIdx)

CV Film/vapor interfacial friction factor [-]

Based on selected Inputs.Model.VAPORFRIC model.

CV_WALLISTHICK_CALC(absfilm, thick, C)

CV_WALLISTHICK_CALC Private method to calculate the interfacial shear factor [-]

Based on the InputEnums.VAPORFRIC = WALLISTHICK model.

CW(absfilm, zIdx)

CW Film wall friction factor [-]

Based on selected Inputs.Model.THINFILMFRIC model.

CW_LAM_CALC(absfilm, zIdx, C)

CW_LAM_CALC Private method to calculate the laminar wall friction factor [-]

CW_TURB_CALC(absfilm, zIdx, C)

CW_TURB_CALC Private method to calculate the turbulent wall friction factor [-]

ENTNUM(absfilm, zIdx)

ENTNUM Private method to calculate the entrainment number [-]

Based on Okawa model assumptions.

FBUOY(absfilm, zIdx)

FBUOY Film buoyancy force [N/m^2]

FDEP(absfilm, drop, zIdx)

FDEP Drop deposition shear force [N/m^2]

FGRAV(absfilm, zIdx)

FGRAV Gravitational force on film [N/m^2]

FTOT(absfilm, drop, zIdx)

FTOT Total film forces per unit wall area [N/m^2]

FVAPOR(absfilm, zIdx)

FVAPOR Vapor shear stress on film [N/m^2]

FWALL(absfilm, zIdx)

FWALL Film wall shear stress [N/m^2]

MENT(absfilm, zIdx)

MENT Film entrainment mass flux [kg/m^2/s]

Based on selected Inputs.Model.ENTRAINMENT model.

MTOT(absfilm, drop, zIdx)

MTOT Total film mass transfer [kg/m^2/s]

OKAWACOEFS(absfilm, entnum, coefs)

OKAWACOEFS Private method to determine the coefficients used in InputEnums.ENTRAINMENT = OKAWA entrainment models

Based on the calculated entrainment number

OKAWAMENT(absfilm, zIdx, coefs)

OKAWAMENT Private method to calculate the entrainment mass flux [kg/m^2/s]

Based on Okawa models.

RE(absfilm, zIdx)

RE Film Reynolds number [-]

THICK(absfilm, zIdx)

THICK Film thickness [m]

UALGEBR(absfilm, zIdx)

UALGEBR Film velocity using simple algebraic model [m/s]

From Adamsson and Le Corre [2014] (eq. 21 or 23).

UEQUIL(absfilm, drop, zIdx)

UEQUIL Film velocity using full force equilibrium model [m/s]

UEQUILS(absfilm, zIdx)

UEQUILS Film velocity assuming equilibrium between wall and vapor shear [m/s]

UWALL(absfilm, zIdx)

UWALL Film wall friction velocity [m/s]

WL(absfilm, zIdx)

WL Film mass flow rate per unit perimeter [kg/s/m]

X(absfilm, zIdx)

X Vapor quality in the near-wall region [-]

Vapor quality in the near-wall region, considering only the film for the liquid phase. The near-wall region is defined in the mixture solver.

Inputs:

YPLUS2THICK(absfilm, yplus, zIdx)

YPLUS2THICK Thickness based on wall unit value [m]

class Solvers.AbstractPhase

Bases: handle

ABSTRACTPHASE Base class for phase definitions across solvers

This abstract class serves as a common interface for all phase-type classes used in solver implementations. It is intended to provide a foundation for shared behavior and structure.

class Solvers.AbstractField

Bases: matlab.mixin.Copyable

ABSTRACTFIELD Base class for field definitions across solvers

This abstract class defines shared properties and methods for all field-type classes used in solver implementations. It provides mechanisms for transient data extraction, plotting, memoization, struct conversion, and property copying.

Constructor Summary
AbstractField()

ABSTRACTFIELD Constructor for AbstractField class

Property Summary
DT

Time step size [s]

ITR

Iteration properties

NTIME

Number of time steps [-]

NZ

Number of axial steps [-]

TIDX

Time step index [-]

TIME

Time series [s]

Z

Elevation [m]

Method Summary
copyFlowProperties(srcObj, targetObj, opts)

COPYFLOWPROPERTIES Copies flow properties from source to target field object

Supports full or partial copying depending on ‘opts.all’ flag.

memoizeFunction(methodStr, methodHandle, varargin)

MEMOIZEDMETHOD Registers and retrieves memoized function handles

Avoids redundant computation by caching results.

Adapted from https://stackoverflow.com/a/75037451

plotzt(param, ylabelText, ylabelUnit, k, opt, subobj, annular, time)

PLOTZT 2D Generates a 2D space-time distribution plot for a given parameter

struct()

STRUCT Converts field object to a structured array

Includes TIME, ITR, and flow properties.

transient(param, subobj, opt)

TRANSIENT Extracts transient distribution array for a given parameter

Supports wall-wise and axial/time slicing with optional subobject access.