World¶
In this section the world representation for simulation setups is described.
Simple world creation that is filled entirely with one material example:
# Create a world that is entirely filled with Permalloy.
# First, create a mesh to spatially discretize the world
mesh = RectangularMesh((100,100,1), (4e-9, 4e-9, 10e-9))
# Second, create the world from the mesh and the material
(in this case permalloy)
world = World(mesh, Material.Py())
More complex worlds can contain different sub-regions (“bodies”) that are each associated with an ID, a geometry (a Shape) and a material:
# Create a world that is composed of "Bodies"
mesh = RectangularMesh((100,100,1), (4e-9, 4e-9, 10e-9))
world = World(
mesh,
Body("the_body_id", Material.Py(), Cuboid((25e-9, 25e-9, 0e-9),
(75e-9, 75e-9, 10e-9)))
# (optionally more bodies, separated by commas)
)
World¶
The world class.
- class magnum.World(mesh, *args)¶
Creates a world that is spatially discretized with the specified mesh. The constructor takes additional arguments that specifiy the contents of the world, i.e. subregions of the world that are associated with (possibly different) materials.
Simple world creation with just a material:
# Create a world that is entirely filled with Permalloy. mesh = RectangularMesh((100,100,1), (4e-9, 4e-9, 10e-9)) world = World(mesh, Material.Py())
World creation with different subregions (“bodies”) that are each associated with an ID, a Shape and a Material:
# Create a world that is composed of "Bodies" mesh = RectangularMesh((100,100,1), (4e-9, 4e-9, 10e-9)) world = World( mesh, Body("the_body_id", Material.Py(), Cuboid((25e-9, 25e-9, 0e-9), (75e-9, 75e-9, 10e-9))) # (optionally more bodies, separated by commas) )
- mesh¶
Read-only property that returns the mesh that is associated with this world.
print(world.mesh) # Retrieve the world's mesh.
- bodies¶
Read-only property that returns all bodies in the world.
print(world.bodies) # Retrieve a list of all world's bodies.
- findBody(body_id)¶
Return the body with the given id string. It is an error if the body does not exist.
body = world.findBody("the_body_id")
Bodies¶
The Body class.
Shapes¶
TODO The Shape class
- class magnum.Shape¶
The abstract Shape class defines a geometrical shape in 3-D space. Shapes are used to define regions in the simulated volume in order to set up spatially varying material parameters (see World and Body classes). The most important method is isPointInside, which has to be implemented by concrete subclasses.
There are predefinded shapes to use and change.
Complex shapes can be created from atomic shapes via set operations: union, intersect, invert. (see e.g. http://en.wikipedia.org/wiki/Constructive_solid_geometry )
- class magnum.ImageShape(isc, color)¶
This class can create a shape from an graphical image using a color mask. In order to use this class, the Python Imaging Library has to be installed (‘import Image’).
ImageShape objects are usually created by the pick method of an ImageShapeCreator object:
isc = ImageShapeCreator("image.png", mesh) # load the image, stretching it over the xy-axes of the mesh. shape = isc.pick("black") # create a shape (of type *ImageShape*) using a color as the mask. world = World(mesh, Body("image", Material.Py(), shape)) # use the shape...
You can use the following color strings: “black”, “green”, “blue”, “red”, “yellow”, “grey”, “white”, “cyan”, “magenta” or make up your own color by passing a tuple of RGB values instead, e.g. (128,128,128) means grey.
Every image format that is supported by the Python Image Library is accepted, although we suggest to use the PNG image format.
- class magnum.Cuboid(p1, p2)¶
A cuboid shape. It is defined by the coordinates of two (arbitrary) diagonally opposite cuboid vertices. The cuboid is always orthogonal to the coordinate axes.
- class magnum.Cylinder(p1, p2, r)¶
A cylindric shape. The cylinder is defined by two points and a radius.
- class magnum.Everywhere¶
This shape describes the whole simulation volume, i.e. isPointInside always returns true.
- class magnum.GmshShape(model, shift=(0.0, 0.0, 0.0), scale=1.0)¶
This class can create a shape from a number of gemetry/mesh files that are supported by Gmsh. The Python wrappers for Gmsh have to be installed on the system.
- static with_mesh_from_file(filename, cell_size, scale=1.0, lc=None, order=3)¶
Creates a shape from a Gmsh supported file format (e.g. brep, msh) along with a suitabe RectangularMesh to fit the shape in.
- Arguments
- filename (string)
- The geometry file to import
- cell_size ([float])
- Cell size of the target mesh to be created
- scale (float)
- Scaling of the input file
- lc (float)
- Discretization constant for geometry approximation. Don’t use this unless you know what you are doing.
- order (int)
- Order for geometry approximiation. Don’t use this unless you know what you are doing.
- Returns
- [Mesh, Shape]
- The mesh and the shape
Materials¶
Materials are used in connection with the Body class to initialize material parameters.
Material | Ms | A | K | anisotropy type |
---|---|---|---|---|
Permalloy | 800e3 | 13e-12 | 0 | uniaxial |
Iron | 1700e3 | 21e-12 | 48e3 | cubic |
Nickel | 490e3 | 9e-12 | -5.7e3 | cubic |
Cobalt(hcp) | 1400e3 | 30e-12 | 520e3 | uniaxial |
In the following the Material class which holds the material parameters for a material type is described.
- class magnum.Material(params)¶
- static Py(**params)¶
Additional keyword options are merged with the material parameters of the newly created instance. Return a material object for the material ‘Permalloy’.
- static Fe(**params)¶
Return a material object for the material ‘Iron’.
- static Co(**params)¶
Return a material object for the material ‘Cobalt’.
- static Ni(**params)¶
Return a material object for the material ‘Nickel’.
Examples:
# Create permalloy with default parameters
py = Material.Py()
# create own material
mat = Material({'id':'MyMaterial', 'Ms': 8e5, 'A':13e-12, 'alpha':0.01})