/
gross_pitaevskii_2D.jl
40 lines (33 loc) · 1.28 KB
/
gross_pitaevskii_2D.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# # 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)