from chemsh import *
from chemsh.io.converter import *
from chemsh.objects import fragment
from ase.atoms import Atoms
from ase.calculators.emt import EMT


"""
# CONDUCTING TWO TESTS TO ENSURE THE DIFFERENT OBJECT CAN BE CONVERTED BETWEEN EACHOTHER
"""
# ATOMS -> FRAGMENT -> ATOMS -> FRAGMENT
print("=======")
myAts = Atoms("N2", positions=[(0, 0, 0), (2.5, 0, 0)])
print("Original myAts: " + str(myAts.positions))
print(" ")

convertToFragment1 = convert_to_fragment(myAts)
print("znums: " + str(convertToFragment1.znums) + "\ncoords: " + str(convertToFragment1.coords) + "\nconnect_mode: " + str(convertToFragment1.connect_mode))
print(" ")

convertToAtoms1 = convert_to_atoms(convertToFragment1)
print("My Atoms 1 Result: " + str(convertToAtoms1.positions))
print(" ")

convertToFragment2 = convert_to_fragment(convertToAtoms1)
print("znums: " + str(convertToFragment2.znums) + "\ncoords: " + str(convertToFragment2.coords) + "\nconnect_mode: " + str(convertToFragment2.connect_mode))
"""


"""
# FRAGMENT -> ATOMS -> FRAGMENT -> ATOMS
print("=======")
myFrags = Fragment(znums=[7, 7], coords=[[0, 0, 0], [4.72431666, 0, 0]], connect_mode="covalent")
print("ORIGINAL FRAGMENT")
print("znums: " + str(myFrags.znums))
print("coords: " + str(myFrags.coords))
print("connect_mode: " + str(myFrags.connect_mode))

print(" ")

convertToAtoms1 = convert_to_atoms(myFrags)
print("Symbols: " + str(convertToAtoms1))
print("Positions: " + str(convertToAtoms1.positions))

print(" ")

convertToFragment1 = convert_to_fragment(convertToAtoms1)
print("znums: " + str(convertToFragment1.znums))
print("coords: " + str(convertToFragment1.coords))
print("connect_mode: " + str(convertToFragment1.connect_mode))

print(" ")

convertToAtoms2 = convert_to_atoms(convertToFragment1)
print("Symbols: " + str(convertToAtoms2))
print("Positions: " + str(convertToAtoms2.positions))
"""


"""
print("=======")
myAts = Atoms("N2", positions=[(0, 0, 0), (2.5, 0, 0)])
print("N2 as ASE atoms: ", myAts, myAts.positions)
myFr = convert_to_fragment(myAts)
print("N2 as Fragment: ", myFr, myFr.coords)

print("=======")
myFrag = Fragment(znums=[7, 7], coords=[[0, 0, 0], [2.2, 0, 0]])
conversion = convert_to_atoms(myFrag)
print("N2 as ASE atoms", conversion, conversion.positions)
conversion.set_calculator(EMT())
print("Potential Energy: " + str(conversion.get_potential_energy()))
print("=======")
