Substracting Geometry

I want to create a hollow box. here is the code for it

G4double reflector_thickness = 0.0002*cm;//0.0002*cm;
G4double ReflectorHalfx_in = 20.0000*cm;//PMMA_x;
G4double ReflectorHalfy_in = 6.0000*cm;//;PMMA_y;
G4double ReflectorHalfz_in = 0.4037*cm;//Mylar_z + PSL_halfz + Siz +PMMA_z;
G4double ReflectorHalfx = ReflectorHalfx_in +(2*reflector_thickness);
G4double ReflectorHalfy = ReflectorHalfy_in +(2*reflector_thickness);
G4double ReflectorHalfz = ReflectorHalfz_in +(2*reflector_thickness);

G4Box*solidReflector_out  = new G4Box("solidReflector_out",			//its name
		    ReflectorHalfx/2,ReflectorHalfy/2,ReflectorHalfz/2);	//its size
    G4Box*solidReflector_in  = new G4Box("solidReflector_in",			//its name
		    ReflectorHalfx_in/2,ReflectorHalfy_in/2,ReflectorHalfz_in/2);	//its size			    
solidReflector[0]= new G4SubtractionSolid("Al_reflector0", // name
                         solidReflector_out,  // solid A
                         solidReflector_in);//,  // solid B
    G4LogicalVolume* logicReflector  = new G4LogicalVolume(solidReflector[0],      	//its solid
								AluR  ,	        //its material
								 "solidReflector");		    //its name

G4VPhysicalVolume* physiReflector =new G4PVPlacement(0,          //no rotation
             G4ThreeVector(0,0,0),//		                //poition	
	    logicReflector ,		//its logical volume
	    "solidReflector",		//its name
	    logicWorld,			//its mother  volume
	    false,			//no boolean operation
	    0);			//copy number     

As I understand G4Substraction, it should subtract Bigger Volume - smaller one with respect to bigger volume coordinate but in this case, subtraction coordinate is displaced although I haven’t given any shift in coordinate.
Does anyone have an idea, what’s the problem?

Why do you think that subtraction coordinate is displaced ? The image does not look wrong

Subtraction should have been from the centre

On the image I see a box. What is wrong?

If you read a code, I am trying to make hollow box having wall thickness 2 micron. So, in visualization I would aspect Smaller volume subtracted from bigger Volume. I would visualize as something like following picture (Off course following is not exact picture)

Probably it is a visualisation problem that works in single precision. Try to increase value of reflector_thickness, the problem should disappear.

Regardless of this issue, a better way to define a hollow box is to define solidReflector_in as a daughter volume of solidReflector_out, instead of usage of Boolean subtraction.

1 Like

Thank You evc !!

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