Skip to content

Name duplicates of materials not always checked #195

@ManuelHu

Description

@ManuelHu

Two small test cases, the first checks the name duplicate; the second one does not. The only difference is that no registry is passed in the second element constructor.

from pyg4ometry import geant4 as g4

reg = g4.Registry()

try:
    el=g4.ElementSimple(name="X", symbol="X", Z=1, A=1, registry=reg)
    x = g4.Material(name="X", density=1, number_of_components=1, registry=reg)
    x.add_element_natoms(el, natoms=1)
except Exception as e:
    print("SAME REGISTRY", e)


reg = g4.Registry()

try:
    el=g4.ElementSimple(name="X", symbol="X", Z=1, A=1)  #, registry=reg)
    x = g4.Material(name="X", density=1, number_of_components=1, registry=reg)
    x.add_element_natoms(el, natoms=1)
except Exception as e:
    print("DIFFERENT REGISTRY", e)

output:

SAME REGISTRY Identical material name detected in registry: X

Interestingly, the second still produces a GMDL file that Geant4 can read just fine - i.e. elements and materials appear to have different "namespaces"/stores in Geant4?

Maybe pyg4ometry should also split the names to check? (I know, that would be quite a substantial checks)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions