Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Luter 345 Experiments
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Creating the Simulation Environment
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Get shortened URL
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Summary== A good starting point for any simulation is coding the environment in which the simulation will take place. This happens in two places: the Detector Construction class, and the Primary Generator Action class. The Detector Construction class handles all the objects of the world, like tables, detector components, the atmosphere, etc. The Primary Generator Action class generates particles in the simulation. ==Detector Construction== [[File:Geant4Detect.jpg|center|]] ===The World=== The <span style="color:red">'''world'''</span> is home to all our physics process. Graciously, Geant's developers have implemented and included known materials and physics processes to be used inside of these virtual <span style="color:red">'''worlds'''</span>. Seen in the diagram above, the <span style="color:red">'''world'''</span> can be thought of as Luter Hall which houses many different rooms (<span style="color:blue">'''envelopes'''</span>) within it. Since Luter Hall is our fictitious creation, ideally we would like to model it closely to a real world building that is filled with air. But we are at liberty to abstract our <span style="color:red">'''world'''</span> in any way to augment the current experimental configuration. For Luter Hall to exist we need three essential components: *'''G4VSolid''': To describe a shape, we use a solid volume. The geometry of choice is up to the user. Here we chose to use a G4Box object. *'''G4LogicalVolume''': To characterize a volume's properties we use a logical volume. It includes the geometrical properties of the solid and adds physical characteristics: the material of the volume; whether it contains any sensitive detector elements; the magnetic field; etc. *'''G4PVPlacement''': To position the volume, create a physical volume. This places a copy of the logical volume inside a larger containing volume that includes the coordinate system of the <span style="color:red">'''world'''</span>. Below is an example on how to generate the <span style="color:red">'''world'''</span> volume in the ''Detector Construction Class'': G4double world_sizeXY = <SCALE_FACTOR*envelope_sizeXY>; G4double world_sizeZ = <SCALE_FACTOR*envelope_sizeZ>; G4Material* world_mat = nist->FindOrBuildMaterial(<"MATERIAL">); G4Box* solidWorld = new G4Box("World", //its name 0.5*world_sizeXY, 0.5*world_sizeXY, 0.5*world_sizeZ); //its size G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, //its solid world_mat, //its material "World"); //its name G4VPhysicalVolume* physWorld = new G4PVPlacement(0, //no rotation G4ThreeVector(), //at (0,0,0) logicWorld, //its logical volume "World", //its name 0, //its mother volume false, //no boolean operation 0, //copy number checkOverlaps); //overlaps checking ===The Envelope=== The <span style="color:blue">'''envelope'''</span> is a smaller volume that exists within the <span style="color:red">'''world'''</span>. While the <span style="color:red">'''world'''</span> volume is created to house all inner volumes, the <span style="color:blue">'''envelope'''</span> is where the experiment occurs. In our case, the <span style="color:blue">'''envelope'''</span> can be thought of as Lab 345 that exists within Luter Hall. Inside of the <span style="color:blue">'''envelope'''</span>, other <span style="color:green">'''volumes'''</span> can be placed and interacted with. Typically, these <span style="color:green">'''volumes'''</span> are detectors or materials that the experiment will be centered around. *Below is an example on how to generate the <span style="color:blue">'''envelope'''</span> volume in the ''Detector Construction Class'': G4Box* solidEnv = new G4Box(<"Envelope_Name">, 0.5*env_sizeXY, 0.5*env_sizeXY, 0.5*env_sizeZ); G4LogicalVolume* logicEnv = new G4LogicalVolume(solidEnv, env_mat, "Envelope"); new G4PVPlacement(0, //no rotation G4ThreeVector(), //at (0,0,0) logicEnv, //its logical volume <"Envelope_Name">, //its name logicWorld, //its mother volume false, //no boolean operation 0, //copy number checkOverlaps); //overlaps checking ===Different Types of Volumes=== Inside the <span style="color:blue">'''envelope'''</span> you may place many different types of <span style="color:green">'''volumes'''</span> to interact with. These <span style="color:green">'''volumes'''</span> act as detectors or materials inside of our Lab in Luter 345. Similar to the <span style="color:red">'''world'''</span> and the <span style="color:blue">'''envelope'''</span>, each <span style="color:green">'''volume'''</span> is created by describing its shape and its physical characteristics, but the <span style="color:green">'''volumes'''</span> also inherit the property of ''scoring''. Scoring allows various physical quantities to be tracked while a particle is interacting with the <span style="color:green">'''volume'''</span>. *Below is an example on how to generate a <span style="color:green">'''volume'''</span> in the ''Detector Construction Class'': //MATERIAL & POSITION G4Material* shape1_mat = nist->FindOrBuildMaterial(<"MATERIAL">); G4ThreeVector pos1 = G4ThreeVector(<xPOS>,<yPOS>,<zPOS>); // SHAPE 1 CREATION G4Box* solidShape1 = new G4Box("Bottom Scintillator", //its name <Variables->getScintX()*0.5*cm>, //its x length <Variables->getScintY()*0.5*cm>, //its y length <Variables->getScintZ()*0.5*cm>); //its z length //LOGICAL VOLUME G4LogicalVolume* logicShape1 = new G4LogicalVolume(solidShape1, //its solid shape1_mat, //its material "Bottom Scintillator"); //its name new G4PVPlacement(0, //no rotation pos1, //at position logicShape1, //its logical volume "Bottom Scintillator", //its name logicEnv, //its mother volume false, //no boolean operation 0, //copy number checkOverlaps); //overlaps checking // SHAPE 1 SCORING VOLUME fScoringVolume = logicShape1; ==Particle Generation== ===Required Definitions for Each Particle=== Geant4 provides its users with various types of particles for its simulations. These various types of particles include ordinary particles such as electrons, protons,and gammas. It also lets you define more complex particles such as resonant particles, nuclei and quarks. Each of these particles are represented by their own class which is derived from ''G4ParticleDefinition''. This ''G4ParticleDefinition'' class is basically a library that holds all of the details required for each particle. Before you do an action you must specify which particle you are using during that action. An example code that is defining a gamma particle G4ParticleDefinition* particle = particleTable->FindParticle(particleName="gamma"); As you can see, we call the class ''G4ParticleDefinition'' and we go through this library looking for "gamma", we then set "gamma" to particleName by this code fParticleGun->SetParticleDefinition(particle); After we clarify which particle we want to work with, we then have to set the particles momentum direction and energy level. Here is an example code of us setting the particles momentum and energy level fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.)); fParticleGun->SetParticleEnergy(6.*MeV); Finally, after you pick and clarify which particle you want to use and set its momentum direction and energy level, then you can start an action. ===Algorithm for an Arbitrary Probability Distribution=== Often when generating particles in a simulation, particle energies, directions, and other properties are governed by a probability distribution. This being the case, a simple algorithm for applying arbitrary probability functions in a program is presented below. It should be noted that there are other methods to apply probability distributions and this is not a particularly efficient one, so if a simulation is large it may be beneficial to find another method. However, the method presented is very simple to apply, and thus is a good option for projects when efficiency is not a major concern. (0) Begin loop (1) Choose a random x value (2) Calculate P(x) of the randomly chosen value (must be adjusted, see note below) (3) Choose a random value between zero and one (uniformRand() function) (4) Compare the random number with the probability of the x value in question (4.a) If P(x) > uniRand : keep the value x (exit loop) (4.b) If P(x) < uniRand : discard the value of x (repeat the loop) It is of great important the maximum value of P(x), where x is the classical variable, is one. To achieve this, find the value of x where P(x) is at its maximum, x_max, and divide each P(x) in the algorithm by P(x_max). Using this method the algorithm will return x values in accordance with the defined probability distribution.
Summary:
Please note that all contributions to Luter 345 Experiments may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Luter 345 Experiments:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)