Skip to content

Commit 04e4377

Browse files
committed
e_ops positional arguement resolutions
1 parent f8f973d commit 04e4377

13 files changed

+37
-37
lines changed

tutorials-v5/lectures/Lecture-0-Introduction-to-QuTiP.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ psi0 = basis(2, 0)
410410
# list of times for which the solver should store the state vector
411411
tlist = np.linspace(0, 10, 100)
412412

413-
result = mesolve(H, psi0, tlist, [], [])
413+
result = mesolve(H, psi0, tlist, [])
414414
```
415415

416416
```python
@@ -458,12 +458,12 @@ axes.set_xlabel(r"$t$", fontsize=20)
458458
axes.set_ylabel(r"$\left<\sigma_z\right>$", fontsize=20);
459459
```
460460

461-
If we are only interested in expectation values, we could pass a list of operators to the `mesolve` function that we want expectation values for, and have the solver compute then and store the results in the `Odedata` class instance that it returns.
461+
If we are only interested in expectation values, we could pass a list of operators to the `mesolve` function that we want expectation values for, and have the solver compute then and store the results in the `Odedata` class instance that it returns.\
462462

463463
For example, to request that the solver calculates the expectation values for the operators $\sigma_x, \sigma_y, \sigma_z$:
464464

465465
```python
466-
result = mesolve(H, psi0, tlist, [], [sigmax(), sigmay(), sigmaz()])
466+
result = mesolve(H, psi0, tlist, [], e_ops=[sigmax(), sigmay(), sigmaz()])
467467
```
468468

469469
Now the expectation values are available in `result.expect[0]`, `result.expect[1]`, and `result.expect[2]`:

tutorials-v5/lectures/Lecture-1-Jaynes-Cumming-model.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ if rate > 0.0:
111111
Here we evolve the system with the Lindblad master equation solver, and we request that the expectation values of the operators $a^\dagger a$ and $\sigma_+\sigma_-$ are returned by the solver by passing the list `[a.dag()*a, sm.dag()*sm]` as the fifth argument to the solver.
112112

113113
```python
114-
output = mesolve(H, psi0, tlist, c_ops, [a.dag() * a, sm.dag() * sm])
114+
output = mesolve(H, psi0, tlist, c_ops, e_ops=[a.dag() * a, sm.dag() * sm])
115115
```
116116

117117
## Visualize the results
@@ -139,7 +139,7 @@ In addition to the cavity's and atom's excitation probabilities, we may also be
139139
To calculate the Wigner function in QuTiP, we first recalculte the evolution without specifying any expectation value operators, which will result in that the solver returns a list of density matrices for the system for the given time coordinates.
140140

141141
```python
142-
output = mesolve(H, psi0, tlist, c_ops, [])
142+
output = mesolve(H, psi0, tlist, c_ops)
143143
```
144144

145145
Now, `output.states` contains a list of density matrices for the system for the time points specified in the list `tlist`:

tutorials-v5/lectures/Lecture-10-cQED-dispersive-regime.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ tlist = np.linspace(0, 250, 1000)
115115
```
116116

117117
```python
118-
res = mesolve(H, psi0, tlist, [], [], options=SolverOptions(nsteps=5000))
118+
res = mesolve(H, psi0, tlist, [], options={'nsteps': 5000})
119119
```
120120

121121
### Excitation numbers

tutorials-v5/lectures/Lecture-11-Charge-Qubits.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ psi0 = psi_g
304304

305305
```python
306306
tlist = np.linspace(0.0, 100.0, 500)
307-
result = mesolve(Heff, psi0, tlist, [], [ket2dm(psi_e)], args=args)
307+
result = mesolve(Heff, psi0, tlist, [], e_ops=[ket2dm(psi_e)], args=args)
308308
```
309309

310310
```python
@@ -362,7 +362,7 @@ psi_e = Qobj(psi_e.full()[keep_states, :])
362362

363363
```python
364364
tlist = np.linspace(0.0, 100.0, 500)
365-
result = mesolve(Heff, psi0, tlist, [], [ket2dm(psi_e)], args=args)
365+
result = mesolve(Heff, psi0, tlist, [], e_ops=[ket2dm(psi_e)], args=args)
366366
```
367367

368368
```python

