Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
DFTK.jl/examples/gross_pitaevskii_2D.jl
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
40 lines (33 sloc)
1.28 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# # Gross-Pitaevskii equation with external magnetic field | |
# We solve the 2D Gross-Pitaevskii equation with a magnetic field. | |
# This is similar to the | |
# previous example ([Gross-Pitaevskii equation in one dimension](@ref gross-pitaevskii)), | |
# but with an extra term for the magnetic field. | |
# We reproduce here the results of https://arxiv.org/pdf/1611.02045.pdf Fig. 10 | |
using DFTK | |
using StaticArrays | |
using Plots | |
## Unit cell. Having one of the lattice vectors as zero means a 2D system | |
a = 15 | |
lattice = a .* [[1 0 0.]; [0 1 0]; [0 0 0]]; | |
## Confining scalar potential, and magnetic vector potential | |
pot(x, y, z) = ((x - a/2)^2 + (y - a/2)^2)/2 | |
ω = .6 | |
Apot(x, y, z) = ω * @SVector [y - a/2, -(x - a/2), 0] | |
Apot(X) = Apot(X...); | |
## Parameters | |
Ecut = 20 # Increase this for production | |
η = 500 | |
C = η/2 | |
α = 2 | |
n_electrons = 1; # Increase this for fun | |
## Collect all the terms, build and run the model | |
terms = [Kinetic(), | |
ExternalFromReal(X -> pot(X...)), | |
LocalNonlinearity(ρ -> C * ρ^α), | |
Magnetic(Apot), | |
] | |
model = Model(lattice; n_electrons, terms, spin_polarization=:spinless) # spinless electrons | |
basis = PlaneWaveBasis(model; Ecut, kgrid=(1, 1, 1)) | |
scfres = direct_minimization(basis, tol=1e-5) # Reduce tol for production | |
heatmap(scfres.ρ[:, :, 1, 1], c=:blues) |