4. minimizer

4.1. sd

Steepest descent minimization algorithm.

Python

Julia

 1Elist = []
 2
 3for i in range(Nit):
 4    E = scf_step(scf)
 5    Elist.append(E)
 6    print("Nit: {}  \tEtot: {:.6f} Eh".format(i + 1, E), end="\r")
 7    if i > 1 and abs(Elist[i - 1] - Elist[i]) < etol:
 8        print("\nSCF converged.")
 9        return E
10    g = get_grad(scf.atoms, scf.op, scf.W, scf.phi, scf.vxc, scf.pot)
11    scf.W = scf.W - beta * g
12print("\nSCF not converged!")
13return E
 1Elist = Float64[]
 2
 3for i = 1:Nit
 4    E = scf_step(scf)
 5    append!(Elist, E)
 6    print("Nit: $(i)  \tEtot: $(round(E; digits=6)) Eh\r")
 7    if i > 1 && abs(Elist[i-1] - Elist[i]) < etol
 8        println("\nSCF converged.")
 9        return E
10    end
11    g = get_grad(scf.atoms, scf.W, scf.phi, scf.vxc, scf.pot)
12    scf.W = scf.W .- beta .* g
13end
14println("\nSCF not converged!")
15return E