pyoomph.equations.multi_component module

class pyoomph.equations.multi_component.BalanceGravityAtFarField(gravity_vector, reference_point=[[0], [0], [0]])[source]

Bases: InterfaceEquations

When flow of e.g. the gas domain of an evaporating droplet with gravity is considered, the boundary conditions at the far field may not be traction-free. Otherwise, the hydrostatic pressure will lead to unphysical in/outflow at the far boundaries from the top to the bottom. We can add this to balance for the gravity term at the far field.

This class requires the parent equations to be of type NavierStokesEquation, meaning that if NavierStokesEquation (or subclasses) are not defined in the parent domain, an error will be raised.

Parameters:
required_parent_type

alias of NavierStokesEquations

class pyoomph.equations.multi_component.CompositionAdvectionDiffusionEquations(fluid_props, *, space='C2', wind=field(velocity, < code=0, tags=>), dt_factor=1, boussinesq=False, integrate_advection_by_parts=False, wrap_params_in_subexpressions=True, GCL=False, scheme='BDF2', stabilization=None)[source]

Bases: ScalarTransportEquations

Represents the advection-diffusion equation for a single component in a multi-component system. The equation is given by:

partial_t(massfrac) + div(velocity*massfrac) = div(D*grad(massfrac)) + reaction_rate

where massfrac is the mass fraction of the component, velocity is the velocity field, D is the diffusion coefficient, and reaction_rate is the reaction rate.

Parameters:
  • fluid_props (PureLiquidProperties | PureGasProperties | MixtureLiquidProperties | MixtureGasProperties) – The fluid properties. Default is None.

  • space (Literal['C1', 'C1TB', 'C2', 'C2TB', 'D1', 'D1TB', 'D2', 'D2TB', 'DL', 'D0']) – The finite element space. Default is “C2”, i.e. second order continuous Lagrangian elements.

  • wind (Expression | GiNaC_GlobalParam | int | float) – The wind field. Default is 0.

  • dt_factor (Expression | GiNaC_GlobalParam | int | float) – The temporal factor. Default is 1.

  • boussinesq (bool) – Whether to consider the Boussinesq approximation. Default is False.

  • integrate_advection_by_parts (bool) – Whether to integrate the advection term by parts. Default is False.

  • wrap_params_in_subexpressions (bool) – Whether to wrap the parameters in subexpressions using GiNaC. Default is True.

  • GCL (bool) – Whether to consider the Generalized Continuity Equation. Default is False.

  • scheme (Literal['BDF1', 'BDF2', 'Newmark2', 'TPZ', 'MPT', 'Simpson', 'Boole', 'trapezoidal', 'Kepler', 'Milne', 'midpoint']) – The time stepping scheme. Default is “BDF2”.

  • stabilization (str | Iterable[str] | ScalarTransportStabilization | None) – Optional residual-based stabilization (SUPG etc.) of the mass fraction transport, see ScalarTransportStabilization. None (the default) adds nothing at all.

Note

Scaling to set on problem level. The residual is a mass balance, so each mass fraction is tested with scale_factor("temporal")/scale_factor("mass_density"). mass_density is no field of the system and must be set by problem.set_scaling(mass_density=...).

class pyoomph.equations.multi_component.CompositionAdvectionDiffusionFluxEquations(**kwargs)[source]

Bases: InterfaceEquations

Represents the flux through the interface that naturally arises from the integration by parts of the diffusion term in the advection-diffusion equation.

Parameters:

**kwargs (Expression | GiNaC_GlobalParam | int | float) – The fluxes. The keys are the names of the components and the values are the mass fluxes.

pyoomph.equations.multi_component.CompositionDiffusionEquations(fluid_props, space='C2', dt_factor=1, with_IC=True, spatial_errors=None, isothermal=True, initial_temperature=None, compo_stabilization=None, thermal_stabilization=None, salts='auto')[source]

Adds diffusion equations for the mass fractions of the components in a multi-component system, but without any Navier-Stokes equations. Can be used e.g. for diffusion-limited species transport in a gas phase.

