From 0a3659cb82e2a6df6667e481e5dd23efde49992b Mon Sep 17 00:00:00 2001 From: leios Date: Wed, 11 Jul 2018 06:59:20 +0900 Subject: [PATCH 1/9] modifying julia split_op code with imaginary time evolution. --- .../quantum/split-op/code/julia/split_op.jl | 102 ++++++++++++++---- 1 file changed, 82 insertions(+), 20 deletions(-) diff --git a/chapters/physics_solvers/quantum/split-op/code/julia/split_op.jl b/chapters/physics_solvers/quantum/split-op/code/julia/split_op.jl index b77bae5f6..f12f51eca 100644 --- a/chapters/physics_solvers/quantum/split-op/code/julia/split_op.jl +++ b/chapters/physics_solvers/quantum/split-op/code/julia/split_op.jl @@ -1,6 +1,3 @@ -using Plots -pyplot() - # struct to hold all parameters for simulation struct Param xmax::Float64 @@ -11,15 +8,19 @@ struct Param x::Vector{Float64} dk::Float64 k::Vector{Float64} + im_time::Bool Param() = new(10.0, 512, 0.05, 1000, 2 * 10.0/512, Vector{Float64}(-10.0 + 10.0/512 : 20.0/512 : 10.0), - pi / 10.0, - Vector{Float64}(vcat(0:512/2 - 1, -512/2 : -1) * pi/10.0)) - Param(xmax::Float64, res::Int64, dt::Float64, timesteps::Int64) = new( + pi / 10.0, + Vector{Float64}(vcat(0:512/2 - 1, -512/2 : -1) * pi/10.0), + false) + Param(xmax::Float64, res::Int64, dt::Float64, timesteps::Int64, + im_val::Bool) = new( xmax, res, dt, timesteps, 2*xmax/res, Vector{Float64}(-xmax+xmax/res:2*xmax/res:xmax), - pi/xmax, Vector{Float64}(vcat(0:res/2-1, -res/2:-1)*pi/xmax) + pi/xmax, Vector{Float64}(vcat(0:res/2-1, -res/2:-1)*pi/(xmax)), + im_val ) end @@ -29,16 +30,27 @@ mutable struct Operators PE::Vector{Complex{Float64}} KE::Vector{Complex{Float64}} wfc::Vector{Complex{Float64}} + + Operators(res) = new(Vector{Complex{Float64}}(res), + Vector{Complex{Float64}}(res), + Vector{Complex{Float64}}(res), + Vector{Complex{Float64}}(res)) end # Function to initialize the wfc and potential function init(par::Param, voffset::Float64, wfcoffset::Float64) - V = 0.5 * (par.x - voffset).^2 - wfc = 3 * exp.(-(par.x - wfcoffset).^2/2) - PE = exp.(-0.5*im*V*par.dt) - KE = exp.(-0.5*im*par.k.^2*par.dt) + opr = Operators(length(par.x)) + opr.V = 0.5 * (par.x - voffset).^2 + opr.wfc = exp.(-(par.x - wfcoffset).^2/2) + if (par.im_time) + opr.KE = exp.(-0.5*par.k.^2*par.dt) + opr.PE = exp.(-0.5*opr.V*par.dt) + else + opr.KE = exp.(-im*0.5*par.k.^2*par.dt) + opr.PE = exp.(-im*0.5*opr.V*par.dt) + end - opr = Operators(V, PE, KE, wfc) + return opr end # Function for the split-operator loop @@ -48,10 +60,10 @@ function split_op(par::Param, opr::Operators) # Half-step in real space opr.wfc = opr.wfc .* opr.PE - # fft to phase space + # fft to momentum space opr.wfc = fft(opr.wfc) - # Full step in phase space + # Full step in momentum space opr.wfc = opr.wfc .* opr.KE # ifft back @@ -60,20 +72,70 @@ function split_op(par::Param, opr::Operators) # final half-step in real space opr.wfc = opr.wfc .* opr.PE - # plotting density and potential + # density for plotting and potential density = abs2.(opr.wfc) - plot([density, real(opr.V)]) - savefig("density" * string(lpad(i, 5, 0)) * ".png") - println(i) + # renormalizing for imaginary time + if (par.im_time) + sum = 0 + for element in density + sum += element + end + sum *= par.dx + + for j = 1:length(opr.wfc) + opr.wfc[j] /= sqrt(sum) + end + end + + # Outputting data to file. Plotting can also be done in a similar way + # This is set to output exactly 100 files, no matter how many timesteps + if ((i-1) % div(par.timesteps, 100) == 0) + outfile = open("output" *string(lpad(i-1, 5, 0))* ".dat","w") + + # Outputting for gnuplot. Any plotter will do. + for j = 1:length(density) + write(outfile, "$j\t" * string(density[j]) * '\t' + * string(real(opr.V[j])) * '\n') + end + + close(outfile) + println("Outputting step: ", i) + end + end end +# We are calculating the energy to check +function calculate_energy(par, opr) + # Creating real, momentum, and conjugate wavefunctions + wfc_r = opr.wfc + wfc_k = fft(wfc_r) + wfc_c = conj(wfc_r) + + # Finding the momentum and real-space energy terms + energy_k = 0.5*wfc_c.*ifft((par.k.^2) .* wfc_k) + energy_r = wfc_c.*opr.V .* wfc_r + + # Integrating over all space + energy_final = 0 + for i = 1:length(energy_k) + energy_final += real(energy_k[i] + energy_r[i]) + end + + return energy_final*par.dx +end + # main function function main() - par = Param(10.0, 512, 0.05, 1000) - opr = init(par, 0.0, 1.0) + par = Param(5.0, 256, 0.05, 100, true) + + # Starting wavefunction slightly offset so we can see it change + opr = init(par, 0.0, -1.00) split_op(par, opr) + + energy = calculate_energy(par, opr) + println("Energy is: ", energy) end main() From 667d9fca1b5904ecb94e6cbea8e581c1b61ea8e6 Mon Sep 17 00:00:00 2001 From: leios Date: Sun, 15 Jul 2018 20:06:26 +0900 Subject: [PATCH 2/9] adding largescale updates to quantum sysmtes and split_op --- .../quantum_energy/code/julia/energy.jl | 19 +++ .../code/julia/split_op.jl | 2 - .../split-operator_method.md | 64 +++++--- .../quantum_systems/quantum_systems.md | 148 +++++++++++++++++- 4 files changed, 208 insertions(+), 25 deletions(-) create mode 100644 chapters/algorithms/quantum_energy/code/julia/energy.jl diff --git a/chapters/algorithms/quantum_energy/code/julia/energy.jl b/chapters/algorithms/quantum_energy/code/julia/energy.jl new file mode 100644 index 000000000..021585efe --- /dev/null +++ b/chapters/algorithms/quantum_energy/code/julia/energy.jl @@ -0,0 +1,19 @@ +# We are calculating the energy to check +function calculate_energy(par, opr) + # Creating real, momentum, and conjugate wavefunctions + wfc_r = opr.wfc + wfc_k = fft(wfc_r) + wfc_c = conj(wfc_r) + + # Finding the momentum and real-space energy terms + energy_k = 0.5*wfc_c.*ifft((par.k.^2) .* wfc_k) + energy_r = wfc_c.*opr.V .* wfc_r + + # Integrating over all space + energy_final = 0 + for i = 1:length(energy_k) + energy_final += real(energy_k[i] + energy_r[i]) + end + + return energy_final*par.dx +end diff --git a/chapters/algorithms/split-operator_method/code/julia/split_op.jl b/chapters/algorithms/split-operator_method/code/julia/split_op.jl index f12f51eca..886f51d14 100644 --- a/chapters/algorithms/split-operator_method/code/julia/split_op.jl +++ b/chapters/algorithms/split-operator_method/code/julia/split_op.jl @@ -1,4 +1,3 @@ -# struct to hold all parameters for simulation struct Param xmax::Float64 res::Int64 @@ -24,7 +23,6 @@ struct Param ) end -# struct to hold all operators mutable struct Operators V::Vector{Complex{Float64}} PE::Vector{Complex{Float64}} diff --git a/chapters/algorithms/split-operator_method/split-operator_method.md b/chapters/algorithms/split-operator_method/split-operator_method.md index 9685a6254..5a16f54d3 100644 --- a/chapters/algorithms/split-operator_method/split-operator_method.md +++ b/chapters/algorithms/split-operator_method/split-operator_method.md @@ -3,22 +3,17 @@ The Split-Operator Method (also called the Split-Step Method), was actually the It is one of the simplest and fastest methods for this purpose and is widely used throughout modern quantum research in the area -- in particular when dealing with the Non-linear Schrodinger Equation: $$ -i \hbar \frac{\partial \Psi(\mathbf{r},t)}{\partial t} = \left[-\frac{\hbar^2}{2m}\nabla^2 + g|\Psi(\mathbf{r},t)|^2 \right] \Psi(\mathbf{r},t), -$$ - -which follows from the notation provided in the [quantum systems](../../general/quantum_systems/quantum_systems.md) chapter: $$\Psi(\mathbf{r},t)$$ is a quantum wave-function with spatial ($$\mathbf{r}$$) and time ($$t$$) dependence and $$\nabla^2$$ is a laplacian; however, in this case, we also add an interaction tern $$g$$ next to a nonlinear $$|\Psi(\mathbf{r},t)|^2$$ term. -By adding in the $$V(\mathbf{r})$$ term, we get an equation used to study superfluid Bose--Einstein Condensate (BEC) systems: - -$$ -i \hbar \frac{\partial \Psi(\mathbf{r},t)}{\partial t} = \left[-\frac{\hbar^2}{2m}\nabla^2 + V(\mathbf{r}) + g|\Psi(\mathbf{r},t)|^2 \right] \Psi(\mathbf{r},t). +i \hbar \frac{\partial \Psi(\mathbf{r},t)}{\partial t} = \left[-\frac{\hbar^2}{2m}\nabla^2 + V(\mathbf{r}) + g|\Psi(\mathbf{r},t)|^2 \right] \Psi(\mathbf{r},t), $$ +which follows from the notation provided in the [quantum systems](../../general/quantum_systems/quantum_systems.md) chapter: $$\Psi(\mathbf{r},t)$$ is a quantum wave-function with spatial ($$\mathbf{r}$$) and time ($$t$$) dependence, $$\nabla^2$$ is a laplacian, and $$V(\mathbf{r})$$ is a potential of some sort (like $$\omega x^2$$ or something) +In this case, we also add an interaction term $$g$$ next to a nonlinear $$|\Psi(\mathbf{r},t)|^2$$ term. This is the system I studied for most of my PhD (granted, we played a few tricks with parallelization and such, so it was _slightly_ more complicated). At it's heart, the split-op method is nothing more than a pseudo-spectral differential equation solver... That is to say, it solves the Schrodinger equation with [FFT's](../cooley_tukey/cooley_tukey.md). In fact, there is a large class of spectral and pseudo-spectral methods used to solve a number of different physical systems, and we'll definitely be covering those in the future. As mentioned in the [quantum systems](../../general/quantum_systems/quantum_systems.md) section, we can represent a a quantum wavefunction in momentum space, which is parameterized with the wavevector $$k$$. -In the hamiltonian shown above, we can split our system into real-space components, $$\hat{H}_R = \left[V(\mathbf{r}) + g|\Psi(\mathbf{r},t)|^2 \right] \Psi(\mathbf{r},t)$$, and momentum space components, $$\hat{H}_M = \left[-\frac{\hbar^2}{2m}\nabla^2 \right]\Psi(\mathbf{r},t)$$. +In the Hamiltonian shown above, we can split our system into position space components, $$\hat{H}_R = \left[V(\mathbf{r}) + g|\Psi(\mathbf{r},t)|^2 \right] \Psi(\mathbf{r},t)$$, and momentum space components, $$\hat{H}_M = \left[-\frac{\hbar^2}{2m}\nabla^2 \right]\Psi(\mathbf{r},t)$$. If we assume a somewhat general solution to our quantum system: $$ @@ -32,17 +27,17 @@ $$ $$ This accrues a small amount of error ($$dt^2$$) related to the commutation of the real and momentum-space components of the Hamiltonian. That's not okay. -In order to change the $$dt^2$$ error to $$dt^3$$, we can split the system by performing a half-step in real space before doing a full-step in momentum space, through a process called _Strang Splitting_ like so: +In order to change the $$dt^2$$ error to $$dt^3$$, we can split the system by performing a half-step in position space before doing a full-step in momentum space, through a process called _Strang Splitting_ like so: $$ \Psi(\mathbf{r},t+dt) = \left[e^{-\frac{i\hat{H}_Rdt}{2\hbar}}e^{-\frac{i\hat{H}_Mdt}{\hbar}}e^{-\frac{i\hat{H}_Rdt}{2\hbar}} \right]\Psi(\mathbf{r},t) + \mathcal{O}(dt^3) $$ -We can then address each part of this solution in chunks, first in real space, then in momentum space, then in real space again by using [Fourier Transforms](../cooley_tukey/cooley_tukey.md). +We can then address each part of this solution in chunks, first in position space, then in momentum space, then in position space again by using [Fourier Transforms](../cooley_tukey/cooley_tukey.md). Which looks something like this: $$ -\Psi(\mathcal{r}, t+dt) = \left[\hat{U}_R(\frac{dt}{2})\mathcal{F}\left[\hat{U}_M(dt) \mathcal{F} \left[\hat{U}_R(\frac{dt}{2}) \Psi(\mathbf{r},t) \right] \right] \right] + \mathcal{O}(dt^3) +\Psi(\mathcal{r}, t+dt) = \left[\hat{U}_R(\frac{dt}{2})\mathcal{F}^{-1}\left[\hat{U}_M(dt) \mathcal{F} \left[\hat{U}_R(\frac{dt}{2}) \Psi(\mathbf{r},t) \right] \right] \right] + \mathcal{O}(dt^3) $$ where $$\hat{U}_R = e^{-\frac{i\hat{H}_Rdt}{\hbar}}$$, $$\hat{U}_M = e^{-\frac{i\hat{H}_Mdt}{\hbar}}$$, and $$\mathcal{F}$$ and $$\mathcal{F}^{-1}$$ indicate forward and inverse Fourier Transforms. @@ -50,41 +45,70 @@ where $$\hat{U}_R = e^{-\frac{i\hat{H}_Rdt}{\hbar}}$$, $$\hat{U}_M = e^{-\frac{i As a small concession here, using this method enforces periodic boundary conditions, where the wavefunction will simply slide from one side of your simulation box to the other, but that's fine for most cases. In fact, for many cases (such as large-scale turbulence models) it's ideal. +That said, there is more to the story. +As we mentioned in the [quantum systems](../../general/quantum_systems/quantum_systems.md) section, many simulations of quantum systems desire to find the ground state of our system. +The split-operator method can be used for that too! +If we run this simulation in _imaginary time_, by simply setting $$\tau = it$$ and stepping through $$\tau$$, we will no longer see an "real-world" example of how the atoms should behave, but will instead see an exponential decay of higher-energy states. +This means that we can find the ground state of our system by running the simulation in imaginary time, which is an incredibly useful feature! + +## The Algorithm + Luckily, the code in this case is pretty straightforward. -Frist, we need to set all the initial parameters, including the initial grids in real and momentum space: +As a note before starting, we will be using some incredibly theoretical units in this simulation where $$\hbar = c = 1$$. +Ironically, these units are called _natural_ units. +Many of you (*cough* experimentalists *cough*) will probably think that these units are completely unphysical, and they are; however, they allow us to output fractions and whole numbers. +For example, if we are trying to find the energy of the ground state of atoms in a simple harmonic oscillator, we know it should be $$\frac{1}{2}\hbar \omega$$, where $$\omega$$ is the coefficient in front of the $$x^2$$ term known as the _frequency_ of the trap. +If we were to calculate the energy in real units, our simulation would output $$5.272859 \times 10^{-35}$$; however, by using natural units, we get precisely $$\frac{1}{2}$$ and we know that those are in units of $$\hbar\omega$$. + +There is a huge debate over the utility of natural units, but there is no doubt that it makes the simulation easier to understand (albeit a little misleading in the end). + +Regardless, we first need to set all the initial parameters, including the initial grids in real and momentum space: {% method %} {% sample lang="jl" %} -[import:4-31, lang:"julia"](code/julia/split_op.jl) +[import:1-24, lang:"julia"](code/julia/split_op.jl) {% endmethod %} As a note, when we generate our grid in momentum space `k`, we need to split the grid into two lines, one that is going from `0` to `-kmax` and is then discontinuous and goes from `kmax` to `0`. This is simply because the FFT will naturally assume that the `0` in our grid is at the left side of the simulation, so we shift k-space to match this expectation. +For this, we will be using the notation from above: `opr.R` will be the real space operators and `opr.M` will be the momentum space operators. +There is another boolean value here called `im_time`, which is for imaginary time evolution. + Afterwards, we turn them into operators: {% method %} {% sample lang="jl" %} -[import:32-41, lang:"julia"](code/julia/split_op.jl) +[import:26-52, lang:"julia"](code/julia/split_op.jl) {% endmethod %} Here, we use a standard harmonic potential for the atoms to sit in and a gaussian distribution for an initial guess for the probability distribution. -As a note, if we run this simulation in _imaginary time_, by simply setting $$\tau = it$$ and stepping through $$\tau$$, we will no longer see an "real-world" example of how the atoms should behave, but will instead see an exponential decay of higher-energy states. -This means that we can find the ground state of our system by running the simulation in imaginary time, which is an incredibly useful feature! +If we give either the trap or the atoms a slight offset (so the gaussian distribution of atoms does not *quite* rest at the bottom of the $$x^2$$ potential, we can see the atoms moving back and forth in the potential as we move the simulation forward in time. +This means that we can easily see the dynamics of our quantum system! +If we run the simulation in imaginary time, we will see the gaussian distribution of atoms move towards the center of the potential, which is the location with the lowest energy. -And finally go step-by-step through the simulation: +The final step is to do the iteration, itself. {% method %} {% sample lang="jl" %} -[import:42-69, lang:"julia"](code/julia/split_op.jl) +[import:54-105, lang:"julia"](code/julia/split_op.jl) {% endmethod %} And that's it. + +There is something a bit odd about the simulation in imaginary time, though. +Basically, in imaginary time, we see an exponential decay of all the higher energy states, which means we are technically losing a large amount of our wavefunction density every timestep! +To solve this issue, we _renormalize_ by basically enforcing that $$\int_{-\infty}^{+\infty}\Psi^\ast\Psi dx = 1$$. +As you can see from the code, this involves summing the density, multiplying that sum by `dx`, and then dividing each element in the wavefunction by the `sqrt()` of that value. + The Split-Operator method is one of the most commonly used quantum simulation algorithms because of how straightforward it is to code and how quickly you can start really digging into the physics of the simulation results! ## Example Code +This example code is a simulation of a gaussian distribution of atoms slightly offset in a harmonic trap in imaginary time. +So long as the code is written appropriately, this means that the atoms should move towards the center of the trap and the energy should decay to $$\frac{1}{2}\hbar\omega$$, which will be simply $$\frac{1}{2}$$ in this simulation. +Checking to make sure your code can output the correct energy for a harmonic trap is a good test to make sure it is all working under-the-hood before simulating systems with more complicated Hamiltonians. + {% method %} {% sample lang="jl" %} -### Julia [import, lang:"julia"](code/julia/split_op.jl) {% endmethod %} diff --git a/chapters/general/quantum_systems/quantum_systems.md b/chapters/general/quantum_systems/quantum_systems.md index 508901c4c..b3f4a055a 100644 --- a/chapters/general/quantum_systems/quantum_systems.md +++ b/chapters/general/quantum_systems/quantum_systems.md @@ -38,7 +38,7 @@ where $$D$$ is some positive definite matrix and $$\phi(\mathbf{r},t)$$ is the d In fact, this is why one of the most common types of quantum simulation is via _diffusion monte carlo_. There really isn't that much of a difference between the two systems in terms of classical simulation. -As a note: quantum mechanics works fundamentally differently than classical mechanics in physics. +Quantum mechanics works fundamentally differently than classical mechanics in physics. The wavefunction is essentially a set of all possible states for an object to be in, where there is some probability for the particle to be found in each state. This means that it is not possible to say that a particle is at a particular location, and instead we often say that it could be at any location with probability, as shown in the _probability density_: @@ -57,7 +57,8 @@ $$ \int_{-\infty}^{+\infty}|\Psi(\mathbf{r},t)|^2 d\mathbf{r} = 1 $$ -As another note: Just like position space can be parameterized by a position vector $$\textbf{x}$$, wavefunctions can be parameterized by a _wave_vector $$\textbf{k}$$ in frequency space. +As another note: Just like position space can be parameterized by a position vector $$\textbf{x}$$, wavefunctions can also be parameterized by a _wave_ vector $$\textbf{k}$$ in frequency space. +Any wavevector $$\textbf{k}$$ has the same units as reciprocal space and is thus analogous to angular frequency $$\omega$$. Often times, the wavevector space is called _momentum_ space, which makes sense when considering the de Broglie formula: $$ @@ -65,7 +66,109 @@ p = \frac{h}{\lambda} $$ where $$h$$ is Planck's constant and $$\lambda$$ is the wavelength. -This means that we can ultimately move between real and momentum space by using [Fourier Transforms](../../algorithms/cooley_tukey/cooley_tukey.md), which is incredibly useful in a number of cases! +This means that we can ultimately move between position and momentum space by using [Fourier Transforms](../../algorithms/cooley_tukey/cooley_tukey.md), which is incredibly useful in a number of cases! + +Even though the relation between position and momentum space is an essential cornerstone of understanding modern Quantum Mechanics, it is difficult to understand at a fundamental level. +What we said above is not incorrect. +Position space and momentum space are related by a Fourier transform; however, the rather hand-wavey argument above might not have been convincing enough and it does not offer any intuitive description of _why_ the Fourier transform is related. +The easiest way to understand this might be to look at the _Heisenberg uncertainty principle_, which is a fundamental relation between position and momentum space. + +## Heisenberg Uncertainty Principle + +Simply put, the Heisenberg uncertainty principle states that we cannot definitely know both the position and momentum of a quantum particle. +In particular, it says: + +$$ +\sigma_x \sigma_p \geq \frac{\hbar}{2} +$$ + +where $$\hbar$$ is Planck's constant and $$\sigma = \sqrt{\frac{1}{N}\sum_{i=1}^{N}(x_i-\mu)}$$. +In this case, $$\sigma$$ is the standard deviation, $$\mu$$ is the statistical mean of your distribution, $$N$$ is the number of points sampled, and $$x_i$$ is the value for each point $$i$$. +Ultimately, this means that if we have a higher precision in position space, we will have a lower precision in momentum space. +The converse is also true: a higher precision in momentum space will lead to a lower precision in position space. + +This makes the most sense if we imagine having a gaussian-like probability density ($$|\Psi(x)|^2$$) in position space, which will provide a gaussian-like density when in momentum space. +Here, we see that if we have a broader distribution in one space, we must have a thinner distribution in the opposite space. + +ADD IMAGES +1. Gaussian in position to similar gaussian in momentum +2. Large gaussian in position to small in momentum +3. Small position, large momentum + +Because the density can be interpreted as "the probability of finding a quantum particle at any provided location in position ($$x_i$$) or momentum ($$k_i$$) space, the interpretation is clear: the more we understand about a particle's position, the less we understand about it's momentum. +This is a powerful statement and should be given some thought. +That said, the most interesting part of this description is not the physical interpretation, but the fact that this act of transforming between larger and smaller gaussians is precisely what Fourier transforms do! +This further strengthens our arguement from before. +Position and momentum space are related by the Fourier transform! + +This is the heart of several algorithms for simulating quantum systems, including the [Split-operator method](../../algorithms/split-operator_method/split-operator_method). + +At least for me, I found this description to be intuitive, but not complete. +There is still something missing from the picture that should be described in more depth, and to do that, we need to dive deeper into the heart of quantum mechanics and into _Hamiltonians_. + +## Hamiltonian + +Here is the Schrodinger equation again: + +$$ +i \hbar \frac{\partial \Psi(\mathbf{r},t)}{\partial t} = \left[-\frac{\hbar^2}{2m} \nabla^2 + V(\mathbf{r},t) \right] \Psi(\mathbf{r},t) +$$ + +We described it in the initial section of this chapter. +For the most part, when we are trying to solve this equation the left-hand side does not change. +It's always $$i \hbar \frac{\partial \Psi(\mathbf{r},t)}{\partial t}$$. +On the other hand, the right-hand side can change a lot depending on the situation. +That is to say that we can easily simplify the Schrodinger equation by using a notational trick called the _Hamiltonian_. + +To be clear, Hamiltonian mechanics is not a quantum-specific idea. +It's everywhere in statistical physics and is often taught in classical physics courses as an analogue to another notational form known as Lagrangian mechanics. +For simplicity, we will restrict our discussion here to interpreting Hamiltonians physically. +Here, we can basically say that the Hamiltonian is a measure of the energy of our quantum system. +More specifically, we can say that the Hamiltonian is a set of energy _operators_ that act on our wavefunction. + +In the case of the example provided here, we might use the following definitions: + +$$ +\begin{align} +\hat H &= T + V \\ +\hat T &= \frac{p^2}{2m} +\hat V &= \frac{1}{2}\omega x^2 +\end{align} +$$ + +where $$p = -i\hbar \nabla$$ is the _momentum operator_ and $$\omega$$ is the _trapping frequency_ indicating how confined our quantum system will be. +In this case, $$\hat T$$ is an operator that works on our wavefunction in momentum space, while $$\hat V$$ acts in position space. +Both of these are operators. +That is to say that they _operate_ on our quantum system by transforming it in some way. +Ultimately, this means that the operators are not meant to be interpreted on their own without acting on some other object, in this case, the wavefunction $$\Psi(x)$$. + +In the end, we can update our Schrodinger equation to be + +$$ +i \hbar \frac{\partial \Psi(\mathbf{r},t)}{\partial t} = \hat H Psi(\mathbf{r},t) +$$ + +Which is a lot cleaner and more general. +Now, the Schrodinger equation can solve any quantum system so long as it can be written in terms of Hamiltonian mechanics! + +When looking at the operators, it is clear that the $$\hat V$$ operator is in position space. +We can clearly see that it operates as a function of $$x$$. +That said, t is not immediately obvious why the $$\hat T$$ is in momentum space. +This is not an easy question to answer, but it is definitely important and will be covered in more depth when we discuss spectral methods. + +For now, we will blanketly say + +$$ +\frac{\partial f}{\partial x} = \mathcal{F}^{-1}\left( 2\pi i k \mathcal{F}\left( f \right)\right) +$$ + +In other words, we can derive a function by performing an FFT on the function, multiplying by some momentum-space grid, and then iFFT'ing back. +Because this operation inherently involves a tranform into momentum space before transformation, it is a momentum-space operator. + +This is the most intuitive reasoning I can find; however, I am sure there are more intuitive explanations of why the derivatives are always momentum-space operations. +If you have better descriptions, please let me know! + +## Bra Ket Notation Unfortunately, the interpretation of quantum simulation is rather tricky and is ultimately easier to understand with slightly different notation. This notation is called _braket_ notation, where a _ket_ looks like this: @@ -85,6 +188,43 @@ It is often represented as a row vector for $$B$$. Because of this, $$ \langle B Now, to this point, the braket notation does not have any particularly quantum-like features; however, it becomes useful when describing actual quantum phenomenon. For example, if we want to indicate the probability of a wavefunction $$\psi$$ collapsing onto state $$\phi$$, we might write: $$\langle \phi \rvert \psi \rangle$$, which is precisely the same as the probability density defined above. +Now that we have a basic understanding of the notation, we should go through several other important quantum mechanical ideas and properties. + +## Eigenstates +As mentioned, the wavefunction $$\Psi(x)$$ is complex and has both real and imaginary parts; however, there are certain states that are eclusively real. +These states are _eigenstates_ of the system, and are often described as the constituent states that make up all other possible wavefunctions. +In other words, + +$$ +\lvert \Psi(x)\rangle = \sum_i c_i \lvert \Psi_i \rangle +$$ + +Where $$c_i$$ is some constant describing _how much_ of a given eigenstate $$i$$ is in the full wavefunction. +As you might expect, all of the $$c_i$$'s should sum to 1. + + +## Energy Calculations + +When it comes to quantum systems, there is no quantity more important than energy. +Basically, every eigenstate of the system has a different energy associated with it, and you can find this energy with a simple calculation: + +$$ +E = \langle \Psi \lvert \hat H \lvert \Psi \rangle +$$ + +Which can be done rather trivially in code by finding the conjugate of the wavefunction and multiplying it with another wavefunction after operation in position and momentum space. +This ultimately looks like this: + +{% method %} +{% sample lang="jl" %} +[import, lang:"julia"](../../algorithms/quantum_energy/code/julia/energy.jl) +{% endmethod %} + +As you might imagine, this calculation will be used in many different simulations of quantum systems to check our results. +In the end, many quantum simulations are focused on the _ground_ state, which is the lowest energy state ($$\Psi_0$$); however, sometimes higher energy states are desired. + +## The Future + As we proceed to add new algorithms to simulate quantum systems, I will add more and more notation to this section; however, there are already huge textbooks out there related to understanding and studying quantum systems. We don't want to re-invent the wheel here. Instead, we want to focus on an area that is often not considered with too much detail -- the algorithms and methods researchers use to ascertain new knowedge about quantum mechanics, like the split-operator method, DMRG, quantum monte carlo, exact diagonalization, and many more. @@ -93,6 +233,8 @@ Quantum mechanics is one of those areas of physics that really does push the bou In fact, [quantum information theory](../quantum_information/quantum_information.md) is currently set to be the next innovation to radically change the landscape of modern computation as we know it! Of course, because of the large-scale effects that this will likely have on the industry, it deserved it's own section. +As always, if there is something that you feel is missing from this section, please feel free to contact me or create an issue on github and we'll get to it as soon as we can! + From 3f2cfd77e9e35088c49996aeaef74d1dba6a2000 Mon Sep 17 00:00:00 2001 From: leios Date: Mon, 16 Jul 2018 06:44:41 +0900 Subject: [PATCH 3/9] adding plotting intructions to julia file. --- .../split-operator_method/code/julia/split_op.jl | 14 +++++++++++--- .../split-operator_method/split-operator_method.md | 6 +++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/chapters/algorithms/split-operator_method/code/julia/split_op.jl b/chapters/algorithms/split-operator_method/code/julia/split_op.jl index 886f51d14..c9dbaf4ce 100644 --- a/chapters/algorithms/split-operator_method/code/julia/split_op.jl +++ b/chapters/algorithms/split-operator_method/code/julia/split_op.jl @@ -1,3 +1,11 @@ +#------------split_op.jl-------------------------------------------------------# +# +# Plotting: to plot individual timesteps, use gnuplot like so: +# p "output00000.dat" u 1:2 w l +# rep "output00000.dat" u 1:3 w l +# +#------------------------------------------------------------------------------# + struct Param xmax::Float64 res::Int64 @@ -93,14 +101,14 @@ function split_op(par::Param, opr::Operators) # Outputting for gnuplot. Any plotter will do. for j = 1:length(density) - write(outfile, "$j\t" * string(density[j]) * '\t' - * string(real(opr.V[j])) * '\n') + write(outfile, string(par.x[j]) * "\t" + * string(density[j]) * "\t" + * string(real(opr.V[j])) * "\n") end close(outfile) println("Outputting step: ", i) end - end end diff --git a/chapters/algorithms/split-operator_method/split-operator_method.md b/chapters/algorithms/split-operator_method/split-operator_method.md index 5a16f54d3..c5f886b0c 100644 --- a/chapters/algorithms/split-operator_method/split-operator_method.md +++ b/chapters/algorithms/split-operator_method/split-operator_method.md @@ -66,7 +66,7 @@ Regardless, we first need to set all the initial parameters, including the initi {% method %} {% sample lang="jl" %} -[import:1-24, lang:"julia"](code/julia/split_op.jl) +[import:9-32, lang:"julia"](code/julia/split_op.jl) {% endmethod %} As a note, when we generate our grid in momentum space `k`, we need to split the grid into two lines, one that is going from `0` to `-kmax` and is then discontinuous and goes from `kmax` to `0`. @@ -78,7 +78,7 @@ Afterwards, we turn them into operators: {% method %} {% sample lang="jl" %} -[import:26-52, lang:"julia"](code/julia/split_op.jl) +[import:34-60, lang:"julia"](code/julia/split_op.jl) {% endmethod %} Here, we use a standard harmonic potential for the atoms to sit in and a gaussian distribution for an initial guess for the probability distribution. @@ -90,7 +90,7 @@ The final step is to do the iteration, itself. {% method %} {% sample lang="jl" %} -[import:54-105, lang:"julia"](code/julia/split_op.jl) +[import:62-113, lang:"julia"](code/julia/split_op.jl) {% endmethod %} And that's it. From 66dc9916461f0bfbd6c5749a8f0f13c7699cf897 Mon Sep 17 00:00:00 2001 From: leios Date: Mon, 16 Jul 2018 17:51:13 +0900 Subject: [PATCH 4/9] revisions to the bulk text --- .../split-operator_method.md | 32 +++++++--- .../quantum_systems/quantum_systems.md | 63 +++++++++++-------- 2 files changed, 59 insertions(+), 36 deletions(-) diff --git a/chapters/algorithms/split-operator_method/split-operator_method.md b/chapters/algorithms/split-operator_method/split-operator_method.md index c5f886b0c..60c2a215c 100644 --- a/chapters/algorithms/split-operator_method/split-operator_method.md +++ b/chapters/algorithms/split-operator_method/split-operator_method.md @@ -1,6 +1,6 @@ # The Split-Operator Method The Split-Operator Method (also called the Split-Step Method), was actually the primary method I used to solve the Schrodinger equation during my PhD. -It is one of the simplest and fastest methods for this purpose and is widely used throughout modern quantum research in the area -- in particular when dealing with the Non-linear Schrodinger Equation: +It is one of the simplest and fastest methods for this purpose and is widely used throughout modern quantum research in the area -- in particular when dealing with the Non-linear Schrodinger Equation (NLSE): $$ i \hbar \frac{\partial \Psi(\mathbf{r},t)}{\partial t} = \left[-\frac{\hbar^2}{2m}\nabla^2 + V(\mathbf{r}) + g|\Psi(\mathbf{r},t)|^2 \right] \Psi(\mathbf{r},t), @@ -12,21 +12,27 @@ This is the system I studied for most of my PhD (granted, we played a few tricks At it's heart, the split-op method is nothing more than a pseudo-spectral differential equation solver... That is to say, it solves the Schrodinger equation with [FFT's](../cooley_tukey/cooley_tukey.md). In fact, there is a large class of spectral and pseudo-spectral methods used to solve a number of different physical systems, and we'll definitely be covering those in the future. -As mentioned in the [quantum systems](../../general/quantum_systems/quantum_systems.md) section, we can represent a a quantum wavefunction in momentum space, which is parameterized with the wavevector $$k$$. +As mentioned in the [quantum systems](../../general/quantum_systems/quantum_systems.md) section, we can represent a quantum wavefunction in momentum space, which is parameterized with the wavevector $$k$$. In the Hamiltonian shown above, we can split our system into position space components, $$\hat{H}_R = \left[V(\mathbf{r}) + g|\Psi(\mathbf{r},t)|^2 \right] \Psi(\mathbf{r},t)$$, and momentum space components, $$\hat{H}_M = \left[-\frac{\hbar^2}{2m}\nabla^2 \right]\Psi(\mathbf{r},t)$$. +I'll be honest, I didn't know what notation to use for $$\hat H_R$$. +After all, $$p$$ is used to describe momentum. +I settled on $$R$$ for _real space_, but that is somewhat notationally ambiguous. +Bad notation aside, let's continue. + If we assume a somewhat general solution to our quantum system: $$ \Psi(\mathbf{r},t + dt) = \left[e^{-\frac{i\hat{H}dt}{\hbar}}\right]\Psi(\mathbf{r},t) = \left[e^{-\frac{i(\hat{H}_R + \hat{H}_M)dt}{\hbar}}\right]\Psi(\mathbf{r},t) $$ -and assume we are simulating our system by a series of small tiemsteps ($$dt$$), we can perform similar splitting by using the Baker-Campbell-Housdorff formula: +and assume we are simulating our system by a series of small timesteps ($$dt$$), we can perform similar splitting by using the Baker-Campbell-Housdorff formula: $$ \Psi(\mathbf{r},t+dt) = \left[e^{-\frac{i\hat{H}_Rdt}{\hbar}}e^{-\frac{i\hat{H}_Mdt}{\hbar}}e^{-\frac{[i\hat{H}_R, i\hat{H}_M]dt^2}{2}}\right]\Psi(\mathbf{r},t) $$ -This accrues a small amount of error ($$dt^2$$) related to the commutation of the real and momentum-space components of the Hamiltonian. That's not okay. +This accrues a small amount of error ($$dt^2$$) related to the commutation of the real and momentum-space components of the Hamiltonian. +This is a relatively large error and that's not okay. In order to change the $$dt^2$$ error to $$dt^3$$, we can split the system by performing a half-step in position space before doing a full-step in momentum space, through a process called _Strang Splitting_ like so: $$ @@ -41,14 +47,21 @@ $$ $$ where $$\hat{U}_R = e^{-\frac{i\hat{H}_Rdt}{\hbar}}$$, $$\hat{U}_M = e^{-\frac{i\hat{H}_Mdt}{\hbar}}$$, and $$\mathcal{F}$$ and $$\mathcal{F}^{-1}$$ indicate forward and inverse Fourier Transforms. +Here's a flowchart of what we are looking for every timestep: + +ADD IMAGE -As a small concession here, using this method enforces periodic boundary conditions, where the wavefunction will simply slide from one side of your simulation box to the other, but that's fine for most cases. +For the most part, that's it. +Flip to momentum space. Multiply. +Flip to position space. Multiply again. +As a small concession, using this method enforces periodic boundary conditions, where the wavefunction will simply slide from one side of your simulation box to the other, but that's fine for most cases. In fact, for many cases (such as large-scale turbulence models) it's ideal. That said, there is more to the story. As we mentioned in the [quantum systems](../../general/quantum_systems/quantum_systems.md) section, many simulations of quantum systems desire to find the ground state of our system. The split-operator method can be used for that too! -If we run this simulation in _imaginary time_, by simply setting $$\tau = it$$ and stepping through $$\tau$$, we will no longer see an "real-world" example of how the atoms should behave, but will instead see an exponential decay of higher-energy states. +If we run this simulation in _imaginary time_, by simply setting $$\tau = it$$ and stepping through $$\tau$$ instead of $$t$$, we will no longer see an "real-world" example of how the atoms should behave, but will instead see an exponential decay of higher-energy states. +If we run the simulation for long enough with a small enough timestep, all higher energy states will vanish. This means that we can find the ground state of our system by running the simulation in imaginary time, which is an incredibly useful feature! ## The Algorithm @@ -58,7 +71,8 @@ As a note before starting, we will be using some incredibly theoretical units in Ironically, these units are called _natural_ units. Many of you (*cough* experimentalists *cough*) will probably think that these units are completely unphysical, and they are; however, they allow us to output fractions and whole numbers. For example, if we are trying to find the energy of the ground state of atoms in a simple harmonic oscillator, we know it should be $$\frac{1}{2}\hbar \omega$$, where $$\omega$$ is the coefficient in front of the $$x^2$$ term known as the _frequency_ of the trap. -If we were to calculate the energy in real units, our simulation would output $$5.272859 \times 10^{-35}$$; however, by using natural units, we get precisely $$\frac{1}{2}$$ and we know that those are in units of $$\hbar\omega$$. +If we were to calculate the energy in real units, our simulation would output $$5.272859 \times 10^{-35}$$, which is hard to interpret. +By instead using natural units, we get precisely $$\frac{1}{2}$$ and we know that those are in units of $$\hbar\omega$$. There is a huge debate over the utility of natural units, but there is no doubt that it makes the simulation easier to understand (albeit a little misleading in the end). @@ -71,7 +85,7 @@ Regardless, we first need to set all the initial parameters, including the initi As a note, when we generate our grid in momentum space `k`, we need to split the grid into two lines, one that is going from `0` to `-kmax` and is then discontinuous and goes from `kmax` to `0`. This is simply because the FFT will naturally assume that the `0` in our grid is at the left side of the simulation, so we shift k-space to match this expectation. -For this, we will be using the notation from above: `opr.R` will be the real space operators and `opr.M` will be the momentum space operators. +Also, for this code we will be using the notation from above: `opr.R` will be the real space operators and `opr.M` will be the momentum space operators. There is another boolean value here called `im_time`, which is for imaginary time evolution. Afterwards, we turn them into operators: @@ -97,7 +111,7 @@ And that's it. There is something a bit odd about the simulation in imaginary time, though. Basically, in imaginary time, we see an exponential decay of all the higher energy states, which means we are technically losing a large amount of our wavefunction density every timestep! -To solve this issue, we _renormalize_ by basically enforcing that $$\int_{-\infty}^{+\infty}\Psi^\ast\Psi dx = 1$$. +To solve this issue, we _renormalize_ by enforcing that $$\int_{-\infty}^{+\infty}\Psi^\ast\Psi dx = 1$$. As you can see from the code, this involves summing the density, multiplying that sum by `dx`, and then dividing each element in the wavefunction by the `sqrt()` of that value. The Split-Operator method is one of the most commonly used quantum simulation algorithms because of how straightforward it is to code and how quickly you can start really digging into the physics of the simulation results! diff --git a/chapters/general/quantum_systems/quantum_systems.md b/chapters/general/quantum_systems/quantum_systems.md index b3f4a055a..b99882039 100644 --- a/chapters/general/quantum_systems/quantum_systems.md +++ b/chapters/general/quantum_systems/quantum_systems.md @@ -2,7 +2,9 @@ As I am sure you have heard, the quantum world is weird. As you deal with progressively smaller and smaller systems, at some point, it becomes less accurate to describe objects as particles. -Instead, it is better to describe objects as probability waves. +Instead, it is better to describe objects as probability densities. +These densities are easiest to understand in terms of _wavefunctions_, which are complex functions characterizing a quantum system's behaviour. + Again, this is pretty common knowledge; however, there is a distinct lack of readable literature on how to simulate quantum systems, even though there are numerous methods for exactly that! This section will deal with the computation of quantum states with classical machines. Now, I know what you are thinking, "Wait. Why are we simulating quantum systems on classical computers? Why not simulate it with some sort of experiment or with quantum computers?" @@ -13,12 +15,13 @@ A _quantum computer_ is the quantum analog to a classical computer, replacing bi Quantum computers are usually thought of as a way to use quantum mechanics to eventually solve real-world problems with new quantum algorithms. Both Grover's and Shor's algorithms are good examples of cases where quantum computation could greatly change the landscape of modern computation as we know it! -_Quantum Simulators_ on the other hand are quantum systems used to better un -derstand quantum mechanics -Because supercomputers are not great at performing quantum computations, quantum simulators exist as a building block for quantum computation; however, their purpose is not explicity for quantum information theory. -Often times a _universal quantum simulator_ is often called a quantum computer. +_Quantum simulators_ on the other hand are quantum systems used to better understand quantum mechanics. +These will often come in the form of experimental quantum systems that express quantum behaviour and allow us to better understand other areas of quantum systems. +In other words, quantum simulators are general techniques to study quantum systems on quantum hardware; however, quantum computers are quantum hardware used for the explicit purpose of quantum computation with qubits. +Because supercomputers are not great at performing quantum computations, certain quantum simulators exist as a building block for quantum computation. +A _universal quantum simulator_ is often called a quantum computer for this reason. -The truth is that until we have real quantum simulators, simulating quantum systems on classical hardware is as good as we can do. +The truth is that quantum simulators are hard to make in laboratories, so simulating quantum systems on classical hardware is as good as we can do in most cases. This section is devoted to all the different methods currently used to solve complex quantum systems, so let's start with the Schrodinger Equation, which has many different fomulations. Here is the easiest one to explain: @@ -26,7 +29,7 @@ $$ i \hbar \frac{\partial \Psi(\mathbf{r},t)}{\partial t} = \left[-\frac{\hbar^2}{2m} \nabla^2 + V(\mathbf{r},t) \right] \Psi(\mathbf{r},t) $$ -Where $$\Psi(\mathbf{r},t)$$ is your quantum _wavefunction_, $$V(\mathbf{r},t)$$ is a _trapping potential_, $$\nabla^2$$ is a _laplacian_, $$\mathbf{r}$$ is some sort of spatial component, and $$t$$ is time. +Where $$\Psi(\mathbf{r},t)$$ is a quantum wavefunction, $$V(\mathbf{r},t)$$ is a _trapping potential_, $$\nabla^2$$ is a _laplacian_, $$\mathbf{r}$$ is some sort of spatial component, and $$t$$ is time. There is a lot to take in here; however, it's ultimately just some time derivative on the left-hand side and a spatial derivative (with some extra steps) on the right-hand side. In this way, it isn't too different from the diffusion (heat) equation: @@ -35,11 +38,14 @@ $$ $$ where $$D$$ is some positive definite matrix and $$\phi(\mathbf{r},t)$$ is the density (or temperature) of the system. -In fact, this is why one of the most common types of quantum simulation is via _diffusion monte carlo_. -There really isn't that much of a difference between the two systems in terms of classical simulation. +In fact, this is why one of the most common types of quantum simulation is sometimes called _diffusion monte carlo_. +There really isn't that much of a difference between the two systems in terms of how they are simulated on classical hardware... but we are gettign ahead of ourselves. +For now, let's talk about how quantum mechanics differs from classical mechanics and how we can use this to our advantage. + +## Probability Density Quantum mechanics works fundamentally differently than classical mechanics in physics. -The wavefunction is essentially a set of all possible states for an object to be in, where there is some probability for the particle to be found in each state. +The wavefunction can be thought of as a set of all possible states for an object to be in, where there is some probability for the particle to be found in each state. This means that it is not possible to say that a particle is at a particular location, and instead we often say that it could be at any location with probability, as shown in the _probability density_: $$ @@ -48,8 +54,8 @@ $$ Here, there are 2 things to note: -1. The absolute value squared of a complex parameter $$\Psi(\mathbf{r},t)$$ is a dot product (inner product) between a complext function and it's Hermitian conjugate -2. As you have probably heard, once a wavefunction is observed it collapses onto a single state +1. The absolute value squared of a complex parameter $$\Psi(\mathbf{r},t)$$ is a dot product (inner product) between a complex function and it's Hermitian conjugate. This means the value will always be real, while the wavefunction, itself, might not be. +2. As you have probably heard, once a wavefunction is observed it collapses onto a single state. This can be simply interpreted as absolute knowledge of the particle's location. A probability density doesn't make sense if we know where the particle is! Now, to be clear: the probabilities must all sum to 1, or (more formally): @@ -57,6 +63,9 @@ $$ \int_{-\infty}^{+\infty}|\Psi(\mathbf{r},t)|^2 d\mathbf{r} = 1 $$ +This simply means that the probability of finding our quantum particle *somewhere in real space* is 1. +In other words, our particle must exist somewhere in the known universe. + As another note: Just like position space can be parameterized by a position vector $$\textbf{x}$$, wavefunctions can also be parameterized by a _wave_ vector $$\textbf{k}$$ in frequency space. Any wavevector $$\textbf{k}$$ has the same units as reciprocal space and is thus analogous to angular frequency $$\omega$$. Often times, the wavevector space is called _momentum_ space, which makes sense when considering the de Broglie formula: @@ -68,9 +77,8 @@ $$ where $$h$$ is Planck's constant and $$\lambda$$ is the wavelength. This means that we can ultimately move between position and momentum space by using [Fourier Transforms](../../algorithms/cooley_tukey/cooley_tukey.md), which is incredibly useful in a number of cases! -Even though the relation between position and momentum space is an essential cornerstone of understanding modern Quantum Mechanics, it is difficult to understand at a fundamental level. -What we said above is not incorrect. -Position space and momentum space are related by a Fourier transform; however, the rather hand-wavey argument above might not have been convincing enough and it does not offer any intuitive description of _why_ the Fourier transform is related. +Even though the relation between position and momentum space is an essential cornerstone of understanding modern quantum mechanics, it is difficult to understand at a fundamental level. +Position space and momentum space are related by a Fourier transform; however, the rather hand-wavey argument above might not have been convincing enough and it does not offer any intuitive description of _why_ the Fourier transform comes into this discussion at all. The easiest way to understand this might be to look at the _Heisenberg uncertainty principle_, which is a fundamental relation between position and momentum space. ## Heisenberg Uncertainty Principle @@ -97,7 +105,8 @@ ADD IMAGES Because the density can be interpreted as "the probability of finding a quantum particle at any provided location in position ($$x_i$$) or momentum ($$k_i$$) space, the interpretation is clear: the more we understand about a particle's position, the less we understand about it's momentum. This is a powerful statement and should be given some thought. -That said, the most interesting part of this description is not the physical interpretation, but the fact that this act of transforming between larger and smaller gaussians is precisely what Fourier transforms do! + +To me, the most interesting part of this description is not the physical interpretation, but the fact that this act of transforming between larger and smaller gaussians is precisely what Fourier transforms do! This further strengthens our arguement from before. Position and momentum space are related by the Fourier transform! @@ -123,7 +132,7 @@ That is to say that we can easily simplify the Schrodinger equation by using a n To be clear, Hamiltonian mechanics is not a quantum-specific idea. It's everywhere in statistical physics and is often taught in classical physics courses as an analogue to another notational form known as Lagrangian mechanics. For simplicity, we will restrict our discussion here to interpreting Hamiltonians physically. -Here, we can basically say that the Hamiltonian is a measure of the energy of our quantum system. +We can basically say that the Hamiltonian is a measure of the energy of our quantum system. More specifically, we can say that the Hamiltonian is a set of energy _operators_ that act on our wavefunction. In the case of the example provided here, we might use the following definitions: @@ -131,7 +140,7 @@ In the case of the example provided here, we might use the following definitions $$ \begin{align} \hat H &= T + V \\ -\hat T &= \frac{p^2}{2m} +\hat T &= \frac{p^2}{2m} \\ \hat V &= \frac{1}{2}\omega x^2 \end{align} $$ @@ -153,7 +162,7 @@ Now, the Schrodinger equation can solve any quantum system so long as it can be When looking at the operators, it is clear that the $$\hat V$$ operator is in position space. We can clearly see that it operates as a function of $$x$$. -That said, t is not immediately obvious why the $$\hat T$$ is in momentum space. +That said, it is not immediately obvious why the $$\hat T$$ is in momentum space. This is not an easy question to answer, but it is definitely important and will be covered in more depth when we discuss spectral methods. For now, we will blanketly say @@ -162,29 +171,30 @@ $$ \frac{\partial f}{\partial x} = \mathcal{F}^{-1}\left( 2\pi i k \mathcal{F}\left( f \right)\right) $$ -In other words, we can derive a function by performing an FFT on the function, multiplying by some momentum-space grid, and then iFFT'ing back. +In other words, we can derive a function by performing a Fourier transform on the function, multiplying by some momentum-space grid, and then inverse-transforming it back. Because this operation inherently involves a tranform into momentum space before transformation, it is a momentum-space operator. This is the most intuitive reasoning I can find; however, I am sure there are more intuitive explanations of why the derivatives are always momentum-space operations. -If you have better descriptions, please let me know! +This section will be updated further when we discuss spectral methods, but if you have better descriptions, please let me know! ## Bra Ket Notation -Unfortunately, the interpretation of quantum simulation is rather tricky and is ultimately easier to understand with slightly different notation. +Unfortunately, the interpretation of quantum simulation is rather tricky and is sometimes easier to understand with slightly different notation. This notation is called _braket_ notation, where a _ket_ looks like this: $$ \lvert A \rangle $$ -And basically describes $$A$$ as a column vector. +and basically describes $$A$$ as a column vector. The _bra_ represents the Hermitian conjucate of the ket and looks like this: $$ \langle B \rvert $$ -It is often represented as a row vector for $$B$$. Because of this, $$ \langle B \rvert A \rangle $$ represents the inner product of the two vectors and $$ \lvert A \rangle \langle B \rvert $$ represents the outer product. +The ket is often represented as a row vector for $$B$$. +Because of this, $$ \langle B \rvert A \rangle $$ represents the inner product of the two vectors and $$ \lvert A \rangle \langle B \rvert $$ represents the outer product. Now, to this point, the braket notation does not have any particularly quantum-like features; however, it becomes useful when describing actual quantum phenomenon. For example, if we want to indicate the probability of a wavefunction $$\psi$$ collapsing onto state $$\phi$$, we might write: $$\langle \phi \rvert \psi \rangle$$, which is precisely the same as the probability density defined above. @@ -202,7 +212,6 @@ $$ Where $$c_i$$ is some constant describing _how much_ of a given eigenstate $$i$$ is in the full wavefunction. As you might expect, all of the $$c_i$$'s should sum to 1. - ## Energy Calculations When it comes to quantum systems, there is no quantity more important than energy. @@ -220,7 +229,7 @@ This ultimately looks like this: [import, lang:"julia"](../../algorithms/quantum_energy/code/julia/energy.jl) {% endmethod %} -As you might imagine, this calculation will be used in many different simulations of quantum systems to check our results. +This calculation will be used in many different simulations of quantum systems to check our results. In the end, many quantum simulations are focused on the _ground_ state, which is the lowest energy state ($$\Psi_0$$); however, sometimes higher energy states are desired. ## The Future @@ -229,7 +238,7 @@ As we proceed to add new algorithms to simulate quantum systems, I will add more We don't want to re-invent the wheel here. Instead, we want to focus on an area that is often not considered with too much detail -- the algorithms and methods researchers use to ascertain new knowedge about quantum mechanics, like the split-operator method, DMRG, quantum monte carlo, exact diagonalization, and many more. -Quantum mechanics is one of those areas of physics that really does push the boundary of human knowledge in a number of different areas and computing is no different. +Quantum mechanics is one of those areas of physics that really does push the boundary of human knowledge in a number of different areas and computing is one of those areas. In fact, [quantum information theory](../quantum_information/quantum_information.md) is currently set to be the next innovation to radically change the landscape of modern computation as we know it! Of course, because of the large-scale effects that this will likely have on the industry, it deserved it's own section. From 7647b7ad932c4a6ad7f6c21ad3d6a9af925a0e4a Mon Sep 17 00:00:00 2001 From: leios Date: Sat, 21 Jul 2018 11:31:14 +0900 Subject: [PATCH 5/9] adding images and fixing typos. --- .../quantum_systems}/code/julia/energy.jl | 0 contents/quantum_systems/quantum_systems.md | 34 +- contents/quantum_systems/res/gaussian.gif | Bin 0 -> 1038393 bytes .../res/imaginary_time.gif | Bin 0 -> 187187 bytes .../res/imaginary_time.png | Bin 0 -> 52665 bytes .../res/imaginary_time.xcf | Bin 0 -> 402663 bytes .../res/imaginary_time_0.png | Bin 0 -> 26289 bytes .../res/imaginary_time_75.png | Bin 0 -> 26616 bytes .../split-operator_method/res/real_time.gif | Bin 0 -> 313392 bytes .../split-operator_method/res/real_time.png | Bin 0 -> 55190 bytes .../split-operator_method/res/real_time.xcf | Bin 0 -> 400414 bytes .../split-operator_method/res/real_time_0.png | Bin 0 -> 28111 bytes .../res/real_time_75.png | Bin 0 -> 28013 bytes .../res/split_op_method.svg | 2138 +++++++++++++++++ .../split-operator_method.md | 21 +- 15 files changed, 2173 insertions(+), 20 deletions(-) rename {chapters/algorithms/quantum_energy => contents/quantum_systems}/code/julia/energy.jl (100%) create mode 100644 contents/quantum_systems/res/gaussian.gif create mode 100644 contents/split-operator_method/res/imaginary_time.gif create mode 100644 contents/split-operator_method/res/imaginary_time.png create mode 100644 contents/split-operator_method/res/imaginary_time.xcf create mode 100644 contents/split-operator_method/res/imaginary_time_0.png create mode 100644 contents/split-operator_method/res/imaginary_time_75.png create mode 100644 contents/split-operator_method/res/real_time.gif create mode 100644 contents/split-operator_method/res/real_time.png create mode 100644 contents/split-operator_method/res/real_time.xcf create mode 100644 contents/split-operator_method/res/real_time_0.png create mode 100644 contents/split-operator_method/res/real_time_75.png create mode 100644 contents/split-operator_method/res/split_op_method.svg diff --git a/chapters/algorithms/quantum_energy/code/julia/energy.jl b/contents/quantum_systems/code/julia/energy.jl similarity index 100% rename from chapters/algorithms/quantum_energy/code/julia/energy.jl rename to contents/quantum_systems/code/julia/energy.jl diff --git a/contents/quantum_systems/quantum_systems.md b/contents/quantum_systems/quantum_systems.md index b99882039..47c576b61 100644 --- a/contents/quantum_systems/quantum_systems.md +++ b/contents/quantum_systems/quantum_systems.md @@ -22,7 +22,7 @@ Because supercomputers are not great at performing quantum computations, certain A _universal quantum simulator_ is often called a quantum computer for this reason. The truth is that quantum simulators are hard to make in laboratories, so simulating quantum systems on classical hardware is as good as we can do in most cases. -This section is devoted to all the different methods currently used to solve complex quantum systems, so let's start with the Schrodinger Equation, which has many different fomulations. +This section is devoted to all the different methods currently used to solve complex quantum systems, so let's start with the Schrodinger Equation, which has many different formulations. Here is the easiest one to explain: $$ @@ -39,7 +39,7 @@ $$ where $$D$$ is some positive definite matrix and $$\phi(\mathbf{r},t)$$ is the density (or temperature) of the system. In fact, this is why one of the most common types of quantum simulation is sometimes called _diffusion monte carlo_. -There really isn't that much of a difference between the two systems in terms of how they are simulated on classical hardware... but we are gettign ahead of ourselves. +There really isn't that much of a difference between the two systems in terms of how they are simulated on classical hardware... but we are getting ahead of ourselves. For now, let's talk about how quantum mechanics differs from classical mechanics and how we can use this to our advantage. ## Probability Density @@ -71,7 +71,7 @@ Any wavevector $$\textbf{k}$$ has the same units as reciprocal space and is thus Often times, the wavevector space is called _momentum_ space, which makes sense when considering the de Broglie formula: $$ -p = \frac{h}{\lambda} +p = \frac{h}{\lambda} = \frac{2 \pi h}{2 \pi \lambda} = \hbar k $$ where $$h$$ is Planck's constant and $$\lambda$$ is the wavelength. @@ -90,24 +90,24 @@ $$ \sigma_x \sigma_p \geq \frac{\hbar}{2} $$ -where $$\hbar$$ is Planck's constant and $$\sigma = \sqrt{\frac{1}{N}\sum_{i=1}^{N}(x_i-\mu)}$$. -In this case, $$\sigma$$ is the standard deviation, $$\mu$$ is the statistical mean of your distribution, $$N$$ is the number of points sampled, and $$x_i$$ is the value for each point $$i$$. +where $$\hbar$$ is Planck's constant and $$\sigma_q = \sqrt{\frac{1}{N}\sum_{i=1}^{N}(q_i-\mu)^2}$$. +In this case, $$\sigma$$ is the standard deviation, $$\mu$$ is the statistical mean of your distribution, $$N$$ is the number of points sampled, $$q_i$$ is the value for each point $$i$$, and $$q$$ stands for $$x$$ or $$p$$.. Ultimately, this means that if we have a higher precision in position space, we will have a lower precision in momentum space. The converse is also true: a higher precision in momentum space will lead to a lower precision in position space. This makes the most sense if we imagine having a gaussian-like probability density ($$|\Psi(x)|^2$$) in position space, which will provide a gaussian-like density when in momentum space. -Here, we see that if we have a broader distribution in one space, we must have a thinner distribution in the opposite space. +Here, we see that if we have a broader distribution in one space, we must have a thinner distribution in the opposite space, as shown here: + +

