Friday, 2 August 2019

Scilab Code to solve Radial part of Hydrogen Atom wave function

// This is not final code...
// I am trying to get the best result, which should match the well known 
// result for radial wave function of H-atom problem:
// Please see any quantum mechanics books for the same.. 
//-------------------------------------------------------------------------------------- 
// Hydrogen atom problem:
// d/dr (r^2 du/dr) + ( 2 m r^2 )/hbar^2 ( E + (Ze^2)/(4 \pi \epsilon_0 r)) u 
// - l*(l+1)*u = 0
//
//=========================================
clf;
conA = -0.1240;
conB = 1.0;
function du=lorenz(r, u)
    du(1) = u(2)
    du(2) = - (2.0*u(1)/r)*u(2) - (conA + conB/r)*u(1)
endfunction
u0=[0.1;0.1]; // this is intial condition
r=0.1:0.1:20; // variable r is changing from 0.001 to 10.0
u=ode(u0,0.1,r,lorenz);
plot2d(r,u(1,:),2)
//scf()
//plot2d(t,u(2,:),2)
//
//============= Matplot-lib code from internet.. 
 // https://chem.libretexts.org/Bookshelves/
//Physical_and_Theoretical_Chemistry_Textbook_Maps/
//Supplemental_Modules_(Physical_and_Theoretical_Chemistry)/
//Quantum_Tutorials_(Rioux)/Numerical_Solutions_for_Schr%C3%B6dinger's_
//Equation/395%3A_Introduction_to_Numerical_Solutions_of_Sch%C3%
//B6dinger's_Equation

//%matplotlib inline
//
//from scipy.integrate import odeint
//import matplotlib.pyplot as plt  
//import numpy as np
//
//
//mu=1
//k=1
//E=.5
//xmax=-5
//
//def psi(y,x):
//    psi1, psi2_dx2 = y 
//    return [psi2_dx2, ((2*mu)/(-1))*(E*psi1 - (1/2)*x**2*psi1)]
//
//x0 = [0.0, 0.1]
//val = np.linspace(-5,5,101)
//sol = odeint(psi, x0, val)
//#plot, legends, and titles 
//plt.plot(val,sol[:,0],color = "red",label = " ")
//plt.title("Wave Function")
//leg = plt.legend(title = "(x)  ", loc = "center", bbox_to_anchor=[-.11,.5],
\\frameon=False)
//
//plt.show()

No comments:

Post a Comment

Note: only a member of this blog may post a comment.

Learning Windows - Microsoft Word - Python in 2024

 As I decided to include an alternating title suggests "Learning Windows - Microsoft Word - Python in 2024 (Trying to say goodbye to Ub...