SkillAgentSearch skills...

PyEFVLib

A library used to solve physical problems governed by partial differential equations, in particular conservation equations using the Element-based Finite Volume Method.

Install / Use

/learn @GustavoExel/PyEFVLib
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

PyEFVLib

PyEFVLib is a Python library that provides tools to support the solution of systems of partial differential equations (PDEs) using the Element-based Finite Volumes Method (EbFVM)

Summary

  1. Installation
  2. Numerical Method
  3. PyEFVLib Classes - Geometrical Entities
  4. PyEFVLib Classes - Non-Geometrical Entities
  5. Tutorial
  6. 3rd-party Softwares
  7. 2D vs 3D considerations
  8. bellbird

1. Installation

Install PyEFVLib using pip, by typing in the command line:

pip install PyEFVLib

2. Numerical Method

2.1 - Partial Differential Equations

  • A differential equation is an equation that relates one or more functions and their derivatives.
  • A partial differential equation (PDE) is an equation that relates one or more functions dependent on two or more variables, to the partial derivatives of these functions in relation to the independent variables.
  • In physics, differential equations relate physical properties (e.g., pressure, temperature, displacement, turbulent kinetic energy, speed) to their spatial and temporal derivatives, and model natural and everyday phenomena.

2.2 - Example: Integrating a PDE in space

control_volume

Take the heat equation as an example

eq1

Integrating in the control volume (CV)

eq2

And applying the divergence theorem

eq3

eq4

eq5


2.3 - Domain Discretization

mesh discretization

Previously it was shown that a differential equation in the differential form can be integrated in any control volume, but to achieve a detailed solution along the domain of interest, the finite volume method discretizes the domain in several control volumes forming a mesh. The more refined the mesh, the better the solution to the problem will be.

Note: The black bordered triangles shown in the figure are actually the elements, the control volumes are outlined by the blue lines.


2.4 - Field Approximations

As it is the nature of PDEs, the equations involve spatial derivatives, but since we are storing a finite number of variables, we need a way to approximate the field continuously to evaluate the spatial derivatives, and the EbFVM does this using the shape functions.

We'll start by evaluating the field within an element of our mesh. It'll be expressed by a linear combination of the property values at the vertices of the element, and the weight of the property at each vertex is given by the shape functions at each point inside the element, as in the figure below:

shape functions

And as we know the entire field inside the element, we can evaluate its partial derivatives, as shown below:

eq4


2.5 - Problem Solution

Previously, the differential equations expressed the values of the unknowns as a function of their partial derivatives, but as we can express the partial derivatives as a function of the values of the field at the neighboring vertices, so the solution of the problem becomes a system of algebraic equations.

eq6

And in the case of a linear system of equations

eq6


3. PyEFVLib Classes - Geometrical Entities

3.1 - Grid

| Attribute | Description | | :-------------- | :---------------------------------------------------- | | vertices | a list of the grid's vertices | | elements | a list of the grid's elements | | regions | a list of the grid's regions | | boundaries | a list of the grid's boundaries | | dimension | the dimension of the mesh (2 or 3) | | gridData | a data structure that holds the information provided by mesh file |


3.2 - Vertex

| Attribute | Description | | :------------ | :------------------------------------------------------------- | | x | vertex x coordinate | | y | vertex y coordinate | | z | vertex z coordinate | | handle | the vertex index in the grid | | elements | a list of all elements to which vertex belongs | | volume | the volume of the control volume at which vertex is centered | | coordinates | a numpy array with the vertex coordinates |

| Method | Parameters | Return type | Description | | :---------------------- | :-------------------- | :----------------- | :-------------------------------------------------------------------------------- | | getLocal | element | int | returns the local index of the vertex within the element | | getInnerFaces | | list[InnerFace] | returns the innerFaces next to vertex | | getSubElementVolume | element | float | returns the volume of the section of element that is inside vertex control volume |

Vertex is a child class of the class Point

It is possible to do operations like vertex1 + vertex2, a * vertex, ...


3.3 - Region

Region is a class used to perform simulations where there are multiple regions with different properties, so the properties are specific to each region. If the domain is homogeneous (has constant properties) one single region will be created containing all the elements. The region names are set in the mesh file.

region

| Attribute | Description | | :---------------- | :------------------------------------- | | name | the name of the region | | handle | the region index in the grid | |

Related Skills

View on GitHub
GitHub Stars7
CategoryDevelopment
Updated4mo ago
Forks7

Languages

Python

Security Score

87/100

Audited on Nov 25, 2025

No findings