1. Poisson's Equation

Preliminaries

We're looking to solve Poisson's equation for electrostatics (given in dimensionless units, so that $\epsilon_{0} = 1$) on an $(N+1) \times (N+1)$ unit grid:

$$ \Delta \phi = -\rho $$

Here, $\rho$ is zero except at $\vec{x} = (0.5 + a/2, 0.25 + a/2)$, where it equals $2\delta(\vec{x})$. Since we're including points along the border, the distance between neighboring grid points is $h = 1/N$. We can express the discretized Laplacian, acting on the $N^2$-vector of potentials on the grid, as:

$$ \Delta_{i,j} \phi_{j} = \frac{-4\phi_{i} + \phi_{i+1} + \phi_{i-1} + \phi_{i+N} + \phi_{i-N}}{h^2} = N^2 \Big(-4\phi_{i} + \phi_{i+1} + \phi_{i-1} + \phi_{i+N} + \phi_{i-N}\Big) $$

so that the Laplacian matrix itself can be expressed in terms of Kronecker deltas as

$$ \Delta_{i,j} = N^2 \Big(-4\delta_{i,j} + \delta_{i+1,j} + \delta_{i-1,j} + \delta_{i+N,j} + \delta_{i-N,j}\Big) $$

which, it's worth noting, is a symmetric matrix.

We have inhomogenous boundary conditions ($\phi = 10$) for the rectangle centered at (0.625, 0.75) and homogenous boundary conditions along the perimeter of the grid. Since these values of $\phi$ are fixed, they cannot figure into the $\Delta\phi=-\rho$ problem, in the sense that $\rho$ cannot be fixed if $\phi$ is held fixed (the equivalent physical analogy is the surface of a conductor in electrostatics). So for any fixed $\phi_{i}$, we can set $\rho_{i} = 0 \implies \Delta_{i,j} = 0 \ \ \forall \ \ j$. In other words, for each $i$ such that $\phi_{i}$ is held constant, we set the $i^{th}$ row of $\Delta$ equal to zero. This assures us that $\phi$ only depends on $\rho$ through the boundary conditions.

Since the conjugate gradient method depends on the symmetry of a matrix, we'll have to deal with the nonzero terms in the $i^{th}$ column of $\Delta$ before zeroing the $i^{th}$ row, which are:

$$ \Delta_{j,i} = N^2 \Big(-4\delta_{i,j} + \delta_{i,j+1} + \delta_{i,j-1} + \delta_{i,j+N} + \delta_{i,j-N}\Big). $$

Implementation

My Laplacian.jl module implements, in order of increasing abstraction:

  • ($\delta$ or kronecker), a Kronecker delta matrix function that takes arbitrary anonymous functions $f_i$ and $f_j$ (of row and column number, respectively) as arguments, and generates a matrix of arbitrary size whose elements are $\delta_{f_i,f_j}$, allowing for convenient translation of the above formulas
  • (lap), a Laplacian matrix function that uses kronecker along with the above formula for $\Delta$ to produce a Laplacian operator matrix for a square grid, given a particular side length and number of subdivisions in each direction.
  • (findfree), a function that produces an array mapping its indices to the free indices of the full matrix and which takes as its arguments the size of the full matrix ($N^2$) and a list of indices whose values are fixed as boundary conditions
  • (opsplit), a function for splitting $\Delta$ into free and boundary parts that takes an $N \times N$ Laplacian matrix (or, in general, a matrix) and an integer array giving the indices of boundary conditions, and returns the tuple ($\Delta_{free}$, $\Delta_{boundary}$) as output.
  • (rhoeff), a function for calculating $\rho_{eff}$ that takes $\rho$, $\Delta_{boundary}$, $\phi_{boundary}$, and an array of the boundary condition indices as input.

My ConjugateGradient module implements:

  • (conjgrad), a conjugate gradient solver for $Ax = b$ that takes $A$, $b$, and (optionally) a starting guess $x_{0}$ as input.

Representing the grid as a 2-d array makes it easier to visualize and easier to specify boundary conditions. I've used Julia's reshape function to convert the boundary conditions $\phi_{boundary}$ and the boundary locations $\beta$ to the appropriate 1-d array form.

