diff --git a/jade/configuration.py b/jade/configuration.py index 4ec9f2b3..1b247a22 100644 --- a/jade/configuration.py +++ b/jade/configuration.py @@ -21,14 +21,21 @@ You should have received a copy of the GNU General Public License along with JADE. If not, see . """ + +from __future__ import annotations + import datetime import logging import os import sys +from dataclasses import dataclass import pandas as pd +import yaml from jade.exceptions import fatal_exception +from jade.output import BinningType +from jade.plotter import PlotType class Configuration: @@ -208,3 +215,99 @@ def get_lib_name(self, suffix: str) -> str: except KeyError: name = suffix return name + + +@dataclass +class ComputationalConfig: + """Configuration for a computational benchmark. + + Attributes + ---------- + excel_options : dict[int, ExcelOptions] + Options for the Excel benchmark. + atlas_options : dict[int, AtlasOptions] + Options for the Atlas benchmark. + """ + + excel_options: dict[int, ExcelOptions] + atlas_options: dict[int, AtlasOptions] + + @classmethod + def from_yaml(cls, file: str | os.PathLike) -> ComputationalConfig: + """Build the configuration for a computational benchmark from a yaml file. + + Parameters + ---------- + file : str | os.PathLike + path to the yaml file. + + Returns + ------- + ComputationalConfig + The configuration for the computational benchmark. + """ + with open(file) as f: + cfg = yaml.safe_load(f) + + atlas_options = {} + for key, value in cfg["Atlas"].items(): + atlas_options[int(key)] = AtlasOptions(**value) + + excel_options = {} + for key, value in cfg["Excel"].items(): + excel_options[int(key)] = ExcelOptions(**value) + + return cls(excel_options=excel_options, atlas_options=atlas_options) + + +@dataclass +class ExcelOptions: + identifier: int # identifier of the tally + x: BinningType | list[BinningType] # tally dataframe column name to use for x axis + x_name: str # x label + y: BinningType | list[BinningType] # tally dataframe column name to use for y axis + y_name: str # y label + cut_y: int | None = ( + None # max number of columns, after that the DF is split and goes to next line + ) + + def __post_init__(self): + # enforce that the binning type is a valid one, try to convert if possible + for attribute in [self.x, self.y]: + if type(attribute) is str: + split = attribute.split("-") + if len(split) > 1: + attribute = [] + for bintype in split: + try: + attribute.append(BinningType(bintype)) + except ValueError: + raise ValueError(f"Invalid binning type: {bintype}") + else: + try: + attribute = BinningType(attribute) + except ValueError: + raise ValueError(f"Invalid binning type: {attribute}") + # try: + # self.x = BinningType(self.x) + # except ValueError: + # raise ValueError(f"Invalid binning type for x: {self.x}") + # try: + # self.y = BinningType(self.y) + # except ValueError: + # raise ValueError(f"Invalid binning type for y: {self.y}") + + +@dataclass +class AtlasOptions: + identifier: int # identifier of the tally + plot_type: PlotType # type of plot + quantity: str | None = None # quantity plotted (goes on the y axis of plots) + unit: str | None = None # unit of the quantity + + def __post_init__(self): + # enforce that the plot type is a valid one + try: + self.plot_type = PlotType(self.plot_type) + except ValueError: + raise ValueError(f"Invalid plot type: {self.plot_type}") diff --git a/jade/default_settings/Benchmarks_Configuration/C_Model.xlsx b/jade/default_settings/Benchmarks_Configuration/C_Model.xlsx deleted file mode 100644 index 14637b49..00000000 Binary files a/jade/default_settings/Benchmarks_Configuration/C_Model.xlsx and /dev/null differ diff --git a/jade/default_settings/Benchmarks_Configuration/C_Model.yaml b/jade/default_settings/Benchmarks_Configuration/C_Model.yaml new file mode 100644 index 00000000..e468fc8e --- /dev/null +++ b/jade/default_settings/Benchmarks_Configuration/C_Model.yaml @@ -0,0 +1,413 @@ +Atlas: + 11: + identifier: 11 + plot_type: Grouped bars + quantity: 'Neutron current ' + unit: '#/cm^2/s' + 12: + identifier: 12 + plot_type: Grouped bars + quantity: Neutron flux + unit: '#/cm^2/s' + 16: + identifier: 16 + plot_type: Grouped bars + quantity: Nuclear Heating + unit: W + 21: + identifier: 21 + plot_type: Grouped bars + quantity: 'Neutron current ' + unit: '#/cm^2/s' + 22: + identifier: 22 + plot_type: Grouped bars + quantity: Neutron flux + unit: '#/cm^2/s' + 26: + identifier: 26 + plot_type: Grouped bars + quantity: Nuclear Heating + unit: W + 31: + identifier: 31 + plot_type: Grouped bars + quantity: 'Neutron current ' + unit: '#/cm^2/s' + 32: + identifier: 32 + plot_type: Grouped bars + quantity: Neutron flux + unit: '#/cm^2/s' + 36: + identifier: 36 + plot_type: Grouped bars + quantity: Nuclear Heating + unit: W + 41: + identifier: 41 + plot_type: Grouped bars + quantity: 'Neutron current ' + unit: '#/cm^2/s' + 42: + identifier: 42 + plot_type: Grouped bars + quantity: Neutron flux + unit: '#/cm^2/s' + 46: + identifier: 46 + plot_type: Grouped bars + quantity: Nuclear Heating + unit: W + 51: + identifier: 51 + plot_type: Grouped bars + quantity: 'Neutron current ' + unit: '#/cm^2/s' + 52: + identifier: 52 + plot_type: Grouped bars + quantity: Neutron flux + unit: '#/cm^2/s' + 56: + identifier: 56 + plot_type: Grouped bars + quantity: Nuclear Heating + unit: W + 61: + identifier: 61 + plot_type: Grouped bars + quantity: 'Neutron current ' + unit: '#/cm^2/s' + 62: + identifier: 62 + plot_type: Grouped bars + quantity: Neutron flux + unit: '#/cm^2/s' + 66: + identifier: 66 + plot_type: Grouped bars + quantity: Nuclear Heating + unit: W + 71: + identifier: 71 + plot_type: Grouped bars + quantity: 'Neutron current ' + unit: '#/cm^2/s' + 72: + identifier: 72 + plot_type: Grouped bars + quantity: Neutron flux + unit: '#/cm^2/s' + 76: + identifier: 76 + plot_type: Grouped bars + quantity: Nuclear Heating + unit: W + 81: + identifier: 81 + plot_type: Grouped bars + quantity: 'Neutron current ' + unit: '#/cm^2/s' + 82: + identifier: 82 + plot_type: Grouped bars + quantity: Neutron flux + unit: '#/cm^2/s' + 86: + identifier: 86 + plot_type: Grouped bars + quantity: Nuclear Heating + unit: W + 91: + identifier: 91 + plot_type: Grouped bars + quantity: 'Neutron current ' + unit: '#/cm^2/s' + 92: + identifier: 92 + plot_type: Grouped bars + quantity: Neutron flux + unit: '#/cm^2/s' + 96: + identifier: 96 + plot_type: Grouped bars + quantity: Nuclear Heating + unit: W + 101: + identifier: 101 + plot_type: Grouped bars + quantity: 'Neutron current ' + unit: '#/cm^2/s' + 102: + identifier: 102 + plot_type: Grouped bars + quantity: Neutron flux + unit: '#/cm^2/s' + 111: + identifier: 111 + plot_type: Grouped bars + quantity: 'Neutron current ' + unit: '#/cm^2/s' + 112: + identifier: 112 + plot_type: Grouped bars + quantity: Neutron flux + unit: '#/cm^2/s' + 121: + identifier: 121 + plot_type: Grouped bars + quantity: 'Neutron current ' + unit: '#/cm^2/s' + 122: + identifier: 122 + plot_type: Grouped bars + quantity: Neutron flux + unit: '#/cm^2/s' + 131: + identifier: 131 + plot_type: Grouped bars + quantity: 'Neutron current ' + unit: '#/cm^2/s' + 132: + identifier: 132 + plot_type: Grouped bars + quantity: Neutron flux + unit: '#/cm^2/s' +Excel: + 11: + cut_y: 20.0 + identifier: 11 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 12: + cut_y: 20.0 + identifier: 12 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 16: + identifier: 16 + x: Cells + x_name: 'Cell #' + y: tally + y_name: Value + 21: + cut_y: 20.0 + identifier: 21 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 22: + cut_y: 20.0 + identifier: 22 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 26: + identifier: 26 + x: Cells + x_name: 'Cell #' + y: tally + y_name: Value + 31: + cut_y: 20.0 + identifier: 31 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 32: + cut_y: 20.0 + identifier: 32 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 36: + identifier: 36 + x: Cells + x_name: 'Cell #' + y: tally + y_name: Value + 41: + cut_y: 20.0 + identifier: 41 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 42: + cut_y: 20.0 + identifier: 42 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 46: + identifier: 46 + x: Cells + x_name: 'Cell #' + y: tally + y_name: Value + 51: + cut_y: 20.0 + identifier: 51 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 52: + cut_y: 20.0 + identifier: 52 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 56: + identifier: 56 + x: Cells + x_name: 'Cell #' + y: tally + y_name: Value + 61: + cut_y: 20.0 + identifier: 61 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 62: + cut_y: 20.0 + identifier: 62 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 66: + identifier: 66 + x: Cells + x_name: 'Cell #' + y: tally + y_name: Value + 71: + cut_y: 20.0 + identifier: 71 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 72: + cut_y: 20.0 + identifier: 72 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 76: + identifier: 76 + x: Cells + x_name: 'Cell #' + y: tally + y_name: Value + 81: + cut_y: 20.0 + identifier: 81 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 82: + cut_y: 20.0 + identifier: 82 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 86: + identifier: 86 + x: Cells + x_name: 'Cell #' + y: tally + y_name: Value + 91: + cut_y: 20.0 + identifier: 91 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 92: + cut_y: 20.0 + identifier: 92 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 96: + identifier: 96 + x: Cells + x_name: 'Cell #' + y: tally + y_name: Value + 101: + cut_y: 20.0 + identifier: 101 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 102: + cut_y: 20.0 + identifier: 102 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 111: + cut_y: 20.0 + identifier: 111 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 112: + cut_y: 20.0 + identifier: 112 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 121: + cut_y: 20.0 + identifier: 121 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 122: + cut_y: 20.0 + identifier: 122 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 131: + cut_y: 20.0 + identifier: 131 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision + 132: + cut_y: 20.0 + identifier: 132 + x: Segments + x_name: 'Segment #' + y: User + y_name: Collision diff --git a/jade/default_settings/Benchmarks_Configuration/HCPB_TBM_1D.xlsx b/jade/default_settings/Benchmarks_Configuration/HCPB_TBM_1D.xlsx deleted file mode 100644 index 4f880172..00000000 Binary files a/jade/default_settings/Benchmarks_Configuration/HCPB_TBM_1D.xlsx and /dev/null differ diff --git a/jade/default_settings/Benchmarks_Configuration/HCPB_TBM_1D.yaml b/jade/default_settings/Benchmarks_Configuration/HCPB_TBM_1D.yaml new file mode 100644 index 00000000..fe791f18 --- /dev/null +++ b/jade/default_settings/Benchmarks_Configuration/HCPB_TBM_1D.yaml @@ -0,0 +1,111 @@ +Atlas: + 54: + identifier: 54 + plot_type: Ratio graph + 94: + identifier: 94 + plot_type: Ratio graph + 134: + identifier: 134 + plot_type: Ratio graph + 164: + identifier: 164 + plot_type: Ratio graph + 184: + identifier: 184 + plot_type: Ratio graph + 194: + identifier: 194 + plot_type: Ratio graph + 204: + identifier: 204 + plot_type: Ratio graph + quantity: Neutron Heating + unit: MeV/cc/n_s + 214: + identifier: 214 + plot_type: Ratio graph + quantity: Photon Heating + unit: MeV/cc/n_s + 224: + identifier: 224 + plot_type: Ratio graph + quantity: Tritium Production + unit: atom/cc/n_s + 234: + identifier: 234 + plot_type: Ratio graph + quantity: Neutron Flux + unit: '#/cc/n_s' + 244: + identifier: 244 + plot_type: Ratio graph + quantity: Photon Flux + unit: '#/cc/n_s' +Excel: + 54: + identifier: 54 + x: Cells + x_name: Cell + y: tally + y_name: Value + 94: + identifier: 94 + x: Cells + x_name: Cell + y: tally + y_name: Value + 134: + identifier: 134 + x: Cells + x_name: Cell + y: tally + y_name: Value + 164: + identifier: 164 + x: Cells + x_name: Cell + y: tally + y_name: Value + 184: + identifier: 184 + x: Cells + x_name: Cell + y: tally + y_name: Value + 194: + identifier: 194 + x: Cells + x_name: Cell + y: tally + y_name: Value + 204: + identifier: 204 + x: Cor A + x_name: R [cm] + y: tally + y_name: Value + 214: + identifier: 214 + x: Cor A + x_name: R [cm] + y: tally + y_name: Value + 224: + identifier: 224 + x: Cor A + x_name: R [cm] + y: tally + y_name: Value + 234: + identifier: 234 + x: Cor A + x_name: R [cm] + y: tally + y_name: Value + 244: + identifier: 244 + x: Cor A + x_name: R [cm] + y: tally + y_name: Value diff --git a/jade/default_settings/Benchmarks_Configuration/ITER_1D.xlsx b/jade/default_settings/Benchmarks_Configuration/ITER_1D.xlsx deleted file mode 100644 index f0f0c3a3..00000000 Binary files a/jade/default_settings/Benchmarks_Configuration/ITER_1D.xlsx and /dev/null differ diff --git a/jade/default_settings/Benchmarks_Configuration/ITER_1D.yaml b/jade/default_settings/Benchmarks_Configuration/ITER_1D.yaml new file mode 100644 index 00000000..8e18a5ec --- /dev/null +++ b/jade/default_settings/Benchmarks_Configuration/ITER_1D.yaml @@ -0,0 +1,236 @@ +Atlas: + 4: + identifier: 4 + plot_type: Ratio graph + quantity: Neutron Flux + unit: '#/cm^2' + 6: + identifier: 6 + plot_type: Ratio graph + quantity: Total Nuclear Heating + unit: W/g + 14: + identifier: 14 + plot_type: Ratio graph + quantity: Photon Flux + unit: '#/cm^2' + 16: + identifier: 16 + plot_type: Ratio graph + quantity: Neutron Heating + unit: W/g + 24: + identifier: 24 + plot_type: Ratio graph + quantity: DPA in Fe + unit: dpa/FPY + 26: + identifier: 26 + plot_type: Ratio graph + quantity: Photon Heating + unit: W/g + 34: + identifier: 34 + plot_type: Ratio graph + quantity: Helium production in SS316 + unit: appm/FPY + 44: + identifier: 44 + plot_type: Ratio graph + quantity: Hydrogen production in SS316 + unit: appm/FPY + 54: + identifier: 54 + plot_type: Ratio graph + quantity: Tritium production in SS316 + unit: appm/FPY + 64: + identifier: 64 + plot_type: Ratio graph + quantity: DPA in Cu + unit: dpa/FPY + 74: + identifier: 74 + plot_type: Ratio graph + 84: + identifier: 84 + plot_type: Ratio graph + 94: + identifier: 94 + plot_type: Ratio graph + 104: + identifier: 104 + plot_type: Ratio graph + 114: + identifier: 114 + plot_type: Ratio graph + 124: + identifier: 124 + plot_type: Ratio graph + 134: + identifier: 134 + plot_type: Ratio graph + 144: + identifier: 144 + plot_type: Ratio graph + 154: + identifier: 154 + plot_type: Ratio graph + 164: + identifier: 164 + plot_type: Ratio graph + 174: + identifier: 174 + plot_type: Ratio graph + 204: + identifier: 204 + plot_type: Ratio graph + quantity: Neutron Flux + unit: '#/cm^2' + 214: + identifier: 214 + plot_type: Ratio graph + quantity: Photon Flux + unit: '#/cm^2' +Excel: + 4.0: + cut_y: 20.0 + identifier: 4 + x: Energy + x_name: Energy [MeV] + y: Cells + y_name: Cell + 6.0: + identifier: 6 + x: Cells + x_name: Cell + y: tally + y_name: Value + 14.0: + cut_y: 20.0 + identifier: 14 + x: Energy + x_name: Energy [MeV] + y: Cells + y_name: Cell + 16.0: + identifier: 16 + x: Cells + x_name: Cell + y: tally + y_name: Value + 24.0: + identifier: 24 + x: Cells + x_name: Cell + y: tally + y_name: Value + 26.0: + identifier: 26 + x: Cells + x_name: Cell + y: tally + y_name: Value + 34.0: + identifier: 34 + x: Cells + x_name: Cell + y: tally + y_name: Value + 44.0: + identifier: 44 + x: Cells + x_name: Cell + y: tally + y_name: Value + 54.0: + identifier: 54 + x: Cells + x_name: Cell + y: tally + y_name: Value + 64.0: + identifier: 64 + x: Cells + x_name: Cell + y: tally + y_name: Value + 74.0: + identifier: 74 + x: Cells + x_name: Cell + y: tally + y_name: Value + 84.0: + identifier: 84 + x: Cells + x_name: Cell + y: tally + y_name: Value + 94.0: + identifier: 94 + x: Cells + x_name: Cell + y: tally + y_name: Value + 104.0: + identifier: 104 + x: Cells + x_name: Cell + y: tally + y_name: Value + 114.0: + identifier: 114 + x: Cells + x_name: Cell + y: tally + y_name: Value + 124.0: + identifier: 124 + x: Cells + x_name: Cell + y: tally + y_name: Value + 134.0: + identifier: 134 + x: Cells + x_name: Cell + y: tally + y_name: Value + 144.0: + identifier: 144 + x: Cells + x_name: Cell + y: tally + y_name: Value + 154.0: + identifier: 154 + x: Cells + x_name: Cell + y: tally + y_name: Value + 164.0: + identifier: 164 + x: Cells + x_name: Cell + y: tally + y_name: Value + 174.0: + cut_y: 20.0 + identifier: 174 + x: Energy + x_name: Energy [MeV] + y: Cells + y_name: Cell + 204.0: + identifier: 204 + x: Cells + x_name: Cell + y: tally + y_name: Value + 214.0: + identifier: 214 + x: Cells + x_name: Cell + y: tally + y_name: Value diff --git a/jade/default_settings/Benchmarks_Configuration/ITER_Cyl_SDDR.xlsx b/jade/default_settings/Benchmarks_Configuration/ITER_Cyl_SDDR.xlsx deleted file mode 100644 index e10aa79d..00000000 Binary files a/jade/default_settings/Benchmarks_Configuration/ITER_Cyl_SDDR.xlsx and /dev/null differ diff --git a/jade/default_settings/Benchmarks_Configuration/ITER_Cyl_SDDR.yaml b/jade/default_settings/Benchmarks_Configuration/ITER_Cyl_SDDR.yaml new file mode 100644 index 00000000..02d07418 --- /dev/null +++ b/jade/default_settings/Benchmarks_Configuration/ITER_Cyl_SDDR.yaml @@ -0,0 +1,98 @@ +Atlas: + 14: + identifier: 14 + plot_type: Grouped bars + quantity: Gamma Flux + unit: '#/cm^2/s' + 34: + identifier: 34 + plot_type: Grouped bars + quantity: Gamma Flux + unit: '#/cm^2/s' + 44: + identifier: 44 + plot_type: Grouped bars + quantity: Gamma Flux + unit: '#/cm^2/s' + 54: + identifier: 54 + plot_type: Grouped bars + quantity: Gamma Flux + unit: '#/cm^2/s' + 74: + identifier: 74 + plot_type: Grouped bars + quantity: Gamma Flux + unit: '#/cm^2/s' + 124: + identifier: 124 + plot_type: Grouped bars + quantity: Dose Rate + unit: Sv/h + 202: + identifier: 202 + plot_type: Grouped bars + quantity: Neutron Flux + unit: '#/cm^2/s' + 242: + identifier: 242 + plot_type: Grouped bars + quantity: Neutron Flux + unit: '#/cm^2/s' +Excel: + 14: + cut_y: 20 + identifier: 14 + x: Energy + x_name: Energy [MeV] + y: Time + y_name: Cooldown time + 34: + cut_y: 20 + identifier: 34 + x: Energy + x_name: Energy [MeV] + y: Time + y_name: Cooldown time + 44: + cut_y: 20 + identifier: 44 + x: Energy + x_name: Energy [MeV] + y: Time + y_name: Cooldown time + 54: + cut_y: 20 + identifier: 54 + x: Energy + x_name: Energy [MeV] + y: Time + y_name: Cooldown time + 74: + cut_y: 20 + identifier: 74 + x: Cells + x_name: Cell n. + y: Time + y_name: Cooldown time + 124: + cut_y: 20 + identifier: 124 + x: Cells + x_name: Cell n. + y: Time + y_name: Cooldown time + 202: + cut_y: 20 + identifier: 202 + x: Energy + x_name: Energy [MeV] + y: Cells-Segments + y_name: Geometrical bin + 242: + cut_y: 20 + identifier: 242 + x: Cells-Segments + x_name: Geometrical bin + y: tally + y_name: Total Neutron Flux [#/cm^2/s] diff --git a/jade/default_settings/Benchmarks_Configuration/WCLL_TBM_1D.xlsx b/jade/default_settings/Benchmarks_Configuration/WCLL_TBM_1D.xlsx deleted file mode 100644 index 59a51c8f..00000000 Binary files a/jade/default_settings/Benchmarks_Configuration/WCLL_TBM_1D.xlsx and /dev/null differ diff --git a/jade/default_settings/Benchmarks_Configuration/WCLL_TBM_1D.yaml b/jade/default_settings/Benchmarks_Configuration/WCLL_TBM_1D.yaml new file mode 100644 index 00000000..ca509dc3 --- /dev/null +++ b/jade/default_settings/Benchmarks_Configuration/WCLL_TBM_1D.yaml @@ -0,0 +1,120 @@ +Atlas: + 54: + identifier: 54 + plot_type: Ratio graph + 94: + identifier: 94 + plot_type: Ratio graph + 134: + identifier: 134 + plot_type: Ratio graph + 164: + identifier: 164 + plot_type: Ratio graph + 184: + identifier: 184 + plot_type: Ratio graph + 194: + identifier: 194 + plot_type: Ratio graph + 204: + identifier: 204 + plot_type: Ratio graph + 214: + identifier: 214 + plot_type: Ratio graph + quantity: Neutron Heating + unit: MeV/cc/n_s + 224: + identifier: 224 + plot_type: Ratio graph + quantity: Photon Heating + unit: MeV/cc/n_s + 234: + identifier: 234 + plot_type: Ratio graph + quantity: Tritium Production + unit: atom/cc/n_s + 244: + identifier: 244 + plot_type: Ratio graph + quantity: Neutron Flux + unit: '#/cc/n_s' + 254: + identifier: 254 + plot_type: Ratio graph + quantity: Photon Flux + unit: '#/cc/n_s' +Excel: + 54: + identifier: 54 + x: Cells + x_name: Cell + y: tally + y_name: Value + 94: + identifier: 94 + x: Cells + x_name: Cell + y: tally + y_name: Value + 134: + identifier: 134 + x: Cells + x_name: Cell + y: tally + y_name: Value + 164: + identifier: 164 + x: Cells + x_name: Cell + y: tally + y_name: Value + 184: + identifier: 184 + x: Cells + x_name: Cell + y: tally + y_name: Value + 194: + identifier: 194 + x: Cells + x_name: Cell + y: tally + y_name: Value + 204: + identifier: 204 + x: Cells + x_name: Cell + y: tally + y_name: Value + 214: + identifier: 214 + x: Cor A + x_name: R [cm] + y: tally + y_name: Value + 224: + identifier: 224 + x: Cor A + x_name: R [cm] + y: tally + y_name: Value + 234: + identifier: 234 + x: Cor A + x_name: R [cm] + y: tally + y_name: Value + 244: + identifier: 244 + x: Cor A + x_name: R [cm] + y: tally + y_name: Value + 254: + identifier: 254 + x: Cor A + x_name: R [cm] + y: tally + y_name: Value diff --git a/jade/output.py b/jade/output.py index 60aad213..3fb71dad 100644 --- a/jade/output.py +++ b/jade/output.py @@ -31,6 +31,7 @@ import sys import json import logging +from enum import Enum from typing import TYPE_CHECKING from f4enix.output.mctal import Mctal, Tally from f4enix.output.meshtal import Meshtal, Fmesh1D @@ -60,6 +61,20 @@ CRED = "\033[91m" CEND = "\033[0m" +class BinningType(Enum): + ENERGY = 'Energy' + CELLS = 'Cells' + TIME = 'Time' + TALLY = 'tally' + DIR = 'Dir' + USER = 'User' + SEGMENTS = 'Segments' + MULTIPLIER = 'Multiplier' + COSINE = 'Cosine' + CORA = 'Cor A' + CORB = 'Cor B' + CORC = 'Cor C' + class AbstractOutput(abc.ABC): @abc.abstractmethod diff --git a/jade/plotter.py b/jade/plotter.py index d044028b..82bda902 100644 --- a/jade/plotter.py +++ b/jade/plotter.py @@ -20,9 +20,10 @@ # You should have received a copy of the GNU General Public License # along with JADE. If not, see . - +from __future__ import annotations import math import os +from enum import Enum import matplotlib.pyplot as plt @@ -59,6 +60,15 @@ plt.rc("figure", titlesize=BIGGER_SIZE) # fontsize of the figure title plt.rc("lines", markersize=12) # Marker default size +class PlotType(Enum): + BINNED = 'Binned graph' + RATIO = 'Ratio graph' + EXP = 'Experimental points' + EXP_GROUP = 'Experimental points group' + CE_EXP_GROUP = 'Experimental points group CE' + DISCRETE_EXP = 'Discreete Experimental points' + GROUPED_BARS = 'Grouped bars' + WAVES = 'Waves' # ============================================================================ # Specific data for benchmarks plots # ============================================================================ @@ -214,7 +224,7 @@ def __init__( "#dede00", ] * 50 - def plot(self, plot_type): + def plot(self, plot_type: PlotType): """ Function to be called to actually perform the plot @@ -237,11 +247,11 @@ def plot(self, plot_type): """ # --- Binned Plot --- - if plot_type == "Binned graph": + if plot_type == PlotType.BINNED: outp = self._binned_plot() # --- Ratio Plot --- - elif plot_type == "Ratio graph": + elif plot_type == PlotType.RATIO: if self.testname == "ITER_1D": # Special actions for ITER 1D outp = self._ratio_plot( additional_labels=ADD_LABELS_ITER1D, v_lines=VERT_LINES_ITER1D @@ -266,10 +276,10 @@ def plot(self, plot_type): outp = self._ratio_plot() # --- Experimental Points Plot --- - elif plot_type == "Experimental points": + elif plot_type == PlotType.EXP: outp = self._exp_points_plot(test_name=self.testname) - elif plot_type == "Experimental points group": + elif plot_type == PlotType.EXP_GROUP: if self.testname == "Tiara-BC": # Special actions for Tiara-BC outp = self._exp_points_group_plot( test_name=self.testname, x_scale="linear" @@ -277,7 +287,7 @@ def plot(self, plot_type): else: outp = self._exp_points_group_plot(test_name=self.testname) - elif plot_type == "Experimental points group CE": + elif plot_type == PlotType.CE_EXP_GROUP: if self.testname == "Tiara-BC": # Special actions for Tiara-BC outp = self._exp_points_group_plot_CE( test_name=self.testname, x_scale="linear" @@ -286,11 +296,11 @@ def plot(self, plot_type): outp = self._exp_points_group_plot_CE(test_name=self.testname) # --- Experimental Points Plot --- - elif plot_type == "Discreet Experimental points": + elif plot_type == PlotType.DISCRETE_EXP: outp = self._exp_points_discreet_plot() # --- Grouped bars chart --- - elif plot_type == "Grouped bars": + elif plot_type == PlotType.GROUPED_BARS: if self.testname == "C_Model": log = True xlegend = None @@ -304,7 +314,7 @@ def plot(self, plot_type): outp = self._grouped_bar(log=log, xlegend=xlegend) # --- Waves plot --- - elif plot_type == "Waves": + elif plot_type == PlotType.WAVES: outp = self._waves() # --- Deafault --- diff --git a/tests/configuration_test.py b/tests/configuration_test.py index c03306f5..aa54ad97 100644 --- a/tests/configuration_test.py +++ b/tests/configuration_test.py @@ -22,8 +22,10 @@ import os import sys + import pytest -from jade.configuration import Configuration + +from jade.configuration import ComputationalConfig, Configuration cp = os.path.dirname(os.path.abspath(__file__)) modules_path = os.path.dirname(cp) @@ -40,7 +42,6 @@ def config(): class TestConfiguration: - def test_read(self, config): # TODO # Check that everything is read in a correct way @@ -51,3 +52,34 @@ def test_get_lib_name(self, config): expected_list = ["FENDL 2.1c", "33c", "pincopalle"] for suffix, expected in zip(suffix_list, expected_list): assert config.get_lib_name(suffix) == expected + + +class TestComputationalConfig: + def test_conformity_defaults(self): + """test all yaml configuration files found in the default settings""" + root = os.path.join( + modules_path, "jade", "default_settings", "Benchmarks_Configuration" + ) + for file in os.listdir(root): + if file.endswith(".yaml"): + cfg = ComputationalConfig.from_yaml(os.path.join(root, file)) + assert cfg + + def test_allowables(self): + # additional keyword not supported by the data class + with pytest.raises(TypeError): + cfg = ComputationalConfig.from_yaml( + os.path.join(resources, "wrong_cfg.yaml") + ) + + # unsupported plot type + with pytest.raises(ValueError): + cfg = ComputationalConfig.from_yaml( + os.path.join(resources, "wrong_cfg2.yaml") + ) + + # unsupported Tally bin type + with pytest.raises(ValueError): + cfg = ComputationalConfig.from_yaml( + os.path.join(resources, "wrong_cfg3.yaml") + )