private static string GetBoxDimensionString(IParticleFilm <Aggregate> particleFilm)
        {
            var xdim = $"{DoubleToString(particleFilm.SimulationBox.XDim.Lower)} {DoubleToString(particleFilm.SimulationBox.XDim.Upper)}";
            var ydim = $"{DoubleToString(particleFilm.SimulationBox.YDim.Lower)} {DoubleToString(particleFilm.SimulationBox.YDim.Upper)}";
            var zdim = $"{DoubleToString(particleFilm.SimulationBox.ZDim.Lower)} {DoubleToString(particleFilm.SimulationBox.ZDim.Upper)}";

            return($"ITEM: BOX BOUNDS pp pp pp{Environment.NewLine}{xdim}{Environment.NewLine}{ydim}{Environment.NewLine}{zdim}{Environment.NewLine}");
        }
        public double GetPorosity <T>(IParticleFilm <T> particleFilm, int numberOfLocations)
        {
            var verticalLimits   = GetVerticalFilmLimits(particleFilm);
            var horizontalLimits = GetHorizontalFilmLimits(particleFilm);
            var porosity         = ComputePorosityInLimits(particleFilm, verticalLimits, horizontalLimits, numberOfLocations);

            return(porosity);
        }
 private double[] GetHorizontalFilmLimits <T>(IParticleFilm <T> particleFilm)
 {
     return(new double[]
     {
         0.9 * particleFilm.SimulationBox.XDim.Lower,
         0.9 * particleFilm.SimulationBox.XDim.Upper
     });
 }
        public async Task <IParticleFilm <Aggregate> > BuildFilm_Async(IEnumerable <Aggregate> aggregates, IProgress <ProgressReportModel> progress, double delta, CancellationToken ct)
        {
            ParticleFilm = new TetragonalAggregatedParticleFilm(_simulationBox, _neighborslistFactory);
            var report    = new ProgressReportModel();
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            await ProcessAggregates(aggregates, progress, report, stopwatch, delta, ct);

            return(ParticleFilm);
        }
        private double ComputePorosityInLimits <T>(IParticleFilm <T> particleFilm, double[] verticalLimits, double[] horizontalLimits, int numberOfLocations)
        {
            var poreHits      = 0;
            var neighborsList = _neighborslistFactory.Build3DNeighborslist(particleFilm.PrimaryParticles);
            var maxRadius     = particleFilm.PrimaryParticles.GetMaxRadius();

            for (var i = 0; i < numberOfLocations; i++)
            {
                poreHits += Convert.ToInt32(IsRandomLocationInPore(verticalLimits, horizontalLimits, neighborsList, maxRadius));
            }

            return(poreHits / Convert.ToDouble(numberOfLocations, CultureInfo.InvariantCulture));
        }
        public static async Task <int> GetNumberOfOverlappingPrimaryParticles_Async(IParticleFilm <Aggregate> particleFilm, bool highlightPrimaryParticle)
        {
            var neighborslistFactory = new AccordNeighborslistFactory();
            var neighborslist        = await neighborslistFactory.Build3DNeighborslist_Async(particleFilm.PrimaryParticles);

            var tasks = new List <Task <int> >();

            foreach (var primaryParticle in particleFilm.PrimaryParticles)
            {
                tasks.Add(Task.Run(() => GetPrimaryParticleOverlaps(primaryParticle, particleFilm, neighborslist, highlightPrimaryParticle)));
            }
            var counts = await Task.WhenAll(tasks);

            return(counts.Sum());
        }
 public static void SerializeParticleFilm(IParticleFilm <Aggregate> particleFilm, string filename)
 {
     using var outfile = new StreamWriter(filename);
     outfile.Write($"ITEM: TIMESTEP{Environment.NewLine}0{Environment.NewLine}");
     outfile.Write($"ITEM: NUMBER OF ATOMS{Environment.NewLine}{particleFilm.NumberOfPrimaryParticles}{Environment.NewLine}");
     outfile.Write(GetBoxDimensionString(particleFilm));
     outfile.Write($"ITEM: ATOMS id type aggregate cluster x y z Radius{Environment.NewLine}");
     foreach (var agg in particleFilm.Particles)
     {
         foreach (var cluster in agg.Cluster)
         {
             foreach (var particle in cluster.PrimaryParticles)
             {
                 outfile.Write(GetPrimaryParticleString(particle, cluster, agg));
             }
         }
     }
 }
        public void Export(
            IParticleFilm <Aggregate> particleFilm,
            string filename,
            FileFormat fileFormat,
            bool doUseSI)
        {
            switch (fileFormat)
            {
            case FileFormat.Json:
                _jsonSerializer.Serialize(particleFilm, filename);
                break;

            case FileFormat.Xml:
                _xmlSerializer.Serialize(particleFilm, filename);
                break;

            case FileFormat.LammpsDump:
                _lammpsSerializer.Serialize(particleFilm, filename);
                break;

            default:
                return;
            }
        }
 private double[] GetVerticalFilmLimits <T>(IParticleFilm <T> particleFilm)
 {
     return(new[] { 0.1 * particleFilm.SimulationBox.ZDim.Lower, 0.9 * particleFilm.SimulationBox.ZDim.Upper });
 }
Esempio n. 10
0
 public async Task Run_Async()
 {
     _result = await _filmFormationService.BuildFilm_Async(_aggregates, _progress, _delta, _cts.Token);
 }
        private static int GetPrimaryParticleOverlaps(PrimaryParticle primaryParticle, IParticleFilm <Aggregate> particleFilm, INeighborslist neighborslist, bool highlightPrimaryParticle)
        {
            var neighbors = neighborslist.GetPrimaryParticlesAndDistanceWithinRadius(primaryParticle.Position, primaryParticle.Radius + particleFilm.PrimaryParticles.GetMaxRadius());
            var count     = 0;

            foreach (var neigh in neighbors)
            {
                if (primaryParticle == neigh.Item1)
                {
                    continue;
                }
                if (primaryParticle.Radius + neigh.Item1.Radius - neigh.Item2 > 1e-6)
                {
                    count++;
                    if (highlightPrimaryParticle)
                    {
                        primaryParticle.Type = 2;
                    }
                }
            }
            return(count);
        }