Skip to content

Commit 5ecb224

Browse files
committed
fixed ion implant table loading first pass
1 parent aed9436 commit 5ecb224

10 files changed

Lines changed: 133 additions & 241 deletions

File tree

AGENTS.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ PiezoD/
1414
│ │ ├── cantileverImplantation.m
1515
│ │ ├── cantileverPiezoelectric.m
1616
│ │ ├── cantileverPoly.m
17-
│ │ ├── lookupTable.mat # Precomputed data
17+
│ │ ├── ionImplantLookupTable.mat # Ion implant lookup data
1818
│ │ └── sensorSimulation.mdl # Simulink model
1919
│ └── sampleCode.m # Usage example
2020
├── python/ # Python port (in progress)
@@ -24,8 +24,10 @@ PiezoD/
2424
│ │ ├── cantilever_epitaxy.py
2525
│ │ ├── cantilever_implantation.py
2626
│ │ ├── cantilever_piezoelectric.py
27-
│ │ └── cantilever_poly.py
28-
│ ├── tests/ # Test suite (empty)
27+
│ │ ├── cantilever_poly.py
28+
│ │ └── data/ # Bundled data files
29+
│ │ └── ionImplantLookupTable.h5
30+
│ ├── tests/ # Test suite
2931
│ ├── examples/ # Usage examples
3032
│ └── archive/ # Legacy/experimental scripts
3133
├── lookupTableGeneration/ # FLOOXS TCAD simulation (Docker)
@@ -34,7 +36,7 @@ PiezoD/
3436
│ ├── templates/ # FLOOXS simulation templates
3537
│ ├── simulations/ # Input/output directory
3638
│ ├── legacy/ # TSUPREM-4 reference files
37-
│ └── lookupTable.mat # Generated data
39+
│ └── lookupTable.mat # Generated source data
3840
├── Docs/ # Website (jemdoc)
3941
│ ├── html/ # Generated HTML
4042
│ └── cgi-bin/ # Download scripts

lookupTableGeneration/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ ENV FLXSHOME=/opt/flooxs
2121
ENV PL_LIBRARY=/usr/share/plplot5.15.0/tcl/
2222

2323
# Build FLOOXS
24-
WORKDIR /opt/flooxs/src
25-
RUN mkdir -p release && cd release && cmake .. && make -j$(nproc)
24+
WORKDIR /opt/flooxs
25+
RUN cp src/License.pdf . && mkdir -p build && cd build && cmake .. && make -j$(nproc)
2626

2727
# Create working directory for simulations
2828
WORKDIR /work
2929

3030
# The built executable
31-
ENTRYPOINT ["/opt/flooxs/src/release/flooxs"]
31+
ENTRYPOINT ["/opt/flooxs/build/flooxs"]

matlab/PiezoD/cantileverImplantation.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
% Load the lookup table
4545
try
46-
data = open('lookupTable.mat');
46+
data = open('ionImplantLookupTable.mat');
4747
self.lookupTableData = data;
4848
catch
4949
fprintf('Dopant type: %s\n', self.doping_type);

python/examples/ion_implantation.py