Results

The algorithm worked well without the rectangle held at fixed potential:

$\phi$ without fixed potential

It also worked with the fixed potential:

$\phi$ with fixed potential

We can also look at the effect of the number of horizontal grid subdivisions on the values found for the potential at various points:

Clearly, $\phi$ exponentially approaches some continuum value at each point as $N \rightarrow \infty$.

2. Free particle Schrodinger equation

Most of the code from question 1 can still be used here. We are now trying to solve Schrodinger's equation,

$$ E \psi = H \psi, $$

where $H = -\frac{1}{2m}\Delta + V$ (using our choice of units such that $h=1$) and $V$ is infinite on the border and in the rectangle and is zero elsewhere. Since $m=1/10$, our equation becomes

$$ -5\Delta \psi = E \psi $$

within the region where $V = 0$; we can rephrase the infinite potential as a boundary condition on $\psi$, i.e. $\psi=0$ wherever $V \rightarrow \infty$. We can use our earlier code to find the matrix $\Delta_{eff}$ that reflects these boundary conditions. Then, we merely need to find the eigenvalues, which we can approximate using reverse iteration, i.e. through repeated application of the matrix

$$ A^{-1}_{\mu} \equiv (-5\Delta_{eff} - \mu I)^{-1} $$

so that, if there are any eigenvalues greater than 1 and close to $\mu$, their corresponding eigenvectors will grow after an application of $A^{-1}_{\mu}$. So, for any $\psi_{0}$ with $\|\psi_{0}\| = 1$, we should have

$$ \psi_{1}^*\psi_{1} = \|A^{-1}_{\mu} \psi_{0}\|^2 >> 1 $$

whenever $\mu$ is near an eigenvalue. Since $-\Delta_{eff}$ is singular, we can't just invert it. We can, however, use the conjugate gradient method to solve

$$ A_{\mu} \psi_{1} = \psi_{0} $$

for $\psi_{1}$. We can then plot $\psi_{1}^*\psi_{1}$ against $\mu$ and look for peaks, which should correspond to eigenvalues of $-5\Delta_{eff}$, i.e. the allowed energies.


In [33]:
include("plot2.jl")
plots = plot2(intrvl);

In [34]:
plots[1]


Out[34]:
Eigenvalue Estimate 1 11 21 31 41 51 61 71 81 91 101 111 121 131 141 151 161 171 181 191 201 211 221 231 241 251 261 271 281 291 301 311 321 331 341 351 361 371 381 391 401 411 421 431 441 451 461 471 481 491 501 511 521 531 541 551 561 571 581 591 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 204.0 204.2 204.4 204.6 204.8 205.0 205.2 205.4 205.6 205.8 206.0 206.2 206.4 206.6 206.8 207.0 207.2 207.4 207.6 207.8 208.0 208.2 208.4 208.6 208.8 209.0 209.2 209.4 209.6 209.8 210.0 210.2 210.4 210.6 210.8 211.0 211.2 211.4 211.6 211.8 212.0 212.2 212.4 212.6 212.8 213.0 213.2 213.4 213.6 213.8 214.0 214.2 214.4 214.6 214.8 215.0 215.2 215.4 215.6 215.8 216.0 216.2 216.4 216.6 216.8 217.0 217.2 217.4 217.6 217.8 218.0 218.2 218.4 218.6 218.8 219.0 200 205 210 215 220 204.0 204.5 205.0 205.5 206.0 206.5 207.0 207.5 208.0 208.5 209.0 209.5 210.0 210.5 211.0 211.5 212.0 212.5 213.0 213.5 214.0 214.5 215.0 215.5 216.0 216.5 217.0 217.5 218.0 218.5 219.0 Magnitude of ψ*ψ Magnitude of wavefunction squared vs. Estimated Eigenvalue

In [29]:
plots[2]


