MCPcopy Create free account
hub / github.com/Geant4/geant4 / BuildMaterialWithNewDensity

Method BuildMaterialWithNewDensity

source/materials/src/G4NistManager.cc:75–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74
75G4Material* G4NistManager::BuildMaterialWithNewDensity(const G4String& name,
76 const G4String& basename, G4double density, G4double temperature, G4double pressure)
77{
78 G4Material* bmat = FindOrBuildMaterial(name);
79 if (bmat != nullptr) {
80 G4cout << "G4NistManager::BuildMaterialWithNewDensity ERROR: " << G4endl;
81 G4cout << " New material <" << name << "> cannot be built because material"
82 << " with the same name already exists." << G4endl;
83 G4Exception("G4NistManager::BuildMaterialWithNewDensity()", "mat101", FatalException,
84 "Wrong material name");
85 return nullptr;
86 }
87 bmat = FindOrBuildMaterial(basename);
88 if (bmat == nullptr) {
89 G4cout << "G4NistManager::BuildMaterialWithNewDensity ERROR: " << G4endl;
90 G4cout << " New material <" << name << "> cannot be built because " << G4endl;
91 G4cout << " base material <" << basename << "> does not exist." << G4endl;
92 G4Exception("G4NistManager::BuildMaterialWithNewDensity()", "mat102", FatalException,
93 "Wrong material name");
94 return nullptr;
95 }
96 G4double dens = density;
97 G4double temp = temperature;
98 G4double pres = pressure;
99 if (dens == 0.0) {
100 dens = bmat->GetDensity();
101 temp = bmat->GetTemperature();
102 pres = bmat->GetPressure();
103 }
104 auto mat = new G4Material(name, dens, bmat, bmat->GetState(), temp, pres);
105 return mat;
106}
107
108//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
109

Callers 13

DefineMaterialsMethod · 0.80
DefineMaterialsMethod · 0.80
ConstructMethod · 0.80
CreateLogicVolumeXYZMethod · 0.80
ConstructMethod · 0.80
MaterialWithDensityMethod · 0.80
MaterialWithDensityMethod · 0.80
DefineMaterialsMethod · 0.80
ConstructMethod · 0.80
SetRedDensityMethod · 0.80
SetGreenDensityMethod · 0.80
SetBlueDensityMethod · 0.80

Calls 5

G4ExceptionFunction · 0.85
GetDensityMethod · 0.45
GetTemperatureMethod · 0.45
GetPressureMethod · 0.45
GetStateMethod · 0.45

Tested by

no test coverage detected