#!/usr/bin/env python # coding: utf-8 # # Term parameters # # Every energy terms requires one or more input parameters for its definition. For example, (second order) uniaxial anisotropy energy requires the anisotropy constant $K$ and the anisotropy axis $\mathbf{u}$. There are three ways how these parameters can be defined: # # ## 1. Constant parameters # # If the energy parameters do not vary in space, they can be defined using constant values. # In[1]: K = 1e5 u = (0, 0, 1) # ## 2. Parameters defined "per region" # # If different regions have different values of parameters, they can be defined "per region". Let us say there are two regions: "region1" and "region2". In "region1", the anisotropy constant is $5\times10^{5} \text{J}/\text{m}^{3}$ and the anisotropy axis is $(1, 0, 0)$. On the other hand, in "region2", these parameters are $3\times10^{5} \text{J}/\text{m}^{3}$ and $(0, 0, 1)$. These two parameters can then be defined using a dictionary: # In[2]: K = {"region1": 5e5, "region2": 3e5} u = {"region1": (1, 0, 0), "region2": (0, 0, 1)} # Certain energy terms also require the parameters to be defined between regions. This can be defined by adding an additional item to the dictionary with colon (`:`) in the key. For example, an exchange energy parameter can be: # In[3]: A = {"region1": 1e-12, "region2": 2e-12, "region1:region2": 1e-11} # ## 3. Parameters defined using `discretisedfield.Field` object # # If it is not possible to define the energy parameter using a dictionary because ot varies in space in a non-trivial manner, a parameter can be defined using a field object. For instance: # In[4]: import discretisedfield as df p1 = (0, 0, 0) p2 = (50e-9, 50e-9, 50e-9) cell = (2e-9, 2e-9, 2e-9) mesh = df.Mesh(p1=p1, p2=p2, cell=cell) K = df.Field(mesh, nvdim=1) u = df.Field(mesh, nvdim=3) # The values of these two (scalar and vector) fields can be then set using Python functions. For further details, plese refer to `discretisedfield` [documentation](https://discretisedfield.readthedocs.io/en/latest/).