PyFinitDiff 1.2.3__py3-none-any.whl → 1.3.1.post0__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.
Files changed (60) hide show
  1. PyFinitDiff/__init__.py +8 -0
  2. PyFinitDiff/_version.py +16 -0
  3. PyFinitDiff/finite_difference_1D/__init__.py +6 -6
  4. PyFinitDiff/finite_difference_1D/boundaries.py +113 -30
  5. PyFinitDiff/finite_difference_1D/derivative.py +44 -0
  6. PyFinitDiff/finite_difference_1D/diagonals.py +4 -3
  7. PyFinitDiff/finite_difference_1D/finite_difference.py +21 -7
  8. PyFinitDiff/finite_difference_1D/utils.py +40 -4
  9. PyFinitDiff/finite_difference_2D/__init__.py +5 -7
  10. PyFinitDiff/finite_difference_2D/boundaries.py +103 -23
  11. PyFinitDiff/finite_difference_2D/dense.py +15 -9
  12. PyFinitDiff/finite_difference_2D/derivative.py +18 -29
  13. PyFinitDiff/finite_difference_2D/diagonals.py +147 -91
  14. PyFinitDiff/finite_difference_2D/finite_difference.py +67 -56
  15. PyFinitDiff/finite_difference_2D/utils.py +51 -5
  16. {PyFinitDiff-1.2.3.dist-info → PyFinitDiff-1.3.1.post0.dist-info}/METADATA +31 -11
  17. PyFinitDiff-1.3.1.post0.dist-info/RECORD +28 -0
  18. {PyFinitDiff-1.2.3.dist-info → PyFinitDiff-1.3.1.post0.dist-info}/WHEEL +1 -1
  19. {PyFinitDiff-1.2.3.dist-info → PyFinitDiff-1.3.1.post0.dist-info}/top_level.txt +0 -1
  20. PyFinitDiff/VERSION +0 -1
  21. PyFinitDiff/__pycache__/__init__.cpython-311.pyc +0 -0
  22. PyFinitDiff/__pycache__/triplet.cpython-311.pyc +0 -0
  23. PyFinitDiff/__pycache__/utils.cpython-311.pyc +0 -0
  24. PyFinitDiff/coefficients/__pycache__/__init__.cpython-311.pyc +0 -0
  25. PyFinitDiff/coefficients/__pycache__/backward.cpython-311.pyc +0 -0
  26. PyFinitDiff/coefficients/__pycache__/central.cpython-311.pyc +0 -0
  27. PyFinitDiff/coefficients/__pycache__/forward.cpython-311.pyc +0 -0
  28. PyFinitDiff/finite_difference_1D/__pycache__/__init__.cpython-311.pyc +0 -0
  29. PyFinitDiff/finite_difference_1D/__pycache__/boundaries.cpython-311.pyc +0 -0
  30. PyFinitDiff/finite_difference_1D/__pycache__/derivatives.cpython-311.pyc +0 -0
  31. PyFinitDiff/finite_difference_1D/__pycache__/diagonals.cpython-311.pyc +0 -0
  32. PyFinitDiff/finite_difference_1D/__pycache__/finite_difference.cpython-311.pyc +0 -0
  33. PyFinitDiff/finite_difference_1D/__pycache__/meshes.cpython-311.pyc +0 -0
  34. PyFinitDiff/finite_difference_1D/__pycache__/utils.cpython-311.pyc +0 -0
  35. PyFinitDiff/finite_difference_1D/derivatives.py +0 -53
  36. PyFinitDiff/finite_difference_1D/meshes.py +0 -41
  37. PyFinitDiff/finite_difference_2D/__pycache__/__init__.cpython-311.pyc +0 -0
  38. PyFinitDiff/finite_difference_2D/__pycache__/boundaries.cpython-311.pyc +0 -0
  39. PyFinitDiff/finite_difference_2D/__pycache__/derivative.cpython-311.pyc +0 -0
  40. PyFinitDiff/finite_difference_2D/__pycache__/diagonals.cpython-311.pyc +0 -0
  41. PyFinitDiff/finite_difference_2D/__pycache__/finite_difference.cpython-311.pyc +0 -0
  42. PyFinitDiff/finite_difference_2D/__pycache__/meshes.cpython-311.pyc +0 -0
  43. PyFinitDiff/finite_difference_2D/__pycache__/utils.cpython-311.pyc +0 -0
  44. PyFinitDiff/finite_difference_2D/meshes.py +0 -50
  45. PyFinitDiff-1.2.3.dist-info/RECORD +0 -65
  46. tests/1D/__init__.py +0 -0
  47. tests/1D/__pycache__/__init__.cpython-311.pyc +0 -0
  48. tests/1D/__pycache__/test_api.cpython-311-pytest-8.2.2.pyc +0 -0
  49. tests/1D/__pycache__/test_derivative.cpython-311-pytest-8.2.2.pyc +0 -0
  50. tests/1D/test_api.py +0 -36
  51. tests/1D/test_derivative.py +0 -60
  52. tests/2D/__init__.py +0 -0
  53. tests/2D/__pycache__/__init__.cpython-311.pyc +0 -0
  54. tests/2D/__pycache__/test_api.cpython-311-pytest-8.2.2.pyc +0 -0
  55. tests/2D/__pycache__/test_derivative.cpython-311-pytest-8.2.2.pyc +0 -0
  56. tests/2D/__pycache__/test_eigen.cpython-311-pytest-8.2.2.pyc +0 -0
  57. tests/2D/test_api.py +0 -44
  58. tests/2D/test_derivative.py +0 -76
  59. tests/2D/test_eigen.py +0 -58
  60. {PyFinitDiff-1.2.3.dist-info → PyFinitDiff-1.3.1.post0.dist-info}/LICENSE +0 -0
