<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/8089" />

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2012-05-01T18:49:23+00:00</updated>

	<author><name><![CDATA[Real-Time Physics Simulation Forum]]></name></author>
	<id>https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/8089</id>

		<entry>
		<author><name><![CDATA[Sijo]]></name></author>
		<updated>2012-05-01T18:49:23+00:00</updated>

		<published>2012-05-01T18:49:23+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=27746#p27746</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=27746#p27746"/>
		<title type="html"><![CDATA[Peaceman ADI method for two-dimensional harmonic oscillator]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=27746#p27746"><![CDATA[
Dear friends,<br>                I have written a matlab code to solve the two-dimensional schrodinger equation in a 2D Harmonic potential.<br>But the program gives diverging result.<br>Can anybody help me to find out the bug in the program. I am attaching the Matlab program.<br>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>close all<br>clear all<br>m=200;<br>n=m;<br>T=50;<br>dt=0.2;<br>hbar=1;<br>me=1;<br>xstart=-2;<br>xend=2;<br>ystart=-2;<br>yend=2;<br>dx=(xend-xstart)/(m-1);<br>dy=(xend-xstart)/(m-1);<br>x=(xstart:dx:xend);<br>y=(ystart:dy:yend);<br>%%%%%%%Two-Dimensional_Potential%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>[xx,yy]=meshgrid(x,y);<br>Vxy=2*(xx.^2+yy.^2);<br>%figure,surf(Vxy)<br>%shading flat<br>%%%%%%%%%%%%%%%%%%initial wave packet%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>vecini=0.01*exp(-xx.*xx-yy.*yy);<br>vec=vecini;<br>%figure,surf(vecini)<br>%shading flat<br>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>Dx=sparse(n-1,n-1);<br>Dy=sparse(n-1,n-1);<br>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>rx=hbar*dt/(4*me*dx*dx);<br>ry=hbar*dt/(4*me*dy*dy);<br>cv=dt/(2*hbar);<br>%%%%%%%%%%%%%%%%%%%Tridiagonal Matrices%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>Dx=diag(rx*ones(1,n))+diag((i-2*rx)*ones(1,n-1),-1)+diag(rx*ones(1,n-1),1);<br>Dy=diag(ry*ones(1,n))+diag((i-2*ry)*ones(1,n-1),-1)+diag(ry*ones(1,n-1),1);<br>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>vec(1,:)=0; %Dritchlet boundary conditions<br>vec(n,:)=0;<br>vec(:,1)=0;<br>vec(:,n)=0;<br>for tt=1:T<br>%starting peaceman ADI method%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    <br>%%%%%%%%%%Y-direction derivative%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>for j = 2:length(x)-1<br>    g(1)=0;%Dritchlet boundary conditions<br>    g(n)=0;<br>for k = 2:length(y)-1<br>g(k)=(i+2*ry)*vec(j,k)-ry*vec(j,k+1)-ry*vec(j,k-1)+dt/2*Vxy(j,k)*vec(j,k);<br>end<br>vecn(:,j)=Dx\g';<br>end<br>vecn(:,1)=zeros(n,1);<br>vecn(:,n)=zeros(n,1);<br>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>%%%%%%%%%%X-direction derivative%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>for k = 2:length(y)-1<br>    g(1)=0;<br>    g(n)=0;<br>for j = 2:length(x)-1<br>g(j)=(i+2*rx)*vecn(k,j)-rx*vecn(k,j+1)-rx*vecn(k,j-1)+dt/2*Vxy(k,j)*vecn(k,j);<br>end<br>vecn2(:,k-1)=Dy\g';<br>end<br>vecn2(:,1)=zeros(n,1);<br>vecn2(:,n)=zeros(n,1);<br>vec=vecn2;<br>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>surf(x,y,abs(vec.*conj(vec)))<br>shading flat<br>F(tt)=getframe()<br>end<br>movie(F)<br>figure,surf(x,y,Vxy),shading flat,title('2D harmonic potential')<br>figure,surf(x,y,vecini),shading flat,title('initial gaussian wavepacket')<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=9286">Sijo</a> — Tue May 01, 2012 6:49 pm</p><hr />
]]></content>
	</entry>
	</feed>