Out[29]:
Eigenvalue Estimate 153.0 153.1 153.2 153.3 153.4 153.5 153.6 153.7 153.8 153.9 154.0 -6.0×10⁵ -5.0×10⁵ -4.0×10⁵ -3.0×10⁵ -2.0×10⁵ -1.0×10⁵ 0 1.0×10⁵ 2.0×10⁵ 3.0×10⁵ 4.0×10⁵ 5.0×10⁵ 6.0×10⁵ 7.0×10⁵ 8.0×10⁵ 9.0×10⁵ 1.0×10⁶ 1.1×10⁶ -5.00×10⁵ -4.80×10⁵ -4.60×10⁵ -4.40×10⁵ -4.20×10⁵ -4.00×10⁵ -3.80×10⁵ -3.60×10⁵ -3.40×10⁵ -3.20×10⁵ -3.00×10⁵ -2.80×10⁵ -2.60×10⁵ -2.40×10⁵ -2.20×10⁵ -2.00×10⁵ -1.80×10⁵ -1.60×10⁵ -1.40×10⁵ -1.20×10⁵ -1.00×10⁵ -8.00×10⁴ -6.00×10⁴ -4.00×10⁴ -2.00×10⁴ 0 2.00×10⁴ 4.00×10⁴ 6.00×10⁴ 8.00×10⁴ 1.00×10⁵ 1.20×10⁵ 1.40×10⁵ 1.60×10⁵ 1.80×10⁵ 2.00×10⁵ 2.20×10⁵ 2.40×10⁵ 2.60×10⁵ 2.80×10⁵ 3.00×10⁵ 3.20×10⁵ 3.40×10⁵ 3.60×10⁵ 3.80×10⁵ 4.00×10⁵ 4.20×10⁵ 4.40×10⁵ 4.60×10⁵ 4.80×10⁵ 5.00×10⁵ 5.20×10⁵ 5.40×10⁵ 5.60×10⁵ 5.80×10⁵ 6.00×10⁵ 6.20×10⁵ 6.40×10⁵ 6.60×10⁵ 6.80×10⁵ 7.00×10⁵ 7.20×10⁵ 7.40×10⁵ 7.60×10⁵ 7.80×10⁵ 8.00×10⁵ 8.20×10⁵ 8.40×10⁵ 8.60×10⁵ 8.80×10⁵ 9.00×10⁵ 9.20×10⁵ 9.40×10⁵ 9.60×10⁵ 9.80×10⁵ 1.00×10⁶ -5.0×10⁵ 0 5.0×10⁵ 1.0×10⁶ -5.00×10⁵ -4.50×10⁵ -4.00×10⁵ -3.50×10⁵ -3.00×10⁵ -2.50×10⁵ -2.00×10⁵ -1.50×10⁵ -1.00×10⁵ -5.00×10⁴ 0 5.00×10⁴ 1.00×10⁵ 1.50×10⁵ 2.00×10⁵ 2.50×10⁵ 3.00×10⁵ 3.50×10⁵ 4.00×10⁵ 4.50×10⁵ 5.00×10⁵ 5.50×10⁵ 6.00×10⁵ 6.50×10⁵ 7.00×10⁵ 7.50×10⁵ 8.00×10⁵ 8.50×10⁵ 9.00×10⁵ 9.50×10⁵ 1.00×10⁶ Magnitude of ψ*ψ Magnitude of wavefunction squared vs. Estimated Eigenvalue

In [30]:
plots[3]


