When I set the finish of a surface to groundbackpainted or polishedbackpainted, its reflectivity is calculated twice, in other words, effective reflectivity is square of the given parameter. In the attached source code which is modified from ExN06, I set the reflectivity to 20%. But 9613 of 10000 photons are absorbed at a boundary (effective reflectivity is 20% x 20% = 4%!). Please try $ tar zxvf N06.tgz $ cd N06 $ make $ exampleN06 Idle> /control/execute optPhoton.mac Idle> /run/beamOn 10000
Created attachment 72 [details] test code for groundbackpainted and reflectivity
Thanks Akira, for pointing this out. You are absolutely right. The bug was introduced when I allowed: 5th Nov 2009 Peter Gumplinger (op-V09-02-03) G4OpBoundary::PostStepDoIt - all dielectric_dielectric surfaces may now have a reflectivity <1; not only 'frontpainted' as was the case in the past. most certainly upon a user's request to have a simple dielecric interface which was nevertheless not 'perfect'. As you point out, not only 'frontpainted' surfaces have had historically a reflectivity attached to them but also 'backpainted' and the latter decision was/is implemented in the code of DielectricDielectric, while the calling code in G4OpBoundaryProcess.cc was changed to read: else if (type == dielectric_dielectric) { ..... else { if( !G4BooleanRand(theReflectivity) ) { DoAbsorption(); } else { DielectricDielectric(); } when it simply read in the past: else { DielectricDielectric(); } I don't want to change the code in DielectricDielectric(), instead (more spaghetti) I'll change to: else if ( theFinish == polishedbackpainted || theFinish == groundbackpainted ) { DielectricDielectric(); } else { if( !G4BooleanRand(theReflectivity) ) { DoAbsorption(); } else { DielectricDielectric(); } } or a permutation which requires fewer else ifs. Please, try it out. Peter
There is a new tag op-V09-03-01 which will be included in an upcoming patch to 9.3. In the meantime, the new code for (type == dielectric_dielectric) reads: else if (type == dielectric_dielectric) { if ( theFinish == polishedbackpainted || theFinish == groundbackpainted ) { DielectricDielectric(); } else { if ( !G4BooleanRand(theReflectivity) ) { DoAbsorption(); } else { if ( theFinish == polishedfrontpainted ) { DoReflection(); } else if ( theFinish == groundfrontpainted ) { theStatus = LambertianReflection; DoReflection(); } else { DielectricDielectric(); } } }