Skip to content

Commit 8028705

Browse files
authored
Merge pull request #31 from mabuni1998/Fixing-Plots-in-Documentation
added RCParams in plots and installed matplolib in initial setup
2 parents 92e455c + 1d9f675 commit 8028705

File tree

11 files changed

+881
-46
lines changed

11 files changed

+881
-46
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Install Julia dependencies
2121
env:
2222
PYTHON: ""
23-
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
23+
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate(); using PyPlot'
2424
- name: Build and deploy
2525
env:
2626
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ authors = "Matias Bundgaard-Nielsen",
1919
pages = [
2020
"WaveguideQED.jl" => "index.md",
2121
"theoreticalbackground.md",
22-
"toturial.md",
22+
"tutorial.md",
2323
"detection.md",
2424
"multiplewaveguides.md",
2525
"Examples" => ["Scattering on two level system" => "example_lodahl.md"],

docs/src/detection.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [Detection and Projections](@id BStoturial)
1+
# [Detection and Projections](@id BStutorial)
22
A beamsplitter is a partly reflective partly transmitive mirror that splits up an incomming photon as depicted here.
33

44
![beamsplitter](./illustrations/single_beamsplitter.png)

docs/src/example_lodahl.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ For the single photon states we have to calculate the two time scattered distrib
8181
ψ1LeftScat = zeros(ComplexF64,(length(times),length(times)))
8282
ψ1RightScat = zeros(ComplexF64,(length(times),length(times)))
8383
ψ1LeftRightScat = zeros(ComplexF64,(length(times),length(times)))
84-
ψ1Right = OnePhotonView(ψScat1,[:,1],1)
85-
ψ1Left = OnePhotonView(ψScat1,[:,1],2)
84+
ψ1Right = OnePhotonView(ψScat1,[:,1],2)
85+
ψ1Left = OnePhotonView(ψScat1,[:,1],1)
8686
8787
for i in eachindex(times)
8888
for j in eachindex(times)
@@ -97,9 +97,9 @@ nothing #hide
9797
Finall, this can be plotted and we note that this matches fig. 3 in Ref. ^[1]:
9898

9999
```@example lodahl
100-
using PyPlot #hide
100+
using PyPlot; #hide
101101
fig,axs = subplots(3,2,figsize=(9,17))
102-
plot_list = [ψ2LeftScat,ψ2RightScat,ψ2LeftRightScat,ψ1LeftScat,ψ1RightScat,ψ1LeftRightScat]
102+
plot_list = [ψ2RightScat,ψ2LeftScat,ψ2LeftRightScat,ψ1RightScat,ψ1LeftScat,ψ1LeftRightScat]
103103
for (i,ax) in enumerate(axs)
104104
plot_twophoton!(ax,plot_list[i],times)
105105
end

docs/src/multiplewaveguides.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Multiple waveguides
22

33
## [Two Waveguides](@id twowaveguide)
4-
In the previous examples, we have only considered cases with a single waveguide. In this toturial, we show how to model a beamsplitter and an optical switch using two waveguides. A beamsplitter or a swap gate can be modelled using the Hamiltonian $H_I = V(w_1^\dagger w_2 + w_2^\dagger w_1)$ where V is some interaction strength that determines which interaction is moddeled (we will discuss this in detail later). $w_1$ and $w_2$ is the annihilation operators of the two waveguides. A sketch of the system can be seen here:
4+
In the previous examples, we have only considered cases with a single waveguide. In this tutorial, we show how to model a beamsplitter and an optical switch using two waveguides. A beamsplitter or a swap gate can be modelled using the Hamiltonian $H_I = V(w_1^\dagger w_2 + w_2^\dagger w_1)$ where V is some interaction strength that determines which interaction is moddeled (we will discuss this in detail later). $w_1$ and $w_2$ is the annihilation operators of the two waveguides. A sketch of the system can be seen here:
55

66
![Alt text](./illustrations/twowaveguide.png)
77

@@ -49,7 +49,7 @@ nothing #hide
4949
```
5050

5151
## Beamsplitter
52-
Let's now treat the same example as in [Interference on Beamsplitter](@ref BStoturial). We consider the two waveguides in a identic single photon state and thus use the above defined `ψ_single_1_and_2`. The Hamiltonian governing a beamsplitter in the time binned formalism has $V= \pi/4$:
52+
Let's now treat the same example as in [Interference on Beamsplitter](@ref BStutorial). We consider the two waveguides in a identic single photon state and thus use the above defined `ψ_single_1_and_2`. The Hamiltonian governing a beamsplitter in the time binned formalism has $V= \pi/4$:
5353

5454
```@example multiple
5555
V = pi/4

docs/src/theoreticalbackground.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ The effect of the creation operator is to create a photon in timebin k and can b
9292
This is also seen if we plot the creation operator acting on the vacuum:
9393

9494
```@example theory
95-
using PyPlot
9695
ψ = wd*zerophoton(bw)
9796
viewed_state = OnePhotonView(ψ)
9897
fig,ax = subplots(1,1,figsize=(9,4.5))
@@ -143,6 +142,7 @@ We can define a twophoton basis and corresponding operator by:
143142
```@example theory
144143
bw = WaveguideBasis(2,times)
145144
wd = create(bw)
145+
nothing #hide
146146
```
147147
The creation operator can then be visualized by acting on a onephoton state with ones all over. This is seen in the following. Note that the state is visualized as a contour plot mirrored around the diagonal.
148148

@@ -170,7 +170,6 @@ nothing #hide
170170
Here, we defined the two photon equivalent of our single photon gaussian state. When we visualize it, we now need two times, and we make a contour plot. This is easily done viewing the twophoton state:
171171

172172
```@example theory
173-
using PyPlot
174173
viewed_state = TwoPhotonView(ψ)
175174
fig,ax = subplots(1,1,figsize=(4.5,4.5))
176175
plot_twophoton!(ax,viewed_state,times)

docs/src/toturial.md renamed to docs/src/tutorial.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Toturials
1+
# Tutorials
22
In this section, we show simple examples that illustrate how to use **WaveguideQED.jl** in combination with [`QuantumOptics.jl`](https://qojulia.org/)
33

44
## [Combining with QuantumOptics.jl](@id combining)
@@ -9,7 +9,7 @@ Basises, states, and operators defined in `WaveguideQED.jl` can be effortlesly c
99

1010
We start by defining the basis of the cavity and waveguide:
1111

12-
```@example toturial
12+
```@example tutorial
1313
using WaveguideQED
1414
using QuantumOptics
1515
times = 0:0.1:10
@@ -20,7 +20,7 @@ nothing #hide
2020

2121
Next we want to create the Hamiltonian for the system. The interaction between the waveguide and cavity is at timestep k given by[^1] $$H_k = i \hbar \sqrt{\gamma / \Delta t}( a^\dagger w_k - a w_k^\dagger)$$, where $$a$$ ($$a^\dagger$$) is the cavity annihilation (creation) operator, $$w_k$$($$w_k^\dagger$$) is the waveguide annihilation (creation) operator, $$\gamma$$ is the leakage rate of the cavity, and `\Delta t = times[2]-times[1]` is the width of the timebin. `WaveguideQED.jl` follows the same syntax as [`QuantumOptics.jl`](https://qojulia.org/) and operators are defined from a basis. Operators of different Hilbert spaces are then combined using ⊗ (``\otimes``):
2222

23-
```@example toturial
23+
```@example tutorial
2424
a = destroy(bc)
2525
ad = create(bc)
2626
w = destroy(bw)
@@ -33,7 +33,7 @@ nothing #hide
3333

3434
With this we can now simulate the scattering of a single photon with a gaussian wavefunction scattered on a cavity. We define the initial state as waveguide state as:
3535

36-
```@example toturial
36+
```@example tutorial
3737
ξ(t,σ,t0) = sqrt(2/σ)* (log(2)/pi)^(1/4)*exp(-2*log(2)*(t-t0)^2/σ^2)
3838
σ,t0 = 1,5
3939
ψ_waveguide = onephoton(bw,ξ,times,σ,t0)
@@ -42,21 +42,21 @@ nothing #hide
4242

4343
Assuming the cavity is empty the combined initial state is then:
4444

45-
```@example toturial
45+
```@example tutorial
4646
ψ_in = fockstate(bc,0) ⊗ ψ_waveguide
4747
nothing #hide
4848
```
4949

5050
With the initial state we can then call the solver the get the wavefunction after the interaction with the cavity.
5151

52-
```@example toturial
52+
```@example tutorial
5353
ψ_out = waveguide_evolution(times,ψ_in,H)
5454
nothing #hide
5555
```
5656

5757
Plotting the wavefunction and its norm square gives:
5858

59-
```@example toturial
59+
```@example tutorial
6060
using PyPlot
6161
viewed_state = OnePhotonView(ψ_out)
6262
fig,ax = subplots(1,2,figsize=(9,4.5))
@@ -79,7 +79,7 @@ We see that the wavefunction has changed after the interaction with the cavity.
7979

8080
In the previous example, only the state at the final timestep was shown. This shows the output wavefunction, but one might also be interested in intermediate states or expectation values. Expectation values can be outputtet from the solver by using the `fout` keyword. As an example, we can get the number of photons in the cavity as a function of time by:
8181

82-
```@example toturial
82+
```@example tutorial
8383
n = (ad*a) ⊗ identityoperator(bw)
8484
function exp_na(time,psi)
8585
expect(n,psi)
@@ -90,7 +90,7 @@ nothing #hide
9090

9191
If we also want to know the number of photons in the waveguide state as a function of time another operator to out expectation function as:
9292

93-
```@example toturial
93+
```@example tutorial
9494
n = (ad*a) ⊗ identityoperator(bw)
9595
n_w = identityoperator(bc) ⊗ (create(bw)*destroy(bw))
9696
function exp_na_and_nw(time,psi)
@@ -104,7 +104,7 @@ Where `expect(n_w,psi)` calculates the expectation value of all times of the pul
104104

105105
This can be plottet as:
106106

107-
```@example toturial
107+
```@example tutorial
108108
fig,ax = subplots(1,1,figsize=(9,4.5))
109109
ax.plot(times,na,"b-",label="na")
110110
ax.plot(times,nw,"r-",label="nw")

0 commit comments

Comments
 (0)