Skip to content

Commit

Permalink
Update many body examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
bastikr committed Mar 23, 2017
1 parent 9fbe30f commit e39eda3
Show file tree
Hide file tree
Showing 2 changed files with 190 additions and 63 deletions.
156 changes: 117 additions & 39 deletions examples/manybody-fourlevel-system.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"*This notebook can be found on* [github](https://github.com/bastikr/QuantumOptics.jl/blob/master/examples/manybody-fourlevel-system.ipynb)\n",
"# Four level system in many-body formalism"
"# Four level system in many-body formalism\n",
"\n",
"In this example, we illustrate the treatment of many-body quantum systems. A **ManyBodyBasis** can be used to describe indistinguishable particles that follow certain exchange symmetries (fermions or bosons). We can define an arbitrary quantum system - in this example a N-level system consisting of four energy states, and use it as foundation of a many-body basis. The basis states of the many-body basis then simply correspond to the number of particles that are in one of these four states. Which occupation states are included depends on the type of the particles (bosonic or fermionic) and if the particle number is preserved. For fermions the dimension of the Hilbert space is greatly reduced since it does not allow more than one particle in the same state (Pauli principle)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
Expand All @@ -22,41 +29,76 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"Define 4-level system"
"First, we define the four-level system and a Hamiltonian with energies $0, 1, 2, 3$."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"b = NLevelBasis(4)\n",
"\n",
"H = diagonaloperator(b, [0, 1, 2, 3])\n",
"\n",
"H = diagonaloperator(b, [0, 1, 2, 3]);"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"Each of the states decays to the next lower one which we account for with the following jump operators."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"j34 = transition(b, 3, 4) # decay from 4th into 3rd level\n",
"j23 = transition(b, 2, 3) # decay from 3rd into 2nd level\n",
"j12 = transition(b, 1, 2) # decay from 2nd into 1st level;"
]
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"## Two fermions with conserved particle number\n",
"Define associated many-body system with two fermionic particles"
"Now, as a first example, we consider two fermionic particles. Each of them can occupy one of the four levels in the system, but not at the same time. To this end, we define a many-body basis associated to this N-level system. Calculating the many-body operators from the corresponding n-level operators can be done with the **manybodyoperator()** function. Basically it uses the relation\n",
"$$\n",
" \\tilde{A} = \\sum_{st} c_s^\\dagger c_t \\langle u_s| A |u_t \\rangle\n",
"$$\n",
"to convert the one-body operator $A$ to the many-body operator $\\tilde{A}$."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
Expand All @@ -74,16 +116,23 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"Calculate time evolution starting with the particles in the two uppermost levels."
"The resulting many-body operators will then account for the decay as defined for the four-level system. For example, the jump operator j34_mb will map the state $|0101\\rangle$ to $|0110\\rangle$, i.e. moving a particle from state 4 into state 3.\n",
"\n",
"We can now calculate a time evolution according to a master equation as usual so that we see the dynamic decay of the energy level occupations. To this end, we initialize the system in the highest state $|0011\\rangle$."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
Expand All @@ -94,16 +143,21 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"Compare occupation of the $|1 1 0 0\\rangle$ and $|0 0 1 1\\rangle$ states and occupation of the one-body basis levels."
"Now, we compare the occupations of the $|1 1 0 0\\rangle$ and $|0 0 1 1\\rangle$ states and the occupations of the one-body basis levels."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
Expand All @@ -115,71 +169,95 @@
"\n",
"figure(figsize=(10, 3))\n",
"subplot(1, 2, 1)\n",
"plot(tout, expect(n0011, ρt))\n",
"plot(tout, expect(n1100, ρt));\n",
"plot(tout, real(expect(n0011, ρt)), label=\"n0011\")\n",
"plot(tout, real(expect(n1100, ρt)), label=\"n1100\")\n",
"legend()\n",
"\n",
"subplot(1, 2, 2)\n",
"for i in 1:4\n",
" plot(tout, expect(number(b_mb, i), ρt))\n",
"end;"
" plot(tout, real(expect(number(b_mb, i), ρt)), label=\"level $i\")\n",
"end\n",
"legend()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"## Three bosons with particle loss"
"## Three bosons with particle loss\n",
"\n",
"As another example, we can instead consider three bosonic particles and additionally account for particle loss. This results in many more possible basis states. We include this in the calculation by explicitly passing all possible particle numbers when creating the many-body basis, i.e. each state can be occupied by 0 to 3 particles."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"b_mb = ManyBodyBasis(b, bosonstates(b, [0, 1, 2, 3, 4, 5]))\n",
"b_mb = ManyBodyBasis(b, bosonstates(b, [0, 1, 2, 3]))\n",
"\n",
"H_mb = manybodyoperator(b_mb, H)\n",
"\n",
"j34_mb = manybodyoperator(b_mb, j34)\n",
"j23_mb = manybodyoperator(b_mb, j23)\n",
"j12_mb = manybodyoperator(b_mb, j12)\n",
"\n",
"at4_mb = create(b_mb, 4) # Particles are created in the uppermost level\n",
"a1_mb = destroy(b_mb, 1) # Particles are lost from the first level\n",
"\n",
"Γ = [0.9, 0.5, 0.3, 3., 0.5]\n",
"J_mb = [j34_mb, j23_mb, j12_mb, a1_mb, at4_mb];"
"j12_mb = manybodyoperator(b_mb, j12);"
]
},
{
"cell_type": "markdown",
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"In addition to the spontaneous decay of the four-level system, we now also define a particle annihilation operator and include it in the jump operators."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"a1_mb = destroy(b_mb, 1) # Particles are lost from the first level\n",
"\n",
"Γ = [0.9, 0.5, 0.3, 3.0]\n",
"J_mb = [j34_mb, j23_mb, j12_mb, a1_mb]\n",
"\n",
"T = [0:0.1:10;]\n",
"Ψ0_mb = basisstate(b_mb, [0, 0, 0, 0])\n",
"Ψ0_mb = basisstate(b_mb, [0, 0, 0, 3])\n",
"tout, ρt = timeevolution.master(T, Ψ0_mb, H_mb, J_mb; Gamma=Γ);"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
"figure(figsize=(5, 3))\n",
"plot(tout, expect(number(b_mb), ρt), \"--k\", alpha=0.6)\n",
"plot(tout, real(expect(number(b_mb), ρt)), \"--k\", alpha=0.6, label=\"particle number\")\n",
"for i in 1:4\n",
" plot(tout, expect(number(b_mb, i), ρt))\n",
"end;"
" plot(tout, real(expect(number(b_mb, i), ρt)), label=\"level $i\")\n",
"end\n",
"legend()\n",
"show()"
]
},
{
Expand All @@ -194,7 +272,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 0.5.0",
"display_name": "Julia 0.5.1",
"language": "julia",
"name": "julia-0.5"
},
Expand Down
Loading

0 comments on commit e39eda3

Please sign in to comment.