jacg / nain4

An API that makes it easier to write Geant4 application code.
https://jacg.github.io/nain4/
2 stars 3 forks source link

Material properties not found when adding G4OpticalPhysics to the physics list #74

Closed Hiitsaso closed 1 year ago

Hiitsaso commented 1 year ago

I have gammas going through a volume with mesh_mat material. When adding G4OpticalPhysics to the physics list I get the following error:

*** G4Exception : mat202
      issued by : G4MaterialPropertiesTable::GetConstProperty()
Constant Material Property Index 11 not found.
*** Fatal Exception *** core dump ***
G4Track (0x55baafd7bc40) - track ID = 1, parent ID = 0
 Particle type : gamma - creator process : not available
 Kinetic energy : 100 keV - Momentum direction : (0.251554,-0.00207847,0.967841)
 Step length : 77.4921 um  - total energy deposit : 0 eV
 Pre-step point : (-7.50294,-7.92732,4.505) - Physical volume : cathode (mesh_mat)
 - defined by : Transportation - step status : 1
 Post-step point : (-7.48345,-7.92748,4.58) - Physical volume : GasVessel (GAr)
 - defined by : Transportation - step status : 1
 *** Note: Step information might not be properly updated.

It seems that it is failing to find some (optical?) properties of the mesh_mat material. I have traced the error to this section of the code:

   G4MaterialPropertiesTable* xenon_pt = GXe_properties(pressure, temperature, sc_yield, e_lifetime);
   return n4::material_properties()
     .add("ABSLENGTH"                   , optPhotRangeE_, abs_length)
     .NEW("WORK_FUNCTION"               ,                 stainless_wf)
     .NEW("OP_PHOTOELECTRIC_PROBABILITY",                 photoe_p)
     .copy_from(xenon_pt, {
       "SCINTILLATIONCOMPONENT1",
       "SCINTILLATIONCOMPONENT2"})
     .copy_NEW_from(xenon_pt, {
       "SCINTILLATIONTIMECONSTANT1",
       "SCINTILLATIONTIMECONSTANT2",
       "SCINTILLATIONYIELD",
       "SCINTILLATIONYIELD1",
       "SCINTILLATIONYIELD2",
       "RESOLUTIONSCALE",
       "ATTACHMENT"})
     .done();

and I suspect that it comes from the .copy_form and/or .copy_NEW_from attributes.

gonzaponte commented 1 year ago

I suspect the bug comes from an error in xenon_pt itself that we found while refactoring your code. Do you have the latest version of your code uploaded somewhere?

Hiitsaso commented 1 year ago

You can find the code here. To reproduce the error just run just run 1000.

Hiitsaso commented 1 year ago

The issue was resolved by updating the nain4 version to v0.1.8.