@@ -1,39 +1,58 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
- from dataclasses import dataclass, field
5
- import PyFinitDiff.finite_difference_2D as module
4
+ from pydantic.dataclasses import dataclass
5
+ from pydantic import ConfigDict
6
+ from dataclasses import field
7
+
6
8
  from PyFinitDiff.coefficients import FiniteCoefficients
7
9
  from PyFinitDiff.triplet import Triplet
10
+ from PyFinitDiff.finite_difference_2D.boundaries import Boundaries
11
+ from PyFinitDiff.finite_difference_2D.utils import MeshInfo
12
+ from PyFinitDiff.finite_difference_2D.diagonals import DiagonalSet, ConstantDiagonal
13
+
14
+
15
+ config_dict = ConfigDict(
16
+ extra='forbid',
17
+ strict=True,
18
+ arbitrary_types_allowed=True,
19
+ kw_only=True,
20
+ frozen=True
21
+ )
8
22
 
9
23
 
10
- @dataclass
24
+ @dataclass(config=config_dict)
11
25
  class FiniteDifference():
12
26
  """
13
- This class represent a specific finit difference configuration, which is defined with the descretization of the mesh, the derivative order,
14
- accuracy and the boundary condition that are defined. More information is providided at the following link: 'math.toronto.edu/mpugh/Teaching/Mat1062/notes2.pdf'
27
+ This class represents a specific finite difference configuration, which is defined
28
+ with the discretization of the mesh, the derivative order, accuracy, and the boundary
29
+ conditions that are defined. More information is provided at the following link:
30
+ 'math.toronto.edu/mpugh/Teaching/Mat1062/notes2.pdf'
31
+
32
+ Attributes:
33
+ n_x (int): Number of points in the x direction.
34
+ n_y (int): Number of points in the y direction.
35
+ dx (float): Infinitesimal displacement in the x direction. Defaults to 1.
36
+ dy (float): Infinitesimal displacement in the y direction. Defaults to 1.
37
+ derivative (int): Derivative order to convert into finite-difference matrix. Defaults to 1.
38
+ accuracy (int): Accuracy of the derivative approximation (error is inversely proportional to the power of this value). Defaults to 2.
39
+ boundaries (Boundaries): Values of the four possible boundaries of the system.
40
+ x_derivative (bool): Add the x derivative. Defaults to True.
41
+ y_derivative (bool): Add the y derivative. Defaults to True.
15
42
  """
