Skip to content

Commit

Permalink
Written section on total energy convergence threshold. Probably needs…
Browse files Browse the repository at this point in the history
… a little better explaination on why this matters?
  • Loading branch information
TruePhys committed Oct 25, 2024
1 parent fe8f4d2 commit 72d044f
Showing 1 changed file with 43 additions and 8 deletions.
51 changes: 43 additions & 8 deletions docs/labs/lab03/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Before starting, if you can't remember how to do something from the command line

-------------------------------------------------------------------------------------------



## Plane Waves and Pseudopotentials

As will be discussed in lectures, pseudopotentials are used in DFT calculations to approximate the potential of the core region. The core is made up of tightly bound electrons close to the nucleus. In this region, the electrons are in a strong coulomb potential generated by the nucleus. This creates a strong oscillation in the electronic wavefucntions in the core region. If one wanted to express the electronic wavefunctions in a plane-wave basis, this rapid oscillation of the electronic wavefucntion would require a significant number of plane waves to describe. To reduce the number of plane-waves needed in the expansion of the Kohn-Sham wavefunctions, and thus reduce the computational load significantly, we approximate the core region. This is essentially 'freezing' the core electrons. The self-consistent calculations are therefore only done on the valence electrons.
Expand Down Expand Up @@ -47,7 +45,7 @@ To start this lab, copy the `/opt/MSE404-MM/docs/labs/lab03` to your `MSE404` di
2P 0 1 2.00 0.00000000000 0.00000000000 0.00000000000
```
The core states are therefore 1S.
- What is the valence charge on the oxygen after the core has been approximated?
- What is the valence charge of the oxygen atom core consisting of the nucleus and the core electrons?

??? success "Answer"
The valence charge is 4. Found by identifying the line `4.00000000000 Z valence` in the information below:
Expand All @@ -71,7 +69,9 @@ To start this lab, copy the `/opt/MSE404-MM/docs/labs/lab03` to your `MSE404` di
```


## Total Energy Convergence
## Total Energy Convergence Threshold

DFT is an iterative process. We self-consistenly solve the Kohn-Sham equations for the ground-state electron density, i.e. until we meet convergence. The criteria for convergence is defined as when the total energy between successive scf iterations is below a certain value, called the convergence threshold. This can play a crucial role in determining the accuracy and and stability of the results.

Let's look at a brief view of an example of the CO input file stored in `01_carbon_monoxide/01_convergence_threshold`.

Expand Down Expand Up @@ -126,6 +126,45 @@ C 15.0000000000 15.0000000000 15.0000000000
6. The structure of this line is <element name> <element atomic mass> <name of pseudopotential>.


!!! tip annotate "Tip: Running Quantum Espressso"
Make sure to have loaded the quantum espresso module and its dependencies using the command:

`module load quantum-espresso`


!!! example "Task 2 - Convergence Threshold"

Make 4 copies of the `CO.in` input file named `CO_i.in`, where i should go from 5 to 8. In each of these files, reduce the order of magnitude of the conv_thr by 10 each time i.e. replace the `conv_thr = 1e-4` with `conv_thr = 1e-5` in `CO_5.in`.

- Run these 4 input files using `pw.x` e.g. `pw.x < CO_5.in > CO_5.out`.

- What does changing this convergence threshold do? What do you expect to happen?

??? success "Answer"
After one scf cycle, a total energy is calculated. The calculation is converged when the difference in the total energy between two successive scf iterations is less than the convergence threshold. Therefore, reducing this convergence threshold is making our convergence tighter, meaning differences in successive iterations must be smaller for our calculation to be converged. This means the smaller the convergence threshold, the more iterations it should take for convergence.

Quantum Espresso outputs the number of scf cycles it took for convergence to be achieved. Look for this line in the output file:
```bash
convergence has been achieved in ...
```

- How many iterations did it take each calculation to converge? Is this what you expected?

??? success "Answer"
```bash
CO_5.out: convergence has been achieved in 6 iterations
CO_6.out: convergence has been achieved in 8 iterations
CO_7.out: convergence has been achieved in 9 iterations
CO_8.out: convergence has been achieved in 11 iterations
```
We could have taken advantage of the `grep` command here. If you don't remember how to use this command, refer back to [Lab 1](../lab01/readme.md) for documentation on `grep`.

- Try this again using the `grep` command.

??? hint "Hint For Using Grep"
`grep 'convergence has been achieved in' CO_5.out`.


## Plane-wave energy cut-off

Regardless of the type of system you're looking at, you'll need to check how
Expand Down Expand Up @@ -217,10 +256,6 @@ K_POINTS gamma
3. Plane-wave cutoff of 25 Ry.
4. This variable controls when the self consistency cycle finishes. When the `estimated energy error < conv_thr` the self consistency cycle (scf) stops. You should be aware of this variable, as there is little point in trying to converge to greater accuracy than we are converging self-consistently.

!!! tip annotate "Tip: Running Quantum Espressso"
Make sure to have loaded the quantum espresso module and its dependencies using the command:

`module load quantum-espresso`

Now we want to run `pw.x` for each of these input files. It would be very tedious to do this manually, especially if we had more input files. This is where ***bash scripting*** comes in handy. We won't go too much into bash scripting, but if you are interested you are encouraged to spend some time understanding the bash scripts provided. Let's examine the simple script below:

Expand Down

0 comments on commit 72d044f

Please sign in to comment.