Beispiel #1
0
		public override void CalculateEnergyTerms(ParticleEnsemble ensemble)
		{
			for (int i = 0; i < ensemble.GetMaxNumberOfParticles(); ++i)
			{
				for (int j = (i + 1); j < ensemble.GetMaxNumberOfParticles(); ++j)
				{
					double MinDistance = 2.0 * (ensemble.GetParticleRadius(i) + ensemble.GetParticleRadius(j));

					MinimumDistance[i, j] = MinDistance;
					MinimumDistance[j, i] = MinDistance;
					LJenergyTermA[i, j] = epsilon * Math.Pow(MinDistance, 12.0);
					LJenergyTermA[j, i] = LJenergyTermA[i, j];
					LJenergyTermB[i, j] = -2.0 * epsilon * Math.Pow(MinDistance, 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];
				}
			}
  
		}
Beispiel #2
0
		// constructor
		public SoftSpheres(ParticleEnsemble pParticleSet)
		{
  
			epsilon=10.0;
	
			// allocate vectors holding positions & forces
			LJxforces = new double[pParticleSet.GetMaxNumberOfParticles()];
			LJyforces = new double[pParticleSet.GetMaxNumberOfParticles()];
  
			// allocate vector holding cutoff distance for calculating Wall-Particle interactions
			WallDistance = 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);
  
		}