Example #1
0
import joommfutil.typesystem as ts
from .energyterm import EnergyTerm


@ts.typesystem(K1=ts.Scalar,
               K2=ts.Scalar,
               u=ts.Vector(size=3),
               name=ts.Name(const=True))
class UniaxialAnisotropy(EnergyTerm):
    def __init__(self, K1, u, K2=0, name='uniaxialanisotropy'):
        """Uniaxial anisotropy energy abstract class.

        Parameters
        ----------
        K1, K2 : Real
            Uniaxial anisotropy energy constant (J/m**3)
        u : (3,) array_like
            Uniaxial anisotropy axis

        Examples
        --------
        Creating a uniaxial anisotropy object

        >>> import micromagneticmodel as mm
        >>> ua = mm.UniaxialAnisotropy(K1=5e6, K2=1e3, u=(0, 0, 1))

        """
        self.K1 = K1
        self.K2 = K2
        self.u = u
        self.name = name
import joommfutil.typesystem as ts
from .energyterm import EnergyTerm


@ts.typesystem(K1=ts.Scalar,
               u1=ts.Vector(size=3),
               u2=ts.Vector(size=3),
               name=ts.Name(const=True))
class CubicAnisotropy(EnergyTerm):
    def __init__(self, K1, u1, u2, name='cubicanisotropy'):
        """Cubic anisotropy energy abstract class.

        Parameters
        ----------
        K1 : Real
            Cubic anisotropy energy constant (J/m**3)
        u1, u2 : (3,) array_like
            Cubic anisotropy axes

        """
        self.K1 = K1
        self.u1 = u1
        self.u2 = u2
        self.name = name

    @property
    def _latex(self):
        a1 = r'(\mathbf{m} \cdot \mathbf{u}_{1})^{2}'
        a2 = r'(\mathbf{m} \cdot \mathbf{u}_{2})^{2}'
        a3 = r'(\mathbf{m} \cdot \mathbf{u}_{3})^{2}'
        return r'$-K_{{1}} [{0}{1}+{1}{2}+{2}{0}]$'.format(a1, a2, a3)
Example #3
0
import joommfutil.typesystem as ts
from .energyterm import EnergyTerm


@ts.typesystem(H=ts.Vector(size=3), name=ts.Name(const=True))
class Zeeman(EnergyTerm):
    _latex = r'$-\mu_{0}M_\text{s} \mathbf{m} \cdot \mathbf{H}$'

    def __init__(self, H, name='zeeman'):
        """A Zeeman energy class.

        This method internally calls set_H method. Refer to its documentation.

        """
        self.H = H
        self.name = name

    @property
    def _repr(self):
        """A representation string property.

        Returns:
           A representation string.

        """
        return 'Zeeman(H={}, name=\'{}\')'.format(self.H, self.name)
Example #4
0
import joommfutil.typesystem as ts
from .dynamicsterm import DynamicsTerm


@ts.typesystem(u=ts.Vector(size=3), beta=ts.Scalar, name=ts.Name(const=True))
class STT(DynamicsTerm):
    _latex = (r'$-(\mathbf{u} \cdot \boldsymbol\nabla)\mathbf{m} + '
              r'\beta\mathbf{m} \times \big[(\mathbf{u} \cdot '
              r'\boldsymbol\nabla)\mathbf{m}\big]$')

    def __init__(self, u, beta, name='stt'):
        """A spin transfer torque term.

        Args:
            u (RealVector): velocity vector
            beta (Real): non-adiabatic parameter

        """
        self.u = u
        self.beta = beta
        self.name = name

    @property
    def _repr(self):
        """A representation string property.

        Returns:
           A representation string.

        """
        return ('STT(u={}, beta={}, '
Example #5
0
import random
import itertools
import numpy as np
import matplotlib.pyplot as plt
import joommfutil.typesystem as ts
import discretisedfield.util as dfu
from mpl_toolkits.mplot3d import Axes3D


@ts.typesystem(p1=ts.Vector(size=3, const=True),
               p2=ts.Vector(size=3, const=True),
               cell=ts.Vector(size=3, positive=True, const=True),
               pbc=ts.Subset(sample_set="xyz"),
               name=ts.Name(const=True))
class Mesh:
    """Finite difference rectangular mesh.

    The rectangular mesh domain spans between two points `p1` and
    `p2`. They are defined as ``array_like`` objects of length 3
    (e.g. ``tuple``, ``list``, ``numpy.ndarray``), :math:`p = (p_{x},
    p_{y}, p_{z})`. The domain is then discretised into finite
    difference cells, where dimensions of a single cell are defined
    with a `cell` parameter. Similar to `p1` and `p2`, `cell`
    parameter is an ``array_like`` object :math:`(d_{x}, d_{y},
    d_{z})` of length 3. The parameter `name` is optional and defaults
    to "mesh".

    In order to properly define a mesh, the length of all mesh domain
    edges must be positive, and the mesh domain must be an aggregate
    of discretisation cells.