Eigra

Time evolution

So far, nothing has moved. To make a state evolve, you give the system an initial wavefunction, and evolve steps it forward in time using the split-step Fourier method.

A wavepacket hits a barrier

GaussianWavepacket is a localised particle: x0 says where it starts, k0 how fast it moves, and sigma how wide it is. evolve then needs a total time t_max, a time step dt, and the number of frames to keep.

This cell sends a packet at a barrier, and draws it at four moments:

import matplotlib.pyplot as plt

from eigora import GridND
from eigora.qm import QuantumSystem
from eigora.qm.potentials import RectangularBarrier
from eigora.qm.scattering import energy_averaged_transmission
from eigora.qm.states import GaussianWavepacket

height = 1.5
k0 = 1.5

barrier = RectangularBarrier(height=height, width=1.0)
packet = GaussianWavepacket(x0=-15.0, k0=k0, sigma=3.0)
grid = GridND.line(-50.0, 50.0, 1024)
system = QuantumSystem(grid=grid, potential=barrier)

t_max = 30.0 / k0
evolution = system.evolve(packet, t_max=t_max, dt=0.01, n_frames=4)
x = grid.values()

for frame, t in enumerate(evolution.times):
    plt.plot(x, evolution.probability_density(frame), label=f"t = {t:.1f}")
plt.plot(x, 0.05 * evolution.potential / height, color="gray", label="barrier")
plt.xlim(-30, 30)
plt.xlabel("x")
plt.ylabel("probability density")
plt.legend()
plt.show()

last = evolution.probability_density(evolution.n_frames - 1)
dx = grid.spacing[0]
print(f"transmitted (simulation): {last[x > 0].sum() * dx:.3f}")
print(f"transmitted (exact):      {energy_averaged_transmission(barrier, packet):.3f}")
1.5
1.5
Runs in your browser. The first run downloads up to 40 MB.

The packet splits in two, with one part reflected and one part transmitted. It does so even when most of its energy, k02/2k_0^2/2, is below the barrier height, which is tunnelling.

Checking the result

The last two lines of output compare the simulation with energy_averaged_transmission, the exact prediction for this barrier and this packet. They agree to about 0.01, with the simulation usually slightly higher.

That gap comes from the grid, not the time stepping. The grid points are about 0.10.1 apart, so a barrier with sharp edges can't have a width of exactly 11, and transmission depends strongly on that width. Refining the grid doesn't steadily help either, because the width it captures jumps around as the points shift. When comparing with an exact result, always ask what the discretisation can represent.

The theory is in the barrier module.

Your turn: a packet in a well

In a harmonic well, a packet with exactly the right width keeps its shape and follows the classical trajectory. This cell computes the average position ⟨x⟩\langle x \rangle from evolution.psi, which holds the wavefunction at every saved frame. Try changing omega or sigma:

import numpy as np
import matplotlib.pyplot as plt

from eigora import GridND
from eigora.qm import QuantumSystem
from eigora.qm.potentials import HarmonicWell
from eigora.qm.states import GaussianWavepacket

omega = 1.0
well = HarmonicWell(omega=omega)
# Try another sigma: at any other width, the packet also breathes.
packet = GaussianWavepacket(x0=-4.0, k0=0.0, sigma=well.coherent_width)

grid = GridND.line(-12.0, 12.0, 512)
system = QuantumSystem(grid=grid, potential=well)
evolution = system.evolve(packet, t_max=4 * np.pi, dt=0.01, n_frames=120)
x = grid.values()

densities = np.abs(evolution.psi) ** 2
dx = grid.spacing[0]
mean_x = (densities * x).sum(axis=1) * dx

plt.plot(evolution.times, mean_x, label="<x>(t), simulation")
plt.plot(evolution.times, -4.0 * np.cos(omega * evolution.times),
         linestyle="--", color="gray", label="classical trajectory")
plt.xlabel("t")
plt.ylabel("position")
plt.legend()
plt.show()
Runs in your browser. The first run downloads up to 40 MB.

Next, we leave the grid behind with spins and qubits.