Beispiel #1
0
        public static void GetPotential_SelfTest(string rootpath, string[] args)
        {
            if (GetPotential_SelfTest_do == false)
            {
                return;
            }

            GetPotential_SelfTest_do = false;
            Namd.Psf psf = Namd.Psf.FromFile(rootpath + @"\Sample\alanin.psf");
            Pdb      pdb = Pdb.FromFile(rootpath + @"\Sample\alanin.pdb");

            Namd.Prm prm = Namd.Prm.FromFileXPlor(rootpath + @"\Sample\alanin.params", new TextLogger());

            Universe univ = Universe.Build(psf, prm, pdb, false);

            List <ForceField.IForceField> frcflds = ForceField.GetMindyForceFields();

            Vector[]    forces  = univ.GetVectorsZero();
            MatrixByArr hessian = null;
            Dictionary <string, object> cache = new Dictionary <string, object>();
            double energy = univ.GetPotential(frcflds, ref forces, ref hessian, cache);
            double toler  = 0.000005;

            HDebug.AssertTolerance(toler, SelfTest_alanin_energy - energy);
            HDebug.AssertTolerance(toler, SelfTest_alanin_energy_bonds - (double)cache["energy_bonds     "]);
            HDebug.AssertTolerance(toler, SelfTest_alanin_energy_angles - (double)cache["energy_angles    "]);
            HDebug.AssertTolerance(toler, SelfTest_alanin_energy_dihedrals - (double)cache["energy_dihedrals "]);
            HDebug.AssertTolerance(toler, SelfTest_alanin_energy_impropers - (double)cache["energy_impropers "]);
            HDebug.AssertTolerance(toler, SelfTest_alanin_energy_nonbondeds - (double)cache["energy_nonbondeds"]);
            HDebug.AssertTolerance(toler, SelfTest_alanin_energy_unknowns - (double)cache["energy_customs   "]);
            HDebug.AssertTolerance(toler, SelfTest_alanin_forces.GetLength(0) - forces.Length);
            for (int i = 0; i < forces.Length; i++)
            {
                HDebug.Assert(forces[i].Size == 3);
                HDebug.AssertTolerance(toler, SelfTest_alanin_forces[i, 0] - forces[i][0]);
                HDebug.AssertTolerance(toler, SelfTest_alanin_forces[i, 1] - forces[i][1]);
                HDebug.AssertTolerance(toler, SelfTest_alanin_forces[i, 2] - forces[i][2]);
            }
        }