Sphere inside a box, geometry

Hi everyone,

For the geometry construction, Ho I can build a geometry that is a box that contains a sphere inside?

Thanks in advance

Nicolás

Hello @nviauxma ,

as I understand you are interested in building two separate objects, one inside the other, with different properties. The best way to do it is using the structure of PhysicalVolumes allowing you to create a daughter volume inside a mother volume. Having a look at PVPlacement class constructor, you can see that in order to place a logical volume you need to pass also the pointer to the mother logical volume (https://geant4.kek.jp/lxr/source/geometry/volumes/include/G4PVPlacement.hh#L47). Steps to follow are the following:

  1. Create box solid volume
  2. Create sphere solid volume
  3. Create box logical volume (adding attributes such as material)
  4. Create sphere logical volume (adding attributes such as material)
  5. Place the sphere inside the box using G4PVPlacement
  6. Place the box in your simulation.

This way, everytime you will place the box, it will contain the sphere, as the box logical volume now includes a sphere.

To clarify this, I suggest you to have a look at the Geant4 guide part concerning detector placement (http://geant4-userdoc.web.cern.ch/geant4-userdoc/UsersGuides/ForApplicationDeveloper/html/Detector/Geometry/geomPhysical.html#placements-single-positioned-copy) and you can have a look at more or less every example (the easiest one is B1) and note how geometry elements are always placed inside another volume (but the world volume).

I hope this helps,
Davide

Hi Davide,

I follow your steps, but I get this:

Checking overlaps for volume void …
-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : GeomVol1002
issued by : G4PVPlacement::CheckOverlaps()
Overlap with volume already placed !
Overlap is detected for volume void:0
apparently fully encapsulating volume terrain6660:0 at the same level !
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

This is a warning but I don’t know if the sphere is placed inside the box, with a different material. Or I need to say that the mother volume of the spere is the box?

Best and thanks.

Nicolás

Yes, you should use the box as the mother volume for the sphere.

The main idea when writing geometry is that daughters must not protrude and must not superimpose.

In your case you should pay attention to sphere dimensions (e.g. the sphere radius cannot be bigger than the box size if sphere is in the center), or the sphere will protrude from the box; on the other hand if you use world as the mother of both the box and the sphere, you will have some superimposing daughters (and I think this is the case).

Best regards,
Davide