Out[30]:
Eigenvalue Estimate 272.0 272.1 272.2 272.3 272.4 272.5 272.6 272.7 272.8 272.9 273.0 -3.0×10⁶ -2.5×10⁶ -2.0×10⁶ -1.5×10⁶ -1.0×10⁶ -5.0×10⁵ 0 5.0×10⁵ 1.0×10⁶ 1.5×10⁶ 2.0×10⁶ 2.5×10⁶ 3.0×10⁶ 3.5×10⁶ 4.0×10⁶ 4.5×10⁶ 5.0×10⁶ 5.5×10⁶ -2.5×10⁶ -2.4×10⁶ -2.3×10⁶ -2.2×10⁶ -2.1×10⁶ -2.0×10⁶ -1.9×10⁶ -1.8×10⁶ -1.7×10⁶ -1.6×10⁶ -1.5×10⁶ -1.4×10⁶ -1.3×10⁶ -1.2×10⁶ -1.1×10⁶ -1.0×10⁶ -9.0×10⁵ -8.0×10⁵ -7.0×10⁵ -6.0×10⁵ -5.0×10⁵ -4.0×10⁵ -3.0×10⁵ -2.0×10⁵ -1.0×10⁵ 0 1.0×10⁵ 2.0×10⁵ 3.0×10⁵ 4.0×10⁵ 5.0×10⁵ 6.0×10⁵ 7.0×10⁵ 8.0×10⁵ 9.0×10⁵ 1.0×10⁶ 1.1×10⁶ 1.2×10⁶ 1.3×10⁶ 1.4×10⁶ 1.5×10⁶ 1.6×10⁶ 1.7×10⁶ 1.8×10⁶ 1.9×10⁶ 2.0×10⁶ 2.1×10⁶ 2.2×10⁶ 2.3×10⁶ 2.4×10⁶ 2.5×10⁶ 2.6×10⁶ 2.7×10⁶ 2.8×10⁶ 2.9×10⁶ 3.0×10⁶ 3.1×10⁶ 3.2×10⁶ 3.3×10⁶ 3.4×10⁶ 3.5×10⁶ 3.6×10⁶ 3.7×10⁶ 3.8×10⁶ 3.9×10⁶ 4.0×10⁶ 4.1×10⁶ 4.2×10⁶ 4.3×10⁶ 4.4×10⁶ 4.5×10⁶ 4.6×10⁶ 4.7×10⁶ 4.8×10⁶ 4.9×10⁶ 5.0×10⁶ -25×10⁶ 0 25×10⁶ 5×10⁶ -2.6×10⁶ -2.4×10⁶ -2.2×10⁶ -2.0×10⁶ -1.8×10⁶ -1.6×10⁶ -1.4×10⁶ -1.2×10⁶ -1.0×10⁶ -8.0×10⁵ -6.0×10⁵ -4.0×10⁵ -2.0×10⁵ 0 2.0×10⁵ 4.0×10⁵ 6.0×10⁵ 8.0×10⁵ 1.0×10⁶ 1.2×10⁶ 1.4×10⁶ 1.6×10⁶ 1.8×10⁶ 2.0×10⁶ 2.2×10⁶ 2.4×10⁶ 2.6×10⁶ 2.8×10⁶ 3.0×10⁶ 3.2×10⁶ 3.4×10⁶ 3.6×10⁶ 3.8×10⁶ 4.0×10⁶ 4.2×10⁶ 4.4×10⁶ 4.6×10⁶ 4.8×10⁶ 5.0×10⁶ Magnitude of ψ*ψ Magnitude of wavefunction squared vs. Estimated Eigenvalue

In [31]:
plots[4]


