Ejemplo n.º 1
0
        private async void GenerateMonodisperseAggregates_Async_Parallel_AllGenerated()
        {
            var primaryParticles = 2000;
            var numCPU           = 4;
            var rndGen           = new Random();
            var logger           = new Mock <ILogger>().Object;

            var fileASD = _resources + "FSP_AggregateSizeDistribution.xml";
            var distASD = XMLSizeDistributionBuilder <int> .Read(fileASD);

            var config = new TestAggregateFormationConfig(primaryParticles);

            var asd = new TabulatedAggregateSizeDistribution(distASD, rndGen, config, integrate: true);
            var psd = new MonodispersePrimaryParticleSizeDistribution(5);

            var cca     = new ClusterClusterAggregationFactory(psd, config, _logger, _neighborslistFactory, _seed);
            var service = new AggregateFormationService(asd, psd, config, cca, _logger);

            var progress = new Progress <ProgressReportModel>();

            progress.ProgressChanged += ReportProgress;
            var aggs = await service.GenerateAggregates_Parallel_Async(numCPU, progress, _cts.Token);

            Assert.True(aggs.Sum(agg => agg.NumberOfPrimaryParticles) >= primaryParticles);
        }
Ejemplo n.º 2
0
        public void FormClusterOfFourParticlesTest()
        {
            var psd     = new MonodispersePrimaryParticleSizeDistribution(5);
            var pca     = new ParticleClusterAggregationFactory(psd, _rndGen, _config, _neighborslistFactory, _logger);
            var cluster = pca.Build(4);

            Assert.Equal(4, cluster.PrimaryParticles.Count());
            var dist     = Math.Round(cluster.PrimaryParticles[1].Radius + cluster.PrimaryParticles[2].Radius, 6);
            var realDist = cluster.PrimaryParticles[0].GetDistanceToPrimaryParticle(cluster.PrimaryParticles[1]);

            Assert.True(realDist >= _config.Epsilon * dist);
            Assert.True(realDist <= _config.Delta * dist);
        }
Ejemplo n.º 3
0
        public void FormClusterOfTwoParticlesTest()
        {
            var config  = new TestAggregateFormationConfig();
            var psd     = new MonodispersePrimaryParticleSizeDistribution(5);
            var pca     = new ParticleClusterAggregationFactory(psd, _rndGen, _config, _neighborslistFactory, _logger);
            var cluster = pca.Build(2);

            Assert.Equal(2, cluster.PrimaryParticles.Count());
            var dist = Math.Round(config.Epsilon
                                  * (cluster.PrimaryParticles[0].Radius
                                     + cluster.PrimaryParticles[1].Radius), 6);

            Assert.Equal(dist, cluster.PrimaryParticles[0].GetDistanceToPrimaryParticle(cluster.PrimaryParticles[1]));
        }
Ejemplo n.º 4
0
        public void FormClusterOfThreeParticlesTest()
        {
            var logger  = new Mock <ILogger>().Object;
            var config  = new TestAggregateFormationConfig();
            var psd     = new MonodispersePrimaryParticleSizeDistribution(5);
            var rndGen  = new Random(_seed);
            var pca     = new ParticleClusterAggregationFactory(psd, _rndGen, _config, _neighborslistFactory, _logger);
            var cluster = pca.Build(3);

            Assert.Equal(3, cluster.PrimaryParticles.Count());
            var dist     = Math.Round(cluster.PrimaryParticles[0].Radius + cluster.PrimaryParticles[1].Radius, 6);
            var realDist = cluster.PrimaryParticles[0].GetDistanceToPrimaryParticle(cluster.PrimaryParticles[1]);

            Assert.True(realDist >= config.Epsilon * dist);
            Assert.True(realDist <= config.Delta * dist);
        }
Ejemplo n.º 5
0
        private void GenerateMonodisperseAggregates_Sync_AllGenerated()
        {
            var primaryParticles = 2000;

            var psd     = new MonodispersePrimaryParticleSizeDistribution(5);
            var fileASD = _resources + "FSP_AggregateSizeDistribution.xml";

            var distASD = XMLSizeDistributionBuilder <int> .Read(fileASD);

            var config  = new TestAggregateFormationConfig(primaryParticles);
            var asd     = new TabulatedAggregateSizeDistribution(distASD, _rndGen, config, integrate: true);
            var cca     = new ClusterClusterAggregationFactory(psd, config, _logger, _neighborslistFactory, _seed);
            var service = new AggregateFormationService(asd, psd, config, cca, _logger);
            var aggs    = service.GenerateAggregates();

            Assert.True(aggs.Sum(agg => agg.NumberOfPrimaryParticles) >= primaryParticles);
        }
Ejemplo n.º 6
0
        public void FormClusterOfTwentyParticlesTest()
        {
            var psd     = new MonodispersePrimaryParticleSizeDistribution(5);
            var pca     = new ParticleClusterAggregationFactory(psd, _rndGen, _config, _neighborslistFactory, _logger);
            var cluster = pca.Build(20);

            Assert.Equal(20, cluster.PrimaryParticles.Count());
            foreach (var pp1 in cluster.PrimaryParticles)
            {
                foreach (var pp2 in cluster.PrimaryParticles)
                {
                    if (pp1 != pp2)
                    {
                        Assert.True(pp1.GetDistanceToPrimaryParticle(pp2) >= pp1.Radius + pp2.Radius);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public void IsPrimaryParticlePositionValid_CorrectDetectionTest()
        {
            var pp1 = new PrimaryParticle(1, new Vector3(), 4.5);
            var pp2 = new PrimaryParticle(2, new Vector3(4.035344, 0.969021, 7.427756), 4.0);
            var primaryParticles = new List <PrimaryParticle>()
            {
                pp1, pp2
            };

            var pp3           = new PrimaryParticle(3, 5.5);
            var com           = primaryParticles.GetCenterOfMass();
            var setPosition   = new Vector3(-11.098618, 1.316368, -6.026161) + com;
            var psd           = new MonodispersePrimaryParticleSizeDistribution(5);
            var pca           = new ParticleClusterAggregationFactory(psd, _rndGen, _config, _neighborslistFactory, _logger);
            var neighborslist = _neighborslistFactory.Build3DNeighborslist(primaryParticles);
            var check         = pca.IsPrimaryParticlePositionValid(pp3, setPosition, neighborslist, primaryParticles, _config);

            Assert.True(check);
        }