Skip to content

TYRH Confusion #142

Description

@enorrislanl

When attempting to build a new ACEtk.ContinuousEnergyTable object using the Python interface, I think I'm seeing an inconsistency at construction time involving the TYRH block. For context, I'm building a .xxh file for proton-induced reactions with an MT=50 reaction whose neutron distribution is stored on the secondary particle blocks.

If I set ptype, hpd, mtrh, sigh, andh, dlwh, and yh all to None, everything works fine and I can build the expected file. If I set ptype and leave the other secondary particle blocks None, I get an error like:

enorris@ro-rfe1:acetk> python na111maker.py 

[error] Not all secondary particle production blocks are defined
[info] PTYPE is defined
[info] HPD is not defined
[info] MTRH is not defined
[info] TYRH is not defined
[info] SIGH is not defined
[info] ANDH is not defined
[info] DLWH is not defined
[info] YH is not defined
Traceback (most recent call last):
  File "/usr/projects/shavanodev/enorris/acetk/zrmaker.py", line 140, in <module>
    the_ace_file = ACEtk.ContinuousEnergyTable(z, a, s, header, esz, nu, dnu, mtr,
                                               lqr, sig, ang, dlw, bdd, dned, gpd,
                                               mtrp, sigp, angp, dlwp, yp,
                                               unr, ptype, hpd,
                                               mtrh, sigh, andh, dlwh, yh)
RuntimeError: std::exception

If I specify everything needed in the constructor, I get a similar but less helpful error:

RuntimeError: std::exception
enorris@ro-rfe1:acetk> python na111maker.py 

Traceback (most recent call last):
  File "/usr/projects/shavanodev/enorris/acetk/zrmaker.py", line 139, in <module>
    the_ace_file = ACEtk.ContinuousEnergyTable(z, a, s, header, esz, nu, dnu, mtr,
                                               lqr, sig, ang, dlw, bdd, dned, gpd,
                                               mtrp, sigp, angp, dlwp, yp,
                                               unr, ptype, hpd,
                                               mtrh, sigh, andh, dlwh, yh)
RuntimeError: bad optional access

I noticed that the constructor does not appear to take a TYRH block. I initially thought this was a mistake but then I ran into Line 78 of ACEtk/src/ACEtk/ContinuousEnergyTable/src/generateData.hpp:

  // generate blocks we don't have yet
  continuous::TYR tyr = generateTYR( dlw, ntr );
  std::optional< std::vector< continuous::TYRH > > tyrh = generateTYRH( dlwh );

which seems to suggest that TYR and TYRH are generated rather than passed into the constructor.

At this point I'm not sure how to best proceed.

The full text of my toy script is

import ACEtk

# Defines a single reaction (p,n) on an imaginary isotope Na-111. This reaction has constant cross section from 1e-11 MeV to 100 MeV.

sig_pn = 4.5
z = 11
a = 111
s = 0
header = ACEtk.Header(
    zaid = '11111.71h',
    awr = 123.456,
    temperature = 273.0/1.1606e10,
    date = '4/13/2026',
    title = 'Na-111',
    material = 'na111'
)
esz = ACEtk.continuous.PrincipalCrossSectionBlock(
    energies = [1e-11, 100.0],
    total = [sig_pn, sig_pn],
    disappearance = [sig_pn, sig_pn],
    elastic = [0.0, 0.0],
    heating = [0.0, 0.0]
)   
nu = None
dnu = None
mtr = ACEtk.continuous.ReactionNumberBlock([50])
lqr = ACEtk.continuous.ReactionQValueBlock([3.21])
sig = ACEtk.continuous.CrossSectionBlock([ACEtk.continuous.CrossSectionData(
    index=1,
    values=[sig_pn, sig_pn]
)])
    
ang = ACEtk.continuous.AngularDistributionBlock(
    elastic = ACEtk.continuous.FullyIsotropicDistribution(),
    distributions = []
)

mp = 0.99916733
mt = 123.456
ma = 1.0
Q = 3.21

dlw = ACEtk.continuous.EnergyDistributionBlock(
    distributions = [],
    multiplicities = [],
    frames = []
)

bdd = None
dned = None
gpd = None
mtrp = None
sigp = None
angp = None
dlwp = None
yp = None
unr = None

ptype = ACEtk.continuous.SecondaryParticleTypeBlock([1])

hpd = [ACEtk.continuous.SecondaryParticleProductionBlock(
    index = 1,
    production = [sig_pn, sig_pn],
    heating = [0.0, 0.0]
)]

mtrh = [ACEtk.continuous.ReactionNumberBlock([50])]

sigh = [ACEtk.continuous.SecondaryParticleProductionCrossSectionBlock(
    xs = [
        ACEtk.continuous.TabulatedSecondaryParticleMultiplicity(
            mftype=12,
            mt=50,
            energies=[1e-11,100.0],
            multiplicities=[1.0,1.0]
        )
    ]
)]

andh = [ACEtk.continuous.SecondaryParticleAngularDistributionBlock([
    ACEtk.continuous.FullyIsotropicDistribution()
])]

dlwh = [ACEtk.continuous.SecondaryParticleEnergyDistributionBlock([
    ACEtk.continuous.TwoBodyTransferDistribution(
        emin = 1e-11,
        emax = 100,
        c1 = (1.0+mt/mp)*(-Q/(mt/mp)),
        c2 = (mt/mp)*(mt/mp + 1.0 - ma/mp)/((1.0+mt/mp)**2)
    )
])]

yh = [ACEtk.continuous.MultiplicityReactionNumberBlock(
    reactions = [50]
)]

the_ace_file = ACEtk.ContinuousEnergyTable(z, a, s, header, esz, nu, dnu, mtr,
                                           lqr, sig, ang, dlw, bdd, dned, gpd,
                                           mtrp, sigp, angp, dlwp, yp,
                                           unr, ptype, hpd,
                                           mtrh, sigh, andh, dlwh, yh)

the_ace_file.to_file('11111.71h')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions