midas-defect 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.
Files changed (93) hide show
  1. midas_defect-0.1.0/LICENSE +31 -0
  2. midas_defect-0.1.0/PKG-INFO +148 -0
  3. midas_defect-0.1.0/README.md +111 -0
  4. midas_defect-0.1.0/midas_defect/__init__.py +16 -0
  5. midas_defect-0.1.0/midas_defect/asterism_fit.py +407 -0
  6. midas_defect-0.1.0/midas_defect/attribution.py +130 -0
  7. midas_defect-0.1.0/midas_defect/bragg_diffuse.py +207 -0
  8. midas_defect-0.1.0/midas_defect/burgers_population.py +170 -0
  9. midas_defect-0.1.0/midas_defect/cli/__init__.py +0 -0
  10. midas_defect-0.1.0/midas_defect/cli/asterism.py +197 -0
  11. midas_defect-0.1.0/midas_defect/cli/polytype.py +131 -0
  12. midas_defect-0.1.0/midas_defect/cli/rods.py +208 -0
  13. midas_defect-0.1.0/midas_defect/contrast_factor.py +484 -0
  14. midas_defect-0.1.0/midas_defect/contrast_factor_hex.py +337 -0
  15. midas_defect-0.1.0/midas_defect/data_io.py +231 -0
  16. midas_defect-0.1.0/midas_defect/defect_tests.py +439 -0
  17. midas_defect-0.1.0/midas_defect/delta_pdf.py +619 -0
  18. midas_defect-0.1.0/midas_defect/detector_qc.py +113 -0
  19. midas_defect-0.1.0/midas_defect/examples/__init__.py +0 -0
  20. midas_defect-0.1.0/midas_defect/examples/copland_fullres_validate.py +72 -0
  21. midas_defect-0.1.0/midas_defect/examples/demk_fcc_end_to_end.py +170 -0
  22. midas_defect-0.1.0/midas_defect/examples/tutorial_size_strain_mosaic.py +99 -0
  23. midas_defect-0.1.0/midas_defect/forward_sim.py +435 -0
  24. midas_defect-0.1.0/midas_defect/geometry.py +449 -0
  25. midas_defect-0.1.0/midas_defect/honesty.py +103 -0
  26. midas_defect-0.1.0/midas_defect/intensity_budget.py +111 -0
  27. midas_defect-0.1.0/midas_defect/lattice.py +212 -0
  28. midas_defect-0.1.0/midas_defect/peakshape.py +175 -0
  29. midas_defect-0.1.0/midas_defect/rod_detect.py +596 -0
  30. midas_defect-0.1.0/midas_defect/seed_index.py +781 -0
  31. midas_defect-0.1.0/midas_defect/subgrain.py +166 -0
  32. midas_defect-0.1.0/midas_defect/types.py +148 -0
  33. midas_defect-0.1.0/midas_defect/viz.py +207 -0
  34. midas_defect-0.1.0/midas_defect/williamson_hall.py +362 -0
  35. midas_defect-0.1.0/midas_defect.egg-info/PKG-INFO +148 -0
  36. midas_defect-0.1.0/midas_defect.egg-info/SOURCES.txt +91 -0
  37. midas_defect-0.1.0/midas_defect.egg-info/dependency_links.txt +1 -0
  38. midas_defect-0.1.0/midas_defect.egg-info/entry_points.txt +5 -0
  39. midas_defect-0.1.0/midas_defect.egg-info/requires.txt +23 -0
  40. midas_defect-0.1.0/midas_defect.egg-info/top_level.txt +1 -0
  41. midas_defect-0.1.0/pyproject.toml +73 -0
  42. midas_defect-0.1.0/setup.cfg +4 -0
  43. midas_defect-0.1.0/tests/test_asterism.py +129 -0
  44. midas_defect-0.1.0/tests/test_asterism_fit.py +281 -0
  45. midas_defect-0.1.0/tests/test_bootstrap.py +198 -0
  46. midas_defect-0.1.0/tests/test_bragg_diffuse.py +81 -0
  47. midas_defect-0.1.0/tests/test_burgers_population.py +71 -0
  48. midas_defect-0.1.0/tests/test_cell_index.py +175 -0
  49. midas_defect-0.1.0/tests/test_cli_polytype.py +49 -0
  50. midas_defect-0.1.0/tests/test_contrast_factor.py +248 -0
  51. midas_defect-0.1.0/tests/test_contrast_factor_hex.py +196 -0
  52. midas_defect-0.1.0/tests/test_cpfem.py +43 -0
  53. midas_defect-0.1.0/tests/test_debye_waller.py +100 -0
  54. midas_defect-0.1.0/tests/test_defect_tests.py +108 -0
  55. midas_defect-0.1.0/tests/test_delta_pdf.py +516 -0
  56. midas_defect-0.1.0/tests/test_demk_experimental_modules.py +148 -0
  57. midas_defect-0.1.0/tests/test_demk_g1592_9r_regression.py +101 -0
  58. midas_defect-0.1.0/tests/test_demk_real_data_regression.py +444 -0
  59. midas_defect-0.1.0/tests/test_detector_qc.py +50 -0
  60. midas_defect-0.1.0/tests/test_distributions.py +143 -0
  61. midas_defect-0.1.0/tests/test_elastic_sc.py +192 -0
  62. midas_defect-0.1.0/tests/test_energy.py +108 -0
  63. midas_defect-0.1.0/tests/test_family_asterism.py +92 -0
  64. midas_defect-0.1.0/tests/test_fault_balance.py +53 -0
  65. midas_defect-0.1.0/tests/test_forward_sim.py +304 -0
  66. midas_defect-0.1.0/tests/test_geometry.py +359 -0
  67. midas_defect-0.1.0/tests/test_geometry_honest_2026.py +169 -0
  68. midas_defect-0.1.0/tests/test_gnd.py +125 -0
  69. midas_defect-0.1.0/tests/test_intensity_budget.py +41 -0
  70. midas_defect-0.1.0/tests/test_lattice.py +210 -0
  71. midas_defect-0.1.0/tests/test_line_profile.py +173 -0
  72. midas_defect-0.1.0/tests/test_modulation_tilt.py +60 -0
  73. midas_defect-0.1.0/tests/test_p1_honesty_2026.py +118 -0
  74. midas_defect-0.1.0/tests/test_peakshape.py +96 -0
  75. midas_defect-0.1.0/tests/test_phases.py +159 -0
  76. midas_defect-0.1.0/tests/test_polytype.py +84 -0
  77. midas_defect-0.1.0/tests/test_polytype_productized_2026.py +230 -0
  78. midas_defect-0.1.0/tests/test_real_data_regression.py +40 -0
  79. midas_defect-0.1.0/tests/test_reports.py +142 -0
  80. midas_defect-0.1.0/tests/test_rod_detect.py +317 -0
  81. midas_defect-0.1.0/tests/test_satellite_doublet.py +101 -0
  82. midas_defect-0.1.0/tests/test_satellite_ladder.py +93 -0
  83. midas_defect-0.1.0/tests/test_schmid.py +93 -0
  84. midas_defect-0.1.0/tests/test_seed_index.py +400 -0
  85. midas_defect-0.1.0/tests/test_spatial.py +114 -0
  86. midas_defect-0.1.0/tests/test_strain.py +102 -0
  87. midas_defect-0.1.0/tests/test_stress.py +183 -0
  88. midas_defect-0.1.0/tests/test_subgrain.py +88 -0
  89. midas_defect-0.1.0/tests/test_synthetic_regression.py +543 -0
  90. midas_defect-0.1.0/tests/test_thermodynamics.py +78 -0
  91. midas_defect-0.1.0/tests/test_types.py +113 -0
  92. midas_defect-0.1.0/tests/test_variants.py +149 -0
  93. midas_defect-0.1.0/tests/test_williamson_hall.py +214 -0
@@ -0,0 +1,31 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, UChicago Argonne, LLC, operator of Argonne National
4
+ Laboratory, and the midas-diffract authors.
5
+ All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without
8
+ modification, are permitted provided that the following conditions are met:
9
+
10
+ 1. Redistributions of source code must retain the above copyright notice,
11
+ this list of conditions and the following disclaimer.
12
+
13
+ 2. Redistributions in binary form must reproduce the above copyright notice,
14
+ this list of conditions and the following disclaimer in the documentation
15
+ and/or other materials provided with the distribution.
16
+
17
+ 3. Neither the name of the copyright holder nor the names of its
18
+ contributors may be used to endorse or promote products derived from
19
+ this software without specific prior written permission.
20
+
21
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
+ POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,148 @@
1
+ Metadata-Version: 2.4
2
+ Name: midas-defect
3
+ Version: 0.1.0
4
+ Summary: Differentiable, phase-agnostic diffuse-scattering defect metrology on top of standard FF-HEDM: intensity-budget closure, per-grain dislocation density, fault-rod and selection-rule tests.
5
+ Author-email: Hemant Sharma <hsharma@anl.gov>
6
+ License-Expression: BSD-3-Clause
7
+ Classifier: Development Status :: 2 - Pre-Alpha
8
+ Classifier: Intended Audience :: Science/Research
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Topic :: Scientific/Engineering :: Physics
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: numpy>=1.20
16
+ Requires-Dist: torch>=2.0
17
+ Requires-Dist: pandas>=1.5
18
+ Requires-Dist: scipy>=1.10
19
+ Requires-Dist: tifffile>=2023.0
20
+ Requires-Dist: zarr>=2.14
21
+ Requires-Dist: midas-transforms>=0.1
22
+ Requires-Dist: midas-hkls>=0.1
23
+ Requires-Dist: midas-stress>=0.1
24
+ Requires-Dist: midas-diffract>=0.1
25
+ Requires-Dist: midas-index>=0.1
26
+ Requires-Dist: midas-peakfit>=0.1
27
+ Requires-Dist: midas-invert>=0.1
28
+ Provides-Extra: viz
29
+ Requires-Dist: plotly>=5.0; extra == "viz"
30
+ Requires-Dist: zarr>=2.14; extra == "viz"
31
+ Requires-Dist: matplotlib>=3.5; extra == "viz"
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest>=7.0; extra == "dev"
34
+ Requires-Dist: pytest-benchmark>=4.0; extra == "dev"
35
+ Requires-Dist: matplotlib>=3.5; extra == "dev"
36
+ Dynamic: license-file
37
+
38
+ # midas-defect
39
+
40
+ Differentiable **diffuse-scattering defect metrology** layered on top of standard
41
+ far-field HEDM.
42
+
43
+ The standard MIDAS chain (`midas_index → midas_fit_grain → midas_process_grains`,
44
+ with `midas_transforms` for the detector model and `midas_stress` for
45
+ orientations) operates on **detected Bragg peaks** and returns **grains**. It
46
+ discards everything between and around the peaks. For a deformed material that
47
+ diffuse field is not noise — it is the defect signal:
48
+
49
+ - **Asterism** — extended, anisotropic intensity hugging each Bragg core,
50
+ encoding the dislocation strain field and orientation gradient. Quantifying it
51
+ gives a per-grain **dislocation density** (Williamson–Hall on radial breadth).
52
+ - **Rods** in q-space — 1-D streaks threading several Bragg shells along
53
+ low-index directions, the reciprocal-space signature of planar defects
54
+ (stacking faults, twin walls). For FCC, faults on {111} ⇒ ⟨111⟩ rods.
55
+ - **The full intensity budget** — classifying *every* above-threshold voxel
56
+ against the predicted reciprocal lattice of the indexed grains lets the
57
+ scattered intensity be **decomposed and closed at 100 %** (Bragg / near-Bragg
58
+ asterism / inter-Bragg diffuse / low-q halo). Closure is what licenses
59
+ *quantitative* statements ("31 % dislocation asterism, 4 % fault rods")
60
+ instead of qualitative ones.
61
+ - **Selection-rule / forbidden-reflection tests** and **3D-ΔPDF** — phase and
62
+ defect-symmetry checks (no second phase, no anti-phase boundaries).
63
+
64
+ This package is the productized, tested form of that whole-field, post-indexing
65
+ diffuse layer.
66
+
67
+ **Phase-agnostic by design.** Every analysis module is driven by a
68
+ `midas_hkls.Crystal` + a `Geometry`; nothing is hard-wired to FCC. The demk
69
+ default is `lattice.fcc_cu_crystal()`, but `lattice.cual2_crystal()` (tetragonal
70
+ θ-Al₂Cu) is retained as a first-class phase — a future CuAl₂ sample that genuinely
71
+ shows superstructure rods is precisely the case the rod / forward-sim / ΔPDF
72
+ machinery was built for, and re-points by swapping the crystal cell.
73
+
74
+ **Shippable notebooks.** [`midas_defect/examples/`](midas_defect/examples/) holds
75
+ end-to-end notebooks parameterized by `(Crystal, Geometry, data)`. The flagship
76
+ reproduces the demk FCC defect inventory (index → budget → ρ → rods → forbidden)
77
+ and is runnable by external collaborators; the same notebook re-points to a
78
+ CuAl₂ dataset by editing one cell.
79
+
80
+ See [`implementation_plan.md`](implementation_plan.md) for the analysis pipelines,
81
+ the MIDAS reuse map, and the test/CI architecture.
82
+
83
+ ## Status
84
+
85
+ Re-scoped 2026-05-21 after the demk FCC re-analysis. The package's original v0.1
86
+ framing — "heavily-deformed *single crystal*, treat the pattern as a continuous
87
+ field because the standard pipeline cannot index it" — is **retired**: on the
88
+ driving dataset the standard pipeline indexes cleanly (~250 grains/layer), the
89
+ material is an ordinary FCC polycrystal/sub-grain mosaic, and the diffuse field
90
+ is dominated by dislocation asterism (~31 %) over rods (~4 %). The corrected
91
+ scope is **diffuse defect metrology on top of, not instead of, standard
92
+ FF-HEDM**.
93
+
94
+ Pre-alpha. v0.1 target: shared infrastructure (`geometry`, `lattice`,
95
+ `bragg_diffuse`) + the three capabilities that close the budget
96
+ (`intensity_budget`, `williamson_hall`, `defect_tests`), each validated to
97
+ reproduce the published demk numbers. Rod/asterism/sub-grain/ΔPDF/forward-sim
98
+ modules exist and pass synthetic tests; they promote once anchored to real-data
99
+ regressions.
100
+
101
+ ## Module status
102
+
103
+ The **validated core** (v0.1) is anchored to the published demk full-res numbers;
104
+ the rest is synthetic-tested and promotes once anchored to real data.
105
+
106
+ | module | status | notes |
107
+ |---|---|---|
108
+ | `geometry` | **core** | MIDAS-canonical detector model (reuses `apply_tilt_distortion`), ω about Z |
109
+ | `lattice` | **core** | FCC + tetragonal CuAl₂, phase-agnostic shells |
110
+ | `bragg_diffuse` | **core** | full-field classifier + geometry QC (96.4 % on-lattice) |
111
+ | `intensity_budget` | **core** | 4-bin partition, closes to 100 % |
112
+ | `williamson_hall` | **core** | per-grain dislocation density (radial-breadth, FCC b) + modified WH (contrast-corrected) |
113
+ | `contrast_factor` | **core** | anisotropic dislocation contrast factors C̄_hkl (Stroh/sextic, ANIZC); cubic; validated to the silver C=0.3843 worked example; symmetry-general single-dislocation core |
114
+ | `contrast_factor_hex` | **core** | hexagonal contrast factors (Dragomir & Ungár 2002): 11 sub-slip-systems, C̄=C̄_{hk.0}(1+q₁x+q₂x²); validated to Table 2 (Ti+Zr, all systems ≤~3%) |
115
+ | `burgers_population` | **core** | ⟨a⟩/⟨c⟩/⟨c+a⟩ Burgers-vector-type fractions from measured (q₁,q₂); reproduces deformed-Ti 75/20/5 % |
116
+ | `defect_tests` | **core** | forbidden-reflection, fault-rod (explicit), fault-α |
117
+ | `examples` | **core** | end-to-end inventory driver + notebook |
118
+ | `rod_detect`, `asterism_fit`, `subgrain`, `delta_pdf`, `forward_sim`, `seed_index` | *experimental* | synthetic-tested; the deformation-physics layer / future genuine-CuAl₂ rod data |
119
+
120
+ `defect_tests.rod_family_enrichment` is a **screening** metric only — confounded by
121
+ reciprocal-lattice geometry; use `fault_rod_alignment` (explicit per-grain) for the
122
+ authoritative ⟨111⟩ fault-rod test.
123
+
124
+ ## Driving dataset
125
+
126
+ Sep-2025 1-ID-E beamtime — 10 Y-layers × 1440 ω-frames @ 0.25°/frame on Pilatus3
127
+ CdTe 2M, 71.676 keV (λ = 0.172979 Å). **Phase: FCC Cu(-rich solid solution),
128
+ a = 3.6356 Å** (space group 225). θ-Al₂Cu (CuAl₂, I4/mcm, a ≈ 6.066 Å) was the
129
+ a-priori candidate given the Cu–Al provenance and was **tested and eliminated**
130
+ from the powder line-out (the 1/d² ring sequence is the exact FCC fingerprint;
131
+ CuAl₂'s strongest (110) line at d = 4.29 Å is absent). The validated
132
+ gold-calibrant detector geometry (Lsd 652.7 mm, tilts + distortion, correct ω
133
+ sign) is the default in `geometry.demk_default_geometry()`.
134
+
135
+ Published analysis (the worked validation case for this package):
136
+ `~/Desktop/analysis/demk/fcc_reanalysis/` (FINDINGS.md + figures + scripts).
137
+
138
+ ## Engineering contract
139
+
140
+ All modules satisfy ALL four:
141
+
142
+ 1. **Differentiable**. Every physics / scoring / fitting routine is torch;
143
+ numpy / scipy live only in `_discrete` helpers off the gradient path.
144
+ 2. **Device portable**. CPU / CUDA / MPS via `midas_transforms.device.resolve_device`.
145
+ 3. **Thoroughly tested**. Per module: synthetic + autograd + device + **real-data
146
+ regression** (reproduces a published demk number) + benchmark.
147
+ 4. **Reuses upstream MIDAS**. No re-ported orientation, lattice, transform, or
148
+ device-resolution code. See the reuse map in `implementation_plan.md`.
@@ -0,0 +1,111 @@
1
+ # midas-defect
2
+
3
+ Differentiable **diffuse-scattering defect metrology** layered on top of standard
4
+ far-field HEDM.
5
+
6
+ The standard MIDAS chain (`midas_index → midas_fit_grain → midas_process_grains`,
7
+ with `midas_transforms` for the detector model and `midas_stress` for
8
+ orientations) operates on **detected Bragg peaks** and returns **grains**. It
9
+ discards everything between and around the peaks. For a deformed material that
10
+ diffuse field is not noise — it is the defect signal:
11
+
12
+ - **Asterism** — extended, anisotropic intensity hugging each Bragg core,
13
+ encoding the dislocation strain field and orientation gradient. Quantifying it
14
+ gives a per-grain **dislocation density** (Williamson–Hall on radial breadth).
15
+ - **Rods** in q-space — 1-D streaks threading several Bragg shells along
16
+ low-index directions, the reciprocal-space signature of planar defects
17
+ (stacking faults, twin walls). For FCC, faults on {111} ⇒ ⟨111⟩ rods.
18
+ - **The full intensity budget** — classifying *every* above-threshold voxel
19
+ against the predicted reciprocal lattice of the indexed grains lets the
20
+ scattered intensity be **decomposed and closed at 100 %** (Bragg / near-Bragg
21
+ asterism / inter-Bragg diffuse / low-q halo). Closure is what licenses
22
+ *quantitative* statements ("31 % dislocation asterism, 4 % fault rods")
23
+ instead of qualitative ones.
24
+ - **Selection-rule / forbidden-reflection tests** and **3D-ΔPDF** — phase and
25
+ defect-symmetry checks (no second phase, no anti-phase boundaries).
26
+
27
+ This package is the productized, tested form of that whole-field, post-indexing
28
+ diffuse layer.
29
+
30
+ **Phase-agnostic by design.** Every analysis module is driven by a
31
+ `midas_hkls.Crystal` + a `Geometry`; nothing is hard-wired to FCC. The demk
32
+ default is `lattice.fcc_cu_crystal()`, but `lattice.cual2_crystal()` (tetragonal
33
+ θ-Al₂Cu) is retained as a first-class phase — a future CuAl₂ sample that genuinely
34
+ shows superstructure rods is precisely the case the rod / forward-sim / ΔPDF
35
+ machinery was built for, and re-points by swapping the crystal cell.
36
+
37
+ **Shippable notebooks.** [`midas_defect/examples/`](midas_defect/examples/) holds
38
+ end-to-end notebooks parameterized by `(Crystal, Geometry, data)`. The flagship
39
+ reproduces the demk FCC defect inventory (index → budget → ρ → rods → forbidden)
40
+ and is runnable by external collaborators; the same notebook re-points to a
41
+ CuAl₂ dataset by editing one cell.
42
+
43
+ See [`implementation_plan.md`](implementation_plan.md) for the analysis pipelines,
44
+ the MIDAS reuse map, and the test/CI architecture.
45
+
46
+ ## Status
47
+
48
+ Re-scoped 2026-05-21 after the demk FCC re-analysis. The package's original v0.1
49
+ framing — "heavily-deformed *single crystal*, treat the pattern as a continuous
50
+ field because the standard pipeline cannot index it" — is **retired**: on the
51
+ driving dataset the standard pipeline indexes cleanly (~250 grains/layer), the
52
+ material is an ordinary FCC polycrystal/sub-grain mosaic, and the diffuse field
53
+ is dominated by dislocation asterism (~31 %) over rods (~4 %). The corrected
54
+ scope is **diffuse defect metrology on top of, not instead of, standard
55
+ FF-HEDM**.
56
+
57
+ Pre-alpha. v0.1 target: shared infrastructure (`geometry`, `lattice`,
58
+ `bragg_diffuse`) + the three capabilities that close the budget
59
+ (`intensity_budget`, `williamson_hall`, `defect_tests`), each validated to
60
+ reproduce the published demk numbers. Rod/asterism/sub-grain/ΔPDF/forward-sim
61
+ modules exist and pass synthetic tests; they promote once anchored to real-data
62
+ regressions.
63
+
64
+ ## Module status
65
+
66
+ The **validated core** (v0.1) is anchored to the published demk full-res numbers;
67
+ the rest is synthetic-tested and promotes once anchored to real data.
68
+
69
+ | module | status | notes |
70
+ |---|---|---|
71
+ | `geometry` | **core** | MIDAS-canonical detector model (reuses `apply_tilt_distortion`), ω about Z |
72
+ | `lattice` | **core** | FCC + tetragonal CuAl₂, phase-agnostic shells |
73
+ | `bragg_diffuse` | **core** | full-field classifier + geometry QC (96.4 % on-lattice) |
74
+ | `intensity_budget` | **core** | 4-bin partition, closes to 100 % |
75
+ | `williamson_hall` | **core** | per-grain dislocation density (radial-breadth, FCC b) + modified WH (contrast-corrected) |
76
+ | `contrast_factor` | **core** | anisotropic dislocation contrast factors C̄_hkl (Stroh/sextic, ANIZC); cubic; validated to the silver C=0.3843 worked example; symmetry-general single-dislocation core |
77
+ | `contrast_factor_hex` | **core** | hexagonal contrast factors (Dragomir & Ungár 2002): 11 sub-slip-systems, C̄=C̄_{hk.0}(1+q₁x+q₂x²); validated to Table 2 (Ti+Zr, all systems ≤~3%) |
78
+ | `burgers_population` | **core** | ⟨a⟩/⟨c⟩/⟨c+a⟩ Burgers-vector-type fractions from measured (q₁,q₂); reproduces deformed-Ti 75/20/5 % |
79
+ | `defect_tests` | **core** | forbidden-reflection, fault-rod (explicit), fault-α |
80
+ | `examples` | **core** | end-to-end inventory driver + notebook |
81
+ | `rod_detect`, `asterism_fit`, `subgrain`, `delta_pdf`, `forward_sim`, `seed_index` | *experimental* | synthetic-tested; the deformation-physics layer / future genuine-CuAl₂ rod data |
82
+
83
+ `defect_tests.rod_family_enrichment` is a **screening** metric only — confounded by
84
+ reciprocal-lattice geometry; use `fault_rod_alignment` (explicit per-grain) for the
85
+ authoritative ⟨111⟩ fault-rod test.
86
+
87
+ ## Driving dataset
88
+
89
+ Sep-2025 1-ID-E beamtime — 10 Y-layers × 1440 ω-frames @ 0.25°/frame on Pilatus3
90
+ CdTe 2M, 71.676 keV (λ = 0.172979 Å). **Phase: FCC Cu(-rich solid solution),
91
+ a = 3.6356 Å** (space group 225). θ-Al₂Cu (CuAl₂, I4/mcm, a ≈ 6.066 Å) was the
92
+ a-priori candidate given the Cu–Al provenance and was **tested and eliminated**
93
+ from the powder line-out (the 1/d² ring sequence is the exact FCC fingerprint;
94
+ CuAl₂'s strongest (110) line at d = 4.29 Å is absent). The validated
95
+ gold-calibrant detector geometry (Lsd 652.7 mm, tilts + distortion, correct ω
96
+ sign) is the default in `geometry.demk_default_geometry()`.
97
+
98
+ Published analysis (the worked validation case for this package):
99
+ `~/Desktop/analysis/demk/fcc_reanalysis/` (FINDINGS.md + figures + scripts).
100
+
101
+ ## Engineering contract
102
+
103
+ All modules satisfy ALL four:
104
+
105
+ 1. **Differentiable**. Every physics / scoring / fitting routine is torch;
106
+ numpy / scipy live only in `_discrete` helpers off the gradient path.
107
+ 2. **Device portable**. CPU / CUDA / MPS via `midas_transforms.device.resolve_device`.
108
+ 3. **Thoroughly tested**. Per module: synthetic + autograd + device + **real-data
109
+ regression** (reproduces a published demk number) + benchmark.
110
+ 4. **Reuses upstream MIDAS**. No re-ported orientation, lattice, transform, or
111
+ device-resolution code. See the reuse map in `implementation_plan.md`.
@@ -0,0 +1,16 @@
1
+ """midas_defect — phase-agnostic diffuse-scattering defect metrology for FF-HEDM.
2
+
3
+ Quantifies the diffuse field around and between the Bragg peaks of an indexed
4
+ FF-HEDM dataset (asterism, fault rods, the full intensity budget, defect /
5
+ selection-rule tests) to produce a per-grain defect inventory. Driven by a
6
+ `midas_hkls.Crystal` + a `Geometry`; nothing is hard-wired to a phase.
7
+ """
8
+
9
+ import os
10
+
11
+ # `geometry.pixel_to_qlab` reuses `midas_transforms.apply_tilt_distortion`, which
12
+ # links a second OpenMP runtime alongside torch's. Allow the duplicate at import
13
+ # time (before either runtime initializes) so callers don't hit a hard crash.
14
+ os.environ.setdefault("KMP_DUPLICATE_LIB_OK", "TRUE")
15
+
16
+ __version__ = "0.1.0"