Parameters:
  • fluid_props (PureLiquidProperties | PureGasProperties | MixtureLiquidProperties | MixtureGasProperties) – The fluid properties.

  • space (Literal['C1', 'C1TB', 'C2', 'C2TB', 'D1', 'D1TB', 'D2', 'D2TB', 'DL', 'D0']) – The space for the mass fraction fields.

  • dt_factor (Expression | GiNaC_GlobalParam | int | float) – Factor for the time derivative in the mass fraction fields.

  • with_IC (bool) – Include an initial condition for the initial composition.

  • spatial_errors (float | None) – Add spatial error estimators automatically.

  • isothermal (bool) – If set to False, a temperature equation is included.

  • initial_temperature (Expression | GiNaC_GlobalParam | int | float | None) – Initial condition for the temperature.

  • compo_stabilization (str | Iterable[str] | ScalarTransportStabilization | None) – Optional residual-based stabilization of the mass fraction transport. Without a wind there is nothing for SUPG to act on unless the mesh moves, so this is mainly of interest on an ALE mesh.

  • thermal_stabilization (str | Iterable[str] | ScalarTransportStabilization | None) – The same for the temperature.

  • salts (Union[Literal['auto'], bool]) – Whether to transport the salts dissolved in fluid_props, see CompositionFlowEquations().

Return type:

Equations

Returns:

A coupled set of equations for the mass fractions for the diffusive transport of the components in the mixture.

class pyoomph.equations.multi_component.CompositionDiffusionInfinityEquations(origin=[[0], [0], [0]], farfield_length=None, **infinity_values)[source]

Bases: InterfaceEquations

Represents the condition at infinity for the advection-diffusion equation, using the assumption that in the far field the mass fraction behaves as:

\[w + R \dfrac{\partial w}{\partial r} = w_{\infty}\]

Hence, works only correctly in axisymmetric or 3D. For 2D, we use:

\[w + \dfrac{R}{\log(R/L)} \dfrac{\partial w}{\partial r} = w_{\infty}\]

Due to the logarithmic solution behavior in 2D, the farfield length L must be provided here.

We furthermore only assume diagonal diffusion here

Additionally, advection in normal (radial) direction should be considered i.e. using:

\[u_r(r \to \infty) = u_R \left(\frac{R}{r}\right)^2\]
Parameters:
  • origin (Expression | GiNaC_GlobalParam | int | float) – The origin of the system. Default is vector([0]).

  • farfield_length (Expression | GiNaC_GlobalParam | int | float | None) – The farfield length (only required for 2D). Default is None.

  • **infinity_values (Expression | GiNaC_GlobalParam | int | float) – The values at infinity. The keys are the names of the components and the values are the mass fractions.

pyoomph.equations.multi_component.CompositionFlowEquations(fluid_props, compo_space='C1', compo_dt_factor=1, ns_mode='TH', boussinesq=False, gravity=None, bulkforce=None, ns_dt_factor=1, ns_nl_factor=None, with_IC=True, hele_shaw_thickness=None, spatial_errors=None, isothermal=True, initial_temperature=None, additional_advection=0, momentum_scheme='BDF2', continuity_scheme='BDF2', compo_scheme='BDF2', integrate_advection_by_parts=False, wrap_params_in_subexpressions=True, thermal_dt_factor=1, thermal_adv_factor=1, GCL=False, ns_stabilization=None, ns_stabilization_options=None, compo_stabilization=None, thermal_stabilization=None, salts='auto', salt_space=None, salt_stabilization=None, salt_treatment='dilute')[source]

Assembles a system for multi-component flow with advection-diffusion equations for mass fraction fields of the mixture composition and the Navier-Stokes equations. Potentially, also a temperature field is included.

