I’m trying to use MethodOfLines to solve the time-independent Schrodinger equation for hydrogen, as a prelude to more complicated systems. The equation is as follows:
This problem has analytically known solutions and eigenvalues. Following the tutorials for the steady-state heat equation and 1D Schrodinger equation in MethodOfLines.jl, I’ve written the following:
using ModelingToolkit, MethodOfLines, OrdinaryDiffEq, DomainSets, NonlinearSolve
# Define parameters (indep. vars)
@parameters x, y, z, E
# Define variables (known and unknown functions of params)
@variables psi(..)
# Define operators
Dxx = Differential(x)^2
Dyy = Differential(y)^2
Dzz = Differential(z)^2
V(x, y, z) = -1/sqrt(x^2 + y^2 + z^2)
# Define PDE
eq = [E*psi(x, y, z) ~ Dxx(psi(x, y, z)) + Dyy(psi(x, y, z)) + Dzz(psi(x, y, z)) + V(x, y, z)*psi(x, y, z)]
# set domain ranges and construct domain
xmin, ymin, zmin = 0, 0, 0
xmax, ymax, zmax = 10, 10, 10
domains = [x in Interval(xmin, xmax), y in Interval(ymin, ymax), z in Interval(zmin, zmax)]
# set boundary conditions
bcs = [psi(0, 0, 0) ~ 0,
psi(xmax, ymax, zmax) ~ 0]
# construct system, discretize
@named sys = PDESystem(eq, bcs, domains, [x, y, z], [psi(x,y,z)])
disc = MOLFiniteDifference([x => 100, y => 100, z => 100])
prob = discretize(sys, disc)
# solve
sol = NonlinearSolve.solve(prob, NewtonRaphson())
println(sol[E])
(Note: the operators and variables are specified in Cartesian coordinates, since the documentation says its restricted to Cartesian grids. The same page says it can handle spherical Laplacians but then says nothing else and provides no examples, so go figure.) As written, this currently errors on the boundary condition psi(0, 0, 0) ~ 0, with the following message:
ERROR: AssertionError: Boundary condition psi(0, 0, 0) ~ 0 is not on a boundary of the domain, or is not a valid boundary condition
Stacktrace:
[1] parse_bcs(bcs::Vector{…}, v::PDEBase.VariableMap, orders::Dict{…})
@ PDEBase C:\Users\njsjr\.julia\packages\PDEBase\mILTI\src\parse_boundaries.jl:370
[2] symbolic_discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{…}; checks::Bool)
@ PDEBase C:\Users\njsjr\.julia\packages\PDEBase\mILTI\src\symbolic_discretize.jl:27
[3] symbolic_discretize
@ C:\Users\njsjr\.julia\packages\PDEBase\mILTI\src\symbolic_discretize.jl:9 [inlined]
[4] discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{…}; analytic::Nothing, checks::Bool, kwargs::@Kwargs{})
@ PDEBase C:\Users\njsjr\.julia\packages\PDEBase\mILTI\src\discretization_state.jl:74
[5] discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{…})
@ PDEBase C:\Users\njsjr\.julia\packages\PDEBase\mILTI\src\discretization_state.jl:69
[6] top-level scope
@ c:\Users\njsjr\Documents\attosecond-research\helium-tdse\_research\pde_test.jl:36
Some type information was truncated. Use `show(err)` to see complete types.
I’m very confused by this, because I set the boundaries of my domain to be 0 and 10, so I don’t see why there should be an issue here.