pyoomph.equations.navier_stokes module

class pyoomph.equations.navier_stokes.ConnectVelocityAtInterface(lagr_mult_prefix='_lagr_velo_conn', mass_transfer_rate=0, use_highest_space=False, normal_velocity_jump=0)[source]

Bases: InterfaceEquations

Connects the velocity field at the interface between two domain. This is done by introducing Lagrange multipliers for each velocity component. The Lagrange multipliers are then used to enforce the continuity of the velocity field across the interface.

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

Parameters:
  • lagr_mult_prefix (str, optional) – Prefix for name of the Lagrange multipliers. Defaults to “_lagr_velo_conn”.

  • mass_transfer_rate (ExpressionOrNum, optional) – Mass transfer rate in case there is mass transfer across the interface. Defaults to 0.

  • use_highest_space (bool, optional) – If True, the highest space is used for the Lagrange multipliers. Defaults to False.

required_parent_type

alias of StokesEquations

class pyoomph.equations.navier_stokes.NavierStokesAzimuthalComponent(prescribed_value=None)[source]

Bases: Equations

Adds an azimuthal component to the velocity defined with Navier-Stokes equations in axisymmetric coordinates. This is independent of the azimuthal angle phi, but will contribute to all equations

Parameters:

prescribed_value (ExpressionNumOrNone, optional) – Prescribed value for the azimuthal component. Defaults to None.

class pyoomph.equations.navier_stokes.NavierStokesContactAngle(contact_angle=1 / 2 * Pi, *, wall_normal=[[0], [1], [0]], wall_tangent=None, with_respect_to_tangent=True)[source]

Bases: InterfaceEquations

Enforces a constant contact angle for a droplet.

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

Parameters:
  • contact_angle (ExpressionOrNum) – Contact angle of the droplet. Defaults to 90 * degree.

  • wall_normal (Expression) – Normal vector of the wall (should be normalized). Defaults to vector([0, 1]).

  • wall_tangent (Expression) – Tangential vector of the wall (should be normalized). If None, it is calculated using the bac-cab rule to point inward to the bulk domain, along the substrate (i.e. orthogonal to the wall normal). with_respect_to_tangent (bool): If True, the contact angle is defined with respect to the tangent vector. Defaults to None.

class pyoomph.equations.navier_stokes.NavierStokesEquations(*, dynamic_viscosity=1.0, mode='TH', mass_density=1.0, bulkforce=None, fluid_props=None, dt_factor=1, nonlinear_factor=1, gravity=None, boussinesq=False, momentum_scheme='BDF2', continuity_scheme='BDF2', wrong_strain=False, pressure_factor=1, wrap_params_in_subexpressions=True, PFEM=False, stress_tensor=None, velocity_name='velocity', pressure_name='pressure', symmetric_test_function='auto', pressure_test_scaling_factor=1)[source]

Bases: StokesEquations

Represents the Navier-Stokes-Equations, defined by the second-order partial differential equations (PDEs):

\[\partial_t \rho + \nabla \cdot (\rho \vec{u}) = 0 \,\]
\[\rho (\partial_t \vec{u} + \vec{u} \cdot \nabla \vec{u} ) = \nabla \cdot [-\nabla p \vec{\vec{I}} + \mu (\nabla \vec{u} + (\nabla \vec{u})^\text{T})] + f \,\]

where \(p\) is the pressure, \(\vec{\vec{I}}\) is the identity matrix, \(\vec{u}\) the velocity, \(\mu\) the dynamic viscosity, \(\rho\) is the mass density and \(f\) the bulk force.

In the weak form, the equations are written as:

\[(\partial_t \rho, q) + (\rho \vec{u}, \nabla q) = 0\]
\[\rho (\partial_t \vec{u}, \vec{v}) + \rho (\vec{u} \cdot \nabla \vec{u}, \vec{v}) + (-p \vec{\vec{I}} + \mu [\nabla \vec{u} + (\nabla \vec{u})^\text{T}], \nabla \vec{v} + (\nabla \vec{v})^\text{T}) - (f,\vec{v})\]
\[- \langle \vec{n} \cdot [-p I + \mu (\nabla \vec{u} + (\nabla \vec{u})^\text{T})], \vec{v} \rangle = 0 \,\]

where \(\vec{v}\) and \(q\) are test functions of the velocity and pressure, respectively.

This class is a subclass of StokesEquations and inherits all its arguments.