Parameters:
  • fluid_props (PureLiquidProperties | PureGasProperties | MixtureLiquidProperties | MixtureGasProperties) – The fluid properties.

  • compo_space (Literal['C1', 'C1TB', 'C2', 'C2TB', 'D1', 'D1TB', 'D2', 'D2TB', 'DL', 'D0']) – Space for the mass fraction fields

  • compo_dt_factor (Expression | GiNaC_GlobalParam | int | float) – Factor for the time derivative of the mass fraction fields

  • ns_mode (Literal['TH', 'CR', 'mini', 'C1', 'C2', 'C2C1', 'C1C1', 'C2C2']) – Which Navier-Stokes discretization to use, Taylor-Hood ("TH") or Crouzeix-Raviart ("CR") or MINI Elements ("mini").

  • boussinesq (bool) – Use Boussinesq approximation

  • gravity (Expression | GiNaC_GlobalParam | int | float | None) – Gravity vector [in m/s^2].

  • bulkforce (Expression | GiNaC_GlobalParam | int | float | None) – Additional bulk force term.

  • ns_dt_factor (Expression | GiNaC_GlobalParam | int | float) – Factor for the time derivative of the Navier-Stokes equations.

  • ns_nl_factor (Expression | GiNaC_GlobalParam | int | float | None) – Factor for the non-linear term in the Navier-Stokes equations.

  • with_IC (bool) – Include the initial mixture composition (and temperature) as initial condition.

  • hele_shaw_thickness (Expression | GiNaC_GlobalParam | int | float | None) – If set, we consider a Hele-Shaw flow with the given thickness. This modifies a few terms in the Navier-Stokes equations.

  • spatial_errors (float | None) – Add spatial error estimators automatically.

  • isothermal (bool) – If set to false, a temperature field is included.

  • initial_temperature (Expression | GiNaC_GlobalParam | int | float | None) – Temperature initial condition.

  • additional_advection (Expression | GiNaC_GlobalParam | int | float) – Adds an additional advection term.

  • momentum_scheme (Literal['BDF1', 'BDF2', 'Newmark2', 'TPZ', 'MPT', 'Simpson', 'Boole', 'trapezoidal', 'Kepler', 'Milne', 'midpoint']) – Selects the time stepping scheme for the momentum equation.

  • continuity_scheme (Literal['BDF1', 'BDF2', 'Newmark2', 'TPZ', 'MPT', 'Simpson', 'Boole', 'trapezoidal', 'Kepler', 'Milne', 'midpoint']) – Selects the time stepping scheme for the continuity equation.

  • compo_scheme (Literal['BDF1', 'BDF2', 'Newmark2', 'TPZ', 'MPT', 'Simpson', 'Boole', 'trapezoidal', 'Kepler', 'Milne', 'midpoint']) – Selects the time stepping scheme for the composition equations.

  • integrate_advection_by_parts (bool) – Integrate the advection terms of the composition equations by parts.

  • wrap_params_in_subexpressions – If True, all material properties in the equations are wrapped in subexpressions.

  • thermal_dt_factor (Expression | GiNaC_GlobalParam | int | float) – Factor for the time derivative of the temperature field.

  • thermal_adv_factor (Expression | GiNaC_GlobalParam | int | float) – Factor for the advection term of the temperature field.

  • GCL (bool) – If True, the Geometric Conservation Law is enforced in the ALE formulation of the Navier-Stokes equations and the composition equations.

  • salts (Union[Literal['auto'], bool]) – Whether to transport the salts dissolved in fluid_props, see SaltTransportEquations. "auto" (the default) does it whenever the material carries any, which is what makes water.add_salt("NaCl", 1*milli*molar) actually mean something here. Pass False for the electrohydrodynamic route, where PoissonNernstPlanck() solves for the ions and the potential instead – the two must not both define the ion concentrations.

  • salt_space (Optional[Literal['C1', 'C1TB', 'C2', 'C2TB', 'D1', 'D1TB', 'D2', 'D2TB', 'DL', 'D0']]) – Space of the salt fields. Defaults to compo_space.

  • salt_stabilization (str | Iterable[str] | ScalarTransportStabilization | None) – The same as compo_stabilization, for the salt transport.

  • salt_treatment (Literal['dilute', 'component']) – "dilute" (the default) transports a dissolved salt as a concentration that takes no part in the mass fractions – right to a few percent up to about half molar. "component" upgrades the material in place so that the salt is an ordinary component with a mass fraction, a mole fraction and a share of the volume; the composition equations then transport it, and the evaporation interface condition it needs is the one they already write for any non-volatile component. See treat_salts_as_components().

  • ns_stabilization (str | Iterable[str] | None) – Residual-based stabilization of the flow, e.g. "SUPG+PSPG". Anything but None switches the flow equations to StabilizedNavierStokes. This is what makes the inf-sup unstable equal-order pairs ns_mode="C1C1"/"C2C2" usable.

  • ns_stabilization_options (dict[str, Any] | None) – Further arguments of StabilizedNavierStokes, e.g. {"tau_formula":"codina","C_I":36}.

  • compo_stabilization (str | Iterable[str] | ScalarTransportStabilization | None) – Residual-based stabilization of the mass fraction transport, see ScalarTransportStabilization.

  • thermal_stabilization (str | Iterable[str] | ScalarTransportStabilization | None) – The same for the temperature transport.

