jacg / nain4

An API that makes it easier to write Geant4 application code.
https://jacg.github.io/nain4/
2 stars 3 forks source link

Add explanation on boolean solids vs nested volumes #95

Open gonzaponte opened 1 year ago

gonzaponte commented 1 year ago

The gist of it is that boolean solids are less efficient and for the majority of cases it is better to use nested volumes; even if it implies doing something silly like placing an air volume inside a steel volume inside an air volume.

jacg commented 1 year ago

Not sure what is silly about air in steel in air.

The point is that placing any volume entirely within another effectively is a boolean subtraction solid. This is how G4 geometries are designed to work.

You should not use boolean solids for anything that can be done (without too many contortions) with plain old placement.

Examples of what you should not do with boolean solids (because placement works just fine):

Examples of things that might sensibly be done with boolean solids:

In summary, I think that boolean solids are a reasonable approach if you combine two volumes which have a non-trivial[^2] intersection.

[^1]: The official G4 name is "solid" but it's a really crap and misleading name: conceptually they are shapes and most definitely not solids. [^2]: The intersection is neither empty, nor the whole of one of the volumes.

gonzaponte commented 1 year ago

Not sure what is silly about air in steel in air.

There is nothing silly about it in reality, but it might sound silly depending on how people think about it. And we must not assume that they think in a very specific way.