Source Code
qflux.closed_systems
DynamicsCS
Class for closed-system dynamics. All input parameters must be in atomic units to ensure consistency. Please be sure to convert your parameters to atomic units prior to instantiation.
Source code in src/qflux/closed_systems/classical_methods.py
11 12 13 14 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 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 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 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 369 370 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 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
|
__init__(n_basis=128, xo=1.0, po=0.0, mass=1.0, omega=1.0)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_basis
|
int
|
Number of states to include in the chosen representation. If basis = 'ladder', this is the Fock cutoff and defines the number of states used for representing the ladder operators. If basis = 'coordinate', this defines the number of points for the position and momenta. |
128
|
xo
|
float
|
Defines the displacement of the initial state in the position coordinate. Default is 1.0 Bohr. |
1.0
|
po
|
float
|
Defines the displacement of the initial state in the position coordinate. Default is 1.0 au. |
0.0
|
mass
|
float
|
Defines the mass of the particle/system of interest. Default is 1.0 au. |
1.0
|
omega
|
float
|
Frequency of harmonic oscillator. Default is 1.0 au. |
1.0
|
Source code in src/qflux/closed_systems/classical_methods.py
_get_pgrid(x_min, x_max, reorder=True)
Populate the self.p_grid
and self.dp
attributes. This function
generates an array of self.n_basis
evenly spaced values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x_min
|
float
|
Minimum value of x-coordinates |
required |
x_max
|
float
|
Maximum value of x-coordinates |
required |
reorder
|
bool
|
Boolean flag to determine whether points should be reordered to be compatible with the FFT routine or not. |
True
|
Returns:
Type | Description |
---|---|
None
|
self.dp (float): Spacing between points in the p-coordinate grid. |
None
|
self.pgrid (array_like): Array of momentum grid points |
Source code in src/qflux/closed_systems/classical_methods.py
_get_xgrid(x_min, x_max)
Populate the self.x_grid
and self.dx
attributes. This function
generates an array of self.n_basis
evenly spaced values between
x_min
and x_max
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x_min
|
float
|
Minimum value of x-coordinates |
required |
x_max
|
float
|
Maximum value of x-coordinates |
required |
Returns:
Type | Description |
---|---|
None
|
self.dx (float): Spacing between points in the x-coordinate grid. |
None
|
self.xgrid (array_like): Array of grid points from x_min to x_max with spacing of dx |
Source code in src/qflux/closed_systems/classical_methods.py
custom_grid_state_initialization(function_name, **kwargs)
Function to allow for customized grid state initialization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
function_name
|
Callable
|
name of user-defined function that returns the initial state. Must return an array |
required |
Source code in src/qflux/closed_systems/classical_methods.py
custom_ladder_state_initialization(function_name, **kwargs)
Function to allow for customized ladder state initialization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
function_name
|
Callable
|
name of user-defined function that returns the initial state. Must return a qutip.Qobj. |
required |
Source code in src/qflux/closed_systems/classical_methods.py
initialize_operators()
Function to initialize core operators in the chosen basis.
Source code in src/qflux/closed_systems/classical_methods.py
propagate_SOFT()
Function used to propagate with the 2nd-Order Trotter Expansion.
Returns:
Name | Type | Description |
---|---|---|
dynamics_results_grid |
array - like
|
array containing the propagated state shape (n_tsteps x self.n_basis) |
Source code in src/qflux/closed_systems/classical_methods.py
propagate_qt(solver_options=None)
Function used to propagate with qutip.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
solver_options
|
dict
|
A dictionary of arguments to pass to the qutip.sesolve function |
None
|
Returns:
Name | Type | Description |
---|---|---|
dynamics_results |
array - like
|
array containing the propagated state |
Source code in src/qflux/closed_systems/classical_methods.py
set_H_grid_with_custom_potential(custom_function, **kwargs)
Function to allow for user-defined potential defined by custom_function. Must be a function of qutip operators.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
custom_function
|
Callable
|
Function that defines the custom potential energy. Must return an array |
required |
Source code in src/qflux/closed_systems/classical_methods.py
set_H_op_with_custom_potential(custom_function, **kwargs)
Function to allow for user-defined potential defined by custom_function. Must be a function of qutip operators.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
custom_function
|
Callable
|
Function that defines the potential energy in terms of qutip QObj operators. Must return a qutip.Qobj |
required |
Source code in src/qflux/closed_systems/classical_methods.py
set_coordinate_operators(x_min=-7.0, x_max=7.0, reorder_p=True)
Populate the self.x_grid
, self.p_grid
, self.dx
, and self.dp
attributes. This functions generates an array of self.n_basis
evenly spaced values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x_min
|
float Minimum value of x-coordinates |
-7.0
|
|
x_max
|
float Maximum value of x-coordinates |
7.0
|
|
reorder_p
|
bool Boolean flag to determine whether momentum values should be reordered to be compatible with the FFT routine or not. |
True
|
Returns:
Type | Description |
---|---|
None
|
self.dx : float Spacing between points in the x-coordinate grid. |
None
|
self.xgrid : array_like Array of x-values |
None
|
self.dp : float Spacing between points in the p-coordinate grid. |
None
|
self.pgrid : array_like Array of p-values |
Source code in src/qflux/closed_systems/classical_methods.py
set_hamiltonian(potential_type='harmonic', **kwargs)
Function to define Hamiltonian.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
potential_type
|
str String defining the type of potential energy surface. Available options are: ('harmonic', 'quartic', ...) Note: You can manually define your potential energy using the functions: - set_H_grid_with_custom_potential - set_H_op_with_custom_potential |
'harmonic'
|
Source code in src/qflux/closed_systems/classical_methods.py
set_initial_state(wfn_omega=1.0)
Function to define the initial state. By default, a coherent state is used as the initial state defined in the basis chosen upon instantiation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wfn_omega
|
float
|
Defines the frequency/width of the initial state. Default is 1.0 au. |
1.0
|
Source code in src/qflux/closed_systems/classical_methods.py
set_propagation_time(total_time, n_tsteps)
Function to define the propagation time, an array of times from t=0 to total_time, with n_tsteps equally-spaced steps.
total_time : float The total time for which we wish to compute the dynamics. n_tsteps : int The number of equally-spaced time steps used to compute the dynamics
Returns: self.tlist : array-like
Source code in src/qflux/closed_systems/classical_methods.py
QubitDynamicsCS
Bases: DynamicsCS
Class to extend DynamicsCS
by adding qubit-based methods for dynamics.
Source code in src/qflux/closed_systems/qubit_methods.py
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 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 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
_construct_pauli_gate(hamiltonian_matrix=None)
Function to construct a pauli evolution gate from Hamiltonian
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hamiltonian_matrix
|
ArrayLike
|
array-like matrix representing the hamiltonian of interest If not provided, use the operator representation of the Hamiltonian by default. |
None
|
Source code in src/qflux/closed_systems/qubit_methods.py
_create_QSOFT_Circuit(psio=None)
Function to construct the QSOFT Circuit.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
psio
|
ArrayLike
|
initial state that we wish to propagate |
None
|
Source code in src/qflux/closed_systems/qubit_methods.py
_execute_circuit(QCircuit, backend=None, shots=None, real_backend=False)
Function to replace the now-deprecated Qiskit
QuantumCircuit.execute()
method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
QCircuit
|
QuantumCircuit
|
qiskit.QuantumCircuit object |
required |
backend
|
Backend
|
qiskit backend instance |
None
|
shots
|
int
|
the number of shots to use for circuit sampling |
None
|
Returns:
Name | Type | Description |
---|---|---|
job |
an executed quantum circuit job |
Source code in src/qflux/closed_systems/qubit_methods.py
_propagate_qSOFT_real(backend='statevector_simulator', n_shots=1024)
Function to propagate dynamics object with the qubit SOFT method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
backend
|
Backend
|
qiskit backend object |
'statevector_simulator'
|
n_shots
|
int
|
specifies the number of shots to use when executing the circuit |
1024
|
Example for using the Statevector Simulator backend
from qiskit_aer import Aer backend = Aer.get_backend('statevector_simulator') self.propagate_qSOFT(backend=backend)
Source code in src/qflux/closed_systems/qubit_methods.py
propagate_qSOFT(backend=None, n_shots=1024)
Function to propagate dynamics object with the qubit SOFT method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
backend
|
Backend
|
qiskit backend object |
None
|
n_shots
|
int
|
specifies the number of shots to use when executing the circuit |
1024
|
Example for using the Statevector Simulator backend
from qiskit_aer import Aer backend = Aer.get_backend('statevector_simulator') self.propagate_qSOFT(backend=backend)
Source code in src/qflux/closed_systems/qubit_methods.py
propagate_qmatvec(backend=None, n_shots=1024, hamiltonian_matrix=None, initial_state=None)
Function to propagate dynamics object with the qubit matvec method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
backend
|
Backend
|
qiskit backend object |
None
|
n_shots
|
int
|
specifies the number of shots to use when executing the circuit |
1024
|
hamiltonian_matrix
|
ArrayLike
|
array-like matrix representing the Hamiltonian Used to construct the propagator: \[ U(t) = e^{- i H t / \hbar} \]
By default, the operator representation of the hamiltonian |
None
|
initial_state
|
ArrayLike
|
array-like vector representing the initial state |
None
|
Example for using the Statevector Simulator backend: >>> from qiskit_aer import Aer >>> backend = Aer.get_backend('statevector_simulator') >>> self.propagate_qSOFT(backend=backend)