16
43
  n_x: int
17
- """ Number of point in the x direction """
18
44
  n_y: int
19
- """ Number of point in the y direction """
20
45
  dx: float = 1
21
- """ Infinetisemal displacement in x direction """
22
46
  dy: float = 1
23
- """ Infinetisemal displacement in y direction """
24
47
  derivative: int = 1
25
- """ Derivative order to convert into finit-difference matrix. """
26
48
  accuracy: int = 2
27
- """ Accuracy of the derivative approximation [error is inversly proportional to the power of that value]. """
28
- boundaries: module.Boundaries = field(default_factory=module.Boundaries())
29
- """ Values of the four possible boundaries of the system. """
49
+ boundaries: Boundaries = field(default_factory=Boundaries)
30
50
  x_derivative: bool = True
31
- """ Add the x derivative """
32
51
  y_derivative: bool = True
33
- """ Add the y derivative """
34
52
 
35
53
  def __post_init__(self):
36
- self.mesh_info = module.MeshInfo(
54
+ """Post-initialization to set up mesh info and finite coefficients."""
55
+ self.mesh_info = MeshInfo(
37
56
  n_x=self.n_x,
38
57
  n_y=self.n_y,
39
58
  dx=self.dx,
@@ -41,7 +60,7 @@ class FiniteDifference():
41
60
  )
42
61
  self.boundaries.mesh_info = self.mesh_info
43
62
 
44
- self.finit_coefficient = FiniteCoefficients(
63
+ self.finite_coefficient = FiniteCoefficients(
45
64
  derivative=self.derivative,
46
65
  accuracy=self.accuracy
47
66
  )
@@ -49,14 +68,17 @@ class FiniteDifference():
49
68
 
50
69
  @property
51
70
  def shape(self):
71
+ """Returns the shape of the mesh as a tuple."""
52
72
  return (self.n_x, self.n_y)
53
73
 
54
74
  @property
55
75
  def triplet(self):
56
76
  """
57
- Triplet representing the non-nul values of the specific
77
+ Triplet representing the non-null values of the specific
58
78
  finite-difference configuration.
59
79
 
80
+ Returns:
81
+ Triplet: The Triplet instance containing the array and shape.
60
82
  """
61
83
  if not self._triplet:
62
84
  self.construct_triplet()
@@ -64,10 +86,12 @@ class FiniteDifference():
64
86
 
65
87
  @property
66
88
  def _dx(self) -> float:
89
+ """Returns the dx value raised to the power of the derivative order."""
67
90
  return self.dx ** self.derivative
68
91
 
69
92
  @property
70
93
  def _dy(self) -> float:
94
+ """Returns the dy value raised to the power of the derivative order."""
71
95
  return self.dy ** self.derivative
72
96
 
73
97
  def iterate_central_coefficient(
@@ -75,46 +99,38 @@ class FiniteDifference():
75
99
  coefficients: str,
76
100
  offset_multiplier: int) -> tuple:
77
101
  """
78
- Iterate throught the given type coefficients
102
+ Iterate through the given type coefficients.
79
103
 
80
- :param coefficient_type: The coefficient type
81
- :type coefficient_type: str
82
- :param offset_multiplier: The offset multiplier
83
- :type offset_multiplier: int
104
+ Args:
105
+ coefficients (str): The coefficient type.
106
+ offset_multiplier (int): The offset multiplier.
84
107
 
85
- :returns: The offset, value, coefficient and boundary type
86
- :rtype: tuple
108
+ Yields:
109
+ tuple: The offset, value, and boundary.
87
110
  """
88
111
  for offset, value in coefficients:
89
112
  offset *= offset_multiplier
90
-
91
113
  boundary = self.boundaries.offset_to_boundary(offset=offset)
92
-
93
114
  yield offset, value, boundary
94
115
 
95
116
  def _add_diagonal_coefficient(
96
117
  self,
97
118
  coefficient_type: str,
98
119
  offset_multiplier: int,
99
- delta: float) -> None:
120
+ delta: float) -> 'DiagonalSet':
100
121
  """
101
122
  Adds a diagonal coefficient to the list of diagonals.
102
123
 
103
- :param coefficient_type: The coefficient type
104
- :type coefficient_type: str
105
- :param diagonals: The diagonals
106
- :type diagonals: list
107
- :param offset_multiplier: The offset multiplier
108
- :type offset_multiplier: int
109
- :param delta: The delta
110
- :type delta: float
111
-
112
- :returns: No return
113
- :rtype: None
114
- """
115
- diagonal_set = module.DiagonalSet(mesh_info=self.mesh_info)
124
+ Args:
125
+ coefficient_type (str): The coefficient type.
126
+ offset_multiplier (int): The offset multiplier.
127
+ delta (float): The delta value.
116
128
 
117
- coefficients = getattr(self.finit_coefficient, coefficient_type)
129
+ Returns:
130
+ DiagonalSet: The diagonal set with added coefficients.
131
+ """
132
+ diagonal_set = DiagonalSet(mesh_info=self.mesh_info)
133
+ coefficients = getattr(self.finite_coefficient, coefficient_type)
118
134
 
119
135
  iterator = self.iterate_central_coefficient(
120
136
  coefficients=coefficients,
@@ -122,31 +138,28 @@ class FiniteDifference():
122
138
  )
123
139
 
124
140
  for offset, value, boundary in iterator:
125
- diagonal = module.ConstantDiagonal(
141
+ diagonal = ConstantDiagonal(
126
142
  mesh_info=self.mesh_info,
127
143
  offset=offset,
128
144
  boundary=boundary,
129
145
  value=value / delta,
130
146
  )
131
-
132
147
  diagonal_set.append(diagonal)
133
148
 
134
149
  diagonal_set.initialize_triplet()
135
-
136
150
  return diagonal_set
137
151
 
138
- def get_diagonal_set_full(self, offset_multiplier: int, delta: float) -> None:
152
+ def get_diagonal_set_full(self, offset_multiplier: int, delta: float) -> 'DiagonalSet':
139
153
  """
140
- Constructs and returns the central coefficents diagonals which is completed with
154
+ Constructs and returns the central coefficients diagonals which is completed with
141
155
  forward and backward coefficients if some 'nan' values are left.
142
156
 
143
- :param offset_multiplier: The offset multiplier
144
- :type offset_multiplier: int
145
- :param delta: The delta
146
- :type delta: float
157
+ Args:
158
+ offset_multiplier (int): The offset multiplier.
159
+ delta (float): The delta value.
147
160
 
148
- :returns: No return
149
- :rtype: None
161
+ Returns:
162
+ DiagonalSet: The full set of diagonal coefficients.
150
163
  """
151
164
  central_diagonal = self._add_diagonal_coefficient(
152
165
  coefficient_type='central',
@@ -167,12 +180,12 @@ class FiniteDifference():
167
180
  )
168
181
 
169
182
  central_diagonal.replace_nan_rows_with(forward_diagonal)
170
-
171
183
  central_diagonal.replace_nan_rows_with(backward_diagonal)
172
184
 
173
185
  return central_diagonal
174
186
 
175
187
  def construct_triplet(self) -> None:
188
+ """Constructs the Triplet instance for the finite-difference configuration."""
176
189
  self._triplet = Triplet(array=[[0, 0, 0]], shape=self.mesh_info.shape)
177
190
 
178
191
  if self.x_derivative:
@@ -180,7 +193,6 @@ class FiniteDifference():
180
193
  offset_multiplier=1,
181
194
  delta=self._dx
182
195
  )
183
-
184
196
  self._triplet += x_diagonals.triplet
185
197
 
186
198
  if self.y_derivative:
@@ -188,7 +200,6 @@ class FiniteDifference():
188
200
  offset_multiplier=self.n_x,
189
201
  delta=self._dy
190
202
  )
191
-
192
203
  self._triplet += y_diagonals.triplet
193
204
 
194
205
 
@@ -1,22 +1,68 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
+ import numpy
5
+ from PyFinitDiff.triplet import DiagonalTriplet
4
6
  from dataclasses import dataclass
5
7
 
6
8
 
7
9
  @dataclass
8
- class MeshInfo():
10
+ class MeshInfo:
11
+ """
12
+ This class represents the mesh information for a finite-difference grid.
13
+
14
+ Attributes:
15
+ n_x (int): Number of points in the x direction.
16
+ n_y (int): Number of points in the y direction.
17
+ dx (float): Infinitesimal displacement in the x direction. Defaults to 1.
18
+ dy (float): Infinitesimal displacement in the y direction. Defaults to 1.
19
+ size (int): Total number of points in the mesh.
20
+ shape (Tuple[int, int]): Shape of the mesh as a tuple.
21
+ """
9
22
  n_x: int
10
- """ Number of point in the x direction """
11
23
  n_y: int
12
- """ Number of point in the y direction """
13
24
  dx: float = 1
14
- """ Infinetisemal displacement in x direction """
15
25
  dy: float = 1
16
- """ Infinetisemal displacement in y direction """
17
26
 
18
27
  def __post_init__(self):
28
+ """Post-initialization to calculate mesh size and shape."""
19
29
  self.size = self.n_x * self.n_y
20
30
  self.shape = (self.n_x, self.n_y)
21
31
 
32
+
33
+ def get_circular_mesh_triplet(
34
+ n_x: int,
35
+ n_y: int,
36
+ radius: float,
37
+ x_offset: float = 0,
38
+ y_offset: float = 0,
39
+ value_out: float = 0,
40
+ value_in: float = 1) -> 'DiagonalTriplet':
41
+ """
42
+ Gets a Triplet corresponding to a 2D mesh with a circular structure of value_in inside and value_out outside.
43
+
44
+ Args:
45
+ n_x (int): The number of points in the x-axis.
46
+ n_y (int): The number of points in the y-axis.
47
+ radius (float): The radius of the circular structure.
48
+ x_offset (float, optional): The x offset of the circular structure. Defaults to 0.
49
+ y_offset (float, optional): The y offset of the circular structure. Defaults to 0.
50
+ value_in (float, optional): The value inside the circular structure. Defaults to 1.
51
+ value_out (float, optional): The value outside the circular structure. Defaults to 0.
52
+
53
+ Returns:
54
+ DiagonalTriplet: The 2D circular mesh triplet.
55
+ """
56
+ y, x = numpy.mgrid[
57
+ -100:100:complex(n_y),
58
+ -100:100:complex(n_x)
59
+ ]
60
+
61
+ r = numpy.sqrt((x - x_offset)**2 + (y - y_offset)**2)
62
+ mesh = numpy.ones(x.shape) * value_out
63
+ mesh[r < radius] = value_in
64
+
65
+ return DiagonalTriplet(mesh, shape=[n_x, n_y])
66
+
67
+
22
68
  # -
@@ -1,37 +1,57 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyFinitDiff
3
- Version: 1.2.3
3
+ Version: 1.3.1.post0
4
4
  Summary: A package finit-difference matrix generation.
5
- Home-page: https://github.com/MartinPdeS/PyFinitDiff
6
- Author: Martin Poinsinet de Sivry
7
- Author-email: Martin.poinsinet.de.sivry@gmail.com
8
- License: MIT
9
- Platform: unix
10
- Platform: linux
11
- Platform: osx
12
- Platform: windows
5
+ Author-email: Martin Poinsinet de Sivry-Houle <martin.poinsinet.de.sivry@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2020 Martin de Sivry
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Keywords: finit-difference,matrix
13
29
  Classifier: Programming Language :: Python
14
30
  Classifier: Programming Language :: Python :: 3
15
31
  Classifier: Programming Language :: Python :: 3.11
32
+ Classifier: Programming Language :: Python :: 3.12
16
33
  Classifier: Programming Language :: Python :: Implementation :: CPython
17
34
  Classifier: Development Status :: 4 - Beta
18
35
  Classifier: Topic :: Scientific/Engineering :: Physics
19
36
  Classifier: License :: OSI Approved :: MIT License
20
37
  Classifier: Intended Audience :: Science/Research
38
+ Requires-Python: >=3.10
21
39
  Description-Content-Type: text/x-rst
22
40
  License-File: LICENSE
23
- Requires-Dist: pydantic ==2.6.3
41
+ Requires-Dist: pydantic >=2.6.3
24
42
  Requires-Dist: numpy
25
43
  Requires-Dist: scipy
26
- Requires-Dist: MPSPlots ==1.4.5
44
+ Requires-Dist: MPSPlots >=1.4.5
27
45
  Requires-Dist: tabulate
28
46
  Provides-Extra: documentation
47
+ Requires-Dist: PyFiberModes ; extra == 'documentation'
29
48
  Requires-Dist: numpydoc ==1.6.0 ; extra == 'documentation'
30
49
  Requires-Dist: sphinx >=5.1.1 ; extra == 'documentation'
31
50
  Requires-Dist: sphinx-gallery ==0.15.0 ; extra == 'documentation'
32
51
  Requires-Dist: sphinx-rtd-theme ==2.0.0 ; extra == 'documentation'
33
52
  Requires-Dist: pydata-sphinx-theme ==0.14.1 ; extra == 'documentation'
34
53
  Provides-Extra: testing
54
+ Requires-Dist: PyFiberModes ; extra == 'testing'
35
55
  Requires-Dist: pytest >=0.6 ; extra == 'testing'
36
56
  Requires-Dist: pytest-cov >=2.0 ; extra == 'testing'
37
57
  Requires-Dist: pytest-json-report ==1.5.0 ; extra == 'testing'
@@ -0,0 +1,28 @@
1
+ PyFinitDiff/__init__.py,sha256=aM48cMAdbYIlGfbEhIvsYBykH2h-u4UpT8DL2utijYQ,121
2
+ PyFinitDiff/_version.py,sha256=m47nb46y08IC1jpKZda94T-n1mypA81rGwZOpPmhrZU,417
3
+ PyFinitDiff/triplet.py,sha256=o_pnW-Y_igF29IosZGQX6WJdX0QZtIGDL2Mu-1X1Ihg,12701
4
+ PyFinitDiff/utils.py,sha256=oKaaG1qbAjJe3Kd9rS86LuylEuoYu2oPeKgTjKtdxME,3175
5
+ PyFinitDiff/coefficients/__init__.py,sha256=D6leOHW6065G9S6rdcQLmTc99bhWJ9OldfR8lWYQJIU,4179
6
+ PyFinitDiff/coefficients/backward.py,sha256=cTti5MkcrhvuJVNURLJqnTcMmSQhdPvRPImu6ZSEsfY,1977
7
+ PyFinitDiff/coefficients/central.py,sha256=Xq1W-yXnTFLNugYwHajl8XynHPWdV7jH6ll2fy_NVSI,2377
8
+ PyFinitDiff/coefficients/forward.py,sha256=znCszjYptZpQiINx_VQXFeLTNKhntm3MV1g7CNOW67E,1973
9
+ PyFinitDiff/finite_difference_1D/__init__.py,sha256=VIxWZB2VhtmtnU-Qz-VDGLIz1V1ufqXHyUxlIAYKgW4,237
10
+ PyFinitDiff/finite_difference_1D/boundaries.py,sha256=2HWURIrSMWLUTn4KoSBXYHZdWQEISzw-m6yZxt7CF3w,6159
11
+ PyFinitDiff/finite_difference_1D/derivative.py,sha256=OK6jN426iXHriiesQSy4hsZEN6z1I6osTw7IUK5aqMY,1476
12
+ PyFinitDiff/finite_difference_1D/diagonals.py,sha256=v6C0bPAApLl4qSwFMeoDPKzg8THlObVm9qc7co8QgnM,7082
13
+ PyFinitDiff/finite_difference_1D/finite_difference.py,sha256=q9UpPDxAxN78iBarW1x8W5UEdHTsE6o2BcXddKBIDXM,5871
14
+ PyFinitDiff/finite_difference_1D/utils.py,sha256=wFToOvAEK3A9VqBf_9e4O3cXRdP_igA_iS-67_5JV3Y,1708
15
+ PyFinitDiff/finite_difference_2D/__init__.py,sha256=TIijlPbN-SiZ9UsaO5zVSZrb5ZsKVm0P63TZ_rjEySU,234
16
+ PyFinitDiff/finite_difference_2D/boundaries.py,sha256=jokzZ1VXq680XLCMsgAxS9Aza_DTmlYN-w2O_IRe33c,7312
17
+ PyFinitDiff/finite_difference_2D/dense.py,sha256=hWcncevb1gSk_-LSHr2SIk5LWy1bcCKN8UKCFI2robM,9199
18
+ PyFinitDiff/finite_difference_2D/derivative.py,sha256=MlO2aGFuxuK5yAf8q8dEOlc3dgRdf68lf1HTFh7IRzo,1820
19
+ PyFinitDiff/finite_difference_2D/diagonals.py,sha256=KPcmx8LoNyUuBQIJC330GUNEdP5UP4mrg__Vtpy1ZQU,9581
20
+ PyFinitDiff/finite_difference_2D/finite_difference.py,sha256=QRMwCjp4iF7jqkp3LqwzOQum2qT_VwRpjl7ZZp73aEI,6889
21
+ PyFinitDiff/finite_difference_2D/utils.py,sha256=OZgp9Wk1NuOEwXSf8PvQyHXOe927K37shu-WDjN21CM,2182
22
+ PyFinitDiff/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
+ PyFinitDiff/tools/directories.py,sha256=CjG37eY-Z68Czo5L7MzHJpu8KEJNhZPnh5VB5MTQ2Tg,837
24
+ PyFinitDiff-1.3.1.post0.dist-info/LICENSE,sha256=U6YG4UEW9XJzHa53oijR0qw6JNN_SZ38WOBmYn3NPd0,1072
25
+ PyFinitDiff-1.3.1.post0.dist-info/METADATA,sha256=W-hsx294Ub0rsFTwhpyEo2XuFFkQTGrS8-Z742p-wuk,5119
26
+ PyFinitDiff-1.3.1.post0.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
27
+ PyFinitDiff-1.3.1.post0.dist-info/top_level.txt,sha256=yl_A1Z9VT4HxBK5PTOM4ZyRcXZb-VtbQo1TzRUc1mW4,12
28
+ PyFinitDiff-1.3.1.post0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (71.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
PyFinitDiff/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.2.3
@@ -1,53 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
-
4
- from PyFinitDiff.coefficients import FiniteCoefficients
5
-
6
- import numpy
7
-
8
-
9
- def get_function_derivative(
10
- function: numpy.ndarray,
11
- x_eval: float,
12
- derivative: int,
13
- delta: float,
14
- function_kwargs: dict,
15
- accuracy: int = 4,
16
- coefficient_type: str = 'central') -> float:
17
- """
18
- Returns the derivative a the given function
19
-
20
- :param function: The function
21
- :type function: function
22
- :param x_eval: parameter to derive
23
- :type x_eval: float
24
- :param order: Differentiation order (1 to 5)
25
- :type order: int
26
- :param n_point: Number of points (3 to 6)
27
- :type n_point: int
28
- :param delta: Distance between points
29
- :type delta: float
30
- :param args: The arguments
31
- :type args: list
32
-
33
- :returns: The value of the derivative
34
- :rtype: float
35
- """
36
- coefficients = FiniteCoefficients(
37
- derivative=derivative,
38
- accuracy=accuracy,
39
- coefficient_type=coefficient_type
40
- )
41
-
42
- summation = 0
43
- for index, value in coefficients:
44
-
45
- x = x_eval + index * delta
46
-
47
- y = function(x, **function_kwargs)
48
-
49
- summation += value * y
50
-
51
- return summation / delta ** derivative
52
-
53
- # -
@@ -1,41 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
-
4
- import numpy
5
-
6
- from PyFinitDiff.triplet import DiagonalTriplet
7
-
8
-
9
- def get_circular_mesh_triplet(
10
- n_x: int,
11
- radius: float,
12
- x_offset: float = 0,
13
- value_out: float = 0,
14
- value_in: float = 1) -> DiagonalTriplet:
15
- """
16
- Gets a Triplet corresponding to a 1d mesh with
17
- circular structure of value_in inside and value_out outside.
18
-
19
- :param n_x: The number of point in the x-axis
20
- :type n_x: int
21
- :param radius: The radius of the structure
22
- :type radius: float
23
- :param x_offset: The x offset of the circular structure
24
- :type x_offset: float
25
- :param value_out: The value inside
26
- :type value_out: float
27
- :param value_in: The value outside
28
- :type value_in: float
29
-
30
- :returns: The 1d circular mesh triplet.
31
- :rtype: DiagonalTriplet
32
- """
33
- x = numpy.linspace(-100, 100, n_x)
34
-
35
- r = numpy.sqrt((x - x_offset)**2)
36
- mesh = numpy.ones(x.shape) * value_out
37
- mesh[r < radius] = value_in
38
-
39
- return DiagonalTriplet(mesh, shape=(n_x,))
40
-
41
- # -
@@ -1,50 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
-
4
- import numpy
5
- from PyFinitDiff.triplet import DiagonalTriplet
6
-
7
-
8
- def get_circular_mesh_triplet(
9
- n_x: int,
10
- n_y: int,
11
- radius: float,
12
- x_offset: float = 0,
13
- y_offset: float = 0,
14
- value_out: float = 0,
15
- value_in: float = 1) -> DiagonalTriplet:
16
- """
17
- Gets a Triplet corresponding to a 2d mesh with
18
- circular structure of value_in inside and value_out outside.
19
-
20
- :param n_x: The number of point in the x-axis
21
- :type n_x: int
22
- :param n_y: The number of point in the y-axis
23
- :type n_y: int
24
- :param radius: The radius of the structure
25
- :type radius: float
26
- :param x_offset: The x offset of the circular structure
27
- :type x_offset: float
28
- :param y_offset: The y offset of the circular structure
29
- :type y_offset: float
30
- :param value_in: The value inside
31
- :type value_in: float
32
- :param value_out: The value outside
33
- :type value_out: float
34
-
35
- :returns: The 2d circular mesh triplet.
36
- :rtype: DiagonalTriplet
37
- """
38
- y, x = numpy.mgrid[
39
- -100:100:complex(n_y),
40
- -100:100:complex(n_x)
41
- ]
42
-
43
- r = numpy.sqrt((x - x_offset)**2 + (y - y_offset)**2)
44
- mesh = numpy.ones(x.shape) * value_out
45
- mesh[r < radius] = value_in
46
-
47
- return DiagonalTriplet(mesh, shape=[n_x, n_y])
48
-
49
-
50
- # -