#  Test connectivity for a covalent molecule

from chemsh       import *
from chemsh.utils import testutils
from numpy        import array

def prt(frag):
    print("### frag =\n", frag.coords2str())
    print("### shellatoms =", frag.shellatoms, end='\n\n')
    print("### shells.coreatoms =", frag.shells.coreatoms)
    print("### shells.coords    =", frag.shells.coords)
    print("### shells.charges   =", frag.shells.charges)
    print("### shells.displace  =", frag.shells.displace, end='\n\n')

# ethane
print("\n --------------------")
print("\n before adding shells")
print("\n --------------------\n")
ethane = Fragment(coords='ethane.cjson')
prt(ethane)
ethane.addShells('C')
print("\n --------------------")
print("\n after adding shells")
print("\n --------------------\n")
prt(ethane)

# mgo
print("\n --------------------")
print("\n before adding shells")
print("\n --------------------\n")
mgo = Fragment(coords='mgo.cjson')
prt(mgo)
mgo.addShells('O', factor=0.5, shift=0.5)
print("\n --------------------")
print("\n after adding shells")
print("\n --------------------\n")
prt(mgo)

# mgo
print("\n --------------------")
print("\n before adding shells")
print("\n --------------------\n")
mgo = Fragment(coords='mgo.cjson')
prt(mgo)
mgo.addShells([5,7], [1], factor=0.5, shift=0.5)
print("\n --------------------")
print("\n after adding shells")
print("\n --------------------\n")
prt(mgo)

# mgo
print("\n --------------------")
print("\n before adding shells")
print("\n --------------------\n")
mgo = Fragment(coords='mgo.cjson')
prt(mgo)
mgo.addShells('O', charges={'O':-0.5})
print("\n --------------------")
print("\n after adding shells")
print("\n --------------------\n")
prt(mgo)

# mgo shells
print("\n --------------------")
print("\n before adding shells")
print("\n --------------------\n")
mgo = Fragment(coords='mgo_shells.cjson')
prt(mgo)
mgo.addShells('Mg', factor=0.5, shift=0.5)
print("\n --------------------")
print("\n after adding shells")
print("\n --------------------\n")
prt(mgo)

#testutils.validate(ethane.conn, reference)
