Repository navigation
Conversation
G4OpBoundaryProcess uses a reflectivity of 1 when the surface has no REFLECTIVITY property (and no complex refractive index), so TRANSMITTANCE and EFFICIENCY have no effect. Celeritas instead built a grid reflectivity of 0 whenever TRANSMITTANCE or EFFICIENCY was present, turning such surfaces into absorbers. Use the Fresnel (always-interact) reflectivity in that case, warn about the ignored properties, and warn about unsupported complex refractive index properties. Assisted-by: Claude Code (Claude Opus 5.5)
Test summary 8 214 files 13 506 suites 16m 15s ⏱️ Results for commit fa07d93. ♻️ This comment has been updated with latest results. |
|
As you state with the Geant4 implementation, this behavior is dependent on surface type and potentially future surface models. If we want to strictly match the Geant4 defaults, we can just set the reflectivity grid to unity, which will most closely reproduce the Geant4 logical flow. In general we should be careful about the grid reflectivity implementation since it's still unclear whether it's semantically meaningful and if we even want to replicate the Geant4 behavior. We should be more strict in checking input in the meantime. |
If only TRANSMITTANCE or EFFICIENCY is given, use the grid model with reflectivity one and transmittance zero instead of the Fresnel model. The transmittance must be zero because the grid model samples transmission before interaction. Also check the transmittance and efficiency grids in the surface importer test. Assisted-by: Claude Code (Claude Opus 5.5)
|
🤖 (Claude Code, Claude Opus 5.5) Thanks, switched to a unit reflectivity grid in 9dd61f8. When only On stricter input checking: these cases currently log a warning. Would you prefer an error ( |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2691 +/- ##
===========================================
- Coverage 86.09% 85.96% -0.14%
===========================================
Files 1415 1420 +5
Lines 45459 45534 +75
Branches 11652 11664 +12
===========================================
+ Hits 39140 39144 +4
+ Misses 4607 4605 -2
- Partials 1712 1785 +73
🚀 New features to boost your workflow:
|
It's probably safest for us to VALIDATE if there's an ambiguous input that results in known different behavior for Celeritas and Geant4. If it's possible, we should stack the ambiguous Geant4 inputs from multiple surfaces/materials together, with recommendations for how to fix them. I want to avoid an iterative process where the user has to repeatedly run celeritas, fix one material, hit the next error, fix that, etc. (Warnings/error messages avoid that.) I think it's good to encourage users to be explicit about the behavior of the optical properties. |
Replace the warnings and unit reflectivity fallback with an error if TRANSMITTANCE or EFFICIENCY is given without REFLECTIVITY, or if REALRINDEX or IMAGINARYRINDEX is given. Geant4 uses the complex index for repeated reflections from metals even if REFLECTIVITY is given. Report all the reflectivity errors for a surface together, with recommended fixes. Advance the surface index after a failure so that partially inserted data does not cause a spurious duplicate error that hides the errors in subsequent surfaces. Assisted-by: Claude Code (Claude Opus 5.5)
|
🤖 (Claude Code, Claude Opus 5.5) Done in 15cddb4:
This combines errors across surfaces only. Other processes, such as scintillation (per material), have separate handlers, so a failure in one of those can still be reported in a separate run. Combining them would need a handler shared across processes, which I'd suggest leaving to a separate PR. |
|
🤖 (Claude Code, Claude Opus 5.5) The |
|
🤖 (Claude Code, Claude Opus 5.5) Thanks for rerunning this. |
|
@hhollenb I've recommended throwing errors where we think missing data is ambiguous/error-prone. Reasonable? |
hhollenb
left a comment
There was a problem hiding this comment.
There seems to be some conflation of grid reflectivity and complex refractive index here. Also some over-complication of the import logic and testing.
Move the complex refractive index check into check_unimplemented_properties, which is now called for every surface. GROUPVEL is dropped from that list because Geant4 adds it whenever RINDEX is given (e.g. back-painted surfaces). insert_reflectivity uses Fresnel when no grid property is given and otherwise requires REFLECTIVITY. Assisted-by: Claude Code (Claude Opus 5.5) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nter Per review: keep the original condition and if/else structure in insert_reflectivity (validate REFLECTIVITY inside the grid branch, Fresnel in the else branch), which also shrinks the diff against develop. Document current_surface_ in the class and the postcondition of operator(): the counter is left at the next unused physics surface ID, including after a failed surface. Assisted-by: Claude Code (Claude Opus 5.5) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Changes were addressed. Thanks again @hholenb!
016943a
In
GeantSurfacePhysicsLoader::insert_reflectivity, if a surface hasTRANSMITTANCEorEFFICIENCYbut noREFLECTIVITY, the missing reflectivity is set to a constant 0.REALRINDEXandIMAGINARYRINDEXare silently ignored.Geant4.
G4OpBoundaryProcessstarts each step withfReflectivity = 1and only overrides it fromREFLECTIVITYor, if that is missing and bothREALRINDEXandIMAGINARYRINDEXare given, fromCalculateReflectivity. It absorbs ifrand > R + Tand transmits ifrand > R, soTRANSMITTANCEandEFFICIENCYhave no effect on these choices when R = 1.DielectricMetalalso callsCalculateReflectivityfor repeated reflections if both indices are given, even withREFLECTIVITY.Consequence. In Celeritas, a surface with only
EFFICIENCYabsorbs every photon (a perfect absorber or detector), and a surface with onlyTRANSMITTANCEtransmits with probability T and absorbs the rest. Geant4 does neither for these surfaces. Results can also differ for surfaces with a complex refractive index.Fix. Raise an error if:
TRANSMITTANCEorEFFICIENCYis given withoutREFLECTIVITY(ambiguous), orREALRINDEXorIMAGINARYRINDEXis given, with or withoutREFLECTIVITY(not supported).Each error names the surface, lists all of its reflectivity problems and recommends fixes. All invalid surfaces are reported in one import:
GeantPhysicsLoaderalready collects the exceptions, but a failed surface left partial data that could cause a spurious "duplicate" assertion in the next one, hiding its actual error. The surface index now advances after a failure. Other surfaces are imported as before.Test. The new
invalid-optical-surfaces.gdmlhas six invalid surfaces (TRANSMITTANCEand/orEFFICIENCYonly, and complex index alone, withREFLECTIVITY, and withTRANSMITTANCE) and two valid ones. The test checks that one import reports exactly the expected errors for all six, and it fails without the surface index change.full-optical-surfaces.gdmlhas a new valid surface with all three grids, andoptical/SurfaceImporternow also compares the transmittance and efficiency grids. The CPUoptical/Surface*andGeantImportertests pass (Debug build, Geant4 11.4.3, no GPU).Related: #2514 (comparing efficiency/reflectivity handling with Geant4). Downstream, dielectric_metal surfaces still go through the interactor behaviour reported in #2682.
@github-actions label physics
🤖 Generated with Claude Code (Claude Opus 5.5)