waferbow 0.3.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.
- waferbow/__init__.py +76 -0
- waferbow/__main__.py +8 -0
- waferbow/_compat.py +18 -0
- waferbow/analytic.py +89 -0
- waferbow/calibration.py +218 -0
- waferbow/cli.py +263 -0
- waferbow/compat.py +404 -0
- waferbow/cte_models.py +134 -0
- waferbow/curated.py +251 -0
- waferbow/data/curated_materials.json +3790 -0
- waferbow/data/curated_materials.yaml +2492 -0
- waferbow/inverse.py +80 -0
- waferbow/io.py +390 -0
- waferbow/materials.py +593 -0
- waferbow/multilayer.py +522 -0
- waferbow/plotting.py +163 -0
- waferbow/process_flow.py +126 -0
- waferbow/providers.py +133 -0
- waferbow/py.typed +0 -0
- waferbow/stoney.py +83 -0
- waferbow/thermal.py +98 -0
- waferbow/units.py +106 -0
- waferbow/validity.py +295 -0
- waferbow-0.3.0.dist-info/METADATA +487 -0
- waferbow-0.3.0.dist-info/RECORD +29 -0
- waferbow-0.3.0.dist-info/WHEEL +4 -0
- waferbow-0.3.0.dist-info/entry_points.txt +2 -0
- waferbow-0.3.0.dist-info/licenses/LICENSE +190 -0
- waferbow-0.3.0.dist-info/licenses/NOTICE +15 -0
waferbow/__init__.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""waferbow — multilayer thin-film stress and wafer bow prediction.
|
|
2
|
+
|
|
3
|
+
Quick start
|
|
4
|
+
-----------
|
|
5
|
+
>>> from waferbow import Stack, Layer, materials
|
|
6
|
+
>>> stack = Stack(
|
|
7
|
+
... substrate=Layer(materials.SI_001, 725e-6),
|
|
8
|
+
... films=[Layer(materials.SI3N4_LPCVD, 200e-9, intrinsic_stress=1.0e9)],
|
|
9
|
+
... diameter=0.300,
|
|
10
|
+
... )
|
|
11
|
+
>>> res = stack.solve()
|
|
12
|
+
>>> round(res.bow * 1e6, 1) # microns, positive = concave (tensile) # doctest: +SKIP
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from . import analytic, cte_models, curated, io, materials, providers
|
|
16
|
+
from .analytic import timoshenko_bilayer_curvature
|
|
17
|
+
from .cte_models import (
|
|
18
|
+
constant_expansion,
|
|
19
|
+
piecewise_expansion,
|
|
20
|
+
polynomial_expansion,
|
|
21
|
+
tabulated_expansion,
|
|
22
|
+
)
|
|
23
|
+
from .curated import CuratedEntry, database
|
|
24
|
+
from .io import load_stack, save_stack
|
|
25
|
+
from .inverse import fit_film_stress
|
|
26
|
+
from .materials import Material
|
|
27
|
+
from .multilayer import (
|
|
28
|
+
CONCAVE_POSITIVE,
|
|
29
|
+
CONVEX_POSITIVE,
|
|
30
|
+
Layer,
|
|
31
|
+
SolveResult,
|
|
32
|
+
Stack,
|
|
33
|
+
)
|
|
34
|
+
from .stoney import (
|
|
35
|
+
bow_to_curvature,
|
|
36
|
+
curvature_to_bow,
|
|
37
|
+
stoney_curvature,
|
|
38
|
+
stoney_stress,
|
|
39
|
+
stress_thickness_product,
|
|
40
|
+
)
|
|
41
|
+
from .validity import Check, ValidityReport
|
|
42
|
+
|
|
43
|
+
__version__ = "0.3.0"
|
|
44
|
+
|
|
45
|
+
__all__ = [
|
|
46
|
+
"Layer",
|
|
47
|
+
"Material",
|
|
48
|
+
"Stack",
|
|
49
|
+
"SolveResult",
|
|
50
|
+
"materials",
|
|
51
|
+
"analytic",
|
|
52
|
+
"io",
|
|
53
|
+
"providers",
|
|
54
|
+
"cte_models",
|
|
55
|
+
"curated",
|
|
56
|
+
"database",
|
|
57
|
+
"load_stack",
|
|
58
|
+
"save_stack",
|
|
59
|
+
"CuratedEntry",
|
|
60
|
+
"constant_expansion",
|
|
61
|
+
"polynomial_expansion",
|
|
62
|
+
"piecewise_expansion",
|
|
63
|
+
"tabulated_expansion",
|
|
64
|
+
"ValidityReport",
|
|
65
|
+
"Check",
|
|
66
|
+
"CONCAVE_POSITIVE",
|
|
67
|
+
"CONVEX_POSITIVE",
|
|
68
|
+
"stoney_curvature",
|
|
69
|
+
"stoney_stress",
|
|
70
|
+
"bow_to_curvature",
|
|
71
|
+
"curvature_to_bow",
|
|
72
|
+
"stress_thickness_product",
|
|
73
|
+
"timoshenko_bilayer_curvature",
|
|
74
|
+
"fit_film_stress",
|
|
75
|
+
"__version__",
|
|
76
|
+
]
|
waferbow/__main__.py
ADDED
waferbow/_compat.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Compatibility shims across the supported NumPy range.
|
|
2
|
+
|
|
3
|
+
``numpy>=1.24`` is a wide window: ``np.trapz`` was removed in NumPy 2.0 and
|
|
4
|
+
replaced by ``np.trapezoid``, which in turn does not exist before 2.0. Neither
|
|
5
|
+
name works everywhere, so bind whichever the installed version provides.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import numpy as np
|
|
11
|
+
|
|
12
|
+
if hasattr(np, "trapezoid"): # NumPy >= 2.0
|
|
13
|
+
trapezoid = np.trapezoid
|
|
14
|
+
else: # pragma: no cover - exercised only on NumPy 1.x
|
|
15
|
+
# np.trapz is absent from NumPy 2.x stubs; this branch only runs on 1.x.
|
|
16
|
+
trapezoid = np.trapz # type: ignore[attr-defined]
|
|
17
|
+
|
|
18
|
+
__all__ = ["trapezoid"]
|
waferbow/analytic.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"""Closed-form solutions, for checking the general solver against.
|
|
2
|
+
|
|
3
|
+
The n-layer solver assembles an equilibrium system and inverts it. That is the
|
|
4
|
+
right way to compute a real stack, but it means a single arithmetic slip can
|
|
5
|
+
move every answer at once without any of them looking obviously wrong. The
|
|
6
|
+
defence is an independent route to the same number.
|
|
7
|
+
|
|
8
|
+
:func:`timoshenko_bilayer_curvature` is that route for the two-layer thermal
|
|
9
|
+
case. It is Timoshenko's 1925 bimetal result, adapted to biaxial moduli, and it
|
|
10
|
+
shares no code with the solver -- not the assembly, not the neutral axis, not
|
|
11
|
+
the mismatch strains. Where the two agree they agree for a reason.
|
|
12
|
+
|
|
13
|
+
It is also unrestricted in thickness ratio, which Stoney is not. A 100 um film
|
|
14
|
+
on a 500 um substrate is far outside anything Stoney can be asked about, and
|
|
15
|
+
the two-layer closed form still pins the solver there to seven digits. See
|
|
16
|
+
``tests/test_analytic.py``.
|
|
17
|
+
|
|
18
|
+
For the thin-film limit itself, use :mod:`waferbow.stoney`.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import math
|
|
24
|
+
|
|
25
|
+
from .multilayer import CONCAVE_POSITIVE, _SIGN
|
|
26
|
+
|
|
27
|
+
__all__ = ["timoshenko_bilayer_curvature"]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _positive(name: str, value: float) -> float:
|
|
31
|
+
if not math.isfinite(value) or value <= 0.0:
|
|
32
|
+
raise ValueError(f"{name} must be finite and positive, got {value!r}.")
|
|
33
|
+
return value
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def timoshenko_bilayer_curvature(
|
|
37
|
+
substrate_biaxial_modulus: float,
|
|
38
|
+
substrate_thickness: float,
|
|
39
|
+
substrate_cte: float,
|
|
40
|
+
film_biaxial_modulus: float,
|
|
41
|
+
film_thickness: float,
|
|
42
|
+
film_cte: float,
|
|
43
|
+
delta_T: float,
|
|
44
|
+
*,
|
|
45
|
+
convention: str = CONCAVE_POSITIVE,
|
|
46
|
+
) -> float:
|
|
47
|
+
"""Curvature [1/m] of a two-layer plate under a uniform temperature change.
|
|
48
|
+
|
|
49
|
+
Timoshenko's bimetal formula with biaxial moduli substituted for the
|
|
50
|
+
uniaxial ones, which is the correct substitution for a plate held in an
|
|
51
|
+
equal-biaxial stress state::
|
|
52
|
+
|
|
53
|
+
m = t_f / t_s, n = M_f / M_s, h = t_s + t_f
|
|
54
|
+
|
|
55
|
+
kappa = -6 (a_f - a_s) dT (1 + m)^2
|
|
56
|
+
/ [ h (3 (1 + m)^2 + (1 + m n)(m^2 + 1 / (m n))) ]
|
|
57
|
+
|
|
58
|
+
Exact for two layers at any thickness ratio -- no thin-film assumption --
|
|
59
|
+
but it carries no intrinsic stress and no temperature-dependent expansion.
|
|
60
|
+
A stack that needs either of those needs the solver.
|
|
61
|
+
|
|
62
|
+
The leading sign puts the result in ``CONCAVE_POSITIVE``: a film with the
|
|
63
|
+
larger CTE, heated, is held back by the substrate and ends up in
|
|
64
|
+
compression, bowing the wafer convex toward the film, so the curvature is
|
|
65
|
+
negative. Pass ``convention=CONVEX_POSITIVE`` to flip it.
|
|
66
|
+
|
|
67
|
+
``delta_T`` is ``T - T_ref``, so cooling from growth is negative.
|
|
68
|
+
"""
|
|
69
|
+
_positive("substrate_biaxial_modulus", substrate_biaxial_modulus)
|
|
70
|
+
_positive("substrate_thickness", substrate_thickness)
|
|
71
|
+
_positive("film_biaxial_modulus", film_biaxial_modulus)
|
|
72
|
+
_positive("film_thickness", film_thickness)
|
|
73
|
+
try:
|
|
74
|
+
sign = _SIGN[convention]
|
|
75
|
+
except KeyError:
|
|
76
|
+
raise ValueError(
|
|
77
|
+
f"Unknown convention {convention!r}; "
|
|
78
|
+
"use CONCAVE_POSITIVE or CONVEX_POSITIVE."
|
|
79
|
+
) from None
|
|
80
|
+
|
|
81
|
+
m = film_thickness / substrate_thickness
|
|
82
|
+
n = film_biaxial_modulus / substrate_biaxial_modulus
|
|
83
|
+
h = substrate_thickness + film_thickness
|
|
84
|
+
|
|
85
|
+
numerator = 6.0 * (film_cte - substrate_cte) * delta_T * (1.0 + m) ** 2
|
|
86
|
+
denominator = h * (
|
|
87
|
+
3.0 * (1.0 + m) ** 2 + (1.0 + m * n) * (m**2 + 1.0 / (m * n))
|
|
88
|
+
)
|
|
89
|
+
return -sign * numerator / denominator
|
waferbow/calibration.py
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"""Fitting model parameters to measured curvature.
|
|
2
|
+
|
|
3
|
+
Two of the three entry points here need no optimiser at all. Curvature is
|
|
4
|
+
*exactly affine* in a layer's intrinsic stress -- the equilibrium system is
|
|
5
|
+
linear in the mismatch strains -- so fitting one stress to one measurement has a
|
|
6
|
+
closed form, and fitting it to a whole curvature-versus-temperature dataset is
|
|
7
|
+
an ordinary linear least squares. Both are solved directly, which is faster,
|
|
8
|
+
has no convergence to fail, and returns the exact answer rather than one within
|
|
9
|
+
a tolerance.
|
|
10
|
+
|
|
11
|
+
Only :func:`fit_parameter`, which fits an arbitrary parameter through a
|
|
12
|
+
caller-supplied setter, is genuinely nonlinear. That one needs SciPy, and it is
|
|
13
|
+
the only thing here that does::
|
|
14
|
+
|
|
15
|
+
pip install waferbow[fit]
|
|
16
|
+
|
|
17
|
+
Every fit leaves the stack it was given untouched.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
from dataclasses import dataclass, field
|
|
23
|
+
from typing import Any, Callable, Sequence
|
|
24
|
+
|
|
25
|
+
import numpy as np
|
|
26
|
+
|
|
27
|
+
from .multilayer import Layer, Stack
|
|
28
|
+
|
|
29
|
+
__all__ = ["CalibrationResult", "fit_intrinsic_stress",
|
|
30
|
+
"fit_stress_from_curvature_vs_temperature", "fit_parameter"]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass
|
|
34
|
+
class CalibrationResult:
|
|
35
|
+
"""Outcome of a fit."""
|
|
36
|
+
|
|
37
|
+
fitted_values: dict[str, float]
|
|
38
|
+
residuals: np.ndarray
|
|
39
|
+
success: bool = True
|
|
40
|
+
message: str = "exact linear solution"
|
|
41
|
+
raw_result: Any = field(default=None, repr=False)
|
|
42
|
+
|
|
43
|
+
@property
|
|
44
|
+
def cost(self) -> float:
|
|
45
|
+
"""Half the sum of squared residuals, matching SciPy's convention."""
|
|
46
|
+
return 0.5 * float(np.sum(np.asarray(self.residuals) ** 2))
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def value(self) -> float:
|
|
50
|
+
"""The fitted value, when there is exactly one."""
|
|
51
|
+
if len(self.fitted_values) != 1:
|
|
52
|
+
raise ValueError(
|
|
53
|
+
f"{len(self.fitted_values)} parameters were fitted; "
|
|
54
|
+
"read fitted_values instead."
|
|
55
|
+
)
|
|
56
|
+
return next(iter(self.fitted_values.values()))
|
|
57
|
+
|
|
58
|
+
def summary(self) -> str:
|
|
59
|
+
lines = [f"calibration: {self.message}"]
|
|
60
|
+
lines += [f" {k} = {v:.6g}" for k, v in self.fitted_values.items()]
|
|
61
|
+
lines.append(f" rms residual {np.sqrt(np.mean(self.residuals**2)):.4e}")
|
|
62
|
+
return "\n".join(lines)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _with_stress(stack: Stack, film_index: int, sigma0: float) -> Stack:
|
|
66
|
+
"""A copy of ``stack`` with one film's intrinsic stress replaced."""
|
|
67
|
+
films = list(stack.films)
|
|
68
|
+
f = films[film_index]
|
|
69
|
+
films[film_index] = Layer(
|
|
70
|
+
material=f.material,
|
|
71
|
+
thickness=f.thickness,
|
|
72
|
+
intrinsic_stress=sigma0,
|
|
73
|
+
deposition_temperature=f.deposition_temperature,
|
|
74
|
+
)
|
|
75
|
+
return Stack(stack.substrate, films, stack.diameter, stack.convention)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _check_index(stack: Stack, film_index: int) -> None:
|
|
79
|
+
if not 0 <= film_index < len(stack.films):
|
|
80
|
+
raise IndexError(
|
|
81
|
+
f"film_index {film_index} out of range for {len(stack.films)} film(s)."
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _affine_in_stress(stack: Stack, film_index: int, temperature: float,
|
|
86
|
+
T_ref: float) -> tuple[float, float]:
|
|
87
|
+
"""Return (intercept, slope) of curvature against that film's stress."""
|
|
88
|
+
k0 = _with_stress(stack, film_index, 0.0).solve(
|
|
89
|
+
temperature=temperature, T_ref=T_ref).curvature
|
|
90
|
+
k1 = _with_stress(stack, film_index, 1e6).solve(
|
|
91
|
+
temperature=temperature, T_ref=T_ref).curvature
|
|
92
|
+
return k0, (k1 - k0) / 1e6
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def fit_intrinsic_stress(
|
|
96
|
+
stack: Stack,
|
|
97
|
+
film_index: int,
|
|
98
|
+
measured_curvature: float,
|
|
99
|
+
temperature: float = 298.15,
|
|
100
|
+
*,
|
|
101
|
+
T_ref: float = 293.15,
|
|
102
|
+
) -> CalibrationResult:
|
|
103
|
+
"""Fit one film's intrinsic stress to a single measured curvature.
|
|
104
|
+
|
|
105
|
+
Exact: curvature is affine in the stress, so this is a division, not a
|
|
106
|
+
search.
|
|
107
|
+
"""
|
|
108
|
+
_check_index(stack, film_index)
|
|
109
|
+
intercept, slope = _affine_in_stress(stack, film_index, temperature, T_ref)
|
|
110
|
+
if slope == 0.0:
|
|
111
|
+
raise ZeroDivisionError(
|
|
112
|
+
"Curvature does not respond to this film's stress; nothing to fit."
|
|
113
|
+
)
|
|
114
|
+
sigma0 = (measured_curvature - intercept) / slope
|
|
115
|
+
residual = np.array([intercept + slope * sigma0 - measured_curvature])
|
|
116
|
+
return CalibrationResult(
|
|
117
|
+
fitted_values={"intrinsic_stress_Pa": sigma0},
|
|
118
|
+
residuals=residual,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def fit_stress_from_curvature_vs_temperature(
|
|
123
|
+
stack: Stack,
|
|
124
|
+
film_index: int,
|
|
125
|
+
temperatures: Sequence[float],
|
|
126
|
+
measured_curvatures: Sequence[float],
|
|
127
|
+
*,
|
|
128
|
+
T_ref: float = 293.15,
|
|
129
|
+
) -> CalibrationResult:
|
|
130
|
+
"""Fit one film's intrinsic stress to a curvature-versus-temperature series.
|
|
131
|
+
|
|
132
|
+
Also exact. At each temperature curvature is ``a(T) + b(T) * sigma0``, so
|
|
133
|
+
the least-squares stress is ``sum(b * (k - a)) / sum(b^2)`` -- a closed
|
|
134
|
+
form, no iteration.
|
|
135
|
+
|
|
136
|
+
Fitting a whole trace rather than one point is worth doing: the *slope* of
|
|
137
|
+
curvature against temperature is set by thermal mismatch alone, so a series
|
|
138
|
+
constrains the stress against a background it can separate.
|
|
139
|
+
"""
|
|
140
|
+
_check_index(stack, film_index)
|
|
141
|
+
T = np.asarray(temperatures, dtype=float)
|
|
142
|
+
k = np.asarray(measured_curvatures, dtype=float)
|
|
143
|
+
if T.shape != k.shape:
|
|
144
|
+
raise ValueError(
|
|
145
|
+
f"Got {T.size} temperatures and {k.size} curvatures; "
|
|
146
|
+
"they must correspond."
|
|
147
|
+
)
|
|
148
|
+
if T.size == 0:
|
|
149
|
+
raise ValueError("No data to fit.")
|
|
150
|
+
|
|
151
|
+
a, b = np.empty_like(T), np.empty_like(T)
|
|
152
|
+
for i, t in enumerate(T):
|
|
153
|
+
a[i], b[i] = _affine_in_stress(stack, film_index, float(t), T_ref)
|
|
154
|
+
|
|
155
|
+
denominator = float(np.sum(b**2))
|
|
156
|
+
if denominator == 0.0:
|
|
157
|
+
raise ZeroDivisionError(
|
|
158
|
+
"Curvature does not respond to this film's stress at any of these "
|
|
159
|
+
"temperatures; nothing to fit."
|
|
160
|
+
)
|
|
161
|
+
sigma0 = float(np.sum(b * (k - a)) / denominator)
|
|
162
|
+
return CalibrationResult(
|
|
163
|
+
fitted_values={"intrinsic_stress_Pa": sigma0},
|
|
164
|
+
residuals=a + b * sigma0 - k,
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def fit_parameter(
|
|
169
|
+
stack: Stack,
|
|
170
|
+
setter: Callable[[Stack, float], Stack],
|
|
171
|
+
param_name: str,
|
|
172
|
+
temperatures: Sequence[float],
|
|
173
|
+
measured_curvatures: Sequence[float],
|
|
174
|
+
initial: float,
|
|
175
|
+
*,
|
|
176
|
+
bounds: tuple[float, float] = (-np.inf, np.inf),
|
|
177
|
+
T_ref: float = 293.15,
|
|
178
|
+
) -> CalibrationResult:
|
|
179
|
+
"""Fit an arbitrary parameter against curvature data. Requires SciPy.
|
|
180
|
+
|
|
181
|
+
``setter(stack, value)`` must return a NEW stack with the parameter applied;
|
|
182
|
+
the stack passed in is never modified. Use this only where the dependence is
|
|
183
|
+
genuinely nonlinear -- for an intrinsic stress the exact routines above are
|
|
184
|
+
better in every respect.
|
|
185
|
+
"""
|
|
186
|
+
try:
|
|
187
|
+
from scipy.optimize import least_squares
|
|
188
|
+
except ImportError as exc: # pragma: no cover - depends on the environment
|
|
189
|
+
raise ImportError(
|
|
190
|
+
"fit_parameter needs SciPy, which is not installed. Either "
|
|
191
|
+
"`pip install waferbow[fit]`, or use fit_intrinsic_stress / "
|
|
192
|
+
"fit_stress_from_curvature_vs_temperature, which are exact and "
|
|
193
|
+
"need no optimiser."
|
|
194
|
+
) from exc
|
|
195
|
+
|
|
196
|
+
T = np.asarray(temperatures, dtype=float)
|
|
197
|
+
k = np.asarray(measured_curvatures, dtype=float)
|
|
198
|
+
if T.shape != k.shape:
|
|
199
|
+
raise ValueError(
|
|
200
|
+
f"Got {T.size} temperatures and {k.size} curvatures; "
|
|
201
|
+
"they must correspond."
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
def residual(x: np.ndarray) -> np.ndarray:
|
|
205
|
+
trial = setter(stack, float(x[0]))
|
|
206
|
+
return np.array([
|
|
207
|
+
trial.solve(temperature=float(t), T_ref=T_ref).curvature - ki
|
|
208
|
+
for t, ki in zip(T, k)
|
|
209
|
+
])
|
|
210
|
+
|
|
211
|
+
out = least_squares(residual, x0=[initial], bounds=bounds)
|
|
212
|
+
return CalibrationResult(
|
|
213
|
+
fitted_values={param_name: float(out.x[0])},
|
|
214
|
+
residuals=np.asarray(out.fun),
|
|
215
|
+
success=bool(out.success),
|
|
216
|
+
message=str(out.message),
|
|
217
|
+
raw_result=out,
|
|
218
|
+
)
|
waferbow/cli.py
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"""The ``waferbow`` command line.
|
|
2
|
+
|
|
3
|
+
Four commands, chosen because they are the four things people actually do:
|
|
4
|
+
|
|
5
|
+
``solve`` a stack file at one temperature
|
|
6
|
+
``sweep`` the same stack across a temperature range
|
|
7
|
+
``stress`` the inverse Stoney a metrology tool leaves you to do by hand
|
|
8
|
+
``materials`` search the curated database
|
|
9
|
+
|
|
10
|
+
Every command that computes a bow also prints the validity report, because a
|
|
11
|
+
number without it is the failure mode this package exists to prevent. Nothing
|
|
12
|
+
here is silent about a check that did not pass.
|
|
13
|
+
|
|
14
|
+
Exit status is 0 on success, 1 on a bad input, and 2 when the answer computed
|
|
15
|
+
but a validity check FAILED -- so a script can tell "wrong" from "shaky". A
|
|
16
|
+
warning prints but does not change the status, because the deep thermal
|
|
17
|
+
excursions that trigger the CTE warning are most of the real work; pass
|
|
18
|
+
``--strict`` to make warnings count too.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import argparse
|
|
24
|
+
import math
|
|
25
|
+
import sys
|
|
26
|
+
from typing import Optional, Sequence
|
|
27
|
+
|
|
28
|
+
from . import __version__, materials
|
|
29
|
+
from .curated import CONFIDENCE_ORDER, database
|
|
30
|
+
from .io import load_stack, write_history_csv, write_result_csv
|
|
31
|
+
from .stoney import stoney_stress
|
|
32
|
+
|
|
33
|
+
EXIT_OK = 0
|
|
34
|
+
EXIT_BAD_INPUT = 1
|
|
35
|
+
EXIT_INVALID = 2
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _report(result, stream, strict: bool = False) -> bool:
|
|
39
|
+
"""Print the validity report. Returns True if the run should exit clean."""
|
|
40
|
+
report = result.validity()
|
|
41
|
+
print(file=stream)
|
|
42
|
+
print(str(report), file=stream)
|
|
43
|
+
return report.ok if strict else report.worst != "FAIL"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _print_result(result, stack, stream) -> None:
|
|
47
|
+
print(f" curvature {result.curvature:+.6e} 1/m", file=stream)
|
|
48
|
+
radius = float("inf") if result.curvature == 0 else 1.0 / result.curvature
|
|
49
|
+
print(f" radius {radius:+.4g} m", file=stream)
|
|
50
|
+
if result.bow is None:
|
|
51
|
+
print(" bow - (the stack has no diameter)", file=stream)
|
|
52
|
+
else:
|
|
53
|
+
print(f" bow {result.bow * 1e6:+.3f} um", file=stream)
|
|
54
|
+
for i, layer in enumerate(stack.films):
|
|
55
|
+
print(f" film {i} stress {result.mean_film_stress(i) / 1e6:+9.1f} MPa"
|
|
56
|
+
f" ({layer.material.name})", file=stream)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _report_status(result, strict: bool) -> bool:
|
|
60
|
+
report = result.validity()
|
|
61
|
+
return report.ok if strict else report.worst != "FAIL"
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
# ---------------------------------------------------------------------------
|
|
65
|
+
|
|
66
|
+
def cmd_solve(args: argparse.Namespace, stream) -> int:
|
|
67
|
+
stack = load_stack(args.stack)
|
|
68
|
+
result = stack.solve(temperature=args.temperature_C + 273.15,
|
|
69
|
+
T_ref=args.reference_C + 273.15)
|
|
70
|
+
print(f"{args.stack} at {args.temperature_C:g} C", file=stream)
|
|
71
|
+
_print_result(result, stack, stream)
|
|
72
|
+
if args.csv:
|
|
73
|
+
write_result_csv(result, args.csv)
|
|
74
|
+
print(f"\n wrote {args.csv}", file=stream)
|
|
75
|
+
return EXIT_OK if _report(result, stream, args.strict) else EXIT_INVALID
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def cmd_sweep(args: argparse.Namespace, stream) -> int:
|
|
79
|
+
if args.steps < 2:
|
|
80
|
+
raise ValueError(f"--steps must be at least 2, got {args.steps}.")
|
|
81
|
+
stack = load_stack(args.stack)
|
|
82
|
+
span = args.to_C - args.from_C
|
|
83
|
+
temps_C = [args.from_C + span * i / (args.steps - 1) for i in range(args.steps)]
|
|
84
|
+
results = [stack.solve(temperature=t + 273.15,
|
|
85
|
+
T_ref=args.reference_C + 273.15) for t in temps_C]
|
|
86
|
+
|
|
87
|
+
print(f"{args.stack}, {args.from_C:g} to {args.to_C:g} C", file=stream)
|
|
88
|
+
print(f" {'T [C]':>9} {'curvature [1/m]':>17} {'bow [um]':>11}", file=stream)
|
|
89
|
+
print(" " + "-" * 41, file=stream)
|
|
90
|
+
for t, r in zip(temps_C, results):
|
|
91
|
+
bow = " -" if r.bow is None else f"{r.bow * 1e6:+11.3f}"
|
|
92
|
+
print(f" {t:9.2f} {r.curvature:+17.6e} {bow}", file=stream)
|
|
93
|
+
|
|
94
|
+
if args.csv:
|
|
95
|
+
write_history_csv(results, args.csv, [t + 273.15 for t in temps_C])
|
|
96
|
+
print(f"\n wrote {args.csv}", file=stream)
|
|
97
|
+
|
|
98
|
+
# A sweep leaves its validity envelope at whichever end bows hardest, so
|
|
99
|
+
# that is the state worth showing -- but the status covers every step.
|
|
100
|
+
ok = all(_report_status(r, args.strict) for r in results)
|
|
101
|
+
worst = max(results, key=lambda r: abs(r.curvature))
|
|
102
|
+
print(f"\n worst case, {temps_C[results.index(worst)]:g} C:", file=stream)
|
|
103
|
+
_report(worst, stream, args.strict)
|
|
104
|
+
return EXIT_OK if ok else EXIT_INVALID
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def cmd_stress(args: argparse.Namespace, stream) -> int:
|
|
108
|
+
"""Inverse Stoney. The one calculation everyone does in a spreadsheet."""
|
|
109
|
+
if args.substrate_modulus_GPa is not None:
|
|
110
|
+
M = args.substrate_modulus_GPa * 1e9
|
|
111
|
+
source = "given"
|
|
112
|
+
else:
|
|
113
|
+
M = materials.get(
|
|
114
|
+
"Si(001)" if args.orientation == "001" else "Si(111)"
|
|
115
|
+
).biaxial_modulus
|
|
116
|
+
source = f"Si({args.orientation})"
|
|
117
|
+
|
|
118
|
+
for label, value in (("--diameter-mm", args.diameter_mm),
|
|
119
|
+
("--substrate-thickness-um", args.substrate_thickness_um),
|
|
120
|
+
("--film-thickness-nm", args.film_thickness_nm)):
|
|
121
|
+
if not math.isfinite(value) or value <= 0.0:
|
|
122
|
+
raise ValueError(f"{label} must be finite and positive, got {value!r}.")
|
|
123
|
+
|
|
124
|
+
diameter = args.diameter_mm / 1e3
|
|
125
|
+
curvature = 8.0 * (args.bow_um / 1e6) / diameter**2
|
|
126
|
+
stress = stoney_stress(curvature, args.film_thickness_nm / 1e9,
|
|
127
|
+
M, args.substrate_thickness_um / 1e6)
|
|
128
|
+
|
|
129
|
+
print(f" bow {args.bow_um:+.3f} um over {args.diameter_mm:g} mm",
|
|
130
|
+
file=stream)
|
|
131
|
+
print(f" curvature {curvature:+.6e} 1/m", file=stream)
|
|
132
|
+
print(f" M_substrate {M / 1e9:.2f} GPa ({source})", file=stream)
|
|
133
|
+
print(f" film stress {stress / 1e6:+.1f} MPa "
|
|
134
|
+
f"({'tensile' if stress > 0 else 'compressive'})", file=stream)
|
|
135
|
+
print(f" stress-thickness {stress * args.film_thickness_nm / 1e9:+.4f} Pa*m",
|
|
136
|
+
file=stream)
|
|
137
|
+
|
|
138
|
+
ratio = (args.film_thickness_nm / 1e9) / (args.substrate_thickness_um / 1e6)
|
|
139
|
+
if ratio > 0.01:
|
|
140
|
+
print(f"\n WARNING: the film is {ratio:.1%} of the substrate thickness. "
|
|
141
|
+
"Stoney\n assumes a thin film; above ~1% use the full "
|
|
142
|
+
"solver.", file=stream)
|
|
143
|
+
return EXIT_INVALID
|
|
144
|
+
return EXIT_OK
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def cmd_materials(args: argparse.Namespace, stream) -> int:
|
|
148
|
+
db = database()
|
|
149
|
+
entries = db.search(name=args.name, method=args.method,
|
|
150
|
+
min_confidence=args.min_confidence)
|
|
151
|
+
if args.variant:
|
|
152
|
+
entries = [e for e in entries if args.variant.lower() in e.variant.lower()]
|
|
153
|
+
|
|
154
|
+
if not entries:
|
|
155
|
+
print(" nothing matched.", file=stream)
|
|
156
|
+
print(f" materials: {', '.join(db.names())}", file=stream)
|
|
157
|
+
return EXIT_BAD_INPUT
|
|
158
|
+
|
|
159
|
+
if args.verbose:
|
|
160
|
+
for e in entries:
|
|
161
|
+
print(f"\n{e.variant}", file=stream)
|
|
162
|
+
print(f" {e.display_name} -- {e.process.describe()}", file=stream)
|
|
163
|
+
print(f" M = {e.material.biaxial_modulus / 1e9:.1f} GPa", file=stream)
|
|
164
|
+
if e.typical_stress_Pa is not None:
|
|
165
|
+
print(f" typical stress {e.typical_stress_Pa / 1e6:+.0f} MPa",
|
|
166
|
+
file=stream)
|
|
167
|
+
print(f" {e.material.provenance}", file=stream)
|
|
168
|
+
else:
|
|
169
|
+
print(f" {'variant':<34} {'M [GPa]':>8} {'sigma [MPa]':>11} confidence",
|
|
170
|
+
file=stream)
|
|
171
|
+
print(" " + "-" * 74, file=stream)
|
|
172
|
+
for e in entries:
|
|
173
|
+
sigma = ("" if e.typical_stress_Pa is None
|
|
174
|
+
else f"{e.typical_stress_Pa / 1e6:+.0f}")
|
|
175
|
+
print(f" {e.variant:<34} {e.material.biaxial_modulus / 1e9:8.1f} "
|
|
176
|
+
f"{sigma:>11} {e.confidence}", file=stream)
|
|
177
|
+
print(f"\n {len(entries)} of {len(db)} entries. "
|
|
178
|
+
"Read the confidence grade before the number.", file=stream)
|
|
179
|
+
return EXIT_OK
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
# ---------------------------------------------------------------------------
|
|
183
|
+
|
|
184
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
185
|
+
parser = argparse.ArgumentParser(
|
|
186
|
+
prog="waferbow",
|
|
187
|
+
description="Multilayer thin-film stress and wafer bow.",
|
|
188
|
+
)
|
|
189
|
+
parser.add_argument("--version", action="version",
|
|
190
|
+
version=f"waferbow {__version__}")
|
|
191
|
+
sub = parser.add_subparsers(dest="command")
|
|
192
|
+
|
|
193
|
+
p = sub.add_parser("solve", help="solve a stack file at one temperature")
|
|
194
|
+
p.add_argument("stack", help="stack description (.json, .yaml, .yml)")
|
|
195
|
+
p.add_argument("--temperature-C", type=float, default=25.0,
|
|
196
|
+
help="temperature to solve at [C] (default 25)")
|
|
197
|
+
p.add_argument("--reference-C", type=float, default=20.0,
|
|
198
|
+
help="stress-free reference for layers that name none "
|
|
199
|
+
"[C] (default 20)")
|
|
200
|
+
p.add_argument("--csv", help="also write the result here")
|
|
201
|
+
p.add_argument("--strict", action="store_true",
|
|
202
|
+
help="exit non-zero on a validity warning, not just a failure")
|
|
203
|
+
p.set_defaults(func=cmd_solve)
|
|
204
|
+
|
|
205
|
+
p = sub.add_parser("sweep", help="solve across a temperature range")
|
|
206
|
+
p.add_argument("stack", help="stack description (.json, .yaml, .yml)")
|
|
207
|
+
p.add_argument("--from-C", type=float, required=True, dest="from_C")
|
|
208
|
+
p.add_argument("--to-C", type=float, required=True, dest="to_C")
|
|
209
|
+
p.add_argument("--steps", type=int, default=11)
|
|
210
|
+
p.add_argument("--reference-C", type=float, default=20.0)
|
|
211
|
+
p.add_argument("--csv", help="also write the sweep here")
|
|
212
|
+
p.add_argument("--strict", action="store_true",
|
|
213
|
+
help="exit non-zero on a validity warning, not just a failure")
|
|
214
|
+
p.set_defaults(func=cmd_sweep)
|
|
215
|
+
|
|
216
|
+
p = sub.add_parser(
|
|
217
|
+
"stress", help="film stress from a measured bow (inverse Stoney)",
|
|
218
|
+
epilog="Pass the CHANGE in bow between pre- and post-deposition, not "
|
|
219
|
+
"the absolute bow of the finished wafer.",
|
|
220
|
+
)
|
|
221
|
+
p.add_argument("--bow-um", type=float, required=True,
|
|
222
|
+
help="measured bow change [um], concave positive")
|
|
223
|
+
p.add_argument("--diameter-mm", type=float, required=True)
|
|
224
|
+
p.add_argument("--substrate-thickness-um", type=float, required=True)
|
|
225
|
+
p.add_argument("--film-thickness-nm", type=float, required=True)
|
|
226
|
+
p.add_argument("--orientation", choices=("001", "111"), default="001",
|
|
227
|
+
help="silicon orientation for the biaxial modulus "
|
|
228
|
+
"(default 001)")
|
|
229
|
+
p.add_argument("--substrate-modulus-GPa", type=float, default=None,
|
|
230
|
+
dest="substrate_modulus_GPa",
|
|
231
|
+
help="override the substrate biaxial modulus")
|
|
232
|
+
p.set_defaults(func=cmd_stress)
|
|
233
|
+
|
|
234
|
+
p = sub.add_parser("materials", help="search the curated database")
|
|
235
|
+
p.add_argument("--name", help="base material, e.g. Si3N4")
|
|
236
|
+
p.add_argument("--method", help="deposition method, e.g. PECVD")
|
|
237
|
+
p.add_argument("--variant", help="substring of the variant key")
|
|
238
|
+
p.add_argument("--min-confidence", choices=CONFIDENCE_ORDER,
|
|
239
|
+
dest="min_confidence")
|
|
240
|
+
p.add_argument("--verbose", "-v", action="store_true",
|
|
241
|
+
help="show provenance for each entry")
|
|
242
|
+
p.set_defaults(func=cmd_materials)
|
|
243
|
+
|
|
244
|
+
return parser
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def main(argv: Optional[Sequence[str]] = None, stream=None) -> int:
|
|
248
|
+
stream = sys.stdout if stream is None else stream
|
|
249
|
+
parser = build_parser()
|
|
250
|
+
args = parser.parse_args(argv)
|
|
251
|
+
if args.command is None:
|
|
252
|
+
parser.print_help(stream)
|
|
253
|
+
return EXIT_BAD_INPUT
|
|
254
|
+
try:
|
|
255
|
+
return args.func(args, stream)
|
|
256
|
+
except (OSError, ValueError, KeyError, TypeError, ImportError,
|
|
257
|
+
ZeroDivisionError, IndexError) as exc:
|
|
258
|
+
print(f"error: {exc}", file=sys.stderr)
|
|
259
|
+
return EXIT_BAD_INPUT
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
if __name__ == "__main__": # pragma: no cover
|
|
263
|
+
sys.exit(main())
|