Esempio n. 1
0
U, s, V = numpy.linalg.svd(basis*q.D())
V = V.conjugate().T		# Numpy quirk
qas = [st.a for st in esbl]
xs = numpy.linspace(-ext,ext,gs)
ys = numpy.linspace(-ext,ext,gs)

for i in xrange(len(s)):
	# sw
	pylab.subplot(2,2*R,2*R+i+1)
	T = blended_transform_factory(pylab.gca().transAxes, pylab.gcf().transFigure)
	pylab.text(0.5, 0.5, "%.4f" % s[i], transform=T)

	# right sv
	pylab.axis('off')
	pylab.bar(range(2*R), V[:,i].real, 0.35, hold=True, color='k')
	pylab.bar(numpy.arange(2*R)+0.35, V[:,i].imag, 0.35, color='r')
	pylab.ylim(-1,1)
	
	# ensemble
	pylab.subplot(2,2*R,i+1)
	plotens(q)
		
	# Q function of left sv
	qpts = [Bra(coherent(x+y*1j)) for x in xs for y in ys]
	A = Matrix(gs, gs, [abs(a*basis.conjugate()*col(U[:,i]))**2 for a in qpts])
	conts = pylab.contour(xs, ys, A, colors='brown', alpha=0.5, linewidths=2)
	pylab.clabel(conts, **csty)
	pylab.axis([-ext,ext,-ext,ext])
	pylab.axis('off')

pylab.show()
Esempio n. 2
0
ham = lop.conjugate()*lop.conjugate()*lop*lop
p = 20		# Fock basis size

basis = col(Bra(number(n)) for n in xrange(p))
def zdot(t, z):
	"return zdot such that |ql>zdot = -iH|qr>"
	q = q0.smrp(col(z))
	lhs = basis*q.D()
	iHq = (-1j)*ham*q
	rhs = basis*iHq
	zd, r, rk, sing = numpy.linalg.lstsq(lhs, rhs)
	zd = zd.flatten()
	print zd
	return zd

# set up initial state
v = FockExpansion(1)
q0 = Ket(Sum(*(DisplacedState(a, v) for a in [ 2.46261965+0.70381217j,  2.48197955-0.16273579j,
        2.39546681+0.22578992j])))
q0 /= norm(q0)

pylab.subplot(211)
plotens(q0)

igtr = scipy.integrate.complex_ode(zdot)
igtr.set_initial_value(array(q0.prms()).flatten())
pylab.subplot(212)
plotens(q0.smrp(col(igtr.integrate(tmax))))

pylab.show()