import numpy as np
from osp.core.namespaces import QE
from osp.core.utils import pretty_print
from osp.wrappers.quantumespresso.qe_session import qeSession

# Creates simulation
sim = QE.Simulation()
k = QE.K_POINTS(vector6 = (7, 7, 7, 0, 0, 0), unit = "")

# Creates a cell, the element Silicon, a pseudopotential, two atoms and cell parameters
SiCell = QE.Cell()
Si = QE.Element(name = "Si")
SiPseudo = QE.PSEUDOPOTENTIAL(path = "Si.pbe-n-kjpaw_psl.1.0.0.UPF")
Si1 = QE.Atom()
celldm1 = QE.Celldm1(value = 5.43070, unit = "au")

# Adds pseudopotential and atoms to the element
# Describes element's mass
# Adds atoms and cell parameters to the cell
# Positions the atoms
Si.add(SiPseudo, Si1)
Si.add(QE.Mass(value = 28.085, unit = "amu"))
SiParams = QE.CellParams(tensor2 = [[0.5, 0.5, 0.],
                                      [0.5, 0., 0.5],
                                      [0., 0.5, 0.5]], unit = "")
SiCell.add(Si1, SiParams)
Si1.add(QE.Position(vector = (0, 0, 0), unit = ""))
SiCell.add(celldm1)

# Specifies the values of the cell parameters
sim  = QE.Simulation()
root = ""
session = qeSession(root)
quantum_espresso_wrapper = QE.QEWrapper(session = session)
quantum_espresso_wrapper.add(sim)

cell = QE.Cell()
alat = 4.
cellParams = cell.add(QE.CellParams(tensor2 = 
[[1., 0., 0.,],
[0., 1., 0.,],
[0., 0., 1.,]], unit = "alat"))
cell.add(QE.Celldm1(value = alat, unit = ""))

O = QE.Element(name = "O")
Ba = QE.Element(name = "Ba")
Ti = QE.Element(name = "Ti")

O.add(QE.Mass(value = 15.999, unit = "amu"))
Ba.add(QE.Mass(value = 137.327, unit = "amu"))
Ti.add(QE.Mass(value = 47.867, unit = "amu"))

O.add(QE.PSEUDOPOTENTIAL(path = "O.pbe-n-kjpaw_psl.1.0.0.UPF"))
Ba.add(QE.PSEUDOPOTENTIAL(path = "Ba.pbe-spn-kjpaw_psl.1.0.0.UPF"))
Ti.add(QE.PSEUDOPOTENTIAL(path = "Ti.pbe-spn-kjpaw_psl.1.0.0.UPF"))

O1 = O.add(QE.Atom())
O2 = O.add(QE.Atom())
O3 = O.add(QE.Atom())
Ba1 = Ba.add(QE.Atom())