Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!
_Geant4 Version: 10.7
_Operating System: Ubuntu WSL
_Compiler/Version: -
_CMake Version: 3.23.0
Evaluating TID in a 3 layers PCB for space LEO missions, I’m finding an error on the computation of the mass of the object.
OUT
Layer 1
Total energy accumulated: 9.38297e-12 eV
Density (kg/m³) di Ground: 2699
Mass Ground: 1.34767e+22 kg (2.1592 g )
Dose (TID): 6.96238e-34 Gy
Fluence totale: 12.757 particles/cm^2 (unità scorer)
Volume (mm^3) di Ground: 800
Mass calculated (kg): 1.34767e+22
[…] with a mass calculated proportional to e+22
here part of the code (RunAction.cc)
void RunAction::EndOfRunAction(const G4Run*)
{
std::vector volumeNames = { “Patch”, “Dielectric”, “Ground” };
for (size_t i = 0; i < volumeNames.size(); ++i) {
G4LogicalVolume* logicVolume = GetLogicalVolumeByName(volumeNames[i]);
if (!logicVolume) {
G4cerr << "Volume logico " << volumeNames[i] << " non trovato!" << G4endl;
continue;
}
double volume = logicVolume->GetSolid()->GetCubicVolume();
double volume_m3 = volume * mm3; // da mm³ a m³
double density = logicVolume->GetMaterial()->GetDensity();
//double density_m3 = density * 0.0000000001;
double mass = volume_m3 * density;
if (mass <= 0) {
G4cerr << "Massa del volume" << volumeNames[i] << "non valida!" << G4endl;
continue;
}
double edep_J = fTotalEdep[i] * eV; // Converti da eV a Joule
double dose = edep_J / mass;
G4cout << "\n>>> Layer " << (i + 1) << " (" << volumeNames[i] << "):" << G4endl;
G4cout << " Energia totale depositata: " << G4BestUnit(fTotalEdep[i], "Energy") << G4endl;
G4cout << "Densità (kg/m³) di " << volumeNames[i] << ": " << density / (kg / m3) << G4endl;
G4cout << "Mass " << volumeNames[i] << ": " << mass << " kg (" << G4BestUnit(mass, "Mass")<<")" << G4endl;
G4cout << "Dose (TID): " << G4BestUnit(dose, "Dose") << G4endl;
G4cout << "Fluence totale: " << fTotalFluence[i] << " particles/cm^2 (unità scorer)" << G4endl;
G4cout << "Volume (mm^3) di " << volumeNames[i] << ": " << volume << G4endl;
G4cout << "Densità (kg/m^3) di " << volumeNames[i] << ": " << density / (kg / m3) << G4endl;
//G4cout << "Massa calcolata (kg): " << mass << G4endl;
}
}
any suggestions?