Exemplo n.º 1
0
def get_struct(s=9.3 / 2.0):
    """Get a structure for silicon"""
    a123 = np.array([[1, 1, 0], [1, 0, 1], [0, 1, 1]
                     ]) * s  # silicon lattice vectors
    atoms = [["Pb", [0., 0., 0.]]]  # first atom
    st = structure.create_structure(a123, atoms)  # create structure
    return st


st = get_struct()  # silicon structure

from dftpy import calculations  # calculations module

# quantum espresso
c1 = calculations.Calculation(st, code="Elk",
                              soc=False)  # create a DFT calculation
ks1, es1 = c1.bandstructure()  # get bandstructure
ks1 = ks1 / max(ks1)

# Elk
c2 = calculations.Calculation(st, code="Elk",
                              soc=True)  # create a DFT calculation
ks2, es2 = c2.bandstructure()  # get bandstructure
ks2 = ks2 / max(ks2)

import matplotlib.pyplot as plt

plt.scatter(ks1, es1, c="red", label="No SOC")
plt.scatter(ks2, es2, c="blue", label="SOC")

plt.legend()
Exemplo n.º 2
0
def get_struct(s=2.7):
    """Get a structure for Fe"""
    a123 = np.array([[1, 1, -1], [1, -1, 1], [-1, 1, 1]
                     ]) * s  # lattice vectors
    atoms = [["Fe", [0., 0., 0.]]]  # first atom
    st = structure.create_structure(a123, atoms)  # create structure
    return st


st = get_struct()  # Fe structure

from dftpy import calculations  # calculations module

# quantum espresso
import matplotlib.pyplot as plt
c1 = calculations.Calculation(st, code="QE", spin=True,
                              m=[0., 0., 1.])  # create a DFT calculation
#c1.gs_energy()
#es1,ds1 =
from dftpy import dosqe
#pd = c1.pdos(nk=4) # get PDOS object
#exit()
pd = dosqe.read_pdos(c1)
#es1,ds1 = pd.energies,pd.pdos_specie[("Fe","up")]
#es2,ds2 = pd.energies,pd.pdos_specie[("Fe","dn")]
es1, ds1 = pd.energies, pd.dos_up
es2, ds2 = pd.energies, pd.dos_dn
#es2,ds2 = pd.energies,pd.pdos_specie["O"]
plt.plot(es1, -ds1, label="Up")
plt.plot(es2, ds2, label="Dn")
plt.plot(es2, -ds1 + ds2, label="Difference", c="black")
plt.legend()
Exemplo n.º 3
0
from __future__ import print_function
import sys
import numpy as np

from dftpy import structure
from dftpy import calculations  # calculations module
import matplotlib.pyplot as plt


def get_struct(s=2.7):
    """Get a structure for Fe"""
    a123 = np.array([[1, 1, -1], [1, -1, 1], [-1, 1, 1]
                     ]) * s  # lattice vectors
    atoms = [["Co", [0., 0., 0.]]]  # first atom
    st = structure.create_structure(a123, atoms)  # create structure
    return st


st = get_struct()  # Fe structure

c = calculations.Calculation(st, spin=True, m=[0., 0., -1.], code="Elk")
c.soc = True
c.options["autolinengy"] = True  # set linenergy to True
c.options["socscf"] = 4  # set linenergy to True
c.gs_energy()  # compute ground state energy
Exemplo n.º 4
0
from __future__ import print_function
import sys
import numpy as np

from dftpy import structure
from dftpy import calculations  # calculations module


def get_struct(s=3.83):
    """Get a structure for silicon"""
    a123 = np.array([[1, 1, 0], [1, 0, 1], [0, 1, 1]
                     ]) * s  # silicon lattice vectors
    atoms = [["Si", [0., 0., 0.]]]  # first atom
    st = structure.create_structure(a123, atoms)  # create structure
    return st


st = get_struct()  # silicon structure

# quantum espresso
import matplotlib.pyplot as plt
c1 = calculations.Calculation(st, code="QE")  # create a DFT calculation
es1, ds1 = c1.dos(nk=8)  # get DOS
c2 = calculations.Calculation(st, code="Elk")  # create a DFT calculation
es2, ds2 = c2.dos(nk=8)  # get DOS
plt.plot(es1, ds1, label="QE")
plt.plot(es2, ds2, label="Elk")
plt.legend()

plt.show()
Exemplo n.º 5
0
from dftpy import calculations  # calculations module
import matplotlib.pyplot as plt


def get_struct(s=2.7):
    """Get a structure for Fe"""
    a123 = np.array([[1, 1, -1], [1, -1, 1], [-1, 1, 1]
                     ]) * s  # lattice vectors
    atoms = [["Co", [0., 0., 0.]]]  # first atom
    st = structure.create_structure(a123, atoms)  # create structure
    return st


