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
106 stars 43 forks source link

[newb] Generating a polydisperse packing #6

Open HellFirePvP opened 6 years ago

HellFirePvP commented 6 years ago

Dear all,

now i probably might not use this for what it's meant to be used for, given that (from what i can gather) that this project is mainly targeting a problem in chemistry. (?) I'm looking to generate a polydisperse sphere packing into a given 3D space as the parameters in the configuration (generation.conf) seem to allow me to do. Unfortunately, i don't have access to matlab, so i wrote myself a java parser for the results, which showed me that the spheres all end up with the same diameter, seemingly regardless of which routine i attempt.

To get straight to the point, what i am looking for is generating a sphere packing which is very dense, has random diameters in range between 20-50 units in a 200 x 250 x 200 space. Now while this project looks to have the tools necessary to create such a packing, i can't figure out how to properly use it to generate such a result, nor do i have (without creating a large amount of work) a tool necessary to visualize the result in a insightful manner.

So my questions are if this program is capable of generating such a packing and in case it is, what am i supposed to do to get this to generate such packings? Any help would be greatly appreciated.

Best regards, HellFire

VasiliBaranov commented 6 years ago

Dear HellFire,

I think the areas where i used the project cover both physics and chemistry, because packings of spheres is a popular and relevant model in many areas of science and engineering. I was doing more theoretical physics at the end of the phd, but the group specializes on chemistry and chemical engineering.

Anyway, i think the easiest way to generate a polydisperse packing is to supply the file packing.xyzd with particle coordinates (random) and needed diameters and specify in the generatuon.conf that you do NOT want to start generation from scratch. Alternatively, you can start generation from scratch, but then provide the diameters.txt file with needed diameters. Please see the readme file for all the details.

I also have a C# code somewhere to read and write binary files like packing.xyzd.

As for visualization, i used matlab for that. You can use python or maybe java. Then, i used the program called VMD (visual molecular dynamics), it accepts text files in a simple format (each line is "x y z d" plus a small header). To get very nice pictures, i used POVRay, just provide a scene full of spheres. I think i need to add a section on visualization, though..

Hope this helps!

Best Regards, Vasili

HellFirePvP commented 6 years ago

Dear Vasili,

first of all, i didn't expect a response this quickly, so thank you very much for your time.

I did some generations now with starting off of some randomly placed spheres and it seems to have turned out pretty well. This is the bits of java code that generated the random placement: https://gist.github.com/HellFirePvP/c03da8559a524d0cbc1e8f2bd619b393 Looking from the results after running the program on it, the results look to be quite great.

I did try VMD to visualize the results and have converted the xyzd into the text format VMD expects for the XYZ data import, however, it seems the diameter is lost after parsing and all it ended up was a dense field of points which i assume are the positions of the spheres. A (rather low fps) gif showing the result i got from one generation: https://i.imgur.com/G36PJYO.gifv

So overall, this worked out quite good. Further instructions on visualization would be appreciated as the suggested programs seem to be, while very capable of loading and visualizing a large variety of things, rather complex.

Thank you for your fast help.

Best Regards, HellFire

VasiliBaranov commented 6 years ago

Dear HellFire,

yeah, that's roughly the code that i had in mind. Though the program presumes periodic boundary conditions, so you could have written double posX = minX + (maxX - minX) * r.nextDouble()); and so on for posY and posZ.

As for the VMD, yes, it might be an overkill, but i used the following for quick visualizations. There is another format, pqr, which vmd supports. It's very easy, you specify in a csv manner atom coordinates, then "charge" (which in our case can be always zero), and an atom diameter. Each line can look as follows: ATOM \<zero-based index> H T 1 \<x> \<y> \<z> 0.0 \<d> E.g. ATOM 36 H T 1 -11.921 26.307 10.410 0.0 1.8500 H and T here are some random names that for real atoms are supposed to have meaning. Zero is the charge. The C++ code that was writing converted pqr files looked like this:

    cout << "ATOM" << seven_spaces 
         << pointIdx << two_spaces 
         << "H" << four_spaces 
         << "T" << four_spaces
         << 1 << four_spaces 
         << x << two_spaces 
         << y << two_spaces 
         << z << two_spaces 
         << "0.0" << two_spaces 
         << diameter << endl;
    ++pointIdx;

There shall be no special header for the file.

Next, you load the file in the VMD and specify that you want to display atoms as spheres.

Here is how to load a molecule.

Then, you go to Graphics->Representations, set Drawing Method to VDW (drawing atoms as spheres), set Coloring Method to Name (which was always "H") and set Scale to 0.5. Here are more details. It shall be it.

Hope this helps.

Best Regards, Vasili

VasiliBaranov commented 6 years ago

P.S. I think it shall be a plain ASCII file, though maybe UTF will also work.