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), but with an extra term for the magnetic field. We reproduce here the results of https://arxiv.org/pdf/1611.02045.pdf Fig. 10

In [1]:
using DFTK
using StaticArrays
using Plots

Unit cell. Having one of the lattice vectors as zero means a 2D system

In [2]:
a = 15
lattice = a .* [[1 0 0.]; [0 1 0]; [0 0 0]];

Confining scalar potential, and magnetic vector potential

In [3]:
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

In [4]:
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

In [5]:
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)
Iter     Function value   Gradient norm 
     0     3.068405e+01     7.473877e+00
 * time: 0.004585981369018555
     1     2.875985e+01     6.225526e+00
 * time: 0.013888835906982422
     2     2.485722e+01     9.941364e+00
 * time: 0.07479500770568848
     3     1.415284e+01     2.280556e+00
 * time: 0.10130596160888672
     4     1.305206e+01     2.413680e+00
 * time: 0.11786484718322754
     5     1.204064e+01     1.846784e+00
 * time: 0.1341559886932373
     6     1.057111e+01     1.433523e+00
 * time: 0.15034890174865723
     7     1.013562e+01     1.747514e+00
 * time: 0.1666250228881836
     8     9.733598e+00     9.628315e-01
 * time: 0.18261504173278809
     9     9.366004e+00     9.722948e-01
 * time: 0.19878888130187988
    10     9.185844e+00     8.222160e-01
 * time: 0.21507596969604492
    11     9.049656e+00     6.046532e-01
 * time: 0.23162388801574707
    12     8.979126e+00     5.376082e-01
 * time: 0.24439287185668945
    13     8.916894e+00     3.240047e-01
 * time: 0.2572929859161377
    14     8.865773e+00     3.135228e-01
 * time: 0.2699768543243408
    15     8.838303e+00     2.740715e-01
 * time: 0.2827279567718506
    16     8.814572e+00     2.353091e-01
 * time: 0.29560089111328125
    17     8.797703e+00     2.146356e-01
 * time: 0.3090198040008545
    18     8.790363e+00     1.632228e-01
 * time: 0.3230249881744385
    19     8.785971e+00     1.080686e-01
 * time: 0.3415999412536621
    20     8.779421e+00     1.123960e-01
 * time: 0.35556793212890625
    21     8.771060e+00     2.108575e-01
 * time: 0.3981599807739258
    22     8.758655e+00     1.775920e-01
 * time: 0.4103658199310303
    23     8.747922e+00     1.157848e-01
 * time: 0.4228689670562744
    24     8.735710e+00     2.110615e-01
 * time: 0.43482089042663574
    25     8.724327e+00     1.405026e-01
 * time: 0.44718289375305176
    26     8.716358e+00     1.305312e-01
 * time: 0.45949387550354004
    27     8.704812e+00     1.971143e-01
 * time: 0.4719099998474121
    28     8.691239e+00     1.931279e-01
 * time: 0.4840669631958008
    29     8.679364e+00     1.789381e-01
 * time: 0.49630284309387207
    30     8.668966e+00     2.267373e-01
 * time: 0.5086309909820557
    31     8.660125e+00     1.535688e-01
 * time: 0.5208728313446045
    32     8.646998e+00     1.397988e-01
 * time: 0.5330648422241211
    33     8.633404e+00     1.240944e-01
 * time: 0.5452280044555664
    34     8.617096e+00     1.758594e-01
 * time: 0.5576088428497314
    35     8.605580e+00     2.437573e-01
 * time: 0.5703840255737305
    36     8.594514e+00     1.471578e-01
 * time: 0.583115816116333
    37     8.580812e+00     2.197228e-01
 * time: 0.595573902130127
    38     8.560864e+00     1.877918e-01
 * time: 0.6078798770904541
    39     8.534669e+00     2.329562e-01
 * time: 0.6201050281524658
    40     8.511610e+00     1.859549e-01
 * time: 0.6325209140777588
    41     8.492595e+00     2.406591e-01
 * time: 0.6457858085632324
    42     8.491859e+00     5.175557e-01
 * time: 0.6588449478149414
    43     8.480363e+00     4.049774e-01
 * time: 0.6721110343933105
    44     8.474581e+00     4.059790e-01
 * time: 0.6853690147399902
    45     8.468200e+00     3.218032e-01
 * time: 0.723822832107544
    46     8.467268e+00     1.737473e-01
 * time: 0.7403459548950195
    47     8.466971e+00     1.586764e-01
 * time: 0.7605698108673096
    48     8.466923e+00     1.188528e-01
 * time: 0.7767958641052246
    49     8.466923e+00     1.188528e-01
 * time: 0.895845890045166
Out[5]: