Last change
on this file since 8427 was
8427,
checked in by davies, 13 years ago
|
Adding the trapezoidal channel validation test, and editing the ANUGA manual
|
File size:
635 bytes
|
Line | |
---|
1 | ## module rootsearch |
---|
2 | ''' x1,x2 = rootsearch(f,a,b,dx). |
---|
3 | Searches the interval (a,b) in increments dx for |
---|
4 | the bounds (x1,x2) of the smallest root of f(x). |
---|
5 | Returns x1 = x2 = None if no roots were detected. |
---|
6 | ''' |
---|
7 | def rootsearch(f,a,b,dx): |
---|
8 | x1 = a; f1 = f(a) |
---|
9 | x2 = a + dx; f2 = f(x2) |
---|
10 | while f1*f2 > 0.0: |
---|
11 | if x1 >= b: return None,None |
---|
12 | x1 = x2; f1 = f2 |
---|
13 | x2 = x1 + dx; f2 = f(x2) |
---|
14 | #print "in rootsearch, x1=",x1 |
---|
15 | #print "in rootsearch, x2=",x2 |
---|
16 | else: |
---|
17 | #print "in rootsearch Here, x1=",x1 |
---|
18 | #print "in rootsearch Here, x2=",x2 |
---|
19 | return x1,x2 |
---|
Note: See
TracBrowser
for help on using the repository browser.