Skip to content

Commit

Permalink
Merge pull request #102 from gadhvirushiraj/dev
Browse files Browse the repository at this point in the history
Adding Tutorials for Circuit Renderers
  • Loading branch information
nwlambert authored Dec 6, 2024
2 parents 522e7b7 + 8d5d9be commit e6ac5f6
Show file tree
Hide file tree
Showing 16 changed files with 440 additions and 82 deletions.
2 changes: 1 addition & 1 deletion tutorials-v4/lectures/Lecture-11-Charge-Qubits.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ where $E_C$ is the charge energy, $E_J$ is the Josephson energy, and $\left| n\r

#### References

* [J. Koch et al, Phys. Rec. A 76, 042319 (2007)](http://link.aps.org/doi/10.1103/PhysRevA.76.042319)
* [J. Koch et al, Phys. Rec. A 76, 042319 (2007)](https://journals.aps.org/pra/abstract/10.1103/PhysRevA.76.042319)
* [Y.A. Pashkin et al, Quantum Inf Process 8, 55 (2009)](http://dx.doi.org/10.1007/s11128-009-0101-5)


Expand Down
4 changes: 2 additions & 2 deletions tutorials-v4/lectures/Lecture-2B-Single-Atom-Lasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ in units where $\hbar = 1$.

References:

* [Yi Mu, C.M. Savage, Phys. Rev. A 46, 5944 (1992)](http://dx.doi.org/10.1103/PhysRevA.46.5944)
* [Yi Mu, C.M. Savage, Phys. Rev. A 46, 5944 (1992)](https://journals.aps.org/pra/abstract/10.1103/PhysRevA.46.5944)

* [D.A. Rodrigues, J. Imbers, A.D. Armour, Phys. Rev. Lett. 98, 067204 (2007)](http://dx.doi.org/10.1103/PhysRevLett.98.067204)
* [D.A. Rodrigues, J. Imbers, A.D. Armour, Phys. Rev. Lett. 98, 067204 (2007)](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.98.067204)

* [S. Ashhab, J.R. Johansson, A.M. Zagoskin, F. Nori, New J. Phys. 11, 023030 (2009)](http://dx.doi.org/10.1088/1367-2630/11/2/023030)

Expand Down
4 changes: 2 additions & 2 deletions tutorials-v4/lectures/Lecture-3A-Dicke-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ $\displaystyle J_\pm = \sum_{i=1}^N \sigma_\pm^{(i)}$

### References

* [R.H. Dicke, Phys. Rev. 93, 99–110 (1954)](http://dx.doi.org/10.1103/PhysRev.93.99)
* [R.H. Dicke, Phys. Rev. 93, 99–110 (1954)](https://journals.aps.org/pr/abstract/10.1103/PhysRev.93.99)


## Setup problem in QuTiP
Expand Down Expand Up @@ -198,7 +198,7 @@ fig.tight_layout()

### References

* [Lambert et al., Phys. Rev. Lett. 92, 073602 (2004)](http://dx.doi.org/10.1103/PhysRevLett.92.073602).
* [Lambert et al., Phys. Rev. Lett. 92, 073602 (2004)](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.92.073602).

```python
def calulcate_entropy(M, N, g_vec):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ The regime $g$ is large compared with all other energy scales in the Hamiltonian

References:

* [P. Nataf et al., Phys. Rev. Lett. 104, 023601 (2010)](http://dx.doi.org/10.1103/PhysRevLett.104.023601)
* [P. Nataf et al., Phys. Rev. Lett. 104, 023601 (2010)](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.104.023601)

* [J. Casanova et al., Phys. Rev. Lett. 105, 26360 (2010)](http://dx.doi.org/10.1103/PhysRevLett.105.263603).
* [J. Casanova et al., Phys. Rev. Lett. 105, 26360 (2010)](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.105.263603).

* [S. Ashhab et al., Phys. Rev. A 81, 042311 (2010)](http://dx.doi.org/10.1103/PhysRevA.81.042311)
* [S. Ashhab et al., Phys. Rev. A 81, 042311 (2010)](https://journals.aps.org/pra/abstract/10.1103/PhysRevA.81.042311)
<!-- #endregion -->

<!-- #region -->
Expand Down
4 changes: 2 additions & 2 deletions tutorials-v4/lectures/Lecture-4-Correlation-Functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ $L(\tau) = 2\langle Q(\tau)Q(0)\rangle - \langle Q(2\tau)Q(0)\rangle \leq 1$

### References

* [A. J. Leggett and A. Garg, Phys. Rev. Lett. 54, 857 (1985)](http://dx.doi.org/10.1103/PhysRevLett.54.857)
* [A. J. Leggett and A. Garg, Phys. Rev. Lett. 54, 857 (1985)](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.54.857)
* [A. J. Leggett, J. Phys. Condens. Matter 14, R415 (2002)](http://dx.doi.org/10.1088/0953-8984/14/15/201)
<!-- #endregion -->

Expand Down Expand Up @@ -186,7 +186,7 @@ def leggett_garg(c_mat):

References:

* [N. Lambert, J.R. Johansson, F. Nori, Phys. Rev. B 82, 245421 (2011)](http://dx.doi.org/10.1103/PhysRevB.84.245421).
* [N. Lambert, J.R. Johansson, F. Nori, Phys. Rev. B 82, 245421 (2011)](https://journals.aps.org/prb/abstract/10.1103/PhysRevB.84.245421).
<!-- #endregion -->

```python
Expand Down
8 changes: 4 additions & 4 deletions tutorials-v4/quantum-circuits/qip-toffoli-cnot.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.8
jupytext_version: 1.16.4
kernelspec:
display_name: Python 3 (ipykernel)
display_name: qutip-dev
language: python
name: python3
---
Expand Down Expand Up @@ -39,7 +39,7 @@ q.add_gate("TOFFOLI", controls=[0, 2], targets=[1])
```

```python
q.png
q.draw()
```

```python
Expand All @@ -53,7 +53,7 @@ q2 = q.resolve_gates()
```

```python
q2.png
q2.draw()
```

```python
Expand Down
54 changes: 27 additions & 27 deletions tutorials-v4/quantum-circuits/quantum-gates.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.13.8
jupytext_version: 1.16.4
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand Down Expand Up @@ -63,7 +63,7 @@ cphase(pi / 2)
```python
q = QubitCircuit(2, reverse_states=False)
q.add_gate("CSIGN", controls=[0], targets=[1])
q.png
q.draw()
```

### Rotation about X-axis
Expand All @@ -74,8 +74,8 @@ rx(pi / 2)

```python
q = QubitCircuit(1, reverse_states=False)
q.add_gate("RX", targets=[0], arg_value=pi / 2, arg_label=r"\frac{\pi}{2}")
q.png
q.add_gate("RX", targets=[0], arg_value=pi / 2, style={"showarg": True})
q.draw()
```

### Rotation about Y-axis
Expand All @@ -86,8 +86,8 @@ ry(pi / 2)

```python
q = QubitCircuit(1, reverse_states=False)
q.add_gate("RY", targets=[0], arg_value=pi / 2, arg_label=r"\frac{\pi}{2}")
q.png
q.add_gate("RY", targets=[0], arg_value=pi / 2, style={"showarg": True})
q.draw()
```

### Rotation about Z-axis
Expand All @@ -98,8 +98,8 @@ rz(pi / 2)

```python
q = QubitCircuit(1, reverse_states=False)
q.add_gate("RZ", targets=[0], arg_value=pi / 2, arg_label=r"\frac{\pi}{2}")
q.png
q.add_gate("RZ", targets=[0], arg_value=pi / 2, style={"showarg": True})
q.draw()
```

### CNOT
Expand All @@ -111,7 +111,7 @@ cnot()
```python
q = QubitCircuit(2, reverse_states=False)
q.add_gate("CNOT", controls=[0], targets=[1])
q.png
q.draw()
```

### CSIGN
Expand All @@ -123,7 +123,7 @@ csign()
```python
q = QubitCircuit(2, reverse_states=False)
q.add_gate("CSIGN", controls=[0], targets=[1])
q.png
q.draw()
```

### Berkeley
Expand All @@ -135,7 +135,7 @@ berkeley()
```python
q = QubitCircuit(2, reverse_states=False)
q.add_gate("BERKELEY", targets=[0, 1])
q.png
q.draw()
```

### SWAPalpha
Expand All @@ -162,7 +162,7 @@ toffoli()
swap()
q = QubitCircuit(2, reverse_states=False)
q.add_gate("SWAP", targets=[0, 1])
q.png
q.draw()
```

### ISWAP
Expand All @@ -171,7 +171,7 @@ q.png
iswap()
q = QubitCircuit(2, reverse_states=False)
q.add_gate("ISWAP", targets=[0, 1])
q.png
q.draw()
```

### SQRTiSWAP
Expand Down Expand Up @@ -234,7 +234,7 @@ cnot(N=3)
```python
q = QubitCircuit(3, reverse_states=False)
q.add_gate("CNOT", controls=[1], targets=[2])
q.png
q.draw()
```

Furthermore, the control and target qubits (when applicable) can also be similarly specified using keyword arguments `control` and `target` (or in some cases `controls` or `targets`):
Expand All @@ -246,7 +246,7 @@ cnot(N=3, control=2, target=0)
```python
q = QubitCircuit(3, reverse_states=False)
q.add_gate("CNOT", controls=[0], targets=[2])
q.png
q.draw()
```

## Setup of a Qubit Circuit
Expand All @@ -261,7 +261,7 @@ In the following example, we take a SWAP gate. It is known that a swap gate is e
N = 2
qc0 = QubitCircuit(N)
qc0.add_gate("ISWAP", [0, 1], None)
qc0.png
qc0.draw()
```

```python
Expand All @@ -275,7 +275,7 @@ qc1 = QubitCircuit(N)
qc1.add_gate("CNOT", 0, 1)
qc1.add_gate("CNOT", 1, 0)
qc1.add_gate("CNOT", 0, 1)
qc1.png
qc1.draw()
```

```python
Expand All @@ -288,7 +288,7 @@ In place of manually converting the SWAP gate to CNOTs, it can be automatically

```python
qc2 = qc0.resolve_gates("CNOT")
qc2.png
qc2.draw()
```

```python
Expand All @@ -301,7 +301,7 @@ From QuTiP 4.4, we can also add gate at arbitrary position in a circuit.

```python
qc1.add_gate("CSIGN", index=[1], targets=[0], controls=[1])
qc1.png
qc1.draw()
```

## Example of basis transformation
Expand All @@ -313,7 +313,7 @@ qc3.add_gate("RX", 0, None, pi / 2, r"\pi/2")
qc3.add_gate("RY", 1, None, pi / 2, r"\pi/2")
qc3.add_gate("RZ", 2, None, pi / 2, r"\pi/2")
qc3.add_gate("ISWAP", [1, 2])
qc3.png
qc3.draw()
```

```python
Expand All @@ -325,7 +325,7 @@ U3

```python
qc4 = qc3.resolve_gates("CNOT")
qc4.png
qc4.draw()
```

```python
Expand All @@ -335,7 +335,7 @@ U4

```python
qc5 = qc3.resolve_gates("ISWAP")
qc5.png
qc5.draw()
```

```python
Expand All @@ -347,7 +347,7 @@ U5

```python
qc6 = qc3.resolve_gates(["ISWAP", "RX", "RY"])
qc6.png
qc6.draw()
```

```python
Expand All @@ -357,7 +357,7 @@ U6

```python
qc7 = qc3.resolve_gates(["CNOT", "RZ", "RX"])
qc7.png
qc7.draw()
```

```python
Expand All @@ -373,7 +373,7 @@ Interactions between non-adjacent qubits can be resolved by QubitCircuit to a se
```python
qc8 = QubitCircuit(3)
qc8.add_gate("CNOT", 2, 0)
qc8.png
qc8.draw()
```

```python
Expand All @@ -393,7 +393,7 @@ U9

```python
qc10 = qc9.resolve_gates("CNOT")
qc10.png
qc10.draw()
```

```python
Expand All @@ -418,7 +418,7 @@ From QuTiP 4.4 on, user defined gates can be defined by a python function that t
```python
def user_gate1(arg_value):
# controlled rotation X
mat = np.zeros((4, 4), dtype=np.complex)
mat = np.zeros((4, 4), dtype=complex)
mat[0, 0] = mat[1, 1] = 1.0
mat[2:4, 2:4] = rx(arg_value)
return Qobj(mat, dims=[[2, 2], [2, 2]])
Expand Down
2 changes: 1 addition & 1 deletion tutorials-v5/lectures/Lecture-11-Charge-Qubits.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ where $E_C$ is the charge energy, $E_J$ is the Josephson energy, and $\left| n\r

#### References

* [J. Koch et al, Phys. Rec. A 76, 042319 (2007)](http://link.aps.org/doi/10.1103/PhysRevA.76.042319)
* [J. Koch et al, Phys. Rec. A 76, 042319 (2007)](https://journals.aps.org/pra/abstract/10.1103/PhysRevA.76.042319)
* [Y.A. Pashkin et al, Quantum Inf Process 8, 55 (2009)](http://dx.doi.org/10.1007/s11128-009-0101-5)


Expand Down
4 changes: 2 additions & 2 deletions tutorials-v5/lectures/Lecture-2B-Single-Atom-Lasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ in units where $\hbar = 1$.

References:

* [Yi Mu, C.M. Savage, Phys. Rev. A 46, 5944 (1992)](http://dx.doi.org/10.1103/PhysRevA.46.5944)
* [Yi Mu, C.M. Savage, Phys. Rev. A 46, 5944 (1992)](https://journals.aps.org/pra/abstract/10.1103/PhysRevA.46.5944)

* [D.A. Rodrigues, J. Imbers, A.D. Armour, Phys. Rev. Lett. 98, 067204 (2007)](http://dx.doi.org/10.1103/PhysRevLett.98.067204)
* [D.A. Rodrigues, J. Imbers, A.D. Armour, Phys. Rev. Lett. 98, 067204 (2007)](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.98.067204)

* [S. Ashhab, J.R. Johansson, A.M. Zagoskin, F. Nori, New J. Phys. 11, 023030 (2009)](http://dx.doi.org/10.1088/1367-2630/11/2/023030)

Expand Down
4 changes: 2 additions & 2 deletions tutorials-v5/lectures/Lecture-3A-Dicke-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ $\displaystyle J_\pm = \sum_{i=1}^N \sigma_\pm^{(i)}$

### References

* [R.H. Dicke, Phys. Rev. 93, 99–110 (1954)](http://dx.doi.org/10.1103/PhysRev.93.99)
* [R.H. Dicke, Phys. Rev. 93, 99–110 (1954)](https://journals.aps.org/pr/abstract/10.1103/PhysRev.93.99)


## Setup problem in QuTiP
Expand Down Expand Up @@ -198,7 +198,7 @@ fig.tight_layout()

### References

* [Lambert et al., Phys. Rev. Lett. 92, 073602 (2004)](http://dx.doi.org/10.1103/PhysRevLett.92.073602).
* [Lambert et al., Phys. Rev. Lett. 92, 073602 (2004)](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.92.073602).

```python
def calulcate_entropy(M, N, g_vec):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ The regime $g$ is large compared with all other energy scales in the Hamiltonian

References:

* [P. Nataf et al., Phys. Rev. Lett. 104, 023601 (2010)](http://dx.doi.org/10.1103/PhysRevLett.104.023601)
* [P. Nataf et al., Phys. Rev. Lett. 104, 023601 (2010)](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.104.023601)

* [J. Casanova et al., Phys. Rev. Lett. 105, 26360 (2010)](http://dx.doi.org/10.1103/PhysRevLett.105.263603).
* [J. Casanova et al., Phys. Rev. Lett. 105, 26360 (2010)](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.105.263603).

* [S. Ashhab et al., Phys. Rev. A 81, 042311 (2010)](http://dx.doi.org/10.1103/PhysRevA.81.042311)
* [S. Ashhab et al., Phys. Rev. A 81, 042311 (2010)](https://journals.aps.org/pra/abstract/10.1103/PhysRevA.81.042311)
<!-- #endregion -->

<!-- #region -->
Expand Down
4 changes: 2 additions & 2 deletions tutorials-v5/lectures/Lecture-4-Correlation-Functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ $L(\tau) = 2\langle Q(\tau)Q(0)\rangle - \langle Q(2\tau)Q(0)\rangle \leq 1$

### References

* [A. J. Leggett and A. Garg, Phys. Rev. Lett. 54, 857 (1985)](http://dx.doi.org/10.1103/PhysRevLett.54.857)
* [A. J. Leggett and A. Garg, Phys. Rev. Lett. 54, 857 (1985)](https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.54.857)
* [A. J. Leggett, J. Phys. Condens. Matter 14, R415 (2002)](http://dx.doi.org/10.1088/0953-8984/14/15/201)
<!-- #endregion -->

Expand Down Expand Up @@ -191,7 +191,7 @@ def leggett_garg(c_mat):

References:

* [N. Lambert, J.R. Johansson, F. Nori, Phys. Rev. B 82, 245421 (2011)](http://dx.doi.org/10.1103/PhysRevB.84.245421).
* [N. Lambert, J.R. Johansson, F. Nori, Phys. Rev. B 82, 245421 (2011)](https://journals.aps.org/prb/abstract/10.1103/PhysRevB.84.245421).
<!-- #endregion -->

```python
Expand Down
Loading

0 comments on commit e6ac5f6

Please sign in to comment.