469 if(fraction < 0.0 || fraction > 1.0) {
470 G4cout <<
"G4Material::AddMaterial ERROR for " << fName <<
" and "
471 << material->
GetName() <<
" mass fraction= " << fraction
474 "Attempt to add material with wrong mass fraction");
477 if (fNumberOfComponents == 0) {
478 fMassFractionVector =
new G4double[fArrayLength];
479 fAtomsVector =
new G4int [fArrayLength];
486 G4int nold = fArrayLength;
487 fArrayLength += nelm - 1;
490 for(
G4int i=0; i<nold; ++i) {
491 v1[i] = fMassFractionVector[i];
492 i1[i] = fAtomsVector[i];
494 delete [] fAtomsVector;
495 delete [] fMassFractionVector;
496 fMassFractionVector = v1;
501 if (fNumberOfComponents < maxNbComponents) {
502 for (
G4int elm=0; elm<nelm; ++elm)
507 while ((el<fNumberOfElements)&&(element!=(*theElementVector)[el])) el++;
508 if (el < fNumberOfElements) fMassFractionVector[el] += fraction
511 theElementVector->push_back(element);
512 fMassFractionVector[el] = fraction
517 ++fNumberOfComponents;
519 fMatComponents[material] = fraction;
522 G4cout <<
"G4Material::AddMaterial ERROR for " << fName <<
" nElement= "
523 << fNumberOfElements <<
G4endl;
525 "Attempt to add more than the declared number of components.");
529 if (fNumberOfComponents == maxNbComponents) {
534 for (i=0; i<fNumberOfElements; ++i) {
535 wtSum += fMassFractionVector[i];
536 Zmol += fMassFractionVector[i]*(*theElementVector)[i]->GetZ();
537 Amol += fMassFractionVector[i]*(*theElementVector)[i]->GetA();
540 G4cout <<
"G4Material::AddMaterial WARNING !! for " << fName
541 <<
" sum of fractional masses "
542 << wtSum <<
" is not 1 - results may be wrong"
545 for (i=0; i<fNumberOfElements; ++i) {
547 G4lrint(fMassFractionVector[i]*Amol/(*theElementVector)[i]->
GetA());
550 ComputeDerivedQuantities();
const G4String & GetName() const
const G4ElementVector * GetElementVector() const
G4GLOB_DLL std::ostream G4cout
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
size_t GetNumberOfElements() const
static constexpr double perThousand
const G4double * GetFractionVector() const