!===========================================================
!file: schUOC.f
!
!Functions used in RKSTEP routine. Here:
!f1 = psip(x) = psi(x)'
!f2 = psip(x)'= psi(x)''
!
!One has to set:
!  1. V(x), the potential     
!  2. The boundary conditions for psi,psip at x=xmin and x=xmax
!
!===========================================================
!----- potential:
real(8) function V(x)
 implicit none
 real(8) :: x, lambda
 lambda = 2.0D0
 V = x*x+2.0D0*lambda*x*x*x*x
end function V
!----- boundary conditions:
subroutine boundary(xmin,xmax,psixmin,psipxmin,psixmax,psipxmax)
 implicit none
 real(8) :: xmin,xmax,psixmin,psipxmin,psixmax,psipxmax,V

 psixmin    =  exp(-0.5D0*DABS(xmin)*DABS(xmin))
 psipxmin   = -xmin*psixmin
 psixmax    =  exp(-0.5D0*DABS(xmax)*DABS(xmax))
 psipxmax   = -xmax*psixmax
end subroutine boundary
!===========================================================
!===========================================================
!----- trivial function: derivative of psi      
real(8) function f1(x,psi,psip) 
 real(8) :: x,psi,psip
 f1=psip
end function f1
!===========================================================
!----- the second derivative of wavefunction:
!psip(x)' = psi(x)'' = -(E-V) psi(x)
real(8) function f2(x,psi,psip)
 implicit none
 real(8) :: x,psi,psip,energy,V
 common /params/energy
!----- Schroedinger eq: RHS
 f2 = (V(x)-energy)*psi
end function f2
!===========================================================
