Skip to content

Instantly share code, notes, and snippets.

@thomasms
Created March 16, 2023 19:30
Show Gist options
  • Save thomasms/53242efbc75ab64b6cd94b2a600961e9 to your computer and use it in GitHub Desktop.
Save thomasms/53242efbc75ab64b6cd94b2a600961e9 to your computer and use it in GitHub Desktop.
An example to show Activity Vs Time (log-log) plot for both irraditation and cooling periods - for Andrea
#!/usr/bin/env python3
import os
import pypact as pp
import pypact.analysis as ppa
# your FISPACT-II output file
filename = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "..", "..", "reference", "test127.out"
)
tz = ppa.TimeZone.BOTH
# this the property you would want to show - activity, atoms, heat, etc...
property = "activity"
isotopes = [
# you give it [(element_name, isotope number, state (optional))]
ppa.NuclideDataEntry(["Ca", 41]),
# you can plot multiple if you want
# ppa.NuclideDataEntry(["K", 40])
]
plt = ppa.LinePlotAdapter()
with pp.Reader(filename) as output:
ppa.plotproperty(
output=output,
property=property,
isotopes=isotopes,
plotter=plt,
fractional=False,
timeperiod=tz,
)
plt.show()
@thomasms
Copy link
Author

If you want to just get the values - a list of tuples with (time, activity) - then you can just do it like this:

#!/usr/bin/env python3

import os
import pypact as pp

nuclide_name = "Ca41"
filename = os.path.join(
    os.path.dirname(os.path.abspath(__file__)), "..", "..", "reference", "test127.out"
)

def matcher(nuclide) -> bool:
    return nuclide.name == nuclide_name

with pp.Reader(filename) as output:
    time_and_act = [
        (timestep.cooling_time, nuclide.activity) 
        for timestep in output
        for nuclide in timestep.nuclides
        if matcher(nuclide)
    ]
    print(time_and_act)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment