UAMonteCarlo and MaterialProperties Swift/Metal Library

Read full text
Authors: Matthew A. Kupinski
Cited by: 0

Abstract

ReDATA curation note: source code files were submitted by the author but were removed from this dataset prior to publication due to licensing terms preventing public sharing. The description provided below as well as the included readme file may reference the removed files. Refer to README.txt for a list of items removed.UAMonteCarlo PackageUAMonteCarlo is a package that can model, x-ray/gamma-ray propagation as well as positron propagation through materials. This package requires the MaterialProperties package as well.MaterialPropertiesThis package computes x-ray and gamma-ray absorption, coherent scattering, incoherent scattering, pair production, and triplet production properties for elements, compounds, or mixtures of materials. This package should be compatible with all Swift platforms that support Foundation (Linux, macOS, iOS, and Windows).ElementsMaterialProperties supports the first 100 elements in the periodic table (Hydrogen through Fermium).An `Element` is an enumeration for the 100 elements. You likely don't need to use it directly. However, if you want to explore some properties of elements, you can, for example:``` let tungsten = Element.W print(tungsten.edges) // prints all the K, L, M, and N edges above 1keVprint(tungsten.naturalDensity) print(tungsten.name) // Tungstenprint(tungsten.symbol) // W print(tungsten.atomicWeight) // atomic weight in g/mole```To make Matter from an element you can``` let copper = Matter(element: .Cu)```which will utilize the natural density. You can override the natural density with``` let copper = Matter(element: .Cu, withDensity: 12.5)```CompoundsMaterialProperties can parse a chemical formula and return a material. Because a density cannot be inferred from the formula, you must provide a density. For example,``` guard let hydroxyApatite = Matter(compound: "Ca5(PO4)3(OH)", withDensity: 3.16) else { ... }guard let water = Matter(compound: "H2O", withDensity: 1.0) else { ... } ``` If the initializer returns `nil` then the program couldn't parse the chemical formula.Material databaseThis package include the entire Geant4 database of NIST materials along with their densities. To use, you can,``` guard let nai = Matter(fromDatabase: "Bone Compact Icru") else { ... }```you can override the density with the optional argument `Matter(fromDatabase: "Adipose Tissue Icrp", withDensity: 1.0)`. A list of all the materials supported is at the end of this readme.### Custom materialsYou can generate your own mixtures using``` public init(fractionsByWeight fromMatter: [(Matter, Double)], withDensity: Double)```and``` public init(fractionsByVolume fromMatter: [(Matter, Double)], withDensity: Double)```Both take an Tuple array of existing Matter and either the fraction by weight or volume of that Matter in the new material. The final density must specified currently. ### Generic initialization`Matter` includes an initializer from a `String` entry via``` public init?(name: String, withDensity: Double? = nil, descriptiveName: String? = nil) {```This will first search `name` in the database and if it does not find a match, will then try parsing the string as either a chemical formula or a single element. This is very useful for parsing user input and generating `Matter` and allows the user to not have to specify the flavor of material beforehand. ### Extracting propertiesYou can get the mass attenuation or linear attenuation coefficients for absorption, coherent scatter, incoherent scatter, pair production, and triplet production for energies ranging from 1keV to 100GeV. Spline fitting from the raw NIST XCOM data is used to generate this data. See the Unit Tests for validation. All provided energies are in keV, mass attenuation values are in g/cm², and linear attenuation coefficients are returned in 1/cm. NOTE: XCOM returns tables w/ MeV energies. ``` let material = Matter(element: .W)let energy = 140.5 // keV let energyArray = stride(from: 0, to: 8, by: 0.1).map { pow(10.0, $0) }let ρA = material.massAbsorption(at: energy) let ρAArray = material.massAbsorption(atEnergies: energyArray)let ρScC = material.massScatterCoherent(at: energy) let ρScI = material.massScatterIncoherent(at: energy)let ρPP = material.massPairProduction(at: energy) let ρTP = material.massTripletProduction(at: energy)let ρTotal = material.massAttenuation(at: energy, includeCoherent: false)for type in CoefficientType.allCases { print(material.massCoefficient(type, atEnergy: energy))}let µA = material.linearAbsorption(at: energy) let µScC = material.linearScatterCoherent(at: energy)let µScI = material.linearScatterIncoherent(at: energy) let µPP = material.linearPairProduction(at: energy)let µTP = material.linearTripletProduction(at: energy)let µTotalArray = material.linearAttenuation(atEnergies: energyArray) // default is to include coherent````materialProps` command-line programThis package includes a command-line executable targe called `materialProps` which will generate information about a provide matter string (element, compound, or database). It also provides linear attenuation in a grid or at a specific energy.``` USAGE: materialProps [--density ] [--atEnergy ] [--noTable] [--linear] [--noHeader] ARGUMENTS: Material string OPTIONS: --density Material density--atEnergy Only produce info at the following energies --noTable Hide the table of coefficients--linear Display linear attenuation instead of mass attenuation --noHeader Hide the header information-h, --help Show help information. ``` Example commands:``` materialProps "Ca5(PO4)3(OH)" --density 3.17 --atEnergy 140.5materialProps "Adipose Tissue Icrp" --noHeader materialProps W --density 17.7 --linearmaterialProps C```Final Notes- `Matter` and `Element` are both `Codable` so their information can be exported via JSON files (or any other format that supports `Codable`). - The GPU implementation of `Matter` is entirely contained in `UAMonteCarlo` and is not in this repository.- `Matter` is considered equal if it contains the same elements and weights, density, and atomic mass; the name is not considered when testing equality since `name` is a `get set` property. - Much of the information in this package is stored in custom JSON files. These files are only loaded when they are needed and then never again. There will be a slight overhead in the first use of these data structures.- `Matter` has an optional `atomicWeight` parameters which is present for elements and compounds but not for the database since mixtures don't have a single atomic weight associated with them. - The *natural density* of an element can be highly variable depending upon the source. Most of my data are simlar to Geant4's densities. However, there are a few small differences where I found answers on Wikipedia with more precise numbers. For the higher-Z elements, natural density is often "predicted".- Currently the coefficients for `.attenuation` computations include the coherent scatter in the sum. It is not obvious that this is correct for all applications.Material Database1,2-Dichlorobenzene 1,2-Dichloroethane5Cr-Mo-V_Stainless_Steel A-150 TissueA201.0_Aluminum A321_Stainless_SteelAF1410_High_Alloy_Steel AISI_1025_Carbon_SteelAZ91E_Magnesium AcetoneAcetylene AdenineAdipose Tissue Icrp AdiposeICRU44AdiposeTissue Air AlanineAluminum Oxide AmberAmmonia AnilineAnthracene B-100 BoneBGO BakeliteBarium Fluoride Barium SulfateBenzene Beryllium OxideBgo Blood IcrpBone Compact Icru Bone Cortical IcrpBone_Corticle Bone_ICRU_CompactBoron Carbide Boron OxideBrain Icrp ButaneC-552 C17200_TF00_Copper_BerylliumCZT Cadmium TellurideCadmium Tungstate Calcium CarbonateCalcium Fluoride Calcium OxideCalcium Sulfate Calcium TungstateCarbon Dioxide Carbon TetrachlorideCellulose Butyrate Cellulose CellophaneCellulose Nitrate Ceric SulfateCesium Fluoride Cesium IodideChlorobenzene ChloroformConcrete Custom_450_H900_Precipitation_Hardened_Stainless_SteelCyclohexane Dichlorodiethyl EtherDiethyl Ether Dimethyl SulfoxideEPDM_Non-Asbestos_Gasket_Material EthaneEthyl Alcohol Ethyl CelluloseEthylene Eye Lens IcrpFerric Oxide FerroborideFerrous Oxide Ferrous SulfateFreon-12 Freon-12B2Freon-13 Freon-13B1Freon-13I1 Gadolinium OxysulfideGallium Arsenide Gel Photo EmulsionGlandularFraction50 GlandularFraction90GlandularTissue Glass LeadGlass Plate GlutamineGlycerol GuanineGypsum ICRU_SoftTissueInconel_600 KaptonLYSO Lanthanum OxybromideLanthanum Oxysulfide Lead OxideLithium Amide Lithium CarbonateLithium Fluoride Lithium HydrideLithium Iodide Lithium OxideLithium Tetraborate LpropaneLung Icrp LungWithAirM3 Wax Magnesium CarbonateMagnesium Fluoride Magnesium OxideMagnesium Tetraborate Mercuric IodideMethane MethanolMix D Wax Ms20 TissueMuscle Skeletal Icrp Muscle Striated IcruMuscle With Sucrose Muscle Without SucroseMylar N,N-Dimethyl FormamideN-Butyl Alcohol N-HeptaneN-Hexane N-PentaneN-Propyl Alcohol NaI w/ ThalliumNaphthalene NitrileNitrobenzene Nitrous OxideNylon-11 Rilsan Nylon-6-10Nylon-6-6 Nylon-8062Nylon6 OctanePH13-8Mo_Stainless_Steel PH15-7Mo_Stainless_SteelPMMA ParaffinPhoto Emulsion Plastic Sc VinyltoluenePlexiglass Plutonium DioxidePolyacrylonitrile PolycarbonatePolychlorostyrene PolyethylenePolyoxymethylene PolypropylenePolystyrene PolytrifluorochloroethylenePolyvinyl Acetate Polyvinyl AlcoholPolyvinyl Butyral Polyvinyl ChloridePolyvinyl Pyrrolidone Polyvinylidene ChloridePolyvinylidene Fluoride Potassium IodidePotassium Oxide PropanePyrex Glass PyridineRubber Butyl Rubber NaturalRubber Neoprene Silicon DioxideSilver Bromide Silver ChlorideSilver Halides Silver IodideSkin Icrp Sodium CarbonateSodium Iodide Sodium MonoxideSod

Publication details

Journal / source
ReDATA
Publication date
1 January 2026