Changeset 5827
- Timestamp:
- Oct 9, 2008, 12:54:08 PM (17 years ago)
- Location:
- anuga_work/development/anuga_1d
- Files:
-
- 3 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/development/anuga_1d/analytic_dam_sudi.py
r5535 r5827 26 26 else: 27 27 zmax=z 28 28 #print 'func=',func 29 29 if( abs(z) > 99.0): 30 30 print 'no convergence' -
anuga_work/development/anuga_1d/comp_flux_ext_wellbalanced.c
r5725 r5827 26 26 //Innermost flux function (using w=z+h) 27 27 int _flux_function_wellbalanced(double *q_left, double *q_right, 28 double z_left, double z_right,29 28 double normals, double g, double epsilon, 30 29 double *edgeflux, double *max_speed) { 31 30 32 31 int i; 32 double z_left, z_right; 33 33 double ql[2], qr[2], flux_left[2], flux_right[2]; 34 34 double z_star, w_left, h_left, h_left_star, uh_left, soundspeed_left, u_left; … … 36 36 double s_max, s_min, denom; 37 37 38 w_left = q_left[0]; 39 uh_left = q_left[1]; 40 uh_left = uh_left*normals; 41 z_left = q_left[2]; 42 43 w_right = q_right[0]; 44 uh_right = q_right[1]; 45 uh_right = uh_right*normals; 46 z_right = q_right[2]; 47 38 48 if (z_left-z_right != 0.0 ) printf("z_l - z_r = %f \n",z_left-z_right); 39 ql[0] = q_left[0]; 40 ql[1] = q_left[1]; 41 ql[1] = ql[1]*normals; 42 43 qr[0] = q_right[0]; 44 qr[1] = q_right[1]; 45 qr[1] = qr[1]*normals; 46 49 47 50 //z = (z_left+z_right)/2.0; 48 51 z_star = max(z_left, z_right); //equation(7) 49 52 50 53 // Compute speeds in x-direction 51 w_left = ql[0];52 54 h_left = w_left-z_left; //This is used for computing the edgeflux[1]. 53 55 h_left_star = max(0, w_left-z_star); //(8) 54 uh_left = ql[1]; 56 55 57 if (h_left_star < epsilon) { 56 58 u_left = 0.0; h_left_star = 0.0; … … 60 62 } 61 63 62 w_right = qr[0];63 64 h_right = w_right-z_right; 64 65 h_right_star = max(0, w_right-z_star); //(9) 65 uh_right = qr[1]; 66 66 67 if (h_right_star < epsilon) { 67 68 u_right = 0.0; h_right_star = 0.0; … … 134 135 double* max_speed_array) { 135 136 136 double flux[2], ql[ 2], qr[2], edgeflux[2];137 double flux[2], ql[3], qr[3], edgeflux[2]; 137 138 double zl, zr, max_speed, normal; 138 139 int k, i, ki, n, m, nm=0; … … 147 148 ql[0] = stage_edge_values[ki]; 148 149 ql[1] = xmom_edge_values[ki]; 149 zl = bed_edge_values[ki]; 150 150 ql[2] = bed_edge_values[ki]; 151 //ql[3] = velocity_edge_values[ki]; 152 //ql[4] = height_edge_values[ki]; 153 151 154 n = neighbours[ki]; 152 155 if (n<0) { … … 154 157 qr[0] = stage_boundary_values[m]; 155 158 qr[1] = xmom_boundary_values[m]; 156 zr = zl; 159 qr[2] = ql[2]; 160 157 161 } else { 158 162 m = neighbour_vertices[ki]; … … 160 164 qr[0] = stage_edge_values[nm]; 161 165 qr[1] = xmom_edge_values[nm]; 162 zr= bed_edge_values[nm];166 qr[2] = bed_edge_values[nm]; 163 167 } 164 168 165 169 normal = normals[ki]; 166 _flux_function_wellbalanced(ql, qr, zl, zr,normal, g, epsilon, edgeflux, &max_speed);170 _flux_function_wellbalanced(ql, qr, normal, g, epsilon, edgeflux, &max_speed); 167 171 flux[0] -= edgeflux[0]; 168 172 flux[1] -= edgeflux[1]; … … 186 190 max_speed_array[k]=max_speed; 187 191 } 188 printf("timestep = %f \n",timestep);192 //printf("timestep = %f \n",timestep); 189 193 return timestep; 190 194 } -
anuga_work/development/anuga_1d/config.py
r5741 r5827 3 3 4 4 epsilon = 1.0e-12 5 h0 = 1.0e- 65 h0 = 1.0e-12 6 6 7 7 default_boundary_tag = 'exterior' … … 39 39 max_smallsteps = 50 #Max number of degenerate steps allowed b4 trying first order 40 40 41 manning = 0. 3#Manning's friction coefficient41 manning = 0.0 #Manning's friction coefficient 42 42 g = 9.8 #Gravity 43 43 #g(phi) = 9780313 * (1 + 0.0053024 sin(phi)**2 - 0.000 0059 sin(2*phi)**2) micro m/s**2, where phi is the latitude … … 109 109 110 110 #Specific to shallow water W.E. 111 minimum_allowed_height = 1.0e- 3#Water depth below which it is considered to be 0112 maximum_allowed_speed = 100 .0111 minimum_allowed_height = 1.0e-6 #Water depth below which it is considered to be 0 112 maximum_allowed_speed = 1000.0 -
anuga_work/development/anuga_1d/dam_h_elevation.py
r5743 r5827 31 31 32 32 L=2000.0 33 N= 20033 N=50 34 34 35 35 cell_len=L/N … … 123 123 import time 124 124 t0=time.time() 125 yieldstep= 45.0 #30.0126 finaltime= 45.0 #20.0125 yieldstep=10.0 #30.0 126 finaltime=10.0 #20.0 127 127 print "integral", domain.quantities['stage'].get_integral() 128 128 for t in domain.evolve(yieldstep=yieldstep, finaltime=finaltime): … … 152 152 153 153 plot(X,ElevationQ,X,HeightQ) 154 #plot1.set_ylim([9.99,10.01])154 plot1.set_ylim([-1.0,11.0]) 155 155 xlabel('Position') 156 156 ylabel('Stage') -
anuga_work/development/anuga_1d/dry_dam_sudi.py
r5587 r5827 1 1 import os 2 2 from math import sqrt, pi 3 from shallow_water_domain import *3 from shallow_water_domain_suggestion1 import * 4 4 from Numeric import allclose, array, zeros, ones, Float, take, sqrt 5 5 from config import g, epsilon … … 8 8 9 9 #t = 0.0 # time (s) 10 g = 9.81# gravity (m/s^2)10 # gravity (m/s^2) 11 11 h1 = 10.0 # depth upstream (m) 12 12 h0 = 0.0 # depth downstream (m) … … 43 43 h[i] = h0 44 44 45 return h , u*h 45 return h , u*h, u 46 46 47 47 #def newLinePlot(title='Simple Plot'): … … 65 65 print "TEST 1D-SOLUTION III -- DRY BED" 66 66 67 L = 2000.0 # Length of channel (m)68 N = 800 # Number of computational cells69 cell_len = L/N # Origin = 0.070 71 points = zeros(N+1,Float)72 for i in range(N+1):73 points[i] = i*cell_len74 75 domain = Domain(points)76 77 67 def stage(x): 78 68 h1 = 10.0 … … 92 82 93 83 finaltime = 20.0 94 yieldstep = 1.084 yieldstep = 20.0 95 85 L = 2000.0 # Length of channel (m) 96 number_of_cells = [ 200]#,200,500,1000,2000,5000,10000,20000]86 number_of_cells = [810]#,200,500,1000,2000,5000,10000,20000] 97 87 h_error = zeros(len(number_of_cells),Float) 98 88 uh_error = zeros(len(number_of_cells),Float) … … 110 100 domain.set_quantity('stage', stage) 111 101 domain.set_boundary({'exterior': Reflective_boundary(domain)}) 112 domain. default_order = 2113 domain. default_time_order = 2102 domain.order = 2 103 domain.set_timestepping_method('rk2') 114 104 domain.cfl = 1.0 115 domain.limiter = " minmod"105 domain.limiter = "vanleer" 116 106 117 107 t0 = time.time() … … 124 114 XmomC = domain.quantities['xmomentum'].centroid_values 125 115 C = domain.centroids 126 h, uh = analytical_sol(C,domain.time)116 h, uh, u = analytical_sol(C,domain.time) 127 117 h_error[k] = 1.0/(N)*sum(abs(h-StageC)) 128 118 uh_error[k] = 1.0/(N)*sum(abs(uh-XmomC)) … … 134 124 StageQ = domain.quantities['stage'].vertex_values 135 125 XmomQ = domain.quantities['xmomentum'].vertex_values 136 h, uh = analytical_sol(X.flat,domain.time) 126 velQ = domain.quantities['velocity'].vertex_values 127 128 h, uh, u = analytical_sol(X.flat,domain.time) 137 129 x = X.flat 138 130 … … 151 143 'upper right', shadow=True) 152 144 plot2 = subplot(212) 153 plot(x,u h,x,XmomQ.flat)145 plot(x,u,x,velQ.flat) 154 146 plot2.set_ylim([-35,35]) 155 147 156 148 xlabel('Position') 157 ylabel(' Xmomentum')149 ylabel('Velocity') 158 150 159 151 file = "dry_bed_" -
anuga_work/development/anuga_1d/parabolic_cannal.py
r5535 r5827 1 1 import os 2 2 from math import sqrt, pi, sin, cos 3 from shallow_water_ 1dimport *3 from shallow_water_domain import * 4 4 from Numeric import allclose, array, zeros, ones, Float, take, sqrt 5 5 from config import g, epsilon 6 6 """ 7 7 def newLinePlot(title='Simple Plot'): 8 8 import Gnuplot … … 20 20 plot3 = Gnuplot.PlotItems.Data(x3.flat,y3.flat,with="linespoints 1") 21 21 g.plot(plot1,plot2,plot3) 22 22 """ 23 23 24 24 def analytic_cannal(C,t): … … 54 54 55 55 L_x = 2500.0 # Length of channel (m) 56 N = 8# Number of compuational cells56 N = 100 # Number of compuational cells 57 57 cell_len = 4*L_x/N # Origin = 0.0 58 58 … … 63 63 domain = Domain(points) 64 64 65 domain.order = 2 #make this unnecessary 66 domain.default_order = 2 67 domain.default_time_order = 2 65 domain.order = 2 66 domain.set_timestepping_method('rk2') 68 67 domain.cfl = 1.0 69 68 domain.beta = 1.0 … … 72 71 #domain.limiter = "vanalbada" 73 72 #domain.limiter = "superbee" 74 domain.limiter = "steve_minmod" 73 #domain.limiter = "steve_minmod" 74 domain.limiter = "pyvolution" 75 75 76 76 def stage(x): … … 113 113 domain.set_quantity('elevation',elevation) 114 114 #domain.set_quantity('height',height) 115 116 115 domain.set_boundary({'exterior': Reflective_boundary(domain)}) 117 116 118 117 import time 119 118 t0 = time.time() 120 finaltime = 1122.0*0.75121 yieldstep = finaltime 122 yieldstep = 10.0123 plot1 = newLinePlot("Stage")124 plot2 = newLinePlot("Xmomentum")119 #finaltime = 1122.0*0.75 120 yieldstep = finaltime = 10.0 121 #yieldstep = 10.0 122 #plot1 = newLinePlot("Stage") 123 #plot2 = newLinePlot("Xmomentum") 125 124 C = domain.centroids 126 125 X = domain.vertices 127 126 StageQ = domain.quantities['stage'].vertex_values 128 127 XmomQ = domain.quantities['xmomentum'].vertex_values 128 #Bed = domain.quantities['elevation'].vertex_values 129 129 import time 130 130 t0 = time.time() … … 133 133 domain.write_time() 134 134 u,h,z,z_b = analytic_cannal(X.flat,t) 135 linePlot(plot1,X,z,X,z_b,X,StageQ)136 linePlot(plot2,X,u*h,X,u*h,X,XmomQ)135 #linePlot(plot1,X,z,X,z_b,X,StageQ) 136 #linePlot(plot2,X,u*h,X,u*h,X,XmomQ) 137 137 HeightQ = domain.quantities['stage'].centroid_values-domain.quantities['elevation'].centroid_values 138 138 u,hc,z,z_b = analytic_cannal(C,t) … … 142 142 error = 1.0/(N)*sum(abs(hc-HeightQ)) 143 143 print 'Error measured at centroids', error 144 #raw_input() 145 146 #from Gnuplot import plot,title,xlabel,ylabel,legend,savefig,show,hold,subplot 147 from pylab import plot,title,xlabel,ylabel,legend,savefig,show,hold,subplot 148 #import Gnuplot 149 X = domain.vertices 150 u,h,z,z_b = analytic_cannal(X.flat,domain.time) 151 StageQ = domain.quantities['stage'].vertex_values 152 XmomQ = domain.quantities['xmomentum'].vertex_values 153 hold(False) 154 plot1 = subplot(211) 155 plot(X,h,X,StageQ) 156 #plot1.set_ylim([4,11]) 157 #title('Free Surface Elevation of a Dry Dam-Break') 158 xlabel('Position') 159 ylabel('Stage') 160 legend(('Analytical Solution', 'Numerical Solution'), 161 'upper right', shadow=True) 162 plot2 = subplot(212) 163 plot(X,u*h,X,XmomQ) 164 #plot2.set_ylim([-1,25]) 165 #title('Xmomentum Profile of a Dry Dam-Break') 166 xlabel('Position') 167 ylabel('Xmomentum') 168 show() 144 # #raw_input() 145 # #from Gnuplot import plot,title,xlabel,ylabel,legend,savefig,show,hold,subplot 146 from pylab import plot,title,xlabel,ylabel,legend,savefig,show,hold,subplot 147 # #import Gnuplot 148 X = domain.vertices 149 u,h,z,z_b = analytic_cannal(X.flat,domain.time) 150 StageQ = domain.quantities['stage'].vertex_values 151 XmomQ = domain.quantities['xmomentum'].vertex_values 152 hold(False) 153 plot1 = subplot(211) 154 plot(X,h,X,StageQ,X,z_b) 155 #plot1.set_ylim([4,11]) 156 #title('?????????') 157 xlabel('Position') 158 ylabel('Stage') 159 legend(('Analytical Solution', 'Numerical Solution', 'Bed'), 160 'upper right', shadow=True) 161 plot2 = subplot(212) 162 plot(X,u*h,X,XmomQ) 163 #plot2.set_ylim([-1,25]) 164 #title('?????????????????????????') 165 xlabel('Position') 166 ylabel('Xmomentum') 167 show() -
anuga_work/development/anuga_1d/quantity.py
r5743 r5827 764 764 elif n1 < 0: 765 765 phi = (qc[k] - qc[k-1])/(C[k] - C[k-1]) 766 elif (self.domain.wet_nodes[k,0] == 2) & (self.domain.wet_nodes[k,1] == 2):767 phi = 0.0766 #elif (self.domain.wet_nodes[k,0] == 2) & (self.domain.wet_nodes[k,1] == 2): 767 # phi = 0.0 768 768 else: 769 769 if limiter == "minmod": -
anuga_work/development/anuga_1d/steady_flow.py
r5535 r5827 1 1 import os 2 import Gnuplot2 #import Gnuplot 3 3 from math import sqrt, pi 4 from shallow_water_ 1dimport *4 from shallow_water_domain import * 5 5 from Numeric import allclose, array, zeros, ones, Float, take, sqrt 6 6 from config import g, epsilon … … 21 21 h_1 = 0.5 22 22 u_1 = 0.6 23 g = 9.81 23 24 24 25 25 #h_c = (q**2/g)**(1/3) … … 103 103 104 104 L = 50.0 105 N = 50 #800105 N = 400 106 106 cell_len = L/N 107 107 points = zeros(N+1,Float) … … 134 134 wc, uc, hc = analytical_sol(C) 135 135 136 from pylab import plot,title,xlabel,ylabel,legend,savefig,show,hold,subplot,ylim,xlim, rc137 hold(False)138 rc('text', usetex=True)136 #from pylab import plot,title,xlabel,ylabel,legend,savefig,show,hold,subplot,ylim,xlim, rc 137 #hold(False) 138 #rc('text', usetex=True) 139 139 h_error = zeros(1,Float) 140 140 uh_error = zeros(1,Float) 141 141 k = 0 142 yieldstep = 25.0143 finaltime = 25.0142 yieldstep = 1.0 143 finaltime = 1.0 144 144 domain.limiter = "vanleer" 145 #domain.limiter = "steve_minmod" 146 domain.default_order = 2 147 domain.default_time_order = 2#check order is not working 145 domain.order = 2 146 domain.set_timestepping_method('rk2') 147 domain.cfl = 1.0 148 print 'THE DOMAIN LIMITER is', domain.limiter 149 import time 150 t0=time.time() 148 151 for t in domain.evolve(yieldstep = yieldstep, finaltime = finaltime): 149 152 domain.write_time() 150 print 'Test 1' 151 plot1 = subplot(211) 152 print 'Test 2' 153 plot(X,w,X,StageQ,X,ElevationQ) 154 print 'Test 3' 155 #xlabel('Position') 156 #ylabel('Stage (m)') 157 #legend(('Analytical Solution', 'Numerical Solution', 'Channel Bed'), 158 # 'upper right', shadow=True) 159 plot1.set_ylim([-0.1,1.0]) 160 print 'Test 4' 161 plot2 = subplot(212) 162 print 'Test 5' 163 plot(X,u*h,X,XmomQ)#/(StageQ-ElevationQ)) 164 print 'Test 6' 165 #xlabel('x (m)') 166 #ylabel(r'X-momentum ($m^2/s$)') 167 h_error[k] = 1.0/(N)*sum(abs(wc-StageC)) 168 uh_error[k] = 1.0/(N)*sum(abs(uc*hc-XmomC)) 169 print "h_error %.10f" %(h_error[k]) 170 print "uh_error %.10f"% (uh_error[k]) 171 print "h_max %.10f"%max(wc-StageC) 172 print "uh max %.10f"%max(uc*hc-XmomC) 173 filename = "steady_flow_" 174 filename += domain.limiter 175 filename += str(400) 176 filename += ".ps" 177 #savefig(filename) 178 show() 179 153 print "integral", domain.quantities['stage'].get_integral() 154 if t>0.0: 155 print 'Test 1' 156 from pylab import clf,plot,title,xlabel,ylabel,legend,savefig,show,hold,subplot,ion 157 #ion() 158 hold(False) 159 #rc('text', usetex=True) 160 clf() 161 162 plot1 = subplot(211) 163 print 'Test 2' 164 plot(X,w,X,StageQ,X,ElevationQ) 165 print 'Test 3' 166 xlabel('Position') 167 ylabel('Stage (m)') 168 legend(('Analytical Solution', 'Numerical Solution', 'Channel Bed'), 169 'upper right', shadow=True) 170 plot1.set_ylim([-0.1,1.0]) 171 print 'Test 4' 172 plot2 = subplot(212) 173 print 'Test 5' 174 plot(X,u*h,X,XmomQ)#/(StageQ-ElevationQ)) 175 print 'Test 6' 176 xlabel('x (m)') 177 ylabel(r'X-momentum (m^2/s)') 178 plot2.set_ylim([0.297,0.301]) 179 h_error[k] = 1.0/(N)*sum(abs(wc-StageC)) 180 uh_error[k] = 1.0/(N)*sum(abs(uc*hc-XmomC)) 181 print "h_error %.10f" %(h_error[k]) 182 print "uh_error %.10f"% (uh_error[k]) 183 print "h_max %.10f"%max(wc-StageC) 184 print "uh max %.10f"%max(uc*hc-XmomC) 185 #filename = "steady_flow_" 186 #filename += domain.limiter 187 #filename += str(400) 188 #filename += ".ps" 189 #savefig(filename) 190 show() 191 print 'That took %.2f seconds'%(time.time()-t0) 192 raw_input("Press return key!")
Note: See TracChangeset
for help on using the changeset viewer.