from chemsh       import *
from chemsh.utils import testutils

ubq_ws = Fragment(coords='ubq_ws.pdb')

namd = NAMD(frag=ubq_ws,
            psf='ubq_ws.psf',
            par='par_all27_prot_lipid.inp',
            pdb='ubq_ws.pdb',
            exclude='scaled1-4',
#            path='/home/ylu/Programs/namd/2.13/Linux-x86_64-g++/namd2',
            binary=False,
           )

md = MD(theory=namd,
        freq_dcd=10,
        freq_chk=10,
        driver='namd',
        minimise=100,
        nsteps=1000,
        nsnapshots=10,
        timestep=2.0,
        temperature=310.0,
        boundary='spherical',
       )

md.run(dryrun=False)


# NAMD trajectory is only reproducible in a serial job
if chemsh.parallel.parallel.nprocs_per_wg == 1:
    snapshot_09 = Fragment(coords='_snapshots/_snapshot_09.pdb')
    ref_09 = Fragment(coords='ubq_snapshot_ref_09.pdb')
    # test coordinates
    testutils.validate(snapshot_09.coords, ref_09.coords, tol=1.0e-10)
else:
    # dummy
    testutils.validate(1, 1)

