(K, emin, emax)) xc, yc = (1.2 * np.random.rand(K) - 0.1) * Nx, (1.2 * np.random.rand(K) - 0.1) * Ny linear_coefficient = np.empty((Nx, Ny)) for i in range(Nx): for j in range(Ny): linear_coefficient[i, j] = vc[(np.square(i - xc) + np.square(j - yc)).argmin()] print('Create GL solver') gl = GLSolver( Nx=Nx, Ny=Ny, dx=0.5, dy=0.5, order_parameter='random', random_level=0.5, linear_coefficient=linear_coefficient, gl_parameter=10.0, normal_conductivity=200.0, homogeneous_external_field=0.05, ) images_dir = 'images' if not os.path.exists(images_dir): os.mkdir(images_dir) dt = 0.1 Nt = 2000 print('Iterate TDGL: %d timesteps with dt = %g' % (Nt, dt)) gl.solve.td(dt=dt, Nt=Nt) print('Minimize GL free energy')
import sys, os sys.path.append(os.path.abspath('../')) import numpy as np from svirl import GLSolver from svirl import plotter print('Create GL solver') gl = GLSolver( Lx = 50, Ly = 50, dx = 0.5, dy = 0.5, order_parameter = 1.0, linear_coefficient = 1.0, gl_parameter = 10.0, normal_conductivity = 200.0, ) print('Add three vortices') gl.params.fixed_vortices.order_parameter_add_vortices([[20, 30, 20], [20, 20, 30], [-1, 1, 1]], phase=True, deep=True) images_dir = 'images' if not os.path.exists(images_dir): os.mkdir(images_dir) print('Save initial figure to %s/vortices_0_initialized.png' % (images_dir)) plotter.save(gl, '%s/vortices_0_initialized.png' % (images_dir), 'order_parameter', show_vortices=True, magnification=2, tight_layout_pad=4.0) print('Iterate TDGL') gl.solve.td(dt=0.1, Nt=400) print('400 timesteps with dt=0.1')
import sys, os sys.path.append(os.path.abspath('../')) import numpy as np from svirl import GLSolver gl = GLSolver( dx=0.5, dy=0.5, Lx=64, Ly=64, order_parameter=1.0, # material_tiling = <128-by-128 np.bool array>, gl_parameter=5.0, # np.inf normal_conductivity=200.0, homogeneous_external_field=0.1, ) gl.vars.randomize_order_parameter(level=0.1) gl.solve.td(dt=0.1, Nt=1000) print('Order parameter: array of shape', gl.vars.order_parameter.shape) gl.params.homogeneous_external_field = 0.11 gl.solve.td(dt=0.1, Nt=1000) vx, vy, vv = gl.vortex_detector.vortices print('%d vortices detected' % vx.size) print('Free energy: ', gl.observables.free_energy)
import numpy as np from svirl import GLSolver from svirl import plotter Nx, Ny = 201, 201 print('Create GL solver') H = 0.01 gl = GLSolver( Lx=100, Ly=100, dx=0.5, dy=0.5, order_parameter='random', random_level=1.0, linear_coefficient= 0.1, # vortex size should scale as 1/sqrt(linear_coefficient) normal_conductivity=200.0, homogeneous_external_field=H, dtype=np.float64, ) print('Iterate TDGL') dt = 0.1 Nt = 10000 gl.solve.td(dt=dt, Nt=Nt) print('%d timesteps with dt = %g' % (Nt, dt)) images_dir = 'images' if not os.path.exists(images_dir): os.mkdir(images_dir)
def material(x, y): return np.logical_or.reduce(( np.logical_and(np.abs(x - y) < 43, np.abs(x + y - 100) < 43), np.logical_and(np.square(x - 200) + np.square(y - 50) < np.square(42), np.square(x - 185) + np.square(y - 50) > np.square(20)), np.square(x - 50) + np.square(y - 200) < np.square(30+20*np.sin(3*np.arctan2(y - 200, x - 50)+0.5*np.pi)), np.logical_and.reduce((np.abs(x - 200) < 50/np.sqrt(2), np.abs(y - 200) < 50/np.sqrt(2), np.abs(x - y) < 50, np.abs(x + y - 400) < 50)), np.logical_and.reduce((x-0.3*y>60, y-0.3*x>60, x+y<300)), )) print('Create GL solver') gl = GLSolver( Lx = 250, Ly = 250, dx = 0.5, dy = 0.5, order_parameter = 'random', random_level = 0.5, material_tiling = material, linear_coefficient = 1.0, gl_parameter = 5.0, normal_conductivity = 50, homogeneous_external_field = 0.1, ) images_dir = 'images' if not os.path.exists(images_dir): os.mkdir(images_dir) dt = 0.1 Nt = 2000 print('Iterate TDGL: %d timesteps with dt = %g' % (Nt, dt)) gl.solve.td(dt = dt, Nt = Nt) print('Minimize GL free energy')
sys.path.append(os.path.abspath('../')) import numpy as np from svirl import GLSolver from svirl import plotter print('Create GL solver') gl = GLSolver( Lx=60, Ly=60, dx=0.5, dy=0.5, order_parameter='random', random_level=0.1, random_seed=2, linear_coefficient=1.0, gl_parameter=1.0, normal_conductivity=10.0, fixed_vortices=(20 + 20 * np.array([0, 0, 1, 1]), 20 + 20 * np.array([0, 1, 0, 1]), [1, -1, -1, 1]), phase_lock_radius= 0.8, # lock phase in four grid points around each fixed vortex ) print('Iterate GL') gl.solve.td(dt=0.1, Nt=2000) print('2000 timesteps with dt=0.1') gl.solve.td(dt=0.01, Nt=2000) print('2000 timesteps with dt=0.01') gl.solve.td(dt=0.001, Nt=2000) print('2000 timesteps with dt=0.001')
import numpy as np import sys, os sys.path.append(os.path.abspath("../")) from svirl import GLSolver from common import * gl = GLSolver( Nx=32, Ny=32, dx=0.5, dy=0.5, ) np.random.seed(5) #============================================= # Test scalar reduction #============================================= nruns = 20 start = 1 end = int(2048 * 2048) N = np.random.randint(start, end, nruns) scalar_reduction_test_passed, scalar_reduction_test_number = 0, 0 for n in N: for block_size in np.random.randint(32, 1024, 8): a_in = np.random.rand(n) # make sure block_size is a multiple of 32 block_size = 32 * int(np.ceil(block_size / 32))
import numpy as np import sys, os sys.path.append(os.path.abspath("../")) from svirl import GLSolver from svirl.storage import GArray from common import * gl = GLSolver( Nx = 8 + np.random.randint(4), Ny = 8 + np.random.randint(4), dx = 0.5 - 0.1*np.random.rand(), dy = 0.5 - 0.1*np.random.rand(), gl_parameter = 1.0, ) verbose = False rs = [0.0001, 0.001, 0.01, 0.1, 0.3, 1.0] test_e0_number, test_e0_passed = 0, 0 test_e1_number, test_e1_passed = 0, 0 test_c_number, test_c_passed = 0, 0 gl.solve._init_cg() psi0 = gl.vars.order_parameter ab0 = gl.vars.vector_potential dpsi = GArray(like = psi0) dab = GArray(shape = [ab0[0].shape, ab0[1].shape], dtype = gl.cfg.dtype)
import numpy as np from svirl import GLSolver from svirl import plotter print('Create GL solver') kappa = 10.0 H = 0.1 gl = GLSolver( Lx=50, Ly=50, dx=0.5, dy=0.5, order_parameter='random', random_level=1.0, material_tiling=lambda x, y: np.square(x - 25) + np.square(y - 15) > np. square(10), gl_parameter=kappa, normal_conductivity=200.0, homogeneous_external_field=H, ) dt = 0.1 Nt = 1000 print('Iterate TDGL: %d timesteps with dt = %g' % (Nt, dt)) gl.solve.td(dt=dt, Nt=Nt) print('Minimize GL free energy') gl.solve.cg()
import numpy as np import sys, os sys.path.append(os.path.abspath("../")) from svirl import GLSolver from common import * cd_test_number, cd_test_passed = 0, 0 for i in range(10): try: gl = GLSolver( Nx = np.random.randint(4, 1024), Ny = np.random.randint(4, 1024), dx = 0.2 + 0.2*np.random.rand(), dy = 0.2 + 0.2*np.random.rand(), gl_parameter = 1.0 if np.random.rand() > 0.5 else np.inf, ) gl.vars.order_parameter = 1.0 gl.vars.randomize_order_parameter(level=0.5) if not np.isposinf(gl.params.gl_parameter): gl.params.gl_parameter = 1.0 + 3.0*np.random.rand() gl.params.external_field = 0.01 + 0.1*np.random.rand() gl.params.homogeneous_external_field = 0.01 + 0.1*np.random.rand() apply_material_tiling(gl, verbose=False) del gl except:
def material(x, y): dx = dy = 1.0 return ~np.logical_and.reduce( (np.logical_and(x > gl.cfg.Lx / 2 - 10.0 * dx / 2, x < gl.cfg.Lx / 2 + 10.0 * dx / 2), np.logical_and(y > gl.cfg.Ly / 2 - 10.0 * dy / 2, y < gl.cfg.Ly / 2 + 10.0 * dy / 2))) gl = GLSolver( Lx=100, Ly=100, dx=dx, dy=dy, order_parameter=1.0, gl_parameter=kappa, normal_conductivity=400.0, homogeneous_external_field=0.1, dtype=np.float32, convergence_rtol=1e-12, ) gl.params.fixed_vortices.order_parameter_add_vortices([50, 50], phase=True, deep=True) gl.mesh.material_tiling = material gl.vars.set_order_parameter_to_zero_outside_material() gl.solve.td(Nt=6000, dt=0.1)
import numpy as np import sys, os sys.path.append(os.path.abspath("../")) from svirl import GLSolver from svirl.storage import GArray from common import * gl = GLSolver( Nx=8 + np.random.randint(4), Ny=8 + np.random.randint(4), dx=0.5 - 0.1 * np.random.rand(), dy=0.5 - 0.1 * np.random.rand(), gl_parameter=np.inf, homogeneous_external_field=0.1, ) verbose = False a_b_alpha = [ # a + b*alpha = 1 [1.0, 0.0, 0.0], [0.0, 1.0, 1.0], [0.5, 0.5, 1.0], ] for i in range(10): alpha, b = np.random.rand(2) a_b_alpha.append([1.0 - b * alpha, b, alpha]) dpsi = GArray(like=gl.vars.order_parameter) gl.solve._init_cg()