tempura — the package root
tempura/__init__.py is the happy-path import for the core workflow. It
re-exports the handful of names you need to go from a layout to a solved
potential, so most scripts import everything from the top level.
The curated surface
from tempura import (
Device,
Dielectric,
Gate,
QuantumRegion,
prepare_layout,
build_device,
build_problem,
solve_gate_potentials,
)
These cover the whole path: describe a stack (Device, Gate, Dielectric,
QuantumRegion), turn a layout file into masks and a device
(prepare_layout, build_device), and assemble and solve the Poisson problem
(build_problem, solve_gate_potentials). The post-solve helpers
extract_quantum_region_plane(...) and extract_quantum_region_basis(...) live
one level down in tempura.electrostatics.
The root package is intentionally small. Everything importable from tempura
is meant to be stable; the per-module pages in this reference document the
internal machinery behind these names for contributors and curious users.
API
tempura
Public package API for Tempura.
Device
Ordered device stack used to derive solver geometry.
A device stores layers in bottom-to-top deposition order. Gates may be
passed as a list to :meth:add_layer when they are deposited in one metal
batch; non-gate layers cover the full device footprint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
float
|
Device span along x in internal units. |
required |
width
|
float
|
Device span along y in internal units. |
required |
grid
|
float
|
Square in-plane lattice spacing. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
length |
Device span along x. |
|
width |
Device span along y. |
|
grid_shape |
Raster shape as |
Source code in tempura/electrostatics/device.py
593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 | |
finalized
property
Return whether :meth:finalize has been called successfully.
grid
property
Return the square in-plane lattice spacing.
layers
property
Return the ordered layer stack as a read-only mapping.
__init__(*, length, width, grid)
Create a device with explicit dimensions and base XY lattice spacing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
float
|
Device span along x in internal units. |
required |
width
|
float
|
Device span along y in internal units. |
required |
grid
|
float
|
Square in-plane grid spacing. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If dimensions are non-positive or not commensurate with
|
TypeError
|
If |
Source code in tempura/electrostatics/device.py
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | |
add_layer(layer)
Add a layer in bottom-to-top stacking order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
LayerInput
|
Either one layer instance or one non-empty list of layers deposited together in one coplanar batch. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the device has already been finalized. |
ValueError
|
If names collide, a layer footprint shape is invalid, or
one batch contains overlapping footprints. |
TypeError
|
If |
Source code in tempura/electrostatics/device.py
657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 | |
finalize()
Realize all layer height fields and freeze the device.
Finalization converts the ordered layer specifications into concrete bottom/top height arrays, Pescado-compatible shapes, and read-only layer buffers. Calling it more than once is a no-op.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the internal finalization pipeline cannot produce geometry for a registered layer. |
Source code in tempura/electrostatics/device.py
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 | |
Dielectric
dataclass
Bases: LayerBase
Dielectric layer covering the full XY device footprint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Unique dielectric name. |
required |
thickness
|
float
|
Dielectric thickness in device units. |
required |
permittivity
|
float
|
Relative permittivity assigned to the layer. |
required |
resolution
|
ndarray | None
|
Optional |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in tempura/electrostatics/device.py
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | |
__post_init__()
Validate and normalize the dielectric permittivity.
Source code in tempura/electrostatics/device.py
518 519 520 521 522 523 524 525 | |
Gate
dataclass
Bases: LayerBase
Metallic gate layer described by a device-aligned stencil.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Unique gate name. The name becomes the Dirichlet region name and
the key returned by :func: |
required |
thickness
|
float
|
Gate thickness in device units. |
required |
stencil
|
ndarray
|
Boolean |
required |
Note
Gates have no refinement zone of their own: they are realized on the
device-halo lattice. Passing resolution is therefore rejected; a
warning is emitted at build time if a stencil feature is finer than the
realizing mesh.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in tempura/electrostatics/device.py
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 | |
__post_init__()
Validate the gate stencil and normalize it to a boolean mask.
Source code in tempura/electrostatics/device.py
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 | |
QuantumRegion
dataclass
Bases: LayerBase
Quantum material region used as the active electrostatic response layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Unique region name. The default downstream extraction helpers
look for |
required |
thickness
|
float
|
Region thickness in device units. |
required |
permittivity
|
float
|
Relative permittivity assigned to the region. |
required |
boundary_condition
|
Literal['neumann', 'helmholtz', 'flexible']
|
Pescado response model for the region. Supported
values are |
'helmholtz'
|
resolution
|
ndarray | None
|
Optional |
None
|
stencil
|
ndarray | None
|
Optional boolean |
None
|
mesh_refinement_resolution
|
ndarray | None
|
Removed legacy spelling. Passing it raises an error so old examples fail loudly. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If material parameters are invalid or an unsupported boundary condition is requested. |
Source code in tempura/electrostatics/device.py
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
__post_init__()
Validate the quantum region material parameters and boundary condition.
Source code in tempura/electrostatics/device.py
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
build_device(prepared, stack)
Build a finalized device from prepared masks and an ordered stack spec.
The stack describes the physical layers and may optionally include one
per-layer resolution entry used directly by build_problem(...).
quantum_region entries may also provide boundary_condition to select
the linear response model for that region plus a literal stencil for one
patterned quantum-region footprint. Gate layers may also set
inverted=True when their one source stencil represents an etched opening
rather than deposited metal. Layout-backed gate entries expand into one or
more concrete Gate objects whose emitted names are suffixed as _0,
_1, and so on. One explicit coplanar batch may be expressed as
{"kind": "batch", "layers": [...]}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prepared
|
PreparedLayout
|
Typed payload returned by :func: |
required |
stack
|
list[dict[str, object]]
|
Ordered layer specification from bottom to top. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Finalized |
Device
|
class: |
Device
|
prepared layout masks and stack specification. |
Source code in tempura/layout/layout_pipeline.py
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | |
build_problem(device, vacuum_scale=8.0, *, vacuum_resolution_scale=8.0, dirichlet_boundary=True, verbose=False)
Build a Poisson problem for a layered device.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
Device
|
Finalized device whose electrostatic stack should be meshed. |
required |
vacuum_scale
|
float
|
Outer vacuum size multiplier relative to the device span. |
8.0
|
vacuum_resolution_scale
|
float
|
Coarsening factor applied to the automatic outer-vacuum lattice spacing. |
8.0
|
dirichlet_boundary
|
bool
|
Whether to add a thin outer shell of zero-volt
Dirichlet sites around the simulation box. When |
True
|
verbose
|
bool
|
Whether to emit progress logging during assembly. |
False
|
Returns:
| Type | Description |
|---|---|
ProblemBuilder
|
Initialized Pescado :class: |
ProblemBuilder
|
explicitly before calling :func: |
Source code in tempura/electrostatics/pescado_wrapper.py
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 | |
prepare_layout(layout_path, aoi_bbox, size_mode, grid_constant_m=DEFAULT_GRID_CONSTANT_M, physical_x_length=None, precision=1e-06, tolerance=1e-06)
Load, crop, scale, and rasterize a layout-backed ROI.
The ROI is first resolved in physical units (meters), then rescaled so one internal XY unit corresponds to one grid constant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layout_path
|
str | Path
|
Filesystem path to the source layout file. |
required |
aoi_bbox
|
tuple[float, float, float, float]
|
AOI bounds in the layout coordinate system. |
required |
size_mode
|
str
|
|
required |
grid_constant_m
|
float
|
Physical size represented by one internal XY unit. |
DEFAULT_GRID_CONSTANT_M
|
physical_x_length
|
float | None
|
Physical x span used when |
None
|
precision
|
float
|
Boolean-operation precision passed to AOI clipping. |
1e-06
|
tolerance
|
float
|
Tolerance used when validating that the physical ROI size is
an integer multiple of |
1e-06
|
Returns:
| Type | Description |
|---|---|
PreparedLayout
|
Typed layout payload containing the rasterized masks plus the minimum |
PreparedLayout
|
geometry and scaling data needed by :func: |
Source code in tempura/layout/layout_pipeline.py
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 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 | |
solve_gate_potentials(problem, *, charge=None, dtype=DTYPE, blr=BLR, eps_blr=EPS_BLR, rhs_block_size=8, save_quantum_region_potential=None, quantum_region_name='quantum_region', quantum_region_plane_selection='midpoint', verbose=False)
Solve the gate basis problem with one reused factorization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
Any
|
Finalized Pescado problem returned by
|
required |
charge
|
ndarray | None
|
Optional distributed charge columns to include in the RHS. |
None
|
dtype
|
DTypeLike
|
Numeric dtype used during factorization and solve. |
DTYPE
|
blr
|
bool
|
Whether to enable MUMPS block low-rank factorization. |
BLR
|
eps_blr
|
float
|
BLR compression threshold when |
EPS_BLR
|
rhs_block_size
|
int
|
Number of gate basis columns to solve per linear solve. |
8
|
save_quantum_region_potential
|
str | Path | None
|
Optional output directory for static quantum region export. |
None
|
quantum_region_name
|
str
|
Region name to export when saving a quantum region basis bundle. |
'quantum_region'
|
quantum_region_plane_selection
|
PlaneSelection
|
Which realized quantum region z plane to export when the region spans multiple z coordinates. |
'midpoint'
|
verbose
|
bool
|
Whether to emit progress logging during solving. |
False
|
Returns:
| Type | Description |
|---|---|
PotentialMap
|
Mapping from gate name to solved basis-potential vector. |
Source code in tempura/electrostatics/pescado_wrapper.py
78 79 80 81 82 83 84 85 86 87 88 89 90 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 | |