GPUE  v1.0
GPU Gross-Pitaevskii Equation numerical solver for Bose-Einstein condensates
stats.py
Go to the documentation of this file.
1 '''
2 stats.py - GPUE: Split Operator based GPU solver for Nonlinear
3 Schrodinger Equation, Copyright (C) 2011-2015, Lee J. O'Riordan
4 <loriordan@gmail.com>, Tadhg Morgan, Neil Crowley. All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are
8 met:
9 
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its
18 contributors may be used to endorse or promote products derived from
19 this software without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
27 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 '''
33 import os
34 from numpy import genfromtxt
35 import math as m
36 #import matplotlib as mpl
37 import numpy as np
38 import numpy.matlib
39 
40 import warnings
41 
42 import ConfigParser
43 import random as r
44 from decimal import *
45 
46 c = ConfigParser.ConfigParser()
47 
48 try:
49  c.readfp(open(r'Params.dat'))
50  incr = int(c.getfloat('Params','printSteps'))
51  xDim = int(c.getfloat('Params','xDim'))
52  yDim = int(c.getfloat('Params','yDim'))
53 
54 except Exception as e:
55  print "Cannot find Params.dat; assuming default values: xDim=yDim=1024, incr=1000"
56  incr=1000
57  xDim=1024
58  yDim=1024
59 
60 def lsFit(start,end,incr):
61  warnings.warn("deprecated", DeprecationWarning)
62  L = np.matrix([
63  [0,0,1],
64  [1,0,1],
65  [0,1,1],
66  [1,1,1]
67  ])
68 
69  LSQ = np.linalg.inv(np.transpose(L)*L)*np.transpose(L)
70  for i in range(start,end,incr):
71  v_arr=genfromtxt('vort_arr_' + str(i),delimiter=',' )
72  real=open('wfc_ev_' + str(i)).read().splitlines()
73  img=open('wfc_evi_' + str(i)).read().splitlines()
74  a_r = np.asanyarray(real,dtype='f8') #64-bit double
75  a_i = np.asanyarray(img,dtype='f8') #64-bit double
76  a = a_r[:] + 1j*a_i[:]
77  wfc = (np.reshape(a,(xDim,yDim)))
78 
79  indX = [row[0] for row in v_arr]
80  indY = [row[2] for row in v_arr]
81  sign = [row[4] for row in v_arr]
82  data=[]
83  for ii in range(0,len(indX)):
84  p=np.matrix([[0],[0],[0],[0]],dtype=np.complex)
85  p[0]=(wfc[indX[ii], indY[ii]])
86  p[1]=(wfc[indX[ii]+1, indY[ii]])
87  p[2]=(wfc[indX[ii], indY[ii]+1])
88  p[3]=(wfc[indX[ii]+1, indY[ii]+1])
89  rc = LSQ * np.real(p)
90  ic = LSQ * np.imag(p)
91 
92  A=np.squeeze([row[0:2] for row in [rc,ic]])
93  B=-np.squeeze([row[2] for row in [rc,ic]])
94  r=np.linalg.lstsq(A,B)[0]
95  data.append([indX[ii]+r[0],indY[ii]+r[1],sign[ii]])
96 
97 
98  np.savetxt('vort_lsq_'+str(i)+'.csv',data,delimiter=',')
99 
100 if __name__ == '__main__':
101  warnings.warn("deprecated", DeprecationWarning)
102  import sys
103  st = int(sys.argv[1])
104  en = int(sys.argv[2])
105  lsFit(st, en, incr)
def lsFit(start, end, incr)
Definition: stats.py:60