Example #1
0
 def allocate_space(self,x_peak,y_peak,k_max,order,type):
     # step=k_max/order
     # points=numpy.array([i*step for i in range(order)])
     # weights=numpy.array([step for i in range(order)])
     [points,weights]=calc.triangle_contour(x_peak,y_peak,k_max,order) # Generate weights.
     self.k_max=k_max
     size=self.size=len(points)
     host_k=(numpy.array([points[i%size] for i in range(size**2)])).astype(type) # Generate k-matrix.
     host_k_prim=(numpy.array([points[(int)(i/size)] for i in range(size**2)])).astype(type) # Generate k_prim-matrix.
     host_step=(numpy.array([weights[(int)(i/size)] for i in range(size**2)])).astype(type) # Generate step-matrix.
     self.gpu_k=cl_array.to_device(self.ctx,self.queue,host_k) # Flush k to gpu
     self.gpu_k_prim=cl_array.to_device(self.ctx,self.queue,host_k_prim) # Flush k_prim to gpu.
     self.gpu_step=cl_array.to_device(self.ctx,self.queue,host_step) # Flush steps to gpu.
     self.gpu_result=cl_array.empty(self.queue,(size**2,1,),type) # Allocate space for results.
Example #2
0
from __future__ import division
from imports import *
import nhqm.bases.mom_space as mom
from nhqm.problems import He5
import nhqm.calculations.QM as calc

problem = He5.problem
problem.V0 = -70
k_max = 2.5
steps = 20
lowest_energy = sp.empty(steps)
orders = sp.arange(steps) + 1
l = 0
j = .5

for (i, order) in enumerate(orders):
    step = k_max / order
    H = calc.hamiltonian(mom.H_element, \
                args=(step, problem, l, j), order=order)
    energy, eigvecs = calc.energies(H)
    lowest_energy[i] = energy[0] # MeV
    print order
    
print lowest_energy[-1]
plt.plot(orders, lowest_energy)
plt.title(r"He5, $l = {0}$, $j = {1}$, $V_0 = {2}$MeV".format(l, j, problem.V0))
plt.xlabel(r"Matrix dimension N ($N \times N$)")
plt.ylabel(r"Lowest energy / MeV")
plt.show()
Example #3
0
          "and a ${3} \\times\\,{3}$ matrix"
          .format("", l, j, order))

for (i, problem) in enumerate(problems):
    print problem.name
    plt.subplot(1, 2, i+1)
    plt.title(problem.name)
    plt.ylabel(r'$r^2|\Psi|^2$')
    plt.xlabel(r'$r$')
    plt.show(block=False)
    
    
    for (i, basis) in enumerate(bases):
        if basis is osc:
            omega = osc.optimal_osc_freq(problem, l, j)
            H = calc.hamiltonian(osc.H_element, args=(problem, omega, l, j), order=order)
            basis_function = basis.gen_basis_function(problem, omega, l=l, j=j)
        else:
            H = calc.hamiltonian(basis.H_element, args=(step_size, problem, l, j), order=order)
            basis_function = basis.gen_basis_function(step_size, problem, l=l, j=j)
        energy, eigvecs = calc.energies(H)
        lowest_energy = energy[0] * problem.eV_factor
        print basis.name, "lowest energy:", lowest_energy, "eV"
        wavefunction = calc.gen_wavefunction(eigvecs[:, 0], basis_function)
        wavefunction = calc.normalize(wavefunction, 0, 10, weight=lambda r: r**2)
        
        plt.plot(r, r**2 * absq(wavefunction(r)), label = basis.name)
        plt.legend()
        plt.draw()

plt.show() # pause when done
Example #4
0
from __future__ import division
from imports import *
import nhqm.bases.mom_space as mom
from nhqm.problems import He5
import nhqm.calculations.QM as calc

problem = He5.problem
steps = 50
lowest_energy = sp.empty(steps)
V0s = sp.linspace(-70, 0, steps)
l = 0
j = .5
k_max = 4
order = 20
step_size = k_max / order

plt.title(r"He5, $l = {0}$, $j = {1}$".format(l, j))
plt.xlabel(r"Potential well depth V0 / MeV")
plt.ylabel(r"Ground state energy E / MeV")

for (i, V0) in enumerate(V0s):
    problem.V0 = V0
    H = calc.hamiltonian(mom.H_element, args=(problem, step_size, l, j), order=order)
    energy, eigvecs = calc.energies(H)
    lowest_energy[i] = energy[0]
    print V0
    
plt.plot(V0s, lowest_energy)
plt.show()
Example #5
0
from __future__ import division
from imports import *
from nhqm.bases import mom_space as mom
from nhqm.problems import He5
from nhqm.calculations import QM as calc

problem = He5.problem   
order = 30
l = 1
j = 1.5
problem.V0 = -70.

contour = sp.linspace(0, 2.5, order + 1)
args = (problem, l, j)
H = calc.contour_hamiltonian(mom.H_element_contour, contour, args)
eigvals, eigvecs = calc.energies(H)
print "Berggren on the real line, lowest energy:", eigvals[0]
Example #6
0
from imports import *
from plotting import *
from nhqm.bases import mom_space as mom
from nhqm.problems import He5
from nhqm.calculations import QM as calc

problem = He5.problem   
order = 100
l = 1
j = 1.5
problem.V0 = -47.
peak_x = 0.17
peak_y = 0.05
k_max = 2.5

contour = mom.gen_simple_contour(peak_x, peak_y, k_max, order)

args = (problem, l, j)
H = calc.contour_hamiltonian(mom.H_element_contour, contour, args)
eigvals, eigvecs = calc.energies(H)
print "Berggren lowest energy:", eigvals[0]
basis_function = mom.gen_basis_function(args)
wavefunction = calc.gen_wavefunction(eigvecs[:,0], basis_function, contour)
r = sp.linspace(0, 10)
plt.figure(0)
plt.plot(r, r**2 * calc.absq(wavefunction(r)))
plt.figure(1)
plot_poles(eigvals, problem.mass)
plt.figure(2)
plot_wavefunctions(contour, eigvecs)
plt.show()
Example #7
0
def plot_wavefunctions(contour, eigvecs):
    plt.plot(sp.real(contour), calc.absq(eigvecs))
Example #8
0
from __future__ import division
from imports import *
import nhqm.bases.mom_space as mom
from nhqm.problems import He5
import nhqm.calculations.QM as calc


problem = He5.problem
problem.V0 = -52.3
k_max = 4
order = 20
step_size = k_max / order
l = 1
j = 1.5

H = calc.hamiltonian(mom.H_element, args=(step_size, problem, l, j), order=order)
energy, eigvecs = calc.energies(H)
basis_function = mom.gen_basis_function(step_size, problem, l=l, j=j)
wavefunction = calc.gen_wavefunction(eigvecs[:,0], basis_function)
wavefunction = calc.normalize(wavefunction, 0, 10, weight= lambda r: r**2)

r = sp.linspace(1e-1, 10, 200)

plt.title("Potential, ground energy (and wavefunction, not to scale) \n\
$l = {0}$, $j = {1}$ and $V_0 = {2}$ MeV".format(l, j, problem.V0))
plt.plot(r, l*(l + 1)/ r**2 + problem.potential(r, l, j))
plt.plot(r, .1*r**2 * calc.absq(wavefunction(r)) + energy[0])
plt.plot(r, sp.zeros(len(r)) + energy[0])
plt.axis([0, 10, -0.01, 0.04])
plt.ylabel(r'$r^2|\Psi(r)|^2$')
plt.xlabel(r'$r$ / fm')