public override void CalculateEnergyTerms(ParticleEnsemble ensemble) { for (int i = 0; i < ensemble.GetMaxNumberOfParticles(); ++i) { for (int j = (i + 1); j < ensemble.GetMaxNumberOfParticles(); ++j) { double MinDist = 2.0 * (ensemble.GetParticleRadius(i) + ensemble.GetParticleRadius(j)); MinimumDistance[i, j] = MinDist * MinDist; MinimumDistance[j, i] = MinimumDistance[i, j]; LJenergyTermA[i, j] = epsilon * Math.Pow(MinDist, 12.0); LJenergyTermA[j, i] = LJenergyTermA[i, j]; LJenergyTermB[i, j] = -2.0 * epsilon * Math.Pow(MinDist, 6.0); LJenergyTermB[j, i] = LJenergyTermB[i, j]; LJgradientTermA[i, j] = -12.0 * LJenergyTermA[i, j]; LJgradientTermA[j, i] = LJgradientTermA[i, j]; LJgradientTermB[i, j] = -6.0 * LJenergyTermB[i, j]; LJgradientTermB[j, i] = LJgradientTermB[i, j]; } } }
// constructor public SoftSpheres(ParticleEnsemble pParticleSet) { epsilon=10.0; // allocate vectors holding positions & forces LJxforces = new List<double>(new double[pParticleSet.GetMaxNumberOfParticles()]); LJyforces = new List<double>(new double[pParticleSet.GetMaxNumberOfParticles()]); // allocate vector holding cutoff distance for calculating Wall-Particle interactions WallDistance = new List<double>(new double[pParticleSet.GetMaxNumberOfParticles()]); // allocate vector holding cutoff distance for calculating particle-particle interaction //Mat_DP tmp(0.0,pParticleSet->GetMaxNumberOfParticles(),pParticleSet->GetMaxNumberOfParticles()); MinimumDistance = new DPMatrix(0, pParticleSet.GetMaxNumberOfParticles(),pParticleSet.GetMaxNumberOfParticles()); // allocate vectors holding particle-particle LJ energy terms LJenergyTermA = new DPMatrix(0, pParticleSet.GetMaxNumberOfParticles(),pParticleSet.GetMaxNumberOfParticles()); // =tmp; LJenergyTermB = new DPMatrix(0, pParticleSet.GetMaxNumberOfParticles(), pParticleSet.GetMaxNumberOfParticles()); // =tmp; LJgradientTermA = new DPMatrix(0, pParticleSet.GetMaxNumberOfParticles(), pParticleSet.GetMaxNumberOfParticles()); // =tmp; LJgradientTermB = new DPMatrix(0, pParticleSet.GetMaxNumberOfParticles(), pParticleSet.GetMaxNumberOfParticles()); // =tmp; CalculateEnergyTerms(pParticleSet); // calculate initial forcefield CalculateForceField(pParticleSet); }