Parameters:
  • dynamic_viscosity (ExpressionOrNum, optional) – Dynamic viscosity of the fluid (if fluid_props==None). Defaults to 1.0.

  • mode (Literal["TH","CR"], optional) – Use Taylor-Hood (“TH”) or Crouzeix-Raviart (“CR”) elements. Defaults to “TH”.

  • bulkforce (ExpressionNumOrNone, optional) – Bulk force term. Defaults to None.

  • fluid_props (Optional[AnyFluidProperties], optional) – Fluid properties. Defaults to None, meaning mass density and dynamic viscosity will be set by the “mass_density” and “dynamic_viscosity” arguments.

  • gravity (ExpressionNumOrNone, optional) – Gravity term in vector form. Defaults to None.

  • boussinesq (bool, optional) – Use Boussinesq approximation, i.e. use constant density in continuity equation. Defaults to False.

  • mass_density (ExpressionNumOrNone, optional) – Mass density of the fluid (if ‘fluid_props==None’). Only used for gravity and the continuity equation. Defaults to None.

  • pressure_sign_flip (bool, optional) – Reverse the pressure sign to get a symmetric matrix. Defaults to False.

  • momentum_scheme (TimeSteppingScheme, optional) – Time-stepping scheme for the momentum equation. Defaults to “BDF2”.

  • continuity_scheme (TimeSteppingScheme, optional) – Time-stepping scheme for the continuity equation. Defaults to “BDF2”.

  • wrong_strain (bool, optional) – Use mu*grad(u) instead of 2*mu*sym(grad(u)) for strain. Defaults to False.

  • pressure_factor (ExpressionOrNum, optional) – Multiplicative factor for the pressure in the momentum equation. Defaults to 1.

  • PFEM (Union[PFEMOptions,bool], optional) – Options for Particle Finite Element Method (PFEM). Defaults to False.

  • stress_tensor (ExpressionNumOrNone, optional) – Custom stress tensor. Defaults to None.

  • velocity_name (str, optional) – Name of the velocity field. Defaults to “velocity”.

  • pressure_name (str, optional) – Name of the pressure field. Defaults to “pressure”.

  • DG_alpha (ExpressionNumOrNone, optional) – If using Discontinuous Galerkin discretisation, set coefficient alpha for stress tensor. Defaults to None.

  • symmetric_test_function (Union[Literal['auto'],bool], optional) – Use symmetric test functions for the momentum equation. Defaults to ‘auto’.

  • dt_factor (ExpressionOrNum, optional) – Multiplicative factor to scale or deactivate the time derivative. Defaults to 1.

  • nonlinear_factor (ExpressionOrNum, optional) – Multiplicative factor to scale or deactivate the nonlinearity, i.e. dot(u,grad(u))). Defaults to 1.

  • wrap_params_in_subexpressions (bool, optional) – Wrap parameters in subexpressions using GiNaC. Defaults to True.

class pyoomph.equations.navier_stokes.NavierStokesFreeSurface(*, surface_tension=1, kinbc_name='_kin_bc', static_interface='auto', additional_normal_traction=0, mass_transfer_rate=0, impose_marangoni_directly=False, kinematic_bc_coordinate_sys=None, remove_redundant_kinematic_bcs=True)[source]

Bases: InterfaceEquations

Represents the free surface kinematic and dynamic boundary conditions for the Navier-Stokes equations, defined by the second-order partial differential equations (PDEs):

\[\vec{n} \cdot [-p \vec{\vec{I}} + \mu (\nabla \vec{u} + (\nabla \vec{u})^\text{T})] = -\sigma \kappa \vec{n} + \nabla_s \sigma\]

where \(p\) is the pressure, \(\vec{\vec{I}}\) is the identity matrix, \(\vec{u}\) the velocity, \(\mu\) the dynamic viscosity, \(\rho\) is the mass density, \(\sigma\) the surface tension, \(\kappa\) the curvature of the interface and \(\vec{n}\) the normal vector of the interface. The operator \(\nabla_s\) denotes the surface gradient, defined at the interface.

In the weak form, the equations are written as:

\[\langle \vec{n} \cdot [-p \vec{\vec{I}} + \mu (\nabla \vec{u} + (\nabla \vec{u})^\text{T})], \vec{v} \rangle = - \langle \sigma, \nabla_s \vec{v} \rangle + \Big[ \sigma \vec{N}, \vec{v} \Big] \,\]

where \(\vec{v}\) is a test function of the velocity and \(\vec{N}\) is the outwards normal vector of the interface’s bounds.

This class requires the parent equations to be of type StokesEquations.

