Skip to content

Commit

Permalink
Improve tutorial and rename nparticles->manybody.
Browse files Browse the repository at this point in the history
  • Loading branch information
bastikr committed Mar 28, 2017
1 parent e310486 commit dbfee30
Show file tree
Hide file tree
Showing 6 changed files with 296 additions and 85 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
docs/build
docs/source/examples/
docs/source/_tutorial.rst
.ipynb_checkpoints
*_files/
docs/source/examples/
2 changes: 1 addition & 1 deletion docs/converttutorial.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
jupyter-nbconvert --to=rst --FilesWriter.build_directory=source --execute source/tutorial.ipynb
jupyter-nbconvert --to=rst --FilesWriter.build_directory=source --execute source/_tutorial.ipynb
133 changes: 53 additions & 80 deletions docs/source/tutorial.ipynb → docs/source/_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@
},
"source": [
"Many quantum systems are already implemented:\n",
"* Fock bases\n",
"* Spins\n",
"\n",
"* [Spins](spin.html)\n",
"* Fock bases _`section-spin`\n",
"* Particles\n",
"* N-level systems\n",
"* Many-body systems"
Expand Down Expand Up @@ -362,19 +363,10 @@
" master(T, psi0/rho0, H, J)\n",
" mcwf(T, psi0, H, J)\n",
"\n",
"They all return two vectors `tout` and `states`."
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"### Schrödinger equation\n",
"They all return two vectors `tout` and `states`.\n",
"\n",
"Let's now analyze the dynamics of the system according to the Schrödinger equation."
"Let's now analyze the dynamics of the system according to the\n",
"Schrödinger equation."
]
},
{
Expand All @@ -398,82 +390,53 @@
"editable": true
},
"source": [
"The results can be visualized using for example matplotlib."
"Adding photon loss to the cavity by introducing a jump operator :math:`a` means that the system is an open quantum system and its time evolution is then described by a master equation."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
"collapsed": true
},
"outputs": [],
"source": [
"using PyPlot\n",
"\n",
"figure(figsize=[10, 3])\n",
"\n",
"subplot(1, 2, 1)\n",
"xlabel(\"Time\")\n",
"ylabel(L\"$\\langle |e\\rangle \\langle e| \\rangle$\")\n",
"plot(tout, expect(2, sp*sm, ψt))\n",
"\n",
"subplot(1, 2, 2)\n",
"xlabel(\"Time\")\n",
"ylabel(L\"$\\langle n \\rangle$\")\n",
"plot(tout, expect(1, n, ψt));"
"κ = 1.\n",
"J = [embed(b, 1, a)]\n",
"tout, ρt = timeevolution.master(T, ψ0, H, J; Gamma=[κ]);"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"metadata": {},
"source": [
"### Master equation\n",
"\n",
"Let's now add photon loss to the cavity by introducing a jump operator $a$. This means the system is now an open quantum system and is described by a master equation."
"Alternatively, one can use the MCWF method to analyze the time evolution\n",
"of the system. Physically, it can be interpreted as an experimental\n",
"setup where every photon leaving the cavity is meassured by a photon\n",
"counter, thereby projecting the system onto the state\n",
"$| \\psi\\rangle \\rightarrow a |\\psi\\rangle$. This leads to a\n",
"coherent time evolution according to a schroedinger equation interrupted\n",
"by jumps at certain random points in time."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
"collapsed": true
},
"outputs": [],
"source": [
"κ = 1.\n",
"J = [embed(b, 1, a)]\n",
"tout, ρt = timeevolution.master(T, ψ0, H, J; Gamma=[κ]);\n",
"\n",
"figure(figsize=[10, 3])\n",
"\n",
"subplot(1, 2, 1)\n",
"xlabel(\"Time\")\n",
"ylabel(L\"$\\langle |e\\rangle \\langle e| \\rangle$\")\n",
"plot(tout, expect(2, sp*sm, ρt))\n",
"\n",
"subplot(1, 2, 2)\n",
"xlabel(\"Time\")\n",
"ylabel(L\"$\\langle n \\rangle$\")\n",
"plot(tout, expect(1, n, ρt));"
"tout, ψt_mcwf = timeevolution.mcwf(T, ψ0, H, J; seed=UInt(0),\n",
" display_beforeevent=true,\n",
" display_afterevent=true);"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"metadata": {},
"source": [
"### Monte Carlo wave function\n",
"Alternatively, one can use the MCWF method to analyze the time evolution of the system. Physically, it can be interpreted as an experimental setup where every photon leaving the cavity is meassured by a photon counter, thereby projecting the system onto the state $| \\psi\\rangle \\rightarrow a |\\psi\\rangle$. This leads to a coherent time evolution according to a schroedinger equation interrupted by these jumps at certain random points in time."
"The results can be visualized using for example matplotlib."
]
},
{
Expand All @@ -486,33 +449,37 @@
},
"outputs": [],
"source": [
"using PyPlot\n",
"\n",
"figure(figsize=[10, 3])\n",
"\n",
"subplot(1, 2, 1)\n",
"xlabel(\"Time\")\n",
"ylabel(L\"$\\langle |e\\rangle \\langle e| \\rangle$\")\n",
"xlim(0, 5)\n",
"ylim(0, 1)\n",
"plot(T, expect(2, sp*sm, ψt), label=\"Schrödinger\")\n",
"plot(T, expect(2, sp*sm, ρt), label=\"Master\")\n",
"plot(tout, expect(2, sp*sm, ψt_mcwf), label=\"MCWF\")\n",
"legend()\n",
"\n",
"subplot(1, 2, 2)\n",
"xlabel(\"Time\")\n",
"ylabel(L\"$\\langle n \\rangle$\")\n",
"\n",
"tout, ψt_mcwf = timeevolution.mcwf(T, ψ0, H, J; seed=UInt(0),\n",
" display_beforeevent=true,\n",
" display_afterevent=true);\n",
"subplot(1, 2, 1)\n",
"plot(tout, expect(2, sp*sm, ψt_mcwf))\n",
"subplot(1, 2, 2)\n",
"plot(tout, expect(1, n, ψt_mcwf));"
"xlim(0, 5)\n",
"ylim(0, 1)\n",
"plot(T, expect(1, n, ψt), label=\"Schrödinger\")\n",
"plot(T, expect(1, n, ρt), label=\"Master\")\n",
"plot(tout, expect(1, n, ψt_mcwf), label=\"MCWF\")\n",
"legend();"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"metadata": {},
"source": [
"In the statistical average the MCWF time evolution is equaivalent to the time evolution according to the master equation."
"In the statistical average the MCWF time evolution is equaivalent to the\n",
"time evolution according to the master equation."
]
},
{
Expand Down Expand Up @@ -545,12 +512,18 @@
"figure(figsize=[10, 3])\n",
"\n",
"subplot(1, 2, 1)\n",
"plot(T, expect(2, sp*sm, ρt))\n",
"plot(T, exp_e/Ntrajectories)\n",
"xlabel(\"Time\")\n",
"ylabel(L\"$\\langle |e\\rangle \\langle e| \\rangle$\")\n",
"plot(T, expect(2, sp*sm, ρt), label=\"Master\")\n",
"plot(T, exp_e/Ntrajectories, label=L\"$\\langle \\mathrm{MCWF} \\rangle$\")\n",
"legend()\n",
"\n",
"subplot(1, 2, 2)\n",
"plot(T, expect(1, n, ρt))\n",
"plot(T, exp_n/Ntrajectories);"
"xlabel(\"Time\")\n",
"ylabel(L\"$\\langle n \\rangle$\")\n",
"plot(T, expect(1, n, ρt), label=\"Master\")\n",
"plot(T, exp_n/Ntrajectories, label=L\"$\\langle \\mathrm{MCWF} \\rangle$\")\n",
"legend();"
]
},
{
Expand All @@ -567,7 +540,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 0.5.0",
"display_name": "Julia 0.5.1",
"language": "julia",
"name": "julia-0.5"
},
Expand Down
4 changes: 2 additions & 2 deletions docs/source/nparticles.rst → docs/source/manybody.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _section-nparticles:
.. _section-manybody:

N-Particles Basis
Many-body systems
=================

Describing systems consisting of many identical particles in a tensor product space created out of single particle Hilbert spaces leads to the problem that not all states in this space correspond to real physical states. In this picture one would have to restrict the Hilbert space to a subspace that is invariant under permutation of particles. However, it is also possible to find a valid description that doesn't first introduce redundant states that later on have to be eliminated. The general idea is to choose an arbitrary basis :math:`\{\left|u_i\right\rangle\}_i` of the single particle Hilbert space and create the N-particle Hilbert space from states that count how many particles are in each of these states - which will in the following be denoted as :math:`\left|\{n\}\right\rangle`. Of course the sum of these occupation numbers has to be identical to the number of particles. For fermionic particles an additional restriction is that there can't be more than one particle in one state.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/quantumsystems.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ Quantum systems in **QuantumOptics.jl** primarily define one or more appropriate
fock
nlevel
particle
nparticles
manybody
Loading

0 comments on commit dbfee30

Please sign in to comment.