The three stabilization switches are independent and all default to off, i.e. to exactly the system that was assembled before they existed. None of them perturbs the interface physics: every added term is an element-interior integral written against the test function of the stabilized field only, so the Marangoni stress, the kinematic boundary condition, mass transfer, latent heat, surfactant transport and the contact-angle conditions – which test against velocity, mesh and the interface fields – are structurally untouched and see the stabilized fields only through their values. The one exception is the discontinuity capturing term "DC", which is diffusion-like and therefore does change the natural boundary condition of the transported field; it is off by default and its footprint is exposed as get_stabilization_flux.

Return type:

Equations

Returns:

A coupled set of equations describing the multi-component flow of the mixture

class pyoomph.equations.multi_component.MultiComponentNavierStokesInterface(interface_props, *, kinbc_name='_kin_bc', velo_connect_prefix='_lagr_conn_', masstransfer_model=None, static='auto', surface_tension_theta=1, total_mass_loss_factor_inside=1, total_mass_loss_factor_outside=1, surface_tension_projection_space=None, additional_normal_traction=0, surface_tension_gradient_directly=False, use_highest_space_for_velo_connection=False, kinematic_bc_coordsys=None, kinematic_bc_space=None, additional_masstransfer_scale=1, additional_kin_bc_test_scale=1, static_normal_interface_motion=0, static_interface_motion_testfunction=None, project_interface_flux=False, surface_tension_factor=1, surfactant_transport=None)[source]

Bases: InterfaceEquations

Represents a multi-component free surface interface between two fluids with multiple components. It considers mass transfer by a mass transfer model and automatically connects the velocity if necessary.

Parameters:
  • interface_props (LiquidGasInterfaceProperties | LiquidLiquidInterfaceProperties) – The interface properties (e.g. surface tension).

  • kinbc_name (str) – The name of the kinematic boundary condition multiplier. Default is “_kin_bc”.

  • velo_connect_prefix (str) – The prefix for the velocity connection fields. Default is “_lagr_conn_”.

  • masstransfer_model (Union[MassTransferModelBase, Literal[False], None]) – The mass transfer model (e.g. UNIFAC). Default is None.

  • static (Union[Literal['auto'], bool]) – Whether the interface is static. Default is “auto”.

  • surface_tension_theta (float) – The theta method to consider the surface tension (0: explicit, i.e. from last step, 1: fully implicit). Default is 1.

  • total_mass_loss_factor_inside (Expression | GiNaC_GlobalParam | int | float) – Multiplicative factor for the total mass loss inside the domain. Default is 1.

  • total_mass_loss_factor_outside (Expression | GiNaC_GlobalParam | int | float) – Multiplicative factor for the total mass loss outside the domain. Default is 1.

  • surface_tension_projection_space (Optional[Literal['C1', 'C1TB', 'C2', 'C2TB', 'D1', 'D1TB', 'D2', 'D2TB', 'DL', 'D0']]) – The finite element space for the surface tension projection. Default is None.

  • additional_normal_traction (Expression | GiNaC_GlobalParam | int | float) – Additional normal traction. Default is 0.

  • surface_tension_gradient_directly (bool) – Whether to consider the surface tension gradient directly. Default is False.

  • use_highest_space_for_velo_connection (bool) – Whether to use the highest space for the velocity connection. Default is False.

  • kinematic_bc_coordsys (BaseCoordinateSystem | None) – The coordinate system for the kinematic boundary condition. Default is None.

  • kinematic_bc_space (Optional[Literal['C1', 'C1TB', 'C2', 'C2TB', 'D1', 'D1TB', 'D2', 'D2TB', 'DL', 'D0']]) – The finite element space for the kinematic boundary condition. Default is None, means auto-select.

  • additional_masstransfer_scale (ExpressionOrNum) – Additional mass transfer scale. Default is 1.

  • additional_kin_bc_test_scale (ExpressionOrNum) – Additional kinematic boundary condition test scale. Default is 1.

  • static_normal_interface_motion (Expression | GiNaC_GlobalParam | int | float) – If solved on a static mesh, we can mimic the interface motion by moving it in normal direction with this rate. Default is 0.

  • static_interface_motion_testfunction (Expression | GiNaC_GlobalParam | int | float | None) – If set, we solve that the total outflux is zero by adjusting this.

  • project_interface_flux (bool) – If set to True, the interface flux (kinematic BC) is projected and used for the kinematic BC. Default is False.

  • surface_tension_factor (Expression | GiNaC_GlobalParam | int | float) – The surface tension factor. Multiplicative factor for the imposition of the surface tension. Default is 1.

  • surfactant_transport (Union[SurfactantTransportEquations, Literal[False], None]) – How the surfactants registered on the interface properties are transported. None (the default) uses SurfactantTransportEquations in its conservative form, which keeps the total amount of an insoluble surfactant exact rather than to the order of the time stepping. Pass a configured instance to change the form, the variable or the stabilization – SurfactantTransportEquations(form="legacy") reproduces the pre-2026 behaviour bit for bit. False switches the surfactant equations off entirely, e.g. to supply your own.

Note

Scaling to set on problem level. The mass transfer rate is scaled with scale_factor("velocity")*scale_factor("mass_density"), i.e. besides the velocity also mass_density – no field of the system – has to be set by problem.set_scaling(mass_density=...).

get_surfactant_transport()[source]

The SurfactantTransportEquations in use, if any.

Return type:

SurfactantTransportEquations | None

property kinematic_bc_coordinate_sys: Any

Deprecated alias of kinematic_bc_coordsys.

uses_projected_surfactant_velocity()[source]

Whether the projected advection velocity field _uinterf_proj exists.

It only does in the legacy transport form. The conservative form integrates the advection by parts, so its natural end condition is already zero flux and there is nothing for the contact line to constrain - see the module docstring of surfactants.

Return type:

bool

with_balanced_end(*boundaries)[source]

Adds the MultiComponentNavierStokesInterfaceBalancedEnd equations to the given boundaries of the interface. Thereby, the Neumann force is balanced at the specified end points. Use this when you neither want to fix the position nor the contact angle at specific end points

class pyoomph.equations.multi_component.MultiComponentNavierStokesInterfaceBalancedEnd(*args: Any, **kwargs: Any)[source]

Bases: InterfaceEquations

The MultiComponentNavierStokesInterface without surface_tension_gradient_directly uses the surface divergence theorem to integrate the surface tension term by parts. This results in a Neumann term at the end points of the interface, which is not balanced by default. This Neumann term can be used e.g. for contact angles, but if you do not want to impose any, you can cancel out the Neumann term by adding this equation to the end points of the interface. This will balance the surface tension at the end points, resulting in a free contact angle.

required_parent_type

alias of MultiComponentNavierStokesInterface

class pyoomph.equations.multi_component.TemperatureAdvectionConductionEquation(material, space='C2', wind=field(velocity, < code=0, tags=>), rho_override=None, cp_override=None, lambda_override=None, dt_factor=1, adv_factor=1, GCL=False, gcl_scheme='BDF2_degr', stabilization=None)[source]

Bases: TemperatureConductionEquation

Represents the temperature advection-conduction equation of the form:

rho * cp * (partial_t(T) + u * grad(T)) = div(k * grad(T))

where rho is the mass density, cp is the specific heat capacity, u is the velocity, and k is the thermal conductivity. grad and div represent the gradient and divergence operators, respectively.

Parameters:

Note

Scaling to set on problem level. As for TemperatureConductionEquation, the test scaling requires the non-field scale rho_cp, i.e. problem.set_scaling(rho_cp=...).

class pyoomph.equations.multi_component.TemperatureConductionEquation(material, space='C2', rho_override=None, cp_override=None, lambda_override=None, dt_factor=1, GCL=False, gcl_scheme='BDF2_degr', stabilization=None)[source]

Bases: ScalarTransportEquations

Represents the temperature conduction equation of the form:

