|
| 1 | +# Aluminium supercell using density-functional theory |
| 2 | + |
| 3 | +In this example we will optimise the structure of a rattled |
| 4 | +aluminium system using density-functional theory. |
| 5 | + |
| 6 | +First we build a rattled aluminium system: |
| 7 | + |
| 8 | +```@example dftk-aluminium |
| 9 | +using AtomsBuilder |
| 10 | +using Unitful |
| 11 | +
|
| 12 | +system = rattle!(bulk(:Al; cubic=true), 0.2u"Å") |
| 13 | +``` |
| 14 | + |
| 15 | +Next we create a calculator employing the |
| 16 | +[density-functional toolkit](https://dftk.org/) |
| 17 | +to compute energies and forces at using the LDA density functional. |
| 18 | +```@example dftk-aluminium |
| 19 | +using DFTK |
| 20 | +
|
| 21 | +model_kwargs = (; functionals=[:lda_x, :lda_c_pw], temperature=1e-3) |
| 22 | +basis_kwargs = (; kgrid=(3, 3, 3), Ecut=10.0) |
| 23 | +scf_kwargs = (; tol=1e-6, mixing=KerkerMixing()) |
| 24 | +calc = DFTKCalculator(; model_kwargs, basis_kwargs, scf_kwargs, verbose=true) |
| 25 | +nothing |
| 26 | +``` |
| 27 | + |
| 28 | +We attach pseudopotentials to the aluminium system, |
| 29 | +i.e. we tell DFTK, that each aluminium atom should be modelled using |
| 30 | +a pseudopotential rather than the full Coulomb potential. |
| 31 | + |
| 32 | +```@example dftk-aluminium |
| 33 | +system = attach_psp(system; Al="hgh/lda/al-q3") |
| 34 | +nothing |
| 35 | +``` |
| 36 | + |
| 37 | +!!! info "Crude computational parameters" |
| 38 | + Note, that these numerical parameters are chosen rather crudely in order |
| 39 | + to give a fast runtime on CI systems. For production calculations one would |
| 40 | + require larger computational parameters. |
| 41 | + |
| 42 | +We perform the structure optimisation using the LBFGS solver |
| 43 | +from Optim with solver parameters adapted for our geometry optimisation setting. |
| 44 | +This is selected by passing the [GeometryOptimization.OptimLBFGS](@ref) |
| 45 | +solver as the third argument. |
| 46 | + |
| 47 | +```@example dftk-aluminium |
| 48 | +using GeometryOptimization |
| 49 | +GO = GeometryOptimization |
| 50 | +
|
| 51 | +results = minimize_energy!(system, calc, GO.OptimLBFGS(); |
| 52 | + tol_force=1e-4u"eV/Å", |
| 53 | + show_trace=true) |
| 54 | +nothing |
| 55 | +``` |
| 56 | + |
| 57 | +The final energy is |
| 58 | +```@example dftk-aluminium |
| 59 | +results.energy |
| 60 | +``` |
| 61 | + |
| 62 | +We can view the final structure |
| 63 | +```@example dftk-aluminium |
| 64 | +results.system |
| 65 | +``` |
| 66 | + |
| 67 | +Some statistics about the optimisation |
| 68 | +```@example dftk-aluminium |
| 69 | +results.stats |
| 70 | +``` |
| 71 | +or the details about the selected algorithm: |
| 72 | +```@example dftk-aluminium |
| 73 | +results.alg |
| 74 | +``` |
| 75 | + |
| 76 | +The final state of the calculator object is also accessible |
| 77 | +via `results.state` and could be employed for postprocessing |
| 78 | +using the framework of the calculator. E.g. in the case |
| 79 | +of `DFTK`, the `results.state` is what `DFTK` calls an `scfres` |
| 80 | +and could just be used to plot a density of states or plot |
| 81 | +bands or compute response properties. |
0 commit comments