numODEsolver 0.2__py3-none-any.whl → 0.3__py3-none-any.whl

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/solver.py CHANGED
@@ -1,26 +1,27 @@
1
- import matplotlib.pyplot as plt
2
1
  import sympy as sp
3
2
  from scipy.interpolate import interp1d
4
3
  import numpy as np
5
4
 
6
5
  class solver:
7
6
 
8
- # 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
+ def validate_func(self,func):
8
+ symbols = {"x":sp.Symbol("x"),"y":sp.Symbol("y"),"pi":sp.pi,"e":sp.E}
9
+ symbols_2 = sp.__dict__
10
+ try:
11
+ sp.sympify(func, {**symbols, **symbols_2})
12
+ return True
13
+ except:
14
+ raise ValueError("Invalid function")
15
+
16
+
17
+ # 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.
9
18
  # --> Example: numODEsolver.get_function("x+y"), The diff.eq. would then be: y' = x+y and it will be numerically solved for y.
10
19
  def get_function(self,func):
11
- x,y = sp.symbols("x,y")
12
- func = sp.sympify(func)
13
- f = sp.lambdify((x,y), func)
14
- return f
15
-
16
- # optional plot with matplotlib, pretty self-explanatory
17
- def plot(self,x,y,xlabel,ylabel,title):
18
- plt.plot(x,y)
19
- plt.xlabel(xlabel)
20
- plt.ylabel(ylabel)
21
- plt.title(title)
22
- plt.grid()
23
- plt.show()
20
+ if self.validate_func(func):
21
+ x,y = sp.symbols("x,y")
22
+ func = sp.sympify(func)
23
+ f = sp.lambdify((x,y), func)
24
+ return f
24
25
 
25
26
  # You can choose between 2 methods to solve the ODE numerically : euler and rk4. Those take the function f from before
26
27
  # 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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: numODEsolver
3
- Version: 0.2
3
+ Version: 0.3
4
4
  Summary: Tool that solves and plots ODE's numerically. Written in Python.
5
5
  Home-page: https://github.com/lukasnf/Numerical-ODE-Solver
6
6
  Classifier: Programming Language :: Python :: 3
@@ -30,18 +30,18 @@ pip install numODEsolver
30
30
  ## Example
31
31
  ```bash
32
32
  from numODEsolver import solver
33
- import numpy as np #optional for constants
33
+ import matplotlib.pyplot as plt #optional for plot
34
34
 
35
35
  solver = solver()
36
36
  f = solver.get_function("cos(x)") , f = solver.get_function("diff(y)")
37
37
  x,y = solver.solve_rk4(f,x0=0,y0=1,n=10000,bound=10.1)
38
- solver.plot(x,y,xlabel="x",ylabel="y",title="rk4")
39
38
  print(solver.get_value(x,y,val=10,dec=5)
40
39
  ```
41
40
 
42
41
  # Version History
43
42
 
44
43
  - 8.12.2024 - v0.1 -> only 1st order ODE's are solvable, more features coming soon
44
+ - 15.12.2024 -v0.2 -> security updates, removed plot function
45
45
 
46
46
 
47
47
  ---
@@ -0,0 +1,9 @@
1
+ numODEsolver/__init__.py,sha256=_riAnUkq4KYJB1oRnKV8pRgW3aIkytj2H0ZmtL5YfSk,26
2
+ numODEsolver/solver.py,sha256=UbVGSbjGc1S8uaMi5s3E1F_n9CTXBccCM4X4sYt00Pc,2364
3
+ solver/__init__.py,sha256=_riAnUkq4KYJB1oRnKV8pRgW3aIkytj2H0ZmtL5YfSk,26
4
+ solver/solver.py,sha256=qIdao9ATou9VwgX_KZUY7-NyLKaFiFQycHgr6IhDfmw,2273
5
+ numODEsolver-0.3.dist-info/LICENSE,sha256=B1LP4xi1JhMSHUlkccB-_2VoeKE8r2jbuvGFUzqJ70Y,1065
6
+ numODEsolver-0.3.dist-info/METADATA,sha256=tY3LUa29_LfcwPVqjj9pGbr0llaGDcnzFPBfCEVpKxw,1690
7
+ numODEsolver-0.3.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
8
+ numODEsolver-0.3.dist-info/top_level.txt,sha256=G-8gaHtECVQ5G30bl_5w1UUSZ7L380bwmNo-6_r74hc,13
9
+ numODEsolver-0.3.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- numODEsolver/__init__.py,sha256=_riAnUkq4KYJB1oRnKV8pRgW3aIkytj2H0ZmtL5YfSk,26
2
- numODEsolver/solver.py,sha256=qIdao9ATou9VwgX_KZUY7-NyLKaFiFQycHgr6IhDfmw,2273
3
- solver/__init__.py,sha256=_riAnUkq4KYJB1oRnKV8pRgW3aIkytj2H0ZmtL5YfSk,26
4
- solver/solver.py,sha256=qIdao9ATou9VwgX_KZUY7-NyLKaFiFQycHgr6IhDfmw,2273
5
- numODEsolver-0.2.dist-info/LICENSE,sha256=B1LP4xi1JhMSHUlkccB-_2VoeKE8r2jbuvGFUzqJ70Y,1065
6
- numODEsolver-0.2.dist-info/METADATA,sha256=59otoyM4bFOtK4GBcmbmm-T4igrbV-tVmEhTnjaCLaQ,1672
7
- numODEsolver-0.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
8
- numODEsolver-0.2.dist-info/top_level.txt,sha256=G-8gaHtECVQ5G30bl_5w1UUSZ7L380bwmNo-6_r74hc,13
9
- numODEsolver-0.2.dist-info/RECORD,,