pyfvm 0.5.3__cp315-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.
@@ -0,0 +1,169 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyfvm
3
+ Version: 0.5.3
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: Programming Language :: Python :: 3.15
20
+ Classifier: Topic :: Scientific/Engineering
21
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ Requires-Dist: meshplex<0.23.0,>=0.22.0
25
+ Requires-Dist: numpy
26
+ Requires-Dist: scipy
27
+ Requires-Dist: sphinxcontrib-bibtex
28
+ Requires-Dist: stonefish-license-manager>=0.8
29
+ Requires-Dist: stonefish-runtime>=0.8
30
+ Requires-Dist: sympy
31
+ Requires-Dist: stonefish-runtime>=0.8.1
32
+
33
+ # pyfvm
34
+
35
+ [![PyPi Version](https://img.shields.io/pypi/v/pyfvm.svg?style=flat-square)](https://pypi.org/project/pyfvm)
36
+ [![PyPI pyversions](https://img.shields.io/pypi/pyversions/pyfvm.svg?style=flat-square)](https://pypi.org/pypi/pyfvm/)
37
+ [![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)
38
+ [![PyPi downloads](https://img.shields.io/pypi/dm/pyfvm.svg?style=flat-square)](https://pypistats.org/packages/pyfvm)
39
+
40
+ [![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)
41
+
42
+ Creating finite volume equation systems with ease.
43
+
44
+ pyfvm provides everything that is needed for setting up finite volume equation
45
+ systems. The user needs to specify the finite volume formulation in a
46
+ configuration file, and pyfvm will create the matrix/right-hand side or the
47
+ nonlinear system for it. This package is for everyone who wants to quickly
48
+ construct FVM systems.
49
+
50
+ ### Examples
51
+
52
+ #### Linear equation systems
53
+
54
+ pyfvm works by specifying the residuals, so for solving Poisson's equation with
55
+ Dirichlet boundary conditions, simply do
56
+
57
+ ```python
58
+ import meshplex
59
+ import meshzoo
60
+ import numpy as np
61
+ from scipy.sparse import linalg
62
+
63
+ import pyfvm
64
+ from pyfvm.form_language import Boundary, dS, dV, integrate, n_dot_grad
65
+
66
+
67
+ class Poisson:
68
+ def apply(self, u):
69
+ return integrate(lambda x: -n_dot_grad(u(x)), dS) - integrate(lambda x: 1.0, dV)
70
+
71
+ def dirichlet(self, u):
72
+ return [(lambda x: u(x) - 0.0, Boundary())]
73
+
74
+
75
+ # Create mesh using meshzoo
76
+ vertices, cells = meshzoo.rectangle_tri(
77
+ np.linspace(0.0, 2.0, 401), np.linspace(0.0, 1.0, 201)
78
+ )
79
+ mesh = meshplex.Mesh(vertices, cells)
80
+
81
+ matrix, rhs = pyfvm.discretize_linear(Poisson(), mesh)
82
+
83
+ u = linalg.spsolve(matrix, rhs)
84
+
85
+ mesh.write("out.vtk", point_data={"u": u})
86
+ ```
87
+
88
+ This example uses [meshzoo](https://pypi.org/project/meshzoo) for creating a
89
+ simple mesh, but anything else that provides vertices and cells works as well.
90
+ For example, reading from a wide variety of mesh files is supported (via
91
+ [meshio](https://pypi.org/project/meshio)):
92
+
93
+ <!--pytest.mark.skip-->
94
+
95
+ ```python
96
+ mesh = meshplex.read("pacman.e")
97
+ ```
98
+
99
+ Likewise, [PyAMG](https://github.com/pyamg/pyamg) is a much faster solver for
100
+ this problem
101
+
102
+ <!--pytest.mark.skip-->
103
+
104
+ ```python
105
+ import pyamg
106
+
107
+ ml = pyamg.smoothed_aggregation_solver(matrix)
108
+ u = ml.solve(rhs, tol=1e-10)
109
+ ```
110
+
111
+ More examples are contained in the [examples directory](examples/).
112
+
113
+ #### Nonlinear equation systems
114
+
115
+ Nonlinear systems are treated almost equally; only the discretization and
116
+ obviously the solver call is different. For Bratu's problem:
117
+
118
+ ```python
119
+ import pyfvm
120
+ from pyfvm.form_language import *
121
+ import meshzoo
122
+ import numpy as np
123
+ from sympy import exp
124
+ import meshplex
125
+
126
+
127
+ class Bratu:
128
+ def apply(self, u):
129
+ return integrate(lambda x: -n_dot_grad(u(x)), dS) - integrate(
130
+ lambda x: 2.0 * exp(u(x)), dV
131
+ )
132
+
133
+ def dirichlet(self, u):
134
+ return [(u, Boundary())]
135
+
136
+
137
+ vertices, cells = meshzoo.rectangle_tri(
138
+ np.linspace(0.0, 2.0, 101), np.linspace(0.0, 1.0, 51)
139
+ )
140
+ mesh = meshplex.Mesh(vertices, cells)
141
+
142
+ f, jacobian = pyfvm.discretize(Bratu(), mesh)
143
+
144
+
145
+ def jacobian_solver(u0, rhs):
146
+ from scipy.sparse import linalg
147
+
148
+ jac = jacobian.get_linear_operator(u0)
149
+ return linalg.spsolve(jac, rhs)
150
+
151
+
152
+ u0 = np.zeros(len(vertices))
153
+ u = pyfvm.newton(f.eval, jacobian_solver, u0)
154
+
155
+ mesh.write("out.vtk", point_data={"u": u})
156
+ ```
157
+
158
+ Note that the Jacobian is computed symbolically from the `Bratu` class.
159
+
160
+ Instead of `pyfvm.newton`, you can use any solver that accepts the residual
161
+ computation `f.eval`, e.g.,
162
+
163
+ <!--pytest.mark.skip-->
164
+
165
+ ```python
166
+ import scipy.optimize
167
+
168
+ u = scipy.optimize.newton_krylov(f.eval, u0)
169
+ ```
@@ -0,0 +1,5 @@
1
+ pyfvm-0.5.3.dist-info/METADATA,sha256=tngmilIAHgOqqW-fUpeiPsIiXzB7LUwdIAb3dOYdN2w,5130
2
+ pyfvm-0.5.3.dist-info/WHEEL,sha256=E0bxZwGow566sLu-koO-FIhzqGs-_etk-jdmZvGiCJ0,91
3
+ pyfvm-0.5.3.dist-info/top_level.txt,sha256=KDGgSlY_Zi0py3eTPNYK_69ArscWtdoK4Mfd7xbQWHM,6
4
+ pyfvm.cpython-315.sfc,sha256=H0nb4LrBcW-_L0Ctzj9fHuAZQtA3TGM2pqLbHSzFq_g,69350
5
+ pyfvm-0.5.3.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: stonefish (0.8.1)
3
+ Root-Is-Purelib: true
4
+ Tag: cp315-none-any
5
+
@@ -0,0 +1 @@
1
+ pyfvm
pyfvm.cpython-315.sfc ADDED
Binary file