Out[31]:
Eigenvalue Estimate 368.0 368.1 368.2 368.3 368.4 368.5 368.6 368.7 368.8 368.9 369.0 -2.0×10⁴ -1.5×10⁴ -1.0×10⁴ -5.0×10³ 0 5.0×10³ 1.0×10⁴ 1.5×10⁴ 2.0×10⁴ 2.5×10⁴ 3.0×10⁴ 3.5×10⁴ -1.50×10⁴ -1.45×10⁴ -1.40×10⁴ -1.35×10⁴ -1.30×10⁴ -1.25×10⁴ -1.20×10⁴ -1.15×10⁴ -1.10×10⁴ -1.05×10⁴ -1.00×10⁴ -9.50×10³ -9.00×10³ -8.50×10³ -8.00×10³ -7.50×10³ -7.00×10³ -6.50×10³ -6.00×10³ -5.50×10³ -5.00×10³ -4.50×10³ -4.00×10³ -3.50×10³ -3.00×10³ -2.50×10³ -2.00×10³ -1.50×10³ -1.00×10³ -5.00×10² 0 5.00×10² 1.00×10³ 1.50×10³ 2.00×10³ 2.50×10³ 3.00×10³ 3.50×10³ 4.00×10³ 4.50×10³ 5.00×10³ 5.50×10³ 6.00×10³ 6.50×10³ 7.00×10³ 7.50×10³ 8.00×10³ 8.50×10³ 9.00×10³ 9.50×10³ 1.00×10⁴ 1.05×10⁴ 1.10×10⁴ 1.15×10⁴ 1.20×10⁴ 1.25×10⁴ 1.30×10⁴ 1.35×10⁴ 1.40×10⁴ 1.45×10⁴ 1.50×10⁴ 1.55×10⁴ 1.60×10⁴ 1.65×10⁴ 1.70×10⁴ 1.75×10⁴ 1.80×10⁴ 1.85×10⁴ 1.90×10⁴ 1.95×10⁴ 2.00×10⁴ 2.05×10⁴ 2.10×10⁴ 2.15×10⁴ 2.20×10⁴ 2.25×10⁴ 2.30×10⁴ 2.35×10⁴ 2.40×10⁴ 2.45×10⁴ 2.50×10⁴ 2.55×10⁴ 2.60×10⁴ 2.65×10⁴ 2.70×10⁴ 2.75×10⁴ 2.80×10⁴ 2.85×10⁴ 2.90×10⁴ 2.95×10⁴ 3.00×10⁴ -2×10⁴ 0 2×10⁴ 4×10⁴ -1.5×10⁴ -1.4×10⁴ -1.3×10⁴ -1.2×10⁴ -1.1×10⁴ -1.0×10⁴ -9.0×10³ -8.0×10³ -7.0×10³ -6.0×10³ -5.0×10³ -4.0×10³ -3.0×10³ -2.0×10³ -1.0×10³ 0 1.0×10³ 2.0×10³ 3.0×10³ 4.0×10³ 5.0×10³ 6.0×10³ 7.0×10³ 8.0×10³ 9.0×10³ 1.0×10⁴ 1.1×10⁴ 1.2×10⁴ 1.3×10⁴ 1.4×10⁴ 1.5×10⁴ 1.6×10⁴ 1.7×10⁴ 1.8×10⁴ 1.9×10⁴ 2.0×10⁴ 2.1×10⁴ 2.2×10⁴ 2.3×10⁴ 2.4×10⁴ 2.5×10⁴ 2.6×10⁴ 2.7×10⁴ 2.8×10⁴ 2.9×10⁴ 3.0×10⁴ Magnitude of ψ*ψ Magnitude of wavefunction squared vs. Estimated Eigenvalue

We can use the results from the first graph to narrow our search and get good estimates of the first three energy eigenvalues: $E_{1}=153.36$, $E_{2}=272.93$, and $E_{3}=368.46$. We then use the conjugate gradient method to solve $A_{\mu} \psi_{1} = \psi_{0}$ for $A_{E_{1}}$, $A_{E_{2}}$, and $A_{E_{3}}$, so that (after normalization), $\psi_{1}$ will be nearly parallel to the eigenvector of $-5\Delta_{eff}$ corresponding to eigenvalue $\mu$.

3. Charged particle Schrodinger equation

Introduce a Coulomb potential:

The Schrodinger equation is now

$$ E\psi = -\frac{1}{2m} \Delta \psi - \frac{q}{r} \psi $$

where $r$ is the distance from our point charge $q$, which is located at $(0.5 + a/2, 0.25 + a/2)$. Taking $m=1/10$, as before, we are thus looking to solve $H\psi = E\psi$ where $H = -5\Delta - \frac{q}{r}$. $V$ is just a diagonal matrix with entries equal to $1/r$ as measured from the point corresponding to a given row/column.

