'''MgO rigid ion single point'''

from chemsh       import *
from chemsh.utils import testutils

# unit cell
mgo = Fragment(coords="mgo.cjson")
print("### unit lattice consts =", mgo.cell.consts)
print("### unit lattice natoms =", mgo.natoms)

# make a supercell trippling each dimension (if symmetric=True it will be expanded by 5-fold along each dimension)
supercell = mgo.getSuperCell(nlayers=3, symmetric=False)
print("### supercell radius  =", supercell.radius)
print("### supercell natoms  =", supercell.natoms, supercell.cell.natoms)
print("### supercell consts  =", supercell.cell.consts)
print("### supercell vectors =", supercell.cell.vectors)

supercell.save('mgo_supercell_4.pun')

ff = '''species
Mg core  2.0
O  core -2.0
buckingham
Mg core O core 2457.243 0.2610  0.00 0.0 10.0
O  core O core   25.410 0.6937 32.32 0.0 12.0
'''

mm = GULP(frag=supercell, ff=ff)

sp = SP(theory=mm, gradients=False)

sp.run()

ecalc = sp.result.energy

# Test result
eref = -5.96794361


testutils.validate(ecalc, eref)
