LESARD: Fluid models and Governing equations



The modules FluidModels and those stored in the ProblemDefinition/GoverningEquations folder take care of the fluids’ motion. Depending on the fluids’ nature (and thus parameters) and their selected equation of state (defined in the Problem’s module), they associate the right fluid’s properties with the selected governing equation to determine the fluid, time and space-dependent system’s flux.


Page navigation



Pre-defined equations and models


Pre-defined governing equations and fluid models can be found in ProblemDefinition/GoverningEquations/*.py and ProblemDefinition/FluidModels.py, respectively. Their respective documentation can be found according to the following table. Generic information for creating new ones are given below.

Predefined governing equations

Predefined fluid models


Note

Templates for creating new governing equations and fluid models can be found in Templates folder.





Governing equations


All the fluids present in the computational domain are governed by a same equation selected by the user through an index mapping to the module ProblemDefinition/GoverningEquations/$TheEquationSetName.py, named accordingly the considered equation’s set.


Any governing equation is defined as a module itself containing the classes:

  • Equations, specifying the fluid’s dynamic

  • EOS, giving the equation of state to use for each fluid, each selected by an index at the instance creation selecting the one to use according to the user’s wishes, among possibly several choices

  • InitialConditions, giving the initial conditions to use on each subdomain, each selected by an index at the instance creation selecting the one to use according to the user’s wishes, among possibly several choices

It also requires a specific fluid model to interface with the fluid’s properties (i.e. which properties of the fluid are involved in the equation). The fluid model to be used is specified directly within the governing equation’s module, by specifying the name of the model to use in the field FluidModel. At runtime, the fluid’s properties (selected from the evolving fluid’s location in the computational domain) will then be injected in the relevant fluid model and transfered to the governing equations.


A Equations class having the minimal required method and fields to be able to run all the numerical schemes has the following structure. Further routines and fields can be added depending on the internal needs.


class 3_LESARD.Templates.Template_Equations.Equations(FluidProp, EOs)

Class furnishing all the methods that are required to define numerical schemes and evolve the solution according to the Euler Equation


Fields

It contains the following initialisation parameters (later available as well as attributes)

  •   FluidProp (list of FluidModel) – the list of fluid property instances (NbFluids)

  •   EOS (list of callbacks) – the list of Equation of state functions (NbFluids)

It further contains the following attributes, filled upon initialisation

  •   NbVariables (integer) – number of variables of the model

  •   VariablesNames (list of strings) – ordered name of the variables

  •   VariablesUnits (list of strings) – symbols of the units of the variables

  •   VariablesLatexNames (list of strings) – ordered name of the variables, latex encoding

  •   VariablesLatexUnits (list of strings) – symbols of the units of the variables, latex encoding

  •   XYLatexUnits (list of strings) – units of the x-y coordinates in latex encoding

Parameters
  • FluidProp (list of FluidModel) – the list of fluid property instances (NbFluids)

  • EOS (list of callbacks) – the list of Equation of state functions (NbFluids)


Methods

ConservativeToPrimary(Var, FluidIndex, *args)

Converts the conservative variables to the primary ones

Parameters
  • Var (2D numpy array) – the variables of the problem (NbVars x NbGivenPoints)

  • FluidIndex (integer numpy array) – the fluid present at each given point (NbGivenPoints)

Returns

(NbVars x NbGivenPoints) the corresponding primary variables

Return type

Var (numpy array)

Note

  • *args is there only for compatibility reason at call time
PrimaryToConservative(PrimVar, FluidIndex, *args)

Converts the primary variables to the conservative ones

Parameters
  • Var (2D numpy array) – the primary variables of the problem (NbVars x NbGivenPoints)

  • FluidIndex (integer numpy array) – the fluid present at each given point (NbGivenPoints)

Returns

(NbVars x NbGivenPoints) the corresponding conservative variables

Return type

Var (numpy array)

Note

  • *args is there only for compatibility reason at call time
Flux(Var, *args)

Flux function of the (conservative) EulerEquations

Parameters

Var (float numpy array) – the value of the variables (NbVariables x NbGivenPoints)

Optional argument

  •   x (float numpy array), – (optional, not impacting here) x-y coordinates of the given points (NbGivenPoints x 2)

  •   FluidIndex (integer numpy array) – the fluid present at each given point (NbGivenPoints)

Returns

the obtained flux (spatialdim x NbVars x NbPoints)

Return type

Flux (3D numpy array)


Note

  • This function is Vectorised
  • Fluid index is the fluid index in the initially given list, not the fluid type
  • FluidProp is the list of all the fluid properties for each fluid (given the list, not the type)
  • *args is there only for compatibility reason at call time
GetUV(Var, *args)

Function giving back the x-y velocity at the considered point, given the variational values given for the the conservative Euler equation’s variables.

Parameters
  • Var (float numpy array) – the value of the variables (NbVariables x NbGivenPoints)

  • x (float numpy array) – (generally optional, required for this problem), x-y coordinates of the given points (NbGivenPoints x 2)

Optional argument

  •   FluidIndex (integer numpy array) – the fluid present at each given point (NbGivenPoints)

Returns

UV (float numpy array) – the velocities values at the points (2 x NbGivenPoints)

Note

  • This function is Vectorised
  • *args is there only for compatibility reason at call time
Jacobian(Var, x, *args)

Computes the Jacobian of the flux for the Euler equations

Parameters
  • Var (float numpy array) – the value of the variables (NbVariables x NbGivenPoints)

  • x (float numpy array) – (generally optional, required for this problem), x-y coordinates of the given points (NbGivenPoints x 2)

Optional argument

–   FluidIndex (integer numpy array) – the fluid present at each given point (NbGivenPoints)

Returns

J[:,:,i] gives the jacobian of the flux taking care of the dynamic of the ith spatial coordinate.

Return type

J (3D numpy array)


Note

  • For each flux fi = (fi1,…, fin), the returned Jacobian reads:
      J[:,:] = [dfi1/dx1, ….., dfi1/dxn
                ….
                df in/dx1, ….., dfin/dxn]
  • *args is there only for compatibility reason at call time
SpectralRadius(Var, FluidIndex, n, x, *args)

Computes the spectral radius associated to the flux.

Parameters
  • Var (2D numpy array) – the variables of the problem (NbVars x NbGivenPoints)

  • FluidIndex (integer numpy array) – the fluid present at each given point (NbGivenPoints)

  • n (2D numpy array) – the x-y values of the normal at each given point (NbGivenPoints x 2)

  • x (2D numpy array) – (generally optional, required for this problem) the x-y locations at which the variables are given (NbGivenPoints x 2)

Returns

the spectral radius computed at each given point

Return type

Lmb (numpy array)

Note

  • *args is there only for compatibility reason at call time
EigenValues(Var, FluidIndex, n, x, *args)

Computes the eigenvalues associated to the flux.

Parameters
  • Var (2D numpy array) – the variables of the problem (NbVars x NbGivenPoints)

  • FluidIndex (integer numpy array) – the fluid present at each given point (NbGivenPoints)

  • n (2D numpy array) – the x-y values of the normal at each given point (NbGivenPoints x 2)

  • x (2D numpy array) – (generally optional, required for this problem) the x-y locations at which the variables are given (NbGivenPoints x 2)

Returns

(NbGivenPoints x NbEigs) the eigenvalues at each given point

Return type

lbd (numpy array)

Note

  • *args is there only for compatibility reason at call time
RightEigenVectors(Var, FluidIndex, n, x, *args)

Computes the right eigenvectors associated to the eigenvalues.

Parameters
  • Var (2D numpy array) – the variables of the problem (NbVars x NbGivenPoints)

  • FluidIndex (integer numpy array) – the fluid present at each given point (NbGivenPoints)

  • n (2D numpy array) – the x-y values of the normal at each given point (NbGivenPoints x 2)

  • x (2D numpy array) – (generally optional, required for this problem) the x-y locations at which the variables are given (NbGivenPoints x 2)

Returns

(NbVars x MbVars x NbGivenPoints) the matrix of eigenvectors for each given point

Return type

reg (numpy array)

Note

  • *args is there only for compatibility reason at call time
LeftEigenVectors(Var, FluidIndex, n, x, *args)

Computes the left eigenvectors associated to the eigenvalues.

Parameters
  • Var (2D numpy array) – the variables of the problem (NbVars x NbGivenPoints)

  • FluidIndex (integer numpy array) – the fluid present at each given point (NbGivenPoints)

  • n (2D numpy array) – the x-y values of the normal at each given point (NbGivenPoints x 2)

  • x (2D numpy array) – (generally optional, required for this problem) the x-y locations at which the variables are given (NbGivenPoints x 2)

Returns

(NbVars x MbVars x NbGivenPoints) the matrix of eigenvectors for each given point

Return type

reg (numpy array)

Note

  • *args is there only for compatibility reason at call time


An EOS class having the minimal required fields to be able to ensure the compatibility with the fluid’s model and the governing equation has the following structure.


class 3_LESARD.Templates.Template_Equations.EOS(Id)

Class furnishing the methods giving the Equation of State that can be used in combination with the Chosen Fluid Model definition. Upon creation, fills the field EOS with the function callback corresponding to the wished initialisation function. The implemented EoS are linked as follows. See their respective documentation for more information.

  1. EOS definition Template
Parameters

Id (integer) – the index corresponding to the equation of fluid the user wants when considering the governing equations given in this module and the associated fluid.


Methods

EOSTemplate(Var, FluidProp, Type)

Equation of State for stiff fluids, giving back either the internal energy or pressure.

Parameters
  • Type (string) – desired output, e.g.: “e”: internal energy, “p”: pressure

  • Var (float numpy array) – the value of the variables (NbVariables x NbGivenPoints). If type “e”, the variables should be [rho, rhoU, rhoV, p].T. If type “p”, the variables should be [rho, rhoU, rhoV, E].

  • FluidProp (FluidModel list) – the list of the fluid properties associated to each given Point

Returns

the pressure values at the given points (NbGivenPoints)

Return type

ThewishedQuantity (float numpy array)



An InitialConditions class having the minimal required fields to be able to initialise the solution on every subdomain has the following structure .


class 3_LESARD.Templates.Template_Equations.InitialConditions(Id, *parameters)

Class furnishing the solution initialisation routines that are suitable to study the the Euler Equations, defined for working on a subdomain. Access the routine computing the initial conditions through the field IC, filled upon creation with the function callback corresponding to the index of the wished initialisation function. The implemented initialisation method are linked as follows. See their respective documentation for more information.

  1. ICTemplate
Parameters
  • Id (integer) – the index corresponding to the initialisation method the user wants when considering the governing equations given in this module.

  • params (list of arguments) – the (fixed) arguments to pass to the selected function


Methods

ICTemplate(PointsID, Mesh, EOS=[], FluidProp=[], subdomain=[], *argv)

Initialising the solution to a constant state that matches the SOD-inner value. (The given points should all belonging to a same subdomain).

Parameters
  • PointsID (integer array-like) – the index of the points to consider

  • Mesh (MeshStructure) – the considered mesh

  • EOS (function callback) – (optional), the equation of state given by the model of the fluid that is present at the given points

  • FluidProp (FluidSpecs) – (optional, not used here) the the properties of the fluid present where the given points are

  • Subdomain (shapely multipolyon) – (optional, not used here) the shapely polygon to which the given points belong

Returns

The initialised values at the considered points (NbVariables x NbGivenPoints)

Return type

Init (float numpy array)


Note

  • *args is here only for compatibility on call

  • There is usually one initialisation routine per subdomain, and the PointsID are not necessarily contigous, be careful when assigning the values back in the regular solution.

  • For running smothly the inner circle diameter of the given subdomain should be at least 2





Fluid’s models


The fluid models are defined as classes in a single module ProblemDefinition.FluidModels. Their fields extracts the relevant properties of given fluids to format them accordingly to the fluid model’s purpose (i.e. its use in one or several governing equations). Furthermore, each class should at least contain the field color, for identifying the fluid when plotting.


A typical fluid model’s class has the following structure (other can be added depending on the governing equations’ needs).


class 3_LESARD.Templates.Template_FluidModels.CustomModel(color, *args)

Custom model that can be used to test the any simple problems or debug problem that does not rely on any Fluid’s properties.


Class to copy within the file “FluidModels.py” located in the “SourceCode/ProblemDefinition” folder.


Note

  • This is only a product-type class: no method is available

  • At instance creation it takes as many input (whose values will be trashed) as wished for call time compatibility


Parameters
  • color (string or matplotlib color scheme) – the color of the fluid for plotting

  • others – other arguments compatible with the properties given through the Mappers.py file when defining a Fluid’s type (oil, water, etc)


Note

  • When designing a model that requires more properties than the other models already predefined, think to update the information given in the file SourceCode/Mappers.py accordingly, as it sets the actual fluid’s properties’ values for commonly used ones (oil, water, etc).

  • In the same vein, mind that the order of the arguments should match the ones prescribed in SourceCode/Mappers.py. Should you need different properties that the ones already given for the other models, you still have to specify them as arguments, up to dropping them later for the consistency of the parameters definition when creating a fluid in the file SourceCode/Mappers.py.