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

First Draft of jacobi matrix (with strings to illustrate how it looks like)

parent 5f65879e
No related branches found
No related tags found
No related merge requests found
......@@ -2,12 +2,10 @@
S'project_paths'
p2
(lp3
VC:\u005cUsers\u005cJan\u005cDaten\u005cFZ-Jlich\u005cPrograms\u005cPython\u005cmagneticimaging
VC:\u005cUsers\u005cJan\u005cDaten\u005cFZ-Jlich\u005cPYRAMID\u005cpyramid
p4
aVC:\u005cUsers\u005cJan\u005cDaten\u005cFZ-Jlich\u005cPYRAMID\u005cpyramid
p5
asS'name'
p5
VPYRAMID
p6
VPython
p7
s.
\ No newline at end of file
File added
......@@ -5,6 +5,7 @@ Created on Wed Apr 03 11:15:38 2013
@author: Jan
"""
import numpy as np
import matplotlib.pyplot as plt
import pyramid.magcreator as mc
import pyramid.dataloader as dl
......@@ -34,16 +35,16 @@ def phase_from_mag():
padding = 20
density = 100
dim = (100, 100) # in px (y,x)
dim = (3, 3) # in px (y,x)
res = 1.0 # in nm
beta = pi/2
beta = pi/4
plot_mag_distr = True
# Slab:
shape_fun = mc.slab
center = (49, 49) # in px (y,x) index starts with 0!
width = (50, 50) # in px (y,x)
center = (2, 2) # in px (y,x) index starts with 0!
width = (1, 1) # in px (y,x)
params = (center, width)
# # Disc:
# shape_fun = mc.disc
......@@ -65,12 +66,12 @@ def phase_from_mag():
# pixel = (5, 5)
# params = pixel
'''CREATE LOGO'''
mc.create_logo(128, res, beta, filename, plot_mag_distr)
mag_data = dl.MagDataLLG(filename)
phase, pixel_stub = pm.real_space_slab(mag_data, b_0)
holo = hi.holo_image(phase, mag_data.res, density)
hi.display_holo(holo, '')
# '''CREATE LOGO'''
# mc.create_logo(128, res, beta, filename, plot_mag_distr)
# mag_data = dl.MagDataLLG(filename)
# phase= pm.real_space_slab(mag_data, b_0)
# holo = hi.holo_image(phase, mag_data.res, density)
# hi.display_holo(holo, '')
'''CREATE MAGNETIC DISTRIBUTION'''
mc.create_hom_mag(dim, res, beta, shape_fun, params,
......@@ -84,13 +85,12 @@ def phase_from_mag():
phase_el = pm.phase_elec(mag_data, v_0=1, v_acc=200000)
'''COLOR WHEEL'''
hi.make_color_wheel()
phase_stub, phi_cos_real_slab = pm.real_space_slab(mag_data, b_0)
phase_stub, phi_cos_real_disc = pm.real_space_disc(mag_data, b_0)
phi_cos_real_slab = np.zeros((2*dim[0]-1, 2*dim[1]-1))
pm.real_space_slab(mag_data, b_0, pixel_map=phi_cos_real_slab)
pm.display_phase(phi_cos_real_slab, res, 'Phase of one Pixel-Slab (Cos - Part)')
phi_cos_real_disc = np.zeros((2*dim[0]-1, 2*dim[1]-1))
pm.real_space_disc(mag_data, b_0, pixel_map=phi_cos_real_disc)
pm.display_phase(phi_cos_real_disc, res, 'Phase of one Pixel-Disc (Cos - Part)')
phi_cos_diff = phi_cos_real_slab - phi_cos_real_disc
pm.display_phase(phi_cos_diff, mag_data.res, 'Difference: One Pixel Slab - Disc')
......@@ -105,16 +105,20 @@ def phase_from_mag():
display_combined(phase_fft, mag_data.res, holo_fft,
'Fourier Space Approach')
# numerical solution Real Space (Slab):
jacobi = np.chararray((2*dim[0]*dim[1], dim[0]*dim[1]), itemsize=10)
tic = time.clock()
phase_real_slab, pixel_stub = pm.real_space_slab(mag_data, b_0)
phase_real_slab = pm.real_space_slab(mag_data, b_0, jacobi=jacobi)
toc = time.clock()
np.save('jacobi.npy', jacobi)
jacobi = np.load('jacobi.npy')
enter_pdb # <- raises error
print 'Time for Real Space Approach (Slab): ' + str(toc - tic)
holo_real_slab = hi.holo_image(phase_real_slab, mag_data.res, density)
display_combined(phase_real_slab, mag_data.res, holo_real_slab,
'Real Space Approach (Slab)')
# numerical solution Real Space (Disc):
tic = time.clock()
phase_real_disc, pixel_stub = pm.real_space_disc(mag_data, b_0)
phase_real_disc = pm.real_space_disc(mag_data, b_0)
toc = time.clock()
print 'Time for Real Space Approach (Disc): ' + str(toc - tic)
holo_real_disc = hi.holo_image(phase_real_disc, mag_data.res, density)
......
This diff is collapsed.
......@@ -61,7 +61,8 @@ def fourier_space(mag_data, b_0=1, padding=0, v_0=0, v_acc=30000):
return phase
def real_space_slab(mag_data, b_0=1, v_0=0, v_acc=30000):
def real_space_slab(mag_data, b_0=1, v_0=0, v_acc=30000,
pixel_map=None, jacobi=None):
'''Calculate phasemap from magnetization data (real space approach).
Arguments:
mag_data - MagDataLLG object (from magneticimaging.dataloader) storing
......@@ -99,6 +100,23 @@ def real_space_slab(mag_data, b_0=1, v_0=0, v_acc=30000):
x_dim-1-i:(2*x_dim-1)-i]
-np.sin(beta[j,i])*phi_sin[y_dim-1-j:(2*y_dim-1)-j,
x_dim-1-i:(2*x_dim-1)-i])
Y = np.chararray((y_dim,x_dim))
Y[:] = 'y'
Div = np.chararray((y_dim,x_dim))
Div[:] = '/'
Index = np.chararray((y_dim,x_dim), itemsize=3)
Index[:] = np.array(range(y_dim*x_dim),dtype='|S3').reshape((y_dim,x_dim))
Mag = np.chararray((y_dim,x_dim))
Mag[:] = 'm'
Beta = np.chararray((y_dim,x_dim))
Beta[:] = 'b'
def phi_del_mag(i, j): # TODO: rename
return Y + Index + Div + Mag + (i+x_dim*j).astype('|S5')
def phi_del_beta(i, j): # TODO: rename
return Y + Index + Div + Beta + (i+x_dim*j).astype('|S5')
'''CREATE COORDINATE GRIDS'''
x = np.linspace(0,(x_dim-1),num=x_dim)
......@@ -112,21 +130,29 @@ def real_space_slab(mag_data, b_0=1, v_0=0, v_acc=30000):
phi_cos = phi_pixel(xx_big, yy_big)
phi_sin = phi_pixel(yy_big, xx_big)
display_phase(phi_cos, res, 'Phase of one Pixel (Cos - Part)')
# display_phase(phi_sin, res, 'Phase of one Pixel (Sin - Part)')
if pixel_map is not None:
pixel_map[:] = phi_cos
'''CALCULATE THE PHASE'''
phase = np.zeros((y_dim, x_dim))
# TODO: only iterate over pixels that have a magn. > threshold (first >0)
for j in range(y_dim):
for i in range(x_dim):
phase += phi_mag(i, j)
if jacobi is not None:
jacobi[i+x_dim*j] = phi_del_mag(i, j).reshape(-1)
jacobi[y_dim*x_dim+i+x_dim*j] = phi_del_beta(i, j).reshape(-1)
return (phase, phi_cos)
return phase
def real_space_disc(mag_data, b_0=1, v_0=0, v_acc=30000):
def real_space_disc(mag_data, b_0=1, v_0=0, v_acc=30000,
pixel_map=None, jacobi=None):
'''Calculate phasemap from magnetization data (real space approach).
Arguments:
mag_data - MagDataLLG object (from magneticimaging.dataloader) storing
......@@ -176,8 +202,8 @@ def real_space_disc(mag_data, b_0=1, v_0=0, v_acc=30000):
phi_cos = phi_pixel(xx_big, yy_big)
phi_sin = phi_pixel(yy_big, xx_big)
display_phase(phi_cos, res, 'Phase of one Pixel (Cos - Part)')
# display_phase(phi_sin, res, 'Phase of one Pixel (Sin - Part)')
if pixel_map is not None:
pixel_map[:] = phi_cos
'''CALCULATE THE PHASE'''
phase = np.zeros((y_dim, x_dim))
......@@ -187,7 +213,7 @@ def real_space_disc(mag_data, b_0=1, v_0=0, v_acc=30000):
for i in range(x_dim):
phase += phi_mag(i, j)
return (phase, phi_cos)
return phase
def phase_elec(mag_data, b_0=1, v_0=0, v_acc=30000):
......
No preview for this file type
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