Пример #1
0
import k3d
import random
import numpy as np
import matplotlib.pyplot as plt
import ubermagutil.units as uu
import ubermagutil.typesystem as ts
import discretisedfield.util as dfu


@ts.typesystem(p1=ts.Vector(size=3, const=True),
               p2=ts.Vector(size=3, const=True))
class Region:
    """A cuboid region.

    A cuboid region spans between two corner points :math:`\\mathbf{p}_{1}` and
    :math:`\\mathbf{p}_{2}`. Points ``p1`` and ``p2`` can be any two diagonally
    opposite points. If any of the edge lengths of the cuboid region is zero,
    ``ValueError`` is raised.

    Parameters
    ----------
    p1 / p2 : (3,) array_like

        Diagonnaly opposite corner points :math:`\\mathbf{p}_{i} = (p_{x},
        p_{y}, p_{z})`.

    Raises
    ------
    ValueError

        If any region's edge length is zero.
Пример #2
0
import k3d
import itertools
import ipywidgets
import collections
import numpy as np
import warnings
import discretisedfield as df
import ubermagutil.units as uu
import matplotlib.pyplot as plt
import ubermagutil.typesystem as ts
import discretisedfield.util as dfu
from mpl_toolkits.mplot3d import Axes3D


@ts.typesystem(region=ts.Typed(expected_type=df.Region),
               cell=ts.Vector(size=3, positive=True, const=True),
               n=ts.Vector(size=3,
                           component_type=int,
                           unsigned=True,
                           const=True),
               bc=ts.Typed(expected_type=str))
class Mesh:
    """Finite-difference mesh.

    Mesh discretises cubic ``discretisedfield.Region``, passed as ``region``,
    using a regular finite-difference mesh. Since cubic region spans between
    two points :math:`\\mathbf{p}_{1}` and :math:`\\mathbf{p}_{2}`, these
    points can be passed as ``p1`` and ``p2``, instead of passing
    ``discretisedfield.Region`` object. In this case
    ``discretisedfield.Region`` is created internally. Either ``region`` or
    ``p1`` and ``p2`` can be passed, not both. The region is discretised using
Пример #3
0
import ubermagutil as uu
import discretisedfield as df
import ubermagutil.typesystem as ts
from .dynamicsterm import DynamicsTerm


@uu.inherit_docs
@ts.typesystem(J=ts.Parameter(descriptor=ts.Scalar(), otherwise=df.Field),
               mp=ts.Parameter(descriptor=ts.Vector(size=3),
                               otherwise=df.Field),
               Lambda=ts.Parameter(descriptor=ts.Scalar(positive=True),
                                   otherwise=df.Field),
               P=ts.Parameter(descriptor=ts.Scalar(positive=True),
                              otherwise=df.Field),
               eps_prime=ts.Parameter(descriptor=ts.Scalar(),
                                      otherwise=df.Field))
class Slonczewski(DynamicsTerm):
    """Slonczewski spin transfer torque dynamics term.

    .. math::

        \\frac{\\text{d}\\mathbf{m}}{\\text{d}t} =
        \\gamma_{0}\\beta\\epsilon(\\mathbf{m} \\times \\mathbf{m}_\\text{p}
        \\times \\mathbf{m}) - \\gamma_{0}\\beta\\epsilon' (\\mathbf{m} \\times
        \\mathbf{m}_\\text{p})

    .. math::

        \\beta = \\left| \\frac{\\hbar}{\\mu_{0}e} \\right|
        \\frac{J}{tM_\\text{s}}
Пример #4
0
import random
import itertools
import numpy as np
import discretisedfield as df
import matplotlib.pyplot as plt
import ubermagutil.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),
               n=ts.Vector(size=3,
                           component_type=int,
                           unsigned=True,
                           const=True),
               pbc=ts.Subset(sample_set='xyz'),
               name=ts.Name(const=True))
class Mesh:
    """Finite difference mesh.

    A rectangular mesh domain spans between two points
    :math:`\\mathbf{p}_{1}` and :math:`\\mathbf{p}_{2}`. The domain is
    discretised using a finite difference cell, whose dimensions are
    defined with `cell`. Alternatively, the domain can be discretised
    by passing the number of discretisation cells `n` in all three
    dimensions. Either `cell` or `n` should be defined to discretise
    the domain, not both. Periodic boundary conditions can be
    specified by passing `pbc` argument, which is an iterable
    containing one or more elements from ``['x', 'y', 'z']``. The
Пример #5
0
import ubermagutil as uu
import discretisedfield as df
import ubermagutil.typesystem as ts
from .energyterm import EnergyTerm


