feeLLGood – Python modules
There are a few Python modules distributed with feeLLGood. They are located in the python-modules directory of the source distribution. The command make install installs them in
/usr/local/lib/python3.X/Y-packages/feellgood/
where 3.X is the version number of your Python interpreter, and Y-packages is either dist-packages or site-packages, depending or your Linux flavor. This is most likely already within your sys.path, and you can import those modules simply with:
from feellgood import module_name
settingsMaker.py: generate a JSON input file
This script provides a class called Settings. The constructor takes a single argument: the mesh file name. It will create an object than contains all the parameters the feellgood executable needs for running your simulation. Technically, it is a dictionnary with some (key,value) pairs mandatory, and others optional. Here is a table of the different keys.
| key | Mandatory/Optional |
|---|---|
"outputs" |
mandatory, and all the inner keys too |
"recentering" |
optional |
"mesh" |
mandatory |
"initial magnetization" |
mandatory, with some math expressions or a .sol file name |
"Bext" |
mandatory, if no field set all components to zero |
"spin_polarized_current" |
optional |
"finite_element_solver" |
mandatory |
"demagnetizing_field_solver" |
mandatory |
"time_integration" |
mandatory |
In order to create a new volume region, use the method createVolRegion. The only parameter is the volume name corresponding to your mesh.
To create a new surface region, use the method createSurfRegion. The only parameter is the surface name corresponding to your mesh.
You may also access any of the keys of the settings dictionary directly in your script.
Once you have filled all you need to give to feellgood, the JSON file can be generated with the write method. Its only parameter is the file name of your JSON parameters file.
meshMaker.py: generate various simple meshes using GMSH
This is a collection of classes for generating simple meshes in GMSH format. In order to illustrate various ways of building a mesh, some meshes are built directly, while others use either the Geo engine or the Open Cascade engine from the GMSH Python module.
class Ico: generate a mesh of an icosahedron
This class generates a mesh of an icosahedron. This mesh is very simple, only containing 20 tetrahedrons, generated from the faces to the center at \((0,0,0)\). It may be useful for some tests. The constructor has no parameter. The method make, which writes the mesh file, accepts 3 parameters: the file name, the volume region name and the surface region name. The output mesh file is written in the 2.2 text file format.
class Cuboid: generate a mesh of a cuboid
This class generates a mesh of a cuboid. This mesh is built by uniformly splitting the cuboid into smaller cuboids, then splitting each of those cuboids into two triangular prisms, and then splitting each prism into three tetrahedrons. The constructor accepts 5 parameters: the first two parameters are 3D points giving the corners (xmin, ymin, zmin) and (xmax, ymax, zmax), and then come 3 integers: the number of points along each dimensions.
The method make writes the mesh file. It takes 3 parameters: the file name, the volume region name and the surface region name. The output mesh file is written in the 2.2 text file format.
class Cylinder: generate a mesh of a cylinder
This class generates a mesh of a cylinder. This mesh is built using the GMSH Python API with the Geo engine. The constructor needs 5 parameters: radius, thickness (length along (0z)), mesh_size, surfName (the surface region name) and volName (the volume region name). Then come two optional parameters: partitionSurface and fileFormat.
partitionSurface is a boolean. If set to true, it will split the outer surface of the Cylinder into three different surfaces: top and bottom disks, and the lateral surface, constituting a partition. Their names are generated using the surfName parameter, concatenated with either "_side", "_bottom" or "_top".
fileFormat is a number defining the output file format: either 2.2 or 4.1 (the default).
The method make writes the output mesh file. It takes 1 parameter: the file name.
Example (assuming the Python module meshMaker is installed):
from feellgood.meshMaker import Cylinder
r = 20
l = 100
meshSize = 4
meshFileName = "cylWithPartionSurf.msh"
volRegionName = "bulk"
surfRegionName = "surf"
c = Cylinder(r,l,meshSize,surfRegionName,volRegionName,partitionSurface=True)
c.make(meshFileName)
This creates a mesh file named cylWithPartitionSurf.msh in GMSH text format 4.1, containing a volume region named "bulk", and three surface regions named "surf_side", "surf_bottom" and "surf_top".
class Tube: generate a mesh of a tube
This class generates a mesh of a hollow tube. This mesh is built using the GMSH Python API with the Geo engine. The constructor needs 6 parameters: radius1 (inner radius), radius2 (outer radius), length (along (0z)), mesh_size, surfName (the surface region name) and volName (the volume region name). Then come two optional parameters: partitionSurface and fileFormat.
partitionSurface is a boolean, if set to true, it will split the outer surface of the Cylinder into four different surfaces: top and bottom disks, and the inner and outer cylindrical surfaces, constituting a partition. Their names are generated using the surfName parameter, concatenated with either "_inner", "_outer", "_bottom" or "_top".
fileFormat is a number defining the output file format, either 2.2 or 4.1 (the default).
The method make writes the mesh file. It takes 1 parameter: the file name.
class Ellipsoid: generate a mesh of an ellipsoid
This class generates a mesh of an ellipsoid. This mesh is built using the GMSH python API with Open Cascade engine. The constructor needs 5 parameters: r1 (radius in the (Oxy) plane), r2 (radius along (0z)), mesh_size, surfName (the surface region name) and volName (the volume region name). Then comes an optional parameter: fileFormat.
fileFormat is a number defining the output file format: either 2.2 or 4.1 (the default).
The method make writes the mesh file. It takes 1 parameter: the file name.