numODEsolver 0.5.1__tar.gz → 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {numodesolver-0.5.1 → numodesolver-1.0.0}/PKG-INFO +13 -5
- {numodesolver-0.5.1 → numodesolver-1.0.0}/README.md +11 -3
- {numodesolver-0.5.1 → numodesolver-1.0.0}/numODEsolver/solver.py +31 -4
- {numodesolver-0.5.1 → numodesolver-1.0.0}/numODEsolver.egg-info/PKG-INFO +13 -5
- {numodesolver-0.5.1 → numodesolver-1.0.0}/setup.py +2 -2
- {numodesolver-0.5.1 → numodesolver-1.0.0}/LICENSE +0 -0
- {numodesolver-0.5.1 → numodesolver-1.0.0}/numODEsolver/__init__.py +0 -0
- {numodesolver-0.5.1 → numodesolver-1.0.0}/numODEsolver.egg-info/SOURCES.txt +0 -0
- {numodesolver-0.5.1 → numodesolver-1.0.0}/numODEsolver.egg-info/dependency_links.txt +0 -0
- {numodesolver-0.5.1 → numodesolver-1.0.0}/numODEsolver.egg-info/requires.txt +0 -0
- {numodesolver-0.5.1 → numodesolver-1.0.0}/numODEsolver.egg-info/top_level.txt +0 -0
- {numodesolver-0.5.1 → numodesolver-1.0.0}/setup.cfg +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: numODEsolver
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Tool that solves
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Tool that solves ODE's numerically. Written in Python.
|
|
5
5
|
Home-page: https://github.com/lukasnf/Numerical-ODE-Solver
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
7
7
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -32,16 +32,24 @@ from numODEsolver import solver
|
|
|
32
32
|
import matplotlib.pyplot as plt #optional for plot
|
|
33
33
|
|
|
34
34
|
solver = solver()
|
|
35
|
-
f = solver.get_function("
|
|
35
|
+
f = solver.get_function("y")
|
|
36
36
|
x,y = solver.solve_rk4(f,x0=0,y0=1,n=10000,bound=10.1)
|
|
37
|
-
print(solver.get_value(x,y,val=10,dec=5)
|
|
37
|
+
print(solver.get_value(x,y,val=10,dec=5))
|
|
38
|
+
```
|
|
39
|
+
```bash
|
|
40
|
+
from numODEsolver import solver
|
|
41
|
+
|
|
42
|
+
solver = solver()
|
|
43
|
+
f = solver.get_function_2order("dy")
|
|
44
|
+
x,y,dy = solver.solve_euler_2order(f,x0=0,y0=1,dy0=1,n=10000,bound=5)
|
|
45
|
+
print(solver.get_value(x,y,val=3,dec=2))
|
|
38
46
|
```
|
|
39
47
|
|
|
40
48
|
# Version History
|
|
41
49
|
|
|
42
50
|
- 8.12.2024 - v0.1 -> only 1st order ODE's are solvable, more features coming soon
|
|
43
51
|
- 15.12.2024 - v0.2 -> removed plot function
|
|
44
|
-
|
|
52
|
+
- 26.1.2025 - v0.3 -> included 2nd order methods, see more on GitHub
|
|
45
53
|
|
|
46
54
|
---
|
|
47
55
|
For more documentation take a look at the source code on my GitHub.
|
|
@@ -17,16 +17,24 @@ from numODEsolver import solver
|
|
|
17
17
|
import matplotlib.pyplot as plt #optional for plot
|
|
18
18
|
|
|
19
19
|
solver = solver()
|
|
20
|
-
f = solver.get_function("
|
|
20
|
+
f = solver.get_function("y")
|
|
21
21
|
x,y = solver.solve_rk4(f,x0=0,y0=1,n=10000,bound=10.1)
|
|
22
|
-
print(solver.get_value(x,y,val=10,dec=5)
|
|
22
|
+
print(solver.get_value(x,y,val=10,dec=5))
|
|
23
|
+
```
|
|
24
|
+
```bash
|
|
25
|
+
from numODEsolver import solver
|
|
26
|
+
|
|
27
|
+
solver = solver()
|
|
28
|
+
f = solver.get_function_2order("dy")
|
|
29
|
+
x,y,dy = solver.solve_euler_2order(f,x0=0,y0=1,dy0=1,n=10000,bound=5)
|
|
30
|
+
print(solver.get_value(x,y,val=3,dec=2))
|
|
23
31
|
```
|
|
24
32
|
|
|
25
33
|
# Version History
|
|
26
34
|
|
|
27
35
|
- 8.12.2024 - v0.1 -> only 1st order ODE's are solvable, more features coming soon
|
|
28
36
|
- 15.12.2024 - v0.2 -> removed plot function
|
|
29
|
-
|
|
37
|
+
- 26.1.2025 - v0.3 -> included 2nd order methods, see more on GitHub
|
|
30
38
|
|
|
31
39
|
---
|
|
32
40
|
For more documentation take a look at the source code on my GitHub.
|
|
@@ -6,20 +6,47 @@ class solver:
|
|
|
6
6
|
# get_function() -> Takes a function of x and y as an input. Make sure to use correct python syntax and put everything in curved brackets.
|
|
7
7
|
# --> Example: numODEsolver.get_function("x+y"), The diff.eq. would then be: y' = x+y and it will be numerically solved for y.
|
|
8
8
|
def get_function(self,func):
|
|
9
|
-
x,y = sp.symbols("x
|
|
9
|
+
x,y = sp.symbols("x y")
|
|
10
10
|
func = sp.sympify(func)
|
|
11
|
-
f = sp.lambdify((x,y), func)
|
|
11
|
+
f = sp.lambdify((x,y), func, "numpy")
|
|
12
|
+
return f
|
|
13
|
+
|
|
14
|
+
# same get_function method, just for 2nd order odes you. Example: y'' = -y,
|
|
15
|
+
def get_function_2order(self,func):
|
|
16
|
+
x,y,dy = sp.symbols("x y dy")
|
|
17
|
+
func = sp.sympify(func)
|
|
18
|
+
f = sp.lambdify((x,y,dy), func, "numpy")
|
|
12
19
|
return f
|
|
13
20
|
|
|
14
21
|
# You can choose between 2 methods to solve the ODE numerically : euler and rk4. Those take the function f from before
|
|
15
|
-
#
|
|
22
|
+
# as an input and 2 Initial conditions x0 and y0 as well as an x-axis bound. If n is a high number the result will be more accurate.
|
|
16
23
|
# Both return arrays with the x,y values
|
|
24
|
+
|
|
25
|
+
# solves the ode with initial conditions y(x0) , dy(x0)
|
|
26
|
+
def solve_euler_2order(self,f,x0,y0,dy0,n,bound):
|
|
27
|
+
if n <= 0:
|
|
28
|
+
raise ValueError("n must be greater than zero.")
|
|
29
|
+
y = [y0]
|
|
30
|
+
dy = [dy0]
|
|
31
|
+
x = [x0]
|
|
32
|
+
h = (bound-x0)/n
|
|
33
|
+
for i in range(n):
|
|
34
|
+
x_e2 = x[-1] + h
|
|
35
|
+
y_e2 = y[-1] + h * dy[-1]
|
|
36
|
+
dy_e2 = dy[-1] + h * f(x[-1],y[-1],dy[-1])
|
|
37
|
+
|
|
38
|
+
x.append(x_e2)
|
|
39
|
+
y.append(y_e2)
|
|
40
|
+
dy.append(dy_e2)
|
|
41
|
+
|
|
42
|
+
return x,y,dy
|
|
43
|
+
|
|
17
44
|
def solve_euler(self,f,x0,y0,n,bound):
|
|
18
45
|
if n <= 0:
|
|
19
46
|
raise ValueError("n must be greater than zero.")
|
|
20
47
|
y = [y0]
|
|
21
48
|
x = [x0]
|
|
22
|
-
h =
|
|
49
|
+
h = (bound-x0)/n
|
|
23
50
|
for i in range(n):
|
|
24
51
|
y_e = y[-1] + h * f(x[-1], y[-1])
|
|
25
52
|
x_e = x[-1] + h
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: numODEsolver
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Tool that solves
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Tool that solves ODE's numerically. Written in Python.
|
|
5
5
|
Home-page: https://github.com/lukasnf/Numerical-ODE-Solver
|
|
6
6
|
Classifier: Programming Language :: Python :: 3
|
|
7
7
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -32,16 +32,24 @@ from numODEsolver import solver
|
|
|
32
32
|
import matplotlib.pyplot as plt #optional for plot
|
|
33
33
|
|
|
34
34
|
solver = solver()
|
|
35
|
-
f = solver.get_function("
|
|
35
|
+
f = solver.get_function("y")
|
|
36
36
|
x,y = solver.solve_rk4(f,x0=0,y0=1,n=10000,bound=10.1)
|
|
37
|
-
print(solver.get_value(x,y,val=10,dec=5)
|
|
37
|
+
print(solver.get_value(x,y,val=10,dec=5))
|
|
38
|
+
```
|
|
39
|
+
```bash
|
|
40
|
+
from numODEsolver import solver
|
|
41
|
+
|
|
42
|
+
solver = solver()
|
|
43
|
+
f = solver.get_function_2order("dy")
|
|
44
|
+
x,y,dy = solver.solve_euler_2order(f,x0=0,y0=1,dy0=1,n=10000,bound=5)
|
|
45
|
+
print(solver.get_value(x,y,val=3,dec=2))
|
|
38
46
|
```
|
|
39
47
|
|
|
40
48
|
# Version History
|
|
41
49
|
|
|
42
50
|
- 8.12.2024 - v0.1 -> only 1st order ODE's are solvable, more features coming soon
|
|
43
51
|
- 15.12.2024 - v0.2 -> removed plot function
|
|
44
|
-
|
|
52
|
+
- 26.1.2025 - v0.3 -> included 2nd order methods, see more on GitHub
|
|
45
53
|
|
|
46
54
|
---
|
|
47
55
|
For more documentation take a look at the source code on my GitHub.
|
|
@@ -8,8 +8,8 @@ classifiers = [
|
|
|
8
8
|
|
|
9
9
|
setup(
|
|
10
10
|
name="numODEsolver",
|
|
11
|
-
version= "0.
|
|
12
|
-
description= "Tool that solves
|
|
11
|
+
version= "1.0.0",
|
|
12
|
+
description= "Tool that solves ODE's numerically. Written in Python.",
|
|
13
13
|
long_description=open("README.md").read(),
|
|
14
14
|
long_description_content_type="text/markdown",
|
|
15
15
|
url="https://github.com/lukasnf/Numerical-ODE-Solver",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|