@uu.inherit_docs
@ts.typesystem(H=ts.Parameter(descriptor=ts.Vector(size=3),
                              otherwise=df.Field),
               wave=ts.Subset(sample_set={'sin', 'sinc'}, unpack=False),
               f=ts.Scalar(positive=True),
               t0=ts.Scalar())
class Zeeman(EnergyTerm):
    """Zeeman energy term.

    .. math::

        w = -\\mu_{0}M_\\text{s} \\mathbf{m} \\cdot \\mathbf{H}

    Zeeman energy term allows defining time-dependent as well as
    time-independent external magnetic field. If only external magnetic field
    ``H`` is passed, a time-constant field is defined. On the other hand, in
    order to define a time-dependent field, ``wave`` must be passed as a
    string. ``wave`` can be either ``'sine'`` or ``'sinc'``. If time-dependent
    external magnetic field is defined, apart from ``wave``, ``f`` and ``t0``
    must be passed. For ``wave='sine'``, energy density is:

    .. math::

        w = -\\mu_{0}M_\\text{s} \\mathbf{m} \\cdot \\mathbf{H} \\sin[2\\pi
        f(t-t_{0})]
import ubermagutil as uu
import discretisedfield as df
import ubermagutil.typesystem as ts
from .energyterm import EnergyTerm


@uu.inherit_docs
@ts.typesystem(B1=ts.Parameter(descriptor=ts.Scalar(), otherwise=df.Field),
               B2=ts.Parameter(descriptor=ts.Scalar(), otherwise=df.Field),
               e_diag=ts.Parameter(descriptor=ts.Vector(size=3),
                                   otherwise=df.Field),
               e_offdiag=ts.Parameter(descriptor=ts.Vector(size=3),
                                      otherwise=df.Field))
class MagnetoElastic(EnergyTerm):
    """Magneto-elastic energy term.

    .. math::

        w = B_{1}\\sum_{i} m_{i}\\epsilon_{ii} + B_{2}\\sum_{i}\\sum_{j\\ne i}
        m_{i}m_{j}\\epsilon_{ij}

    Parameters
    ----------
    B1/B2 : numbers.Real, dict, discretisedfield.Field

        If a single value ``numbers.Real`` is passed, a spatially constant
        parameter is defined. For a spatially varying parameter, either a
        dictionary, e.g. ``B1={'region1': 1e7, 'region2': 5e7}`` (if the
        parameter is defined "per region") or ``discretisedfield.Field`` is
        passed.
Пример #7
0
import numpy as np
import ubermagutil.typesystem as ts
import discretisedfield.util as dfu


@ts.typesystem(pmin=ts.Vector(size=3, const=True),
               pmax=ts.Vector(size=3, const=True))
class Region:
    """A rectangular region.

    A rectangular region spans between two corner points
    :math:`\\mathbf{p}_{1}` and :math:`\\mathbf{p}_{2}`.

    Parameters
    ----------
    p1, p2 : (3,) array_like
        Points between which the region spans :math:`\\mathbf{p}
        = (p_{x}, p_{y}, p_{z})`.

    Raises
    ------
    ValueError
        If the length of one or more region edges is zero.

    Examples
    --------
    1. Defining a nano-sized region

    >>> import discretisedfield as df
    ...
    >>> p1 = (-50e-9, -25e-9, 0)
Пример #8
0
import ubermagutil.typesystem as ts


@ts.typesystem(
    t1=ts.Typed(expected_type=int),
    t2=ts.Typed(expected_type=numbers.Real),
    t3=ts.Typed(expected_type=str, allow_none=True),
    t4c=ts.Typed(expected_type=list, const=True),
    s1=ts.Scalar(),
    s2=ts.Scalar(expected_type=float),
    s3=ts.Scalar(positive=True),
    s4=ts.Scalar(unsigned=True, otherwise=str),
    s5=ts.Scalar(expected_type=int, positive=True),
    s6=ts.Scalar(expected_type=numbers.Real, positive=False),
    s7c=ts.Scalar(expected_type=float, unsigned=True, const=True),
    v1=ts.Vector(),
    v2=ts.Vector(size=5),
    v3=ts.Vector(unsigned=True),
    v4=ts.Vector(positive=True, otherwise=int),
    v5=ts.Vector(size=1, positive=False),
    v6=ts.Vector(component_type=int),
    v7=ts.Vector(size=3, component_type=float),
    v8c=ts.Vector(size=2, component_type=int, const=True),
    n1=ts.Name(),
    n2=ts.Name(allowed_char=":"),
    n3c=ts.Name(const=True),
    d1=ts.Dictionary(key_descriptor=ts.Name(),
                     value_descriptor=ts.Scalar(),
                     allow_empty=True),
    d2=ts.Dictionary(
        key_descriptor=ts.Scalar(),