pyfvm 0.5.0a4__cp313-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.

Potentially problematic release.


This version of pyfvm might be problematic. Click here for more details.

@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyfvm
3
+ Version: 0.5.0a4
4
+ Summary: Finite volume discretizations for Python
5
+ Author-email: Nico Schlömer <nico.schloemer@gmail.com>
6
+ License-Expression: LicenseRef-Proprietary
7
+ Project-URL: Home, https://github.com/meshpro/pyfvm
8
+ Project-URL: Issues, https://github.com/meshpro/pyfvm/issues
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Scientific/Engineering
20
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ Requires-Dist: meshplex<0.22.0,>=0.21.3
24
+ Requires-Dist: npx
25
+ Requires-Dist: numpy
26
+ Requires-Dist: scipy
27
+ Requires-Dist: sphinxcontrib-bibtex
28
+ Requires-Dist: stonefish-license-manager>=0.6
29
+ Requires-Dist: sympy
30
+ Requires-Dist: stonefish-runtime>=0.4.6
31
+
32
+ # pyfvm
33
+
34
+ [![PyPi Version](https://img.shields.io/pypi/v/pyfvm.svg?style=flat-square)](https://pypi.org/project/pyfvm)
35
+ [![PyPI pyversions](https://img.shields.io/pypi/pyversions/pyfvm.svg?style=flat-square)](https://pypi.org/pypi/pyfvm/)
36
+ [![GitHub stars](https://img.shields.io/github/stars/meshpro/pyfvm.svg?style=flat-square&logo=github&label=Stars&logoColor=white)](https://github.com/meshpro/pyfvm)
37
+ [![PyPi downloads](https://img.shields.io/pypi/dm/pyfvm.svg?style=flat-square)](https://pypistats.org/packages/pyfvm)
38
+
39
+ [![Discord](https://img.shields.io/static/v1?logo=discord&logoColor=white&label=chat&message=on%20discord&color=7289da&style=flat-square)](https://discord.gg/hnTJ5MRX2Y)
40
+
41
+ Creating finite volume equation systems with ease.
42
+
43
+ pyfvm provides everything that is needed for setting up finite volume equation
44
+ systems. The user needs to specify the finite volume formulation in a
45
+ configuration file, and pyfvm will create the matrix/right-hand side or the
46
+ nonlinear system for it. This package is for everyone who wants to quickly
47
+ construct FVM systems.
48
+
49
+ ### Examples
50
+
51
+ #### Linear equation systems
52
+
53
+ pyfvm works by specifying the residuals, so for solving Poisson's equation with
54
+ Dirichlet boundary conditions, simply do
55
+
56
+ ```python
57
+ import meshplex
58
+ import meshzoo
59
+ import numpy as np
60
+ from scipy.sparse import linalg
61
+
62
+ import pyfvm
63
+ from pyfvm.form_language import Boundary, dS, dV, integrate, n_dot_grad
64
+
65
+
66
+ class Poisson:
67
+ def apply(self, u):
68
+ return integrate(lambda x: -n_dot_grad(u(x)), dS) - integrate(lambda x: 1.0, dV)
69
+
70
+ def dirichlet(self, u):
71
+ return [(lambda x: u(x) - 0.0, Boundary())]
72
+
73
+
74
+ # Create mesh using meshzoo
75
+ vertices, cells = meshzoo.rectangle_tri(
76
+ np.linspace(0.0, 2.0, 401), np.linspace(0.0, 1.0, 201)
77
+ )
78
+ mesh = meshplex.Mesh(vertices, cells)
79
+
80
+ matrix, rhs = pyfvm.discretize_linear(Poisson(), mesh)
81
+
82
+ u = linalg.spsolve(matrix, rhs)
83
+
84
+ mesh.write("out.vtk", point_data={"u": u})
85
+ ```
86
+
87
+ This example uses [meshzoo](https://pypi.org/project/meshzoo) for creating a
88
+ simple mesh, but anything else that provides vertices and cells works as well.
89
+ For example, reading from a wide variety of mesh files is supported (via
90
+ [meshio](https://pypi.org/project/meshio)):
91
+
92
+ <!--pytest.mark.skip-->
93
+
94
+ ```python
95
+ mesh = meshplex.read("pacman.e")
96
+ ```
97
+
98
+ Likewise, [PyAMG](https://github.com/pyamg/pyamg) is a much faster solver for
99
+ this problem
100
+
101
+ <!--pytest.mark.skip-->
102
+
103
+ ```python
104
+ import pyamg
105
+
106
+ ml = pyamg.smoothed_aggregation_solver(matrix)
107
+ u = ml.solve(rhs, tol=1e-10)
108
+ ```
109
+
110
+ More examples are contained in the [examples directory](examples/).
111
+
112
+ #### Nonlinear equation systems
113
+
114
+ Nonlinear systems are treated almost equally; only the discretization and
115
+ obviously the solver call is different. For Bratu's problem:
116
+
117
+ ```python
118
+ import pyfvm
119
+ from pyfvm.form_language import *
120
+ import meshzoo
121
+ import numpy as np
122
+ from sympy import exp
123
+ import meshplex
124
+
125
+
126
+ class Bratu:
127
+ def apply(self, u):
128
+ return integrate(lambda x: -n_dot_grad(u(x)), dS) - integrate(
129
+ lambda x: 2.0 * exp(u(x)), dV
130
+ )
131
+
132
+ def dirichlet(self, u):
133
+ return [(u, Boundary())]
134
+
135
+
136
+ vertices, cells = meshzoo.rectangle_tri(
137
+ np.linspace(0.0, 2.0, 101), np.linspace(0.0, 1.0, 51)
138
+ )
139
+ mesh = meshplex.Mesh(vertices, cells)
140
+
141
+ f, jacobian = pyfvm.discretize(Bratu(), mesh)
142
+
143
+
144
+ def jacobian_solver(u0, rhs):
145
+ from scipy.sparse import linalg
146
+
147
+ jac = jacobian.get_linear_operator(u0)
148
+ return linalg.spsolve(jac, rhs)
149
+
150
+
151
+ u0 = np.zeros(len(vertices))
152
+ u = pyfvm.newton(f.eval, jacobian_solver, u0)
153
+
154
+ mesh.write("out.vtk", point_data={"u": u})
155
+ ```
156
+
157
+ Note that the Jacobian is computed symbolically from the `Bratu` class.
158
+
159
+ Instead of `pyfvm.newton`, you can use any solver that accepts the residual
160
+ computation `f.eval`, e.g.,
161
+
162
+ <!--pytest.mark.skip-->
163
+
164
+ ```python
165
+ import scipy.optimize
166
+
167
+ u = scipy.optimize.newton_krylov(f.eval, u0)
168
+ ```
@@ -0,0 +1,6 @@
1
+ pyfvm-0.5.0a4.dist-info/METADATA,sha256=SYytlH0a8WlOZcn3gGtYYBWgD9WS9ssRvRFyO3-JHzw,5062
2
+ pyfvm-0.5.0a4.dist-info/RECORD,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ pyfvm-0.5.0a4.dist-info/WHEEL,sha256=2VCZSE_6uCIWxe3OG6Hr4ahEHPwiSWI10DTtiWtCxm0,91
4
+ pyfvm-0.5.0a4.dist-info/top_level.txt,sha256=KDGgSlY_Zi0py3eTPNYK_69ArscWtdoK4Mfd7xbQWHM,6
5
+ pyfvm.cpython-313.sfc,sha256=AnnRuIsTiBO_ZD-KN2aXYOtacSXJskQxAdV2gd7_F2o,56142
6
+ pyfvm-0.5.0a4.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: stonefish (0.7.2)
3
+ Root-Is-Purelib: true
4
+ Tag: cp313-none-any
5
+
@@ -0,0 +1 @@
1
+ pyfvm
pyfvm.cpython-313.sfc ADDED
Binary file