Exemplo n.º 1
0
 private void GetPositions(IAtomicSystem system, ref float[] positions)
 {
     for (int i = 0; i < system.NumberOfParticles; i++)
     {
         for (int j = 0; j < 3; j++)
         {
             positions[i * 3 + j] = system.Particles.Position[i][j] * Units.AngstromsPerNm;
         }
     }
 }
Exemplo n.º 2
0
 private void InitialiseFields(IAtomicSystem system)
 {
     if (positions1d == null)
     {
         positions1d = new float[system.NumberOfParticles * 3];
     }
     if (atomElements == null)
     {
         atomElements = new int[system.NumberOfParticles];
         for (int i = 0; i < system.NumberOfParticles; i++)
         {
             atomElements[i] = (int)system.Topology.Elements[i];
         }
     }
 }
Exemplo n.º 3
0
        /// <inheritdoc />
        public float CalculateForceField(IAtomicSystem system, List <Vector3> forces)
        {
            InitialiseFields(system);

            GetPositions(system, ref positions1d);

            float energy;

            using (Py.GIL())
            {
                dynamic result = QmlPredict.calculate(atomElements, positions1d);
                energy = result[0] * kJMolPerHartree;
                dynamic pyForces = result[1];
                CopyForces(pyForces, forces);
                dynamic result2 = QmlPredict.calculate(atomElements, positions1d);
            }
            Console.WriteLine($"Energy: {energy}");
            return(energy);
        }