rho * cp * partial_t(T) = div(k * grad(T))

Parameters:
  • material (MaterialProperties | BaseLiquidProperties | BaseGasProperties | BaseSolidProperties | PureSolidProperties | PureLiquidProperties | PureGasProperties | MixtureLiquidProperties | MixtureGasProperties) – The material properties.

  • space (Literal['C1', 'C1TB', 'C2', 'C2TB', 'D1', 'D1TB', 'D2', 'D2TB', 'DL', 'D0']) – The finite element space. Default is “C2”, i.e. quadratic continuous Lagrangian elements.

  • rho_override (Expression | GiNaC_GlobalParam | int | float | None) – The mass density. Default is None.

  • cp_override (Expression | GiNaC_GlobalParam | int | float | None) – The specific heat capacity. Default is None.

  • lambda_override (Expression | GiNaC_GlobalParam | int | float | None) – The thermal conductivity. Default is None.

  • dt_factor (Expression | GiNaC_GlobalParam | int | float) – The factor for the time derivative. Default is 1.

  • GCL (bool) – Write the transient term as the derivative of the whole integral of rho*cp*T, and (in the advective subclass) advect with the velocity relative to the mesh: the conservative ALE form. On a mesh that follows a moving or evaporating boundary the enthalpy is then conserved to machine precision instead of to the order of the time stepping. If rho or cp depend on the temperature this is a different model, not merely a different discretization: the GCL form differentiates the product rho*cp*T in time, where the standard form multiplies rho*cp onto partial_t(T). Identical for constant properties. Default is False.

  • gcl_scheme (Literal['BDF1', 'BDF2', 'Newmark2', 'BDF2_degr', 'Newmark2_degr']) – Time stepping scheme of the GCL transient, from the set a derivative of an integral understands. The default "BDF2_degr" degrades to first order in the first step, where an initial condition has no history.

  • stabilization (str | Iterable[str] | ScalarTransportStabilization | None) – Optional residual-based stabilization (SUPG etc.), see ScalarTransportStabilization. None (the default) adds nothing at all. Without a wind there is nothing to stabilize on a static mesh, but on a moving (ALE) mesh the transport by the mesh motion is stabilized.

Note

Scaling to set on problem level. The temperature equation is tested with scale_factor("temporal")/(scale_factor("temperature")*scale_factor("rho_cp")). Besides the temperature field scale, the volumetric heat capacity rho_cp is therefore required, i.e. problem.set_scaling(rho_cp=...), and it is no field of the system.

define_galerkin_residuals()[source]

The Galerkin part alone. Subclasses extend this, not define_residuals, so that the stabilization stays the last thing added and is added exactly once.

get_rho_cp_k()[source]

The three material coefficients, honouring the *_override arguments. Resolved in one place so that the strong residual cannot drift away from the Galerkin one.

Return type:

tuple[Expression | GiNaC_GlobalParam | int | float, Expression | GiNaC_GlobalParam | int | float, Expression | GiNaC_GlobalParam | int | float]

class pyoomph.equations.multi_component.TemperatureHeatFlux(q)[source]

Bases: InterfaceEquations

Represents the heat flux through the interface.

This class requires the parent equations to be of type TemperatureConductionEquation, meaning that if TemperatureConductionEquation (or subclasses) are not defined in the parent domain, an error will be raised.

Parameters:

q (Expression | GiNaC_GlobalParam | int | float) – The heat flux.

required_parent_type

alias of TemperatureConductionEquation

class pyoomph.equations.multi_component.TemperatureInfinityEquations(far_temperature, origin=[[0], [0], [0]])[source]

Bases: InterfaceEquations

Represents the condition at infinity for the temperature conduction equation, using the assumption that in the far field the temperature behaves as:

T(r->infty) = T_infty + R/r(T_R-T_infty) for some large R and r>>R

Hence, works only correctly in axisymmetric or 3d.

Parameters:
class pyoomph.equations.multi_component.ThinLayerThermalConductionEquation(material, thickness, *, ALE='auto', outside_temperature=None)[source]

Bases: InterfaceEquations

Considers a thin plate (not resolved in depth direction) of some material in between. Can be added in between two domains with temperature equations. If there is no domain at the opposite side, the outside_temperature must be set manually

Parameters: