return vwall + vbar + voffset Npoints = (2000, ) dr = (L[0] / (Npoints[0] - 1), ) Xs = [(-L[0] / 2 + i * dr[0]) for i in xrange(Npoints[0])] Uext = np.zeros(Npoints) for i, x in enumerate(Xs): Uext[i, ] = vext((x, )) fprint("output/uext", Uext, (Xs, )) print "Uext saved in output" b.prepareMatrices(vext, None) qmech = q.qfr(b, vext, lamb) tolerance = 1E-2 states = [] ens = qmech.Hdiag.tolist() curr = ens[0] avgen = curr lidx = [0] for ii, en in enumerate(ens[1:]): if abs(curr - en) < tolerance: lidx.append(ii + 1) avgen = avgen + curr else: avgen = avgen / len(lidx) states.append((avgen, tuple(lidx))) avgen = en
namex = "x**2_eta" + bn namey = "y**2_eta" + bn namer = "r12**-1_eta" + bn hp.loadFunc(namex, v1x, fdir="../../data/harmonic") hp.loadFunc(namey, v1y, fdir="../../data/harmonic") hp.compoundFunc("Uext", v1, [namex, namey], [wx**2, wy**2]) hp.loadFunc(namer, v2, Rw, fdir="../../data/harmonic") basis = hm.bset(bpar, nlevs, npart, [(-10, 10), (-10, 10)], 10000, symmetry) lamb = 0.5 if interaction == "On": basis.prepareMatrices(v1, v2) qmech = q.qfr(basis, v1, lamb, v2) else: basis.prepareMatrices(v1, v2) qmech = q.qfr(basis, v1, lamb) #psi0=qmech.U[:,0].tolist() #psi1=qmech.U[:,1].tolist() # from eigenvalues list regroup with degenerate states # this is an array of tuples. Each tuple is (E_n, states), where # states is a tuple of indices corresponding to the relative eigenstates. # Since E_n are approximated we need to specify a tolerance for the definition of # degenerate states (i.e. E_m = E_n). Note that E_n are already ordered. tolerance = 1E-1
print basis.braket(1,1,lambda x : 1.0) print basis.braket(2,2,lambda x : 1.0) print basis.braket(3,3,lambda x : 1.0) print basis.braket(4,4,lambda x : 1.0) print basis.braket(5,5,lambda x : 1.0) print "##### Second test #####" qmech = q.qfr(basis, lambda x : 0.5*x*x + 0.1*x*x*x*x, lamb) print "E0=",qmech.E0 print "PSI0=",qmech.PSI0 print "PSI1=",qmech.U[:,1] print "#### Third test ####" #qmech.settime(0.5) beta=0.1 qmech.settemperature(beta) fo = open("fdc.dat","w+")