public void BuildAggregateTest() { var cca = new ClusterClusterAggregationFactory(_monoPSD, _config, _logger, _neighborslistFactory, _seed); var agg = cca.Build(24); Assert.Equal(24, agg.NumberOfPrimaryParticles); }
public void TrySetClusterTest() { var pp1 = new PrimaryParticle(1, new Vector3(0, 0, 0), 5); var pp2 = new PrimaryParticle(2, new Vector3(0, 0, 10), 5); var cca = new ClusterClusterAggregationFactory(_monoPSD, _config, _logger, _neighborslistFactory, _seed); var cluster1 = new Cluster(1, new List <PrimaryParticle>() { pp1, pp2 }); var depositedCluster = new List <Cluster> { cluster1 }; var neighborslist = _neighborslistFactory.Build3DNeighborslist(cluster1.PrimaryParticles); var pp3 = new PrimaryParticle(3, new Vector3(0, 0, 30), 5); var pp4 = new PrimaryParticle(4, new Vector3(0, 0, 20), 5); var cluster2 = new Cluster(1, new List <PrimaryParticle>() { pp3, pp4 }); var position = new Vector3(0, 0, 25.02); cluster2.MoveTo(position); var set = cca.IsClusterPositionValid(cluster2, neighborslist, depositedCluster); Assert.True(set); var position2 = new Vector3(0, 0, 24); cluster2.MoveTo(position2); var set2 = cca.IsClusterPositionValid(cluster2, neighborslist, depositedCluster); Assert.False(set2); }
private async void GeneratePolydisperseAggregates_Async_Parallel_AllGenerated() { var primaryParticles = 500; var numCPU = 4; var rndGen = new Random(); var logger = new Mock <ILogger>().Object; var config = new TestAggregateFormationConfig(primaryParticles); var filePSD = _resources + "FSP_PrimaryParticleSizeDistribution.xml"; var dist = XMLSizeDistributionBuilder <double> .Read(filePSD); var psd = new TabulatedPrimaryParticleSizeDistribution(dist, _rndGen, config, integrate: true); var fileASD = _resources + "FSP_AggregateSizeDistribution.xml"; var distASD = XMLSizeDistributionBuilder <int> .Read(fileASD); 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 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); }
public void BuildPolydisperseAggregateTest() { var file = _resources + "FSP_PrimaryParticleSizeDistribution.xml"; var dist = XMLSizeDistributionBuilder <double> .Read(file); var psd = new TabulatedPrimaryParticleSizeDistribution(dist, _rndGen, _config, integrate: true); var cca = new ClusterClusterAggregationFactory(psd, _config, _logger, _neighborslistFactory, _seed); var agg = cca.Build(24); Assert.Equal(24, agg.NumberOfPrimaryParticles); }
public void CorrectClusterSizeTest() { var ccaf = new ClusterClusterAggregationFactory(_monoPSD, _config, _logger, _neighborslistFactory); var clusterSizes = ccaf.GetClusterSizes(20); Assert.Equal(4, ccaf.GetNumberOfCluster(20)); Assert.Equal(new List <int>() { 5, 5, 5, 5 }, clusterSizes); }
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); }
public void FeasiblePositionTest() { var logger = new Mock <ILogger>().Object; var rndGen = new Random(_seed); var cca = new ClusterClusterAggregationFactory(_monoPSD, _config, _logger, _neighborslistFactory, _seed); var pp1 = new PrimaryParticle(1, new Vector3(0, 0, 0), 5); var pp2 = new PrimaryParticle(2, new Vector3(0, 0, 10), 5); var cluster1 = new Cluster(1, new List <PrimaryParticle>() { pp1, pp2 }); var depositedCluster = new List <Cluster> { cluster1 }; var neighborslist = _neighborslistFactory.Build3DNeighborslist(cluster1.PrimaryParticles); var pp3 = new PrimaryParticle(3, new Vector3(0, 0, 25), 5); var pp4 = new PrimaryParticle(4, new Vector3(0, 0, 19), 5); var pp5 = new PrimaryParticle(4, new Vector3(0, 0, 20.02), 5); var(anyNearby1, allFeasible1) = cca.IsPrimaryParticlePositionValid(neighborslist, pp3, depositedCluster.GetPrimaryParticles()); Assert.False(anyNearby1); Assert.True(allFeasible1); var(anyNearby2, allFeasible2) = cca.IsPrimaryParticlePositionValid(neighborslist, pp4, depositedCluster.GetPrimaryParticles()); Assert.True(anyNearby2); Assert.False(allFeasible2); var(anyNearby3, allFeasible3) = cca.IsPrimaryParticlePositionValid(neighborslist, pp5, depositedCluster.GetPrimaryParticles()); Assert.True(anyNearby3); Assert.True(allFeasible3); }
public void NoOverlappingParticlesTest() { var cca = new ClusterClusterAggregationFactory(_monoPSD, _config, _logger, _neighborslistFactory, _seed); var logger = new Mock <ILogger>().Object; var rndGen = new Random(_seed); for (var i = 0; i < 100; i++) { var agg = cca.Build(24); foreach (var pp1 in agg.Cluster.GetPrimaryParticles()) { foreach (var pp2 in agg.Cluster.GetPrimaryParticles()) { if (pp1 != pp2) { var distance = pp1.GetDistanceToPrimaryParticle(pp2); Assert.True(distance >= pp1.Radius + pp2.Radius); } } } } }