정보통신기술(ICT)

양자역학: 터널링 효과(Quantum Tunneling Effect)

해머슴 2024. 11. 5. 10:29
import numpy as np
import matplotlib.pyplot as plt
from tkinter import Tk, Label, Entry, Button
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg

# 상수 정의
hbar = 1.0545718e-34  # Reduced Planck's constant (J·s)
m_e = 9.10938356e-31  # Electron mass (kg)

# 터널링 확률 계산 함수
def tunneling_probability(V0, E, a):
    if E >= V0:
        return 1  # 에너지가 잠재장벽보다 크면 100% 터널링
    alpha = np.sqrt(2 * m_e * (V0 - E)) / hbar
    T = np.exp(-2 * alpha * a)
    return T

# Tkinter GUI 설정
def calculate_and_plot():
    try:
        V0 = float(entry_V0.get())  # 잠재장벽의 높이 (J)
        E = float(entry_E.get())    # 입자의 에너지 (J)
        a = float(entry_a.get())    # 장벽의 두께 (m)
       
        T = tunneling_probability(V0, E, a)
       
        # 그래프 생성
        fig, ax = plt.subplots()
        energies = np.linspace(0, V0, 100)
        probabilities = [tunneling_probability(V0, E, a) for E in energies]
       
        ax.plot(energies, probabilities)
        ax.set_title("Quantum Tunneling Probability")
        ax.set_xlabel("Particle Energy (J)")
        ax.set_ylabel("Tunneling Probability")
        ax.grid(True)
       
        # GUI에 그래프 표시
        canvas = FigureCanvasTkAgg(fig, master=window)
        canvas.draw()
        canvas.get_tk_widget().pack()
       
    except ValueError:
        label_result.config(text="Invalid input. Please enter valid numbers.")

# Tkinter 창 설정
window = Tk()
window.title("Quantum Tunneling Effect")

Label(window, text="Potential Barrier Height (V0, J):").pack()
entry_V0 = Entry(window)
entry_V0.pack()

Label(window, text="Particle Energy (E, J):").pack()
entry_E = Entry(window)
entry_E.pack()

Label(window, text="Barrier Width (a, m):").pack()
entry_a = Entry(window)
entry_a.pack()

Button(window, text="Calculate and Plot", command=calculate_and_plot).pack()

label_result = Label(window, text="")
label_result.pack()

window.mainloop()

 

 

https://www.tistory.com/event/write-challenge-2024

 

작심삼주 오블완 챌린지

오늘 블로그 완료! 21일 동안 매일 블로그에 글 쓰고 글력을 키워보세요.

www.tistory.com