tutorials-v5/lectures/Lecture-12-Decay-into-a-squeezed-vacuum-field.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ e_ops = [sigmax(), sigmay(), sigmaz()]
161161
```
162162

163163
```python
164-
result1 = mesolve(L, psi0, tlist, [], e_ops)
164+
result1 = mesolve(L, psi0, tlist, [], e_ops=e_ops)
165165
```
166166

167167
```python
@@ -205,7 +205,7 @@ c_ops = [np.sqrt(gamma0) *
205205
```
206206

207207
```python
208-
result2 = mesolve(H, psi0, tlist, c_ops, e_ops)
208+
result2 = mesolve(H, psi0, tlist, c_ops, e_ops=e_ops)
209209
```
210210

211211
And we can verify that it indeed gives the same results:
@@ -292,7 +292,7 @@ c_ops = [np.sqrt(gamma0) *
292292
```
293293

294294
```python
295-
result1 = mesolve(H, psi0, tlist, c_ops, e_ops)
295+
result1 = mesolve(H, psi0, tlist, c_ops, e_ops=e_ops)
296296
```
297297

298298
```python
@@ -304,7 +304,7 @@ c_ops = [np.sqrt(gamma0) *
304304
```
305305

306306
```python
307-
result2 = mesolve(H, psi0, tlist, c_ops, e_ops)
307+
result2 = mesolve(H, psi0, tlist, c_ops, e_ops=e_ops)
308308
```
309309

310310
```python

tutorials-v5/lectures/Lecture-13-Resonance-flourescence.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ psi0 = basis(2, 0)
8585

8686
```python
8787
tlist = np.linspace(0, 20 / (2 * np.pi), 200)
88-
result = mesolve(HL, psi0, tlist, c_ops, e_ops)
88+
result = mesolve(HL, psi0, tlist, c_ops, e_ops=e_ops)
8989
```
9090

9191
```python
@@ -118,7 +118,7 @@ fig, ax = plt.subplots(1, 1, figsize=(12, 6), sharex=True)
118118
for idx, gamma0 in enumerate([0.1 * Omega, 0.5 * Omega, 1.0 * Omega]):
119119

120120
HL, c_ops = system_spec(Omega, gamma0, N)
121-
result = mesolve(HL, psi0, tlist, c_ops, e_ops)
121+
result = mesolve(HL, psi0, tlist, c_ops, e_ops=e_ops)
122122

123123
ax.plot(result.times, result.expect[5], "b",
124124
label=fr"$P_e$ ($\gamma_0={gamma0:.2f}$)")
@@ -136,7 +136,7 @@ fig, ax = plt.subplots(1, 1, figsize=(12, 6), sharex=True)
136136
for idx, gamma0 in enumerate([0.1 * Omega, 0.5 * Omega, 1.0 * Omega]):
137137

138138
HL, c_ops = system_spec(Omega, gamma0, N)
139-
result = mesolve(HL, psi0, tlist, c_ops, e_ops)
139+
result = mesolve(HL, psi0, tlist, c_ops, e_ops=e_ops)
140140

141141
ax.plot(
142142
result.times, np.imag(result.expect[4]),

tutorials-v5/lectures/Lecture-14-Kerr-nonlinearities.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ psi0 = coherent(N, 2.0)
184184
# and evolve the state under the influence of the hamiltonian.
185185
# by passing an empty list as expecation value operators argument,
186186
# we get the full state of the system in result.states
187-
result = mesolve(H, psi0, tlist, [], [])
187+
result = mesolve(H, psi0, tlist, [])
188188
```
189189

190190
First, let's look at how the expecation values and variances of the photon number operator $n$ and the $x$ and $p$ quadratures evolve in time:

tutorials-v5/lectures/Lecture-2A-Cavity-Qubit-Gates.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ H_t = [[Hc, wc_t], [H1, w1_t], [H2, w2_t], Hc1 + Hc2]
139139
### Evolve the system
140140

141141
```python
142-
res = mesolve(H_t, psi0, tlist, [], [])
142+
res = mesolve(H_t, psi0, tlist, [])
143143
```
144144

145145
### Plot the results
@@ -239,7 +239,7 @@ c_ops = [np.sqrt(kappa) * a, np.sqrt(gamma1) * sm1, np.sqrt(gamma2) * sm2]
239239
### Evolve the system
240240

241241
```python
242-
res = mesolve(H_t, psi0, tlist, c_ops, [])
242+
res = mesolve(H_t, psi0, tlist, c_ops)
243243
```
244244

245245
### Plot the results
@@ -323,7 +323,7 @@ fig.tight_layout()
323323
### Evolve the system
324324

325325
```python
326-
res = mesolve(H_t, psi0, tlist, [], [])
326+
res = mesolve(H_t, psi0, tlist, [])
327327
```
328328

329329
### Plot the results
@@ -408,7 +408,7 @@ fig.tight_layout()
408408
### Evolve the system
409409

410410
```python
411-
res = mesolve(H_t, psi0, tlist, [], [])
411+
res = mesolve(H_t, psi0, tlist, [])
412412
```
413413

414414
### Plot the results
@@ -488,7 +488,7 @@ c_ops = [np.sqrt(kappa) * a, np.sqrt(gamma1) * sm1, np.sqrt(gamma2) * sm2]
488488
### Evolve the system
489489

490490
```python
491-
res = mesolve(H_t, psi0, tlist, c_ops, [])
491+
res = mesolve(H_t, psi0, tlist, c_ops)
492492
```
493493

494494
### Plot results
@@ -574,7 +574,7 @@ H_t = [[Hc, wc_t], H1 * w1 + H2 * w2 + Hc1 + Hc2]
574574
### Evolve the system
575575

576576
```python
577-
res = mesolve(H_t, psi0, tlist, c_ops, [])
577+
res = mesolve(H_t, psi0, tlist, c_ops)
578578
```
579579

580580
### Plot the results

tutorials-v5/lectures/Lecture-2B-Single-Atom-Lasing.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ if rate > 0.0:
130130
Here we evolve the system with the Lindblad master equation solver, and we request that the expectation values of the operators $a^\dagger a$ and $\sigma_+\sigma_-$ are returned by the solver by passing the list `[a.dag()*a, sm.dag()*sm]` as the fifth argument to the solver.
131131

132132
```python
133-
opt = SolverOptions(nsteps=2000) # allow extra time-steps
134-
output = mesolve(H, psi0, tlist, c_ops, [a.dag() * a, sm.dag() * sm],
133+
opt = {'nsteps': 2000} # allow extra time-steps
134+
output = mesolve(H, psi0, tlist, c_ops, e_ops=[a.dag() * a, sm.dag() * sm],
135135
options=opt)
136136
```
137137

@@ -191,8 +191,8 @@ axes[0].set_ylabel("Occupation probability", fontsize=18);
191191

192192
```python
193193
tlist = np.linspace(0, 25, 5)
194-
output = mesolve(H, psi0, tlist, c_ops, [],
195-
options=SolverOptions(nsteps=5000))
194+
output = mesolve(H, psi0, tlist, c_ops,
195+
options={'nsteps': 5000})
196196
```
197197

198198
```python

tutorials-v5/lectures/Lecture-3B-Jaynes-Cumming-model-with-ultrastrong-coupling.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ psi0 = tensor(basis(N, 1), basis(2, 0))
206206

207207
```python
208208
tlist = np.linspace(0, 20, 1000)
209-
output = mesolve(H, psi0, tlist, [], [a.dag() * a, sm.dag() * sm])
209+
output = mesolve(H, psi0, tlist, [], e_ops=[a.dag() * a, sm.dag() * sm])
210210
```
211211

212212
```python
@@ -223,7 +223,7 @@ fig.tight_layout()
223223

224224
```python
225225
tlist = np.linspace(0, 0.35, 8)
226-
output = mesolve(H, psi0, tlist, [], [])
226+
output = mesolve(H, psi0, tlist, [])
227227
```
228228

229229
```python
@@ -269,7 +269,7 @@ kappa = 0.25
269269
```python
270270
tlist = np.linspace(0, 20, 1000)
271271
output = mesolve(H, psi0, tlist, [np.sqrt(kappa) * a],
272-
[a.dag() * a, sm.dag() * sm])
272+
e_ops=[a.dag() * a, sm.dag() * sm])
273273
```
274274

275275
```python
@@ -281,7 +281,7 @@ axes.legend(loc=0);
281281

282282
```python
283283
tlist = np.linspace(0, 10, 8)
284-
output = mesolve(H, psi0, tlist, [np.sqrt(kappa) * a], [])
284+
output = mesolve(H, psi0, tlist, [np.sqrt(kappa) * a])
285285
```
286286

287287
```python
@@ -323,7 +323,7 @@ tlist = np.linspace(0, 30, 50)
323323

324324
psi0 = H.groundstate()[1]
325325

326-
output = mesolve(H, psi0, tlist, [np.sqrt(kappa) * a], [])
326+
output = mesolve(H, psi0, tlist, [np.sqrt(kappa) * a])
327327
```
328328

329329
```python

0 commit comments

Comments
 (0)