py-materials 2.0.5__tar.gz → 2.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.
- py_materials-2.1.0/.gitignore +225 -0
- {py_materials-2.0.5 → py_materials-2.1.0}/LICENSE +0 -1
- {py_materials-2.0.5 → py_materials-2.1.0}/PKG-INFO +102 -76
- {py_materials-2.0.5 → py_materials-2.1.0}/README.md +94 -71
- py_materials-2.1.0/docs/decisions/README.md +56 -0
- {py_materials-2.0.5 → py_materials-2.1.0}/pyproject.toml +19 -6
- {py_materials-2.0.5 → py_materials-2.1.0}/src/pymat/__init__.py +79 -40
- {py_materials-2.0.5 → py_materials-2.1.0}/src/pymat/core.py +141 -98
- {py_materials-2.0.5 → py_materials-2.1.0}/src/pymat/data/ceramics.toml +0 -1
- {py_materials-2.0.5 → py_materials-2.1.0}/src/pymat/data/electronics.toml +0 -1
- {py_materials-2.0.5 → py_materials-2.1.0}/src/pymat/data/gases.toml +0 -1
- {py_materials-2.0.5 → py_materials-2.1.0}/src/pymat/data/liquids.toml +0 -1
- {py_materials-2.0.5 → py_materials-2.1.0}/src/pymat/data/metals.toml +0 -1
- {py_materials-2.0.5 → py_materials-2.1.0}/src/pymat/data/scintillators.toml +0 -1
- py_materials-2.1.0/src/pymat/elements.py +156 -0
- {py_materials-2.0.5 → py_materials-2.1.0}/src/pymat/enrichers.py +61 -48
- {py_materials-2.0.5 → py_materials-2.1.0}/src/pymat/factories.py +48 -41
- {py_materials-2.0.5 → py_materials-2.1.0}/src/pymat/loader.py +84 -49
- {py_materials-2.0.5 → py_materials-2.1.0}/src/pymat/properties.py +123 -112
- {py_materials-2.0.5 → py_materials-2.1.0}/src/pymat/registry.py +5 -5
- {py_materials-2.0.5 → py_materials-2.1.0}/src/pymat/units.py +0 -6
- {py_materials-2.0.5 → py_materials-2.1.0}/tests/__init__.py +0 -1
- {py_materials-2.0.5 → py_materials-2.1.0}/tests/conftest.py +7 -6
- {py_materials-2.0.5 → py_materials-2.1.0}/tests/test_apply_to.py +78 -76
- {py_materials-2.0.5 → py_materials-2.1.0}/tests/test_core.py +82 -39
- {py_materials-2.0.5 → py_materials-2.1.0}/tests/test_enrichers.py +72 -72
- {py_materials-2.0.5 → py_materials-2.1.0}/tests/test_integration.py +72 -68
- {py_materials-2.0.5 → py_materials-2.1.0}/tests/test_loader.py +73 -52
- {py_materials-2.0.5 → py_materials-2.1.0}/tests/test_properties.py +83 -81
- {py_materials-2.0.5 → py_materials-2.1.0}/tests/test_readme_examples.py +108 -110
- py_materials-2.0.5/.gitignore +0 -142
- {py_materials-2.0.5 → py_materials-2.1.0}/src/pymat/data/plastics.toml +0 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
|
|
204
|
+
# Ruff stuff:
|
|
205
|
+
.ruff_cache/
|
|
206
|
+
|
|
207
|
+
# PyPI configuration file
|
|
208
|
+
.pypirc
|
|
209
|
+
|
|
210
|
+
# Marimo
|
|
211
|
+
marimo/_static/
|
|
212
|
+
marimo/_lsp/
|
|
213
|
+
__marimo__/
|
|
214
|
+
|
|
215
|
+
# Streamlit
|
|
216
|
+
.streamlit/secrets.toml
|
|
217
|
+
|
|
218
|
+
# Personal justfile recipes
|
|
219
|
+
justfile.local
|
|
220
|
+
|
|
221
|
+
# Pre-commit cache
|
|
222
|
+
.pre-commit-cache/
|
|
223
|
+
|
|
224
|
+
# Cursor local config
|
|
225
|
+
.cursor/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: py-materials
|
|
3
|
-
Version: 2.0
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: Hierarchical material library for CAD applications with build123d integration
|
|
5
5
|
Project-URL: Homepage, https://github.com/MorePet/py-mat
|
|
6
6
|
Project-URL: Repository, https://github.com/MorePet/py-mat
|
|
@@ -14,20 +14,23 @@ Classifier: Intended Audience :: Developers
|
|
|
14
14
|
Classifier: Intended Audience :: Science/Research
|
|
15
15
|
Classifier: License :: OSI Approved :: MIT License
|
|
16
16
|
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
21
|
Classifier: Topic :: Scientific/Engineering
|
|
20
22
|
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
21
|
-
Requires-Python: >=3.
|
|
23
|
+
Requires-Python: >=3.10
|
|
22
24
|
Requires-Dist: pint>=0.20
|
|
25
|
+
Requires-Dist: tomli>=1.0.0; python_version == '3.10'
|
|
23
26
|
Provides-Extra: all
|
|
24
|
-
Requires-Dist: build123d>=0.7.0; extra == 'all'
|
|
27
|
+
Requires-Dist: build123d>=0.7.0; (python_version < '3.13') and extra == 'all'
|
|
25
28
|
Requires-Dist: periodictable>=1.6.0; extra == 'all'
|
|
26
29
|
Requires-Dist: pymatgen>=2024.0.0; extra == 'all'
|
|
27
30
|
Provides-Extra: build123d
|
|
28
|
-
Requires-Dist: build123d>=0.7.0; extra == 'build123d'
|
|
31
|
+
Requires-Dist: build123d>=0.7.0; (python_version < '3.13') and extra == 'build123d'
|
|
29
32
|
Provides-Extra: dev
|
|
30
|
-
Requires-Dist: build123d>=0.7.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: build123d>=0.7.0; (python_version < '3.13') and extra == 'dev'
|
|
31
34
|
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
32
35
|
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
33
36
|
Provides-Extra: matproj
|
|
@@ -36,57 +39,81 @@ Provides-Extra: periodictable
|
|
|
36
39
|
Requires-Dist: periodictable>=1.6.0; extra == 'periodictable'
|
|
37
40
|
Description-Content-Type: text/markdown
|
|
38
41
|
|
|
39
|
-
#
|
|
42
|
+
# mat
|
|
40
43
|
|
|
41
|
-
|
|
44
|
+
Material database for CAD and Monte Carlo particle transport.
|
|
45
|
+
|
|
46
|
+
Shared TOML data files with language-specific packages:
|
|
47
|
+
|
|
48
|
+
| Package | Language | Registry | Import |
|
|
49
|
+
|---------|----------|----------|--------|
|
|
50
|
+
| [py-materials](https://pypi.org/project/py-materials/) | Python | PyPI | `import pymat` |
|
|
51
|
+
| [rs-materials](mat-rs/) | Rust | crates.io | `use rs_materials::...` |
|
|
42
52
|
|
|
43
53
|
## Features
|
|
44
54
|
|
|
55
|
+
### Python (py-materials)
|
|
56
|
+
|
|
45
57
|
- **Hierarchical Materials**: Chain grades, tempers, treatments, and vendors
|
|
46
58
|
- **Property Inheritance**: Children inherit parent properties unless overridden
|
|
47
59
|
- **Lazy Loading**: Categories load on first access
|
|
48
|
-
- **TOML Data Storage**: Easy-to-edit material definitions
|
|
49
60
|
- **build123d Integration**: Apply materials to shapes with automatic mass calculation
|
|
50
61
|
- **PBR Rendering**: Physically-based rendering properties for visualization
|
|
51
62
|
- **periodictable Integration**: Auto-fill density from chemical formulas
|
|
52
63
|
- **Factory Functions**: Temperature/pressure-dependent materials (water, air, saline)
|
|
53
|
-
|
|
64
|
+
|
|
65
|
+
### Rust (rs-materials)
|
|
66
|
+
|
|
67
|
+
- **TOML Database Reader**: Loads all 7 material categories with property inheritance
|
|
68
|
+
- **Formula Parser**: Fractional stoichiometry (`Lu1.8Y0.2SiO5` → element/count pairs)
|
|
69
|
+
- **Mass/Atom Fraction Conversion**: Bidirectional with roundtrip correctness
|
|
70
|
+
- **Scintillator Properties**: Light yield, decay time, emission peak, refractive index
|
|
71
|
+
- **Thread-Safe**: `Send + Sync` for `Arc` sharing in multi-threaded transport engines
|
|
54
72
|
|
|
55
73
|
## Installation
|
|
56
74
|
|
|
75
|
+
### Python
|
|
76
|
+
|
|
57
77
|
```bash
|
|
58
78
|
# With uv (recommended)
|
|
59
|
-
uv add git+https://github.com/MorePET/
|
|
79
|
+
uv add git+https://github.com/MorePET/mat.git@latest
|
|
60
80
|
|
|
61
81
|
# Or specify version
|
|
62
|
-
uv add git+https://github.com/MorePET/
|
|
82
|
+
uv add git+https://github.com/MorePET/mat.git@v1.0.0
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Rust
|
|
86
|
+
|
|
87
|
+
```toml
|
|
88
|
+
[dependencies]
|
|
89
|
+
rs-materials = { git = "https://github.com/MorePET/mat.git" }
|
|
63
90
|
```
|
|
64
91
|
|
|
65
92
|
## Quick Start
|
|
66
93
|
|
|
67
94
|
## Creating Materials
|
|
68
|
-
|
|
95
|
+
|
|
69
96
|
Create materials with convenient parameters:
|
|
70
97
|
|
|
71
98
|
```python
|
|
72
99
|
from pymat import Material
|
|
73
|
-
|
|
100
|
+
|
|
74
101
|
# Using convenience parameters
|
|
75
|
-
steel = Material(name="Steel", density=7.85)
|
|
102
|
+
steel = Material(name="Steel", density=7.85)
|
|
76
103
|
# With visualization color
|
|
77
|
-
aluminum = Material(name="Aluminum", density=2.7, color=(0.88, 0.88, 0.88))
|
|
104
|
+
aluminum = Material(name="Aluminum", density=2.7, color=(0.88, 0.88, 0.88))
|
|
78
105
|
# With formula
|
|
79
106
|
lyso = Material(name="LYSO", formula="Lu1.8Y0.2SiO5", density=7.1)
|
|
80
107
|
assert lyso.formula == "Lu1.8Y0.2SiO5"
|
|
81
108
|
```
|
|
82
109
|
|
|
83
110
|
## Using Property Groups
|
|
84
|
-
|
|
111
|
+
|
|
85
112
|
Define multiple properties at once using property group dictionaries:
|
|
86
113
|
|
|
87
114
|
```python
|
|
88
115
|
from pymat import Material
|
|
89
|
-
|
|
116
|
+
|
|
90
117
|
# Define steel with multiple property groups
|
|
91
118
|
steel = Material(
|
|
92
119
|
name="Stainless Steel 304",
|
|
@@ -97,63 +124,63 @@ from pymat import Material
|
|
|
97
124
|
```
|
|
98
125
|
|
|
99
126
|
## Applying Materials to Shapes
|
|
100
|
-
|
|
127
|
+
|
|
101
128
|
Apply materials to build123d shapes for visualization and mass calculation:
|
|
102
129
|
|
|
103
130
|
```python
|
|
104
131
|
from build123d import Box
|
|
105
132
|
from pymat import Material
|
|
106
|
-
|
|
133
|
+
|
|
107
134
|
# Create material
|
|
108
135
|
steel = Material(name="Steel", density=7.85, color=(0.7, 0.7, 0.7))
|
|
109
|
-
|
|
136
|
+
|
|
110
137
|
# Create shape and apply material
|
|
111
138
|
box = Box(10, 10, 10)
|
|
112
139
|
steel.apply_to(box) assert box.color is not None
|
|
113
140
|
```
|
|
114
141
|
|
|
115
142
|
## Chainable Material Hierarchy
|
|
116
|
-
|
|
143
|
+
|
|
117
144
|
Build hierarchies with grades, tempers, and treatments:
|
|
118
145
|
|
|
119
146
|
```python
|
|
120
147
|
from pymat import Material
|
|
121
|
-
|
|
148
|
+
|
|
122
149
|
# Create base stainless steel
|
|
123
150
|
stainless = Material(
|
|
124
151
|
name="Stainless Steel",
|
|
125
152
|
density=8.0,
|
|
126
153
|
thermal={"melting_point": 1450}
|
|
127
154
|
)
|
|
128
|
-
|
|
155
|
+
|
|
129
156
|
# Add grade
|
|
130
|
-
s304 = stainless.grade_("304", name="SS 304", mechanical={"yield_strength": 170})
|
|
157
|
+
s304 = stainless.grade_("304", name="SS 304", mechanical={"yield_strength": 170})
|
|
131
158
|
# Add treatment
|
|
132
159
|
passivated = s304.treatment_("passivated", name="SS 304 Passivated") assert passivated.density == 8.0 # Inherited through chain
|
|
133
160
|
```
|
|
134
161
|
|
|
135
162
|
## Direct Material Access
|
|
136
|
-
|
|
163
|
+
|
|
137
164
|
Load materials and access them directly from the library:
|
|
138
165
|
|
|
139
166
|
```python
|
|
140
167
|
from pymat import stainless, aluminum, lyso
|
|
141
|
-
|
|
168
|
+
|
|
142
169
|
# Direct access to materials
|
|
143
|
-
s316L = stainless.s316L
|
|
144
|
-
al6061 = aluminum.a6061
|
|
170
|
+
s316L = stainless.s316L
|
|
171
|
+
al6061 = aluminum.a6061
|
|
145
172
|
lyso_crystal = lyso
|
|
146
173
|
assert "LYSO" in lyso_crystal.name
|
|
147
174
|
```
|
|
148
175
|
|
|
149
176
|
## Physics Properties vs Visualization
|
|
150
|
-
|
|
151
|
-
Understand the difference between measured optical properties (physics)
|
|
177
|
+
|
|
178
|
+
Understand the difference between measured optical properties (physics)
|
|
152
179
|
and rendering properties (visualization):
|
|
153
180
|
|
|
154
181
|
```python
|
|
155
182
|
from pymat import Material
|
|
156
|
-
|
|
183
|
+
|
|
157
184
|
# Create transparent material
|
|
158
185
|
glass = Material(
|
|
159
186
|
name="Optical Glass",
|
|
@@ -161,18 +188,18 @@ from pymat import Material
|
|
|
161
188
|
optical={"transparency": 95, "refractive_index": 1.517}, # Physics: 95% transmission
|
|
162
189
|
pbr={"transmission": 0.8} # Rendering: how transparent it looks
|
|
163
190
|
)
|
|
164
|
-
|
|
165
|
-
# Physics properties (measured)
|
|
191
|
+
|
|
192
|
+
# Physics properties (measured)
|
|
166
193
|
# Visualization properties (rendering) assert glass.properties.pbr.transmission == 0.8
|
|
167
194
|
```
|
|
168
195
|
|
|
169
196
|
## Scintillator-Specific Properties
|
|
170
|
-
|
|
197
|
+
|
|
171
198
|
Define detector crystals with optical physics properties:
|
|
172
199
|
|
|
173
200
|
```python
|
|
174
201
|
from pymat import Material
|
|
175
|
-
|
|
202
|
+
|
|
176
203
|
lyso_crystal = Material(
|
|
177
204
|
name="LYSO:Ce Crystal",
|
|
178
205
|
density=7.1,
|
|
@@ -188,43 +215,43 @@ from pymat import Material
|
|
|
188
215
|
```
|
|
189
216
|
|
|
190
217
|
## Temperature-Dependent Materials
|
|
191
|
-
|
|
218
|
+
|
|
192
219
|
Use factory functions for materials with properties that depend on external parameters:
|
|
193
220
|
|
|
194
221
|
```python
|
|
195
222
|
from pymat.factories import water
|
|
196
|
-
|
|
223
|
+
|
|
197
224
|
# Water at different temperatures
|
|
198
225
|
cold_water = water(4) # Max density
|
|
199
226
|
room_water = water(20) # Room temperature
|
|
200
|
-
hot_water = water(80) # Heated
|
|
227
|
+
hot_water = water(80) # Heated
|
|
201
228
|
# Verify realistic values assert 0.95 < hot_water.density < 0.98
|
|
202
229
|
```
|
|
203
230
|
|
|
204
231
|
## Air at Different Conditions
|
|
205
|
-
|
|
232
|
+
|
|
206
233
|
Create air material at specific temperature and pressure:
|
|
207
234
|
|
|
208
235
|
```python
|
|
209
236
|
from pymat.factories import air
|
|
210
|
-
|
|
237
|
+
|
|
211
238
|
sea_level = air(15, 1.0) # 15°C, 1 atm
|
|
212
239
|
high_altitude = air(15, 0.5) # 15°C, 0.5 atm (5500m)
|
|
213
|
-
|
|
240
|
+
|
|
214
241
|
assert sea_level.density > high_altitude.density
|
|
215
242
|
```
|
|
216
243
|
|
|
217
244
|
## Saline Solutions
|
|
218
|
-
|
|
245
|
+
|
|
219
246
|
Create solutions with specific concentration and temperature:
|
|
220
247
|
|
|
221
248
|
```python
|
|
222
249
|
from pymat.factories import saline, water
|
|
223
|
-
|
|
250
|
+
|
|
224
251
|
# Physiological saline at body temperature
|
|
225
252
|
phantom = saline(0.9, temperature_c=37)
|
|
226
253
|
# Saline is slightly denser than pure water at same temperature
|
|
227
|
-
pure_water_37 = water(37)
|
|
254
|
+
pure_water_37 = water(37)
|
|
228
255
|
# Seawater (3.5% NaCl) at 20°C
|
|
229
256
|
seawater = saline(3.5, temperature_c=20)
|
|
230
257
|
# Higher concentration = higher density
|
|
@@ -232,120 +259,120 @@ from pymat.factories import saline, water
|
|
|
232
259
|
```
|
|
233
260
|
|
|
234
261
|
## Loading Metal Materials
|
|
235
|
-
|
|
262
|
+
|
|
236
263
|
Access various metal materials from the metals category:
|
|
237
264
|
|
|
238
265
|
```python
|
|
239
266
|
from pymat import stainless, aluminum, copper
|
|
240
|
-
|
|
267
|
+
|
|
241
268
|
# Stainless steel variants
|
|
242
269
|
s304 = stainless.s304
|
|
243
|
-
s316L = stainless.s316L
|
|
270
|
+
s316L = stainless.s316L
|
|
244
271
|
# Aluminum alloys
|
|
245
272
|
al6061 = aluminum.a6061
|
|
246
|
-
al7075 = aluminum.a7075
|
|
273
|
+
al7075 = aluminum.a7075
|
|
247
274
|
# Copper
|
|
248
275
|
copper_material = copper
|
|
249
276
|
assert copper_material.density == 8.96
|
|
250
277
|
```
|
|
251
278
|
|
|
252
279
|
## Plastic Materials
|
|
253
|
-
|
|
280
|
+
|
|
254
281
|
Access plastic materials for 3D printing and engineering:
|
|
255
282
|
|
|
256
283
|
```python
|
|
257
284
|
from pymat import peek, pla, pc, pmma
|
|
258
|
-
|
|
259
|
-
# Engineering plastics
|
|
260
|
-
# 3D printing plastics
|
|
285
|
+
|
|
286
|
+
# Engineering plastics
|
|
287
|
+
# 3D printing plastics
|
|
261
288
|
# Transparent plastics assert pc.properties.optical.transparency == 89
|
|
262
289
|
```
|
|
263
290
|
|
|
264
291
|
## Scintillator Crystals
|
|
265
|
-
|
|
292
|
+
|
|
266
293
|
Access scintillator materials for radiation detectors:
|
|
267
294
|
|
|
268
295
|
```python
|
|
269
296
|
from pymat import lyso, bgo, nai
|
|
270
|
-
|
|
271
|
-
# LYSO crystal
|
|
272
|
-
# BGO crystal
|
|
297
|
+
|
|
298
|
+
# LYSO crystal
|
|
299
|
+
# BGO crystal
|
|
273
300
|
# NaI crystal
|
|
274
301
|
assert nai.properties.optical.light_yield == 38000
|
|
275
302
|
```
|
|
276
303
|
|
|
277
304
|
## Gas Materials
|
|
278
|
-
|
|
305
|
+
|
|
279
306
|
Access gases for simulation and detector design:
|
|
280
307
|
|
|
281
308
|
```python
|
|
282
309
|
from pymat import air, nitrogen, argon, helium, xenon
|
|
283
|
-
|
|
284
|
-
# Common gases at STP
|
|
310
|
+
|
|
311
|
+
# Common gases at STP
|
|
285
312
|
# Detector gases
|
|
286
313
|
assert argon.properties.compliance.radiation_resistant == True
|
|
287
314
|
```
|
|
288
315
|
|
|
289
316
|
## Property Inheritance
|
|
290
|
-
|
|
317
|
+
|
|
291
318
|
Child materials inherit properties from parents unless overridden:
|
|
292
319
|
|
|
293
320
|
```python
|
|
294
321
|
from pymat import Material
|
|
295
|
-
|
|
322
|
+
|
|
296
323
|
# Create material hierarchy
|
|
297
324
|
root = Material(
|
|
298
325
|
name="Base",
|
|
299
326
|
density=7.8,
|
|
300
327
|
thermal={"melting_point": 1500, "thermal_conductivity": 50}
|
|
301
328
|
)
|
|
302
|
-
|
|
303
|
-
grade1 = root.grade_("G1", mechanical={"yield_strength": 400})
|
|
329
|
+
|
|
330
|
+
grade1 = root.grade_("G1", mechanical={"yield_strength": 400})
|
|
304
331
|
# Override inherited property
|
|
305
332
|
grade2 = root.grade_("G2", thermal={"melting_point": 1600})
|
|
306
333
|
assert grade2.properties.thermal.melting_point == 1600 # Overridden
|
|
307
334
|
```
|
|
308
335
|
|
|
309
336
|
## Automatic Mass Calculation
|
|
310
|
-
|
|
337
|
+
|
|
311
338
|
Materials with density automatically calculate shape mass:
|
|
312
339
|
|
|
313
340
|
```python
|
|
314
341
|
from build123d import Box
|
|
315
342
|
from pymat import stainless, aluminum
|
|
316
|
-
|
|
343
|
+
|
|
317
344
|
# 10x10x10 mm³ box = 1000 mm³ = 1 cm³
|
|
318
345
|
steel_box = Box(10, 10, 10)
|
|
319
346
|
stainless.apply_to(steel_box)
|
|
320
|
-
|
|
321
|
-
# Density = 8.0 g/cm³, Volume = 1 cm³ → Mass = 8.0 g
|
|
347
|
+
|
|
348
|
+
# Density = 8.0 g/cm³, Volume = 1 cm³ → Mass = 8.0 g
|
|
322
349
|
# Aluminum box
|
|
323
350
|
al_box = Box(10, 10, 10)
|
|
324
351
|
aluminum.apply_to(al_box)
|
|
325
|
-
|
|
352
|
+
|
|
326
353
|
# Density = 2.7 g/cm³ → Mass = 2.7 g
|
|
327
354
|
assert 2.6 < al_box.mass < 2.8
|
|
328
355
|
```
|
|
329
356
|
|
|
330
357
|
## Material Visualization
|
|
331
|
-
|
|
358
|
+
|
|
332
359
|
Materials render with appropriate colors for visualization:
|
|
333
360
|
|
|
334
361
|
```python
|
|
335
362
|
from build123d import Box
|
|
336
363
|
from pymat import stainless, aluminum, lyso
|
|
337
|
-
|
|
364
|
+
|
|
338
365
|
# Create shapes
|
|
339
366
|
steel_part = Box(10, 10, 10)
|
|
340
367
|
al_part = Box(10, 10, 10)
|
|
341
368
|
crystal = Box(10, 10, 10)
|
|
342
|
-
|
|
369
|
+
|
|
343
370
|
# Apply materials
|
|
344
371
|
stainless.apply_to(steel_part)
|
|
345
372
|
aluminum.apply_to(al_part)
|
|
346
373
|
lyso.apply_to(crystal)
|
|
347
|
-
|
|
348
|
-
# Verify colors are set
|
|
374
|
+
|
|
375
|
+
# Verify colors are set
|
|
349
376
|
# Colors should differ assert crystal.color != steel_part.color
|
|
350
377
|
```
|
|
351
378
|
|
|
@@ -438,6 +465,5 @@ MIT
|
|
|
438
465
|
|
|
439
466
|
## Links
|
|
440
467
|
|
|
441
|
-
- **GitHub**: https://github.com/MorePET/
|
|
442
|
-
- **Issues**: https://github.com/MorePET/
|
|
443
|
-
|
|
468
|
+
- **GitHub**: https://github.com/MorePET/mat
|
|
469
|
+
- **Issues**: https://github.com/MorePET/mat/issues
|