I made my Lanczos method run for 20 steps before picking the new "best guess" ground state vector, renormalizing it, and restarting, and was able to consistently (and quickly) get results that agreed with each other (as well as Julia's built in eigenvalue functions). For example, for $q=1$, I found $E_{gs} = 159.49$. For $q=10$, $E_{gs} = 209.35$. Plotting the eigenstates for a few values of q, we can see a subtle change in the probability distribution as $q$ increases:

It seems that the likelihood of the particle being found in the top half of the region is gradually increasing. Intuitively, this makes sense: a steeper Coulombic potential would lead to higher kinetic energy when in the bottom half of the region, near the fixed charge, which means the moving charge would spend comparatively little time in the lower half. This reasoning suggests that the trend of spending more time far from the fixed charge (i.e. in the top half) as $q$ increases is a more general one. To find the probability that the particle is in the bottom half, we can sum up the squares of the components of $\psi$ on the lower half of the region, i.e. for $1 < j < N/2 + 1$, and multiply by the area under each point, namely, $a^2 = 1/N^2$. We can define a function, $F$, that does this for any given values of N and q. Our problem, then, reduces to finding the solution to

$$ F(N,q) - 0.5 = 0 $$

which we can feed to an equation solver or solve by plotting. Doing so gives $q_{critical}=36.9445$. Comparing $q$ to $F(N,q)$, we see that $F$ is, indeed, decreasing against q:


In [4]:
include("plot3.jl")
plots3 = plot3(intrvls3);

In [5]:
plots3[1]


Out[5]:
Charge of Point Particle, q 0 10 20 30 40 50 -0.2 -0.1 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 -0.10 -0.08 -0.06 -0.04 -0.02 0.00 0.02 0.04 0.06 0.08 0.10 0.12 0.14 0.16 0.18 0.20 0.22 0.24 0.26 0.28 0.30 0.32 0.34 0.36 0.38 0.40 0.42 0.44 0.46 0.48 0.50 0.52 0.54 0.56 0.58 0.60 0.62 0.64 0.66 0.68 0.70 0.72 0.74 0.76 0.78 0.80 0.82 0.84 0.86 0.88 0.90 0.92 0.94 0.96 0.98 1.00 1.02 1.04 1.06 1.08 1.10 1.12 1.14 1.16 1.18 1.20 1.22 1.24 1.26 1.28 1.30 1.32 1.34 1.36 1.38 1.40 -0.5 0.0 0.5 1.0 1.5 -0.10 -0.05 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 1.05 1.10 1.15 1.20 1.25 1.30 1.35 1.40 ψ*ψ Probability of Finding Particle in Bottom Half of Region vs. Charge of Point Particle

In [7]:
plots3[2]


Out[7]:
Charge of Point Particle, q 36.50 36.55 36.60 36.65 36.70 36.75 36.80 36.85 36.90 36.95 37.00 0.493 0.494 0.495 0.496 0.497 0.498 0.499 0.500 0.501 0.502 0.503 0.504 0.505 0.506 0.507 0.508 0.509 0.510 0.4938 0.4940 0.4942 0.4944 0.4946 0.4948 0.4950 0.4952 0.4954 0.4956 0.4958 0.4960 0.4962 0.4964 0.4966 0.4968 0.4970 0.4972 0.4974 0.4976 0.4978 0.4980 0.4982 0.4984 0.4986 0.4988 0.4990 0.4992 0.4994 0.4996 0.4998 0.5000 0.5002 0.5004 0.5006 0.5008 0.5010 0.5012 0.5014 0.5016 0.5018 0.5020 0.5022 0.5024 0.5026 0.5028 0.5030 0.5032 0.5034 0.5036 0.5038 0.5040 0.5042 0.5044 0.5046 0.5048 0.5050 0.5052 0.5054 0.5056 0.5058 0.5060 0.5062 0.5064 0.5066 0.5068 0.5070 0.5072 0.5074 0.5076 0.5078 0.5080 0.5082 0.5084 0.5086 0.5088 0.5090 0.490 0.495 0.500 0.505 0.510 0.4935 0.4940 0.4945 0.4950 0.4955 0.4960 0.4965 0.4970 0.4975 0.4980 0.4985 0.4990 0.4995 0.5000 0.5005 0.5010 0.5015 0.5020 0.5025 0.5030 0.5035 0.5040 0.5045 0.5050 0.5055 0.5060 0.5065 0.5070 0.5075 0.5080 0.5085 0.5090 ψ*ψ Probability of Finding Particle in Bottom Half of Region vs. Charge of Point Particle

We can also see the shape of the wavefunction for $q_{critical}=36.9445$:

A cursory visual inspection supports our solution for q; the probability distribution does indeed seem to be equally split between the top and bottom halves of the region.