Delightful Dandelions

  • Chess
  • Python
  • Quantum Mechanics

  • Chess
  • Python
  • Quantum Mechanics

Embed an ipython jupyter notebook in wordpress

October 19, 2017 by delightfuldandelions 1 Comment

Nothing could be simpler

  • Generate the notebook
    • inline your graphics using %matplotlib -inline in the first cell as shown
    • export as an html file.
  • Upload the html to as a media file to the wordpress site.
    • Make note of the url of the media file
  • Install the iframe plugin
  • Add this code to the body of the post:
    • [iframe src="url_to_your_file"]
  • Done

numpy_acrobatics-2

Filed Under: Uncategorized

Simple itertools examples

October 15, 2017 by delightfuldandelions Leave a Comment

If we have a quantum system that has n_sites and n_levels, itertools.product provides a convenient way to enumerate the basis_states:

1
2
3
4
import itertools
n_sites=2 # 2 lattice sites
n_levels=3 # 3 energy levels per lattice site
basis_states = list(itertools.product(range(n_levels), repeat=n_sites))

Python
1
2
In [19]: list(itertools.product(range(n_levels), repeat=n_sites))
Out[19]: [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]

 

Filed Under: Python

Partial Trace of the Density Matrix – Simple example and python code

January 28, 2017 by delightfuldandelions Leave a Comment

 

Here we discuss the meaning of a partial trace and show how to perform this operation.  We provide explicit examples and a python implementation that is intended to be instructive, but is not (at all) optimized for efficiency.

We first consider the canonical example of two coupled two-level systems, sites a and b.

The basis states of this system are \ket{00}, \ket{01}, \ket{10}, \ket{11}, for \ket{q_a, q_b} and the density matrix is:

\rho =\begin{bmatrix}  \rho_{00,00} & \rho_{00,01}  & \rho_{00,10} & \rho_{00,11} \\  \rho_{01,00} & \rho_{01,01}  & \rho_{01,10} & \rho_{01,11} \\  \rho_{10,00} & \rho_{10,01}  & \rho_{10,10} & \rho_{10,11} \\  \rho_{11,00} & \rho_{11,01}  & \rho_{11,10} & \rho_{11,11} \\  \end{bmatrix}

The reduced density matrix for one of these sites can be computed by the partial trace.  For site a the reduced density matrix is:

$

\rho_{a} = \begin{bmatrix}

\rho_{00, 00} + \rho_{01,01} & \rho{10,10} + \rho{11

 

Filed Under: Quantum Mechanics

Example python post

January 7, 2017 by delightfuldandelions Leave a Comment

Here is something that you might want to do in python:

 

Test Function
Python
1
2
3
def my_function():
    for i,val in enumerate(data):
        print '{},{}'.format(i,val)

Filed Under: Python

Categories

Copyright © 2025 · Minimum Pro Theme on Genesis Framework · WordPress · Log in