Development migrated to Femeko.jl
All future updates will only be available at codeberg.
Using Gmsh, Femeko simplifies the model creation and mesh generation, and provides the relevant data in a digested and simple structure.
Here is an example of how easy it is to create a model and mesh to simulate a magnet in free space with Femeko:
cells = [] # Holds each entity (dim, tag) property
addRectangle([0.0, 0.0], [2.0, 1.0], cells) # 2 by 1 magnet
ID = addDisk([0.0, 0.0], 10.0) # Disk of radius 10 with tag 'ID'
unifyModel(cells, ID) # Combine the geometries to create a conforming mesh
mesh = Mesh2D(cells, 2.0, 0.1) # Create a mesh with maximum element size 2.0
# and with local 0.1 size mesh refinement on the magnet's boundary
# or import your own model with
importCAD("STEP_Models/Fennec_Fox.step")Then, you can access the 3 nodes of the first element by nodes = mesh.t[:, 1], and the x,y coordinates of each node of that element with xy = mesh.p[:, nodes]. You also have access to the boundary elements and their respective boundary ID with mesh.surfaceT[:, elementTag], this would output the 2 nodes + boundary ID (in 2D) or 3 nodes + boundary ID (in 3D).
- Magnetostatics (non-linear magnetic materials under applied fields, permanent magnets, etc)
- Heat equation (with implicit time stepping)
- Viscous fluid (incompressible, static)
- Heat transfer with convection to a passing fluid (2D)
- Micromagnetics (both in time and steepest descent energy minimization)
Femeko has implementations for both 3D and 2D in most physics packages.
- Full 3D Heat equation (with convection to a passing fluid)
- Elastostatics (stress)
Each physics package has its own folder: Magnetostatics, Micromagnetics, Heat and Fluids.
Example from Magnetostatics, the internal magnetic field of a plate aligned with the applied field.
Most implementations in Femeko have both a 2D and 3D version. Here is a snapshot of the 2D heat simulation
Femeko.jl can incorporate quadratic order elements, solving the stokes equation of a viscus fluid for both pressure and velocity.
The Micromagnetics package has two distinct functionalities, based on the Landau-Lifshitz equation: the magnetization over time of the system; and an energy minimization by the steepest descent algorithm. The solver incorporates an external magnetic field, the demagnetizing field, the exchange field and the anisotropy field. This solver was validated against OOMMF, replicating Fig 2. of this article https://doi.org/10.1109/TMAG.2008.2001666 .
Main install:
- Open the Repl
- Press ']' key to switch to the package manager "pkg >"
add Gmsh LinearAlgebra SparseArrays IterativeSolvers Dierckx DelimitedFiles
Most examples plot the results using Makie.jl. It is recommended that you do
add GLMakieor/andadd CairoMakie
Compiling C++ alternative implementations:
- First update your clone of the repository to include eigen by going to the terminal and run
git submodule update --init --recursivewhile in the Femeko.jl folder - Move to the
cFemeko/Magnetostatics/folder and compilemagnetostatics.cppwithg++ -O3 -fPIC -shared -o magnetostatics.so magnetostatics.cpp - Adding this flag is recommended:
-fopenmp
Femeko has two types of C++ implementations. A full 100% rewrite to C++ and a mix between Julia and C++ with Julia's ccall().
The mixed language use has:
- Magnetostatics has a complete C++ alternative available.
- Micromagnetics has a full implementation with FEM and an older implementation with FEM-BEM.
The 100% rewrite has:
- Magnetostatics
Femeko is organized as:
| Directory | Contents |
|---|---|
src/ |
source code to handle the geometry, mesh, and FEM functionality |
Fluids/ |
Fluid simulation implementation |
Heat/ |
Heat simulation implementation |
Magnetostatics/ |
Magnetostatics simulation implementation |
Micromagnetics/ |
Micromagnetics simulation implementation |
STEP_Models/ |
Example .STEP files to import 3D models |
cFemeko/ |
Combined use of C++ and Julia |
Femeko.cpp/ |
100% rewrite to C++ |
extern/ |
external libraries needed for C++ implementations |
Distributed under the MIT License. See LICENSE for more information.