Skip to content
Snippets Groups Projects
Commit 4d230fd8 authored by Jan Caron's avatar Jan Caron
Browse files

Added scripts to create and compare vortices and one to setup interactive mode

parent 04d86506
No related branches found
No related tags found
No related merge requests found
......@@ -217,3 +217,30 @@ def create_mag_dist_comb(mag_shape_list, phi_list, theta_list=None, magnitude_li
y_mag += mag_object[1]
x_mag += mag_object[2]
return z_mag, y_mag, x_mag
def create_mag_dist_vortex(mag_shape, center=None, magnitude=1):
'''Create a 3-dimensional magnetic distribution of a homogeneous magnetized object.
Arguments:
mag_shape - the magnetic shapes (numpy arrays, see Shapes.* for examples)
phi - the azimuthal angle, describing the direction of the magnetized object
theta - the polar angle, describing the direction of the magnetized object
(optional, is set to pi/2 if not specified -> z-component is zero)
magnitude - the relative magnitudes for the magnetic shape (optional, one if not specified)
Returns:
the 3D magnetic distribution as a MagData object (see pyramid.magdata for reference)
'''
dim = np.shape(mag_shape)
assert len(dim) == 3, 'Magnetic shapes must describe 3-dimensional distributions!'
if center is None:
center = (int(dim[1]/2)-0.5, int(dim[2]/2)-0.5) # center has to be between (!) two pixels
assert len(center) == 2, 'Vortex center has to be defined in 2D!'
x = np.linspace(-center[1], dim[2]-1-center[1], dim[2])
y = np.linspace(-center[0], dim[1]-1-center[0], dim[1])
xx, yy = np.meshgrid(x, y)
phi = np.arctan2(yy, xx) - pi/2
z_mag = np.zeros(dim)
y_mag = -np.ones(dim) * np.sin(phi) * mag_shape * magnitude
x_mag = -np.ones(dim) * np.cos(phi) * mag_shape * magnitude
return z_mag, y_mag, x_mag
\ No newline at end of file
......@@ -37,7 +37,8 @@ def compare_method_errors_res():
b_0 = 1 # in T
phi = -pi/4
dim_list = [(1, 4, 4), (1, 8, 8), (1, 16, 16), (1, 32, 32), (1, 64, 64), (1, 128, 128), (1, 256, 256), (1, 512, 512)]
dim_list = [(1, 4, 4), (1, 8, 8), (1, 16, 16), (1, 32, 32), (1, 64, 64),
(1, 128, 128), (1, 256, 256), (1, 512, 512)]
res_list = [64., 32., 16., 8., 4., 2., 1., 0.5, 0.25] # in nm
......@@ -69,23 +70,27 @@ def compare_method_errors_res():
data_sl_p_fourier0[0, :] = res_list
data_sl_w_fourier0[0, :] = res_list
data_disc_fourier0[0, :] = res_list
data_vort_fourier0[0, :] = res_list
data_sl_p_fourier1[0, :] = res_list
data_sl_w_fourier1[0, :] = res_list
data_disc_fourier1[0, :] = res_list
data_vort_fourier1[0, :] = res_list
data_sl_p_fourier20[0, :] = res_list
data_sl_w_fourier20[0, :] = res_list
data_disc_fourier20[0, :] = res_list
data_vort_fourier20[0, :] = res_list
data_sl_p_real_s[0, :] = res_list
data_sl_w_real_s[0, :] = res_list
data_disc_real_s[0, :] = res_list
data_vort_real_s[0, :] = res_list
data_sl_p_real_d[0, :]= res_list
data_sl_w_real_d[0, :] = res_list
data_disc_real_d[0, :] = res_list
data_vort_real_d[0, :] = res_list
......@@ -117,6 +122,9 @@ def compare_method_errors_res():
phase_ana_disc = an.phase_mag_disc(dim, res, phi, center, radius, height, b_0)
mag_data_disc = MagData(res, mc.create_mag_dist(mag_shape_disc, phi))
projection_disc = pj.simple_axis_projection(mag_data_disc)
# Vortex:
center_vortex = (center[1], center[2])
'''FOURIER UNPADDED'''
padding = 0
......
# -*- coding: utf-8 -*-
"""Create the Pyramid-Logo."""
import pdb, traceback, sys
import numpy as np
from numpy import pi
import matplotlib.pyplot as plt
import pyramid.magcreator as mc
import pyramid.projector as pj
import pyramid.phasemapper as pm
import pyramid.holoimage as hi
from pyramid.magdata import MagData
from pyramid.phasemap import PhaseMap
def compare_vortices():
'''Calculate and display the Pyramid-Logo.
Arguments:
None
Returns:
None
'''
# Input parameters:
dim_list = [(1, 512, 512), (1, 256, 256), (1, 128, 128), (1, 64, 64), (1, 32, 32), (1, 16, 16)]
res_list = [2., 4., 8., 16., 32., 64.] # in nm
density = 10
height = 1
x = []
y = []
# Starting magnetic distribution:
dim_start = (1, 2*dim_list[0][1], 2*dim_list[0][2])
res_start = res_list[0] / 2
print 'dim_start = ', dim_start
print 'res_start = ', res_start
center = (0, dim_start[1]/2 - 0.5, dim_start[2]/2 - 0.5)
radius = 0.25 * dim_start[1]
mag_shape = mc.Shapes.disc(dim_start, center, radius, height)
mag_data = MagData(res_start, mc.create_mag_dist_vortex(mag_shape))
#mag_data.quiver_plot()
for i, (dim, res) in enumerate(zip(dim_list, res_list)):
# Create coarser grid for the magnetization:
z_mag = mag_data.magnitude[0].reshape(1, dim[1], 2, dim[1], 2)
y_mag = mag_data.magnitude[1].reshape(1, dim[1], 2, dim[1], 2)
x_mag = mag_data.magnitude[2].reshape(1, dim[1], 2, dim[1], 2)
print 'dim = ', dim
print 'res = ', res
magnitude = (z_mag.mean(axis=4).mean(axis=2) / 2,
y_mag.mean(axis=4).mean(axis=2) / 2,
x_mag.mean(axis=4).mean(axis=2) / 2)
mag_data = MagData(res, magnitude)
print np.shape(mag_data.magnitude[0])
#mag_data.quiver_plot()
projection = pj.simple_axis_projection(mag_data)
phase_map = PhaseMap(res, pm.phase_mag_real(res, projection, 'slab'))
hi.display_combined(phase_map, density, 'Vortex State, res = {}'.format(res))
x.append(np.linspace(0, dim[1]*res, dim[1]))
y.append(phase_map.phase[dim[1]/2, :]/pi)
fig = plt.figure()
fig.add_subplot(1, 1, 1)
plt.plot(x[i], y[i])
#
# Plot:
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.plot(x[0], y[0], 'k',
x[1], y[1], 'r',
x[2], y[2], 'm',
x[3], y[3], 'y',
x[4], y[4], 'c',
x[5], y[5], 'g',
x[6], y[6], 'b')
axis.set_xlabel('x [nm]')
axis.set_ylabel('phase')
if __name__ == "__main__":
try:
compare_vortices()
except:
type, value, tb = sys.exc_info()
traceback.print_exc()
pdb.post_mortem(tb)
\ No newline at end of file
# -*- coding: utf-8 -*-
"""Create the Pyramid-Logo."""
import pdb, traceback, sys
import numpy as np
from numpy import pi
import matplotlib.pyplot as plt
import pyramid.magcreator as mc
import pyramid.projector as pj
import pyramid.phasemapper as pm
import pyramid.holoimage as hi
from pyramid.magdata import MagData
from pyramid.phasemap import PhaseMap
def create_vortex():
'''Calculate and display the Pyramid-Logo.
Arguments:
None
Returns:
None
'''
# Input parameters:
filename = '../output/mag_dist_vortex.txt'
res = 10.0 # in nm
density = 1
dim = (1, 128, 128)
center = (0, int(dim[1]/2)-0.5, int(dim[2]/2)-0.5)
radius = 0.25 * dim[1]
height = 1
# Create magnetic shape:
mag_shape = mc.Shapes.disc(dim, center, radius, height)
mag_data = MagData(res, mc.create_mag_dist_vortex(mag_shape))
mag_data.quiver_plot()
mag_data.quiver_plot3d()
mag_data.save_to_llg(filename)
projection = pj.simple_axis_projection(mag_data)
phase_map = PhaseMap(res, pm.phase_mag_real(res, projection, 'slab'))
hi.display_combined(phase_map, density, 'Vortex State')
phase_slice = phase_map.phase[dim[1]/2, :]
fig = plt.figure()
fig.add_subplot(111)
plt.plot(range(dim[1]), phase_slice)
if __name__ == "__main__":
try:
create_vortex()
except:
type, value, tb = sys.exc_info()
traceback.print_exc()
pdb.post_mortem(tb)
\ No newline at end of file
# -*- coding: utf-8 -*-
"""Imports pyramid package and sets working directory to output directory"""
import pyramid.analytic as an
import pyramid.holoimage as hi
import pyramid.magcreator as mc
import pyramid.phasemapper as pm
import pyramid.projector as pj
import pyramid.reconstructor as rc
from pyramid.magdata import MagData
from pyramid.phasemap import PhaseMap
import os
os.chdir('C:\Users\Jan\PhD Thesis\Pyramid\output')
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment