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. 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions are 10 1. Redistributions of source code must retain the above copyright 11 notice, this list of conditions and the following disclaimer. 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. 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. 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. 34 from numpy
import genfromtxt
46 c = ConfigParser.ConfigParser()
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'))
54 except Exception
as e:
55 print "Cannot find Params.dat; assuming default values: xDim=yDim=1024, incr=1000" 61 warnings.warn(
"deprecated", DeprecationWarning)
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')
75 a_i = np.asanyarray(img,dtype=
'f8')
76 a = a_r[:] + 1j*a_i[:]
77 wfc = (np.reshape(a,(xDim,yDim)))
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]
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])
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]])
98 np.savetxt(
'vort_lsq_'+str(i)+
'.csv',data,delimiter=
',')
100 if __name__ ==
'__main__':
101 warnings.warn(
"deprecated", DeprecationWarning)
103 st = int(sys.argv[1])
104 en = int(sys.argv[2])
def lsFit(start, end, incr)