GPUE  v1.0
GPU Gross-Pitaevskii Equation numerical solver for Bose-Einstein condensates
hist3d.py
Go to the documentation of this file.
1 '''
2 hist3d.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 
34 from mpl_toolkits.mplot3d import Axes3D
35 import matplotlib.pyplot as plt
36 import numpy as np
37 from numpy import genfromtxt
38 import math as m
39 import ConfigParser
40 
41 c = ConfigParser.ConfigParser()
42 c.readfp(open(r'Params.dat'))
43 
44 xDim = int(c.getfloat('Params','xDim'))
45 yDim = int(c.getfloat('Params','yDim'))
46 gndMaxVal = int(c.getfloat('Params','gsteps'))
47 evMaxVal = int(c.getfloat('Params','esteps'))
48 incr = int(c.getfloat('Params','print_out'))
49 sep = (c.getfloat('Params','dx'))
50 dx = (c.getfloat('Params','dx'))
51 dt = (c.getfloat('Params','dt'))
52 xMax = (c.getfloat('Params','xMax'))
53 yMax = (c.getfloat('Params','yMax'))
54 num_vort = 0#int(c.getfloat('Params','Num_vort'))
55 
56 sep=1.0
57 def plot_xyz_histogram(start,fin,incr, barcolor):
58  fig = plt.figure()
59  ax = Axes3D(fig)
60  data =[]
61  for i in range(start, fin, incr):
62  v_arr=genfromtxt('vort_lsq_' + str(i) + '.csv',delimiter=',' )
63  datatmp=[]
64  count=0
65 
66  for i1 in range(0,v_arr.size/2):
67  for i2 in range(i1,v_arr.size/2):
68  datatmp.append(m.sqrt( abs(v_arr[i1][0]*sep - v_arr[i2][0]*sep)**2 + abs(v_arr[i1][1]*sep - v_arr[i2][1]*sep)**2 ))
69  count = count + 1
70  hist=np.histogram(datatmp,bins=np.arange(1.0,m.sqrt(xDim**2 + yDim**2),1.0))
71  data.append(hist[:][0])
72  """ Takes in a matrix (see structure above) and generate a pseudo-3D histogram by overlaying close, semitransparent bars. """
73  for time, occurrence in zip(range(len(data)), data):
74  dist = range(len(occurrence))
75  barband = range(-45, 45, 5)
76  #for modifier in barband:
77  ax.bar(dist, occurrence, zs=time, zdir='y', color=np.random.rand(3,1), alpha=0.8)
78  #ax.bar(current, occurrence, zs=duration+(float(modifier)/100), zdir='y', color=np.random.rand(3,1), alpha=0.6)
79 
80  ax.set_xlabel('Dist')
81  ax.set_ylabel('Time')
82  ax.set_zlabel('Occurrances')
83 
84  plt.savefig("HIST_N.pdf")
85  plt.show()
86 
87 def plot_hist_pcolor(start,fin,incr, barcolor):
88  fig = plt.figure()
89 
90  data =[]
91  for i in range(start, fin, incr):
92  v_arr=genfromtxt('vort_lsq_' + str(i) + '.csv',delimiter=',' )
93  datatmp=[]
94  count=0
95 
96  for i1 in range(0,v_arr.size/2):
97  for i2 in range(i1,v_arr.size/2):
98  m_tmp = m.sqrt(abs(v_arr[i1][0]*sep - v_arr[i2][0]*sep)**2 + abs(v_arr[i1][1]*sep - v_arr[i2][1]*sep)**2 )
99  datatmp.append( m_tmp )
100  count = count + 1
101  hist=np.histogram(datatmp,bins=np.arange(0.0,240.0,0.1))
102  data.append(hist[:][0])
103 
104  # print data
105  ax = fig.add_subplot(111)
106  ax.imshow(data)
107  plt.gca().invert_yaxis()
108  ax.set_aspect('auto')
109 # plt.jet()
110  fig.savefig("HIST_PCOLOR.pdf")
def plot_xyz_histogram(start, fin, incr, barcolor)
Definition: hist3d.py:57
def plot_hist_pcolor(start, fin, incr, barcolor)
Definition: hist3d.py:87