Last change
on this file since 8594 was
8594,
checked in by mungkasi, 12 years ago
|
Uploading the 1D Carrier-Greenspan test for 2D model.
|
File size:
465 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 | else: |
---|
15 | return x1,x2 |
---|
Note: See
TracBrowser
for help on using the repository browser.