Material definition order


I am a novice GEANT4 user, so I apologize in advance if I’m writting a too basic question (didn’t find here). I was trying to simulate the dose in a G4Sphere by different particles taking as reference the exampleB1.

I defined the sphere material as a mixture of different elements. The problem is that I get different dose values when the material definition order is changed. For example, for ~water:

G4Material* env_mat = new G4Material(name = “env_mat”, 1.000 * g / cm3, ncomponents = 2);
env_mat->AddElement(elO, fractionmass= 88.88);
env_mat->AddElement(elH, fractionmass= 11.12);

G4Material* env_mat = new G4Material(name = “env_mat”, 1.000 * g / cm3, ncomponents = 2);
env_mat->AddElement(elH, fractionmass= 11.12);
env_mat->AddElement(elO, fractionmass= 88.88);

the dose changes as well, as if the mixture was not homegeneous or built as a different material layers.

I’ve modified the code in order to get rid of the default kinematics randomly distributed setting ‘SetParticlePosition(G4ThreeVector(x0, y0, z0))’ to a fixed value of (x0, y0, z0). I’ve also set seeds with the macro command: /random/setSeeds 0 0, but still have different dose values when altering the order of the elements above.

I have also tried to modify the default example by defining the envelope material (H2O as shown before) and get different dose results as well, when “gunning” neutrons.

I appreciate if someone can help me out, cause I don’t know if the results should actually vary and there is a material order standard to define materials or I’m wrong with the code

Thank you in advance.

I think the fraction should be between 0 and 1, and add up to 1. Maybe this could fix it?

G4Material* env_mat = new G4Material(name = “env_mat”, 1.000 * g / cm3, ncomponents = 2);
env_mat->AddElement(elO, fractionmass= 88.88* perCent);
env_mat->AddElement(elH, fractionmass= 11.12* perCent);

Hello weller,

Thank you for your reply and help, adding the “perCent” or putting the fraction between 0 and 1 solves the problem in this case, but when I build a mixture of mixtures, as the aerogel defined in the User’s Guide:

G4Element* elC = …;
G4Material* SiO2 = …;
G4Material* H2O = …;
density = 0.200* g/cm3;
G4Material* env_mat = new G4Material(“env_mat”, density, ncomponents = 3);
env_mat->AddMaterial(SiO2, fractionmass = 62.5* perCent);
env_mat->AddMaterial(H2O , fractionmass = 37.4* perCent);
env_mat->AddElement (elC , fractionmass = 0.1* perCent);

my problem is still there. If I exchange the position of SiO2 and H2O, for example, the dose value varies as well.

I did an exercice similar to you. In exampleB1, implement Aerogel and Aerogel2 (aerogel inverted) and run the attached macro. I join the two output.
aerogel.mac.txt (279 Bytes)
aerogel1.out.txt (2.3 KB)
aerogel2.out.txt (2.3 KB)

When you say “the dose value varies”, can you be more quantitative? With the constituents in a different order, that means that a given random throw will chose something different in the two cases. But over many throws, you’ll get the same statistical populations.

In Michel’s example, you see that the reported results are not identical, but they are statistically equivalent (they differ by much less than the RMS of either one).

Thank you both for your answers, they were very helpful for understanding the problem.

Following your advices I’ve run Michel’s macro for /run/beamOn 1000000 (instead of 100000), and got statistically equivalent results as you explained (10 times greater than Michel for aerogel 1 and 2: in scoring volume 5.39604 microGy and rms=1.98309 nanoGy; vs dose=5.39628 microGy and rms=1.98899 nanoGy for proton), thank you.

However, I would like to know if there could be any way to make the results independent of the mixture order. Further on, I would be also interested in determinining the number of particles that reach a complex detector rather than dose, but I do not know if in this case the large amount of required throws would affect the results. Specially, if secondary particles emerged from the target are discretized as a function of their energy, and variations arising from the different material order of the target would affect their energy and therefore the number of particles registered in a detector?

Thank you again, appreciate your help.

Not without modifications to the Geant4 code, which are not essential to getting the physics right. The lists of constituents within materials are vectors. The random throw picks which vector is chosen. Making that order-independent would mean changing the vectors to sets, and also defining special sorting functions for each class. Lots of work for no physics benefit.

The “basic” answer is sqrt(N) (i.e., simple statistical precision). Throwing more tracks might possibly cause you to see a small number of the extremely rare processes (e.g., photonuclear interactions), but their rarity can’t affect your overall results, just display a couple of outliers.

I don’t know what you mean by,

Particles are tracked continuously, until either their energy reaches zero (due to energy loss interactions), or they decay if appropriate, or they reach the boundary of the world volume. There’s no “discretization” that is done, except in the way that you choose to score hits (e.g., you put information into a binned histogram).

Thank you very much for your prompt and clarifying reply. I think I was not fully aware about the constituents material vectors. It make sense for me now.

I was interested, in a future, in measuring the number of secondary particles, resulting from the interaction of the thrown particles with the target volume, that would reach to an independent detector. I shall write the information into a binned histogram in different energy ranges to analyze the results, so I think I missformulated the question. I was afraid the large number of required throws would affect the number of entries.

Thank you very much for your replies