<jupyter_start><jupyter_text>Tutorial 13: Skyrmion in a disk> Interactive online tutorial:> [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ubermag/oommfc/master?filepath=docs%2Fipynb%2Findex.ipynb) In this tutorial, we compute and relax a skyrmion in a interfacial-DMI material in a confined disk like geometry.<jupyter_code>import oommfc as oc
import discretisedfield as df
import micromagneticmodel as mm<jupyter_output><empty_output><jupyter_text>We define mesh in cuboid through corner points `p1` and `p2`, and discretisation cell size `cell`.<jupyter_code>region = df.Region(p1=(-50e-9, -50e-9, 0), p2=(50e-9, 50e-9, 10e-9))
mesh = df.Mesh(region=region, cell=(5e-9, 5e-9, 5e-9))<jupyter_output><empty_output><jupyter_text>The mesh we defined is:<jupyter_code>%matplotlib inline
mesh.k3d()<jupyter_output><empty_output><jupyter_text>Now, we can define the system object by first setting up the Hamiltonian:<jupyter_code>system = mm.System(name='skyrmion')

system.energy = (mm.Exchange(A=1.6e-11)
               + mm.DMI(D=4e-3, crystalclass='Cnv') 
               + mm.UniaxialAnisotropy(K=0.51e6, u=(0, 0, 1)) 
               + mm.Demag()
               + mm.Zeeman(H=(0, 0, 2e5)))<jupyter_output><empty_output><jupyter_text>Disk geometry is set up be defining the saturation magnetisation (norm of the magnetisation field). For that, we define a function:<jupyter_code>Ms = 1.1e6

def Ms_fun(pos):
    """Function to set magnitude of magnetisation: zero outside cylindric shape, 
    Ms inside cylinder.
    
    Cylinder radius is 50nm.
    
    """
    x, y, z = pos
    if (x**2 + y**2)**0.5 < 50e-9:
        return Ms
    else:
        return 0<jupyter_output><empty_output><jupyter_text>And the second function we need is the function to definr the initial magnetisation which is going to relax to skyrmion.<jupyter_code>def m_init(pos):
    """Function to set initial magnetisation direction: 
    -z inside cylinder (r=10nm),
    +z outside cylinder.
    y-component to break symmetry.
    
    """
    x, y, z = pos
    if (x**2 + y**2)**0.5 < 10e-9:
        return (0, 0, -1)
    else:
        return (0, 0, 1)
    

# create system with above geometry and initial magnetisation
system.m = df.Field(mesh, dim=3, value=m_init, norm=Ms_fun)<jupyter_output><empty_output><jupyter_text>The geometry is now:<jupyter_code>system.m.norm.k3d_nonzero()<jupyter_output><empty_output><jupyter_text>and the initial magnetsation is:<jupyter_code>system.m.plane('z').mpl()<jupyter_output>/Users/marijanbeg/miniconda3/envs/ubermag-dev/lib/python3.8/site-packages/matplotlib/quiver.py:715: RuntimeWarning: divide by zero encountered in double_scalars
  length = a * (widthu_per_lenu / (self.scale * self.width))
/Users/marijanbeg/miniconda3/envs/ubermag-dev/lib/python3.8/site-packages/matplotlib/quiver.py:715: RuntimeWarning: invalid value encountered in multiply
  length = a * (widthu_per_lenu / (self.scale * self.width))
/Users/marijanbeg/miniconda3/envs/ubermag-dev/lib/python3.8/site-packages/matplotlib/quiver.py:767: RuntimeWarning: invalid value encountered in less
  short = np.repeat(length < minsh, 8, axis=1)
/Users/marijanbeg/miniconda3/envs/ubermag-dev/lib/python3.8/site-packages/matplotlib/quiver.py:780: RuntimeWarning: invalid value encountered in less
  tooshort = length < self.minlength<jupyter_text>Finally we can minimise the energy and plot the magnetisation.<jupyter_code># minimize the energy
md = oc.MinDriver()
md.drive(system)

# Plot relaxed configuration: vectors in z-plane
system.m.plane('z').mpl()
# Plot z-component only:
system.m.z.plane('z').mpl()
# 3d-plot of z-component
system.m.z.k3d_scalar(filter_field=system.m.norm)<jupyter_output><empty_output><jupyter_text>Finally we can sample and plot the magnetisation along the line:<jupyter_code>system.m.z.line(p1=(-49e-9, 0, 0), p2=(49e-9, 0, 0), n=20).mpl()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12765413149143004, 'fraction_numerical': 0.03095420823740087, 'mean_word_length': 4.642135642135642, 'pattern_counts': {'":': 0, '<': 44, '<?xml version=': 0, '>': 42, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '418', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1497, 'n_tokens_neox': 1419, 'n_words': 317, 'path': 'docs/ipynb/13-tutorial-skyrmion.ipynb', 'repo_name': 'spinachslayer420/MSE598-SAF-Project', 'size': '3909'}