Geometry spherical cap

Hello,

Is it possible to draw a geometry like a spherical cap in GEANT4? I ask this question because I need to divide my geometry into two pieces:

  1. an upper part, spherical cap, to be filled with material X;
  2. a lower part to be filled with material Y.

Can this be done easily? Could you give me some advice?

Does this help?

https://geant4-userdoc.web.cern.ch/UsersGuides/ForApplicationDeveloper/html/Detector/Geometry/geomSolids.html#constructed-solid-geometry-csg-solids

Sphere or Spherical Shell Section:

To build a sphere, or a spherical shell section, use:

G4Sphere(const G4String& pName, G4double pRmin, G4double pRmax, G4double pSPhi, G4double pDPhi, G4double pSTheta, G4double pDTheta )

../../_images/aSphere.jpg

In the picture:

pRmin = 100, pRmax = 120, pSPhi = 0*Degree, pDPhi = 180*Degree, pSTheta = 0 Degree, pDTheta = 180*Degree

Plus there is always the option to use boolean solids, where you subtract the respective other part of the sphere. Solids — Book For Application Developers 11.1 documentation

1 Like

Thanks @weller . I had already thought about this option, but, correct me if I am wrong, it is not possible to build a spherical cap from that construction since there is no way to define the height of the spherical cap.

Yes, another option is Boolean solids… but this way I have no way to scale the geometry of my simulation. But it’s an idea that certainly works.

hm. maybe you are right. it looks like that is not a spherical cap, but spherical sector :frowning:

Exactly, I am quite dejected, there seems to be no way to do this and it seems really strange to me! :confused:

By the way, I’m following your second tip. I have created a box volume which I will use as an object to subtract from the existing blue volume to create the spherical cap:

  G4Box* box = new G4Box("box", r2, r2, 3*cm);

  //associate it to a logical volume as a normal solid
  G4LogicalVolume* logicbox =  new G4LogicalVolume(box,
                                              Olio_Oliva,
                                              "boxLV");

  //define displacements for the shapes                       
   new G4PVPlacement(0,                      // rotation, sostituisci 0 con rotm
                    G4ThreeVector(0,0,-r1/2),    //at (0,0,0)
                    logicbox,                //its logical volume
                    "boxPhys",               //its name
                    logicSferaIntegratrice,  //its mother  volume
                    false,                   //no boolean operation
                    0,                       //copy number
                    fCheckOverlaps);         // checking overlaps

  G4VisAttributes* red = new G4VisAttributes(G4Colour::Red());
  
    red->SetVisibility(true);
    red->SetForceAuxEdgeVisible(true);


    logicbox->SetVisAttributes(red);

Then i made the subtraction:

  G4Box* box = new G4Box("box", r2, r2, 3*cm);

/*
  //associate it to a logical volume as a normal solid
  G4LogicalVolume* logicbox =  new G4LogicalVolume(box,
                                              Olio_Oliva,
                                              "boxLV");

  //define displacements for the shapes                       
   new G4PVPlacement(0,                      // rotation, sostituisci 0 con rotm
                    G4ThreeVector(0,0,-r1/2),    //at (0,0,0)
                    logicbox,                //its logical volume
                    "boxPhys",               //its name
                    logicSferaIntegratrice,  //its mother  volume
                    false,                   //no boolean operation
                    0,                       //copy number
                    fCheckOverlaps);         // checking overlaps

  G4VisAttributes* red = new G4VisAttributes(G4Colour::Red());
  
    red->SetVisibility(true);
    red->SetForceAuxEdgeVisible(true);


    logicbox->SetVisAttributes(red);
*/


  
  G4SubtractionSolid* Calotta_Olio_oliva = 
                new G4SubtractionSolid("Calotta_Olio_oliva", SferaIntegratrice, box);

  //associate it to a logical volume as a normal solid
  G4LogicalVolume* logicCalotta_Olio_oliva =  new G4LogicalVolume(Calotta_Olio_oliva,
                                              Olio_Oliva,
                                              "Calotta_Olio_olivaLV");


  //define displacements for the shapes                       
   new G4PVPlacement(0,                      // rotation, sostituisci 0 con rotm
                    G4ThreeVector(0,0,0),    //at (0,0,0)
                    logicCalotta_Olio_oliva,  //its logical volume
                    "Calotta_Olio_olivaPhys", //its name
                    logicSferaIntegratrice,  //its mother  volume
                    false,                   //no boolean operation
                    0,                       //copy number
                    fCheckOverlaps);         // checking overlaps
  
  G4VisAttributes* green = new G4VisAttributes(G4Colour::Green());
  
    green->SetVisibility(true);
    green->SetForceAuxEdgeVisible(true);


    logicCalotta_Olio_oliva->SetVisAttributes(green);

