Skip to content

Commit

Permalink
Merge pull request #49 from PeBoch/bug_metastable_plotting
Browse files Browse the repository at this point in the history
Bug metastable plotting
  • Loading branch information
thomasms authored Oct 23, 2022
2 parents 9a4b6ff + eb87c9f commit be77231
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
16 changes: 13 additions & 3 deletions examples/outputplotting/plotnuclideheat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@
import os
import pypact as pp
import pypact.analysis as ppa
from pypact.library.nuclidelib import get_zai

filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'..', '..', 'reference', 'test127.out')

tz = ppa.TimeZone.COOL
properties = ['heat', 'grams', 'ingestion']
isotopes = [ ppa.NuclideDataEntry(i) for i in ppa.get_all_isotopes() if ppa.find_z(i[0]) <= 10]
tz = ppa.TimeZone.BOTH
properties = ['heat', 'grams', 'inhalation']

# plot all isotopes of a specific element regardless of state, here Sc
#isotopes = [ ppa.NuclideDataEntry(i) for i in ppa.get_all_isotopes() if ppa.find_z(i[0]) == 21]

# plot specific isotope with specific state, here Sc45m
#isotopes = [ ppa.NuclideDataEntry(i) for i in ppa.get_all_isotopes_states() if get_zai(i[0]+str(i[1])+str(i[2])) == 210451 ]

# plot all isotopes and states of an element, here Sc
isotopes = [ ppa.NuclideDataEntry(i) for i in ppa.get_all_isotopes_states() if ppa.find_z(i[0]) == 21 ]


plt = ppa.LinePlotAdapter()

Expand Down
1 change: 1 addition & 0 deletions pypact/analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
from pypact.library.nuclidelib import find_element
from pypact.library.nuclidelib import find_z
from pypact.library.nuclidelib import get_all_isotopes
from pypact.library.nuclidelib import get_all_isotopes_states
15 changes: 10 additions & 5 deletions pypact/analysis/propertyplotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@ class NuclideDataEntry(object):
def __init__(self, nuclide):
self.element = nuclide[0]
self.isotope = nuclide[1]

try:
self.state = nuclide[2]
except IndexError:
self.state = ""

self.reset()

def reset(self):
self.times = []
self.values = []


def __str__(self):
return str.format("Isotope {0}-{1} values: {2}",
self.element, self.isotope, self.values)
return str.format("Isotope {0}-{1}-{2} values: {3}",
self.element, self.isotope, self.state, self.values)


def plotproperty(output,
Expand All @@ -40,7 +45,7 @@ def plotproperty(output,
value = getattr(n, property)
total += value
for i in isotopes:
if n.element == i.element and n.isotope == i.isotope:
if n.element == i.element and n.isotope == i.isotope and n.state == i.state:
i.times.append(t.irradiation_time + t.cooling_time)
i.values.append(value)

Expand All @@ -60,7 +65,7 @@ def plotproperty(output,

f = plotter.lineplot(x=i.times,
y=i.values,
datalabel=str.format('{0}-{1}', i.element, i.isotope),
datalabel=str.format('{0}-{1}{2}', i.element, i.isotope, i.state),
xlabel="time [s]",
ylabel=yaxislabel,
logx=(timeperiod != TimeZone.IRRAD),
Expand Down
11 changes: 11 additions & 0 deletions pypact/library/nuclidelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,14 @@ def get_all_isotopes():
all_list[count] = (n[ELEMENT_KEY], i)
count += 1
return all_list

def get_all_isotopes_states():
all_list_2 = [('', 0,'')] * NUMBER_OF_ISOTOPES * len(STATE_MAPPINGS)
count = 0
for n in NUCLIDE_DICTIONARY:
if ELEMENT_KEY in n and ISOTOPES_KEY in n:
for i in n[ISOTOPES_KEY]:
for k in STATE_MAPPINGS:
all_list_2[count] = (n[ELEMENT_KEY], i, STATE_MAPPINGS[k])
count += 1
return all_list_2

0 comments on commit be77231

Please sign in to comment.