Message: Random number seed | Not Logged In (login) |
In my simulation I have a xenon cylinder surrounded by 1cm of copper on all sides. My particle gun is set to shoot electrons inside the xenon at random positions with random directions. My knowledge about random number seeds is limited, but here is my question: If I change the thickness of copper that is around the cylinder and re-compile and re-run the simulation, the starting positions for certain events will be slightly different, but some will appear to be the same. I used HepRep::showEngineStatus() at each event, and the "initial seed" is always the same for each event and both simulations. Moreover, if I change the copper thickness back to what it was, my results go back to what they were initially. Is this normal behavior for random number seeds? I assumed that if I am using the same seed, then the starting positions should be the same for both simulations if I am only altering a parameter unrelated to the random numbers. The cylinder is centered at x=y=z=0. Here is my geometry code: //----------- Sizes of the principal geometrical components (solids) -------- G4double innerRadiusOfTheCylinder = 0.*cm; G4double outerRadiusOfTheCylinder = 304.2*cm; G4double heightOfTheCylinder = 304.2*cm; G4double startAngleOfTheTube = 0.*deg; G4double spanningAngleOfTheTube = 360.*deg; G4Tubs* xenon_tube = new G4Tubs("xenon_tube", innerRadiusOfTheCylinder, outerRadiusOfTheCylinder, heightOfTheCylinder, startAngleOfTheTube, spanningAngleOfTheTube); innerRadiusOfTheCylinder = 0.*cm; outerRadiusOfTheCylinder = 309.*cm; heightOfTheCylinder = 309.*cm; startAngleOfTheTube = 0.*deg; spanningAngleOfTheTube = 360.*deg; G4Tubs* copper_tube = new G4Tubs("copper_tube", innerRadiusOfTheCylinder, outerRadiusOfTheCylinder, heightOfTheCylinder, startAngleOfTheTube, spanningAngleOfTheTube); G4double expHall_x = 10.*meter; G4double expHall_y = 10.*meter; G4double expHall_z = 10.*meter; G4Box* experimentalHall_box = new G4Box("experimentalHall_box", expHall_x, expHall_y, expHall_z); G4LogicalVolume* experimentalHall_log = new G4LogicalVolume(experimentalHall_box, Air, "expHall_log"); G4LogicalVolume* copper_log = new G4LogicalVolume(copper_tube, Copper, "copper_log"); G4LogicalVolume* xenon_log = new G4LogicalVolume(xenon_tube, Xenon, "xenon_log"); G4VPhysicalVolume* experimentalHall_phys = new G4PVPlacement(0,G4ThreeVector(), experimentalHall_log, "expHall", 0, false, 0); G4double xenonpos_x = 0.0*meter; G4double xenonpos_y = 0.0*meter; G4double xenonpos_z = 0.0*meter; G4VPhysicalVolume* copper_phys = new G4PVPlacement(0, G4ThreeVector(xenonpos_x, xenonpos_y, xenonpos_z), copper_log, "Copper Can", experimentalHall_log, false, 0); G4VPhysicalVolume* xenon_phys = new G4PVPlacement(0, G4ThreeVector(xenonpos_x, xenonpos_y, xenonpos_z), xenon_log, "xenon", copper_log, false, 0); G4cout << "The solid is a Xenon gas cylinder surrounded with a copper can that is +1cm it's height and radius. " << copper_phys << xenon_phys; Here is the code that is generating the random positions: void ExN02PrimaryGeneratorAction::GeneratePointsInVolume() { G4ThreeVector RandPos; G4double x=0.*cm, y=0.*cm, z=0.*cm; G4double radius=304.2*cm, height=304.2*cm; x = radius*2.*cm; y = radius*2.*cm; while(((x*x)+(y*y)) > (radius*radius)) { x = G4UniformRand(); y = G4UniformRand(); z = G4UniformRand(); x = (x*2.*radius) - radius; y = (y*2.*radius) - radius; z = (z*2.*height) - height; } RandPos.setX(x); RandPos.setY(y); RandPos.setZ(z); G4cout << "Starting position is : " << RandPos << G4endl; particleGun->SetParticlePosition(RandPos); } Any insight would be appreciated. |
Inline Depth: | Outline Depth: | Add message: |
to: |