But doesnt work, infact I don’t see blu geometry

and i receive some errors:

Checking overlaps for volume CilindroPhys:0 (G4Tubs) ... OK! 
Checking overlaps for volume SferaIntegratricePhys:0 (G4MultiUnion) ... OK! 
Checking overlaps for volume Calotta_Olio_olivaPhys:0 (G4SubtractionSolid) ... 
-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : GeomSolids1001
      issued by : G4BooleanSolid::GetPointOnSurface()
Solid - Calotta_Olio_oliva
All 100k attempts to generate a point on the surface have failed!
The solid created may be an invalid Boolean construct!
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------


-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : GeomVol1002
      issued by : G4PVPlacement::CheckOverlaps()
Sample point is not on the surface !
          The issue is detected for volume Calotta_Olio_olivaPhys:0 (G4SubtractionSolid)
          generated point (-23.8274,-165.847,-30) is outside
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

Checking overlaps for volume SiPMPhys:0 (G4Tubs) ... 
-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : GeomSolids1001
      issued by : G4BooleanSolid::GetPointOnSurface()
Solid - Calotta_Olio_oliva
All 100k attempts to generate a point on the surface have failed!
The solid created may be an invalid Boolean construct!
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

Where is the error in the subtraction? Thanks so much.

A spherical cap be defined with G4Ellipsoid.

1 Like

@evc I did it, but I obtain a strange result:

  G4Ellipsoid* solidSfera1 = new G4Ellipsoid("Sfera", r1, r1, r1, -r1, r1);        //its a sphere
  G4Ellipsoid* solidSfera2 = new G4Ellipsoid("Sfera", r1, r1, r1, -r1, r1-0.5*cm);

  G4SubtractionSolid* Calotta_Olio_oliva = 
                new G4SubtractionSolid("Calotta_Olio_oliva", solidSfera1, solidSfera2);

  //associate it to a logical volume as a normal solid
  G4LogicalVolume* logicCalotta_Olio_oliva =  new G4LogicalVolume(Calotta_Olio_oliva,
                                                                  Olio_Oliva,
                                                                  "Calotta_Olio_olivaLV");

  //define displacements for the shapes                       
   new G4PVPlacement(0,                      // rotation, sostituisci 0 con rotm
                    G4ThreeVector(0,0,0),    //at (0,0,0)
                    logicCalotta_Olio_oliva, //its logical volume
                    "Calotta_Olio_olivaPhys",//its name
                    logicCilindro,           //its mother  volume
                    false,                   //no boolean operation
                    0,                       //copy number
                    fCheckOverlaps);         // checking overlaps
    
  
  G4VisAttributes* green = new G4VisAttributes(G4Colour::Green());
  
    green->SetVisibility(true);
    green->SetForceAuxEdgeVisible(true);


    logicCalotta_Olio_oliva->SetVisAttributes(green);

The top part is correct, I don’t understand why I see the bottom part…

It’s a visualisation issue - there is a subtraction of two coincident surfaces, which confuses the boolean subtraction algorithm.

You don’t need to apply subtraction to construct a spherical cap, just use:

  G4Ellipsoid* upperCap = new G4Ellipsoid("Upper_Cap", r1, r1, r1, r1-0.5*cm, r1);
  G4Ellipsoid* lowerCap = new G4Ellipsoid("Lower_Cap", r1, r1, r1, -r1, r1-0.5*cm); 
1 Like

Fantastic! It works so well:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.