Parameters:
  • surface_tension (ExpressionOrNum, optional) – Surface tension of the fluid. Defaults to 1.

  • kinbc_name (str, optional) – Name of the kinematic boundary condition field. Defaults to “_kin_bc”.

  • static_interface (Union[Literal["auto"],bool], optional) – If True, the mesh of the interface is static. Defaults to “auto”.

  • additional_normal_traction (ExpressionOrNum, optional) – Additional normal traction. Defaults to 0.

  • mass_transfer_rate (ExpressionOrNum, optional) – Mass transfer rate in case there is mass transfer across the interface. Defaults to 0.

  • impose_marangoni_directly (bool, optional) – If False, the weak form of grad_s(sigma) is integrated by parts. Defaults to False.

  • kinematic_bc_coordinate_sys (Optional[BaseCoordinateSystem], optional) – Coordinate system for the kinematic boundary condition. Defaults to None.

  • remove_redundant_kinematic_bcs (bool, optional) – If True, redundant kinematic boundary conditions are removed. Defaults to True.

required_parent_type

alias of StokesEquations

class pyoomph.equations.navier_stokes.NavierStokesPrescribedNormalVelocity(normal_velocity=0)[source]

Bases: InterfaceEquations

Prescribes the normal velocity at the interface between two domains. This is done by introducing a Lagrange multiplier for the normal velocity component and enforcing it in the weak sense. The normal no-penetration still needs to be ensured, e.g. by pinning or Lagrange multipliers on curved surfaces. Furthermore, it assumes zero velocity of the solid

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

Parameters:

normal_velocity (ExpressionOrNum) – Normal velocity to be imposed at the interface. Defaults to 0.

required_parent_type

alias of StokesEquations

class pyoomph.equations.navier_stokes.NavierStokesSlipLength(sliplength, surface_tension=None, tangential_wall_velocity=0)[source]

Bases: InterfaceEquations

Represents the Navier-Stokes slip length boundary condition for the Navier-Stokes equations, by setting the tangential velocity to a prescribed slip length. The normal no-penetration still needs to be ensured, e.g. by pinning or Lagrange multipliers on curved surfaces. Furthermore, it assumes zero velocity of the solid.

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

Parameters:
  • sliplength (ExpressionOrNum) – Slip length of the fluid.

  • surface_tension (ExpressionNumOrNone, optional) – Surface tension of the fluid. Defaults to None.

  • tangential_wall_velocity (ExpressionOrNum, optional) – Tangential velocity of the wall. Defaults to 0.

required_parent_type

alias of StokesEquations

class pyoomph.equations.navier_stokes.NoSlipBC(*args: Any, **kwargs: Any)[source]

Bases: DirichletBC

No-slip boundary condition for the Navier-Stokes equations. This is enforced by setting the degrees of freedom of the velocity field to zero at the specified boundary. It is a subclass of DirichletBC and inherits all its arguments.

Parameters:

velocity_name (str, optional) – Name of the velocity field. Defaults to “velocity”.

class pyoomph.equations.navier_stokes.StokesEquations(*, dynamic_viscosity=1.0, mode='TH', bulkforce=None, fluid_props=None, gravity=None, boussinesq=False, mass_density=None, pressure_sign_flip=False, momentum_scheme='BDF2', continuity_scheme='BDF2', wrong_strain=False, pressure_factor=1, PFEM=False, stress_tensor=None, velocity_name='velocity', pressure_name='pressure', DG_alpha=None, symmetric_test_function='auto', pressure_test_scaling_factor=1)[source]

Bases: Equations

Represents the Stokes equations, defined by the second-order partial differential equations (PDEs):

\[\partial_t \rho + \nabla \cdot (\rho \vec{u}) = 0\]
\[\nabla \cdot [-\nabla p \vec{\vec{I}} + \mu (\nabla \vec{u} + (\nabla \vec{u})^\text{T})] + f = 0 \,\]

where \(p\) is the pressure, \(\vec{\vec{I}}\) is the identity matrix, \(\vec{u}\) the velocity, \(\mu\) the dynamic viscosity, \(\rho\) is the mass density and \(f\) the bulk force.

In the weak form, the equations are written as:

\[(\partial_t \rho, q) + (\rho \vec{u}, \nabla q) = 0\]
\[- (-p \vec{\vec{I}} + \mu [\nabla \vec{u} + (\nabla \vec{u})^\text{T}], \nabla \vec{v} + (\nabla \vec{v})^\text{T}) + (f,\vec{v}) + \langle \vec{n} \cdot [-p I + \mu (\nabla \vec{u} + (\nabla \vec{u})^\text{T})], \vec{v} \rangle = 0 \,\]

where \(\vec{v}\) and \(q\) are test functions of the velocity and pressure, respectively.

