-
Notifications
You must be signed in to change notification settings - Fork 0
/
relax_atoms.py
63 lines (46 loc) · 1.67 KB
/
relax_atoms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from ase.build import bulk
from ase import Atoms
from ase.db import connect
from ase.visualize import view
from ase.optimize.precon import PreconLBFGS
from ase.io.trajectory import Trajectory
from gpaw import GPAW, PW, FermiDirac
import sys
def save_atoms(my_atoms, E_c, Nbands, Kpts, Fermi_dirac, Lattice_constant, Is_varying):
db = connect('fe_kpts.db')
db.write(my_atoms, energy_cutoff = E_c,
nbands = Nbands, k_points = Kpts,
smearing_factor = Fermi_dirac,
lattice_constant = Lattice_constant,
is_varying = Is_varying)
if __name__ == "__main__":
a = 2.86
e_cut = 500
nbands = -5
xc = 'PBE'
k_pts = 5
k_pts = int(k_pts)
smear = 0.1
#set hunds rule
#precon lfgs variable_cell = true
atoms = 1
atoms = int(atoms)
bulk_mat = bulk('Fe','bcc',a)*(2,1,1)
#bulk_mat.set_initial_magnetic_moments([2.2, 2.2])
print(bulk_mat.get_positions())
bulk_mat = bulk_mat#*(atoms,atoms,atoms)
is_varying = 'nothing'
calc = GPAW(mode=PW(e_cut), nbands = nbands,
xc='PBE', spinpol = True, kpts=(k_pts,k_pts,k_pts),
occupations=FermiDirac(smear , fixmagmom = True), txt='Fe.out')
bulk_mat.set_calculator(calc)
traj = Trajectory('some_test.traj', 'w', bulk_mat)
bulk_mat = unitcellfilter...(bulk_mat, hydrotstatic_strain=True)
relaxer = PreconLBFGS(bulk_mat, variable_cell = True, logfile = 'my_log.txt')
relaxer.attach(traj)
relaxer.run(fmax = 0.025, smax = 0.003)
energy = bulk_mat.get_potential_energy()
print(bulk_mat.get_magnetic_moments())
print(bulk_mat.get_positions())
print(energy)
calc.write('Fe.gpw')