Lines changed: 29 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
touch sensation in C. elegans.
1111
"""
1212

13-
from pathlib import Path
14-
1513
import addcopyfighandler # noqa: F401
16-
import scipy.io
1714

1815
from piezod import CantileverImplantation
1916

@@ -66,17 +63,6 @@
6663
c.fluid = "air"
6764
c.number_of_piezoresistors = 4 # Full bridge for temperature compensation
6865

69-
# Load the lookup table for electrical calculations
70-
lookup_path = Path(__file__).parent.parent.parent / "matlab" / "PiezoD" / "lookupTable.mat"
71-
if lookup_path.exists():
72-
mat_data = scipy.io.loadmat(str(lookup_path), squeeze_me=True)
73-
c.load_lookup_table(mat_data)
74-
lookup_loaded = True
75-
else:
76-
print(f"Warning: Lookup table not found at {lookup_path}")
77-
print("Electrical parameters requiring lookup table will not be available.")
78-
lookup_loaded = False
79-
8066
# Print design summary
8167
print("=== Ion-Implanted Cantilever Design ===")
8268
print("Based on Park et al. JMEMS 2010 (optimized for C. elegans force sensing)")
@@ -129,35 +115,34 @@ def print_row(name, model_str, paper_val, tol=0.15):
129115
print_row("Stiffness (mN/m)", f"{stiffness:.2f}", paper["stiffness_mN_m"])
130116
print_row("Resonant freq (kHz)", f"{freq:.2f}", paper["freq_kHz"])
131117

132-
# Electrical properties (require lookup table)
133-
if lookup_loaded:
134-
Rs = c.sheet_resistance()
135-
beta = c.beta()
136-
Xj = c.junction_depth * 1e6 # um
137-
resistance = c.resistance()
138-
power = c.power_dissipation() * 1e3 # mW
139-
sqrt_Dt = c.diffusion_length * 1e4 # um
140-
141-
print_row("Junction depth t_p (um)", f"{Xj:.2f}", paper["junction_depth_um"], tol=0.25)
142-
print_row("Resistance R_piezo (Ohm)", f"{resistance:.0f}", paper["resistance_ohm"], tol=0.25)
143-
print_row("Beta* (efficiency)", f"{beta:.2f}", paper["beta_star"])
144-
print_row("sqrt(Dt) (um)", f"{sqrt_Dt:.4f}", paper["sqrt_Dt_um"])
145-
print_row("Power dissipation (mW)", f"{power:.2f}", paper["power_mW"])
146-
147-
# Performance metrics
148-
print("-" * 62)
149-
force_sensitivity = c.force_sensitivity()
150-
force_res = c.force_resolution() * 1e12 # pN
151-
152-
print_row("Sensitivity S_FV (V/N)", f"{force_sensitivity:.0f}", paper["sensitivity_V_N"])
153-
print_row("Force resolution (pN)", f"{force_res:.1f}", paper["force_resolution_pN"])
154-
155-
# Additional derived parameters
156-
print("-" * 62)
157-
print(" Additional Parameters:")
158-
print(f" Sheet resistance: {Rs:.1f} Ohm/sq")
159-
print(f" Hooge parameter alpha: {c.alpha():.2e}")
160-
print(f" Number of squares: {c.number_of_squares():.1f}")
161-
print(f" Piezoresistor width: {c.w_pr() * 1e6:.1f} um")
118+
# Electrical properties (from bundled lookup table)
119+
Rs = c.sheet_resistance()
120+
beta = c.beta()
121+
Xj = c.junction_depth * 1e6 # um
122+
resistance = c.resistance()
123+
power = c.power_dissipation() * 1e3 # mW
124+
sqrt_Dt = c.diffusion_length * 1e4 # um
125+
126+
print_row("Junction depth t_p (um)", f"{Xj:.2f}", paper["junction_depth_um"], tol=0.25)
127+
print_row("Resistance R_piezo (Ohm)", f"{resistance:.0f}", paper["resistance_ohm"], tol=0.25)
128+
print_row("Beta* (efficiency)", f"{beta:.2f}", paper["beta_star"])
129+
print_row("sqrt(Dt) (um)", f"{sqrt_Dt:.4f}", paper["sqrt_Dt_um"])
130+
print_row("Power dissipation (mW)", f"{power:.2f}", paper["power_mW"])
131+
132+
# Performance metrics
133+
print("-" * 62)
134+
force_sensitivity = c.force_sensitivity()
135+
force_res = c.force_resolution() * 1e12 # pN
136+
137+
print_row("Sensitivity S_FV (V/N)", f"{force_sensitivity:.0f}", paper["sensitivity_V_N"])
138+
print_row("Force resolution (pN)", f"{force_res:.1f}", paper["force_resolution_pN"])
139+
140+
# Additional derived parameters
141+
print("-" * 62)
142+
print(" Additional Parameters:")
143+
print(f" Sheet resistance: {Rs:.1f} Ohm/sq")
144+
print(f" Hooge parameter alpha: {c.alpha():.2e}")
145+
print(f" Number of squares: {c.number_of_squares():.1f}")
146+
print(f" Piezoresistor width: {c.w_pr() * 1e6:.1f} um")
162147

163148
print("=" * 62)

python/examples/ion_implantation_figures.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
import addcopyfighandler # noqa: F401
1010
import matplotlib.pyplot as plt
1111
import numpy as np
12-
import scipy.io
12+
13+
from piezod.cantilever_implantation import _load_lookup_table
1314

1415
plt.style.use("piezod.default")
1516

16-
# Load lookup table
17-
lookup_path = Path(__file__).parent.parent.parent / "matlab" / "PiezoD" / "lookupTable.mat"
18-
mat_data = scipy.io.loadmat(str(lookup_path), squeeze_me=True)
17+
# Load bundled lookup table
18+
mat_data = _load_lookup_table()
1919

2020
# Available parameter ranges from lookup table
2121
DOSES = mat_data["ImplantDoses"] # [2e14, 2e15, 2e16]

python/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ dependencies = [
2727
"scipy>=1.7.0",
2828
"matplotlib>=3.4.0",
2929
"addcopyfighandler>=2.0.0",
30+
"h5py>=3.0.0",
3031
]
3132

3233
[project.optional-dependencies]

0 commit comments

Comments
 (0)