trotterization_simulator
¶
Closed-system Trotterization simulator.
TrotterizationSimulator
¶
Bases: ProductFormulaSimulator
Simulate closed-system dynamics with a Trotter product formula.
closed_system is true, so Lindblad operators are rejected.
Counts come from circuit_backend when that backend stores shots.
Omitting it uses Aer. Before the measurement, each
qubit is rotated into its letter of basis (default all Z). The result
keeps one counts dict per time point, where bit i of a key is qubit i.
Read them with :meth:measure. A backend without a shot budget, such as
PauliPropagation, returns the expectation of each qubit's basis letter
from the same circuit with the measurement removed, and the result has no
counts. :meth:measure reads a one-qubit measurement from that distribution:
counts["0"] is (1 + expectation) / 2, counts["1"] is
(1 - expectation) / 2, and shots is 1. Dividing by shots gives
the infinite-shot value, and an expression that uses raw counts without
shots reads those probabilities. Two or more qubits need a sampling backend.
The shot count is that backend's shots attribute when it has one.
With workers greater than 1, that backend is pickled into each worker process.
order=1 (the default) applies each local term once per slice of width
t / (num_steps * trotter_depth), in list order. order=2 uses one Strang
step per slice: half-steps forward, a full step on the last term, then half-steps
in reverse. trotter_depth is how many slices fit in one time sample, for both
orders.
Each time point starts from initial_state and uses the same seed.
workers=1 (the default) runs those points serially, in tlist order.
workers greater than 1 runs one process-pool task per time point.
Traces are still returned in tlist order, and progress(index, total)
may run in completion order. A job from start() counts each finished
time point in completed_steps.
Source code in shadowsim/simulators/trotterization_simulator.py
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 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 | |
__init__
¶
__init__(
hamiltonians: list[LocalHamiltonian],
lindblads: Sequence[Operator],
initial_state: State,
*,
num_qubits: int,
total_time: float,
time_steps: int,
num_steps: int,
trotter_depth: int = 1,
order: Literal[1, 2] = 1,
verbose: bool = False,
seed: int | None = None,
progress: ProgressCallback | None = None,
workers: int = 1,
circuit_backend: CircuitBackend | None = None,
basis: str | None = None,
) -> None
Initialize a closed-system Trotterization simulator for the given model.
Source code in shadowsim/simulators/trotterization_simulator.py
metrics_circuit
¶
metrics_circuit() -> Program
Return the program executed at the final time.
A sampling backend includes the computational-basis measurement.