midas-diffract 0.1.0__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.
- midas_diffract/__init__.py +55 -0
- midas_diffract/forward.py +1559 -0
- midas_diffract/hkls.py +180 -0
- midas_diffract/losses.py +494 -0
- midas_diffract/optimize.py +248 -0
- midas_diffract-0.1.0.dist-info/METADATA +122 -0
- midas_diffract-0.1.0.dist-info/RECORD +10 -0
- midas_diffract-0.1.0.dist-info/WHEEL +5 -0
- midas_diffract-0.1.0.dist-info/licenses/LICENSE +31 -0
- midas_diffract-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""midas-diffract: End-to-end differentiable forward model for HEDM.
|
|
2
|
+
|
|
3
|
+
A PyTorch-based differentiable forward simulator for far-field, near-field,
|
|
4
|
+
and point-focused High-Energy Diffraction Microscopy, with pixel-exact
|
|
5
|
+
agreement against the canonical C reference simulators in MIDAS.
|
|
6
|
+
|
|
7
|
+
See the companion paper for methodology:
|
|
8
|
+
Sharma, Zhang, Andrejevic, Cherukara, "An End-to-End Differentiable Forward
|
|
9
|
+
Model for High-Energy Diffraction Microscopy," IUCrJ (in prep, 2026).
|
|
10
|
+
|
|
11
|
+
Quick start
|
|
12
|
+
-----------
|
|
13
|
+
import torch
|
|
14
|
+
import midas_diffract as md
|
|
15
|
+
|
|
16
|
+
# Construct the forward model from geometry + reflection list
|
|
17
|
+
geom = md.HEDMGeometry(Lsd=..., y_BC=..., z_BC=..., px=..., ...)
|
|
18
|
+
model = md.HEDMForwardModel(hkls=hkls_cart, thetas=thetas,
|
|
19
|
+
geometry=geom, hkls_int=hkls_int)
|
|
20
|
+
|
|
21
|
+
# Forward: grain state -> predicted spots
|
|
22
|
+
euler = torch.tensor([[phi1, Phi, phi2]], requires_grad=True)
|
|
23
|
+
pos = torch.tensor([[x, y, z]], requires_grad=True)
|
|
24
|
+
spots = model(euler, pos, lattice_params=latc)
|
|
25
|
+
|
|
26
|
+
# Scalar loss -> gradient to all inputs via autograd
|
|
27
|
+
loss = (spots.omega * spots.valid).pow(2).sum()
|
|
28
|
+
loss.backward()
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
__version__ = "0.1.0"
|
|
32
|
+
|
|
33
|
+
from .forward import (
|
|
34
|
+
HEDMForwardModel,
|
|
35
|
+
HEDMGeometry,
|
|
36
|
+
ScanConfig,
|
|
37
|
+
TriVoxelConfig,
|
|
38
|
+
SpotDescriptors,
|
|
39
|
+
)
|
|
40
|
+
from .hkls import hkls_for_forward_model
|
|
41
|
+
from .losses import SpotMatchingLoss
|
|
42
|
+
from .optimize import optimize_single_grain, evaluate_recovery
|
|
43
|
+
|
|
44
|
+
__all__ = [
|
|
45
|
+
"HEDMForwardModel",
|
|
46
|
+
"HEDMGeometry",
|
|
47
|
+
"ScanConfig",
|
|
48
|
+
"TriVoxelConfig",
|
|
49
|
+
"SpotDescriptors",
|
|
50
|
+
"SpotMatchingLoss",
|
|
51
|
+
"hkls_for_forward_model",
|
|
52
|
+
"optimize_single_grain",
|
|
53
|
+
"evaluate_recovery",
|
|
54
|
+
"__version__",
|
|
55
|
+
]
|