st = get_struct()  # Fe structure

c = calculations.Calculation(st, spin=True, m=[0., 0., -1.])
(es, ds) = c.dos()

plt.plot(es, ds)
plt.show()
exit()

c.code = "QE"
c.gs_energy()  # get ground state energy
#exit()
c.scf = True
#c.runnscf(k=[0.5,0.5,0.5]) # run a non selfconsistent calculation
kp, es = c.bandstructure(spin=True)  # write bandstructure

#sz = sz/np.max(np.abs(sz))
np.savetxt("BAND.OUT", np.matrix([kp, es]).T)
Exemplo n.º 6
0
from __future__ import print_function
import sys
import numpy as np

from dftpy import structure


def get_struct(s=4.5):
  """Get a structure for silicon"""
  a123 = np.array([[1,1,0],[1,0,1],[0,1,1]])*s # silicon lattice vectors
  atoms = [["Si",[0.,0.,0.]]] # first atom
  atoms += [["Si",[0.25,0.25,0.25]]] # second atom
  st = structure.create_structure(a123,atoms) # create structure
  return st


from dftpy import calculations # calculations module
from dftpy import optimize

st = get_struct() # get the structure
calculations.cores = 4
c = calculations.Calculation(st,code="Elk") # create a DFT calculation
c = optimize.volume(c) # optimize the volume
Exemplo n.º 7
0
from dftpy import structure
from dftpy import calculations # calculations module
from dftpy import dosqe # calculations module

st = structure.read_qe("qe.in") # read Quantum Espresso structure

c = calculations.Calculation(st,code="QE") 
#pd = c.pdos(nk=10) # get PDOS object
pd = dosqe.read_pdos(c)
#es,ds = pd.energies,pd.pdos_specie[("Re")]
e0,d0 = pd.energies,pd.get_sum([None,"s",None]) # get the s PDOS
e1,d1 = pd.energies,pd.get_sum([None,"d",None]) # get the d PDOS
e2,d2 = pd.energies,pd.get_sum([None,"p",None]) # get the d PDOS
import matplotlib.pyplot as plt
import numpy as np

np.savetxt("PDOS_S_QE.OUT",np.array([e0,d0]).T)
np.savetxt("PDOS_D_QE.OUT",np.array([e1,d1]).T)
np.savetxt("PDOS_P_QE.OUT",np.array([e2,d2]).T)


plt.plot(e0,d0)
plt.plot(e1,d1)
plt.plot(e2,d2)
plt.show()

Exemplo n.º 8
0

def get_struct(s=5.2):
    """Get a structure for silicon"""
    a123 = np.array([[1, 1, 0], [1, 0, 1], [0, 1, 1]
                     ]) * s  # silicon lattice vectors
    atoms = [["Si", [0., 0., 0.]]]  # first atom
    atoms += [["Si", [0.25, 0.25, 0.25]]]  # second atom
    st = structure.create_structure(a123, atoms)  # create structure
    return st


from dftpy import calculations  # calculations module

st = get_struct()
c = calculations.Calculation(st, spin=True)  # create a DFT calculation
c.relax()

exit()
aa = np.linspace(4.5, 5.8, 10)  # array for the lattice constants
es = []  # array for the energies
for a in aa:
    st = get_struct(a)  # get the structure
    c = calculations.Calculation(st)  # create a DFT calculation
    e = c.gs_energy()  # get the ground state energy
    es.append(e)  # store energy
    print("Lattice constant = ", a, "Energy = ", e)

es = np.array(es)
es = es - min(es)  # shift energy
Exemplo n.º 9
0

def get_struct(s=5.2):
    """Get a structure for silicon"""
    a123 = np.array([[1, 1, 0], [1, 0, 1], [0, 1, 1]
                     ]) * s  # silicon lattice vectors
    atoms = [["Si", [0., 0., 0.]]]  # first atom
    atoms += [["Si", [0.25, 0.25, 0.25]]]  # second atom
    st = structure.create_structure(a123, atoms)  # create structure
    return st


st = get_struct()  # silicon structure

from dftpy import calculations  # calculations module
c = calculations.Calculation(st)  # create a DFT calculation
#c.spin = True
c.code = "QE"
c.gs_energy()  # get ground state energy
c.scf = True
ks, es = c.bandstructure()  # write bandstructure

kp = ks
#kp = np.array([k[0] for k in ks])
kp = kp / max(kp)

print(kp.shape, es.shape)

import matplotlib.pyplot as plt

plt.scatter(kp, es, c="black")