API
Device model
tempura.electrostatics.device
Device geometry helpers for building meshing regions.
Device
Container for device layers and derived height/shape fields.
Attributes:
| Name | Type | Description |
|---|---|---|
L |
Device length. |
|
W |
Device width. |
|
dx |
Grid spacing in x. |
|
dy |
Grid spacing in y. |
|
min_grid_resolution |
Global minimum mesh resolution used by electrostatics. |
|
grid_shape |
Array shape (rows, cols) for masks. |
|
layers |
dict[str, Layer]
|
Layers in stacking order. |
Source code in tempura/electrostatics/device.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
__init__(device_size)
Create a device with (L, W, dx, dy).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device_size
|
tuple[float, float, float, float]
|
Tuple of (L, W, dx, dy). |
required |
Source code in tempura/electrostatics/device.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
add_layer(layer)
Add a layer (order matters for stacking).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
Layer
|
Layer instance to add. |
required |
Source code in tempura/electrostatics/device.py
178 179 180 181 182 183 184 185 | |
finalize()
Compute height fields and shapes for all layers.
Source code in tempura/electrostatics/device.py
187 188 189 190 191 | |
Dielectric
dataclass
Bases: LayerBase
Dielectric layer covering the full XY domain.
Source code in tempura/electrostatics/device.py
108 109 110 111 112 | |
Gate
dataclass
Bases: LayerBase
Metallic gate layer.
Requires a stencil and does not define a dielectric constant.
Source code in tempura/electrostatics/device.py
93 94 95 96 97 98 99 100 101 102 103 104 105 | |
__post_init__()
Validate required attributes after dataclass init.
Source code in tempura/electrostatics/device.py
102 103 104 105 | |
LayerBase
dataclass
Shared data and helpers for device layers.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Layer name. |
resolution |
ndarray
|
Mesh resolution for this layer. |
thickness |
float
|
Layer thickness. |
deposition_group |
str | None
|
Optional deposition group identifier used to keep multiple gates at the same physical z-level. |
z_bot_arr |
ndarray | None
|
Cached bottom height field on the device grid. |
z_top_arr |
ndarray | None
|
Cached top height field on the device grid. |
z_bot_fn |
Callable[[float, float], float] | None
|
Function returning bottom height at (x, y). |
z_top_fn |
Callable[[float, float], float] | None
|
Function returning top height at (x, y). |
shape |
Shape | None
|
Cached geometry shape. |
Source code in tempura/electrostatics/device.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
box(L, W, z0)
Return a simple box covering the full device footprint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
L
|
float
|
Device length. |
required |
W
|
float
|
Device width. |
required |
z0
|
float
|
Bottom z coordinate. |
required |
Returns:
| Type | Description |
|---|---|
Box
|
A box shape covering the device footprint. |
Source code in tempura/electrostatics/device.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
TwoDEG
dataclass
Bases: LayerBase
Two-dimensional electron gas (2DEG) layer.
Attributes:
| Name | Type | Description |
|---|---|---|
permitivity |
float
|
Relative permittivity for the region. |
boundary_condition |
Literal['neumann', 'helmholtz', 'flexible']
|
Boundary condition type for the region. |
Source code in tempura/electrostatics/device.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
__post_init__()
Validate boundary condition choice.
Source code in tempura/electrostatics/device.py
127 128 129 130 131 132 133 134 | |
Linear solver
tempura.electrostatics.solver
Sparse linear-system helpers for Tempura electrostatics solves.
This module is intentionally independent from Pescado's geometry assembly. It only deals with constrained sparse linear systems, RHS construction, and MUMPS factorization reuse.
build_rhs_vectors(region_inds, gate_names, *, size=None, charge=None, dtype=DTYPE)
Build the multi-RHS matrix for the ordered gate basis solves.
Source code in tempura/electrostatics/solver.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
setup_solver(matrix, *, dtype=DTYPE, blr=BLR, eps_blr=EPS_BLR, symmetric=False)
Create and factor a MUMPS solver for a sparse linear system.
Source code in tempura/electrostatics/solver.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
solve_linear_system(matrix, rhs, *, solver=None, dtype=DTYPE, blr=BLR, eps_blr=EPS_BLR, symmetric=False)
Solve matrix x = rhs with a factored MUMPS solver.
Source code in tempura/electrostatics/solver.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
Pescado wrapper
tempura.electrostatics.pescado_wrapper
Pescado-specific problem assembly for Tempura devices.
build_problem(device, vacuum_scale=8.0, vacuum_resolution_factor=1 / 4, *, verbose=False)
Build a Poisson problem for a layered device.
Creates a vacuum simulation region around the device, refines the mesh for each layer, assigns material properties, and sets boundary conditions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
Any
|
Device instance with layers added. |
required |
vacuum_scale
|
float
|
Multiplier for the vacuum region size relative to device. |
8.0
|
vacuum_resolution_factor
|
float
|
Factor to scale the vacuum resolution relative to device size. |
1 / 4
|
verbose
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
tuple[ProblemBuilder, RegionMap, list[str]]
|
Tuple of (problem_builder, region_shapes, gate_names). |
Source code in tempura/electrostatics/pescado_wrapper.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
get_region_inds(pescado_problem_finalized, gate_shapes, boundary_shape, *, boundary_name='Boundary')
Return indices for interior, gates, and the outer boundary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pescado_problem_finalized
|
Any
|
Finalized problem instance from Pescado. |
required |
gate_shapes
|
RegionMap
|
Mapping of gate name -> shape. |
required |
boundary_shape
|
Shape
|
Shape for the outer boundary shell. |
required |
boundary_name
|
str
|
Name to use for the boundary in the output mapping. |
'Boundary'
|
Returns:
| Type | Description |
|---|---|
IndexMap
|
Dict mapping region names to indices. |
Source code in tempura/electrostatics/pescado_wrapper.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | |
solve_gate_potentials(problem_builder, region_shapes, gate_names, *, charge=None, dtype=DTYPE, blr=BLR, eps_blr=EPS_BLR, rhs_block_size=8, verbose=False)
Solve the gate basis problem with one MUMPS factorization.
Dirichlet conditions are enforced on the outer boundary (0 V) and gate rows. The raw capacitance matrix is rewritten into a symmetry-preserving Dirichlet system, factored once with MUMPS, and solved in RHS blocks to limit peak memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem_builder
|
ProblemBuilder
|
Pescado problem builder. |
required |
region_shapes
|
RegionMap
|
Mapping of region names to shapes. |
required |
gate_names
|
list[str]
|
Names of gates to solve. |
required |
charge
|
ndarray | None
|
Optional interior charge columns to include in the RHS. |
None
|
dtype
|
DTypeLike
|
Numeric dtype used for factorization and solve. |
DTYPE
|
blr
|
bool
|
Whether to enable block low-rank MUMPS factorization. |
BLR
|
eps_blr
|
float
|
BLR compression threshold used when |
EPS_BLR
|
rhs_block_size
|
int
|
Number of gate basis columns to solve per MUMPS call. |
8
|
verbose
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
PotentialMap
|
Tuple of (results, finalized_problem), where results maps gate name to |
Any
|
the solved potential vector. |
Source code in tempura/electrostatics/pescado_wrapper.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | |