viewer.potential_export — quantum-region potential export
tempura/viewer/potential_export.py exports the per-gate quantum-region basis
potentials for the browser viewer, so the page can recombine them interactively
as the user drags voltage sliders.
Browser-side superposition
Rather than baking in one voltage configuration, the exporter writes each gate's basis field on the quantum-region plane as a separate array, plus the plane geometry and a shared voltage range. The viewer then forms the superposition \(\phi = \sum_i V_i\,\phi_i\) on the fly — the same linearity the solver exploits, moved to the client. Optional per-gate footprint masks are written alongside for overlays.
export_quantum_region_potential_view(...) validates that every basis array and
footprint matches the plane's \((n_y, n_x)\) shape, writes the binary assets and a
potential.json manifest, and returns a
QuantumRegionPotentialExportManifest listing the files.
API
potential_export
Export quantum region basis potentials for the standalone TypeScript viewer.
QuantumRegionPotentialExportManifest
dataclass
Paths written by :func:export_quantum_region_potential_view.
Attributes:
| Name | Type | Description |
|---|---|---|
dataset_name |
str
|
Dataset label stored in |
potential_json_path |
Path
|
Path to the potential metadata file. |
asset_paths |
tuple[Path, ...]
|
Paths to binary array assets referenced by
|
Source code in tempura/viewer/potential_export.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
export_quantum_region_potential_view(basis_quantum_region, plane, out_dir, *, gate_footprints=None, dataset_name=None, voltage_range=(-1.0, 1.0), overwrite=True, verbose=False)
Export per-gate quantum region basis potentials for browser-side recombination.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
basis_quantum_region
|
dict[str, ndarray]
|
Mapping of gate name to |
required |
plane
|
QuantumRegionPlaneData
|
Extracted quantum region plane metadata. |
required |
out_dir
|
str | Path
|
Output directory for the exported bundle. |
required |
gate_footprints
|
dict[str, ndarray] | None
|
Optional per-gate footprint masks on the same
|
None
|
dataset_name
|
str | None
|
Optional dataset label stored in |
None
|
voltage_range
|
tuple[float, float]
|
Shared slider range written to metadata. |
(-1.0, 1.0)
|
overwrite
|
bool
|
If |
True
|
verbose
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
QuantumRegionPotentialExportManifest
|
Manifest describing the files written. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no gate potentials are provided or shapes are invalid. |
FileExistsError
|
If |
Source code in tempura/viewer/potential_export.py
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 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 | |