GPUE  v1.0
GPU Gross-Pitaevskii Equation numerical solver for Bose-Einstein condensates
extract_gauge.py
Go to the documentation of this file.
1 #-------------extract_gauge.py-------------------------------------------------#
2 #
3 # Purpose: This file takes a .mat file for a gauge field and turns it into
4 # something actually useable by GPUE / c++
5 #
6 #------------------------------------------------------------------------------#
7 
8 import scipy.io
9 
10 hbar = 1.05457148e-34
11 
12 # function to extract gauge field from .mat file
13 def extract_field(filename, varname):
14  mat = scipy.io.loadmat(filename)
15  return mat[varname]
16 
17 # function to output file in 2d format
18 def write_2d(var, outfile, fudge_factor):
19  file = open(outfile,'w')
20  for i in range(0,len(var)):
21  for j in range(0,len(var)):
22  file.write(str(var[i][j] * fudge_factor) + '\n')
23  file.close()
24 
25 # function to output 2d gauge field in 3d for GPU simulation
26 def write_3d(var, outfile, fudge_factor):
27  file = open(outfile,'w')
28  for i in range(0,len(var)):
29  for j in range(0,len(var)):
30  for k in range(0,len(var)):
31  file.write(str(var[k][j] * fudge_factor) + '\n')
32  file.close()
33 
34 def write_constant(outfile, res):
35  file = open(outfile,'w')
36  for i in range(0,res*res*res):
37  file.write(str(0) + '\n')
38  file.close()
39 
40 var = extract_field("Avec_broad_256.mat","avec")
41 #var = extract_field("Avec_128.mat","avec")
42 
43 # These are the necessary parameters for when the BEC is 10x too large
44 #write_3d(var, "gauge_3d", 0.001)
45 #write_2d(var, "gauge_2d", 0.001)
46 write_3d(var, "gauge_3d", 1.0/3100.)
47 write_2d(var, "gauge_2d", 1.0/3100.)
48 #write_constant("const_256", 256)
49 
50 # This is for the case where the BEC is the appropriate size
51 #write_3d(var, "gauge_3d", 1.0/2000000.0)
52 #write_2d(var, "gauge_2d", 1.0/2000000.0)
def extract_field(filename, varname)
def write_2d(var, outfile, fudge_factor)
def write_3d(var, outfile, fudge_factor)
def write_constant(outfile, res)