VasiliBaranov / packing-generation

Hard-sphere packing generation in C++ with the Lubachevsky–Stillinger, Jodrey–Tory, and force-biased algorithms and packing post-processing.
MIT License
102 stars 44 forks source link

Random generation of sphere positioning during packing #23

Open RajeshC018 opened 3 years ago

RajeshC018 commented 3 years ago

Hi Vasili,

I am investigating the microstructure of materials using Voronoi tesselation based on randomized sphere packing. Your work is well programmed and documented for implementation. Thank you!

I need to generate a randomized sphere packing for the same input diameter distribution, i.e., different sphere positions in the packing resulting in the same size distribution. Currently, for a particular diameter distribution, the algorithm always generates the same output. Is there any input parameter to randomize the outputs?

What is the seeds parameter in a 'generation.conf' file responsible for? Does it control the randomization?

Thank you, Rajesh

VasiliBaranov commented 3 years ago

Dear Rajesh,

you are right, the "seed" parameter in the config specifies the seed for random number generation. You have to change it to get different results. See http://www.cplusplus.com/reference/cstdlib/srand/

Please refer to this section for the seed and other parameters: https://github.com/VasiliBaranov/packing-generation#13-parameter-description

Best Regards, Vasili

RajeshC018 commented 3 years ago

Thank you for your reply!

I have another question regarding your code.

Is it possible to define a particular distance (unique) to be obtained between the spheres? If yes, could you please explain which part of the code should be modified?

Thanks, Rajesh

VasiliBaranov commented 3 years ago

Hi Rajesh,

if you go to the branch https://github.com/VasiliBaranov/packing-generation/tree/feature/SuccessfulPermutationProbability , you can use an option -nnc, it shall save nearest neighbors for each particle.

You can track how this is calculated by going through these links:

https://github.com/VasiliBaranov/packing-generation/blob/4572b7b3f66c02a3415b9df17cdab2b31fe0bf60/PackingGeneration/Execution/Source/PackingTaskFactory.cpp#L210

https://github.com/VasiliBaranov/packing-generation/blob/4572b7b3f66c02a3415b9df17cdab2b31fe0bf60/PackingGeneration/Execution/Source/PackingGenerationTask.cpp#L272

https://github.com/VasiliBaranov/packing-generation/blob/4572b7b3f66c02a3415b9df17cdab2b31fe0bf60/PackingGeneration/Generation/GenerationManager.cpp#L157

https://github.com/VasiliBaranov/packing-generation/blob/4572b7b3f66c02a3415b9df17cdab2b31fe0bf60/PackingGeneration/Generation/GenerationManager.cpp#L611

And then distanceService->FillClosestPairs.

But maybe it will be easier for you just to write a small Python script to do whatever post-processing is needed for your task, because the C++ code needs some initial time investment probably.. Maybe the Python code will be slower, and you can even implement it without any optimizations, but if it is a one-time task, it will probably be easier. Hope this helps.

Best Regards, Vasili