fabtwin 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.
- fabtwin-0.1.0/LICENSE +201 -0
- fabtwin-0.1.0/PKG-INFO +189 -0
- fabtwin-0.1.0/README.md +164 -0
- fabtwin-0.1.0/pyproject.toml +30 -0
- fabtwin-0.1.0/setup.cfg +4 -0
- fabtwin-0.1.0/src/fabtwin/__init__.py +43 -0
- fabtwin-0.1.0/src/fabtwin/adjoint.py +117 -0
- fabtwin-0.1.0/src/fabtwin/design.py +119 -0
- fabtwin-0.1.0/src/fabtwin/materials.py +97 -0
- fabtwin-0.1.0/src/fabtwin/process.py +126 -0
- fabtwin-0.1.0/src/fabtwin/risk.py +78 -0
- fabtwin-0.1.0/src/fabtwin/robust.py +126 -0
- fabtwin-0.1.0/src/fabtwin/tmm.py +170 -0
- fabtwin-0.1.0/src/fabtwin/twin_jax.py +356 -0
- fabtwin-0.1.0/src/fabtwin/twins.py +80 -0
- fabtwin-0.1.0/src/fabtwin.egg-info/PKG-INFO +189 -0
- fabtwin-0.1.0/src/fabtwin.egg-info/SOURCES.txt +23 -0
- fabtwin-0.1.0/src/fabtwin.egg-info/dependency_links.txt +1 -0
- fabtwin-0.1.0/src/fabtwin.egg-info/requires.txt +10 -0
- fabtwin-0.1.0/src/fabtwin.egg-info/top_level.txt +1 -0
- fabtwin-0.1.0/tests/test_adjoint.py +93 -0
- fabtwin-0.1.0/tests/test_process_twins.py +113 -0
- fabtwin-0.1.0/tests/test_risk_design_robust.py +162 -0
- fabtwin-0.1.0/tests/test_tmm.py +139 -0
- fabtwin-0.1.0/tests/test_twin_jax.py +132 -0
fabtwin-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
fabtwin-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fabtwin
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Learned generative process twins for yield-aware inverse design of multilayer optics: exact TMM with a hand-derived adjoint, CVaR robustification through twin and physics at once
|
|
5
|
+
Author: Tanvir Mahmud Mahim
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/TaN-MM-Org/fabtwin
|
|
8
|
+
Project-URL: Paper, https://github.com/Tanvir-Mahmud-Mahim/Learned-generative-process-twins-for-yield-aware-inverse-design-of-multilayer-photonic-sensor
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: numpy>=1.26
|
|
17
|
+
Requires-Dist: scipy>=1.11
|
|
18
|
+
Provides-Extra: twin
|
|
19
|
+
Requires-Dist: jax>=0.4.30; extra == "twin"
|
|
20
|
+
Requires-Dist: optax>=0.2; extra == "twin"
|
|
21
|
+
Provides-Extra: test
|
|
22
|
+
Requires-Dist: pytest>=7; extra == "test"
|
|
23
|
+
Requires-Dist: tmm>=0.1.8; extra == "test"
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# fabtwin
|
|
27
|
+
|
|
28
|
+
[](https://github.com/TaN-MM-Org/fabtwin/actions)
|
|
29
|
+
[](https://pypi.org/project/fabtwin/)
|
|
30
|
+
[](LICENSE)
|
|
31
|
+
|
|
32
|
+
**Learned generative process twins for yield-aware inverse design of
|
|
33
|
+
multilayer optics.** Real deposition errors are systematic,
|
|
34
|
+
layer-correlated, design-conditional, skewed and heavy-tailed, and
|
|
35
|
+
manufacturing yield is decided precisely in the tail that hand-specified
|
|
36
|
+
Gaussian tolerance models represent worst. `fabtwin` is the generalized
|
|
37
|
+
library form of the FabGAN-ID framework (Mahim, Islam, Rahman and
|
|
38
|
+
Mohsin, *IEEE Sensors Journal*, 2026): learn the fabrication process
|
|
39
|
+
from historical (recipe, outcome) traces, then robustify designs by
|
|
40
|
+
ascending the yield-deciding lower-tail statistic **pathwise through the
|
|
41
|
+
learned twin and the exact physics at once**.
|
|
42
|
+
|
|
43
|
+
> Learn what cannot be simulated; differentiate what can.
|
|
44
|
+
|
|
45
|
+
Where the paper's companion repository reproduces the paper (fixed
|
|
46
|
+
20-layer SiNx notch platform, JAX required end to end), `fabtwin` is the
|
|
47
|
+
reusable instrument: any layer count, any design box, any wavelength
|
|
48
|
+
grid, any cited material system, any linear-in-T merit -- and the entire
|
|
49
|
+
differentiable fabrication loop runs on **NumPy alone**, because the
|
|
50
|
+
discrete adjoint of the transfer-matrix recursion is derived by hand
|
|
51
|
+
rather than delegated to an autodiff framework. The learned conditional
|
|
52
|
+
WGAN-GP twin is an optional extra (`pip install 'fabtwin[twin]'`, JAX +
|
|
53
|
+
optax), and its autodiff gradients are asserted equal to the hand
|
|
54
|
+
adjoint to machine precision -- two independent derivations of the same
|
|
55
|
+
physics agreeing is the package's core cross-validation.
|
|
56
|
+
|
|
57
|
+
## What is inside
|
|
58
|
+
|
|
59
|
+
- `fabtwin.tmm` -- exact characteristic-matrix optics (Macleod) for
|
|
60
|
+
arbitrary stratified stacks: normal or oblique incidence (s/p),
|
|
61
|
+
absorbing layers (n + ik, gain refused), reflectance/transmittance,
|
|
62
|
+
and linear-in-T merit builders (fluorescence-rejection notch and
|
|
63
|
+
bandpass, per the paper's sensor front-ends). Cross-validated against
|
|
64
|
+
the open `tmm` reference (Byrnes, arXiv:1603.02720) to 1e-12 and
|
|
65
|
+
against closed forms: bare-interface Fresnel, the exact absentee
|
|
66
|
+
half-wave layer, the exact quarter-wave antireflection transform, the
|
|
67
|
+
analytic Brewster zero, and R + T = 1 at machine precision.
|
|
68
|
+
- `fabtwin.adjoint` -- the hand-derived exact adjoint: `merit_and_grad`
|
|
69
|
+
returns dJ/d(thickness) and dJ/d(index) from two O(NL) sweeps of
|
|
70
|
+
prefix/suffix products. Matches central finite differences at the
|
|
71
|
+
paper's own accuracy figure and vanishes exactly at the closed-form
|
|
72
|
+
quarter-wave optimum.
|
|
73
|
+
- `fabtwin.materials` -- a cited Sellmeier engine (Si3N4: Luke 2015;
|
|
74
|
+
fused silica: Malitson 1965; both CC0 via refractiveindex.info) with
|
|
75
|
+
validity-range refusal instead of silent extrapolation, and the
|
|
76
|
+
variable-index layer construction of the single-material SiNx
|
|
77
|
+
platform (Yesilyurt 2023).
|
|
78
|
+
- `fabtwin.process` -- the six-mechanism virtual deposition process of
|
|
79
|
+
the FabGAN-ID benchmark as a parametric dataclass (systematic bias,
|
|
80
|
+
index drift, intermixing, design-conditional AR(1) thickness noise,
|
|
81
|
+
right-skewed index noise, rare particulates): every mechanism
|
|
82
|
+
re-scalable or removable, the paper's published magnitudes as cited
|
|
83
|
+
defaults, and an exact closed-form anchor when the randomness is off.
|
|
84
|
+
- `fabtwin.twins` -- the common error parameterization
|
|
85
|
+
x = (t̃/t − 1, ñ − n) with exact round trip, and Gaussian twins
|
|
86
|
+
(diagonal/full) as differentiable parametric baselines.
|
|
87
|
+
- `fabtwin.risk` -- CVaR (exact sorted-tail convention, Rockafellar &
|
|
88
|
+
Uryasev 2000), tail statistics, the hard pass/fail filter yield, and
|
|
89
|
+
Monte-Carlo scoring of a design under any process or twin.
|
|
90
|
+
- `fabtwin.design` -- the probe-seeded projected-Adam adjoint engine
|
|
91
|
+
and its equal-budget random-search baseline; recovers the analytic
|
|
92
|
+
quarter-wave optimum in the tests.
|
|
93
|
+
- `fabtwin.robust` -- pathwise CVaR (or mean − beta*sigma)
|
|
94
|
+
robustification in pure NumPy for affinely reparameterized twins,
|
|
95
|
+
with the frozen-latent gradient anchored against finite differences.
|
|
96
|
+
- `fabtwin.twin_jax` (the `[twin]` extra) -- the conditional,
|
|
97
|
+
moment-matched WGAN-GP process twin, optional physics-in-the-loop
|
|
98
|
+
tail calibration (the paper's honest finding is reproduced in the
|
|
99
|
+
docstring: it helps only when traces are scarce), a JAX solver
|
|
100
|
+
asserted equal to the NumPy one, and `robustify_gan`: the paper's
|
|
101
|
+
Stage 2, CVaR ascent through generator and solver jointly.
|
|
102
|
+
|
|
103
|
+
## Install
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
pip install fabtwin # NumPy core: physics, adjoint, Gaussian twins, CVaR loop
|
|
107
|
+
pip install 'fabtwin[twin]' # + JAX/optax: the learned WGAN-GP twin
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## The loop in five lines
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
import numpy as np, fabtwin as ft
|
|
114
|
+
|
|
115
|
+
lam = np.linspace(0.40, 0.80, 161) # um
|
|
116
|
+
S = ft.dispersion_shape(lam, 0.550) # SiNx shape (Luke 2015)
|
|
117
|
+
nsub = ft.SIO2_MALITSON1965.n(lam) # substrate (Malitson 1965)
|
|
118
|
+
w, c0 = ft.notch_weights(lam, 0.532, 0.015, 0.030) # 532-nm rejection merit
|
|
119
|
+
box = ft.DesignBox(20, 0.020, 0.120, 1.6, 2.4) # fabrication box
|
|
120
|
+
|
|
121
|
+
t, n0, J, _ = ft.inverse_design(lam, S, w, c0, box, n_sub=nsub) # nominal optimum
|
|
122
|
+
|
|
123
|
+
rng = np.random.default_rng(0)
|
|
124
|
+
recipes = box.sample(rng, 200)
|
|
125
|
+
rt, rn, ftd, fnd = ft.PAPER_PROCESS.trace_dataset(*recipes, 2, rng) # historical traces
|
|
126
|
+
twin = ft.GaussianTwin(ft.errors_from_traces(rt, rn, ftd, fnd)) # or train the WGAN twin
|
|
127
|
+
|
|
128
|
+
t_rob, n_rob, hist = ft.robustify(lam, t, n0, S, w, c0, twin, box,
|
|
129
|
+
alpha=0.05, n_sub=nsub) # CVaR ascent
|
|
130
|
+
report = ft.evaluate_under_process(
|
|
131
|
+
lambda a, b, K: ft.PAPER_PROCESS.ensemble(a, b, K, rng),
|
|
132
|
+
t_rob, n_rob, lam, S, w, c0, K=2000, n_sub=nsub) # score vs the process
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The learned twin drops in through the `[twin]` extra:
|
|
136
|
+
`fabtwin.twin_jax.train_wgan` on the same traces, then
|
|
137
|
+
`robustify_gan` ascends the identical objective through the generator.
|
|
138
|
+
|
|
139
|
+
## Status
|
|
140
|
+
|
|
141
|
+
v0.1.0 (alpha). Implemented and tested (37 tests, Python 3.10-3.13;
|
|
142
|
+
the JAX extra's tests skip cleanly without it): everything listed
|
|
143
|
+
above, with every physics claim anchored to a closed form, an
|
|
144
|
+
independent reference implementation, or an exact identity -- never to
|
|
145
|
+
a stored number. The API may change before v1.0.
|
|
146
|
+
|
|
147
|
+
Deliberate scope, designed out with reasons rather than overlooked:
|
|
148
|
+
|
|
149
|
+
- The hand adjoint covers normal incidence and lossless (real-index)
|
|
150
|
+
designs -- the regime of the FabGAN-ID loop. The oblique and
|
|
151
|
+
absorbing *forward* solver is provided; its gradients are not faked.
|
|
152
|
+
- No specification-conditioned correction policies (the paper's Stage
|
|
153
|
+
3): the paper itself scopes that study as exploratory, and a policy
|
|
154
|
+
layer would import its chain-GCN encoder wholesale rather than
|
|
155
|
+
generalize it. The pathwise machinery a policy trainer needs is all
|
|
156
|
+
here.
|
|
157
|
+
- No neural forward surrogates, by *result*: the paper's protocol
|
|
158
|
+
study found the exact differentiable solver strictly dominates them
|
|
159
|
+
in this regime (faster, exact, with exact gradients), so shipping
|
|
160
|
+
one would package a documented mistake.
|
|
161
|
+
- The benchmark data (300 designs / 48,300 samples / 400 traces) stays
|
|
162
|
+
with the paper's companion repository and its Zenodo archive; this
|
|
163
|
+
package regenerates equivalent data from `DepositionProcess` instead
|
|
164
|
+
of redistributing files.
|
|
165
|
+
|
|
166
|
+
## Associated paper
|
|
167
|
+
|
|
168
|
+
T. M. Mahim, M. N. Islam, M. M. Rahman, A. S. M. Mohsin, "FabGAN-ID:
|
|
169
|
+
Learning the Fabrication Process for Yield-Aware Inverse Design of
|
|
170
|
+
Multilayer Photonic Sensor Filters", *IEEE Sensors Journal* (2026).
|
|
171
|
+
Companion repository:
|
|
172
|
+
[Learned-generative-process-twins...](https://github.com/Tanvir-Mahmud-Mahim/Learned-generative-process-twins-for-yield-aware-inverse-design-of-multilayer-photonic-sensor)
|
|
173
|
+
(benchmark archived on Zenodo, doi:10.5281/zenodo.21315793).
|
|
174
|
+
|
|
175
|
+
## Support and governance
|
|
176
|
+
|
|
177
|
+
The package is written and maintained by Tanvir Mahmud Mahim
|
|
178
|
+
(Department of Electrical and Electronic Engineering, BRAC University),
|
|
179
|
+
who reviews every change and takes the final decision on scope and
|
|
180
|
+
releases. There is no separate governance body; design questions are
|
|
181
|
+
discussed in the open in issues and pull requests, and the standing
|
|
182
|
+
rule of [CONTRIBUTING.md](CONTRIBUTING.md) binds the maintainer exactly
|
|
183
|
+
as it binds contributors: a change that touches physics arrives with a
|
|
184
|
+
test, and a constant arrives with its source.
|
|
185
|
+
|
|
186
|
+
## License and citation
|
|
187
|
+
|
|
188
|
+
Apache-2.0. Cite via [CITATION.cff](CITATION.cff) and the associated
|
|
189
|
+
paper above.
|
fabtwin-0.1.0/README.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# fabtwin
|
|
2
|
+
|
|
3
|
+
[](https://github.com/TaN-MM-Org/fabtwin/actions)
|
|
4
|
+
[](https://pypi.org/project/fabtwin/)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
**Learned generative process twins for yield-aware inverse design of
|
|
8
|
+
multilayer optics.** Real deposition errors are systematic,
|
|
9
|
+
layer-correlated, design-conditional, skewed and heavy-tailed, and
|
|
10
|
+
manufacturing yield is decided precisely in the tail that hand-specified
|
|
11
|
+
Gaussian tolerance models represent worst. `fabtwin` is the generalized
|
|
12
|
+
library form of the FabGAN-ID framework (Mahim, Islam, Rahman and
|
|
13
|
+
Mohsin, *IEEE Sensors Journal*, 2026): learn the fabrication process
|
|
14
|
+
from historical (recipe, outcome) traces, then robustify designs by
|
|
15
|
+
ascending the yield-deciding lower-tail statistic **pathwise through the
|
|
16
|
+
learned twin and the exact physics at once**.
|
|
17
|
+
|
|
18
|
+
> Learn what cannot be simulated; differentiate what can.
|
|
19
|
+
|
|
20
|
+
Where the paper's companion repository reproduces the paper (fixed
|
|
21
|
+
20-layer SiNx notch platform, JAX required end to end), `fabtwin` is the
|
|
22
|
+
reusable instrument: any layer count, any design box, any wavelength
|
|
23
|
+
grid, any cited material system, any linear-in-T merit -- and the entire
|
|
24
|
+
differentiable fabrication loop runs on **NumPy alone**, because the
|
|
25
|
+
discrete adjoint of the transfer-matrix recursion is derived by hand
|
|
26
|
+
rather than delegated to an autodiff framework. The learned conditional
|
|
27
|
+
WGAN-GP twin is an optional extra (`pip install 'fabtwin[twin]'`, JAX +
|
|
28
|
+
optax), and its autodiff gradients are asserted equal to the hand
|
|
29
|
+
adjoint to machine precision -- two independent derivations of the same
|
|
30
|
+
physics agreeing is the package's core cross-validation.
|
|
31
|
+
|
|
32
|
+
## What is inside
|
|
33
|
+
|
|
34
|
+
- `fabtwin.tmm` -- exact characteristic-matrix optics (Macleod) for
|
|
35
|
+
arbitrary stratified stacks: normal or oblique incidence (s/p),
|
|
36
|
+
absorbing layers (n + ik, gain refused), reflectance/transmittance,
|
|
37
|
+
and linear-in-T merit builders (fluorescence-rejection notch and
|
|
38
|
+
bandpass, per the paper's sensor front-ends). Cross-validated against
|
|
39
|
+
the open `tmm` reference (Byrnes, arXiv:1603.02720) to 1e-12 and
|
|
40
|
+
against closed forms: bare-interface Fresnel, the exact absentee
|
|
41
|
+
half-wave layer, the exact quarter-wave antireflection transform, the
|
|
42
|
+
analytic Brewster zero, and R + T = 1 at machine precision.
|
|
43
|
+
- `fabtwin.adjoint` -- the hand-derived exact adjoint: `merit_and_grad`
|
|
44
|
+
returns dJ/d(thickness) and dJ/d(index) from two O(NL) sweeps of
|
|
45
|
+
prefix/suffix products. Matches central finite differences at the
|
|
46
|
+
paper's own accuracy figure and vanishes exactly at the closed-form
|
|
47
|
+
quarter-wave optimum.
|
|
48
|
+
- `fabtwin.materials` -- a cited Sellmeier engine (Si3N4: Luke 2015;
|
|
49
|
+
fused silica: Malitson 1965; both CC0 via refractiveindex.info) with
|
|
50
|
+
validity-range refusal instead of silent extrapolation, and the
|
|
51
|
+
variable-index layer construction of the single-material SiNx
|
|
52
|
+
platform (Yesilyurt 2023).
|
|
53
|
+
- `fabtwin.process` -- the six-mechanism virtual deposition process of
|
|
54
|
+
the FabGAN-ID benchmark as a parametric dataclass (systematic bias,
|
|
55
|
+
index drift, intermixing, design-conditional AR(1) thickness noise,
|
|
56
|
+
right-skewed index noise, rare particulates): every mechanism
|
|
57
|
+
re-scalable or removable, the paper's published magnitudes as cited
|
|
58
|
+
defaults, and an exact closed-form anchor when the randomness is off.
|
|
59
|
+
- `fabtwin.twins` -- the common error parameterization
|
|
60
|
+
x = (t̃/t − 1, ñ − n) with exact round trip, and Gaussian twins
|
|
61
|
+
(diagonal/full) as differentiable parametric baselines.
|
|
62
|
+
- `fabtwin.risk` -- CVaR (exact sorted-tail convention, Rockafellar &
|
|
63
|
+
Uryasev 2000), tail statistics, the hard pass/fail filter yield, and
|
|
64
|
+
Monte-Carlo scoring of a design under any process or twin.
|
|
65
|
+
- `fabtwin.design` -- the probe-seeded projected-Adam adjoint engine
|
|
66
|
+
and its equal-budget random-search baseline; recovers the analytic
|
|
67
|
+
quarter-wave optimum in the tests.
|
|
68
|
+
- `fabtwin.robust` -- pathwise CVaR (or mean − beta*sigma)
|
|
69
|
+
robustification in pure NumPy for affinely reparameterized twins,
|
|
70
|
+
with the frozen-latent gradient anchored against finite differences.
|
|
71
|
+
- `fabtwin.twin_jax` (the `[twin]` extra) -- the conditional,
|
|
72
|
+
moment-matched WGAN-GP process twin, optional physics-in-the-loop
|
|
73
|
+
tail calibration (the paper's honest finding is reproduced in the
|
|
74
|
+
docstring: it helps only when traces are scarce), a JAX solver
|
|
75
|
+
asserted equal to the NumPy one, and `robustify_gan`: the paper's
|
|
76
|
+
Stage 2, CVaR ascent through generator and solver jointly.
|
|
77
|
+
|
|
78
|
+
## Install
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
pip install fabtwin # NumPy core: physics, adjoint, Gaussian twins, CVaR loop
|
|
82
|
+
pip install 'fabtwin[twin]' # + JAX/optax: the learned WGAN-GP twin
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## The loop in five lines
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
import numpy as np, fabtwin as ft
|
|
89
|
+
|
|
90
|
+
lam = np.linspace(0.40, 0.80, 161) # um
|
|
91
|
+
S = ft.dispersion_shape(lam, 0.550) # SiNx shape (Luke 2015)
|
|
92
|
+
nsub = ft.SIO2_MALITSON1965.n(lam) # substrate (Malitson 1965)
|
|
93
|
+
w, c0 = ft.notch_weights(lam, 0.532, 0.015, 0.030) # 532-nm rejection merit
|
|
94
|
+
box = ft.DesignBox(20, 0.020, 0.120, 1.6, 2.4) # fabrication box
|
|
95
|
+
|
|
96
|
+
t, n0, J, _ = ft.inverse_design(lam, S, w, c0, box, n_sub=nsub) # nominal optimum
|
|
97
|
+
|
|
98
|
+
rng = np.random.default_rng(0)
|
|
99
|
+
recipes = box.sample(rng, 200)
|
|
100
|
+
rt, rn, ftd, fnd = ft.PAPER_PROCESS.trace_dataset(*recipes, 2, rng) # historical traces
|
|
101
|
+
twin = ft.GaussianTwin(ft.errors_from_traces(rt, rn, ftd, fnd)) # or train the WGAN twin
|
|
102
|
+
|
|
103
|
+
t_rob, n_rob, hist = ft.robustify(lam, t, n0, S, w, c0, twin, box,
|
|
104
|
+
alpha=0.05, n_sub=nsub) # CVaR ascent
|
|
105
|
+
report = ft.evaluate_under_process(
|
|
106
|
+
lambda a, b, K: ft.PAPER_PROCESS.ensemble(a, b, K, rng),
|
|
107
|
+
t_rob, n_rob, lam, S, w, c0, K=2000, n_sub=nsub) # score vs the process
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The learned twin drops in through the `[twin]` extra:
|
|
111
|
+
`fabtwin.twin_jax.train_wgan` on the same traces, then
|
|
112
|
+
`robustify_gan` ascends the identical objective through the generator.
|
|
113
|
+
|
|
114
|
+
## Status
|
|
115
|
+
|
|
116
|
+
v0.1.0 (alpha). Implemented and tested (37 tests, Python 3.10-3.13;
|
|
117
|
+
the JAX extra's tests skip cleanly without it): everything listed
|
|
118
|
+
above, with every physics claim anchored to a closed form, an
|
|
119
|
+
independent reference implementation, or an exact identity -- never to
|
|
120
|
+
a stored number. The API may change before v1.0.
|
|
121
|
+
|
|
122
|
+
Deliberate scope, designed out with reasons rather than overlooked:
|
|
123
|
+
|
|
124
|
+
- The hand adjoint covers normal incidence and lossless (real-index)
|
|
125
|
+
designs -- the regime of the FabGAN-ID loop. The oblique and
|
|
126
|
+
absorbing *forward* solver is provided; its gradients are not faked.
|
|
127
|
+
- No specification-conditioned correction policies (the paper's Stage
|
|
128
|
+
3): the paper itself scopes that study as exploratory, and a policy
|
|
129
|
+
layer would import its chain-GCN encoder wholesale rather than
|
|
130
|
+
generalize it. The pathwise machinery a policy trainer needs is all
|
|
131
|
+
here.
|
|
132
|
+
- No neural forward surrogates, by *result*: the paper's protocol
|
|
133
|
+
study found the exact differentiable solver strictly dominates them
|
|
134
|
+
in this regime (faster, exact, with exact gradients), so shipping
|
|
135
|
+
one would package a documented mistake.
|
|
136
|
+
- The benchmark data (300 designs / 48,300 samples / 400 traces) stays
|
|
137
|
+
with the paper's companion repository and its Zenodo archive; this
|
|
138
|
+
package regenerates equivalent data from `DepositionProcess` instead
|
|
139
|
+
of redistributing files.
|
|
140
|
+
|
|
141
|
+
## Associated paper
|
|
142
|
+
|
|
143
|
+
T. M. Mahim, M. N. Islam, M. M. Rahman, A. S. M. Mohsin, "FabGAN-ID:
|
|
144
|
+
Learning the Fabrication Process for Yield-Aware Inverse Design of
|
|
145
|
+
Multilayer Photonic Sensor Filters", *IEEE Sensors Journal* (2026).
|
|
146
|
+
Companion repository:
|
|
147
|
+
[Learned-generative-process-twins...](https://github.com/Tanvir-Mahmud-Mahim/Learned-generative-process-twins-for-yield-aware-inverse-design-of-multilayer-photonic-sensor)
|
|
148
|
+
(benchmark archived on Zenodo, doi:10.5281/zenodo.21315793).
|
|
149
|
+
|
|
150
|
+
## Support and governance
|
|
151
|
+
|
|
152
|
+
The package is written and maintained by Tanvir Mahmud Mahim
|
|
153
|
+
(Department of Electrical and Electronic Engineering, BRAC University),
|
|
154
|
+
who reviews every change and takes the final decision on scope and
|
|
155
|
+
releases. There is no separate governance body; design questions are
|
|
156
|
+
discussed in the open in issues and pull requests, and the standing
|
|
157
|
+
rule of [CONTRIBUTING.md](CONTRIBUTING.md) binds the maintainer exactly
|
|
158
|
+
as it binds contributors: a change that touches physics arrives with a
|
|
159
|
+
test, and a constant arrives with its source.
|
|
160
|
+
|
|
161
|
+
## License and citation
|
|
162
|
+
|
|
163
|
+
Apache-2.0. Cite via [CITATION.cff](CITATION.cff) and the associated
|
|
164
|
+
paper above.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "fabtwin"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Learned generative process twins for yield-aware inverse design of multilayer optics: exact TMM with a hand-derived adjoint, CVaR robustification through twin and physics at once"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = {text = "Apache-2.0"}
|
|
12
|
+
authors = [{name = "Tanvir Mahmud Mahim"}]
|
|
13
|
+
dependencies = ["numpy>=1.26", "scipy>=1.11"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Science/Research",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Topic :: Scientific/Engineering :: Physics",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://github.com/TaN-MM-Org/fabtwin"
|
|
23
|
+
Paper = "https://github.com/Tanvir-Mahmud-Mahim/Learned-generative-process-twins-for-yield-aware-inverse-design-of-multilayer-photonic-sensor"
|
|
24
|
+
|
|
25
|
+
[project.optional-dependencies]
|
|
26
|
+
twin = ["jax>=0.4.30", "optax>=0.2"]
|
|
27
|
+
test = ["pytest>=7", "tmm>=0.1.8"]
|
|
28
|
+
|
|
29
|
+
[tool.setuptools.packages.find]
|
|
30
|
+
where = ["src"]
|
fabtwin-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""fabtwin: learned generative process twins for yield-aware inverse
|
|
2
|
+
design of multilayer optics.
|
|
3
|
+
|
|
4
|
+
Generalized library form of the FabGAN-ID framework (T. M. Mahim,
|
|
5
|
+
M. N. Islam, M. M. Rahman, A. S. M. Mohsin, "FabGAN-ID: Learning the
|
|
6
|
+
Fabrication Process for Yield-Aware Inverse Design of Multilayer
|
|
7
|
+
Photonic Sensor Filters", IEEE Sensors Journal, 2026): exact
|
|
8
|
+
transfer-matrix physics with a hand-derived discrete adjoint (no
|
|
9
|
+
autodiff framework required), a parametric six-mechanism virtual
|
|
10
|
+
deposition process, Gaussian and learned (conditional WGAN-GP, the
|
|
11
|
+
optional [twin] JAX extra) process twins on a common error
|
|
12
|
+
parameterization, probe-seeded adjoint inverse design, and pathwise
|
|
13
|
+
CVaR robustification through twin and physics at once. The guiding
|
|
14
|
+
principle of the paper is the guiding principle of the package:
|
|
15
|
+
learn what cannot be simulated; differentiate what can.
|
|
16
|
+
"""
|
|
17
|
+
from .materials import (SI3N4_LUKE2015, SIO2_MALITSON1965,
|
|
18
|
+
SellmeierMaterial, dispersion_shape, layer_index,
|
|
19
|
+
sellmeier)
|
|
20
|
+
from .tmm import (bandpass_weights, merit, notch_weights, reflectance,
|
|
21
|
+
stack_rt, transmittance)
|
|
22
|
+
from .adjoint import merit_and_grad, transmittance_and_grads
|
|
23
|
+
from .process import PAPER_PROCESS, DepositionProcess
|
|
24
|
+
from .twins import GaussianTwin, apply_errors, errors_from_traces
|
|
25
|
+
from .risk import (cvar, evaluate_under_process, pass_fail,
|
|
26
|
+
tail_statistics, yield_fraction)
|
|
27
|
+
from .design import DesignBox, adam_ascent, inverse_design, random_search
|
|
28
|
+
from .robust import cvar_objective_and_grad, robustify
|
|
29
|
+
|
|
30
|
+
__version__ = "0.1.0"
|
|
31
|
+
__all__ = [
|
|
32
|
+
"SellmeierMaterial", "SI3N4_LUKE2015", "SIO2_MALITSON1965",
|
|
33
|
+
"sellmeier", "dispersion_shape", "layer_index",
|
|
34
|
+
"transmittance", "reflectance", "stack_rt", "merit",
|
|
35
|
+
"notch_weights", "bandpass_weights",
|
|
36
|
+
"transmittance_and_grads", "merit_and_grad",
|
|
37
|
+
"DepositionProcess", "PAPER_PROCESS",
|
|
38
|
+
"GaussianTwin", "errors_from_traces", "apply_errors",
|
|
39
|
+
"cvar", "tail_statistics", "pass_fail", "yield_fraction",
|
|
40
|
+
"evaluate_under_process",
|
|
41
|
+
"DesignBox", "inverse_design", "random_search", "adam_ascent",
|
|
42
|
+
"cvar_objective_and_grad", "robustify",
|
|
43
|
+
]
|