Exemple #1
0
'''

# Parameters
l = 1
j = 1.5
x_peak = 0.17
y_peak = -0.07
basis_state_count = 30
k_max = 30

problem = Helium5()
quantum_numbers = QuantumNumbers(l, j)

# Bases and contours
mom_contour = gauss_contour([0, k_max], basis_state_count)
berg_contour = triangle_contour(x_peak, y_peak, k_max, basis_state_count, 5)
mom = MomentumBasis(mom_contour)
berg = MomentumBasis(berg_contour)
bas = [mom, berg]

#  Solve, print and plot for each basis
r = sp.linspace(0, 30, 100)
for basis in bas:
    states = solve(problem, quantum_numbers, basis)
    ground_state = states[0]
    print basis.name
    print "Ground state energy", ground_state.energy, problem.energy_units
    plt.plot(r, absq(ground_state.wavefunction(r) * r), label=basis.name)
# plot(ground_state.wavefunction) #pseudo-code
plt.show()
Exemple #2
0
def plot_momentum_wavefunction(state):
    """
    Plots the momentum wavefunction (a vector) of a state.
    """
    points, _ = state.basis.contour
    return plt.plot(sp.real(points), absq(state.eigenvector))
# For plotting

r = sp.linspace(0, 10, 100)

# For each basis, we solve the problem, print the ground state energy
# and plot the probability distribution.

for basis in bases:
    states = solve(problem, quantum_numbers, basis)
    ground_state = states[0]
    
    print basis.name
    print "Ground state energy:", ground_state.energy, problem.energy_units
    
    plt.plot(r, absq(ground_state.wavefunction(r) * r) , label=basis.name )

# Analytical "correct" answer

print "Analytical"
print "Ground state energy:", -0.5, "Hartrees"

def analytical_ground_state_wavefunction(r):
    return 2 * sp.exp(-r)

plt.plot(r, absq(analytical_ground_state_wavefunction(r) * r), 
        label="Analytical Wavefunction")

# A pretty title and legend and we're done!

plt.title("Hydrogen atom ground state radial distribution \n"
Exemple #4
0
def plot_momentum_wavefunction(state):
    """
    Plots the momentum wavefunction (a vector) of a state.
    """
    points, _ = state.basis.contour
    return plt.plot(sp.real(points), absq(state.eigenvector))
Exemple #5
0
# For plotting

r = sp.linspace(0, 10, 100)

# For each basis, we solve the problem, print the ground state energy
# and plot the probability distribution.

for basis in bases:
    states = solve(problem, quantum_numbers, basis)
    ground_state = states[0]

    print basis.name
    print "Ground state energy:", ground_state.energy, problem.energy_units

    plt.plot(r, absq(ground_state.wavefunction(r) * r), label=basis.name)

# Analytical "correct" answer

print "Analytical"
print "Ground state energy:", -0.5, "Hartrees"


def analytical_ground_state_wavefunction(r):
    return 2 * sp.exp(-r)


plt.plot(r,
         absq(analytical_ground_state_wavefunction(r) * r),
         label="Analytical Wavefunction")
Exemple #6
0
r=sp.linspace(0,50,500)

'''
Solve med de olika baserna. resonance tycks alltid vara samma som ground_state_tri[0]. Vet inte vad det betyder.
Hursomhelst, jag tror att triangelkonturen skapar en berggren-bas
'''
states_tri=nhqm.solve.solve(problem, quantum_numbers, mom_tri)
states_str=nhqm.solve.solve(problem, quantum_numbers, mom_str)


resonance_tri = find_resonance_state(states_tri) 
resonance_str = find_resonance_state(states_str)
ground_state_str=states_str[0]
ground_state_tri=states_tri[0]





print resonance_tri.energy
print resonance_str.energy
print ground_state_tri.energy
print ground_state_str.energy

plt.plot(r, absq(resonance_tri.wavefunction(r) * r), label=("triangelresonans"))
plt.plot(r, absq(resonance_str.wavefunction(r) * r), label=("vanlig resonans"))

plt.show()
plt.legend()