Python und Physik: Harmonischer Oszillator graphisch bis n= 4?

1 Antwort

Ich mag mir Deinen Code nicht ansehen und habe das einfach schnell mit Gnuplot gemacht:

Bild zum Beitrag

Bild zum Beitrag

Verschönerungen können immer noch gemacht werden.

piq=1/(sqrt(sqrt(pi)))
cutoff(x) = abs(x)<0.01 ? NaN : x
psi0(x)=cutoff(piq*exp(-0.5*x**2))
psi1(x)=cutoff(sqrt(2)*piq*x * exp(-0.5*x**2))
psi2(x)=cutoff(1/sqrt(2)*piq * (2*x**2-1) * exp(-0.5*x**2))
psi3(x)=cutoff(1/sqrt(3)*piq * (2*x**3-3*x) * exp(-0.5*x**2))
psi4(x)=cutoff(0.5/sqrt(6)*piq * (4*x**4-12*x**2+3) * exp(-0.5*x**2))
psi5(x)=cutoff(0.5/sqrt(15)*piq * (4*x**5-20*x**3+15*x) * exp(-0.5*x**2))

cutoff2(x) = x**2<0.01 ? NaN : 2*x**2
psi_0(x)=cutoff2(piq*exp(-0.5*x**2))
psi_1(x)=cutoff2(sqrt(2)*piq*x * exp(-0.5*x**2))
psi_2(x)=cutoff2(1/sqrt(2)*piq * (2*x**2-1) * exp(-0.5*x**2))
psi_3(x)=cutoff2(1/sqrt(3)*piq * (2*x**3-3*x) * exp(-0.5*x**2))
psi_4(x)=cutoff2(0.5/sqrt(6)*piq * (4*x**4-12*x**2+3) * exp(-0.5*x**2))
psi_5(x)=cutoff2(0.5/sqrt(15)*piq * (4*x**5-20*x**3+15*x) * exp(-0.5*x**2))

e0=1.0
niveau(x,e)=abs(x)<sqrt(2*e) ? e : NaN
bound=3.5

plot [-bound:bound] [0:bound**2/2] x**2/2 lw 3 title "", \
            e0/2*psi0(x)+0.5*e0 ls 2 title "", \
            e0/2*psi1(x)+1.5*e0 ls 3 title "", \
            e0/2*psi2(x)+2.5*e0 ls 4 title "", \
            e0/2*psi3(x)+3.5*e0 ls 5 title "", \
            e0/2*psi4(x)+4.5*e0 ls 6 title "", \
            e0/2*psi5(x)+5.5*e0 ls 7 title "", \
            niveau (x,0.5*e0) ls 2 lw 2 title "", \
            niveau (x,1.5*e0) ls 3 lw 2 title "", \
            niveau (x,2.5*e0) ls 4 lw 2 title "", \
            niveau (x,3.5*e0) ls 5 lw 2 title "", \
            niveau (x,4.5*e0) ls 6 lw 2 title "", \
            niveau (x,5.5*e0) ls 7 lw 2 title ""

pause -1

plot [-bound:bound]  [0:bound**2/2] x**2/2 lw 3 title "", \
            e0/2*psi_0(x)+0.5*e0 ls 2 title "", \
            e0/2*psi_1(x)+1.5*e0 ls 3 title "", \
            e0/2*psi_2(x)+2.5*e0 ls 4 title "", \
            e0/2*psi_3(x)+3.5*e0 ls 5 title "", \
            e0/2*psi_4(x)+4.5*e0 ls 6 title "", \
            e0/2*psi_5(x)+5.5*e0 ls 7 title "", \
            niveau (x,0.5*e0) ls 2 lw 2 title "", \
            niveau (x,1.5*e0) ls 3 lw 2 title "", \
            niveau (x,2.5*e0) ls 4 lw 2 title "", \
            niveau (x,3.5*e0) ls 5 lw 2 title "", \
            niveau (x,4.5*e0) ls 6 lw 2 title "", \
            niveau (x,5.5*e0) ls 7 lw 2 title ""

pause -1

  

  

P.S.: Die erste Version hatte den Faktor ½ im Potential verschustert. Beachte, daß das immer noch nur für eine einzige Wahl des Potentialparameters k und der reduzierten Masse m gilt, nämlich k=m=1 in atomaren Einheiten. Wenn Dir das nicht gefällt, dann mußt Du k und m in die Koordinaten einbauen und beachten, daß e0=sqrt(k/m).

 - (Physik, programmieren, Python)  - (Physik, programmieren, Python)

UnknownUser1192 
Beitragsersteller
 16.11.2024, 11:09

Omg, du bist ein Engel! Danke danke..

Ich habe es mir tatsächlich schon gedacht, das auch etwas falsch ist an den Komponenten aber ich konnte nicht erklären warum lul