numODEsolver 0.5.2__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.
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: numODEsolver
3
- Version: 0.5.2
4
- Summary: Tool that solves and plots ODE's numerically. Written in Python.
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("cos(x)")
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("cos(x)")
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.
@@ -11,15 +11,42 @@ class solver:
11
11
  f = sp.lambdify((x,y), func, "numpy")
12
12
  return f
13
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")
19
+ return f
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
- # 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.
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 = (bound-x0)/n
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.5.2
4
- Summary: Tool that solves and plots ODE's numerically. Written in Python.
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("cos(x)")
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.5.2",
12
- description= "Tool that solves and plots ODE's numerically. Written in Python.",
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