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.060136e+01     7.595435e+00
 * time: 0.004382133483886719
     1     2.880997e+01     5.423184e+00
 * time: 0.013163089752197266
     2     1.674728e+01     3.684839e+00
 * time: 0.038455963134765625
     3     1.298976e+01     1.842488e+00
 * time: 0.05840802192687988
     4     1.157225e+01     2.066631e+00
 * time: 0.07877898216247559
     5     1.067315e+01     1.395294e+00
 * time: 0.09610199928283691
     6     1.022136e+01     1.297891e+00
 * time: 0.11374402046203613
     7     9.733602e+00     7.906879e-01
 * time: 0.1299431324005127
     8     9.498805e+00     9.571391e-01
 * time: 0.1461939811706543
     9     9.376034e+00     6.080652e-01
 * time: 0.16211605072021484
    10     9.256797e+00     4.508729e-01
 * time: 0.1778249740600586
    11     9.159711e+00     6.484503e-01
 * time: 0.18931198120117188
    12     9.101580e+00     6.137670e-01
 * time: 0.20073914527893066
    13     9.062695e+00     4.728745e-01
 * time: 0.21219301223754883
    14     9.003882e+00     4.749752e-01
 * time: 0.22366809844970703
    15     8.961750e+00     2.891135e-01
 * time: 0.23530101776123047
    16     8.940465e+00     3.054697e-01
 * time: 0.2867159843444824
    17     8.902345e+00     2.605803e-01
 * time: 0.29808616638183594
    18     8.882018e+00     1.942450e-01
 * time: 0.3094971179962158
    19     8.869787e+00     2.098498e-01
 * time: 0.3207430839538574
    20     8.860407e+00     2.653612e-01
 * time: 0.33221006393432617
    21     8.834069e+00     2.061801e-01
 * time: 0.3436880111694336
    22     8.792125e+00     2.805051e-01
 * time: 0.355147123336792
    23     8.756360e+00     2.548108e-01
 * time: 0.36669206619262695
    24     8.729760e+00     2.118028e-01
 * time: 0.3781859874725342
    25     8.674094e+00     2.337216e-01
 * time: 0.389707088470459
    26     8.639844e+00     2.488812e-01
 * time: 0.40123605728149414
    27     8.610054e+00     2.194887e-01
 * time: 0.4128580093383789
    28     8.571872e+00     1.824702e-01
 * time: 0.424389123916626
    29     8.551868e+00     1.659673e-01
 * time: 0.43578314781188965
    30     8.541628e+00     1.793289e-01
 * time: 0.44706201553344727
    31     8.535471e+00     1.925776e-01
 * time: 0.45818209648132324
    32     8.530846e+00     1.393299e-01
 * time: 0.4694051742553711
    33     8.526631e+00     1.107636e-01
 * time: 0.48075199127197266
    34     8.524832e+00     8.344340e-02
 * time: 0.49204111099243164
    35     8.522520e+00     6.546595e-02
 * time: 0.5034000873565674
    36     8.519161e+00     5.673858e-02
 * time: 0.5149180889129639
    37     8.517701e+00     5.615832e-02
 * time: 0.5263099670410156
    38     8.516916e+00     5.937991e-02
 * time: 0.5379111766815186
    39     8.515851e+00     3.801164e-02
 * time: 0.5496761798858643
    40     8.515053e+00     5.264755e-02
 * time: 0.5936429500579834
    41     8.514499e+00     3.867559e-02
 * time: 0.6050460338592529
    42     8.514251e+00     5.469878e-02
 * time: 0.6164431571960449
    43     8.513826e+00     3.737006e-02
 * time: 0.6277720928192139
    44     8.513366e+00     4.034809e-02
 * time: 0.6390640735626221
    45     8.513194e+00     2.816864e-02
 * time: 0.6503660678863525
    46     8.513045e+00     3.915307e-02
 * time: 0.6616780757904053
    47     8.512761e+00     2.934585e-02
 * time: 0.673194169998169
    48     8.512589e+00     2.754424e-02
 * time: 0.6845731735229492
    49     8.512434e+00     1.678330e-02
 * time: 0.6960961818695068
    50     8.512323e+00     1.595735e-02
 * time: 0.7073981761932373
    51     8.512243e+00     1.906035e-02
 * time: 0.7187399864196777
    52     8.512171e+00     1.109253e-02
 * time: 0.730100154876709
    53     8.512089e+00     1.465525e-02
 * time: 0.7413949966430664
    54     8.512037e+00     9.566615e-03
 * time: 0.7527220249176025
    55     8.512024e+00     1.233504e-02
 * time: 0.763901948928833
    56     8.511974e+00     9.108683e-03
 * time: 0.7753121852874756
    57     8.511942e+00     7.699279e-03
 * time: 0.7867450714111328
    58     8.511924e+00     9.541852e-03
 * time: 0.7980160713195801
    59     8.511905e+00     7.157047e-03
 * time: 0.809149980545044
    60     8.511891e+00     6.120977e-03
 * time: 0.820289134979248
    61     8.511875e+00     4.611738e-03
 * time: 0.8314640522003174
    62     8.511867e+00     4.805000e-03
 * time: 0.8427109718322754
    63     8.511863e+00     3.933121e-03
 * time: 0.8542051315307617
    64     8.511858e+00     2.674432e-03
 * time: 0.8937420845031738
    65     8.511855e+00     2.280951e-03
 * time: 0.90513014793396
    66     8.511852e+00     1.941317e-03
 * time: 0.9165301322937012
    67     8.511851e+00     2.158678e-03
 * time: 0.9278850555419922
    68     8.511850e+00     1.499713e-03
 * time: 0.9392681121826172
    69     8.511849e+00     1.661873e-03
 * time: 0.950592041015625
    70     8.511848e+00     1.873279e-03
 * time: 0.9620001316070557
    71     8.511848e+00     1.682758e-03
 * time: 0.9737610816955566
    72     8.511847e+00     1.516782e-03
 * time: 0.9852659702301025
    73     8.511846e+00     7.989321e-04
 * time: 0.9965569972991943
    74     8.511846e+00     7.280981e-04
 * time: 1.0077309608459473
    75     8.511846e+00     8.588832e-04
 * time: 1.019024133682251
    76     8.511846e+00     5.718639e-04
 * time: 1.0302910804748535
    77     8.511846e+00     4.213009e-04
 * time: 1.0414800643920898
    78     8.511845e+00     4.633857e-04
 * time: 1.0527970790863037
    79     8.511845e+00     4.753988e-04
 * time: 1.063992977142334
    80     8.511845e+00     3.306843e-04
 * time: 1.0752429962158203
    81     8.511845e+00     2.141433e-04
 * time: 1.086557149887085
    82     8.511845e+00     2.072007e-04
 * time: 1.0977730751037598
    83     8.511845e+00     2.727225e-04
 * time: 1.108877182006836
    84     8.511845e+00     2.249107e-04
 * time: 1.1201529502868652
    85     8.511845e+00     1.443985e-04
 * time: 1.1314470767974854
    86     8.511845e+00     1.298849e-04
 * time: 1.1428041458129883
Out[5]: