Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenMC general output processing for simple tokamak model #333

Merged
merged 62 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
59f93c4
Placholder _get_tally_data function
sbradnam Oct 31, 2024
275f4e0
Merge branch 'developing' into omc-tokamak-out
sbradnam Oct 31, 2024
9b2f89f
First pass omc single library
sbradnam Oct 31, 2024
4279c9e
Sort output from omc dataframes
sbradnam Nov 1, 2024
9ba1337
openmc tally data to self.raw_data
sbradnam Nov 1, 2024
e858907
Generalised tally indexing for mcnp and openmc
sbradnam Nov 1, 2024
8b05c5c
Extract omc tally comments and numbers
sbradnam Nov 1, 2024
e88ed47
omc generated excel and atlas simple tokamak
sbradnam Nov 1, 2024
abd43a2
Black format new changes
sbradnam Nov 1, 2024
2a9a230
Update omc output test
sbradnam Nov 1, 2024
ecb6232
Initialised abstract _get_output_files
sbradnam Nov 4, 2024
7e54213
Moved some functions to AbstractOutput
sbradnam Nov 4, 2024
3c4111c
Abstract functions added to child classes
sbradnam Nov 4, 2024
6c9b541
Moved single excel output to AbstractOutput
sbradnam Nov 4, 2024
4fc8353
Reoved benchmark output class
sbradnam Nov 4, 2024
064de02
Refactored benchmark output
sbradnam Nov 4, 2024
870025d
Need to complete abstracts
sbradnam Nov 4, 2024
18ae465
Temp
sbradnam Nov 5, 2024
09d5424
Added revised benchmark output hierarchy
sbradnam Nov 5, 2024
3995fde
Added abstract parse_output_data
sbradnam Nov 5, 2024
f3018da
Restored excel comparison
sbradnam Nov 5, 2024
48e660f
Started fixing bugs and tests
sbradnam Nov 5, 2024
89a224d
Fixed output_test
sbradnam Nov 5, 2024
2f6169c
debugging tests
sbradnam Nov 5, 2024
ce65213
add some type hint
dodu94 Nov 5, 2024
6f75f04
Fixed meshtal test
sbradnam Nov 5, 2024
381f985
type hints
dodu94 Nov 5, 2024
66f97fb
Merge branch 'omc-tokamak-out' of https://github.com/JADE-V-V/JADE in…
dodu94 Nov 5, 2024
68aba66
Initialise abstract sphere
sbradnam Nov 5, 2024
3a8a4f9
Merge branch 'omc-tokamak-out' of github.com:JADE-V-V/JADE into omc-t…
sbradnam Nov 5, 2024
d2eda70
Docstrings
sbradnam Nov 5, 2024
3c87d60
Docstrings for output.py
sbradnam Nov 5, 2024
fcd1f5e
Abstract sim output initialised
sbradnam Nov 5, 2024
7f2ddfe
First pass abstract attributes
sbradnam Nov 5, 2024
2d88920
Attribute enorcement with NotImplimentError
sbradnam Nov 6, 2024
758047e
abstract layer in Sphere
dodu94 Nov 6, 2024
8d2520c
Merge branch 'omc-tokamak-out' of https://github.com/JADE-V-V/JADE in…
dodu94 Nov 6, 2024
06df2c7
Refactored raw_data to remove code layer
sbradnam Nov 6, 2024
e496418
Started fixing expout tests
sbradnam Nov 6, 2024
e01017b
fix sphere_output
dodu94 Nov 6, 2024
1272a10
Merge branch 'omc-tokamak-out' of https://github.com/JADE-V-V/JADE in…
dodu94 Nov 6, 2024
be19f5a
Started fixing sphereout tests
sbradnam Nov 6, 2024
460d877
fixed exp tests
dodu94 Nov 6, 2024
4c29f37
Merge branch 'omc-tokamak-out' of github.com:JADE-V-V/JADE into omc-t…
sbradnam Nov 6, 2024
aeb6971
Fixed test_read_openmc_output test
sbradnam Nov 6, 2024
31a2d22
fix sphereSDDR
dodu94 Nov 6, 2024
2a6c8fd
Merge branch 'omc-tokamak-out' of https://github.com/JADE-V-V/JADE in…
dodu94 Nov 6, 2024
c13f6b4
Expout docstrings
sbradnam Nov 6, 2024
cdaf063
Merge branch 'omc-tokamak-out' of github.com:JADE-V-V/JADE into omc-t…
sbradnam Nov 6, 2024
4c6b866
Docstrings
sbradnam Nov 6, 2024
c6b8973
Fix merge conflicts
sbradnam Nov 6, 2024
587a135
Fixed expout tests after merge
sbradnam Nov 6, 2024
27d7a1d
More docstrings
sbradnam Nov 6, 2024
950778f
More docstrings
sbradnam Nov 6, 2024
33da2c8
Black format and docstring expout
sbradnam Nov 6, 2024
b7e1e1d
Docstrings for output.py, removed ExcelOutputSheet object
sbradnam Nov 6, 2024
9acf14b
sphereoutputs docstrings
sbradnam Nov 6, 2024
059b2e3
Docstrings sphereoutput
sbradnam Nov 6, 2024
48c054f
Black format output and sphereoutput
sbradnam Nov 6, 2024
96ba4cb
Fixed bug in SphereSDDROutput
sbradnam Nov 7, 2024
90a7c92
fix spheresddr tests
alexvalentine94 Nov 18, 2024
0549c65
naming fix
alexvalentine94 Nov 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
520 changes: 312 additions & 208 deletions jade/expoutput.py

Large diffs are not rendered by default.

46 changes: 41 additions & 5 deletions jade/openmc.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from __future__ import annotations

import logging
import os
import re
import openmc

from typing import TYPE_CHECKING

import openmc

if TYPE_CHECKING:
from f4enix.input.libmanager import LibManager
from f4enix.input.materials import Material, SubMaterial, Zaid
Expand Down Expand Up @@ -233,8 +234,8 @@ def write(self, path: str) -> None:
self.materials.export_to_xml(os.path.join(path, "materials.xml"))


class OpenMCSimOutput:
def __init__(self, spfile_path: str) -> None:
class OpenMCStatePoint:
def __init__(self, spfile_path: str | os.PathLike) -> None:
"""Class for handling OpenMC tatepoint file

Parameters
Expand All @@ -256,6 +257,11 @@ def initialise(self, spfile_path: str) -> None:
try:
# Retrieve the version from the statepoint file (convert from tuple of integers to string)
self.statepoint = openmc.StatePoint(spfile_path)
self.tally_numbers = []
self.tally_comments = []
for _, tally in self.statepoint.tallies.items():
self.tally_numbers.append(tally.id)
self.tally_comments.append(tally.name)
except (FileNotFoundError, KeyError):
logging.warning(
"OpenMC version not found in the statepoint file for %s",
Expand All @@ -274,8 +280,38 @@ def read_openmc_version(self) -> str:
version = ".".join(map(str, self.statepoint.version))
return version

def _get_tally_data(self, tally: openmc.Tally):
"""Extract tally data from statepoint file

Parameters
----------
tally : openmc.Tally
openmc tally

Returns
-------
df : pd.DataFrame
pandas dataframe containing tally data
"""
df = tally.get_pandas_dataframe()
# df.to_csv('tally_'+str(tally.id)+'.csv')
return df

def tallies_to_dataframes(self):
"""Call to extract tally data from statepoint file

Returns
-------
list
list of rows with all sphere case tally data
"""
tallies = {}
for _, tally in self.statepoint.tallies.items():
tallies[tally.id] = self._get_tally_data(tally)
return tallies


class OpenMCSphereSimOutput(OpenMCSimOutput):
class OpenMCSphereStatePoint(OpenMCStatePoint):
def __init__(self, spfile_path: str) -> None:
"""Class to handle the data extraction of the Sphere leakage benchmark in OpenMC

Expand Down
Loading