コード例 #1
0
            public virtual void Compute(Universe.Nonbonded nonbonded, Vector[] coords, ref double energy, ref Vector[] forces, ref MatrixByArr[,] hessian, double[,] pwfrc = null, double[,] pwspr = null)
            {
                Universe.Atom atom1 = nonbonded.atoms[0];
                Universe.Atom atom2 = nonbonded.atoms[1];
                double        pchij = atom1.Charge * atom2.Charge;

                Compute(coords, ref energy, ref forces, ref hessian, pchij, pwfrc, pwspr);
            }
コード例 #2
0
ファイル: ForceField.PwVdw.cs プロジェクト: htna/explsolv
            public virtual void Compute(Universe.Nonbonded nonbonded, Vector[] coords, ref double energy, ref Vector[] forces, ref MatrixByArr[,] hessian, double[,] pwfrc = null, double[,] pwspr = null)
            {
                Universe.Atom atom1 = nonbonded.atoms[0];
                Universe.Atom atom2 = nonbonded.atoms[1];
                double        radi  = atom1.Rmin2;
                double        radj  = atom2.Rmin2;
                double        epsi  = atom1.epsilon;
                double        epsj  = atom2.epsilon;

                Compute(nonbonded, coords, ref energy, ref forces, ref hessian, radi, radj, epsi, epsj, pwfrc, pwspr);
            }
コード例 #3
0
            // electrostatic
            public static PPotential Elec(Universe.Nonbonded nonbonded, Vector[] coords, double ee)
            {
                Universe.Atom atom1 = nonbonded.atoms[0]; Vector coord1 = coords[atom1.ID];
                Universe.Atom atom2 = nonbonded.atoms[1]; Vector coord2 = coords[atom2.ID];

                //double ee = 1; // 80

                double pch1 = atom1.Charge;
                double pch2 = atom2.Charge;

                return(Elec(coord1, coord2, pch1, pch2, ee));
            }
コード例 #4
0
            // Lennard-Jones
            public static PPotential LJ(Universe.Nonbonded nonbonded, Vector[] coords)
            {
                Universe.Atom atom1 = nonbonded.atoms[0]; Vector coord1 = coords[atom1.ID];
                Universe.Atom atom2 = nonbonded.atoms[1]; Vector coord2 = coords[atom2.ID];

                double rad1 = atom1.Rmin2;
                double rad2 = atom2.Rmin2;
                double eps1 = atom1.epsilon;
                double eps2 = atom2.epsilon;

                return(LJ(coord1, coord2, rad1, rad2, eps1, eps2));
            }
コード例 #5
0
            public virtual void Compute(Universe.Nonbonded nonbonded, Vector[] coords, ref double energy, ref Vector[] forces, ref MatrixByArr[,] hessian, double[,] pwfrc = null, double[,] pwspr = null)
            {
                Universe.Atom atom1 = nonbonded.atoms[0];
                Universe.Atom atom2 = nonbonded.atoms[1];
                double        radij = (atom1.Rmin2 + atom2.Rmin2);

                if (divideRadijByTwo)
                {
                    radij = radij / 2;
                }
                double epsij = Math.Sqrt(atom1.epsilon * atom2.epsilon);

                Compute(coords, ref energy, ref forces, ref hessian, radij, epsij, pwfrc, pwspr);
            }
コード例 #6
0
            public void BuildHess4PwIntrAct(Universe.AtomPack info, Vector[] coords, out Pair <int, int>[] pwidxs, out PwIntrActInfo[] pwhessinfos)
            {
                Universe.Nonbonded nonbonded = (Universe.Nonbonded)info;

                HDebug.Depreciated("check idx1 and idx2");
                int idx1 = 0; // nonbonded.atoms[0].ID;
                int idx2 = 1; // nonbonded.atoms[1].ID;

                Universe.Atom atom1 = nonbonded.atoms[0];
                Universe.Atom atom2 = nonbonded.atoms[1];
                double        pchij = atom1.Charge * atom2.Charge;

                if (double.IsNaN(pchij))
                {
                    HDebug.Assert(false);
                    pwidxs      = null;
                    pwhessinfos = null;
                    return;
                }

                Vector diff = (coords[idx2] - coords[idx1]);
                double dx   = diff[0];
                double dy   = diff[1];
                double dz   = diff[2];
                double pchi = atom1.Charge;
                double pchj = atom2.Charge;
                double ee   = 80;

                // !V(Lennard-Jones) = Eps,i,j[(Rmin,i,j/ri,j)**12 - 2(Rmin,i,j/ri,j)**6]
                // !epsilon: kcal/mole, Eps,i,j = sqrt(eps,i * eps,j)
                // !Rmin/2: A, Rmin,i,j = Rmin/2,i + Rmin/2,j
                //
                // V(rij) =           (332 * pchij / ee) * rij^-1
                // F(rij) = (   -1) * (332 * pchij / ee) * rij^-2
                // K(rij) = (-2*-1) * (332 * pchij / ee) * rij^-3
//                double pchij = pchi * pchj;
                double rij2 = dx * dx + dy * dy + dz * dz;
                double rij  = Math.Sqrt(rij2);
                double rij3 = rij2 * rij;
                double fij  = (-1) * (332 * pchij / ee) / rij2;
                double kij  = (-2 * -1) * (332 * pchij / ee) / rij3;

                pwidxs         = new Pair <int, int> [1];
                pwidxs[0]      = new Pair <int, int>(0, 1);
                pwhessinfos    = new PwIntrActInfo[1];
                pwhessinfos[0] = new PwIntrActInfo(kij, fij);
            }
コード例 #7
0
        public static bool GetPwEnrgFrcSprNbnd(bool vdW, bool elec
                                               , Universe.Nonbonded nonbonded
                                               , IList <Vector> coords
                                               , double D // = 80 // dielectric constant
                                               , out double Eij
                                               , out double Fij
                                               , out double Kij
                                               )
        {
            Eij = Fij = Kij = double.NaN;

            Universe.Atom atom0 = nonbonded.atoms[0];
            Universe.Atom atom1 = nonbonded.atoms[1];
            int           id0   = atom0.ID; if (coords[id0] == null)
            {
                return(false);
            }
            int id1 = atom1.ID; if (coords[id1] == null)
            {
                return(false);
            }

            Vector coord0 = coords[id0];
            Vector coord1 = coords[id1];

            double ri0 = atom0.Rmin2;
            double rj0 = atom1.Rmin2;
            double qi  = atom0.Charge;
            double qj  = atom1.Charge;
            double ei  = atom0.epsilon;
            double ej  = atom1.epsilon;

            GetPwEnrgFrcSprNbnd(vdW, elec
                                , coord0, ri0, qi, ei
                                , coord1, rj0, qj, ej
                                , D
                                , out Eij, out Fij, out Kij
                                );
            return(true);
        }