|
| 1 | +#!/usr/bin/env python3 |
| 2 | +from gconfiguration import autogeometry |
| 3 | +from gvolume import GVolume |
| 4 | +from gmaterial import GMaterial |
| 5 | + |
| 6 | +cfg = autogeometry("examples", "material") |
| 7 | + |
| 8 | +world_size = 50 |
| 9 | +world = GVolume("root") |
| 10 | +world.description = "World" |
| 11 | +world.make_box(world_size * 0.5, world_size * 0.5, world_size * 0.5) |
| 12 | +world.material = "G4_AIR" |
| 13 | +world.color = "ghostwhite" |
| 14 | +world.visible = 0 |
| 15 | +world.publish(cfg) |
| 16 | + |
| 17 | +# Five tubes: 10 cm diameter, 1 cm thick, along z-axis starting at z=0. |
| 18 | +# Each tube is separated from the next by 3 cm (edge to edge), so centers |
| 19 | +# are 4 cm apart (1 cm thickness + 3 cm gap). |
| 20 | +radius = 5 # cm, giving 10 cm diameter |
| 21 | +half_thickness = 0.5 # cm, giving 1 cm total thickness |
| 22 | +z_step = 4 # cm center-to-center spacing |
| 23 | + |
| 24 | +# --- Tube 1: Geant4 built-in material --- |
| 25 | +tube1 = GVolume("tube_carbon") |
| 26 | +tube1.mother = "root" |
| 27 | +tube1.description = "Carbon tube using the Geant4 built-in G4_C (graphite) material" |
| 28 | +tube1.make_tube(0, radius, half_thickness, 0, 360) |
| 29 | +tube1.material = "G4_C" |
| 30 | +tube1.color = "808080" |
| 31 | +tube1.set_position(0, 0, 0.5) |
| 32 | +tube1.publish(cfg) |
| 33 | + |
| 34 | +# --- Tube 2: Custom material by molecular composition --- |
| 35 | +water = GMaterial("custom_water") |
| 36 | +water.description = "Water defined by molecular composition (H2O)" |
| 37 | +water.density = 1.0 |
| 38 | +water.addNAtoms("H", 2) |
| 39 | +water.addNAtoms("O", 1) |
| 40 | +water.publish(cfg) |
| 41 | + |
| 42 | +tube2 = GVolume("tube_water") |
| 43 | +tube2.mother = "root" |
| 44 | +tube2.description = "Tube made of custom water defined by molecular composition" |
| 45 | +tube2.make_tube(0, radius, half_thickness, 0, 360) |
| 46 | +tube2.material = "custom_water" |
| 47 | +tube2.color = "1565C0" |
| 48 | +tube2.set_position(0, 0, 0.5 + z_step) |
| 49 | +tube2.publish(cfg) |
| 50 | + |
| 51 | +# --- Tube 3: Custom material by fractional masses --- |
| 52 | +mixture = GMaterial("air_water_mixture") |
| 53 | +mixture.description = "80% air / 20% water mixture defined by fractional masses" |
| 54 | +mixture.density = 0.9601 |
| 55 | +mixture.addMaterialWithFractionalMass("G4_AIR", 0.80) |
| 56 | +mixture.addMaterialWithFractionalMass("G4_WATER", 0.20) |
| 57 | +mixture.publish(cfg) |
| 58 | + |
| 59 | +tube3 = GVolume("tube_mixture") |
| 60 | +tube3.mother = "root" |
| 61 | +tube3.description = "Tube made of an air/water mixture defined by fractional masses" |
| 62 | +tube3.make_tube(0, radius, half_thickness, 0, 360) |
| 63 | +tube3.material = "air_water_mixture" |
| 64 | +tube3.color = "2E7D32" |
| 65 | +tube3.set_position(0, 0, 0.5 + 2 * z_step) |
| 66 | +tube3.publish(cfg) |
| 67 | + |
| 68 | +# --- Tube 4: Scintillator with fast/slow emission components --- |
| 69 | +scint_energy = "2.0*eV 2.5*eV 3.0*eV 3.5*eV 4.0*eV" |
| 70 | + |
| 71 | +scintillator = GMaterial("my_scintillator") |
| 72 | +scintillator.description = "NaI-like scintillator with fast and slow emission components" |
| 73 | +scintillator.density = 3.67 |
| 74 | +scintillator.addNAtoms("Na", 1) |
| 75 | +scintillator.addNAtoms("I", 1) |
| 76 | +scintillator.photonEnergy = scint_energy |
| 77 | +scintillator.fastcomponent = "1.0 0.9 0.8 0.7 0.6" |
| 78 | +scintillator.slowcomponent = "0.5 0.4 0.3 0.2 0.1" |
| 79 | +scintillator.scintillationyield = 1000 |
| 80 | +scintillator.resolutionscale = 1.0 |
| 81 | +scintillator.fasttimeconstant = 6 |
| 82 | +scintillator.slowtimeconstant = 88 |
| 83 | +scintillator.yieldratio = 0.8 |
| 84 | +scintillator.birksConstant = 0.00152 |
| 85 | +scintillator.publish(cfg) |
| 86 | + |
| 87 | +tube4 = GVolume("tube_scintillator") |
| 88 | +tube4.mother = "root" |
| 89 | +tube4.description = "Tube made of a NaI-like scintillating material" |
| 90 | +tube4.make_tube(0, radius, half_thickness, 0, 360) |
| 91 | +tube4.material = "my_scintillator" |
| 92 | +tube4.color = "F57F17" |
| 93 | +tube4.style = 0 |
| 94 | +tube4.set_position(0, 0, 0.5 + 3 * z_step) |
| 95 | +tube4.publish(cfg) |
| 96 | + |
| 97 | +# --- Tube 5: Optical glass with index of refraction (Cherenkov radiator) --- |
| 98 | +photon_energy = "2.0*eV 3.0*eV 4.0*eV 5.0*eV" |
| 99 | + |
| 100 | +optical_glass = GMaterial("optical_glass") |
| 101 | +optical_glass.description = "SiO2 optical glass with a refractive index for Cherenkov applications" |
| 102 | +optical_glass.density = 2.5 |
| 103 | +optical_glass.addNAtoms("Si", 1) |
| 104 | +optical_glass.addNAtoms("O", 2) |
| 105 | +optical_glass.photonEnergy = photon_energy |
| 106 | +optical_glass.indexOfRefraction = "1.458 1.466 1.476 1.490" |
| 107 | +optical_glass.absorptionLength = "3*m 3*m 3*m 3*m" |
| 108 | +optical_glass.publish(cfg) |
| 109 | + |
| 110 | +tube5 = GVolume("tube_optical") |
| 111 | +tube5.mother = "root" |
| 112 | +tube5.description = "Tube made of SiO2 optical glass with a refractive index for Cherenkov radiation" |
| 113 | +tube5.make_tube(0, radius, half_thickness, 0, 360) |
| 114 | +tube5.material = "optical_glass" |
| 115 | +tube5.color = "00BCD4" |
| 116 | +tube5.style = 2 |
| 117 | +tube5.set_position(0, 0, 0.5 + 4 * z_step) |
| 118 | +tube5.publish(cfg) |
0 commit comments