Skip to content

Commit

Permalink
Merge pull request #2 from mathemacode/dev
Browse files Browse the repository at this point in the history
Major refactor: ABM now Class object
  • Loading branch information
glider4 authored Apr 17, 2021
2 parents 93742e8 + 89bc341 commit aed4617
Show file tree
Hide file tree
Showing 21 changed files with 399 additions and 275 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ Systems I have tested with this code:
- Lorenz Attractor dynamical system

To run this module, you need a system of 3 dynamical ODE's. This module does *not* use SymPy, so make sure to
verify that you've typed in the equations correctly. Input the 3 functions as f1, f2, and f3, and then call
`abm_comp` for a 3D plot of the solution.
verify that you've typed in the equations correctly. Input the 3 functions as f1, f2, and f3, and then
instantiate the class `ABM` as shown below. To 3D plot. use ABM.plot3d(). To get numerical answers,
use ABM.adams().

This is the Rossler Attractor:

Expand All @@ -58,7 +59,7 @@ def f2(x, y, z):
def f3(x, y, z):
return 0.1 + z*(x - 14)

abm_comp(f1, f2, f3, 0, 15, 15, 36, 0, 100, 10000)
res = ABM(f1, f2, f3, 0, 15, 15, 36, 0, 100, 10000)
# func1, func2, func3, initial t0, x0, y0, z0, lower bound, upper, num iterations
```

Expand Down
4 changes: 2 additions & 2 deletions computepac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
from .dynamic_triple import *
from computepac import *

__author__ = 'mathemacode'
__copyright__ = 'License in LICENSE.txt'
__author__ = "mathemacode"
__copyright__ = "License in LICENSE.txt"
16 changes: 8 additions & 8 deletions computepac/bisection.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@


def bisection(f, a, b, acc) -> list:
x = sym.Symbol('x')
start_time = time.time() # start timer
error = 10 # before assignment in while loop
err = [] # to store errors
x = sym.Symbol("x")
start_time = time.time() # start timer
error = 10 # before assignment in while loop
err = [] # to store errors

while error > acc: # if error still larger than desired accuracy
while error > acc: # if error still larger than desired accuracy

m = (a + b) / 2 # middle between bounds
m = (a + b) / 2 # middle between bounds
ans = f.evalf(subs={x: m})

if ans > 0:
Expand All @@ -39,8 +39,8 @@ def bisection(f, a, b, acc) -> list:
err.append(error)

end_time = time.time()
total_time = end_time-start_time
total_time = end_time - start_time
num_itr = len(err)
root = m

return [num_itr, root, total_time]
Loading

0 comments on commit aed4617

Please sign in to comment.