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

analytic: added vortex solution

holoimage: turned off interpolation
test_compliance: added scripts to be tested
setup: work in progress
parent 4b3922c3
No related branches found
No related tags found
No related merge requests found
......@@ -120,3 +120,36 @@ def phase_mag_sphere(dim, res, phi, center, radius, b_0=1):
xx, yy = np.meshgrid(x, y)
# Return phase:
return phiMag(xx, yy)
def phase_mag_vortex(dim, res, center, radius, height, b_0=1):
'''Get the analytic solution for a phase map of a sharp vortex disc of specified dimensions
Arguments:
dim - the dimensions of the grid, shape(z, y, x)
res - the resolution of the grid (grid spacing) in nm
center - the center of the disc in pixel coordinates, shape(z, y, x)
radius - the radius of the disc in pixel coordinates (scalar value)
height - the height of the disc in pixel coordinates (scalar value)
b_0 - magnetic induction corresponding to a magnetization Mo in T (default: 1)
Returns:
the analytic solution for the phase map
'''
# Function for the phase:
def phiMag(x, y):
r = np.hypot(x - x0, y - y0)
result = coeff * np.where(r <= R, r - R, 0)
return result
# Process input parameters:
z_dim, y_dim, x_dim = dim
y0 = res * (center[1] + 0.5) # y0, x0 have to be in the center of a pixel,
x0 = res * (center[2] + 0.5) # hence: cellindex + 0.5
Lz = res * height
R = res * radius
coeff = pi * b_0 * Lz / PHI_0
# Create grid:
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)
xx, yy = np.meshgrid(x, y)
# Return phase:
return phiMag(xx, yy)
......@@ -99,7 +99,7 @@ def display(holo_image, title='Holography Image', axis=None):
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1, aspect='equal')
# Plot the image and set axes:
axis.imshow(holo_image)
axis.imshow(holo_image, interpolation='none')
axis.set_title(title)
axis.set_xlabel('x-axis')
axis.set_ylabel('y-axis')
......
/* Generated by Cython 0.19.1 on Tue Jul 16 14:55:54 2013 */
/* Generated by Cython 0.19.1 on Tue Jul 23 11:18:13 2013 */
 
#define PY_SSIZE_T_CLEAN
#ifndef CYTHON_USE_PYLONG_INTERNALS
......@@ -1569,7 +1569,7 @@ static char __pyx_k_43[] = "Cannot transpose memoryview with indirect dimensions
static char __pyx_k_44[] = "got differing extents in dimension %d (got %d and %d)";
static char __pyx_k_45[] = "Dimension %d is not direct";
static char __pyx_k_48[] = "phase_mag_real_helper";
static char __pyx_k_49[] = "C:\\Users\\Jan\\PhD Thesis\\Pyramid\\pyramid\\numcore\\phase_mag_real.pyx";
static char __pyx_k_49[] = "C:\\Users\\Jan\\Daten\\PhD Thesis\\Pyramid\\pyramid\\numcore\\phase_mag_real.pyx";
static char __pyx_k_50[] = "getbuffer(obj, view, flags)";
static char __pyx_k_51[] = "<strided and direct or indirect>";
static char __pyx_k_53[] = "<strided and direct>";
......
......@@ -30,7 +30,7 @@ class TestCaseCompliance(unittest.TestCase):
def test_pep8(self):
# TODO: Docstring
files = self.get_files_to_check('..') # search in pyramid package
files = self.get_files_to_check('../../pyramid') + self.get_files_to_check('../../scripts')
ignores = ('E226', 'E128')
pep8.MAX_LINE_LENGTH = 99
pep8style = pep8.StyleGuide(quiet=False)
......
......@@ -20,27 +20,22 @@ PHI_0 = -2067.83 # magnetic flux in T*nm²
def compare_vortices():
'''Calculate and display the Pyramid-Logo.
Arguments:
None
Returns:
None
''' DOCSTRING
'''
# Input parameters:
dim_list = [(16, 256, 256), (8, 128, 128), (4, 64, 64), (2, 32, 32), (1, 16, 16)]
res_list = [4., 8., 16., 32., 64.] # in nm
density = 1
res_list = [1., 2., 4., 8., 16.] # in nm
density = 20
phi = pi/2
x = []
y = []
# Analytic solution:
L = 1024. # in nm
Lz = 0.5 * 64. # in nm
R = 0.25 * L
x0 = L / 2
L = dim_list[0][1] # in px/nm
Lz = 0.5 * dim_list[0][0] # in px/nm
R = 0.25 * L # in px/nm
x0 = L / 2 # in px/nm
def F(x):
coeff = - pi * Lz / (2*PHI_0)
result = coeff * (- (x - x0) * np.sin(phi))
......@@ -73,9 +68,6 @@ def compare_vortices():
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, :])
fig = plt.figure()
fig.add_subplot(1, 1, 1)
plt.plot(x[i], y[i])
# Plot:
fig = plt.figure()
......
......@@ -11,7 +11,7 @@ import matplotlib.pyplot as plt
import pyramid.magcreator as mc
import pyramid.projector as pj
import pyramid.phasemapper as pm
import pyramid.analytic as an
import pyramid.analytic as an
from pyramid.magdata import MagData
from pyramid.phasemap import PhaseMap
import shelve
......@@ -31,10 +31,10 @@ def phase_from_mag():
'''FOURIER PADDING->RMS|DURATION'''
# Parameters:
b_0 = 1 # in T
res = 10.0 # in nm
dim = (1, 128, 128)
res = 1.0 # in nm
dim = (16, 256, 256)
phi = -pi/4
padding_list = [0, 0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4,5, 6,7, 8,9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
padding_list = [0, 0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4,5, 6,7, 8,9, 10, 11]#, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
geometry = 'disc'
# Create magnetic shape:
if geometry == 'slab':
......@@ -45,7 +45,7 @@ def phase_from_mag():
elif geometry == 'disc':
center = (0, dim[1]/2-0.5, dim[2]/2-0.5) # in px (z, y, x) index starts with 0!
radius = dim[1]/4 # in px
height = 1 # in px
height = 8 # in px
mag_shape = mc.Shapes.disc(dim, center, radius, height)
phase_ana = an.phase_mag_disc(dim, res, phi, center, radius, b_0)
# Project the magnetization data:
......@@ -73,7 +73,8 @@ def phase_from_mag():
# Plot duration against padding:
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.set_yscale('log')
# axis.set_xscale('log')
# axis.set_yscale('log')
axis.plot(data[0], data[1])
axis.set_title('Fourier Space Approach: Variation of the Padding')
axis.set_xlabel('padding')
......@@ -81,151 +82,13 @@ def phase_from_mag():
# Plot RMS against padding:
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
# axis.set_xscale('log')
# axis.set_yscale('log')
axis.plot(data[0], data[2])
axis.set_title('Fourier Space Approach: Variation of the Padding')
axis.set_xlabel('padding')
axis.set_ylabel('duration [s]')
'''VARY DIMENSIONS FOR ALL APPROACHES'''
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)]
res_list = [64., 32., 16., 8., 4., 2., 1.] # in nm
data_sl_p_fourier0 = np.zeros((3, len(res_list)))
data_sl_w_fourier0 = np.zeros((3, len(res_list)))
data_disc_fourier0 = np.zeros((3, len(res_list)))
data_sl_p_fourier1 = np.zeros((3, len(res_list)))
data_sl_w_fourier1 = np.zeros((3, len(res_list)))
data_disc_fourier1 = np.zeros((3, len(res_list)))
data_sl_p_fourier20 = np.zeros((3, len(res_list)))
data_sl_w_fourier20 = np.zeros((3, len(res_list)))
data_disc_fourier20 = np.zeros((3, len(res_list)))
data_sl_p_real_s = np.zeros((3, len(res_list)))
data_sl_w_real_s = np.zeros((3, len(res_list)))
data_disc_real_s = np.zeros((3, len(res_list)))
data_sl_p_real_d= np.zeros((3, len(res_list)))
data_sl_w_real_d = np.zeros((3, len(res_list)))
data_disc_real_d = np.zeros((3, len(res_list)))
data_slab_perfect[0, :] = res_list
data_slab_worst[0, :] = res_list
data_disc[0, :] = res_list
'''FOURIER UNPADDED'''
for i, (dim, res) in enumerate(zip(dim_list, res_list)):
print 'dim =', str(dim)
# ANALYTIC SOLUTIONS:
# Slab (perfectly aligned):
center = (0, dim[1]/2.-0.5, dim[2]/2.-0.5) # in px (z, y, x) index starts with 0!
width = (1, dim[1], dim[2]) # in px (z, y, x)
mag_shape_slab_perfect = mc.Shapes.slab(dim, center, width)
phase_ana_slab_perfect = an.phase_mag_slab(dim, res, phi, center, width, b_0)
mag_data_slab_perfect = MagData(res, mc.create_mag_dist(mag_shape_slab_perfect, phi))
projection_slab_perfect = pj.simple_axis_projection(mag_data_slab_perfect)
# Slab (worst case):
center = (0, dim[1]/2, dim[2]/2) # in px (z, y, x) index starts with 0!
width = (1, dim[1], dim[2]) # in px (z, y, x)
mag_shape_slab_worst = mc.Shapes.slab(dim, center, width)
phase_ana_slab_worst = an.phase_mag_slab(dim, res, phi, center, width, b_0)
mag_data_slab_worst = MagData(res, mc.create_mag_dist(mag_shape_slab_worst, phi))
projection_slab_worst = pj.simple_axis_projection(mag_data_slab_worst)
# Disc:
center = (0, dim[1]/2.-0.5, dim[2]/2.-0.5) # in px (z, y, x) index starts with 0!
radius = dim[1]/2 # in px
height = 1 # in px
mag_shape_disc = mc.Shapes.disc(dim, center, radius, height)
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)
# NUMERICAL SOLUTIONS:
# Slab (perfectly aligned):
key = ', '.join(['Resolution->RMS|duration', 'Fourier', 'padding=0',
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=slab_perfect'])
if data_shelve.has_key(key):
data_slab_perfect[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection_slab_perfect, b_0, 0)
data_slab_perfect[2, i] = time.time() - start_time
phase_diff = phase_ana_slab_perfect - phase_num
data_slab_perfect[1, i] = np.std(phase_diff)
data_shelve[key] = data_slab_perfect[:, i]
# Slab (worst case):
key = ', '.join(['Resolution->RMS|duration', 'Fourier', 'padding=0',
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=slab_worst'])
if data_shelve.has_key(key):
data_slab_worst[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection_slab_worst, b_0, 0)
data_slab_worst[2, i] = time.time() - start_time
phase_diff = phase_ana_slab_worst - phase_num
data_slab_worst[1, i] = np.std(phase_diff)
data_shelve[key] = data_slab_worst[:, i]
# Disc:
key = ', '.join(['Resolution->RMS|duration', 'Fourier', 'padding=0',
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=disc'])
if data_shelve.has_key(key):
data_disc[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection_disc, b_0, 0)
data_disc[2, i] = time.time() - start_time
phase_diff = phase_ana_disc - phase_num
data_disc[1, i] = np.std(phase_diff)
data_shelve[key] = data_disc[:, i]
# Plot duration against res:
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.set_yscale('log')
axis.plot(data_slab_perfect[0], data_slab_perfect[1],
data_slab_worst[0], data_slab_worst[1],
data_disc[0], data_disc[1])
axis.set_title('Variation of the resolution (Fourier without padding)')
axis.set_xlabel('res [nm]')
axis.set_ylabel('RMS')
# Plot RMS against res:
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.plot(data_slab_perfect[0], data_slab_perfect[1],
data_slab_worst[0], data_slab_worst[1],
data_disc[0], data_disc[1])
axis.set_title('Variation of the resolution (Fourier without padding)')
axis.set_xlabel('res [nm]')
axis.set_ylabel('duration [s]')
data_shelve.close()
......
# -*- coding: utf-8 -*-
"""Compare the different methods to create phase maps."""
import time
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.analytic as an
from pyramid.magdata import MagData
from pyramid.phasemap import PhaseMap
import shelve
def phase_from_mag():
'''Calculate and display the phase map from a given magnetization.
Arguments:
None
Returns:
None
'''
# Create / Open databank:
data_shelve = shelve.open('../output/method_errors_shelve')
'''FOURIER PADDING->RMS|DURATION'''
# Parameters:
b_0 = 1 # in T
res = 10.0 # in nm
dim = (1, 128, 128)
phi = -pi/4
padding_list = [0, 0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4,5, 6,7, 8,9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]
geometry = 'disc'
# Create magnetic shape:
if geometry == 'slab':
center = (0, dim[1]/2-0.5, dim[2]/2-0.5) # in px (z, y, x) index starts with 0!
width = (1, dim[1]/2, dim[2]/2) # in px (z, y, x)
mag_shape = mc.Shapes.slab(dim, center, width)
phase_ana = an.phase_mag_slab(dim, res, phi, center, width, b_0)
elif geometry == 'disc':
center = (0, dim[1]/2-0.5, dim[2]/2-0.5) # in px (z, y, x) index starts with 0!
radius = dim[1]/4 # in px
height = 1 # in px
mag_shape = mc.Shapes.disc(dim, center, radius, height)
phase_ana = an.phase_mag_disc(dim, res, phi, center, radius, b_0)
# Project the magnetization data:
mag_data = MagData(res, mc.create_mag_dist(mag_shape, phi))
projection = pj.simple_axis_projection(mag_data)
# Create data:
data = np.zeros((3, len(padding_list)))
data[0, :] = padding_list
for (i, padding) in enumerate(padding_list):
print 'padding =', padding_list[i]
# Key:
key = ', '.join(['Padding->RMS|duration', 'Fourier', 'padding={}'.format(padding_list[i]),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry={}'.format(geometry)])
if data_shelve.has_key(key):
data[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection, b_0, padding_list[i])
data[2, i] = time.time() - start_time
phase_diff = phase_ana - phase_num
PhaseMap(res, phase_diff).display()
data[1, i] = np.std(phase_diff)
data_shelve[key] = data[:, i]
# Plot duration against padding:
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.set_yscale('log')
axis.plot(data[0], data[1])
axis.set_title('Fourier Space Approach: Variation of the Padding')
axis.set_xlabel('padding')
axis.set_ylabel('RMS')
# Plot RMS against padding:
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.plot(data[0], data[2])
axis.set_title('Fourier Space Approach: Variation of the Padding')
axis.set_xlabel('padding')
axis.set_ylabel('duration [s]')
data_shelve.close()
if __name__ == "__main__":
try:
phase_from_mag()
except:
type, value, tb = sys.exc_info()
traceback.print_exc()
pdb.post_mortem(tb)
\ No newline at end of file
......@@ -104,7 +104,6 @@ def compare_method_errors_res():
print 'i =', i, ' dim =', str(dim)
'''ANALYTIC SOLUTIONS'''
# Slab (perfectly aligned):
center = (0, dim[1]/2.-0.5, dim[2]/2.-0.5) # in px (z, y, x) index starts with 0!
width = (1, dim[1]/2, dim[2]/2) # in px (z, y, x)
......@@ -120,6 +119,7 @@ def compare_method_errors_res():
mag_data_sl_w = MagData(res, mc.create_mag_dist(mag_shape_sl_w, phi))
projection_sl_w = pj.simple_axis_projection(mag_data_sl_w)
# Disc:
print center
center = (0, dim[1]/2.-0.5, dim[2]/2.-0.5) # in px (z, y, x) index starts with 0!
radius = dim[1]/4 # in px
height = 1 # in px
......@@ -129,7 +129,10 @@ def compare_method_errors_res():
projection_disc = pj.simple_axis_projection(mag_data_disc)
# Vortex:
center_vortex = (center[1], center[2])
mag_shape_vort = mc.Shapes.disc(dim, center, radius, height)
phase_ana_vort = an.phase_mag_vortex(dim, res, center, radius, height, b_0)
mag_data_vort = MagData(res, mc.create_mag_dist_vortex(mag_shape_vort, center_vortex))
projection_vort = pj.simple_axis_projection(mag_data_vort)
'''FOURIER UNPADDED'''
padding = 0
......@@ -172,6 +175,19 @@ def compare_method_errors_res():
phase_diff = phase_ana_disc - phase_num
data_disc_fourier0[1, i] = np.std(phase_diff)
data_shelve[key] = data_disc_fourier0[:, i]
# Vortex:
key = ', '.join(['Resolution->RMS|duration', 'Fourier', 'padding={}'.format(padding),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=vortex'])
if data_shelve.has_key(key):
data_vort_fourier0[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection_disc, b_0, padding)
data_vort_fourier0[2, i] = time.time() - start_time
phase_diff = phase_ana_vort - phase_num
data_vort_fourier0[1, i] = np.std(phase_diff)
data_shelve[key] = data_vort_fourier0[:, i]
'''FOURIER PADDED ONCE'''
......@@ -214,7 +230,20 @@ def compare_method_errors_res():
data_disc_fourier1[2, i] = time.time() - start_time
phase_diff = phase_ana_disc - phase_num
data_disc_fourier1[1, i] = np.std(phase_diff)
data_shelve[key] = data_disc_fourier1[:, i]
data_shelve[key] = data_disc_fourier1[:, i]
# Vortex:
key = ', '.join(['Resolution->RMS|duration', 'Fourier', 'padding={}'.format(padding),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=vortex'])
if data_shelve.has_key(key):
data_vort_fourier1[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection_disc, b_0, padding)
data_vort_fourier1[2, i] = time.time() - start_time
phase_diff = phase_ana_vort - phase_num
data_vort_fourier1[1, i] = np.std(phase_diff)
data_shelve[key] = data_vort_fourier1[:, i]
'''FOURIER PADDED 20'''
......@@ -259,7 +288,19 @@ def compare_method_errors_res():
phase_diff = phase_ana_disc - phase_num
data_disc_fourier20[1, i] = np.std(phase_diff)
data_shelve[key] = data_disc_fourier20[:, i]
# Vortex:
key = ', '.join(['Resolution->RMS|duration', 'Fourier', 'padding={}'.format(padding),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=vortex'])
if data_shelve.has_key(key):
data_vort_fourier20[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_fourier(res, projection_disc, b_0, padding)
data_vort_fourier20[2, i] = time.time() - start_time
phase_diff = phase_ana_vort - phase_num
data_vort_fourier20[1, i] = np.std(phase_diff)
data_shelve[key] = data_vort_fourier20[:, i]
'''REAL SLAB'''
method = 'slab'
......@@ -301,8 +342,20 @@ def compare_method_errors_res():
data_disc_real_s[2, i] = time.time() - start_time
phase_diff = phase_ana_disc - phase_num
data_disc_real_s[1, i] = np.std(phase_diff)
data_shelve[key] = data_disc_real_s[:, i]
data_shelve[key] = data_disc_real_s[:, i]
# Vortex:
key = ', '.join(['Resolution->RMS|duration', 'Real', 'method={}'.format(method),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=vortex'])
if data_shelve.has_key(key):
data_disc_real_s[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_real(res, projection_disc, method, b_0)
data_vort_real_s[2, i] = time.time() - start_time
phase_diff = phase_ana_vort - phase_num
data_vort_real_s[1, i] = np.std(phase_diff)
data_shelve[key] = data_vort_real_s[:, i]
'''REAL DISC'''
method = 'disc'
......@@ -345,11 +398,24 @@ def compare_method_errors_res():
phase_diff = phase_ana_disc - phase_num
data_disc_real_d[1, i] = np.std(phase_diff)
data_shelve[key] = data_disc_real_d[:, i]
# Vortex:
key = ', '.join(['Resolution->RMS|duration', 'Real', 'method={}'.format(method),
'B0={}'.format(b_0), 'res={}'.format(res), 'dim={}'.format(dim),
'phi={}'.format(phi), 'geometry=vortex'])
if data_shelve.has_key(key):
data_vort_real_d[:, i] = data_shelve[key]
else:
start_time = time.time()
phase_num = pm.phase_mag_real(res, projection_disc, method, b_0)
data_vort_real_d[2, i] = time.time() - start_time
phase_diff = phase_ana_vort - phase_num
data_vort_real_d[1, i] = np.std(phase_diff)
data_shelve[key] = data_vort_real_d[:, i]
# Plot duration against res (perfect slab):
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.set_xscale('log')
axis.set_yscale('log')
axis.plot(data_sl_p_fourier0[0], data_sl_p_fourier0[1], 'b+',
data_sl_p_fourier1[0], data_sl_p_fourier1[1], 'bx',
......@@ -362,6 +428,7 @@ def compare_method_errors_res():
# Plot RMS against res (perfect slab):
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.set_xscale('log')
axis.set_yscale('log')
axis.plot(data_sl_p_fourier0[0], data_sl_p_fourier0[2], 'b+',
data_sl_p_fourier1[0], data_sl_p_fourier1[2], 'bx',
......@@ -371,10 +438,18 @@ def compare_method_errors_res():
axis.set_title('Variation of the resolution (perfectly adjusted slab)')
axis.set_xlabel('res [nm]')
axis.set_ylabel('duration [s]')
# Save to file:
data_sl_p = np.concatenate((data_sl_p_fourier0,
data_sl_p_fourier1[1:,:],
data_sl_p_fourier20[1:,:],
data_sl_p_real_s[1:,:],
data_sl_p_real_d[1:,:]))
np.savetxt('../output/data_slab_perfect.txt', data_sl_p.T)
# Plot duration against res (worst case slab):
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.set_xscale('log')
axis.set_yscale('log')
axis.plot(data_sl_w_fourier0[0], data_sl_w_fourier0[1], 'b+',
data_sl_w_fourier1[0], data_sl_w_fourier1[1], 'bx',
......@@ -387,6 +462,7 @@ def compare_method_errors_res():
# Plot RMS against res (worst case slab):
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.set_xscale('log')
axis.set_yscale('log')
axis.plot(data_sl_w_fourier0[0], data_sl_w_fourier0[2], 'b+',
data_sl_w_fourier1[0], data_sl_w_fourier1[2], 'bx',
......@@ -396,10 +472,18 @@ def compare_method_errors_res():
axis.set_title('Variation of the resolution (worst case slab)')
axis.set_xlabel('res [nm]')
axis.set_ylabel('duration [s]')
# Save to file:
data_sl_w = np.concatenate((data_sl_w_fourier0,
data_sl_w_fourier1[1:,:],
data_sl_w_fourier20[1:,:],
data_sl_w_real_s[1:,:],
data_sl_w_real_d[1:,:]))
np.savetxt('../output/data_slab_worstcase.txt', data_sl_w.T)
# Plot duration against res (disc<):
# Plot duration against res (disc):
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.set_xscale('log')
axis.set_yscale('log')
axis.plot(data_disc_fourier0[0], data_disc_fourier0[1], 'b+',
data_disc_fourier1[0], data_disc_fourier1[1], 'bx',
......@@ -412,6 +496,7 @@ def compare_method_errors_res():
# Plot RMS against res (disc):
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.set_xscale('log')
axis.set_yscale('log')
axis.plot(data_disc_fourier0[0], data_disc_fourier0[2], 'b+',
data_disc_fourier1[0], data_disc_fourier1[2], 'bx',
......@@ -421,7 +506,47 @@ def compare_method_errors_res():
axis.set_title('Variation of the resolution (disc)')
axis.set_xlabel('res [nm]')
axis.set_ylabel('duration [s]')
# Save to file:
data_disc = np.concatenate((data_disc_fourier0,
data_disc_fourier1[1:,:],
data_disc_fourier20[1:,:],
data_disc_real_s[1:,:],
data_disc_real_d[1:,:]))
np.savetxt('../output/data_disc.txt', data_disc.T)
# Plot duration against res (vortex):
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.set_xscale('log')
axis.set_yscale('log')
axis.plot(data_vort_fourier0[0], data_vort_fourier0[1], 'b+',
data_vort_fourier1[0], data_vort_fourier1[1], 'bx',
data_vort_fourier20[0], data_vort_fourier20[1], 'b*',
data_vort_real_s[0], data_vort_real_s[1], 'rs',
data_vort_real_d[0], data_vort_real_d[1], 'ro')
axis.set_title('Variation of the resolution (vortex)')
axis.set_xlabel('res [nm]')
axis.set_ylabel('RMS')
# Plot RMS against res (vort):
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.set_xscale('log')
axis.set_yscale('log')
axis.plot(data_vort_fourier0[0], data_vort_fourier0[2], 'b+',
data_vort_fourier1[0], data_vort_fourier1[2], 'bx',
data_vort_fourier20[0], data_vort_fourier20[2], 'b*',
data_vort_real_s[0], data_vort_real_s[2], 'rs',
data_vort_real_d[0], data_vort_real_d[2], 'ro')
axis.set_title('Variation of the resolution (vortex)')
axis.set_xlabel('res [nm]')
axis.set_ylabel('duration [s]')
# Save to file:
data_vort = np.concatenate((data_vort_fourier0,
data_vort_fourier1[1:,:],
data_vort_fourier20[1:,:],
data_vort_real_s[1:,:],
data_vort_real_d[1:,:]))
np.savetxt('../output/data_vortex.txt', data_vort.T)
data_shelve.close()
......
......@@ -28,8 +28,8 @@ def compare_vortices():
'''
# Input parameters:
dim_list = [(16, 256, 256), (8, 128, 128), (4, 64, 64), (2, 32, 32), (1, 16, 16)]
res_list = [4., 8., 16., 32., 64.] # in nm
density = 1
res_list = [1., 2., 4., 8., 16.] # in nm
density = 20
x = []
y = []
......@@ -44,15 +44,15 @@ def compare_vortices():
mag_data = MagData(res_start, mc.create_mag_dist_vortex(mag_shape))
# Analytic solution:
L = 1024. # in nm
Lz = 0.5 * 64. # in nm
R = 0.25 * L
x0 = L / 2
L = dim_list[0][1] # in px/nm
Lz = 0.5 * dim_list[0][0] # in px/nm
R = 0.25 * L # in px/nm
x0 = L / 2 # in px/nm
def F(x):
coeff = pi*Lz/PHI_0
result = coeff * np.where(np.abs(x - x0) <= R, (np.abs(x-x0)-R), 0)
return result
x_an = np.linspace(0, L, 1000)
x_an = np.linspace(0, L, 1001)
y_an = F(x_an)
for i, (dim, res) in enumerate(zip(dim_list, res_list)):
......@@ -71,9 +71,6 @@ def compare_vortices():
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, :])
fig = plt.figure()
fig.add_subplot(1, 1, 1)
plt.plot(x[i], y[i])
# Plot:
fig = plt.figure()
......
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 22 15:01:55 2013
@author: Jan
"""
def make_hgrevision(target, source, env):
import subprocess as sp
output = sp.Popen(["hg", "id", "-i"], stdout=sp.PIPE).communicate()[0]
hgrevision_cc = file(str(target[0]), "w")
hgrevision_cc.write('HG_Revision = "{0}"\n'.format(output.strip()))
hgrevision_cc.close()
\ No newline at end of file
......@@ -11,4 +11,5 @@ 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
os.chdir('C:\Users\Jan\Daten\PhD Thesis\Pyramid\output')
# TODO: Path not hard-coded!!!
\ No newline at end of file
......@@ -11,10 +11,30 @@ Created on Fri May 03 10:27:04 2013
import numpy
import os
import sys
import sysconfig
from distutils.core import setup
from distutils.command.build import build
from distutils.extension import Extension
from Cython.Distutils import build_ext
class custom_build(build):
def run(self):
build.run(self)
print 'Test'
def distutils_dir_name(dname):
'''Returns the name of a distutils build directory'''
path = "{dirname}.{platform}-{version[0]}.{version[1]}"
return path.format(dirname=dname, platform=sysconfig.get_platform(), version=sys.version_info)
print '\n------------------------------------------------------------------------------'
build_path = os.path.join('build', distutils_dir_name('lib'))
setup(
......@@ -24,16 +44,25 @@ setup(
author = 'Jan Caron',
author_email = 'j.caron@fz-juelich.de',
packages = ['pyramid', 'pyramid.numcore'],
packages = ['pyramid', 'pyramid.numcore', 'pyramid.test'],
include_dirs = [numpy.get_include()],
requires = ['numpy', 'matplotlib'],
cmdclass = {'build_ext': build_ext},
cmdclass = {'build_ext': build_ext, 'build': custom_build},
ext_package = 'pyramid/numcore',
ext_modules = [
Extension('phase_mag_real', ['pyramid/numcore/phase_mag_real.pyx'],
include_dirs = [numpy.get_include(), numpy.get_numarray_include()],
extra_compile_args=["-march=pentium", "-mtune=pentium"]
extra_compile_args=["-march=native", "-mtune=native"]
)
]
)
import os
print os.getcwd()
print '------------------------------------------------------------------------------\n'
#import pyramid.test as test
#test.run_tests()
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