I’ve introduced an easy-to-use high-level interface for working with shapes and regions. There are a number of built-in elementary shapes (rectangle, disk, triangle, ellipsoid, torus, pyramid, tetrahedron, cone) which can be combined to form composite shapes. These shapes can then be used as 1) physical objects in meshes, 2) as masks to set magnetization directions, and 3) as regions to set material parameter values. The shapes also have transformation functions, including scaling, translation, rotation, array generation.

Shapes can be used directly with console commands, however the best way to use them is with the high-level Python interface now provided through the NetSocks.py module. Let’s have a look at some examples.

First let’s take a simple example with two objects: a torus and a disk.

from NetSocks import NSClient |

The Shape class contains all the elementary shapes, which can be combined using simple operators (+, -) into composite shapes. Once a shape is define it can be physically set in the mesh using theĀ **shape_set** function. The shapes can also be used as masks to set magnetization angle using theĀ **shape_setangle** function. The above example produces the following mesh structure and magnetization direction:

Finally the shapes can be used to define regions with different material parameters, set using the **shape_setparam** function.

#set material parameter values of regions defined by shapes |

If we look at the Ms material parameter spatial variation we have the following:

All material parameters in Boris may be assigned a spatial variation with the same resolution as the mesh discretization, and there are a number of built-in spatial variation generators as described in the manual. Internally this is handled efficiently (in terms of code reuse and maintainability, as well as execution time) using a variadic template function to check material parameters spatial, temporal, and temperature dependences.

Let’s have a look at a more advanced example. First let’s set a hollow half-torus, and set its left and right sides to different magnetization directions, using the following script:

from NetSocks import NSClient |

This produces the following:

Let’s take it a step further and introduce more shapes, also showing how rotations and array generation can be used:

#rectangular base |

This now produces the following:

Finally let’s relax the magnetization so it looks a bit more interesting (why not!):

This functionality will be available in v3.0, which I’m hoping to release this Friday.