#!/usr/bin/env python # coding: utf-8 # # Micromagnetic model # # ## Mesh # In[1]: import oommfc as oc # In[2]: get_ipython().run_line_magic('matplotlib', 'inline') L = 100e-9 d = 10e-9 mesh = oc.Mesh(p1=(0, 0, 0), p2=(L, L, L), cell=(d, d, d), name="mesh") mesh # The domain edge lengths in x, y, and z directions are: # In[3]: mesh.l # The number of cells in all three directions: # In[4]: mesh.n # The centre point of the mesh: # In[5]: mesh.centre # ## System # The basic block of our micromagnetic model is the system object. It is fully defined if: # # 1. Hamiltonian, # 2. dynamics equation, # 3. magnetisation. # # are provided. The system is then "driven" in phase space using particular drivers. # In[6]: system = oc.System(name="system") # ## Hamiltonian # In[7]: exchange = oc.Exchange(A=1e-12) # In[8]: exchange # In[9]: exchange.A # In[10]: repr(exchange) # In[11]: hamiltonian = exchange + oc.Zeeman(H=(1e6, 0, 0)) type(hamiltonian) # In[12]: system.hamiltonian = hamiltonian # In[13]: system.hamiltonian # In[14]: system.hamiltonian.exchange.A # In[15]: system.hamiltonian.zeeman.H # In[16]: system.hamiltonian += oc.Demag(name="energy_term_name") # In[17]: system.hamiltonian.energy_term_name # ## Dynamics # In[18]: system.dynamics = oc.Precession(gamma=2.211e5) + oc.Damping(alpha=0.1) # In[19]: system.dynamics # ## Magnetisation # In[20]: import discretisedfield as df # In[21]: Ms = 8e5 m = df.Field(mesh, value=(1, 0, 1), norm=Ms, name="m") # In[22]: p = (50e-9, 50e-9, 5e-9) m(p) # sampling # In[23]: m.f = lambda pos: (pos[0]+pos[2]+1, pos[2], 0) # In[24]: system.m = m # ## Drivers # ### MinDriver # In[25]: md = oc.MinDriver() md.drive(system) # In[26]: system.m.average # In[27]: system.m.plot_plane("z") # In[28]: system.hamiltonian.zeeman.H = (0, 1e7, 0) # In[29]: md.drive(system) # In[30]: system.m.plot_plane("z") # ### Time driver # In[31]: system.hamiltonian += oc.UniaxialAnisotropy(K1=5e3, u=(0, 0, 1)) system.hamiltonian.zeeman.H = (1e6, 0, 0) # In[32]: td = oc.TimeDriver() td.drive(system, t=0.2e-9, n=50) # In[33]: system.m.plot_plane("z") # In[34]: system.dt # In[35]: system.dt.plot("t", "E")