feeLLGood – finite element LLG object oriented development

feeLLGood – Example scripts

To illustrate how to perform some simulations, some Python examples are provided in the directory examples. Any of them can be used by typing in a terminal:

python3 exampleX.py

FeeLLGood settings are defined in a YAML or JSON file. It can be built using a Python script, that build a Python dictionary and write it as a JSON file. If the user is not familiar to dictionary in Python, see there. The user only needs to import the class Settings from the file settingsMaker.py, and create his own settings dictionary, as shown in the following examples.

example0.py

This Python script is illustrating how to generate a JSON input file for FeeLLGood executable, define an applied field value, fix the output columns in the .evol output text file to monitor some values of your simulation, and launch the simulation.

from settingsMaker import Settings
mySettings = Settings("ellipsoid.msh")
mySettings.createVolRegion( "ellipsoid_volume" )
mySettings.createSurfRegion( "ellipsoid_surface" )

mySettings["Bext"] = [0.01, 0.0, 0.0]
mySettings["outputs"]["evol_columns"] = ["t","<Mx>","<My>","<Mz>","E_tot"]

mySettings.write('mySettings.json')
os.system("../feellgood mySettings.json")

The class Settings imported from settingsMaker.py provides an easy way to generate JSON input file parameters. The only argument of the constructor is the name of the mesh file. Here it is an ellipsoid of revolution around \((Oz)\).

The output file .evol will contain 5 columns corresponding to the keywords in the table mySettings["outputs"]["evol columns"] Check the user documentation to see all the possible keywords.

example1.py

This Python script is a very simple example to illustrate how to run feellgood executable for three different values of the applied field, with adequate output directories name for each field value.

from settingsMaker import Settings
mySettings = Settings("ellipsoid.msh")
mySettings.createVolRegion( "ellipsoid_volume" )
mySettings.createSurfRegion( "ellipsoid_surface" )

then accessing any key within the Settings dictionary is done the usual way:

mySettings["Bext"] = [0.01, 0.02, 0.04]

Nota Bene: Each component of the applied field will be converted to a string, it is processed by the Duktape JavaScript interpreter. The user may define a time dependent expression, see example2.py.

Since Settings is a nested structure, accessing the output directory is simply done this way:

mySettings["outputs"]["directory"] = myDir

You have to write in a JSON file your mySettings dictionary, calling the write method:

mySettings.write('mySettings.json')

and finally call the feellgood executable:

os.system("../feellgood mySettings.json")

Note that here it is the local executable feellgood that is called, not the installed one if any, since installing it is optional.

example2.py

Example of a ferromagnetic resonance simulation, using time dependent analytical expression. The time dependent applied field may destabilize the feellgood time integration scheme, the timing parameters are difficult to tune.

example3.py

Example of a simulation using a very simple mesh of an icosahedron. This mesh is generated using the meshMaker.py Python script, see tools section for more information.

example4.py

Example of a simulation using a mesh of a flat cuboid with cubic anisotropy. The mesh is generated using the meshMaker.py Python script, see tools section for more information.

example5.py

Example of a simulation of a cylinder sample subject to spin-transfer torque. The mesh is generated using the meshMaker.py Python script. This script is using the python gmsh API to build the mesh, with the geo engine. The parameters of the simulation are not written to disk: they are defined in a Python dictionary and provided to feeLLGood on its standard input, in JSON format. A preliminary calculation is performed to find the electrostatic potential on the nodes of the mesh. It is done once at the beginning of the simulation. This electrostatic side problem requires to define some Dirichlet boundary conditions: fixed potential values on two surfaces (or more) of the mesh. Then, at each time step of the micromagnetic simulation, a spin transfer torque contribution with Thiaville formulation is added to the LLG equation.

example6.sh

This shell script is a ferromagnetic resonance simulation, somewhat similar to example2.py. It shows how a bash script can be used to:

At the end of the simulation a figure similar to the one below is displayed:

Ferromagnetic resonance: frequency scan