pyfebio 0.1.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.
Potentially problematic release.
This version of pyfebio might be problematic. Click here for more details.
- pyfebio-0.1.0/PKG-INFO +336 -0
- pyfebio-0.1.0/README.md +323 -0
- pyfebio-0.1.0/pyproject.toml +29 -0
- pyfebio-0.1.0/src/pyfebio/__init__.py +45 -0
- pyfebio-0.1.0/src/pyfebio/_types.py +95 -0
- pyfebio-0.1.0/src/pyfebio/boundary.py +119 -0
- pyfebio-0.1.0/src/pyfebio/constraints.py +41 -0
- pyfebio-0.1.0/src/pyfebio/contact.py +172 -0
- pyfebio-0.1.0/src/pyfebio/control.py +73 -0
- pyfebio-0.1.0/src/pyfebio/discrete.py +40 -0
- pyfebio-0.1.0/src/pyfebio/globals.py +12 -0
- pyfebio-0.1.0/src/pyfebio/include.py +5 -0
- pyfebio-0.1.0/src/pyfebio/initial.py +27 -0
- pyfebio-0.1.0/src/pyfebio/loaddata.py +51 -0
- pyfebio-0.1.0/src/pyfebio/loads.py +55 -0
- pyfebio-0.1.0/src/pyfebio/material.py +1191 -0
- pyfebio-0.1.0/src/pyfebio/mesh.py +354 -0
- pyfebio-0.1.0/src/pyfebio/meshadaptor.py +159 -0
- pyfebio-0.1.0/src/pyfebio/meshdata.py +52 -0
- pyfebio-0.1.0/src/pyfebio/meshdomains.py +65 -0
- pyfebio-0.1.0/src/pyfebio/model.py +144 -0
- pyfebio-0.1.0/src/pyfebio/module.py +14 -0
- pyfebio-0.1.0/src/pyfebio/output.py +298 -0
- pyfebio-0.1.0/src/pyfebio/py.typed +0 -0
- pyfebio-0.1.0/src/pyfebio/rigid.py +275 -0
- pyfebio-0.1.0/src/pyfebio/step.py +28 -0
pyfebio-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyfebio
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python API for the FEBio finite element solver.
|
|
5
|
+
Author: Scott Sibole
|
|
6
|
+
Author-email: Scott Sibole <scott.sibole@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Requires-Dist: lxml>=6.0.1
|
|
9
|
+
Requires-Dist: meshio[all]>=5.3.5
|
|
10
|
+
Requires-Dist: pydantic-xml>=2.17.3
|
|
11
|
+
Requires-Python: >=3.13
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
This is a Python package for generating FEBio input files. We rely heavily on pydantic and pydantic-xml
|
|
17
|
+
for type validation and XML serialization. Many of FEBio's features are covered, but not all.
|
|
18
|
+
|
|
19
|
+
## Getting Started
|
|
20
|
+
|
|
21
|
+
- [Installation](#installation)
|
|
22
|
+
- [Testing](#testing)
|
|
23
|
+
- [Example](#example)
|
|
24
|
+
- [Documentation](https://comporthobiomech.github.io/pyfebio/index.html)
|
|
25
|
+
- [Features](#features)
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
We will build PyPi packages later. For now, you can install from source:
|
|
30
|
+
|
|
31
|
+
Clone with https:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
git clone https://github.com/CompOrthoBiomech/pyfebio.git
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Or,
|
|
38
|
+
|
|
39
|
+
Clone with ssh:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
git clone git@github.com:CompOrthoBiomech/pyfebio.git
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Using uv:**
|
|
46
|
+
|
|
47
|
+
Install uv from [here](https://docs.astral.sh/uv/getting-started/installation/)
|
|
48
|
+
|
|
49
|
+
In top-level repository directory:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
uv sync
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
This will create a virtual environment and install the package.
|
|
56
|
+
|
|
57
|
+
**Using pip:**
|
|
58
|
+
|
|
59
|
+
In top-level repository directory:
|
|
60
|
+
|
|
61
|
+
Create a virtual environment:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
python -m venv .venv
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Activate the virtual environment:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
source .venv/bin/activate
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Install the package:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install .
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
If you want to run the tests, additionally install the dev group dependencies:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
pip install . --group dev
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Testing
|
|
86
|
+
|
|
87
|
+
We rely on FEBio to check our generated models are valid. Therefore, you will need to have FEBio installed and available in your PATH.
|
|
88
|
+
|
|
89
|
+
To run all the tests, execute the following command:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
cd src
|
|
93
|
+
pytest
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
For tests that depend on running finite element simulations, you can find them in the pytest tmp_path directory, which varies by operating system.
|
|
97
|
+
|
|
98
|
+
For the latest run:
|
|
99
|
+
|
|
100
|
+
on Linux,
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
cd /tmp/pytest-of-[USER]/pytest-current/[TEST_FUNCTION_NAME]current
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Example
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
import pyfebio
|
|
110
|
+
|
|
111
|
+
# Instantiate a model tree with default values
|
|
112
|
+
# This contains empty mesh, material, loads, boundary, etc. sections
|
|
113
|
+
my_model = pyfebio.model.Model()
|
|
114
|
+
|
|
115
|
+
# Let's create a single hex8 element explicitly
|
|
116
|
+
# Normally, you would use the meshio functions to import
|
|
117
|
+
nodes_list = [
|
|
118
|
+
[0.0, 0.0, 0.0],
|
|
119
|
+
[1.0, 0.0, 0.0],
|
|
120
|
+
[1.0, 1.0, 0.0],
|
|
121
|
+
[0.0, 1.0, 0.0],
|
|
122
|
+
[0.0, 0.0, 1.0],
|
|
123
|
+
[1.0, 0.0, 1.0],
|
|
124
|
+
[1.0, 1.0, 1.0],
|
|
125
|
+
[0.0, 1.0, 1.0],
|
|
126
|
+
]
|
|
127
|
+
|
|
128
|
+
elements_list = [[1, 2, 3, 4, 5, 6, 7, 8]]
|
|
129
|
+
|
|
130
|
+
# Add Nodes to an pyfebio.Nodes object
|
|
131
|
+
nodes = pyfebio.mesh.Nodes(name="nodes")
|
|
132
|
+
for i, node in enumerate(nodes_list):
|
|
133
|
+
nodes.add_node(pyfebio.mesh.Node(id=i + 1, text=",".join(map(str, node))))
|
|
134
|
+
|
|
135
|
+
# Add Elements to an pyfebio.Elements object
|
|
136
|
+
elements = pyfebio.mesh.Elements(name="box", type="hex8")
|
|
137
|
+
for i, element in enumerate(elements_list):
|
|
138
|
+
elements.add_element(pyfebio.mesh.Hex8Element(id=i + 1, text=",".join(map(str, element))))
|
|
139
|
+
|
|
140
|
+
# Append nodes and elements to the model's mesh section
|
|
141
|
+
my_model.mesh.nodes.append(nodes)
|
|
142
|
+
my_model.mesh.elements.append(elements)
|
|
143
|
+
|
|
144
|
+
# Let's make a node set for top and bottom
|
|
145
|
+
bottom_nodes = [1, 2, 3, 4]
|
|
146
|
+
top_nodes = [5, 6, 7, 8]
|
|
147
|
+
top_node_set = pyfebio.mesh.NodeSet(name="top", text=",".join(map(str, top_nodes)))
|
|
148
|
+
bottom_node_set = pyfebio.mesh.NodeSet(name="bottom", text=",".join(map(str, bottom_nodes)))
|
|
149
|
+
|
|
150
|
+
# Append the node sets to the model's mesh section
|
|
151
|
+
my_model.mesh.node_sets.append(top_node_set)
|
|
152
|
+
my_model.mesh.node_sets.append(bottom_node_set)
|
|
153
|
+
|
|
154
|
+
# We need a material
|
|
155
|
+
# the use of pyfebio.material.MaterialParameter is our solution
|
|
156
|
+
# to handle mapped, math, or directly specified values
|
|
157
|
+
my_material = pyfebio.material.MooneyRivlin(
|
|
158
|
+
id=1,
|
|
159
|
+
name="cartilage",
|
|
160
|
+
c1=pyfebio.material.MaterialParameter(text=10.0),
|
|
161
|
+
c2=pyfebio.material.MaterialParameter(text=1.0),
|
|
162
|
+
k=pyfebio.material.MaterialParameter(text=1000.0),
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
# Define a solid domain for the box to assign the material
|
|
166
|
+
solid_domain = pyfebio.meshdomains.SolidDomain(name="box", mat="cartilage")
|
|
167
|
+
|
|
168
|
+
# add the solid domain
|
|
169
|
+
my_model.mesh_domains.add_solid_domain(solid_domain)
|
|
170
|
+
|
|
171
|
+
# add the material
|
|
172
|
+
my_model.material.add_material(my_material)
|
|
173
|
+
|
|
174
|
+
# Fix the bottom nodes (1 means BC DoF is active)
|
|
175
|
+
fixed_bottom = pyfebio.boundary.BCZeroDisplacement(node_set="bottom",
|
|
176
|
+
x_dof=1,
|
|
177
|
+
y_dof=1,
|
|
178
|
+
z_dof=1)
|
|
179
|
+
|
|
180
|
+
# Displace the top nodes in z
|
|
181
|
+
# We need to create a boundary.Value object that references a load curve
|
|
182
|
+
displacement_value = pyfebio.boundary.Value(lc=1, text=-0.2)
|
|
183
|
+
move_top = pyfebio.boundary.BCPrescribedDisplacement(
|
|
184
|
+
node_set="top", dof="z", value=displacement_value
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
# Add boundary conditions
|
|
188
|
+
my_model.boundary.add_bc(fixed_bottom)
|
|
189
|
+
my_model.boundary.add_bc(move_top)
|
|
190
|
+
|
|
191
|
+
# Now, create the loadcurve 1 we referenced
|
|
192
|
+
curve_points = pyfebio.loaddata.CurvePoints(points=["0.0,0.0", "1.0,1.0"])
|
|
193
|
+
load_curve1 = pyfebio.loaddata.LoadCurve(id=1, points=curve_points)
|
|
194
|
+
# And, add it to model
|
|
195
|
+
my_model.load_data.add_load_curve(load_curve1)
|
|
196
|
+
|
|
197
|
+
# Finally, save the model to disk
|
|
198
|
+
my_model.save("my_model.feb")
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Run the model from the CLI (assuming febio4 is on your PATH):
|
|
202
|
+
|
|
203
|
+
```{bash}
|
|
204
|
+
febio4 -i my_model.feb
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+

|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
## Features
|
|
211
|
+
|
|
212
|
+
Brief overview, see module documentation for more details. Unchecked are not yet implemented.
|
|
213
|
+
|
|
214
|
+
:white_check_mark: Implemented and tested
|
|
215
|
+
|
|
216
|
+
:ballot_box_with_check: Implemented but untested
|
|
217
|
+
|
|
218
|
+
:x: Not yet implemented
|
|
219
|
+
|
|
220
|
+
- Control
|
|
221
|
+
- :white_check_mark: All control settings
|
|
222
|
+
- Mesh Section
|
|
223
|
+
- :white_check_mark: Nodes
|
|
224
|
+
- :white_check_mark: Solid Elements:
|
|
225
|
+
- tet4, tet10, hex8, hex20, hex27, penta6
|
|
226
|
+
- :ballot_box_with_check: Shell Elements:
|
|
227
|
+
- tri3, tri6, quad4, quad8, quad9, q4ans, q4eas
|
|
228
|
+
- :ballot_box_with_check: Beam Elements:
|
|
229
|
+
- line2, line3
|
|
230
|
+
- :white_check_mark: Node, Element, Surface Sets
|
|
231
|
+
- MeshDomain
|
|
232
|
+
- :white_check_mark: Solid Domain
|
|
233
|
+
- :ballot_box_with_check: Shell Domain
|
|
234
|
+
- :ballot_box_with_check: Beam Domain
|
|
235
|
+
- :ballot_box_with_check: Granular control for integration schemes, etc.
|
|
236
|
+
- MeshData Section
|
|
237
|
+
- :ballot_box_with_check: Node Data
|
|
238
|
+
- :ballot_box_with_check: Scalar
|
|
239
|
+
- :ballot_box_with_check: Vector3
|
|
240
|
+
- :ballot_box_with_check: Element Data
|
|
241
|
+
- :ballot_box_with_check: Scalar
|
|
242
|
+
- :ballot_box_with_check: Vector3
|
|
243
|
+
- :x: Surface Data
|
|
244
|
+
- :x: Scalar
|
|
245
|
+
- :x: Vector3
|
|
246
|
+
- MeshAdaptor
|
|
247
|
+
- :ballot_box_with_check: Erosion
|
|
248
|
+
- :white_check_mark: MMG3d Remeshing
|
|
249
|
+
- :white_check_mark: hex_refine
|
|
250
|
+
- :white_check_mark: hex_refine2d
|
|
251
|
+
- :ballot_box_with_check: Criteria
|
|
252
|
+
- :ballot_box_with_check: element selection
|
|
253
|
+
- :ballot_box_with_check: math
|
|
254
|
+
- :ballot_box_with_check: min-max filter
|
|
255
|
+
- :white_check_mark: relative error
|
|
256
|
+
- :white_check_mark: stress
|
|
257
|
+
- :ballot_box_with_check: contact gap
|
|
258
|
+
- :ballot_box_with_check: damage
|
|
259
|
+
- :ballot_box_with_check: max variable
|
|
260
|
+
- Material
|
|
261
|
+
- :white_check_mark: Most Unconstrained Formulation Materials
|
|
262
|
+
- :white_check_mark: Most Uncoupled Formulation Materials
|
|
263
|
+
- :ballot_box_with_check: Prestrain Material
|
|
264
|
+
- :ballot_box_with_check: Fiber models
|
|
265
|
+
- :white_check_mark: Material Axis
|
|
266
|
+
- :white_check_mark: Vector Definition
|
|
267
|
+
- :white_check_mark: Fiber Vector
|
|
268
|
+
- :ballot_box_with_check: Continuous Fiber Distributions
|
|
269
|
+
- :ballot_box_with_check: Integration Schemes
|
|
270
|
+
- :ballot_box_with_check: Element-wise, mapped, or math parameter defintion
|
|
271
|
+
- :white_check_mark: Biphasic Materials
|
|
272
|
+
- :white_check_mark: Viscoelastic Materials
|
|
273
|
+
- :x: Multiphasic Materials
|
|
274
|
+
- :x: Biphasic-solute Materials
|
|
275
|
+
- :x: Chemical Reactions
|
|
276
|
+
- :x: Active Contraction Materials
|
|
277
|
+
- :x: Damage Materials
|
|
278
|
+
- :x: First-order Homogenization
|
|
279
|
+
- Rigid
|
|
280
|
+
- :ballot_box_with_check: Fixed Displacement and Rotation
|
|
281
|
+
- :ballot_box_with_check: Prescribed Displacement and Rotation
|
|
282
|
+
- :ballot_box_with_check: Precribed Rotation about Vector
|
|
283
|
+
- :ballot_box_with_check: Prescribed Euler Rotation
|
|
284
|
+
- :ballot_box_with_check: All Connectors
|
|
285
|
+
- :ballot_box_with_check: Follower Loads
|
|
286
|
+
- Initial
|
|
287
|
+
- :ballot_box_with_check: Initial Velocity
|
|
288
|
+
- :ballot_box_with_check: Initial Pre-strain
|
|
289
|
+
- Loads
|
|
290
|
+
- :ballot_box_with_check: Nodal Loads
|
|
291
|
+
- :ballot_box_with_check: Traction Loads (surface)
|
|
292
|
+
- :ballot_box_with_check: Pressure Loads (surface)
|
|
293
|
+
- :ballot_box_with_check: Fluid Flux (surface)
|
|
294
|
+
- :ballot_box_with_check: Fluid Pressure (surface)
|
|
295
|
+
- LoadData
|
|
296
|
+
- :white_check_mark: Load Curves
|
|
297
|
+
- :balloit_box_with_check: All Options
|
|
298
|
+
- :ballot_box_with_check: PID Controllers
|
|
299
|
+
- :ballot_box_with_check: Math Controllers
|
|
300
|
+
- Boundary
|
|
301
|
+
- :white_check_mark: Fixed Displacement (solid)
|
|
302
|
+
- :white_check_mark: Prescribed Displacement (solid)
|
|
303
|
+
- :ballot_box_with_check: Fixed Displacement (shell)
|
|
304
|
+
- :ballot_box_with_check: Prescribed Displacement (shell)
|
|
305
|
+
- :ballot_box_with_check: Precribed Deformation Gradient
|
|
306
|
+
- :ballot_box_with_check: Displacement Along Normals
|
|
307
|
+
- :ballot_box_with_check: Fix to Rigid Body
|
|
308
|
+
- :white_check_mark: Rigid Node Set Deformation (rotation about axis)
|
|
309
|
+
- :white_check_mark: Zero Fluid Pressure
|
|
310
|
+
- :ballot_box_with_check: Prescribed Fluid Pressure
|
|
311
|
+
- Constraints
|
|
312
|
+
- :ballot_box_with_check: Symmetry Plane
|
|
313
|
+
- :ballot_box_with_check: Prestrain
|
|
314
|
+
- :ballot_box_with_check: In-Situ Stretch
|
|
315
|
+
- Contact
|
|
316
|
+
- :ballot_box_with_check: Sliding
|
|
317
|
+
- :ballot_box_with_check: Elastic
|
|
318
|
+
- :ballot_box_with_check: Facet-Facet
|
|
319
|
+
- :ballot_box_with_check: Node-Facet
|
|
320
|
+
- :ballot_box_with_check: Biphasic
|
|
321
|
+
- :ballot_box_with_check: Sliding2
|
|
322
|
+
- :ballot_box_with_check: Contact Potential Formulation
|
|
323
|
+
- :ballot_box_with_check: Tie
|
|
324
|
+
- :ballot_box_with_check: Elastic
|
|
325
|
+
- :ballot_box_with_check: Facet-Facet
|
|
326
|
+
- :ballot_box_with_check: Node-Facet
|
|
327
|
+
- :ballot_box_with_check: Biphasic
|
|
328
|
+
- Step
|
|
329
|
+
- :ballot_box_with_check: Multistep Analysis
|
|
330
|
+
- Output
|
|
331
|
+
- :ballot_box_with_check: Log File Configuration
|
|
332
|
+
- :ballot_box_with_check: Plot File Configuration
|
|
333
|
+
- :ballot_box_with_check: Node Variables
|
|
334
|
+
- :ballot_box_with_check: Element Variables
|
|
335
|
+
- :ballot_box_with_check: Rigid Body Variables
|
|
336
|
+
- :ballot_box_with_check: Rigid Connector Variables
|
pyfebio-0.1.0/README.md
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
## Overview
|
|
2
|
+
|
|
3
|
+
This is a Python package for generating FEBio input files. We rely heavily on pydantic and pydantic-xml
|
|
4
|
+
for type validation and XML serialization. Many of FEBio's features are covered, but not all.
|
|
5
|
+
|
|
6
|
+
## Getting Started
|
|
7
|
+
|
|
8
|
+
- [Installation](#installation)
|
|
9
|
+
- [Testing](#testing)
|
|
10
|
+
- [Example](#example)
|
|
11
|
+
- [Documentation](https://comporthobiomech.github.io/pyfebio/index.html)
|
|
12
|
+
- [Features](#features)
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
We will build PyPi packages later. For now, you can install from source:
|
|
17
|
+
|
|
18
|
+
Clone with https:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
git clone https://github.com/CompOrthoBiomech/pyfebio.git
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or,
|
|
25
|
+
|
|
26
|
+
Clone with ssh:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
git clone git@github.com:CompOrthoBiomech/pyfebio.git
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Using uv:**
|
|
33
|
+
|
|
34
|
+
Install uv from [here](https://docs.astral.sh/uv/getting-started/installation/)
|
|
35
|
+
|
|
36
|
+
In top-level repository directory:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
uv sync
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This will create a virtual environment and install the package.
|
|
43
|
+
|
|
44
|
+
**Using pip:**
|
|
45
|
+
|
|
46
|
+
In top-level repository directory:
|
|
47
|
+
|
|
48
|
+
Create a virtual environment:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
python -m venv .venv
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Activate the virtual environment:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
source .venv/bin/activate
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Install the package:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install .
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
If you want to run the tests, additionally install the dev group dependencies:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install . --group dev
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Testing
|
|
73
|
+
|
|
74
|
+
We rely on FEBio to check our generated models are valid. Therefore, you will need to have FEBio installed and available in your PATH.
|
|
75
|
+
|
|
76
|
+
To run all the tests, execute the following command:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
cd src
|
|
80
|
+
pytest
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
For tests that depend on running finite element simulations, you can find them in the pytest tmp_path directory, which varies by operating system.
|
|
84
|
+
|
|
85
|
+
For the latest run:
|
|
86
|
+
|
|
87
|
+
on Linux,
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
cd /tmp/pytest-of-[USER]/pytest-current/[TEST_FUNCTION_NAME]current
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Example
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
import pyfebio
|
|
97
|
+
|
|
98
|
+
# Instantiate a model tree with default values
|
|
99
|
+
# This contains empty mesh, material, loads, boundary, etc. sections
|
|
100
|
+
my_model = pyfebio.model.Model()
|
|
101
|
+
|
|
102
|
+
# Let's create a single hex8 element explicitly
|
|
103
|
+
# Normally, you would use the meshio functions to import
|
|
104
|
+
nodes_list = [
|
|
105
|
+
[0.0, 0.0, 0.0],
|
|
106
|
+
[1.0, 0.0, 0.0],
|
|
107
|
+
[1.0, 1.0, 0.0],
|
|
108
|
+
[0.0, 1.0, 0.0],
|
|
109
|
+
[0.0, 0.0, 1.0],
|
|
110
|
+
[1.0, 0.0, 1.0],
|
|
111
|
+
[1.0, 1.0, 1.0],
|
|
112
|
+
[0.0, 1.0, 1.0],
|
|
113
|
+
]
|
|
114
|
+
|
|
115
|
+
elements_list = [[1, 2, 3, 4, 5, 6, 7, 8]]
|
|
116
|
+
|
|
117
|
+
# Add Nodes to an pyfebio.Nodes object
|
|
118
|
+
nodes = pyfebio.mesh.Nodes(name="nodes")
|
|
119
|
+
for i, node in enumerate(nodes_list):
|
|
120
|
+
nodes.add_node(pyfebio.mesh.Node(id=i + 1, text=",".join(map(str, node))))
|
|
121
|
+
|
|
122
|
+
# Add Elements to an pyfebio.Elements object
|
|
123
|
+
elements = pyfebio.mesh.Elements(name="box", type="hex8")
|
|
124
|
+
for i, element in enumerate(elements_list):
|
|
125
|
+
elements.add_element(pyfebio.mesh.Hex8Element(id=i + 1, text=",".join(map(str, element))))
|
|
126
|
+
|
|
127
|
+
# Append nodes and elements to the model's mesh section
|
|
128
|
+
my_model.mesh.nodes.append(nodes)
|
|
129
|
+
my_model.mesh.elements.append(elements)
|
|
130
|
+
|
|
131
|
+
# Let's make a node set for top and bottom
|
|
132
|
+
bottom_nodes = [1, 2, 3, 4]
|
|
133
|
+
top_nodes = [5, 6, 7, 8]
|
|
134
|
+
top_node_set = pyfebio.mesh.NodeSet(name="top", text=",".join(map(str, top_nodes)))
|
|
135
|
+
bottom_node_set = pyfebio.mesh.NodeSet(name="bottom", text=",".join(map(str, bottom_nodes)))
|
|
136
|
+
|
|
137
|
+
# Append the node sets to the model's mesh section
|
|
138
|
+
my_model.mesh.node_sets.append(top_node_set)
|
|
139
|
+
my_model.mesh.node_sets.append(bottom_node_set)
|
|
140
|
+
|
|
141
|
+
# We need a material
|
|
142
|
+
# the use of pyfebio.material.MaterialParameter is our solution
|
|
143
|
+
# to handle mapped, math, or directly specified values
|
|
144
|
+
my_material = pyfebio.material.MooneyRivlin(
|
|
145
|
+
id=1,
|
|
146
|
+
name="cartilage",
|
|
147
|
+
c1=pyfebio.material.MaterialParameter(text=10.0),
|
|
148
|
+
c2=pyfebio.material.MaterialParameter(text=1.0),
|
|
149
|
+
k=pyfebio.material.MaterialParameter(text=1000.0),
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
# Define a solid domain for the box to assign the material
|
|
153
|
+
solid_domain = pyfebio.meshdomains.SolidDomain(name="box", mat="cartilage")
|
|
154
|
+
|
|
155
|
+
# add the solid domain
|
|
156
|
+
my_model.mesh_domains.add_solid_domain(solid_domain)
|
|
157
|
+
|
|
158
|
+
# add the material
|
|
159
|
+
my_model.material.add_material(my_material)
|
|
160
|
+
|
|
161
|
+
# Fix the bottom nodes (1 means BC DoF is active)
|
|
162
|
+
fixed_bottom = pyfebio.boundary.BCZeroDisplacement(node_set="bottom",
|
|
163
|
+
x_dof=1,
|
|
164
|
+
y_dof=1,
|
|
165
|
+
z_dof=1)
|
|
166
|
+
|
|
167
|
+
# Displace the top nodes in z
|
|
168
|
+
# We need to create a boundary.Value object that references a load curve
|
|
169
|
+
displacement_value = pyfebio.boundary.Value(lc=1, text=-0.2)
|
|
170
|
+
move_top = pyfebio.boundary.BCPrescribedDisplacement(
|
|
171
|
+
node_set="top", dof="z", value=displacement_value
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
# Add boundary conditions
|
|
175
|
+
my_model.boundary.add_bc(fixed_bottom)
|
|
176
|
+
my_model.boundary.add_bc(move_top)
|
|
177
|
+
|
|
178
|
+
# Now, create the loadcurve 1 we referenced
|
|
179
|
+
curve_points = pyfebio.loaddata.CurvePoints(points=["0.0,0.0", "1.0,1.0"])
|
|
180
|
+
load_curve1 = pyfebio.loaddata.LoadCurve(id=1, points=curve_points)
|
|
181
|
+
# And, add it to model
|
|
182
|
+
my_model.load_data.add_load_curve(load_curve1)
|
|
183
|
+
|
|
184
|
+
# Finally, save the model to disk
|
|
185
|
+
my_model.save("my_model.feb")
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Run the model from the CLI (assuming febio4 is on your PATH):
|
|
189
|
+
|
|
190
|
+
```{bash}
|
|
191
|
+
febio4 -i my_model.feb
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+

|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
## Features
|
|
198
|
+
|
|
199
|
+
Brief overview, see module documentation for more details. Unchecked are not yet implemented.
|
|
200
|
+
|
|
201
|
+
:white_check_mark: Implemented and tested
|
|
202
|
+
|
|
203
|
+
:ballot_box_with_check: Implemented but untested
|
|
204
|
+
|
|
205
|
+
:x: Not yet implemented
|
|
206
|
+
|
|
207
|
+
- Control
|
|
208
|
+
- :white_check_mark: All control settings
|
|
209
|
+
- Mesh Section
|
|
210
|
+
- :white_check_mark: Nodes
|
|
211
|
+
- :white_check_mark: Solid Elements:
|
|
212
|
+
- tet4, tet10, hex8, hex20, hex27, penta6
|
|
213
|
+
- :ballot_box_with_check: Shell Elements:
|
|
214
|
+
- tri3, tri6, quad4, quad8, quad9, q4ans, q4eas
|
|
215
|
+
- :ballot_box_with_check: Beam Elements:
|
|
216
|
+
- line2, line3
|
|
217
|
+
- :white_check_mark: Node, Element, Surface Sets
|
|
218
|
+
- MeshDomain
|
|
219
|
+
- :white_check_mark: Solid Domain
|
|
220
|
+
- :ballot_box_with_check: Shell Domain
|
|
221
|
+
- :ballot_box_with_check: Beam Domain
|
|
222
|
+
- :ballot_box_with_check: Granular control for integration schemes, etc.
|
|
223
|
+
- MeshData Section
|
|
224
|
+
- :ballot_box_with_check: Node Data
|
|
225
|
+
- :ballot_box_with_check: Scalar
|
|
226
|
+
- :ballot_box_with_check: Vector3
|
|
227
|
+
- :ballot_box_with_check: Element Data
|
|
228
|
+
- :ballot_box_with_check: Scalar
|
|
229
|
+
- :ballot_box_with_check: Vector3
|
|
230
|
+
- :x: Surface Data
|
|
231
|
+
- :x: Scalar
|
|
232
|
+
- :x: Vector3
|
|
233
|
+
- MeshAdaptor
|
|
234
|
+
- :ballot_box_with_check: Erosion
|
|
235
|
+
- :white_check_mark: MMG3d Remeshing
|
|
236
|
+
- :white_check_mark: hex_refine
|
|
237
|
+
- :white_check_mark: hex_refine2d
|
|
238
|
+
- :ballot_box_with_check: Criteria
|
|
239
|
+
- :ballot_box_with_check: element selection
|
|
240
|
+
- :ballot_box_with_check: math
|
|
241
|
+
- :ballot_box_with_check: min-max filter
|
|
242
|
+
- :white_check_mark: relative error
|
|
243
|
+
- :white_check_mark: stress
|
|
244
|
+
- :ballot_box_with_check: contact gap
|
|
245
|
+
- :ballot_box_with_check: damage
|
|
246
|
+
- :ballot_box_with_check: max variable
|
|
247
|
+
- Material
|
|
248
|
+
- :white_check_mark: Most Unconstrained Formulation Materials
|
|
249
|
+
- :white_check_mark: Most Uncoupled Formulation Materials
|
|
250
|
+
- :ballot_box_with_check: Prestrain Material
|
|
251
|
+
- :ballot_box_with_check: Fiber models
|
|
252
|
+
- :white_check_mark: Material Axis
|
|
253
|
+
- :white_check_mark: Vector Definition
|
|
254
|
+
- :white_check_mark: Fiber Vector
|
|
255
|
+
- :ballot_box_with_check: Continuous Fiber Distributions
|
|
256
|
+
- :ballot_box_with_check: Integration Schemes
|
|
257
|
+
- :ballot_box_with_check: Element-wise, mapped, or math parameter defintion
|
|
258
|
+
- :white_check_mark: Biphasic Materials
|
|
259
|
+
- :white_check_mark: Viscoelastic Materials
|
|
260
|
+
- :x: Multiphasic Materials
|
|
261
|
+
- :x: Biphasic-solute Materials
|
|
262
|
+
- :x: Chemical Reactions
|
|
263
|
+
- :x: Active Contraction Materials
|
|
264
|
+
- :x: Damage Materials
|
|
265
|
+
- :x: First-order Homogenization
|
|
266
|
+
- Rigid
|
|
267
|
+
- :ballot_box_with_check: Fixed Displacement and Rotation
|
|
268
|
+
- :ballot_box_with_check: Prescribed Displacement and Rotation
|
|
269
|
+
- :ballot_box_with_check: Precribed Rotation about Vector
|
|
270
|
+
- :ballot_box_with_check: Prescribed Euler Rotation
|
|
271
|
+
- :ballot_box_with_check: All Connectors
|
|
272
|
+
- :ballot_box_with_check: Follower Loads
|
|
273
|
+
- Initial
|
|
274
|
+
- :ballot_box_with_check: Initial Velocity
|
|
275
|
+
- :ballot_box_with_check: Initial Pre-strain
|
|
276
|
+
- Loads
|
|
277
|
+
- :ballot_box_with_check: Nodal Loads
|
|
278
|
+
- :ballot_box_with_check: Traction Loads (surface)
|
|
279
|
+
- :ballot_box_with_check: Pressure Loads (surface)
|
|
280
|
+
- :ballot_box_with_check: Fluid Flux (surface)
|
|
281
|
+
- :ballot_box_with_check: Fluid Pressure (surface)
|
|
282
|
+
- LoadData
|
|
283
|
+
- :white_check_mark: Load Curves
|
|
284
|
+
- :balloit_box_with_check: All Options
|
|
285
|
+
- :ballot_box_with_check: PID Controllers
|
|
286
|
+
- :ballot_box_with_check: Math Controllers
|
|
287
|
+
- Boundary
|
|
288
|
+
- :white_check_mark: Fixed Displacement (solid)
|
|
289
|
+
- :white_check_mark: Prescribed Displacement (solid)
|
|
290
|
+
- :ballot_box_with_check: Fixed Displacement (shell)
|
|
291
|
+
- :ballot_box_with_check: Prescribed Displacement (shell)
|
|
292
|
+
- :ballot_box_with_check: Precribed Deformation Gradient
|
|
293
|
+
- :ballot_box_with_check: Displacement Along Normals
|
|
294
|
+
- :ballot_box_with_check: Fix to Rigid Body
|
|
295
|
+
- :white_check_mark: Rigid Node Set Deformation (rotation about axis)
|
|
296
|
+
- :white_check_mark: Zero Fluid Pressure
|
|
297
|
+
- :ballot_box_with_check: Prescribed Fluid Pressure
|
|
298
|
+
- Constraints
|
|
299
|
+
- :ballot_box_with_check: Symmetry Plane
|
|
300
|
+
- :ballot_box_with_check: Prestrain
|
|
301
|
+
- :ballot_box_with_check: In-Situ Stretch
|
|
302
|
+
- Contact
|
|
303
|
+
- :ballot_box_with_check: Sliding
|
|
304
|
+
- :ballot_box_with_check: Elastic
|
|
305
|
+
- :ballot_box_with_check: Facet-Facet
|
|
306
|
+
- :ballot_box_with_check: Node-Facet
|
|
307
|
+
- :ballot_box_with_check: Biphasic
|
|
308
|
+
- :ballot_box_with_check: Sliding2
|
|
309
|
+
- :ballot_box_with_check: Contact Potential Formulation
|
|
310
|
+
- :ballot_box_with_check: Tie
|
|
311
|
+
- :ballot_box_with_check: Elastic
|
|
312
|
+
- :ballot_box_with_check: Facet-Facet
|
|
313
|
+
- :ballot_box_with_check: Node-Facet
|
|
314
|
+
- :ballot_box_with_check: Biphasic
|
|
315
|
+
- Step
|
|
316
|
+
- :ballot_box_with_check: Multistep Analysis
|
|
317
|
+
- Output
|
|
318
|
+
- :ballot_box_with_check: Log File Configuration
|
|
319
|
+
- :ballot_box_with_check: Plot File Configuration
|
|
320
|
+
- :ballot_box_with_check: Node Variables
|
|
321
|
+
- :ballot_box_with_check: Element Variables
|
|
322
|
+
- :ballot_box_with_check: Rigid Body Variables
|
|
323
|
+
- :ballot_box_with_check: Rigid Connector Variables
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pyfebio"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A Python API for the FEBio finite element solver."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.13"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
authors = [{ name = "Scott Sibole", email = "scott.sibole@gmail.com" }]
|
|
9
|
+
dependencies = [
|
|
10
|
+
"lxml>=6.0.1",
|
|
11
|
+
"meshio[all]>=5.3.5",
|
|
12
|
+
"pydantic-xml>=2.17.3",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[dependency-groups]
|
|
16
|
+
dev = [
|
|
17
|
+
"autodoc-pydantic>=2.2.0",
|
|
18
|
+
"pytest>=8.4.2",
|
|
19
|
+
"pytest-cov>=7.0.0",
|
|
20
|
+
"sphinx>=8.2.3",
|
|
21
|
+
"sphinx-autodoc-typehints>=3.2.0",
|
|
22
|
+
"sphinx-copybutton>=0.5.2",
|
|
23
|
+
"sphinx-rtd-theme>=3.0.2",
|
|
24
|
+
"sphinxcontrib-youtube>=1.4.1",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[build-system]
|
|
28
|
+
requires = ["uv_build>=0.8.13,<0.9.0"]
|
|
29
|
+
build-backend = "uv_build"
|