#!/usr/bin/env python # coding: utf-8 # # Time-varying field # # In this tutorial, we introduce how a time-dependent external magnetic field can be defined in energy equation. We start by importing the modules we are going to use: # In[1]: import oommfc as mc import discretisedfield as df import micromagneticmodel as mm # For the sample, we choose a one-dimensional chain of magnetic moments. # In[2]: p1 = (-10e-9, 0, 0) p2 = (10e-9, 1e-9, 1e-9) cell = (1e-9, 1e-9, 1e-9) region = df.Region(p1=p1, p2=p2) mesh = df.Mesh(region=region, cell=cell) # The mesh is: # In[3]: mesh.mpl(box_aspect=(10, 3, 3)) # Now, we can define the system object and add a time-dependent sine-wave field to our energy equation. We need to pass: # # - Field `H` which is multiplied by time-dependent function at each time step, # - wave shape `func='sin'` # - frequency `f`, and # - time shift `t0`. # # Accordingly, the time-dependent Zeeman field is then: # # $$\mathbf{H}(t) = \mathbf{H}_\text{amp}\sin(2\pi f (t-t_{0}))$$ # In[4]: system = mm.System(name="time_dependent_field") system.energy = mm.Exchange(A=1.6e-11) + mm.Zeeman( H=(1e6, 2e6, 3e6), func="sin", f=1e9, t0=1e-9 ) system.dynamics = mm.Precession(gamma0=mm.consts.gamma0) + mm.Damping(alpha=1e-5) system.m = df.Field(mesh, nvdim=3, value=(0, 0, 1), norm=1.1e6) # Now, we can run the simulation using `TimeDriver`: # In[5]: td = mc.TimeDriver() td.drive(system, t=5e-9, n=200) # In the system table, there are columns with field values: # In[6]: system.table.data # In[7]: system.table.mpl(y=["Bx_zeeman", "By_zeeman", "Bz_zeeman"]) # Similarly, we can define a cardinal sine wave ("sinc pulse"). We need to pass: # # - Field `H` which is multiplied by time-dependent function at each time step, # - wave shape `wave='sinc'` # - cut-off frequency `f`, and # - time shift `t0`. # # Accordingly, the time-dependent Zeeman field is then: # # $$\mathbf{H}(t) = \mathbf{H}_\text{amp}\text{sinc}(2\pi f_{c} (t-t_{0})) = \mathbf{H}_\text{amp}\frac{\text{sinc}(2\pi f_{c} (t-t_{0}))}{2\pi f_{c} (t-t_{0})}$$ # In[8]: system = mm.System(name="time_dependent_field") system.energy = mm.Exchange(A=1.6e-11) + mm.Zeeman( H=(1e6, 2e6, 3e6), func="sinc", f=1e9, t0=5e-9 ) system.dynamics = mm.Precession(gamma0=mm.consts.gamma0) + mm.Damping(alpha=1e-5) system.m = df.Field(mesh, nvdim=3, value=(0, 0, 1), norm=1.1e6) td = mc.TimeDriver() td.drive(system, t=10e-9, n=200) system.table.mpl(y=["Bx_zeeman", "By_zeeman", "Bz_zeeman"])