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

Modified real space approach, more segmented functions

Now calls cells by their index instead of the real coordinates (first step
toward "one-time-call" of the F-function and lookup afterwards)
parent 71c25eeb
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,7 @@ def phasemap_slab(dim, res, beta, center, width, b_0):
-F0(y-y0+Ly/2,x-x0-Lx/2)
-F0(y-y0-Ly/2,x-x0+Lx/2)
+F0(y-y0+Ly/2,x-x0+Lx/2) ) )
'''CREATE COORDINATE GRIDS'''
x = np.linspace(res/2,x_dim*res-res/2,num=x_dim)
y = np.linspace(res/2,y_dim*res-res/2,num=y_dim)
......
No preview for this file type
......@@ -67,6 +67,8 @@ def real_space(mag_data, b_0=1, v_0=0, v_acc=30000):
'''
# TODO: Expand docstring!
# import pdb; pdb.set_trace() # TODO
res = mag_data.res
x_dim, y_dim, z_dim = mag_data.dim
......@@ -77,25 +79,34 @@ def real_space(mag_data, b_0=1, v_0=0, v_acc=30000):
abs_mag = np.sqrt(x_mag**2 + y_mag**2)
coeff = abs_mag * res / ( 4 * PHI_0 ) / res # TODO: Lz = res
def F0(n, m):
a = np.log(res**2 * (n**2 + m**2))
b = np.arctan(n / m)
return res * (n*a - 2*n + 2*m*b)
def F0(x, y):
a = np.log(x**2 + y**2)
b = np.arctan(x / y)
return x*a - 2*x + 2*y*b
def F_part(x, y):
return ( F0(x-res/2, y-res/2) - F0(x+res/2, y-res/2)
-F0(x-res/2, y+res/2) + F0(x+res/2, y+res/2) )
def F_part(n, m):
return ( F0(n-0.5, m-0.5) - F0(n+0.5, m-0.5)
-F0(n-0.5, m+0.5) + F0(n+0.5, m+0.5) )
def phiMag(xx, yy, xi, yj, coeffij, betaij):
return coeffij * ( - np.cos(betaij) * F_part(xx-xi, yy-yj)
+ np.sin(betaij) * F_part(yy-yj, xx-xi) )
'''CREATE COORDINATE GRIDS'''
x = np.linspace(res/2,x_dim*res-res/2,num=x_dim)
y = np.linspace(res/2,y_dim*res-res/2,num=y_dim)
x = np.linspace(0,(x_dim-1),num=x_dim)
y = np.linspace(0,(y_dim-1),num=y_dim)
xx, yy = np.meshgrid(x,y)
xF = np.linspace(-(x_dim-1), x_dim-1, num=2*x_dim-1)
yF = np.linspace(-(y_dim-1), y_dim-1, num=2*y_dim-1)
xxF, yyF = np.meshgrid(xF,yF)
F_cos_part = F_part(xxF, yyF)
F_sin_part = F_part(yyF, xxF)
display(F_cos_part, res, 'F_cos_part')
display(F_sin_part, res, 'F_sin_part')
phase = np.zeros((y_dim,x_dim))
for j in range(y_dim):
......
No preview for this file type
......@@ -33,7 +33,7 @@ def phase_from_mag():
padding = 20
density = 10
dim = (40, 40) # in px (y,x)
dim = (20, 20) # in px (y,x)
res = 10.0 # in nm
beta = pi/4
......@@ -41,8 +41,8 @@ def phase_from_mag():
# Slab:
shape_fun = mc.slab
center = (20, 20) # in px (y,x)
width = (20, 20) # in px (y,x)
center = (10, 10) # in px (y,x)
width = (10, 10) # in px (y,x)
params = (center, width)
# # Disc:
# shape_fun = mc.disc
......@@ -111,9 +111,8 @@ def phase_from_mag():
diff_real_to_fft = phase_real - phase_fft
pm.display(diff_real_to_ana, res, 'Difference: Analytic - Real')
pm.display(diff_fft_to_ana, res, 'Difference: Analytic - Fourier')
pm.display(diff_real_to_fft, res, 'Difference: Real - Fourier')
pm.display(diff_real_to_fft, res, 'Difference: Real - Fourier')
pass
if __name__ == "__main__":
phase_from_mag()
\ No newline at end of file
This diff is collapsed.
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