Last change
on this file since 3273 was
3190,
checked in by sexton, 18 years ago
|
MOST and ANUGA comparisons and updates
|
File size:
1.5 KB
|
Rev | Line | |
---|
[2862] | 1 | """ |
---|
| 2 | Determining maximum of SMF slump surface elevation function. |
---|
| 3 | Jane Sexton, GA 2006 |
---|
| 4 | """ |
---|
| 5 | |
---|
| 6 | from math import exp, cosh |
---|
[2869] | 7 | import Numeric |
---|
[2862] | 8 | |
---|
[2878] | 9 | |
---|
[2862] | 10 | # Grilli and Watts 2005 example |
---|
| 11 | dx = 2.0 |
---|
| 12 | x0 = 10.0 |
---|
| 13 | y0 = 0.0 |
---|
| 14 | w = 2.0 |
---|
| 15 | kappa = 3 |
---|
| 16 | g = 9.8 |
---|
| 17 | d = 0.259 |
---|
| 18 | T = 0.052 |
---|
| 19 | theta = 15.0 |
---|
| 20 | lam0 = 5.0 |
---|
| 21 | |
---|
| 22 | def func(x,y,kappad): |
---|
[2869] | 23 | numerator = exp(-((x-x0)/lam0)**2.0) - kappad*exp(-((x-dx-x0)/lam0)**2.0) |
---|
| 24 | denominator = cosh(kappa*(y-y0)/(w+lam0))**2.0 |
---|
[2862] | 25 | return -numerator/denominator |
---|
| 26 | |
---|
| 27 | def dfuncdx(x,kappad): |
---|
[2869] | 28 | dfdx = (x-x0)*exp(-((x-x0)/lam0)**2.0)-kappad*(x-dx-x0)*exp(-((x-dx-x0)/lam0)**2.0) |
---|
[2862] | 29 | return dfdx |
---|
| 30 | |
---|
| 31 | step = 0.001 |
---|
| 32 | x = x0 |
---|
| 33 | deriv = 10 |
---|
| 34 | tol = 0.001 |
---|
| 35 | c = 0 |
---|
[2878] | 36 | direction = 'negative' |
---|
[3190] | 37 | xstar = x0 |
---|
| 38 | print 'start of loop', deriv |
---|
[2862] | 39 | while c < 100000 and deriv > 0: |
---|
[2878] | 40 | deriv = dfuncdx(x,0.83) |
---|
[3190] | 41 | if deriv < 0: |
---|
| 42 | xstar = x |
---|
| 43 | print 'hello', deriv, xstar/lam0, c |
---|
[2862] | 44 | if direction == 'positive': x += step |
---|
| 45 | if direction == 'negative': x -= step |
---|
| 46 | c += 1 |
---|
[3190] | 47 | |
---|
[2862] | 48 | |
---|
[2869] | 49 | print 'location of maximum of surface elevation function: xstar = %f' % (xstar/lam0) |
---|
[2862] | 50 | const = 1.0 #a3D = ? #sydney = 86? and kappad=1 |
---|
| 51 | |
---|
[3190] | 52 | #x = arange(-20,25,0.001) |
---|
| 53 | #y = arange(-10,10,0.1) |
---|
| 54 | #X,Y = meshgrid(x,y) |
---|
[2862] | 55 | |
---|
[3190] | 56 | #test = 0.0 |
---|
| 57 | #for xi in x: |
---|
| 58 | # testi = func(xi,0.0,0.83) |
---|
| 59 | # if direction == 'positive': |
---|
| 60 | # if testi > test: |
---|
| 61 | # test = testi |
---|
| 62 | # xstar = xi |
---|
| 63 | # else: |
---|
| 64 | # if testi < test: |
---|
| 65 | # test = testi |
---|
| 66 | # xstar = xi |
---|
[2869] | 67 | |
---|
[3190] | 68 | #print 'check: xstar = %f and eta(xstar) = %f' %(xstar/lam0, test) |
---|
Note: See
TracBrowser
for help on using the repository browser.