Parameters:
  • dynamic_viscosity (ExpressionOrNum, optional) – Dynamic viscosity of the fluid (if fluid_props==None). Defaults to 1.0.

  • mode (Literal["TH","CR"], optional) – Use Taylor-Hood (“TH”) or Crouzeix-Raviart (“CR”) elements. Defaults to “TH”.

  • bulkforce (ExpressionNumOrNone, optional) – Bulk force term. Defaults to None.

  • fluid_props (Optional[AnyFluidProperties], optional) – Fluid properties. Defaults to None, meaning mass density and dynamic viscosity will be set by the “mass_density” and “dynamic_viscosity” arguments.

  • gravity (ExpressionNumOrNone, optional) – Gravity term in vector form. Defaults to None.

  • boussinesq (bool, optional) – Use Boussinesq approximation, i.e. use constant density in continuity equation. Defaults to False.

  • mass_density (ExpressionNumOrNone, optional) – Mass density of the fluid (if ‘fluid_props==None’). Only used for gravity and the continuity equation. Defaults to None.

  • pressure_sign_flip (bool, optional) – Reverse the pressure sign to get a symmetric matrix. Defaults to False.

  • momentum_scheme (TimeSteppingScheme, optional) – Time-stepping scheme for the momentum equation. Defaults to “BDF2”.

  • continuity_scheme (TimeSteppingScheme, optional) – Time-stepping scheme for the continuity equation. Defaults to “BDF2”.

  • wrong_strain (bool, optional) – Use mu*grad(u) instead of 2*mu*sym(grad(u)) for strain. Defaults to False.

  • pressure_factor (ExpressionOrNum, optional) – Multiplicative factor for the pressure in the momentum equation. Defaults to 1.

  • PFEM (Union[PFEMOptions,bool], optional) – Options for Particle Finite Element Method (PFEM). Defaults to False.

  • stress_tensor (ExpressionNumOrNone, optional) – Custom stress tensor. Defaults to None.

  • velocity_name (str, optional) – Name of the velocity field. Defaults to “velocity”.

  • pressure_name (str, optional) – Name of the pressure field. Defaults to “pressure”.

  • DG_alpha (ExpressionNumOrNone, optional) – If using Discontinuous Galerkin discretisation, set penalty coefficient alpha for jump terms of the stress tensor. Defaults to None.

  • symmetric_test_function (Union[Literal['auto'],bool], optional) – Use symmetric test functions for the momentum equation. Defaults to ‘auto’.

  • pressure_test_scaling_factor (float, optional) – Multiplicative scaling factor for the pressure test function. Defaults to 1.0.

with_pressure_fixation(*, nondim_p_value=None)[source]

Instead of adding StokesEquation, add StokesEquation.with_pressure_fixation(...) to remove the pressure nullspace in case of pure Dirichlet boundary conditions for the normal flow. With this method, a single pressure dof is pinned to remove the nullspace.

Parameters:
  • problem – The problem where the equations are added.

  • integral_value – The integral value of the pressure over the domain.

  • ode_domain_name – Domain name for the Lagrange multiplier enforcing the pressure integral. Defaults to “globals”.

  • lagrange_name – Name of the global Lagrange multiplier. Defaults to “lagr_intconstr_pressure”.

  • set_zero_on_normal_mode_eigensolve – Deactivate when solving angular eigenvalue problems. Defaults to True.

Return type:

Equations

Returns:

The (Navier-)Stokes equations with the pressure integral constraint.

with_pressure_integral_constraint(problem, integral_value=0, *, ode_domain_name='globals', lagrange_name='lagr_intconstr_pressure', set_zero_on_normal_mode_eigensolve=True)[source]

Instead of adding StokesEquation, add StokesEquation.with_pressure_integral_constraint(...) to remove the pressure nullspace in case of pure Dirichlet boundary conditions for the normal flow. With this method, the integral of the pressure is constrained to a given value via a global Lagrange multiplier.

Parameters:
  • problem (Problem) – The problem where the equations are added.

  • integral_value (Union[Expression, int, float]) – The integral value of the pressure over the domain.

  • ode_domain_name (str) – Domain name for the Lagrange multiplier enforcing the pressure integral. Defaults to “globals”.

  • lagrange_name (str) – Name of the global Lagrange multiplier. Defaults to “lagr_intconstr_pressure”.

  • set_zero_on_normal_mode_eigensolve (bool) – Deactivate when solving angular eigenvalue problems. Defaults to True.

Return type:

Equations

Returns:

The (Navier-)Stokes equations with the pressure integral constraint.

class pyoomph.equations.navier_stokes.StokesFlowRadialFarField(infinity_pressure=0)[source]

Bases: InterfaceEquations

Enforces a far-field condition for a radialsymmetric inward or outward flow.

Parameters:

infinity_pressure (ExpressionOrNum) – Pressure at infinity. Defaults to 0.

required_parent_type

alias of StokesEquations