Skip to content

Fix XeHe molar fraction material construction - #276

Merged
kvjmistry merged 4 commits into
next-exp:masterfrom
jerenner:fix-xehe-molar-fractions
Jun 4, 2026
Merged

kvjmistry merged 4 commits into
next-exp:masterfrom
jerenner:fix-xehe-molar-fractions

Conversation

@jerenner

@jerenner jerenner commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes a bug in the creation of the Xe/He mixture, identified by @martinperezmaneiro

G4Material::AddElement interprets the numeric fraction argument as a mass fraction. GXeHe was using the requested Xe percentage directly, which made 85/15 Xe/He become 85/15 by mass rather than by molar fraction.

Compute the enriched-xenon molar mass, form the Xe/He mixture molar mass from the requested molar fractions, and derive the mass fractions passed to Geant4 from those molar fractions. Use the same mixture molar mass for the gas density calculation so the material density and composition are internally consistent.

G4Material::AddElement interprets the numeric fraction argument as a mass fraction. GXeHe was using the requested Xe percentage directly, which made 85/15 Xe/He become 85/15 by mass rather than by molar fraction.

Compute the enriched-xenon molar mass, form the Xe/He mixture molar mass from the requested molar fractions, and derive the mass fractions passed to Geant4 from those molar fractions. Use the same mixture molar mass for the gas density calculation so the material density and composition are internally consistent.
@jerenner
jerenner force-pushed the fix-xehe-molar-fractions branch from afd46b9 to 7ebad88 Compare May 25, 2026 15:42

@kvjmistry kvjmistry left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed this PR and it looks good. I have a few extra requests before merging:

  • Please could you also fix the GXeAr function which suffers from this same issue.
  • Please add a comment to the function that this is currently configured for enriched Xe + helium. In the future, we may want to add depleted Xe + He as an option. Or if you can think of a better way to include the Xe Enrichment that would be better.

Treat the XePercentage argument in GXeAr as a molar percentage, convert the resulting Xe/Ar molar fractions to mass fractions before adding elements to the G4Material, and compute the gas density from the mixture molar mass.

Document that the current GXeHe material uses enriched xenon, leaving future depleted-Xe support as an explicit extension point.
@jerenner
jerenner force-pushed the fix-xehe-molar-fractions branch from 7ebad88 to e2d76fb Compare June 2, 2026 21:16
@jerenner

jerenner commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

The GXeAr function is now updated, and there are comments in the .cc and .h stating that the Xe/He mixture is enriched Xe + He.

We could continue by adding depleted Xe + He (or adding some way to select between natural, depleted, and enriched), or we can do that in a new PR

@kvjmistry

Copy link
Copy Markdown
Collaborator

The GXeAr function is now updated, and there are comments in the .cc and .h stating that the Xe/He mixture is enriched Xe + He.

We could continue by adding depleted Xe + He (or adding some way to select between natural, depleted, and enriched), or we can do that in a new PR

If you have the time to add the option between switching between natural/depleted/enriched then that would be great. I think that would be useful for the tonne scale simulations in the future.

Allow GXeHe to use natural, enriched, or depleted xenon isotope compositions, defaulting to natural xenon when no option is specified.

Expose the XeHeXenonType messenger property in the geometries that construct XeHe mixtures, and give each XeHe material variant a distinct Geant4 material name.

Example NextTonScale macro configuration:

/Geometry/NextTonScale/gas XeHe
/Geometry/NextTonScale/gas_pressure 13. bar
/Geometry/NextTonScale/gas_temperature 300. kelvin
/Geometry/NextTonScale/XePercentage 85.
/Geometry/NextTonScale/helium_A 4
/Geometry/NextTonScale/XeHeXenonType enrichedXe
@jerenner

jerenner commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

The last commit adds functionality to set the XeHeXenonType in the macro for Next100, NextNew, and NextTonScale, for example:

/Geometry/NextTonScale/XeHeXenonType enrichedXe

The options are: naturalXe enrichedXe depletedXe

Comment thread source/geometries/Next100Vessel.cc Outdated
// Visibility
visibility_(0),
gas_("enrichedXe"),
xe_he_xe_type_("naturalXe"),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here i would prefer the var name xe_he_type_ which is a little easier to read.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment in the header for var definition that this refers to the xenon type mixed with the helium

Comment thread source/geometries/Next100Vessel.cc Outdated
G4GenericMessenger::Command& xe_he_xe_type_cmd =
msg_->DeclareProperty("XeHeXenonType", xe_he_xe_type_,
"Xenon type used in XeHe mixtures.");
xe_he_xe_type_cmd.SetCandidates("naturalXe enrichedXe depletedXe");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ive not see the use of SetCandidates before. Could you test this functionality by giving it a mis-spelled word and see if it works?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method does exist in the Geant4 source.

Running a test in a macro with a misspelling:

/Geometry/NextTonScale/XeHeXenonType enrichedXXe

gives:

parameter value (enrichedXXe) is not listed in the candidate List.
  Candidates are: naturalXe enrichedXe depletedXe

-------- EEEE ------- G4Exception-START -------- EEEE -------
*** G4Exception : ExecCommand()
      issued by : [BatchSession]
Illegal parameter: /Geometry/NextTonScale/XeHeXenonType enrichedXXe
*** Fatal Exception *** core dump ***
 **** Track information is not available at this moment
 **** Step information is not available at this moment

-------- EEEE -------- G4Exception-END --------- EEEE -------

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, thanks for checking!

Rename the XeHe xenon-type member to xe_he_type_ for readability and document that it selects the xenon type mixed with helium.

Verified that SetCandidates rejects misspelled XeHeXenonType values in a Next100 macro, aborting with the valid candidates listed.
@jerenner

jerenner commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

Variable names changed to xe_he_type_ and commented in headers that the variable refers to the xenon type mixed with the helium

@kvjmistry kvjmistry left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR fixes an issue related to how we defined the gas mixtures. The fixes were (for the first time?) using AI to provide the changes. All looks good to me!

@kvjmistry
kvjmistry merged commit ab253e5 into next-exp:master Jun 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants