Skip to content

Commit 8425844

Browse files
committed
lint
1 parent 47ad023 commit 8425844

2 files changed

Lines changed: 67 additions & 91 deletions

File tree

python/src/piezod/cantilever_piezoelectric.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ class CantileverPiezoelectric:
100100
# Sader lookup table for hydrodynamic function
101101
# kappa = C * w / l, where C = 1.8751 for first mode
102102
KAPPA_LOOKUP = np.array([0, 0.125, 0.25, 0.5, 0.75, 1, 2, 3, 5, 7, 10, 20])
103-
REYNOLDS_LOOKUP = np.array(
104-
[-4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4]
105-
)
103+
REYNOLDS_LOOKUP = np.array([-4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4])
106104

107105
# fmt: off
108106
TAU_LOOKUP_REAL = np.array([
@@ -255,11 +253,16 @@ def stiffness(self) -> float:
255253
@property
256254
def effective_mass(self) -> float:
257255
"""Calculate effective mass (kg)."""
258-
return 0.243 * self.w_si * self.l_si * (
259-
self.t_si * self.RHO_SI
260-
+ self.T_BOTTOM_ELECTRODE * self.RHO_ELECTRODE
261-
+ self.t_pe * self.rho_pe
262-
+ self.T_TOP_ELECTRODE * self.RHO_ELECTRODE
256+
return (
257+
0.243
258+
* self.w_si
259+
* self.l_si
260+
* (
261+
self.t_si * self.RHO_SI
262+
+ self.T_BOTTOM_ELECTRODE * self.RHO_ELECTRODE
263+
+ self.t_pe * self.rho_pe
264+
+ self.T_TOP_ELECTRODE * self.RHO_ELECTRODE
265+
)
263266
)
264267

265268
@property
@@ -321,9 +324,7 @@ def q_x_sensitivity(self, freq: NDArray[np.float64]) -> NDArray[np.float64]:
321324
def v_f_sensitivity(self, freq: NDArray[np.float64]) -> NDArray[np.float64]:
322325
"""Calculate voltage force sensitivity (V/N)."""
323326
omega = 2 * np.pi * freq
324-
return 2 * omega * self.q_f_sensitivity_intrinsic * self.R_half / (
325-
1 + omega * self.R_half * self.C_half
326-
)
327+
return 2 * omega * self.q_f_sensitivity_intrinsic * self.R_half / (1 + omega * self.R_half * self.C_half)
327328

328329
def v_x_sensitivity(self, freq: NDArray[np.float64]) -> NDArray[np.float64]:
329330
"""Calculate voltage displacement sensitivity (V/m)."""
@@ -377,9 +378,7 @@ def residual(omega_d: float) -> float:
377378
if omega_d <= 0:
378379
return 1e10
379380
hydro = self._hydrodynamic_function(omega_d, rho_f, eta_f)
380-
target = omega_vac * (
381-
1 + np.pi * rho_f * self.w_si / (4 * self.RHO_SI * self.t_si) * hydro.real
382-
) ** -0.5
381+
target = omega_vac * (1 + np.pi * rho_f * self.w_si / (4 * self.RHO_SI * self.t_si) * hydro.real) ** -0.5
383382
return (omega_d - target) ** 2
384383

385384
result = minimize_scalar(residual, bounds=(0, omega_vac), method="bounded")

python/src/piezod/cantilever_poly.py

Lines changed: 54 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -172,18 +172,22 @@ def neutral_axis(self) -> float:
172172
Neutral axis position (m)
173173
"""
174174
# Centroid positions of each layer from bottom
175-
z = np.array([
176-
self.t_bot / 2,
177-
self.t_bot + self.t_mid / 2,
178-
self.t_bot + self.t_mid + self.t_top / 2,
179-
])
175+
z = np.array(
176+
[
177+
self.t_bot / 2,
178+
self.t_bot + self.t_mid / 2,
179+
self.t_bot + self.t_mid + self.t_top / 2,
180+
]
181+
)
180182

181183
# Elastic moduli
182-
E = np.array([
183-
self._get_elastic_modulus(self.matl_bot),
184-
self._get_elastic_modulus(self.matl_mid),
185-
self._get_elastic_modulus(self.matl_top),
186-
])
184+
E = np.array(
185+
[
186+
self._get_elastic_modulus(self.matl_bot),
187+
self._get_elastic_modulus(self.matl_mid),
188+
self._get_elastic_modulus(self.matl_top),
189+
]
190+
)
187191

188192
# Cross-sectional areas
189193
A = self.w * np.array([self.t_bot, self.t_mid, self.t_top])
@@ -200,27 +204,33 @@ def normalized_curvature(self) -> float:
200204
Zm = self.neutral_axis()
201205

202206
# Distance from neutral axis to each layer centroid
203-
z = np.array([
204-
self.t_bot / 2,
205-
self.t_bot + self.t_mid / 2,
206-
self.t_bot + self.t_mid + self.t_top / 2,
207-
])
207+
z = np.array(
208+
[
209+
self.t_bot / 2,
210+
self.t_bot + self.t_mid / 2,
211+
self.t_bot + self.t_mid + self.t_top / 2,
212+
]
213+
)
208214
Z = z - Zm
209215

210216
# Elastic moduli
211-
E = np.array([
212-
self._get_elastic_modulus(self.matl_bot),
213-
self._get_elastic_modulus(self.matl_mid),
214-
self._get_elastic_modulus(self.matl_top),
215-
])
217+
E = np.array(
218+
[
219+
self._get_elastic_modulus(self.matl_bot),
220+
self._get_elastic_modulus(self.matl_mid),
221+
self._get_elastic_modulus(self.matl_top),
222+
]
223+
)
216224

217225
# Cross-sectional areas and second moments of area
218226
A = self.w * np.array([self.t_bot, self.t_mid, self.t_top])
219-
I = self.w * np.array([
220-
self.t_bot**3 / 12,
221-
self.t_mid**3 / 12,
222-
self.t_top**3 / 12,
223-
])
227+
I = self.w * np.array(
228+
[
229+
self.t_bot**3 / 12,
230+
self.t_mid**3 / 12,
231+
self.t_top**3 / 12,
232+
]
233+
)
224234

225235
# EI_effective using parallel axis theorem
226236
return float(1.0 / np.sum(E * (I + A * Z**2)))
@@ -240,11 +250,13 @@ def resonant_frequency(self) -> float:
240250
Returns:
241251
Resonant frequency (Hz)
242252
"""
243-
densities = np.array([
244-
self._get_density(self.matl_bot),
245-
self._get_density(self.matl_mid),
246-
self._get_density(self.matl_top),
247-
])
253+
densities = np.array(
254+
[
255+
self._get_density(self.matl_bot),
256+
self._get_density(self.matl_mid),
257+
self._get_density(self.matl_top),
258+
]
259+
)
248260
thicknesses = np.array([self.t_bot, self.t_mid, self.t_top])
249261

250262
# Effective mass (0.243 is the first mode coefficient)
@@ -273,9 +285,7 @@ def mobility(self, dopant_concentration: float) -> float:
273285
alpha = 0.711
274286
beta = 1.98
275287

276-
mobility = mu_0 + (mu_max - mu_0) / (1 + (n / C_r) ** alpha) - mu_1 / (
277-
1 + (C_s / n) ** beta
278-
)
288+
mobility = mu_0 + (mu_max - mu_0) / (1 + (n / C_r) ** alpha) - mu_1 / (1 + (C_s / n) ** beta)
279289

280290
# 50% reduction for polycrystalline silicon
281291
return mobility * 0.5
@@ -350,22 +360,15 @@ def hooge_PSD(self, freq: NDArray[np.float64]) -> NDArray[np.float64]:
350360
Returns:
351361
Voltage PSD (V^2/Hz)
352362
"""
353-
return (
354-
self.alpha
355-
* self.v_bridge**2
356-
* self.number_of_piezoresistors
357-
/ (4 * self.number_of_carriers() * freq)
358-
)
363+
return self.alpha * self.v_bridge**2 * self.number_of_piezoresistors / (4 * self.number_of_carriers() * freq)
359364

360365
def hooge_integrated(self) -> float:
361366
"""Calculate integrated 1/f noise.
362367
363368
Returns:
364369
Integrated noise voltage (V)
365370
"""
366-
freq = np.logspace(
367-
np.log10(self.freq_min), np.log10(self.freq_max), self.numFrequencyPoints
368-
)
371+
freq = np.logspace(np.log10(self.freq_min), np.log10(self.freq_max), self.numFrequencyPoints)
369372
return float(np.sqrt(np.trapezoid(self.hooge_PSD(freq), freq)))
370373

371374
def johnson_PSD(self, freq: NDArray[np.float64]) -> NDArray[np.float64]:
@@ -385,9 +388,7 @@ def johnson_integrated(self) -> float:
385388
Returns:
386389
Integrated noise voltage (V)
387390
"""
388-
freq = np.logspace(
389-
np.log10(self.freq_min), np.log10(self.freq_max), self.numFrequencyPoints
390-
)
391+
freq = np.logspace(np.log10(self.freq_min), np.log10(self.freq_max), self.numFrequencyPoints)
391392
return float(np.sqrt(np.trapezoid(self.johnson_PSD(freq), freq)))
392393

393394
def thermo_PSD(self, freq: NDArray[np.float64]) -> NDArray[np.float64]:
@@ -416,9 +417,7 @@ def thermo_integrated(self) -> float:
416417
Returns:
417418
Integrated noise voltage (V)
418419
"""
419-
freq = np.logspace(
420-
np.log10(self.freq_min), np.log10(self.freq_max), self.numFrequencyPoints
421-
)
420+
freq = np.logspace(np.log10(self.freq_min), np.log10(self.freq_max), self.numFrequencyPoints)
422421
return float(np.sqrt(np.trapezoid(self.thermo_PSD(freq), freq)))
423422

424423
def amplifier_PSD(self, freq: NDArray[np.float64]) -> NDArray[np.float64]:
@@ -439,20 +438,15 @@ def amplifier_PSD(self, freq: NDArray[np.float64]) -> NDArray[np.float64]:
439438
A_IF = 25e-12 # A/sqrt(Hz) @ 1 Hz
440439

441440
R_effective = self.resistance() / 2
442-
return (
443-
(A_VJ**2 + 2 * (R_effective * A_IJ) ** 2)
444-
+ (A_VF**2 + 2 * (R_effective * A_IF) ** 2) / freq
445-
)
441+
return (A_VJ**2 + 2 * (R_effective * A_IJ) ** 2) + (A_VF**2 + 2 * (R_effective * A_IF) ** 2) / freq
446442

447443
def amplifier_integrated(self) -> float:
448444
"""Calculate integrated amplifier noise.
449445
450446
Returns:
451447
Integrated noise voltage (V)
452448
"""
453-
freq = np.logspace(
454-
np.log10(self.freq_min), np.log10(self.freq_max), self.numFrequencyPoints
455-
)
449+
freq = np.logspace(np.log10(self.freq_min), np.log10(self.freq_max), self.numFrequencyPoints)
456450
return float(np.sqrt(np.trapezoid(self.amplifier_PSD(freq), freq)))
457451

458452
def actuator_noise_integrated(self) -> float:
@@ -483,16 +477,9 @@ def integrated_noise(self) -> float:
483477
Returns:
484478
Integrated noise voltage (V)
485479
"""
486-
freq = np.logspace(
487-
np.log10(self.freq_min), np.log10(self.freq_max), self.numFrequencyPoints
488-
)
480+
freq = np.logspace(np.log10(self.freq_min), np.log10(self.freq_max), self.numFrequencyPoints)
489481
actuator = self.actuator_noise_integrated()
490-
total_psd = (
491-
self.johnson_PSD(freq)
492-
+ self.hooge_PSD(freq)
493-
+ self.thermo_PSD(freq)
494-
+ self.amplifier_PSD(freq)
495-
)
482+
total_psd = self.johnson_PSD(freq) + self.hooge_PSD(freq) + self.thermo_PSD(freq) + self.amplifier_PSD(freq)
496483
return float(np.sqrt(actuator**2 + np.trapezoid(total_psd, freq)))
497484

498485
def piezo_coefficient(self) -> float:
@@ -567,11 +554,7 @@ def power_dissipation(self) -> float:
567554
Returns:
568555
Power dissipation (W)
569556
"""
570-
return (
571-
self.number_of_piezoresistors_on_cantilever
572-
* self.v_bridge**2
573-
/ (4 * self.resistance())
574-
)
557+
return self.number_of_piezoresistors_on_cantilever * self.v_bridge**2 / (4 * self.resistance())
575558

576559
def force_resolution(self) -> float:
577560
"""Calculate minimum detectable force.
@@ -592,14 +575,8 @@ def displacement_resolution(self) -> float:
592575
def print_performance(self) -> None:
593576
"""Print cantilever performance summary."""
594577
print(f"Cantilever L/W: {self.l * 1e6:.1f} {self.w * 1e6:.1f} um")
595-
print(
596-
f"Layers - Bottom:{self.matl_bot.value} Mid:{self.matl_mid.value} "
597-
f"Top:{self.matl_top.value}"
598-
)
599-
print(
600-
f"Thicknesses (nm) - Bottom:{self.t_bot * 1e9:.1f} "
601-
f"Mid:{self.t_mid * 1e9:.1f} Top:{self.t_top * 1e9:.1f}"
602-
)
578+
print(f"Layers - Bottom:{self.matl_bot.value} Mid:{self.matl_mid.value} Top:{self.matl_top.value}")
579+
print(f"Thicknesses (nm) - Bottom:{self.t_bot * 1e9:.1f} Mid:{self.t_mid * 1e9:.1f} Top:{self.t_top * 1e9:.1f}")
603580
print(f"PR Length Ratio: {self.l_pr_ratio}")
604581
print(f"Bridge voltage: {self.v_bridge} V")
605582
print(f"Number of piezoresistors: {self.number_of_piezoresistors}")

0 commit comments

Comments
 (0)