+ +

-ADD IMAGES -1. Gaussian in position to similar gaussian in momentum -2. Large gaussian in position to small in momentum -3. Small position, large momentum Because the density can be interpreted as "the probability of finding a quantum particle at any provided location in position ($$x_i$$) or momentum ($$k_i$$) space, the interpretation is clear: the more we understand about a particle's position, the less we understand about it's momentum. This is a powerful statement and should be given some thought. To me, the most interesting part of this description is not the physical interpretation, but the fact that this act of transforming between larger and smaller gaussians is precisely what Fourier transforms do! -This further strengthens our arguement from before. +This further strengthens our argument from before. Position and momentum space are related by the Fourier transform! This is the heart of several algorithms for simulating quantum systems, including the [Split-operator method](../../algorithms/split-operator_method/split-operator_method). @@ -127,7 +127,7 @@ We described it in the initial section of this chapter. For the most part, when we are trying to solve this equation the left-hand side does not change. It's always $$i \hbar \frac{\partial \Psi(\mathbf{r},t)}{\partial t}$$. On the other hand, the right-hand side can change a lot depending on the situation. -That is to say that we can easily simplify the Schrodinger equation by using a notational trick called the _Hamiltonian_. +That is to say that we can easily simplify the Schrodinger equation by using a mathematical formalism known as the _Hamiltonian_. To be clear, Hamiltonian mechanics is not a quantum-specific idea. It's everywhere in statistical physics and is often taught in classical physics courses as an analogue to another notational form known as Lagrangian mechanics. @@ -135,11 +135,11 @@ For simplicity, we will restrict our discussion here to interpreting Hamiltonian We can basically say that the Hamiltonian is a measure of the energy of our quantum system. More specifically, we can say that the Hamiltonian is a set of energy _operators_ that act on our wavefunction. -In the case of the example provided here, we might use the following definitions: +In the case of a 1D particle in a harmonic trap, we might use the following definitions: $$ \begin{align} -\hat H &= T + V \\ +\hat H &= \hat T + \hat V \\ \hat T &= \frac{p^2}{2m} \\ \hat V &= \frac{1}{2}\omega x^2 \end{align} @@ -172,7 +172,7 @@ $$ $$ In other words, we can derive a function by performing a Fourier transform on the function, multiplying by some momentum-space grid, and then inverse-transforming it back. -Because this operation inherently involves a tranform into momentum space before transformation, it is a momentum-space operator. +Because this operation inherently involves a transform into momentum space before transformation, it is a momentum-space operator. This is the most intuitive reasoning I can find; however, I am sure there are more intuitive explanations of why the derivatives are always momentum-space operations. This section will be updated further when we discuss spectral methods, but if you have better descriptions, please let me know! @@ -226,7 +226,7 @@ This ultimately looks like this: {% method %} {% sample lang="jl" %} -[import, lang:"julia"](../../algorithms/quantum_energy/code/julia/energy.jl) +[import, lang:"julia"](code/julia/energy.jl) {% endmethod %} This calculation will be used in many different simulations of quantum systems to check our results. @@ -242,7 +242,7 @@ Quantum mechanics is one of those areas of physics that really does push the bou In fact, [quantum information theory](../quantum_information/quantum_information.md) is currently set to be the next innovation to radically change the landscape of modern computation as we know it! Of course, because of the large-scale effects that this will likely have on the industry, it deserved it's own section. -As always, if there is something that you feel is missing from this section, please feel free to contact me or create an issue on github and we'll get to it as soon as we can! +As always, if there is something that you feel is missing from this section, please feel free to contact me or create an issue on GitHub and we'll get to it as soon as we can!