Changeset 8158
- Timestamp:
- Mar 20, 2011, 11:32:14 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_validation/validation_tests/dam_break_analytical.py
r8157 r8158 21 21 # MA 02110-1301, USA. 22 22 23 24 23 25 def wu(h2 ):24 def wu(h2, h0=1.0, h1=10.0): 26 25 """ The intermediate state in dambreak problem 27 26 must satisfy wu(h2) = 0.0 … … 29 28 Taken from formula (3.14) from Zoppou and Roberts SWW notes 30 29 """ 31 30 32 31 h21 = h2/h1 33 32 h01 = h0/h1 … … 36 35 37 36 38 h0 = 1.0 39 h1 = 2.0 37 def h2(h0=1.0, h1=10.0): 40 38 41 h21 = 1.0 42 h01 = 0.5 39 assert h1 > 0.0 40 assert h0 <= h1 41 assert h0 >= 0.0 43 42 44 print h21**3 - 9.0*(h21**2)*h01 + 16.0*(h21**(1.5))*h01 - h21*h01*(h01+8.0) + h01**3 45 46 h21 = 0.5 47 h01 = 0.5 48 49 print - 8.0*h21**3 + 16.0*h21**(2.5) -8*h21**2 43 from scipy.optimize import brentq 44 return brentq(wu, h0, h1, args=(h0,h1)) 50 45 51 46 52 n = 10 53 import pylab as p 47 h1 = 1.0 54 48 55 import numpy 56 57 x = h0 + numpy.arange(0,n+1)/float(n)*(h1-h0) 58 59 new_wu = numpy.vectorize(wu) 60 y = new_wu(x) 61 62 print x 63 print y 49 for i in range(0,11): 50 h0 = float(i)/10.0*h1 51 print 'h2(%g,%g) = %g' % (h0, h1, h2(h0)) 64 52 65 53 66 print wu(h0), wu(h1)67 54 68 from scipy.optimize import brentq69 55 70 h2 = brentq(wu, h0,h1,disp=True)71 56 72 #print h2, wu(h2)73
Note: See TracChangeset
for help on using the changeset viewer.