Group Abstract Group Abstract

Message Boards Message Boards

[WSS18] Optimal Packing of Bidisperse Circles

Attachments:
6 Replies

Another idea is to use Compile, which should give much better performance than plain Mathematica code, in particular when the code is procedural (as here) and it doesn't use any high-level functions (i.e. it's basically loops, arithmetic, and list manipulation). I might have missed something but it seemed to me that the only high-level function you used was Nearest.

I'd still be curious about how your current code performs—I just can't run it for the reason I mentioned earlier.

POSTED BY: Szabolcs Horvát

Hmn, I was unaware of Compile's better performance, I'll use it in the future. Thanks!

It looks like an interesting project!

I was hoping to play with your implementation and see how it performs. I downloaded the notebook and evaluated the "Development" section, which seemed to contain the definitions.

Then I evaluated "Numerical Variable Definition" and finally "Global Variables", which gave the error:

Nearest::near1: createDisks[{1,1,1,0.5,0.5,0.5,0.5}[0.5,1,300,0.5,0.9],1]->{1,2} is neither a list of real points nor a valid list of rules.

So I was wondering if the notebook is complete or is missing some bits that are necessary to play with the algorithm.


I was also wondering about the decision to implement the entire algorithm in Mathematica. This looks like a complex and highly procedural algorithm that relies on data structures that Mathematica does not have built-in (min-heap). It seems like exactly that thing that Mathematica does not do well with. Of course it is going to work, but probably very slowly.

Thus, I am curious about what motivated the decision to re-do everything in Mathematica instead of leaving only the data processing and visualization to it (the things it does the best), and what advantages you were able to derive from this choice. How does performance compare to the C++ version? I would expect a difference of orders of magnitude.

Typical reasons one would use Mathematica:

  • You don't know C++. I assume this does not apply since you based it on an existing C++ implementation.
  • Mathematica is good for prototyping. But you went as far as implementing a min heap, which is merely a performance optimization and goes far beyond prototyping.
  • Finally, Mathematica is very good at visualization and data analysis. However, this does not imply that the simulation needs to be in Mathematica.

I will usually write such simulations in C++ and connect them to Mathematica through LibraryLink. Thus I get the best of both worlds. My LTemplate package takes most of the pain out of LibraryLink development. It comes with detailed documentation and many examples. One of the examples shows how to implement an Ising model in C++ and visualize it in Mathematica in real-time.

I use Mathematica daily and I love it. However, I also believe in using the right tool for each job. This is why I advocate for developing more links between Mathematica and other systems.

POSTED BY: Szabolcs Horvát

Hey Szabolcs!

I hadn't obtained that error personally, so I played around until I was able to repeat it. It seems createDisks wasn't evaluated in your nb, it should just be a matter of evaluating the initialization cells.

The intention was part scientific experiment and part learning experience, to try to keep it 100% in WL (otherwise I would indeed do it in C++). Thanks for the package suggestion though, I'll definitely use it.

As for the performance, the average simulation takes a couple minutes, but is highly sensitive on initialization parameters (play around, I want to know how to make it better).

Great project and post! I'm curious about the geometry (fractal?) of the 'fault lines' your algorithm produces large-scale. I would really be interested to see any real materials that mimic those 'fault lines'. Is 3D necessary for that? (wikipedia doesn't mention a 3D algorithm -- is it feasible?)

POSTED BY: Peter Barendse

Thanks Peter! I imagine the fault lines should be strongly dependent on the region format (for now only squares, easily extendable to rectangles). The code should be generalizable to 3D without difficulty, I should try that too.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard