From c28c379e671d7cd8491f34e2456823be719c3091 Mon Sep 17 00:00:00 2001 From: BitterB0NG0 <93603537+BitterB0NG0@users.noreply.github.com> Date: Thu, 28 Nov 2024 18:26:17 -0700 Subject: [PATCH] files/inp: updated imports --- README.md | 2 +- scripts/build_cell_options.py | 7 +- scripts/build_data.py | 12 +- scripts/build_surfaces.py | 7 +- src/pymcnp/files/inp/__init__.py | 226 ++++----- src/pymcnp/files/inp/cell.py | 159 +------ src/pymcnp/files/inp/cell_geometry.py | 129 +++++ src/pymcnp/files/inp/cell_keyword.py | 60 +++ src/pymcnp/files/inp/cell_option.py | 59 +-- .../__init__.py | 0 .../bflcl.py | 3 +- .../cosy.py | 3 +- .../dxc.py | 3 +- .../elpt.py | 3 +- .../ext.py | 3 +- .../fcl.py | 3 +- .../fill.py | 3 +- .../imp.py | 3 +- .../lat.py | 3 +- .../nonu.py | 3 +- .../pd.py | 3 +- .../pwt.py | 3 +- .../tmp.py | 3 +- .../trcl.py | 3 +- .../u.py | 3 +- .../unc.py | 3 +- .../vol.py | 3 +- .../wwn.py | 3 +- src/pymcnp/files/inp/data.py | 222 +-------- .../__init__.py | 0 .../{subclasses_data => data_cards}/act.py | 6 +- .../{subclasses_data => data_cards}/area.py | 2 +- .../{subclasses_data => data_cards}/awtab.py | 4 +- .../{subclasses_data => data_cards}/bflcl.py | 2 +- .../{subclasses_data => data_cards}/bfld.py | 8 +- .../{subclasses_data => data_cards}/cosy.py | 2 +- .../{subclasses_data => data_cards}/cosyp.py | 2 +- .../{subclasses_data => data_cards}/cut.py | 2 +- .../inp/{subclasses_data => data_cards}/dm.py | 2 +- .../{subclasses_data => data_cards}/drxs.py | 2 +- .../{subclasses_data => data_cards}/elpt.py | 2 +- .../{subclasses_data => data_cards}/embdb.py | 2 +- .../{subclasses_data => data_cards}/embdf.py | 2 +- .../{subclasses_data => data_cards}/embeb.py | 2 +- .../{subclasses_data => data_cards}/embed.py | 6 +- .../{subclasses_data => data_cards}/embee.py | 6 +- .../{subclasses_data => data_cards}/embem.py | 2 +- .../{subclasses_data => data_cards}/embtb.py | 2 +- .../{subclasses_data => data_cards}/embtm.py | 2 +- .../{subclasses_data => data_cards}/fill.py | 2 +- .../{subclasses_data => data_cards}/fmult.py | 6 +- .../{subclasses_data => data_cards}/hsrc.py | 2 +- .../{subclasses_data => data_cards}/kcode.py | 2 +- .../{subclasses_data => data_cards}/kopts.py | 6 +- .../{subclasses_data => data_cards}/ksrc.py | 4 +- .../{subclasses_data => data_cards}/lae.py | 2 +- .../{subclasses_data => data_cards}/lat.py | 2 +- .../{subclasses_data => data_cards}/lbc.py | 0 .../{subclasses_data => data_cards}/lca.py | 2 +- .../{subclasses_data => data_cards}/lcb.py | 2 +- .../{subclasses_data => data_cards}/lcc.py | 2 +- .../{subclasses_data => data_cards}/leb.py | 2 +- .../inp/{subclasses_data => data_cards}/m.py | 8 +- .../{subclasses_data => data_cards}/mgopt.py | 4 +- .../{subclasses_data => data_cards}/mode.py | 2 +- .../inp/{subclasses_data => data_cards}/mt.py | 2 +- .../{subclasses_data => data_cards}/nonu.py | 2 +- .../{subclasses_data => data_cards}/nps.py | 2 +- .../{subclasses_data => data_cards}/otfdb.py | 2 +- .../{subclasses_data => data_cards}/rand.py | 6 +- .../inp/{subclasses_data => data_cards}/sc.py | 2 +- .../{subclasses_data => data_cards}/sdef.py | 6 +- .../{subclasses_data => data_cards}/ssr.py | 6 +- .../{subclasses_data => data_cards}/thtme.py | 2 +- .../inp/{subclasses_data => data_cards}/tr.py | 4 +- .../{subclasses_data => data_cards}/tropt.py | 6 +- .../inp/{subclasses_data => data_cards}/u.py | 2 +- .../{subclasses_data => data_cards}/unc.py | 2 +- .../{subclasses_data => data_cards}/uran.py | 4 +- .../{subclasses_data => data_cards}/void.py | 2 +- .../inp/{subclasses_data => data_cards}/xs.py | 4 +- src/pymcnp/files/inp/data_entry.py | 17 + src/pymcnp/files/inp/data_keyword.py | 17 + src/pymcnp/files/inp/data_mnemonic.py | 184 ++++++++ src/pymcnp/files/inp/data_option.py | 21 + src/pymcnp/files/inp/inp.py | 439 +++++++++--------- src/pymcnp/files/inp/surface.py | 74 --- .../__init__.py | 0 .../arb.py | 3 +- .../box.py | 3 +- .../c_x.py | 3 +- .../c_y.py | 3 +- .../c_z.py | 3 +- .../cx.py | 3 +- .../cy.py | 3 +- .../cz.py | 3 +- .../ell.py | 3 +- .../gq.py | 3 +- .../k_x.py | 3 +- .../k_y.py | 3 +- .../k_z.py | 3 +- .../kx.py | 3 +- .../ky.py | 3 +- .../kz.py | 3 +- .../p.py | 3 +- .../px.py | 3 +- .../py.py | 3 +- .../pz.py | 3 +- .../rcc.py | 3 +- .../rec.py | 3 +- .../rhp.py | 3 +- .../rpp.py | 3 +- .../s.py | 3 +- .../so.py | 3 +- .../sph.py | 3 +- .../sq.py | 3 +- .../sx.py | 3 +- .../sy.py | 3 +- .../sz.py | 3 +- .../trc.py | 3 +- .../tx.py | 3 +- .../ty.py | 3 +- .../tz.py | 3 +- .../wed.py | 3 +- .../x.py | 3 +- .../y.py | 3 +- .../z.py | 3 +- src/pymcnp/files/inp/surface_mnemonic.py | 79 ++++ 128 files changed, 1076 insertions(+), 969 deletions(-) create mode 100644 src/pymcnp/files/inp/cell_geometry.py create mode 100644 src/pymcnp/files/inp/cell_keyword.py rename src/pymcnp/files/inp/{subclasses_cell_options => cell_options}/__init__.py (100%) rename src/pymcnp/files/inp/{subclasses_cell_options => cell_options}/bflcl.py (95%) rename src/pymcnp/files/inp/{subclasses_cell_options => cell_options}/cosy.py (95%) rename src/pymcnp/files/inp/{subclasses_cell_options => cell_options}/dxc.py (97%) rename src/pymcnp/files/inp/{subclasses_cell_options => cell_options}/elpt.py (96%) rename src/pymcnp/files/inp/{subclasses_cell_options => cell_options}/ext.py (96%) rename src/pymcnp/files/inp/{subclasses_cell_options => cell_options}/fcl.py (96%) rename src/pymcnp/files/inp/{subclasses_cell_options => cell_options}/fill.py (96%) rename src/pymcnp/files/inp/{subclasses_cell_options => cell_options}/imp.py (96%) rename src/pymcnp/files/inp/{subclasses_cell_options => cell_options}/lat.py (95%) rename src/pymcnp/files/inp/{subclasses_cell_options => cell_options}/nonu.py (95%) rename src/pymcnp/files/inp/{subclasses_cell_options => cell_options}/pd.py (96%) rename src/pymcnp/files/inp/{subclasses_cell_options => cell_options}/pwt.py (95%) rename src/pymcnp/files/inp/{subclasses_cell_options => cell_options}/tmp.py (96%) rename src/pymcnp/files/inp/{subclasses_cell_options => cell_options}/trcl.py (95%) rename src/pymcnp/files/inp/{subclasses_cell_options => cell_options}/u.py (95%) rename src/pymcnp/files/inp/{subclasses_cell_options => cell_options}/unc.py (96%) rename src/pymcnp/files/inp/{subclasses_cell_options => cell_options}/vol.py (95%) rename src/pymcnp/files/inp/{subclasses_cell_options => cell_options}/wwn.py (97%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/__init__.py (100%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/act.py (99%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/area.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/awtab.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/bflcl.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/bfld.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/cosy.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/cosyp.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/cut.py (99%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/dm.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/drxs.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/elpt.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/embdb.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/embdf.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/embeb.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/embed.py (99%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/embee.py (99%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/embem.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/embtb.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/embtm.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/fill.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/fmult.py (99%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/hsrc.py (99%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/kcode.py (99%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/kopts.py (99%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/ksrc.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/lae.py (99%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/lat.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/lbc.py (100%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/lca.py (99%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/lcb.py (99%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/lcc.py (99%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/leb.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/m.py (99%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/mgopt.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/mode.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/mt.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/nonu.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/nps.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/otfdb.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/rand.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/sc.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/sdef.py (99%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/ssr.py (99%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/thtme.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/tr.py (99%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/tropt.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/u.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/unc.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/uran.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/void.py (98%) rename src/pymcnp/files/inp/{subclasses_data => data_cards}/xs.py (98%) create mode 100644 src/pymcnp/files/inp/data_entry.py create mode 100644 src/pymcnp/files/inp/data_keyword.py create mode 100644 src/pymcnp/files/inp/data_mnemonic.py create mode 100644 src/pymcnp/files/inp/data_option.py rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/__init__.py (100%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/arb.py (99%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/box.py (99%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/c_x.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/c_y.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/c_z.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/cx.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/cy.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/cz.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/ell.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/gq.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/k_x.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/k_y.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/k_z.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/kx.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/ky.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/kz.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/p.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/px.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/py.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/pz.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/rcc.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/rec.py (99%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/rhp.py (99%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/rpp.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/s.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/so.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/sph.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/sq.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/sx.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/sy.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/sz.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/trc.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/tx.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/ty.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/tz.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/wed.py (99%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/x.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/y.py (98%) rename src/pymcnp/files/inp/{subclasses_surfaces => surface_cards}/z.py (98%) create mode 100644 src/pymcnp/files/inp/surface_mnemonic.py diff --git a/README.md b/README.md index 080c061..9de9515 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ After instaling `pytest`, test the `pymcnp` package by calling the following com ## Metaprogramming -To regenerate the autogenerated files in `files/inp/subclasses_cell_option`, `files/inp/subclasses_data`, and `files/inp/subclasses_surfaces`, run the following Python scripts: +To regenerate the autogenerated files in `files/inp/cell_option`, `files/inp/data`, and `files/inp/surfaces`, run the following Python scripts: parallel python3 {} ::: scripts/build_cell_options.py scripts/build_surfaces.py scripts/build_data.py diff --git a/scripts/build_cell_options.py b/scripts/build_cell_options.py index d071e4c..5849a35 100644 --- a/scripts/build_cell_options.py +++ b/scripts/build_cell_options.py @@ -15,7 +15,8 @@ def build_CellOption(cell_option: _data.CellOptionScheme): o += 'import re\n' o += 'from typing import Final\n' o += '\n' - o += 'from ..cell_option import CellOption, CellKeyword\n' + o += 'from ..cell_option import CellOption\n' + o += 'from ..cell_keyword import CellKeyword\n' o += 'from ...utils import types, errors, _parser\n' o += '\n' o += f'class {cell_option.name}(CellOption):\n' @@ -152,7 +153,7 @@ def build_CellOption(cell_option: _data.CellOptionScheme): for cell_option in _data.CELL_OPTIONS: filename = pathlib.Path(__file__).parent / pathlib.Path( - f'../src/pymcnp/files/inp/subclasses_cell_options/{cell_option.mnemonic}.py' + f'../src/pymcnp/files/inp/cell_options/{cell_option.mnemonic}.py' ) with filename.open('w') as file: file.write( @@ -163,7 +164,7 @@ def build_CellOption(cell_option: _data.CellOptionScheme): init_all.append(f'"{cell_option.name}",') init_path = pathlib.Path(__file__).parent / pathlib.Path( - '../src/pymcnp/files/inp/subclasses_cell_options/__init__.py' + '../src/pymcnp/files/inp/cell_options/__init__.py' ) with init_path.open('w') as file: file.write( diff --git a/scripts/build_data.py b/scripts/build_data.py index a74e49f..0e458f4 100644 --- a/scripts/build_data.py +++ b/scripts/build_data.py @@ -321,10 +321,10 @@ def build_Data(data: _data.DataScheme): o += 'from typing import Final, Union\n' o += '\n' o += 'from ..data import Data\n' - o += 'from ..data import DataMnemonic\n' - o += 'from ..data import DataEntry\n' if data.entries else '' - o += 'from ..data import DataOption\n' if data.options else '' - o += 'from ..data import DataKeyword\n' if data.options else '' + o += 'from ..data_mnemonic import DataMnemonic\n' + o += 'from ..data_entry import DataEntry\n' if data.entries else '' + o += 'from ..data_option import DataOption\n' if data.options else '' + o += 'from ..data_keyword import DataKeyword\n' if data.options else '' o += 'from ...utils import types, errors, _parser\n' o += '\n' @@ -595,7 +595,7 @@ def build_Data(data: _data.DataScheme): for data in _data.DATA_CARDS: filename = pathlib.Path(__file__).parent / pathlib.Path( - f'../src/pymcnp/files/inp/subclasses_data/{data.name.lower()}.py' + f'../src/pymcnp/files/inp/data_cards/{data.name.lower()}.py' ) with filename.open('w') as file: file.write(build_Data(data)) @@ -603,7 +603,7 @@ def build_Data(data: _data.DataScheme): init_all.append(f'"{data.name}",') init_path = pathlib.Path(__file__).parent / pathlib.Path( - '../src/pymcnp/files/inp/subclasses_data/__init__.py' + '../src/pymcnp/files/inp/data_cards/__init__.py' ) with init_path.open('w') as file: file.write( diff --git a/scripts/build_surfaces.py b/scripts/build_surfaces.py index 231770b..5faf62c 100644 --- a/scripts/build_surfaces.py +++ b/scripts/build_surfaces.py @@ -14,7 +14,8 @@ def build_Surface(surface: _data.SurfaceScheme): o += 'from typing import Final\n' o += '\n' - o += 'from ..surface import Surface, SurfaceMnemonic\n' + o += 'from ..surface import Surface\n' + o += 'from ..surface_mnemonic import SurfaceMnemonic\n' o += 'from ...utils import types, errors, _parser\n' o += '\n' o += f'class {surface.name}(Surface):\n' @@ -159,7 +160,7 @@ def build_Surface(surface: _data.SurfaceScheme): for surface in _data.SURFACE_CARDS: filename = pathlib.Path(__file__).parent / pathlib.Path( - f'../src/pymcnp/files/inp/subclasses_surfaces/{surface.name.lower()}.py' + f'../src/pymcnp/files/inp/surface_cards/{surface.name.lower()}.py' ) with filename.open('w') as file: file.write( @@ -170,7 +171,7 @@ def build_Surface(surface: _data.SurfaceScheme): init_all.append(f'"{surface.name}",') init_path = pathlib.Path(__file__).parent / pathlib.Path( - '../src/pymcnp/files/inp/subclasses_surfaces/__init__.py' + '../src/pymcnp/files/inp/surface_cards/__init__.py' ) with init_path.open('w') as file: file.write( diff --git a/src/pymcnp/files/inp/__init__.py b/src/pymcnp/files/inp/__init__.py index 3ff9ceb..a051507 100644 --- a/src/pymcnp/files/inp/__init__.py +++ b/src/pymcnp/files/inp/__init__.py @@ -1,122 +1,122 @@ from .inp import Inp from .comment import Comment from .cell import Cell -from .cell import CellGeometry -from .cell_option import CellKeyword +from .cell_geometry import CellGeometry +from .cell_keyword import CellKeyword from .cell_option import CellOption -from .cell import Imp as CellImp -from .cell import Vol as CellVol -from .cell import Pwt as CellPwt -from .cell import Ext as CellExt -from .cell import Fcl as CellFcl -from .cell import Wwn as CellWwn -from .cell import Dxc as CellDxc -from .cell import Nonu as CellNonu -from .cell import Pd as CellPd -from .cell import Tmp as CellTmp -from .cell import U as CellU -from .cell import Trcl as CellTrcl -from .cell import Lat as CellLat -from .cell import Fill as CellFill -from .cell import Elpt as CellElpt -from .cell import Cosy as CellCosy -from .cell import Bflcl as CellBflcl -from .cell import Unc as CellUnc +from .cell_options import Imp as CellImp +from .cell_options import Vol as CellVol +from .cell_options import Pwt as CellPwt +from .cell_options import Ext as CellExt +from .cell_options import Fcl as CellFcl +from .cell_options import Wwn as CellWwn +from .cell_options import Dxc as CellDxc +from .cell_options import Nonu as CellNonu +from .cell_options import Pd as CellPd +from .cell_options import Tmp as CellTmp +from .cell_options import U as CellU +from .cell_options import Trcl as CellTrcl +from .cell_options import Lat as CellLat +from .cell_options import Fill as CellFill +from .cell_options import Elpt as CellElpt +from .cell_options import Cosy as CellCosy +from .cell_options import Bflcl as CellBflcl +from .cell_options import Unc as CellUnc from .surface import Surface -from .surface import SurfaceMnemonic -from .subclasses_surfaces import P as SurfaceP -from .subclasses_surfaces import Px as SurfacePx -from .subclasses_surfaces import Py as SurfacePy -from .subclasses_surfaces import Pz as SurfacePz -from .subclasses_surfaces import So as SurfaceSo -from .subclasses_surfaces import S as SurfaceS -from .subclasses_surfaces import Sx as SurfaceSx -from .subclasses_surfaces import Sy as SurfaceSy -from .subclasses_surfaces import Sz as SurfaceSz -from .subclasses_surfaces import C_x as SurfaceC_x -from .subclasses_surfaces import C_y as SurfaceC_y -from .subclasses_surfaces import C_z as SurfaceC_z -from .subclasses_surfaces import Cx as SurfaceCx -from .subclasses_surfaces import Cy as SurfaceCy -from .subclasses_surfaces import Cz as SurfaceCz -from .subclasses_surfaces import K_x as SurfaceK_x -from .subclasses_surfaces import K_y as SurfaceK_y -from .subclasses_surfaces import K_z as SurfaceK_z -from .subclasses_surfaces import Kx as SurfaceKx -from .subclasses_surfaces import Ky as SurfaceKy -from .subclasses_surfaces import Kz as SurfaceKz -from .subclasses_surfaces import Sq as SurfaceSq -from .subclasses_surfaces import Gq as SurfaceGq -from .subclasses_surfaces import Tx as SurfaceTx -from .subclasses_surfaces import Ty as SurfaceTy -from .subclasses_surfaces import Tz as SurfaceTz -from .subclasses_surfaces import X as SurfaceX -from .subclasses_surfaces import Y as SurfaceY -from .subclasses_surfaces import Z as SurfaceZ -from .subclasses_surfaces import Box as SurfaceBox -from .subclasses_surfaces import Rpp as SurfaceRpp -from .subclasses_surfaces import Sph as SurfaceSph -from .subclasses_surfaces import Rcc as SurfaceRcc -from .subclasses_surfaces import Rhp as SurfaceRhp -from .subclasses_surfaces import Rec as SurfaceRec -from .subclasses_surfaces import Trc as SurfaceTrc -from .subclasses_surfaces import Ell as SurfaceEll -from .subclasses_surfaces import Wed as SurfaceWed +from .surface_mnemonic import SurfaceMnemonic +from .surface_cards import P as SurfaceP +from .surface_cards import Px as SurfacePx +from .surface_cards import Py as SurfacePy +from .surface_cards import Pz as SurfacePz +from .surface_cards import So as SurfaceSo +from .surface_cards import S as SurfaceS +from .surface_cards import Sx as SurfaceSx +from .surface_cards import Sy as SurfaceSy +from .surface_cards import Sz as SurfaceSz +from .surface_cards import C_x as SurfaceC_x +from .surface_cards import C_y as SurfaceC_y +from .surface_cards import C_z as SurfaceC_z +from .surface_cards import Cx as SurfaceCx +from .surface_cards import Cy as SurfaceCy +from .surface_cards import Cz as SurfaceCz +from .surface_cards import K_x as SurfaceK_x +from .surface_cards import K_y as SurfaceK_y +from .surface_cards import K_z as SurfaceK_z +from .surface_cards import Kx as SurfaceKx +from .surface_cards import Ky as SurfaceKy +from .surface_cards import Kz as SurfaceKz +from .surface_cards import Sq as SurfaceSq +from .surface_cards import Gq as SurfaceGq +from .surface_cards import Tx as SurfaceTx +from .surface_cards import Ty as SurfaceTy +from .surface_cards import Tz as SurfaceTz +from .surface_cards import X as SurfaceX +from .surface_cards import Y as SurfaceY +from .surface_cards import Z as SurfaceZ +from .surface_cards import Box as SurfaceBox +from .surface_cards import Rpp as SurfaceRpp +from .surface_cards import Sph as SurfaceSph +from .surface_cards import Rcc as SurfaceRcc +from .surface_cards import Rhp as SurfaceRhp +from .surface_cards import Rec as SurfaceRec +from .surface_cards import Trc as SurfaceTrc +from .surface_cards import Ell as SurfaceEll +from .surface_cards import Wed as SurfaceWed from .data import Data -from .data import DataMnemonic -from .data import DataEntry -from .data import DataKeyword -from .data import DataOption -from .subclasses_data import Area as DataArea -from .subclasses_data import Tr as DataTr -from .subclasses_data import U as DataU -from .subclasses_data import Lat as DataLat -from .subclasses_data import Fill as DataFill -from .subclasses_data import Uran as DataUran -from .subclasses_data import Dm as DataDm -from .subclasses_data import Embed as DataEmbed -from .subclasses_data import Embee as DataEmbee -from .subclasses_data import Embeb as DataEmbeb -from .subclasses_data import Embem as DataEmbem -from .subclasses_data import Embtb as DataEmbtb -from .subclasses_data import Embtm as DataEmbtm -from .subclasses_data import Embdb as DataEmbdb -from .subclasses_data import Embdf as DataEmbdf -from .subclasses_data import M as DataM -from .subclasses_data import Mt as DataMt -from .subclasses_data import Otfdb as DataOtfdb -from .subclasses_data import Nonu as DataNonu -from .subclasses_data import Awtab as DataAwtab -from .subclasses_data import Xs as DataXs -from .subclasses_data import Void as DataVoid -from .subclasses_data import Mgopt as DataMgopt -from .subclasses_data import Drxs as DataDrxs -from .subclasses_data import Mode as DataMode -from .subclasses_data import Act as DataAct -from .subclasses_data import Cut as DataCut -from .subclasses_data import Elpt as DataElpt -from .subclasses_data import Thtme as DataThtme -from .subclasses_data import Lca as DataLca -from .subclasses_data import Lcb as DataLcb -from .subclasses_data import Lcc as DataLcc -from .subclasses_data import Lae as DataLae -from .subclasses_data import Leb as DataLeb -from .subclasses_data import Fmult as DataFmult -from .subclasses_data import Tropt as DataTropt -from .subclasses_data import Unc as DataUnc -from .subclasses_data import Cosyp as DataCosyp -from .subclasses_data import Cosy as DataCosy -from .subclasses_data import Bfld as DataBfld -from .subclasses_data import Bflcl as DataBflcl -from .subclasses_data import Sdef as DataSdef -from .subclasses_data import Sc as DataSc -from .subclasses_data import Ssr as DataSsr -from .subclasses_data import Kcode as DataKcode -from .subclasses_data import Ksrc as DataKsrc -from .subclasses_data import Kopts as DataKopts -from .subclasses_data import Hsrc as DataHsrc -from .subclasses_data import Nps as DataNps -from .subclasses_data import Rand as DataRand +from .data_mnemonic import DataMnemonic +from .data_entry import DataEntry +from .data_keyword import DataKeyword +from .data_option import DataOption +from .data_cards import Area as DataArea +from .data_cards import Tr as DataTr +from .data_cards import U as DataU +from .data_cards import Lat as DataLat +from .data_cards import Fill as DataFill +from .data_cards import Uran as DataUran +from .data_cards import Dm as DataDm +from .data_cards import Embed as DataEmbed +from .data_cards import Embee as DataEmbee +from .data_cards import Embeb as DataEmbeb +from .data_cards import Embem as DataEmbem +from .data_cards import Embtb as DataEmbtb +from .data_cards import Embtm as DataEmbtm +from .data_cards import Embdb as DataEmbdb +from .data_cards import Embdf as DataEmbdf +from .data_cards import M as DataM +from .data_cards import Mt as DataMt +from .data_cards import Otfdb as DataOtfdb +from .data_cards import Nonu as DataNonu +from .data_cards import Awtab as DataAwtab +from .data_cards import Xs as DataXs +from .data_cards import Void as DataVoid +from .data_cards import Mgopt as DataMgopt +from .data_cards import Drxs as DataDrxs +from .data_cards import Mode as DataMode +from .data_cards import Act as DataAct +from .data_cards import Cut as DataCut +from .data_cards import Elpt as DataElpt +from .data_cards import Thtme as DataThtme +from .data_cards import Lca as DataLca +from .data_cards import Lcb as DataLcb +from .data_cards import Lcc as DataLcc +from .data_cards import Lae as DataLae +from .data_cards import Leb as DataLeb +from .data_cards import Fmult as DataFmult +from .data_cards import Tropt as DataTropt +from .data_cards import Unc as DataUnc +from .data_cards import Cosyp as DataCosyp +from .data_cards import Cosy as DataCosy +from .data_cards import Bfld as DataBfld +from .data_cards import Bflcl as DataBflcl +from .data_cards import Sdef as DataSdef +from .data_cards import Sc as DataSc +from .data_cards import Ssr as DataSsr +from .data_cards import Kcode as DataKcode +from .data_cards import Ksrc as DataKsrc +from .data_cards import Kopts as DataKopts +from .data_cards import Hsrc as DataHsrc +from .data_cards import Nps as DataNps +from .data_cards import Rand as DataRand __all__ = [ 'Inp', diff --git a/src/pymcnp/files/inp/cell.py b/src/pymcnp/files/inp/cell.py index ba0994e..8c6bf77 100644 --- a/src/pymcnp/files/inp/cell.py +++ b/src/pymcnp/files/inp/cell.py @@ -6,151 +6,32 @@ from typing import Final from . import _card -from .subclasses_cell_options import Imp -from .subclasses_cell_options import Vol -from .subclasses_cell_options import Pwt -from .subclasses_cell_options import Ext -from .subclasses_cell_options import Fcl -from .subclasses_cell_options import Wwn -from .subclasses_cell_options import Dxc -from .subclasses_cell_options import Nonu -from .subclasses_cell_options import Pd -from .subclasses_cell_options import Tmp -from .subclasses_cell_options import U -from .subclasses_cell_options import Trcl -from .subclasses_cell_options import Lat -from .subclasses_cell_options import Fill -from .subclasses_cell_options import Elpt -from .subclasses_cell_options import Cosy -from .subclasses_cell_options import Bflcl -from .subclasses_cell_options import Unc from .cell_option import CellOption -from .cell_option import CellKeyword +from .cell_keyword import CellKeyword +from .cell_geometry import CellGeometry +from .cell_options import Imp +from .cell_options import Vol +from .cell_options import Pwt +from .cell_options import Ext +from .cell_options import Fcl +from .cell_options import Wwn +from .cell_options import Dxc +from .cell_options import Nonu +from .cell_options import Pd +from .cell_options import Tmp +from .cell_options import U +from .cell_options import Trcl +from .cell_options import Lat +from .cell_options import Fill +from .cell_options import Elpt +from .cell_options import Cosy +from .cell_options import Bflcl +from .cell_options import Unc from ..utils import types from ..utils import errors from ..utils import _parser -class CellGeometry(_card.CardEntry): - """ - Represents INP cell card geometry formulas. - - ``CellGeometry`` implements ``_card.CardMnemonic``. - - Attributes: - string: Geometry formula string representation. - """ - - _OPERATIONS_ORDER = {'#': 0, ' ': 1, ':': 2} - - def __init__(self, formula: str): - """ - Initializes ``CellGeometry``. - - Parameters: - formula: INP for cell geometry. - - Raises: - McnpError: EXPECTED_TOKEN. - McnpError: INVALID_CELL_GEOMETRY. - """ - - if not formula: - raise errors.McnpError(errors.McnpCode.INVALID_CELL_GEOMETRY, formula) - - # Running Shunting-Yard Algorithm - ops_stack = _parser.Parser( - [], - errors.McnpError(errors.McnpCode.EXPECTED_TOKEN, formula), - ) - out_stack = _parser.Parser( - [], - errors.McnpError(errors.McnpCode.EXPECTED_TOKEN, formula), - ) - inp_stack = re.findall( - r'#|:| : |[()]| [()]|[()] | [()] | |[+-]?\d+', - formula, - ) - - if ''.join(inp_stack) != formula: - raise errors.McnpError(errors.McnpCode.INVALID_CELL_GEOMETRY, formula) - - for token in inp_stack: - if re.match(r'[+-]?\d+', token): - # Processing Surface Number - - entry = int(token) - if entry is None or not (entry != 0 and -99_999_999 <= entry <= 99_999_999): - raise errors.McnpError(errors.McnpCode.INVALID_CELL_GEOMETRY, formula) - - out_stack.pushr(token) - - elif re.match(r'#', token): - # Processing Unary Operator - ops_stack.pushr(token) - - elif re.match(r'([(]| [(]|[(] | [(] )', token): - # Processing Left Parenthesis - ops_stack.pushr('(') - - elif re.match(r'([)]| [)]|[)] | [)] )', token): - # Processing Right Parenthesis - while ops_stack.peekr() != '(': - out_stack.pushr(ops_stack.popr()) - - ops_stack.popr() - - elif re.match(r':| : | |: | :', token): - # Processing Binary Operator - token = token.strip() if token != ' ' else token - - while ( - ops_stack - and ops_stack.peekr() not in {'(', ')'} - and self._OPERATIONS_ORDER[ops_stack.peekr()] >= self._OPERATIONS_ORDER[token] - ): - out_stack.pushr(ops_stack.popr()) - - ops_stack.pushr(token) - - else: - # Unrecognized Character - assert False - - while ops_stack: - out_stack.pushr(ops_stack.popr()) - - self.formula = formula - - @staticmethod - def from_mcnp(source: str) -> str: - """ - Generates ``CellGeometry`` objects from INP. - - ``from_mcnp`` translates from INP to PyMCNP; it parses INP. - - Parameters: - source: INP for cell card geometry. - - Returns: - ``CellGeometry`` object. - """ - - return CellGeometry(source) - - def to_mcnp(self) -> str: - """ - Generates INP from ``CellGeometry``. - - ``to_mcnp`` translates from PyMCNP to INP. - - Returns: - INP for ``CellGeometry``. - """ - - return self.formula - - class Cell(_card.Card): """ Represents INP cell cards. diff --git a/src/pymcnp/files/inp/cell_geometry.py b/src/pymcnp/files/inp/cell_geometry.py new file mode 100644 index 0000000..7073cb4 --- /dev/null +++ b/src/pymcnp/files/inp/cell_geometry.py @@ -0,0 +1,129 @@ +""" +Contains classes representing INP cell card geometry formulas. +""" + +import re + +from . import _card +from ..utils import errors +from ..utils import _parser + + +class CellGeometry(_card.CardEntry): + """ + Represents INP cell card geometry formulas. + + ``CellGeometry`` implements ``_card.CardMnemonic``. + + Attributes: + string: Geometry formula string representation. + """ + + _OPERATIONS_ORDER = {'#': 0, ' ': 1, ':': 2} + + def __init__(self, formula: str): + """ + Initializes ``CellGeometry``. + + Parameters: + formula: INP for cell geometry. + + Raises: + McnpError: EXPECTED_TOKEN. + McnpError: INVALID_CELL_GEOMETRY. + """ + + if not formula: + raise errors.McnpError(errors.McnpCode.INVALID_CELL_GEOMETRY, formula) + + # Running Shunting-Yard Algorithm + ops_stack = _parser.Parser( + [], + errors.McnpError(errors.McnpCode.EXPECTED_TOKEN, formula), + ) + out_stack = _parser.Parser( + [], + errors.McnpError(errors.McnpCode.EXPECTED_TOKEN, formula), + ) + inp_stack = re.findall( + r'#|:| : |[()]| [()]|[()] | [()] | |[+-]?\d+', + formula, + ) + + if ''.join(inp_stack) != formula: + raise errors.McnpError(errors.McnpCode.INVALID_CELL_GEOMETRY, formula) + + for token in inp_stack: + if re.match(r'[+-]?\d+', token): + # Processing Surface Number + + entry = int(token) + if entry is None or not (entry != 0 and -99_999_999 <= entry <= 99_999_999): + raise errors.McnpError(errors.McnpCode.INVALID_CELL_GEOMETRY, formula) + + out_stack.pushr(token) + + elif re.match(r'#', token): + # Processing Unary Operator + ops_stack.pushr(token) + + elif re.match(r'([(]| [(]|[(] | [(] )', token): + # Processing Left Parenthesis + ops_stack.pushr('(') + + elif re.match(r'([)]| [)]|[)] | [)] )', token): + # Processing Right Parenthesis + while ops_stack.peekr() != '(': + out_stack.pushr(ops_stack.popr()) + + ops_stack.popr() + + elif re.match(r':| : | |: | :', token): + # Processing Binary Operator + token = token.strip() if token != ' ' else token + + while ( + ops_stack + and ops_stack.peekr() not in {'(', ')'} + and self._OPERATIONS_ORDER[ops_stack.peekr()] >= self._OPERATIONS_ORDER[token] + ): + out_stack.pushr(ops_stack.popr()) + + ops_stack.pushr(token) + + else: + # Unrecognized Character + assert False + + while ops_stack: + out_stack.pushr(ops_stack.popr()) + + self.formula = formula + + @staticmethod + def from_mcnp(source: str) -> str: + """ + Generates ``CellGeometry`` objects from INP. + + ``from_mcnp`` translates from INP to PyMCNP; it parses INP. + + Parameters: + source: INP for cell card geometry. + + Returns: + ``CellGeometry`` object. + """ + + return CellGeometry(source) + + def to_mcnp(self) -> str: + """ + Generates INP from ``CellGeometry``. + + ``to_mcnp`` translates from PyMCNP to INP. + + Returns: + INP for ``CellGeometry``. + """ + + return self.formula diff --git a/src/pymcnp/files/inp/cell_keyword.py b/src/pymcnp/files/inp/cell_keyword.py new file mode 100644 index 0000000..06e1fe9 --- /dev/null +++ b/src/pymcnp/files/inp/cell_keyword.py @@ -0,0 +1,60 @@ +""" +Contains classes representing INP cell card option keywords. +""" + +from . import _card +from ..utils import errors +from ..utils import _parser + + +class CellKeyword(_card.CardKeyword): + """ + Represents INP cell card option keywords. + + ``CellKeyword`` implements ``_card.CardKeyword``. + """ + + IMP = 'imp' + VOL = 'vol' + PWT = 'pwt' + EXT = 'ext' + FCL = 'fcl' + WWN = 'wwn' + DXC = 'dxc' + NONU = 'nonu' + PD = 'pd' + TMP = 'tmp' + U = 'u' + TRCL = 'trcl' + # COORDINATE_TRANSFORMATION_ANGLE = '*trcl' + LAT = 'lat' + FILL = 'fill' + # FILL_ANGLE = '*fill' + ELPT = 'elpt' + COSY = 'cosy' + BFLCL = 'bflcl' + UNC = 'unc' + + @staticmethod + def from_mcnp(source: str): + """ + Generates ``CellKeyword`` objects from INP. + + ``from_mcnp`` translates from INP to PyMCNP; it parses INP. + + Parameters: + source: INP for ``CellKeyword`` + + Returns: + ``CellKeyword`` object. + + Raises: + MCNPError: UNRECOGNIZED_KEYWORD. + """ + + source = _parser.Preprocessor.process_inp(source) + + try: + return CellKeyword(source) + except ValueError: + raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, source) diff --git a/src/pymcnp/files/inp/cell_option.py b/src/pymcnp/files/inp/cell_option.py index ea2ab0f..d18af5b 100644 --- a/src/pymcnp/files/inp/cell_option.py +++ b/src/pymcnp/files/inp/cell_option.py @@ -1,59 +1,8 @@ -from . import _card -from ..utils import errors -from ..utils import _parser - - -class CellKeyword(_card.CardKeyword): - """ - Represents INP cell card option keywords. - - ``CellKeyword`` implements ``_card.CardKeyword``. - """ - - IMP = 'imp' - VOL = 'vol' - PWT = 'pwt' - EXT = 'ext' - FCL = 'fcl' - WWN = 'wwn' - DXC = 'dxc' - NONU = 'nonu' - PD = 'pd' - TMP = 'tmp' - U = 'u' - TRCL = 'trcl' - # COORDINATE_TRANSFORMATION_ANGLE = '*trcl' - LAT = 'lat' - FILL = 'fill' - # FILL_ANGLE = '*fill' - ELPT = 'elpt' - COSY = 'cosy' - BFLCL = 'bflcl' - UNC = 'unc' - - @staticmethod - def from_mcnp(source: str): - """ - Generates ``CellKeyword`` objects from INP. - - ``from_mcnp`` translates from INP to PyMCNP; it parses INP. - - Parameters: - source: INP for ``CellKeyword`` - - Returns: - ``CellKeyword`` object. - - Raises: - MCNPError: UNRECOGNIZED_KEYWORD. - """ +""" +Contains classes representing INP cell card options. +""" - source = _parser.Preprocessor.process_inp(source) - - try: - return CellKeyword(source) - except ValueError: - raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, source) +from . import _card class CellOption(_card.CardOption): diff --git a/src/pymcnp/files/inp/subclasses_cell_options/__init__.py b/src/pymcnp/files/inp/cell_options/__init__.py similarity index 100% rename from src/pymcnp/files/inp/subclasses_cell_options/__init__.py rename to src/pymcnp/files/inp/cell_options/__init__.py diff --git a/src/pymcnp/files/inp/subclasses_cell_options/bflcl.py b/src/pymcnp/files/inp/cell_options/bflcl.py similarity index 95% rename from src/pymcnp/files/inp/subclasses_cell_options/bflcl.py rename to src/pymcnp/files/inp/cell_options/bflcl.py index 7babe18..b1bef7b 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/bflcl.py +++ b/src/pymcnp/files/inp/cell_options/bflcl.py @@ -5,7 +5,8 @@ import re from typing import Final -from ..cell_option import CellOption, CellKeyword +from ..cell_option import CellOption +from ..cell_keyword import CellKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_cell_options/cosy.py b/src/pymcnp/files/inp/cell_options/cosy.py similarity index 95% rename from src/pymcnp/files/inp/subclasses_cell_options/cosy.py rename to src/pymcnp/files/inp/cell_options/cosy.py index bd0fcae..5fc1a8e 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/cosy.py +++ b/src/pymcnp/files/inp/cell_options/cosy.py @@ -5,7 +5,8 @@ import re from typing import Final -from ..cell_option import CellOption, CellKeyword +from ..cell_option import CellOption +from ..cell_keyword import CellKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_cell_options/dxc.py b/src/pymcnp/files/inp/cell_options/dxc.py similarity index 97% rename from src/pymcnp/files/inp/subclasses_cell_options/dxc.py rename to src/pymcnp/files/inp/cell_options/dxc.py index 268bb3c..4c1b053 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/dxc.py +++ b/src/pymcnp/files/inp/cell_options/dxc.py @@ -5,7 +5,8 @@ import re from typing import Final -from ..cell_option import CellOption, CellKeyword +from ..cell_option import CellOption +from ..cell_keyword import CellKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_cell_options/elpt.py b/src/pymcnp/files/inp/cell_options/elpt.py similarity index 96% rename from src/pymcnp/files/inp/subclasses_cell_options/elpt.py rename to src/pymcnp/files/inp/cell_options/elpt.py index 006d59c..e7b117e 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/elpt.py +++ b/src/pymcnp/files/inp/cell_options/elpt.py @@ -5,7 +5,8 @@ import re from typing import Final -from ..cell_option import CellOption, CellKeyword +from ..cell_option import CellOption +from ..cell_keyword import CellKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_cell_options/ext.py b/src/pymcnp/files/inp/cell_options/ext.py similarity index 96% rename from src/pymcnp/files/inp/subclasses_cell_options/ext.py rename to src/pymcnp/files/inp/cell_options/ext.py index a6e6f0f..f5c97f2 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/ext.py +++ b/src/pymcnp/files/inp/cell_options/ext.py @@ -5,7 +5,8 @@ import re from typing import Final -from ..cell_option import CellOption, CellKeyword +from ..cell_option import CellOption +from ..cell_keyword import CellKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_cell_options/fcl.py b/src/pymcnp/files/inp/cell_options/fcl.py similarity index 96% rename from src/pymcnp/files/inp/subclasses_cell_options/fcl.py rename to src/pymcnp/files/inp/cell_options/fcl.py index 466297b..6f88a17 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/fcl.py +++ b/src/pymcnp/files/inp/cell_options/fcl.py @@ -5,7 +5,8 @@ import re from typing import Final -from ..cell_option import CellOption, CellKeyword +from ..cell_option import CellOption +from ..cell_keyword import CellKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_cell_options/fill.py b/src/pymcnp/files/inp/cell_options/fill.py similarity index 96% rename from src/pymcnp/files/inp/subclasses_cell_options/fill.py rename to src/pymcnp/files/inp/cell_options/fill.py index cd96f04..ff03fac 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/fill.py +++ b/src/pymcnp/files/inp/cell_options/fill.py @@ -5,7 +5,8 @@ import re from typing import Final -from ..cell_option import CellOption, CellKeyword +from ..cell_option import CellOption +from ..cell_keyword import CellKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_cell_options/imp.py b/src/pymcnp/files/inp/cell_options/imp.py similarity index 96% rename from src/pymcnp/files/inp/subclasses_cell_options/imp.py rename to src/pymcnp/files/inp/cell_options/imp.py index dc47dcc..4dac7b2 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/imp.py +++ b/src/pymcnp/files/inp/cell_options/imp.py @@ -5,7 +5,8 @@ import re from typing import Final -from ..cell_option import CellOption, CellKeyword +from ..cell_option import CellOption +from ..cell_keyword import CellKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_cell_options/lat.py b/src/pymcnp/files/inp/cell_options/lat.py similarity index 95% rename from src/pymcnp/files/inp/subclasses_cell_options/lat.py rename to src/pymcnp/files/inp/cell_options/lat.py index 70949ac..fb7b59b 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/lat.py +++ b/src/pymcnp/files/inp/cell_options/lat.py @@ -5,7 +5,8 @@ import re from typing import Final -from ..cell_option import CellOption, CellKeyword +from ..cell_option import CellOption +from ..cell_keyword import CellKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_cell_options/nonu.py b/src/pymcnp/files/inp/cell_options/nonu.py similarity index 95% rename from src/pymcnp/files/inp/subclasses_cell_options/nonu.py rename to src/pymcnp/files/inp/cell_options/nonu.py index 5f08d7a..d408d96 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/nonu.py +++ b/src/pymcnp/files/inp/cell_options/nonu.py @@ -5,7 +5,8 @@ import re from typing import Final -from ..cell_option import CellOption, CellKeyword +from ..cell_option import CellOption +from ..cell_keyword import CellKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_cell_options/pd.py b/src/pymcnp/files/inp/cell_options/pd.py similarity index 96% rename from src/pymcnp/files/inp/subclasses_cell_options/pd.py rename to src/pymcnp/files/inp/cell_options/pd.py index 4641e0a..85617c2 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/pd.py +++ b/src/pymcnp/files/inp/cell_options/pd.py @@ -5,7 +5,8 @@ import re from typing import Final -from ..cell_option import CellOption, CellKeyword +from ..cell_option import CellOption +from ..cell_keyword import CellKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_cell_options/pwt.py b/src/pymcnp/files/inp/cell_options/pwt.py similarity index 95% rename from src/pymcnp/files/inp/subclasses_cell_options/pwt.py rename to src/pymcnp/files/inp/cell_options/pwt.py index ef4e810..43a31aa 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/pwt.py +++ b/src/pymcnp/files/inp/cell_options/pwt.py @@ -5,7 +5,8 @@ import re from typing import Final -from ..cell_option import CellOption, CellKeyword +from ..cell_option import CellOption +from ..cell_keyword import CellKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_cell_options/tmp.py b/src/pymcnp/files/inp/cell_options/tmp.py similarity index 96% rename from src/pymcnp/files/inp/subclasses_cell_options/tmp.py rename to src/pymcnp/files/inp/cell_options/tmp.py index 4b01f7d..86c351c 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/tmp.py +++ b/src/pymcnp/files/inp/cell_options/tmp.py @@ -5,7 +5,8 @@ import re from typing import Final -from ..cell_option import CellOption, CellKeyword +from ..cell_option import CellOption +from ..cell_keyword import CellKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_cell_options/trcl.py b/src/pymcnp/files/inp/cell_options/trcl.py similarity index 95% rename from src/pymcnp/files/inp/subclasses_cell_options/trcl.py rename to src/pymcnp/files/inp/cell_options/trcl.py index dba76fa..efa86cc 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/trcl.py +++ b/src/pymcnp/files/inp/cell_options/trcl.py @@ -5,7 +5,8 @@ import re from typing import Final -from ..cell_option import CellOption, CellKeyword +from ..cell_option import CellOption +from ..cell_keyword import CellKeyword from ...utils import errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_cell_options/u.py b/src/pymcnp/files/inp/cell_options/u.py similarity index 95% rename from src/pymcnp/files/inp/subclasses_cell_options/u.py rename to src/pymcnp/files/inp/cell_options/u.py index bc8e94f..c01fb78 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/u.py +++ b/src/pymcnp/files/inp/cell_options/u.py @@ -5,7 +5,8 @@ import re from typing import Final -from ..cell_option import CellOption, CellKeyword +from ..cell_option import CellOption +from ..cell_keyword import CellKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_cell_options/unc.py b/src/pymcnp/files/inp/cell_options/unc.py similarity index 96% rename from src/pymcnp/files/inp/subclasses_cell_options/unc.py rename to src/pymcnp/files/inp/cell_options/unc.py index 9089e44..973f5e8 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/unc.py +++ b/src/pymcnp/files/inp/cell_options/unc.py @@ -5,7 +5,8 @@ import re from typing import Final -from ..cell_option import CellOption, CellKeyword +from ..cell_option import CellOption +from ..cell_keyword import CellKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_cell_options/vol.py b/src/pymcnp/files/inp/cell_options/vol.py similarity index 95% rename from src/pymcnp/files/inp/subclasses_cell_options/vol.py rename to src/pymcnp/files/inp/cell_options/vol.py index 4b19c4e..862c944 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/vol.py +++ b/src/pymcnp/files/inp/cell_options/vol.py @@ -5,7 +5,8 @@ import re from typing import Final -from ..cell_option import CellOption, CellKeyword +from ..cell_option import CellOption +from ..cell_keyword import CellKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_cell_options/wwn.py b/src/pymcnp/files/inp/cell_options/wwn.py similarity index 97% rename from src/pymcnp/files/inp/subclasses_cell_options/wwn.py rename to src/pymcnp/files/inp/cell_options/wwn.py index 20912d2..b593cd9 100644 --- a/src/pymcnp/files/inp/subclasses_cell_options/wwn.py +++ b/src/pymcnp/files/inp/cell_options/wwn.py @@ -5,7 +5,8 @@ import re from typing import Final -from ..cell_option import CellOption, CellKeyword +from ..cell_option import CellOption +from ..cell_keyword import CellKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/data.py b/src/pymcnp/files/inp/data.py index b7ec701..f187954 100644 --- a/src/pymcnp/files/inp/data.py +++ b/src/pymcnp/files/inp/data.py @@ -3,230 +3,12 @@ """ import re -from typing import Final, Union # noqa +from typing import Final from . import _card -from ..utils import types # noqa from ..utils import errors from ..utils import _parser -from ..utils import _elements # noqa - - -class DataMnemonic(_card.CardMnemonic): - """ - Represents INP data card mnemonics. - - ``DataMnemonic`` implements ``_card.CardMnemonic``. - """ - - # Fully Implemented - AREA = 'area' - TR = 'tr' - U = 'u' - LAT = 'lat' - FILL = 'fill' - URAN = 'uran' - DM = 'dm' - EMBED = 'embed' - EMBEE = 'embee' - EMBEB = 'embeb' - EMBEM = 'embem' - EMBTB = 'embtb' - EMBTM = 'embtm' - EMBDB = 'embdb' - EMBDF = 'embdf' - M = 'm' - MT = 'mt' - OTFDB = 'otfdb' - NONU = 'nonu' - AWTAB = 'awtab' - XS = 'xs' - VOID = 'void' - MGOPT = 'mgopt' - DRXS = 'drxs' - MODE = 'mode' - ACT = 'act' - CUT = 'cut' - ELPT = 'elpt' - THTME = 'thtme' - LCA = 'lca' - LCB = 'lcb' - LCC = 'lcc' - LEA = 'lea' - LEB = 'leb' - FMULT = 'fmult' - TROPT = 'tropt' - UNC = 'unc' - COSYP = 'cosyp' - COSY = 'cosy' - BFLD = 'bfld' - BFLCL = 'bflcl' - SDEF = 'sdef' - SC = 'sc' - SSR = 'ssr' - KCODE = 'kcode' - KSRC = 'ksrc' - KOPTS = 'kopts' - HSRC = 'hsrc' - NPS = 'nps' - RAND = 'rand' - - # I'm Working on It! :) - VOLUME = 'vol' - TRANSFORMATION_ANGLE = '*tr' - FILL_ANGLE = 'fill' - DETERMINISTIC_WEIGHT_WINDOW = 'dawwg' - MATERIAL_NUCLIDE_SUBSTITUTION = 'mx' - TOTAL_FISSION = 'totnu' - PARTICLE_PHYSICS_OPTIONS = 'phys' - FREE_GAS_THERMAL_TEMPERATURE = 'tmp' - CELL_ENERGY_CUTOFFS = 'elpt' - MODEL_PHYSICS_CONTROL = 'mphys' - GRAVITATIONAL_FIELD = 'field' - SOURCE_INFORMATION = 'si' - SOURCE_PROBABILITY = 'sp' - SOURCE_BIAS = 'sb' - DEPENDENT_SOURCE_DISTRIBUTION = 'ds' - SURFACE_SOURCE_WRITE = 'ssw' - DEPLETION_BURNUP = 'burn' - SOURCE = 'source' - SRCDX = 'srdx' - STANDARD_TALLIES = 'f' - STANDARD_TALLIES_ANGLE = '*f' - FIP = 'fip' - FIR = 'fir' - FIC = 'fic' - TALLY_COMMENT = 'fc' - TALLY_ENERGY = 'e' - TALLY_TIME = 't' - TALLY_COSINE = 'c' - TALLY_COSINE_ANGLE = '*c' - PRINT_HIERARCHY = 'fq' - TALLY_MULTIPLIER = 'fm' - DOSE_ENERGY = 'de' - DOSE_FUNCTION = 'df' - ENERGY_MULTIPLIER = 'em' - TIME_MULTIPLIER = 'tm' - COSINE_MULTIPLIER = 'cm' - CELL_FLAGGING = 'cf' - SURFACE_FLAGGING = 'sf' - TALLY_SEGMENT = 'fs' - SEGMENT_DIVISOR = 'sd' - SPECIAL_TALLY = 'fu' - TALLYX_SUBROUTINE = 'tallyx' - SPECIAL_TREATMENTS_TALLIES = 'ft' - TALLY_FLUCTUATION = 'tf' - DIRECT_ONLY_CONTRIBUTIONS = 'notrn' - TALLY_PERTUBATION = 'pert' - REACTIVITY_PERTUBATIONS = 'kpert' - SENSITIVITY_COEFFICENTS = 'ksen' - SUPERIMPOSED_MESH_TALLY_A = 'tmesh' - SUPERIMPOSED_MESH_TALLY_B = 'fmesh' - LATTICE_SPEED_TALLY_ENHANCEMENT = 'spdtl' - IMPORTANCE = 'imp' - VARIANCE_REDUCATION_CONTROL = 'var' - WEIGHT_WINDOW_ENERGIES = 'wwe' - WEIGHT_WINDOW_TIMES = 'wwt' - WEIGHT_WINDOW_BOUNDS = 'wwn' - WEIGHT_WINDOW_PARAMETER = 'wwp' - WEIGHT_WINDOW_GENERATION = 'wwg' - WEIGHT_WINDOW_GENERATION_ENERGIES = 'wwge' - WEIGHT_WINDOW_GENERATION_TIMES = 'wwgt' - SUPERIMPOSED_IMPORTANCE_MESH = 'mesh' - ENERGY_SPLITTING = 'esplt' - TIME_SPLITTING = 'tsplt' - EXPONENTIAL_TRANSFORM = 'ext' - VECTOR_INPUT = 'vect' - FORCED_COLLISION = 'fcl' - DXTRAN_SPHERE = 'dxt' - DETECTOR_DIAGNOSTICS = 'dd' - DETECTOR_CONTRIBUTION = 'pd' - DXTRAN_CONTRIBUTION = 'dxc' - BREMSSTRAHLUNG_BIASING = 'bbrem' - PHOTON_PRODUDCTION_BIASING = 'pikmt' - SECONDARY_PARTICLE_BIASING = 'spabi' - PHOTON_WEIGHT = 'pwt' - COMPUTER_TIME_CUTOFF = 'ctme' - PERCISION_CUTOFF = 'stop' - OUPUT_PRINT_TABLES = 'print' - NEGATE_PRINTING_TALLIES = 'talnp' - PRINT_DUMP_CYCLES = 'prdmp' - PARTICLE_TRACK_OUTPUT = 'ptrac' - PLOT_TALLIES_WHITE_RUNNING = 'mplot' - CREATE_LAHET = 'histp' - DEBUG_INFORMATION = 'dbcn' - LOST_PARTICLE_CONTROL = 'lost' - INTEGER_ARRAY = 'idum' - FLOATINGPOINT_ARRAY = 'rdum' - ZA = 'za' - ZB = 'zb' - ZC = 'zc' - ZD = 'zd' - FILE = 'files' - - @staticmethod - def from_mcnp(source: str): - """ - Generates PyMCNP ``DataMnemonic`` from INP. - - ``from_mcnp`` translates from INP to PyMCNP; it parses INP. - - Parameters: - source: INP for ``DataMnemonic``. - - Returns: - ``DataMnemonic``. - - Raises: - McnpError: INVALID_DATUM_MNEMONIC. - """ - - source = _parser.Preprocessor.process_inp(source) - - try: - return DataMnemonic(source) - except ValueError: - raise errors.McnpError(errors.McnpCode.INVALID_DATUM_MNEMONIC) - - -class DataKeyword(_card.CardKeyword): - """ - Represents INP data card option keywords. - - ``DataKeyword`` extends the ``_card.CawrdKeyword`` abstract class. - """ - - @staticmethod - def from_mcnp(source: str): - raise NotImplementedError - - -class DataOption(_card.CardOption): - """ - Represents INP data cards options. - - ``DataOption`` extends the ``_card.CardOption`` abstract class. - - Attributes: - keyword: Data card option keyword. - value: Data card option value. - """ - - @staticmethod - def from_mcnp(source: str): - raise NotImplementedError - - -class DataEntry(_card.CardEntry): - """ - Represents INP data card entry. - - ``DataEntry`` extends the ``_card.CardEntry`` abstract class. - """ - - @staticmethod - def from_mcnp(source: str): - raise NotImplementedError +from .data_mnemonic import DataMnemonic class Data(_card.Card): diff --git a/src/pymcnp/files/inp/subclasses_data/__init__.py b/src/pymcnp/files/inp/data_cards/__init__.py similarity index 100% rename from src/pymcnp/files/inp/subclasses_data/__init__.py rename to src/pymcnp/files/inp/data_cards/__init__.py diff --git a/src/pymcnp/files/inp/subclasses_data/act.py b/src/pymcnp/files/inp/data_cards/act.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_data/act.py rename to src/pymcnp/files/inp/data_cards/act.py index 276910c..774dd64 100644 --- a/src/pymcnp/files/inp/subclasses_data/act.py +++ b/src/pymcnp/files/inp/data_cards/act.py @@ -6,9 +6,9 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic -from ..data import DataOption -from ..data import DataKeyword +from ..data_mnemonic import DataMnemonic +from ..data_option import DataOption +from ..data_keyword import DataKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/area.py b/src/pymcnp/files/inp/data_cards/area.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/area.py rename to src/pymcnp/files/inp/data_cards/area.py index 0854a0d..d598a82 100644 --- a/src/pymcnp/files/inp/subclasses_data/area.py +++ b/src/pymcnp/files/inp/data_cards/area.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/awtab.py b/src/pymcnp/files/inp/data_cards/awtab.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/awtab.py rename to src/pymcnp/files/inp/data_cards/awtab.py index d95e5cc..81bb4d4 100644 --- a/src/pymcnp/files/inp/subclasses_data/awtab.py +++ b/src/pymcnp/files/inp/data_cards/awtab.py @@ -6,8 +6,8 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic -from ..data import DataEntry +from ..data_mnemonic import DataMnemonic +from ..data_entry import DataEntry from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/bflcl.py b/src/pymcnp/files/inp/data_cards/bflcl.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/bflcl.py rename to src/pymcnp/files/inp/data_cards/bflcl.py index a2a0f2e..cbc92bd 100644 --- a/src/pymcnp/files/inp/subclasses_data/bflcl.py +++ b/src/pymcnp/files/inp/data_cards/bflcl.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/bfld.py b/src/pymcnp/files/inp/data_cards/bfld.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/bfld.py rename to src/pymcnp/files/inp/data_cards/bfld.py index 82b94e9..95b4962 100644 --- a/src/pymcnp/files/inp/subclasses_data/bfld.py +++ b/src/pymcnp/files/inp/data_cards/bfld.py @@ -6,9 +6,9 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic -from ..data import DataOption -from ..data import DataKeyword +from ..data_mnemonic import DataMnemonic +from ..data_option import DataOption +from ..data_keyword import DataKeyword from ...utils import types, errors, _parser @@ -502,7 +502,7 @@ def __init__(self, kind: str, suffix: types.McnpInteger, pairs: dict[DataOption] McnpError: INVALID_DATUM_PARAMETERS. """ - if kind is None or type not in {'const', 'quad', 'quadff'}: + if kind is None or type.value not in {'const', 'quad', 'quadff'}: raise errors.McnpError(errors.McnpCode.INVALID_DATUM_PARAMETERS, str(kind)) if suffix is None: diff --git a/src/pymcnp/files/inp/subclasses_data/cosy.py b/src/pymcnp/files/inp/data_cards/cosy.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/cosy.py rename to src/pymcnp/files/inp/data_cards/cosy.py index 7013606..0b52ec7 100644 --- a/src/pymcnp/files/inp/subclasses_data/cosy.py +++ b/src/pymcnp/files/inp/data_cards/cosy.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/cosyp.py b/src/pymcnp/files/inp/data_cards/cosyp.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/cosyp.py rename to src/pymcnp/files/inp/data_cards/cosyp.py index 7da6b5b..965096d 100644 --- a/src/pymcnp/files/inp/subclasses_data/cosyp.py +++ b/src/pymcnp/files/inp/data_cards/cosyp.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/cut.py b/src/pymcnp/files/inp/data_cards/cut.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_data/cut.py rename to src/pymcnp/files/inp/data_cards/cut.py index f0ae45d..8a181d4 100644 --- a/src/pymcnp/files/inp/subclasses_data/cut.py +++ b/src/pymcnp/files/inp/data_cards/cut.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/dm.py b/src/pymcnp/files/inp/data_cards/dm.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/dm.py rename to src/pymcnp/files/inp/data_cards/dm.py index bffee04..439a652 100644 --- a/src/pymcnp/files/inp/subclasses_data/dm.py +++ b/src/pymcnp/files/inp/data_cards/dm.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/drxs.py b/src/pymcnp/files/inp/data_cards/drxs.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/drxs.py rename to src/pymcnp/files/inp/data_cards/drxs.py index 57897bd..1fd95fd 100644 --- a/src/pymcnp/files/inp/subclasses_data/drxs.py +++ b/src/pymcnp/files/inp/data_cards/drxs.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/elpt.py b/src/pymcnp/files/inp/data_cards/elpt.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/elpt.py rename to src/pymcnp/files/inp/data_cards/elpt.py index 615db4b..3d4c37c 100644 --- a/src/pymcnp/files/inp/subclasses_data/elpt.py +++ b/src/pymcnp/files/inp/data_cards/elpt.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/embdb.py b/src/pymcnp/files/inp/data_cards/embdb.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/embdb.py rename to src/pymcnp/files/inp/data_cards/embdb.py index 47c4eb2..36119e5 100644 --- a/src/pymcnp/files/inp/subclasses_data/embdb.py +++ b/src/pymcnp/files/inp/data_cards/embdb.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/embdf.py b/src/pymcnp/files/inp/data_cards/embdf.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/embdf.py rename to src/pymcnp/files/inp/data_cards/embdf.py index 062275c..abb9789 100644 --- a/src/pymcnp/files/inp/subclasses_data/embdf.py +++ b/src/pymcnp/files/inp/data_cards/embdf.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/embeb.py b/src/pymcnp/files/inp/data_cards/embeb.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/embeb.py rename to src/pymcnp/files/inp/data_cards/embeb.py index f1e84c4..e746e55 100644 --- a/src/pymcnp/files/inp/subclasses_data/embeb.py +++ b/src/pymcnp/files/inp/data_cards/embeb.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/embed.py b/src/pymcnp/files/inp/data_cards/embed.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_data/embed.py rename to src/pymcnp/files/inp/data_cards/embed.py index 51c82d9..f46b77a 100644 --- a/src/pymcnp/files/inp/subclasses_data/embed.py +++ b/src/pymcnp/files/inp/data_cards/embed.py @@ -6,9 +6,9 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic -from ..data import DataOption -from ..data import DataKeyword +from ..data_mnemonic import DataMnemonic +from ..data_option import DataOption +from ..data_keyword import DataKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/embee.py b/src/pymcnp/files/inp/data_cards/embee.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_data/embee.py rename to src/pymcnp/files/inp/data_cards/embee.py index b87bda4..e821839 100644 --- a/src/pymcnp/files/inp/subclasses_data/embee.py +++ b/src/pymcnp/files/inp/data_cards/embee.py @@ -6,9 +6,9 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic -from ..data import DataOption -from ..data import DataKeyword +from ..data_mnemonic import DataMnemonic +from ..data_option import DataOption +from ..data_keyword import DataKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/embem.py b/src/pymcnp/files/inp/data_cards/embem.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/embem.py rename to src/pymcnp/files/inp/data_cards/embem.py index aaa16ee..f1914a8 100644 --- a/src/pymcnp/files/inp/subclasses_data/embem.py +++ b/src/pymcnp/files/inp/data_cards/embem.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/embtb.py b/src/pymcnp/files/inp/data_cards/embtb.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/embtb.py rename to src/pymcnp/files/inp/data_cards/embtb.py index 8c9df6f..befd49a 100644 --- a/src/pymcnp/files/inp/subclasses_data/embtb.py +++ b/src/pymcnp/files/inp/data_cards/embtb.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/embtm.py b/src/pymcnp/files/inp/data_cards/embtm.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/embtm.py rename to src/pymcnp/files/inp/data_cards/embtm.py index 5c89ebb..72c1c17 100644 --- a/src/pymcnp/files/inp/subclasses_data/embtm.py +++ b/src/pymcnp/files/inp/data_cards/embtm.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/fill.py b/src/pymcnp/files/inp/data_cards/fill.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/fill.py rename to src/pymcnp/files/inp/data_cards/fill.py index f3d6b0a..3c46f30 100644 --- a/src/pymcnp/files/inp/subclasses_data/fill.py +++ b/src/pymcnp/files/inp/data_cards/fill.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/fmult.py b/src/pymcnp/files/inp/data_cards/fmult.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_data/fmult.py rename to src/pymcnp/files/inp/data_cards/fmult.py index f9189b9..3d11e74 100644 --- a/src/pymcnp/files/inp/subclasses_data/fmult.py +++ b/src/pymcnp/files/inp/data_cards/fmult.py @@ -6,9 +6,9 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic -from ..data import DataOption -from ..data import DataKeyword +from ..data_mnemonic import DataMnemonic +from ..data_option import DataOption +from ..data_keyword import DataKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/hsrc.py b/src/pymcnp/files/inp/data_cards/hsrc.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_data/hsrc.py rename to src/pymcnp/files/inp/data_cards/hsrc.py index 3329be4..cced37d 100644 --- a/src/pymcnp/files/inp/subclasses_data/hsrc.py +++ b/src/pymcnp/files/inp/data_cards/hsrc.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/kcode.py b/src/pymcnp/files/inp/data_cards/kcode.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_data/kcode.py rename to src/pymcnp/files/inp/data_cards/kcode.py index 392225c..93ad2bf 100644 --- a/src/pymcnp/files/inp/subclasses_data/kcode.py +++ b/src/pymcnp/files/inp/data_cards/kcode.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/kopts.py b/src/pymcnp/files/inp/data_cards/kopts.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_data/kopts.py rename to src/pymcnp/files/inp/data_cards/kopts.py index 26babcb..e385cef 100644 --- a/src/pymcnp/files/inp/subclasses_data/kopts.py +++ b/src/pymcnp/files/inp/data_cards/kopts.py @@ -6,9 +6,9 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic -from ..data import DataOption -from ..data import DataKeyword +from ..data_mnemonic import DataMnemonic +from ..data_option import DataOption +from ..data_keyword import DataKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/ksrc.py b/src/pymcnp/files/inp/data_cards/ksrc.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/ksrc.py rename to src/pymcnp/files/inp/data_cards/ksrc.py index a54f303..841be95 100644 --- a/src/pymcnp/files/inp/subclasses_data/ksrc.py +++ b/src/pymcnp/files/inp/data_cards/ksrc.py @@ -6,8 +6,8 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic -from ..data import DataEntry +from ..data_mnemonic import DataMnemonic +from ..data_entry import DataEntry from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/lae.py b/src/pymcnp/files/inp/data_cards/lae.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_data/lae.py rename to src/pymcnp/files/inp/data_cards/lae.py index 741f456..a1df5f2 100644 --- a/src/pymcnp/files/inp/subclasses_data/lae.py +++ b/src/pymcnp/files/inp/data_cards/lae.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/lat.py b/src/pymcnp/files/inp/data_cards/lat.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/lat.py rename to src/pymcnp/files/inp/data_cards/lat.py index 62c3ddb..446789b 100644 --- a/src/pymcnp/files/inp/subclasses_data/lat.py +++ b/src/pymcnp/files/inp/data_cards/lat.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/lbc.py b/src/pymcnp/files/inp/data_cards/lbc.py similarity index 100% rename from src/pymcnp/files/inp/subclasses_data/lbc.py rename to src/pymcnp/files/inp/data_cards/lbc.py diff --git a/src/pymcnp/files/inp/subclasses_data/lca.py b/src/pymcnp/files/inp/data_cards/lca.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_data/lca.py rename to src/pymcnp/files/inp/data_cards/lca.py index 15a4609..4f998b1 100644 --- a/src/pymcnp/files/inp/subclasses_data/lca.py +++ b/src/pymcnp/files/inp/data_cards/lca.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/lcb.py b/src/pymcnp/files/inp/data_cards/lcb.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_data/lcb.py rename to src/pymcnp/files/inp/data_cards/lcb.py index 6b1c486..f433411 100644 --- a/src/pymcnp/files/inp/subclasses_data/lcb.py +++ b/src/pymcnp/files/inp/data_cards/lcb.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/lcc.py b/src/pymcnp/files/inp/data_cards/lcc.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_data/lcc.py rename to src/pymcnp/files/inp/data_cards/lcc.py index 1af4b4f..e277d8c 100644 --- a/src/pymcnp/files/inp/subclasses_data/lcc.py +++ b/src/pymcnp/files/inp/data_cards/lcc.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/leb.py b/src/pymcnp/files/inp/data_cards/leb.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/leb.py rename to src/pymcnp/files/inp/data_cards/leb.py index 07d67bf..16f882a 100644 --- a/src/pymcnp/files/inp/subclasses_data/leb.py +++ b/src/pymcnp/files/inp/data_cards/leb.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/m.py b/src/pymcnp/files/inp/data_cards/m.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_data/m.py rename to src/pymcnp/files/inp/data_cards/m.py index 65087ff..7c85b8f 100644 --- a/src/pymcnp/files/inp/subclasses_data/m.py +++ b/src/pymcnp/files/inp/data_cards/m.py @@ -6,10 +6,10 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic -from ..data import DataEntry -from ..data import DataOption -from ..data import DataKeyword +from ..data_mnemonic import DataMnemonic +from ..data_entry import DataEntry +from ..data_option import DataOption +from ..data_keyword import DataKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/mgopt.py b/src/pymcnp/files/inp/data_cards/mgopt.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/mgopt.py rename to src/pymcnp/files/inp/data_cards/mgopt.py index acd46d1..cd0fd0c 100644 --- a/src/pymcnp/files/inp/subclasses_data/mgopt.py +++ b/src/pymcnp/files/inp/data_cards/mgopt.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser @@ -52,7 +52,7 @@ def __init__( McnpError: INVALID_DATUM_PARAMETERS. """ - if mcal is None or mcal not in {'f', 'a'}: + if mcal is None or mcal.value not in {'f', 'a'}: raise errors.McnpError(errors.McnpCode.INVALID_DATUM_PARAMETERS, str(mcal)) if igm is None or not (igm >= 0): diff --git a/src/pymcnp/files/inp/subclasses_data/mode.py b/src/pymcnp/files/inp/data_cards/mode.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/mode.py rename to src/pymcnp/files/inp/data_cards/mode.py index e61cd27..5e5782d 100644 --- a/src/pymcnp/files/inp/subclasses_data/mode.py +++ b/src/pymcnp/files/inp/data_cards/mode.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/mt.py b/src/pymcnp/files/inp/data_cards/mt.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/mt.py rename to src/pymcnp/files/inp/data_cards/mt.py index e029c1b..f7e596b 100644 --- a/src/pymcnp/files/inp/subclasses_data/mt.py +++ b/src/pymcnp/files/inp/data_cards/mt.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/nonu.py b/src/pymcnp/files/inp/data_cards/nonu.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/nonu.py rename to src/pymcnp/files/inp/data_cards/nonu.py index 4849a57..443cca8 100644 --- a/src/pymcnp/files/inp/subclasses_data/nonu.py +++ b/src/pymcnp/files/inp/data_cards/nonu.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/nps.py b/src/pymcnp/files/inp/data_cards/nps.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/nps.py rename to src/pymcnp/files/inp/data_cards/nps.py index 1be02d6..81f27ac 100644 --- a/src/pymcnp/files/inp/subclasses_data/nps.py +++ b/src/pymcnp/files/inp/data_cards/nps.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/otfdb.py b/src/pymcnp/files/inp/data_cards/otfdb.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/otfdb.py rename to src/pymcnp/files/inp/data_cards/otfdb.py index 575efbd..98f119f 100644 --- a/src/pymcnp/files/inp/subclasses_data/otfdb.py +++ b/src/pymcnp/files/inp/data_cards/otfdb.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/rand.py b/src/pymcnp/files/inp/data_cards/rand.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/rand.py rename to src/pymcnp/files/inp/data_cards/rand.py index 37f9f26..ea11353 100644 --- a/src/pymcnp/files/inp/subclasses_data/rand.py +++ b/src/pymcnp/files/inp/data_cards/rand.py @@ -6,9 +6,9 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic -from ..data import DataOption -from ..data import DataKeyword +from ..data_mnemonic import DataMnemonic +from ..data_option import DataOption +from ..data_keyword import DataKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/sc.py b/src/pymcnp/files/inp/data_cards/sc.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/sc.py rename to src/pymcnp/files/inp/data_cards/sc.py index 482af9f..238c964 100644 --- a/src/pymcnp/files/inp/subclasses_data/sc.py +++ b/src/pymcnp/files/inp/data_cards/sc.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/sdef.py b/src/pymcnp/files/inp/data_cards/sdef.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_data/sdef.py rename to src/pymcnp/files/inp/data_cards/sdef.py index 9c6ad8b..169aba9 100644 --- a/src/pymcnp/files/inp/subclasses_data/sdef.py +++ b/src/pymcnp/files/inp/data_cards/sdef.py @@ -6,9 +6,9 @@ from typing import Final, Union from ..data import Data -from ..data import DataMnemonic -from ..data import DataOption -from ..data import DataKeyword +from ..data_mnemonic import DataMnemonic +from ..data_option import DataOption +from ..data_keyword import DataKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/ssr.py b/src/pymcnp/files/inp/data_cards/ssr.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_data/ssr.py rename to src/pymcnp/files/inp/data_cards/ssr.py index 693c6ce..6d8fbeb 100644 --- a/src/pymcnp/files/inp/subclasses_data/ssr.py +++ b/src/pymcnp/files/inp/data_cards/ssr.py @@ -6,9 +6,9 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic -from ..data import DataOption -from ..data import DataKeyword +from ..data_mnemonic import DataMnemonic +from ..data_option import DataOption +from ..data_keyword import DataKeyword from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/thtme.py b/src/pymcnp/files/inp/data_cards/thtme.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/thtme.py rename to src/pymcnp/files/inp/data_cards/thtme.py index 21db21d..50a3828 100644 --- a/src/pymcnp/files/inp/subclasses_data/thtme.py +++ b/src/pymcnp/files/inp/data_cards/thtme.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/tr.py b/src/pymcnp/files/inp/data_cards/tr.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_data/tr.py rename to src/pymcnp/files/inp/data_cards/tr.py index ab8928c..3b7df30 100644 --- a/src/pymcnp/files/inp/subclasses_data/tr.py +++ b/src/pymcnp/files/inp/data_cards/tr.py @@ -6,8 +6,8 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic -from ..data import DataEntry +from ..data_mnemonic import DataMnemonic +from ..data_entry import DataEntry from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/tropt.py b/src/pymcnp/files/inp/data_cards/tropt.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/tropt.py rename to src/pymcnp/files/inp/data_cards/tropt.py index 669feec..6154542 100644 --- a/src/pymcnp/files/inp/subclasses_data/tropt.py +++ b/src/pymcnp/files/inp/data_cards/tropt.py @@ -6,9 +6,9 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic -from ..data import DataOption -from ..data import DataKeyword +from ..data_mnemonic import DataMnemonic +from ..data_option import DataOption +from ..data_keyword import DataKeyword from ...utils import errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/u.py b/src/pymcnp/files/inp/data_cards/u.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/u.py rename to src/pymcnp/files/inp/data_cards/u.py index cc866fa..ef6227e 100644 --- a/src/pymcnp/files/inp/subclasses_data/u.py +++ b/src/pymcnp/files/inp/data_cards/u.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/unc.py b/src/pymcnp/files/inp/data_cards/unc.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/unc.py rename to src/pymcnp/files/inp/data_cards/unc.py index a94d30f..627e2d2 100644 --- a/src/pymcnp/files/inp/subclasses_data/unc.py +++ b/src/pymcnp/files/inp/data_cards/unc.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/uran.py b/src/pymcnp/files/inp/data_cards/uran.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/uran.py rename to src/pymcnp/files/inp/data_cards/uran.py index a37bc15..7c6f85e 100644 --- a/src/pymcnp/files/inp/subclasses_data/uran.py +++ b/src/pymcnp/files/inp/data_cards/uran.py @@ -6,8 +6,8 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic -from ..data import DataEntry +from ..data_mnemonic import DataMnemonic +from ..data_entry import DataEntry from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/void.py b/src/pymcnp/files/inp/data_cards/void.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/void.py rename to src/pymcnp/files/inp/data_cards/void.py index a8d149f..0b7dadb 100644 --- a/src/pymcnp/files/inp/subclasses_data/void.py +++ b/src/pymcnp/files/inp/data_cards/void.py @@ -6,7 +6,7 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic +from ..data_mnemonic import DataMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_data/xs.py b/src/pymcnp/files/inp/data_cards/xs.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_data/xs.py rename to src/pymcnp/files/inp/data_cards/xs.py index 641cd5a..90ea127 100644 --- a/src/pymcnp/files/inp/subclasses_data/xs.py +++ b/src/pymcnp/files/inp/data_cards/xs.py @@ -6,8 +6,8 @@ from typing import Final from ..data import Data -from ..data import DataMnemonic -from ..data import DataEntry +from ..data_mnemonic import DataMnemonic +from ..data_entry import DataEntry from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/data_entry.py b/src/pymcnp/files/inp/data_entry.py new file mode 100644 index 0000000..aadc860 --- /dev/null +++ b/src/pymcnp/files/inp/data_entry.py @@ -0,0 +1,17 @@ +""" +Contains classes representing INP data card entries. +""" + +from . import _card + + +class DataEntry(_card.CardEntry): + """ + Represents INP data card entry. + + ``DataEntry`` extends the ``_card.CardEntry`` abstract class. + """ + + @staticmethod + def from_mcnp(source: str): + raise NotImplementedError diff --git a/src/pymcnp/files/inp/data_keyword.py b/src/pymcnp/files/inp/data_keyword.py new file mode 100644 index 0000000..6a84cf6 --- /dev/null +++ b/src/pymcnp/files/inp/data_keyword.py @@ -0,0 +1,17 @@ +""" +Contains classes representing INP data card keywords. +""" + +from . import _card + + +class DataKeyword(_card.CardKeyword): + """ + Represents INP data card option keywords. + + ``DataKeyword`` extends the ``_card.CawrdKeyword`` abstract class. + """ + + @staticmethod + def from_mcnp(source: str): + raise NotImplementedError diff --git a/src/pymcnp/files/inp/data_mnemonic.py b/src/pymcnp/files/inp/data_mnemonic.py new file mode 100644 index 0000000..b8d1aba --- /dev/null +++ b/src/pymcnp/files/inp/data_mnemonic.py @@ -0,0 +1,184 @@ +""" +Contains classes representing INP data card mnemonics. +""" + +from . import _card +from ..utils import errors +from ..utils import _parser + + +class DataMnemonic(_card.CardMnemonic): + """ + Represents INP data card mnemonics. + + ``DataMnemonic`` implements ``_card.CardMnemonic``. + """ + + # Fully Implemented + AREA = 'area' + TR = 'tr' + U = 'u' + LAT = 'lat' + FILL = 'fill' + URAN = 'uran' + DM = 'dm' + EMBED = 'embed' + EMBEE = 'embee' + EMBEB = 'embeb' + EMBEM = 'embem' + EMBTB = 'embtb' + EMBTM = 'embtm' + EMBDB = 'embdb' + EMBDF = 'embdf' + M = 'm' + MT = 'mt' + OTFDB = 'otfdb' + NONU = 'nonu' + AWTAB = 'awtab' + XS = 'xs' + VOID = 'void' + MGOPT = 'mgopt' + DRXS = 'drxs' + MODE = 'mode' + ACT = 'act' + CUT = 'cut' + ELPT = 'elpt' + THTME = 'thtme' + LCA = 'lca' + LCB = 'lcb' + LCC = 'lcc' + LEA = 'lea' + LEB = 'leb' + FMULT = 'fmult' + TROPT = 'tropt' + UNC = 'unc' + COSYP = 'cosyp' + COSY = 'cosy' + BFLD = 'bfld' + BFLCL = 'bflcl' + SDEF = 'sdef' + SC = 'sc' + SSR = 'ssr' + KCODE = 'kcode' + KSRC = 'ksrc' + KOPTS = 'kopts' + HSRC = 'hsrc' + NPS = 'nps' + RAND = 'rand' + + # I'm Working on It! :) + VOLUME = 'vol' + TRANSFORMATION_ANGLE = '*tr' + FILL_ANGLE = 'fill' + DETERMINISTIC_WEIGHT_WINDOW = 'dawwg' + MATERIAL_NUCLIDE_SUBSTITUTION = 'mx' + TOTAL_FISSION = 'totnu' + PARTICLE_PHYSICS_OPTIONS = 'phys' + FREE_GAS_THERMAL_TEMPERATURE = 'tmp' + CELL_ENERGY_CUTOFFS = 'elpt' + MODEL_PHYSICS_CONTROL = 'mphys' + GRAVITATIONAL_FIELD = 'field' + SOURCE_INFORMATION = 'si' + SOURCE_PROBABILITY = 'sp' + SOURCE_BIAS = 'sb' + DEPENDENT_SOURCE_DISTRIBUTION = 'ds' + SURFACE_SOURCE_WRITE = 'ssw' + DEPLETION_BURNUP = 'burn' + SOURCE = 'source' + SRCDX = 'srdx' + STANDARD_TALLIES = 'f' + STANDARD_TALLIES_ANGLE = '*f' + FIP = 'fip' + FIR = 'fir' + FIC = 'fic' + TALLY_COMMENT = 'fc' + TALLY_ENERGY = 'e' + TALLY_TIME = 't' + TALLY_COSINE = 'c' + TALLY_COSINE_ANGLE = '*c' + PRINT_HIERARCHY = 'fq' + TALLY_MULTIPLIER = 'fm' + DOSE_ENERGY = 'de' + DOSE_FUNCTION = 'df' + ENERGY_MULTIPLIER = 'em' + TIME_MULTIPLIER = 'tm' + COSINE_MULTIPLIER = 'cm' + CELL_FLAGGING = 'cf' + SURFACE_FLAGGING = 'sf' + TALLY_SEGMENT = 'fs' + SEGMENT_DIVISOR = 'sd' + SPECIAL_TALLY = 'fu' + TALLYX_SUBROUTINE = 'tallyx' + SPECIAL_TREATMENTS_TALLIES = 'ft' + TALLY_FLUCTUATION = 'tf' + DIRECT_ONLY_CONTRIBUTIONS = 'notrn' + TALLY_PERTUBATION = 'pert' + REACTIVITY_PERTUBATIONS = 'kpert' + SENSITIVITY_COEFFICENTS = 'ksen' + SUPERIMPOSED_MESH_TALLY_A = 'tmesh' + SUPERIMPOSED_MESH_TALLY_B = 'fmesh' + LATTICE_SPEED_TALLY_ENHANCEMENT = 'spdtl' + IMPORTANCE = 'imp' + VARIANCE_REDUCATION_CONTROL = 'var' + WEIGHT_WINDOW_ENERGIES = 'wwe' + WEIGHT_WINDOW_TIMES = 'wwt' + WEIGHT_WINDOW_BOUNDS = 'wwn' + WEIGHT_WINDOW_PARAMETER = 'wwp' + WEIGHT_WINDOW_GENERATION = 'wwg' + WEIGHT_WINDOW_GENERATION_ENERGIES = 'wwge' + WEIGHT_WINDOW_GENERATION_TIMES = 'wwgt' + SUPERIMPOSED_IMPORTANCE_MESH = 'mesh' + ENERGY_SPLITTING = 'esplt' + TIME_SPLITTING = 'tsplt' + EXPONENTIAL_TRANSFORM = 'ext' + VECTOR_INPUT = 'vect' + FORCED_COLLISION = 'fcl' + DXTRAN_SPHERE = 'dxt' + DETECTOR_DIAGNOSTICS = 'dd' + DETECTOR_CONTRIBUTION = 'pd' + DXTRAN_CONTRIBUTION = 'dxc' + BREMSSTRAHLUNG_BIASING = 'bbrem' + PHOTON_PRODUDCTION_BIASING = 'pikmt' + SECONDARY_PARTICLE_BIASING = 'spabi' + PHOTON_WEIGHT = 'pwt' + COMPUTER_TIME_CUTOFF = 'ctme' + PERCISION_CUTOFF = 'stop' + OUPUT_PRINT_TABLES = 'print' + NEGATE_PRINTING_TALLIES = 'talnp' + PRINT_DUMP_CYCLES = 'prdmp' + PARTICLE_TRACK_OUTPUT = 'ptrac' + PLOT_TALLIES_WHITE_RUNNING = 'mplot' + CREATE_LAHET = 'histp' + DEBUG_INFORMATION = 'dbcn' + LOST_PARTICLE_CONTROL = 'lost' + INTEGER_ARRAY = 'idum' + FLOATINGPOINT_ARRAY = 'rdum' + ZA = 'za' + ZB = 'zb' + ZC = 'zc' + ZD = 'zd' + FILE = 'files' + + @staticmethod + def from_mcnp(source: str): + """ + Generates PyMCNP ``DataMnemonic`` from INP. + + ``from_mcnp`` translates from INP to PyMCNP; it parses INP. + + Parameters: + source: INP for ``DataMnemonic``. + + Returns: + ``DataMnemonic``. + + Raises: + McnpError: INVALID_DATUM_MNEMONIC. + """ + + source = _parser.Preprocessor.process_inp(source) + + try: + return DataMnemonic(source) + except ValueError: + raise errors.McnpError(errors.McnpCode.INVALID_DATUM_MNEMONIC) diff --git a/src/pymcnp/files/inp/data_option.py b/src/pymcnp/files/inp/data_option.py new file mode 100644 index 0000000..6fb2c85 --- /dev/null +++ b/src/pymcnp/files/inp/data_option.py @@ -0,0 +1,21 @@ +""" +Contains classes representing INP data card options. +""" + +from . import _card + + +class DataOption(_card.CardOption): + """ + Represents INP data cards options. + + ``DataOption`` extends the ``_card.CardOption`` abstract class. + + Attributes: + keyword: Data card option keyword. + value: Data card option value. + """ + + @staticmethod + def from_mcnp(source: str): + raise NotImplementedError diff --git a/src/pymcnp/files/inp/inp.py b/src/pymcnp/files/inp/inp.py index a60c4af..66d0b8d 100644 --- a/src/pymcnp/files/inp/inp.py +++ b/src/pymcnp/files/inp/inp.py @@ -7,97 +7,100 @@ import pathlib -from . import cell -from . import data -from . import surface -from .subclasses_surfaces import P -from .subclasses_surfaces import Px -from .subclasses_surfaces import Py -from .subclasses_surfaces import Pz -from .subclasses_surfaces import So -from .subclasses_surfaces import S -from .subclasses_surfaces import Sx -from .subclasses_surfaces import Sy -from .subclasses_surfaces import Sz -from .subclasses_surfaces import C_x -from .subclasses_surfaces import C_y -from .subclasses_surfaces import C_z -from .subclasses_surfaces import Cx -from .subclasses_surfaces import Cy -from .subclasses_surfaces import Cz -from .subclasses_surfaces import K_x -from .subclasses_surfaces import K_y -from .subclasses_surfaces import K_z -from .subclasses_surfaces import Kx -from .subclasses_surfaces import Ky -from .subclasses_surfaces import Sq -from .subclasses_surfaces import Gq -from .subclasses_surfaces import Tx -from .subclasses_surfaces import Ty -from .subclasses_surfaces import Tz -from .subclasses_surfaces import X -from .subclasses_surfaces import Y -from .subclasses_surfaces import Z -from .subclasses_surfaces import Box -from .subclasses_surfaces import Rpp -from .subclasses_surfaces import Sph -from .subclasses_surfaces import Rcc -from .subclasses_surfaces import Rhp -from .subclasses_surfaces import Rec -from .subclasses_surfaces import Trc -from .subclasses_surfaces import Ell -from .subclasses_surfaces import Wed -from .subclasses_surfaces import Arb -from .subclasses_data import Area -from .subclasses_data import U -from .subclasses_data import Lat -from .subclasses_data import Fill -from .subclasses_data import Uran -from .subclasses_data import Dm -from .subclasses_data import Embed -from .subclasses_data import Embee -from .subclasses_data import Embeb -from .subclasses_data import Embem -from .subclasses_data import Embtb -from .subclasses_data import Embtm -from .subclasses_data import Embdb -from .subclasses_data import Embdf -from .subclasses_data import M -from .subclasses_data import Mt -from .subclasses_data import Otfdb -from .subclasses_data import Nonu -from .subclasses_data import Awtab -from .subclasses_data import Xs -from .subclasses_data import Void -from .subclasses_data import Mgopt -from .subclasses_data import Drxs -from .subclasses_data import Mode -from .subclasses_data import Act -from .subclasses_data import Cut -from .subclasses_data import Elpt -from .subclasses_data import Thtme -from .subclasses_data import Lca -from .subclasses_data import Lcb -from .subclasses_data import Lcc -from .subclasses_data import Lae -from .subclasses_data import Leb -from .subclasses_data import Fmult -from .subclasses_data import Tropt -from .subclasses_data import Unc -from .subclasses_data import Cosyp -from .subclasses_data import Cosy -from .subclasses_data import Bfld -from .subclasses_data import Bflcl -from .subclasses_data import Sdef -from .subclasses_data import Sc -from .subclasses_data import Ssr -from .subclasses_data import Kcode -from .subclasses_data import Ksrc -from .subclasses_data import Kopts -from .subclasses_data import Hsrc -from .subclasses_data import Nps -from .subclasses_data import Rand -from . import comment +from .comment import Comment +from .cell import Cell +from .surface import Surface +from .surface_mnemonic import SurfaceMnemonic +from .surface_cards import P +from .surface_cards import Px +from .surface_cards import Py +from .surface_cards import Pz +from .surface_cards import So +from .surface_cards import S +from .surface_cards import Sx +from .surface_cards import Sy +from .surface_cards import Sz +from .surface_cards import C_x +from .surface_cards import C_y +from .surface_cards import C_z +from .surface_cards import Cx +from .surface_cards import Cy +from .surface_cards import Cz +from .surface_cards import K_x +from .surface_cards import K_y +from .surface_cards import K_z +from .surface_cards import Kx +from .surface_cards import Ky +from .surface_cards import Sq +from .surface_cards import Gq +from .surface_cards import Tx +from .surface_cards import Ty +from .surface_cards import Tz +from .surface_cards import X +from .surface_cards import Y +from .surface_cards import Z +from .surface_cards import Box +from .surface_cards import Rpp +from .surface_cards import Sph +from .surface_cards import Rcc +from .surface_cards import Rhp +from .surface_cards import Rec +from .surface_cards import Trc +from .surface_cards import Ell +from .surface_cards import Wed +from .surface_cards import Arb +from .data import Data +from .data import _Placeholder +from .data_mnemonic import DataMnemonic +from .data_cards import Area +from .data_cards import U +from .data_cards import Lat +from .data_cards import Fill +from .data_cards import Uran +from .data_cards import Dm +from .data_cards import Embed +from .data_cards import Embee +from .data_cards import Embeb +from .data_cards import Embem +from .data_cards import Embtb +from .data_cards import Embtm +from .data_cards import Embdb +from .data_cards import Embdf +from .data_cards import M +from .data_cards import Mt +from .data_cards import Otfdb +from .data_cards import Nonu +from .data_cards import Awtab +from .data_cards import Xs +from .data_cards import Void +from .data_cards import Mgopt +from .data_cards import Drxs +from .data_cards import Mode +from .data_cards import Act +from .data_cards import Cut +from .data_cards import Elpt +from .data_cards import Thtme +from .data_cards import Lca +from .data_cards import Lcb +from .data_cards import Lcc +from .data_cards import Lae +from .data_cards import Leb +from .data_cards import Fmult +from .data_cards import Tropt +from .data_cards import Unc +from .data_cards import Cosyp +from .data_cards import Cosy +from .data_cards import Bfld +from .data_cards import Bflcl +from .data_cards import Sdef +from .data_cards import Sc +from .data_cards import Ssr +from .data_cards import Kcode +from .data_cards import Ksrc +from .data_cards import Kopts +from .data_cards import Hsrc +from .data_cards import Nps +from .data_cards import Rand from ..utils import errors from ..utils import _parser from ..utils import _object @@ -130,18 +133,18 @@ class Inp(_object.PyMcnpFileObject): def __init__( self, title: str, - cells: dict[int, cell.Cell], - cells_comments: dict[comment.Comment], - surfaces: dict[int, surface.Surface], - surfaces_comments: dict[comment.Comment], - data_geometry: dict[int, data.Data], - data_material: dict[int, data.Data], - data_physics: dict[int, data.Data], - data_source: dict[int, data.Data], - data_tally: dict[int, data.Data], - data_variance: dict[int, data.Data], - data_micellaneous: dict[int, data.Data], - data_comments: tuple[comment.Comment], + cells: dict[int, Cell], + cells_comments: dict[Comment], + surfaces: dict[int, Surface], + surfaces_comments: dict[Comment], + data_geometry: dict[int, Data], + data_material: dict[int, Data], + data_physics: dict[int, Data], + data_source: dict[int, Data], + data_tally: dict[int, Data], + data_variance: dict[int, Data], + data_micellaneous: dict[int, Data], + data_comments: tuple[Comment], message: str = '', other: str = '', ): @@ -269,18 +272,18 @@ def __init__( raise errors.McnpError(errors.McnpCode.INVALID_INP_OTHER, info=other) self.title: Final[str] = title - self.cells: Final[dict[int, cell.Cell]] = cells - self.cells_comments: Final[tuple[comment.Comment]] = cells_comments - self.surfaces: Final[dict[int, surface.Surface]] = surfaces - self.surfaces_comments: Final[tuple[comment.Comment]] = surfaces_comments - self.data_geometry: Final[dict[int, data.Data]] = data_geometry - self.data_material: Final[dict[int, data.Data]] = data_material - self.data_physics: Final[dict[int, data.Data]] = data_physics - self.data_source: Final[dict[int, data.Data]] = data_source - self.data_tally: Final[dict[int, data.Data]] = data_tally - self.data_variance: Final[dict[int, data.Data]] = data_variance - self.data_micellaneous: Final[dict[int, data.Data]] = data_micellaneous - self.data_comments: Final[tuple[comment.Comment]] = data_comments + self.cells: Final[dict[int, Cell]] = cells + self.cells_comments: Final[tuple[Comment]] = cells_comments + self.surfaces: Final[dict[int, Surface]] = surfaces + self.surfaces_comments: Final[tuple[Comment]] = surfaces_comments + self.data_geometry: Final[dict[int, Data]] = data_geometry + self.data_material: Final[dict[int, Data]] = data_material + self.data_physics: Final[dict[int, Data]] = data_physics + self.data_source: Final[dict[int, Data]] = data_source + self.data_tally: Final[dict[int, Data]] = data_tally + self.data_variance: Final[dict[int, Data]] = data_variance + self.data_micellaneous: Final[dict[int, Data]] = data_micellaneous + self.data_comments: Final[tuple[Comment]] = data_comments self.message: Final[str] = message self.other: Final[str] = other @@ -319,9 +322,9 @@ def from_mcnp(source: str): line = lines.popl() if re.match(r'c[^a-zA-Z]*', line): - cells_comments.append(comment.Comment.from_mcnp(line)) + cells_comments.append(Comment.from_mcnp(line)) else: - card = cell.Cell.from_mcnp(line) + card = Cell.from_mcnp(line) cells[card.ident] = card lines.popl() @@ -333,90 +336,90 @@ def from_mcnp(source: str): line = lines.popl() if re.match(r'c[^a-zA-Z]*', line): - surfaces_comments.append(comment.Comment.from_mcnp(line)) + surfaces_comments.append(Comment.from_mcnp(line)) else: mnemonic = re.search(r'[a-zA-z*]+', line) mnemonic = mnemonic.group() if mnemonic else '' - mnemonic = surface.SurfaceMnemonic.from_mcnp(mnemonic) + mnemonic = SurfaceMnemonic.from_mcnp(mnemonic) match mnemonic: - case surface.SurfaceMnemonic.P: + case SurfaceMnemonic.P: card = P.from_mcnp(line) - case surface.SurfaceMnemonic.PX: + case SurfaceMnemonic.PX: card = Px.from_mcnp(line) - case surface.SurfaceMnemonic.PY: + case SurfaceMnemonic.PY: card = Py.from_mcnp(line) - case surface.SurfaceMnemonic.PZ: + case SurfaceMnemonic.PZ: card = Pz.from_mcnp(line) - case surface.SurfaceMnemonic.SO: + case SurfaceMnemonic.SO: card = So.from_mcnp(line) - case surface.SurfaceMnemonic.S: + case SurfaceMnemonic.S: card = S.from_mcnp(line) - case surface.SurfaceMnemonic.SX: + case SurfaceMnemonic.SX: card = Sx.from_mcnp(line) - case surface.SurfaceMnemonic.SY: + case SurfaceMnemonic.SY: card = Sy.from_mcnp(line) - case surface.SurfaceMnemonic.SZ: + case SurfaceMnemonic.SZ: card = Sz.from_mcnp(line) - case surface.SurfaceMnemonic.C_X: + case SurfaceMnemonic.C_X: card = C_x.from_mcnp(line) - case surface.SurfaceMnemonic.C_Y: + case SurfaceMnemonic.C_Y: card = C_y.from_mcnp(line) - case surface.SurfaceMnemonic.C_Z: + case SurfaceMnemonic.C_Z: card = C_z.from_mcnp(line) - case surface.SurfaceMnemonic.CX: + case SurfaceMnemonic.CX: card = Cx.from_mcnp(line) - case surface.SurfaceMnemonic.CY: + case SurfaceMnemonic.CY: card = Cy.from_mcnp(line) - case surface.SurfaceMnemonic.CZ: + case SurfaceMnemonic.CZ: card = Cz.from_mcnp(line) - case surface.SurfaceMnemonic.K_X: + case SurfaceMnemonic.K_X: card = K_x.from_mcnp(line) - case surface.SurfaceMnemonic.K_Y: + case SurfaceMnemonic.K_Y: card = K_y.from_mcnp(line) - case surface.SurfaceMnemonic.K_Z: + case SurfaceMnemonic.K_Z: card = K_z.from_mcnp(line) - case surface.SurfaceMnemonic.KX: + case SurfaceMnemonic.KX: card = Kx.from_mcnp(line) - case surface.SurfaceMnemonic.KY: + case SurfaceMnemonic.KY: card = Ky.from_mcnp(line) - case surface.SurfaceMnemonic.KZ: + case SurfaceMnemonic.KZ: card = Kx.from_mcnp(line) - case surface.SurfaceMnemonic.SQ: + case SurfaceMnemonic.SQ: card = Sq.from_mcnp(line) - case surface.SurfaceMnemonic.GQ: + case SurfaceMnemonic.GQ: card = Gq.from_mcnp(line) - case surface.SurfaceMnemonic.TX: + case SurfaceMnemonic.TX: card = Tx.from_mcnp(line) - case surface.SurfaceMnemonic.TY: + case SurfaceMnemonic.TY: card = Ty.from_mcnp(line) - case surface.SurfaceMnemonic.TZ: + case SurfaceMnemonic.TZ: card = Tz.from_mcnp(line) - case surface.SurfaceMnemonic.X: + case SurfaceMnemonic.X: card = X.from_mcnp(line) - case surface.SurfaceMnemonic.Y: + case SurfaceMnemonic.Y: card = Y.from_mcnp(line) - case surface.SurfaceMnemonic.Z: + case SurfaceMnemonic.Z: card = Z.from_mcnp(line) - case surface.SurfaceMnemonic.BOX: + case SurfaceMnemonic.BOX: card = Box.from_mcnp(line) - case surface.SurfaceMnemonic.RPP: + case SurfaceMnemonic.RPP: card = Rpp.from_mcnp(line) - case surface.SurfaceMnemonic.SPH: + case SurfaceMnemonic.SPH: card = Sph.from_mcnp(line) - case surface.SurfaceMnemonic.RCC: + case SurfaceMnemonic.RCC: card = Rcc.from_mcnp(line) - case surface.SurfaceMnemonic.RHP: + case SurfaceMnemonic.RHP: card = Rhp.from_mcnp(line) - case surface.SurfaceMnemonic.REC: + case SurfaceMnemonic.REC: card = Rec.from_mcnp(line) - case surface.SurfaceMnemonic.TRC: + case SurfaceMnemonic.TRC: card = Trc.from_mcnp(line) - case surface.SurfaceMnemonic.ELL: + case SurfaceMnemonic.ELL: card = Ell.from_mcnp(line) - case surface.SurfaceMnemonic.WED: + case SurfaceMnemonic.WED: card = Wed.from_mcnp(line) - case surface.SurfaceMnemonic.ARB: + case SurfaceMnemonic.ARB: card = Arb.from_mcnp(line) surfaces[card.ident] = card @@ -437,129 +440,129 @@ def from_mcnp(source: str): line = lines.popl() if re.match(r'c[^a-zA-Z]*', line): - data_comments.append(comment.Comment.from_mcnp(line)) + data_comments.append(Comment.from_mcnp(line)) else: mnemonic = re.search(r'[a-zA-z*]+', line) mnemonic = mnemonic.group() if mnemonic else '' - mnemonic = data.DataMnemonic.from_mcnp(mnemonic) + mnemonic = DataMnemonic.from_mcnp(mnemonic) match mnemonic: - case data.DataMnemonic.AREA: + case DataMnemonic.AREA: card = Area.from_mcnp(line) - case data.DataMnemonic.U: + case DataMnemonic.U: card = U.from_mcnp(line) - case data.DataMnemonic.LAT: + case DataMnemonic.LAT: card = Lat.from_mcnp(line) - case data.DataMnemonic.FILL: + case DataMnemonic.FILL: card = Fill.from_mcnp(line) - case data.DataMnemonic.URAN: + case DataMnemonic.URAN: card = Uran.from_mcnp(line) - case data.DataMnemonic.DM: + case DataMnemonic.DM: card = Dm.from_mcnp(line) - case data.DataMnemonic.EMBED: + case DataMnemonic.EMBED: card = Embed.from_mcnp(line) - case data.DataMnemonic.EMBEE: + case DataMnemonic.EMBEE: card = Embee.from_mcnp(line) - case data.DataMnemonic.EMBEE: + case DataMnemonic.EMBEE: card = Embee.from_mcnp(line) - case data.DataMnemonic.EMBEB: + case DataMnemonic.EMBEB: card = Embeb.from_mcnp(line) - case data.DataMnemonic.EMBEM: + case DataMnemonic.EMBEM: card = Embem.from_mcnp(line) - case data.DataMnemonic.EMBTB: + case DataMnemonic.EMBTB: card = Embtb.from_mcnp(line) - case data.DataMnemonic.EMBTM: + case DataMnemonic.EMBTM: card = Embtm.from_mcnp(line) - case data.DataMnemonic.EMBDB: + case DataMnemonic.EMBDB: card = Embdb.from_mcnp(line) - case data.DataMnemonic.EMBDF: + case DataMnemonic.EMBDF: card = Embdf.from_mcnp(line) - case data.DataMnemonic.M: + case DataMnemonic.M: card = M.from_mcnp(line) - case data.DataMnemonic.MT: + case DataMnemonic.MT: card = Mt.from_mcnp(line) - case data.DataMnemonic.OTFDB: + case DataMnemonic.OTFDB: card = Otfdb.from_mcnp(line) - case data.DataMnemonic.NONU: + case DataMnemonic.NONU: card = Nonu.from_mcnp(line) - case data.DataMnemonic.AWTAB: + case DataMnemonic.AWTAB: card = Awtab.from_mcnp(line) - case data.DataMnemonic.XS: + case DataMnemonic.XS: card = Xs.from_mcnp(line) - case data.DataMnemonic.VOID: + case DataMnemonic.VOID: card = Void.from_mcnp(line) - case data.DataMnemonic.MGOPT: + case DataMnemonic.MGOPT: card = Mgopt.from_mcnp(line) - case data.DataMnemonic.DRXS: + case DataMnemonic.DRXS: card = Drxs.from_mcnp(line) - case data.DataMnemonic.MODE: + case DataMnemonic.MODE: card = Mode.from_mcnp(line) - case data.DataMnemonic.ACT: + case DataMnemonic.ACT: card = Act.from_mcnp(line) - case data.DataMnemonic.CUT: + case DataMnemonic.CUT: card = Cut.from_mcnp(line) - case data.DataMnemonic.ELPT: + case DataMnemonic.ELPT: card = Elpt.from_mcnp(line) - case data.DataMnemonic.THTME: + case DataMnemonic.THTME: card = Thtme.from_mcnp(line) - case data.DataMnemonic.LCA: + case DataMnemonic.LCA: card = Lca.from_mcnp(line) - case data.DataMnemonic.LCB: + case DataMnemonic.LCB: card = Lcb.from_mcnp(line) - case data.DataMnemonic.LCC: + case DataMnemonic.LCC: card = Lcc.from_mcnp(line) - case data.DataMnemonic.LEA: + case DataMnemonic.LEA: card = Lae.from_mcnp(line) - case data.DataMnemonic.LEB: + case DataMnemonic.LEB: card = Leb.from_mcnp(line) - case data.DataMnemonic.FMULT: + case DataMnemonic.FMULT: card = Fmult.from_mcnp(line) - case data.DataMnemonic.TROPT: + case DataMnemonic.TROPT: card = Tropt.from_mcnp(line) - case data.DataMnemonic.UNC: + case DataMnemonic.UNC: card = Unc.from_mcnp(line) - case data.DataMnemonic.COSYP: + case DataMnemonic.COSYP: card = Cosyp.from_mcnp(line) - case data.DataMnemonic.COSY: + case DataMnemonic.COSY: card = Cosy.from_mcnp(line) - case data.DataMnemonic.BFLD: + case DataMnemonic.BFLD: card = Bfld.from_mcnp(line) - case data.DataMnemonic.BFLCL: + case DataMnemonic.BFLCL: card = Bflcl.from_mcnp(line) - case data.DataMnemonic.SDEF: + case DataMnemonic.SDEF: card = Sdef.from_mcnp(line) - case data.DataMnemonic.SC: + case DataMnemonic.SC: card = Sc.from_mcnp(line) - case data.DataMnemonic.SSR: + case DataMnemonic.SSR: card = Ssr.from_mcnp(line) - case data.DataMnemonic.KCODE: + case DataMnemonic.KCODE: card = Kcode.from_mcnp(line) - case data.DataMnemonic.KSRC: + case DataMnemonic.KSRC: card = Ksrc.from_mcnp(line) - case data.DataMnemonic.KOPTS: + case DataMnemonic.KOPTS: card = Kopts.from_mcnp(line) - case data.DataMnemonic.HSRC: + case DataMnemonic.HSRC: card = Hsrc.from_mcnp(line) - case data.DataMnemonic.NPS: + case DataMnemonic.NPS: card = Nps.from_mcnp(line) - case data.DataMnemonic.RAND: + case DataMnemonic.RAND: card = Rand.from_mcnp(line) case _: - card = data._Placeholder.from_mcnp(line) + card = _Placeholder.from_mcnp(line) - if card.mnemonic in data.Data.GEOMETRY_MNEMONICS: + if card.mnemonic in Data.GEOMETRY_MNEMONICS: data_geometry[card.ident] = card - elif card.mnemonic in data.Data.MATERIAL_MNEMONICS: + elif card.mnemonic in Data.MATERIAL_MNEMONICS: data_material[card.ident] = card - elif card.mnemonic in data.Data.PHYSICS_MNEMONICS: + elif card.mnemonic in Data.PHYSICS_MNEMONICS: data_physics[card.ident] = card - elif card.mnemonic in data.Data.SOURCE_MNEMONICS: + elif card.mnemonic in Data.SOURCE_MNEMONICS: data_source[card.ident] = card - elif card.mnemonic in data.Data.TALLY_MNEMONICS: + elif card.mnemonic in Data.TALLY_MNEMONICS: data_tally[card.ident] = card - elif card.mnemonic in data.Data.VARIENCE_MNEMONICS: + elif card.mnemonic in Data.VARIENCE_MNEMONICS: data_variance[card.ident] = card - elif card.mnemonic in data.Data.MICELLANEOUS_MNEMONICS: + elif card.mnemonic in Data.MICELLANEOUS_MNEMONICS: data_micellaneous[card.ident] = card else: data_micellaneous[card.ident] = card diff --git a/src/pymcnp/files/inp/surface.py b/src/pymcnp/files/inp/surface.py index 49b971e..b845afc 100644 --- a/src/pymcnp/files/inp/surface.py +++ b/src/pymcnp/files/inp/surface.py @@ -3,83 +3,9 @@ """ from . import _card -from ..utils import types # noqa -from ..utils import errors from ..utils import _parser -class SurfaceMnemonic(_card.CardMnemonic): - """ - Represents INP surface card mnemonics. - - ``SurfaceMnemonic`` implements ``_card.CardMnemonic``. - """ - - P = 'p' - PX = 'px' - PY = 'py' - PZ = 'pz' - SO = 'so' - S = 's' - SX = 'sx' - SY = 'sy' - SZ = 'sz' - C_X = 'c/x' - C_Y = 'c/y' - C_Z = 'c/z' - CX = 'cx' - CY = 'cy' - CZ = 'cz' - K_X = 'k/x' - K_Y = 'k/y' - K_Z = 'k/z' - KX = 'kx' - KY = 'ky' - KZ = 'kz' - SQ = 'sq' - GQ = 'gq' - TX = 'tx' - TY = 'ty' - TZ = 'tz' - X = 'x' - Y = 'y' - Z = 'z' - BOX = 'box' - RPP = 'rpp' - SPH = 'sph' - RCC = 'rcc' - RHP = 'rhp' - REC = 'rec' - TRC = 'trc' - ELL = 'ell' - WED = 'wed' - ARB = 'arb' - - @staticmethod - def from_mcnp(source: str): - """ - Generates ``SurfaceMnemonic`` objects from INP. - - ``from_mcnp`` translates from INP to PyMCNP; it parses INP. - - Parameters: - source: INP for ``SurfaceMnemonic``. - - Returns: - ``SurfaceMnemonic`` object. - - Raises: - McnpError: INVALID_SURFACE_MNEMONIC. - """ - - source = _parser.Preprocessor.process_inp(source) - - try: - return SurfaceMnemonic(source) - except ValueError: - raise errors.McnpError(errors.McnpCode.INVALID_SURFACE_MNEMONIC) - - class Surface(_card.Card): """ Represents INP data cards. diff --git a/src/pymcnp/files/inp/subclasses_surfaces/__init__.py b/src/pymcnp/files/inp/surface_cards/__init__.py similarity index 100% rename from src/pymcnp/files/inp/subclasses_surfaces/__init__.py rename to src/pymcnp/files/inp/surface_cards/__init__.py diff --git a/src/pymcnp/files/inp/subclasses_surfaces/arb.py b/src/pymcnp/files/inp/surface_cards/arb.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_surfaces/arb.py rename to src/pymcnp/files/inp/surface_cards/arb.py index 1132c52..87140ef 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/arb.py +++ b/src/pymcnp/files/inp/surface_cards/arb.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/box.py b/src/pymcnp/files/inp/surface_cards/box.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_surfaces/box.py rename to src/pymcnp/files/inp/surface_cards/box.py index 47e4bdb..b2367e7 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/box.py +++ b/src/pymcnp/files/inp/surface_cards/box.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/c_x.py b/src/pymcnp/files/inp/surface_cards/c_x.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/c_x.py rename to src/pymcnp/files/inp/surface_cards/c_x.py index c81cbf5..5bdca57 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/c_x.py +++ b/src/pymcnp/files/inp/surface_cards/c_x.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/c_y.py b/src/pymcnp/files/inp/surface_cards/c_y.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/c_y.py rename to src/pymcnp/files/inp/surface_cards/c_y.py index 97ced90..03cf03c 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/c_y.py +++ b/src/pymcnp/files/inp/surface_cards/c_y.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/c_z.py b/src/pymcnp/files/inp/surface_cards/c_z.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/c_z.py rename to src/pymcnp/files/inp/surface_cards/c_z.py index ae3863f..faffbf1 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/c_z.py +++ b/src/pymcnp/files/inp/surface_cards/c_z.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/cx.py b/src/pymcnp/files/inp/surface_cards/cx.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/cx.py rename to src/pymcnp/files/inp/surface_cards/cx.py index f91dab5..0702af0 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/cx.py +++ b/src/pymcnp/files/inp/surface_cards/cx.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/cy.py b/src/pymcnp/files/inp/surface_cards/cy.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/cy.py rename to src/pymcnp/files/inp/surface_cards/cy.py index 079c8a8..249c3d8 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/cy.py +++ b/src/pymcnp/files/inp/surface_cards/cy.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/cz.py b/src/pymcnp/files/inp/surface_cards/cz.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/cz.py rename to src/pymcnp/files/inp/surface_cards/cz.py index 5f1c529..0edd001 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/cz.py +++ b/src/pymcnp/files/inp/surface_cards/cz.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/ell.py b/src/pymcnp/files/inp/surface_cards/ell.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/ell.py rename to src/pymcnp/files/inp/surface_cards/ell.py index aa42a2e..32cb724 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/ell.py +++ b/src/pymcnp/files/inp/surface_cards/ell.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/gq.py b/src/pymcnp/files/inp/surface_cards/gq.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/gq.py rename to src/pymcnp/files/inp/surface_cards/gq.py index 91ba4ee..24fb885 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/gq.py +++ b/src/pymcnp/files/inp/surface_cards/gq.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/k_x.py b/src/pymcnp/files/inp/surface_cards/k_x.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/k_x.py rename to src/pymcnp/files/inp/surface_cards/k_x.py index 83a49b2..2e84ecd 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/k_x.py +++ b/src/pymcnp/files/inp/surface_cards/k_x.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/k_y.py b/src/pymcnp/files/inp/surface_cards/k_y.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/k_y.py rename to src/pymcnp/files/inp/surface_cards/k_y.py index 2c6069c..1e36959 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/k_y.py +++ b/src/pymcnp/files/inp/surface_cards/k_y.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/k_z.py b/src/pymcnp/files/inp/surface_cards/k_z.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/k_z.py rename to src/pymcnp/files/inp/surface_cards/k_z.py index b473606..c49c23e 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/k_z.py +++ b/src/pymcnp/files/inp/surface_cards/k_z.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/kx.py b/src/pymcnp/files/inp/surface_cards/kx.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/kx.py rename to src/pymcnp/files/inp/surface_cards/kx.py index fda39e8..aca078e 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/kx.py +++ b/src/pymcnp/files/inp/surface_cards/kx.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/ky.py b/src/pymcnp/files/inp/surface_cards/ky.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/ky.py rename to src/pymcnp/files/inp/surface_cards/ky.py index 687f998..9436fd6 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/ky.py +++ b/src/pymcnp/files/inp/surface_cards/ky.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/kz.py b/src/pymcnp/files/inp/surface_cards/kz.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/kz.py rename to src/pymcnp/files/inp/surface_cards/kz.py index 0eb5849..ab7a238 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/kz.py +++ b/src/pymcnp/files/inp/surface_cards/kz.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/p.py b/src/pymcnp/files/inp/surface_cards/p.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/p.py rename to src/pymcnp/files/inp/surface_cards/p.py index ede92b2..17dccde 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/p.py +++ b/src/pymcnp/files/inp/surface_cards/p.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/px.py b/src/pymcnp/files/inp/surface_cards/px.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/px.py rename to src/pymcnp/files/inp/surface_cards/px.py index 3bbdefc..03397e2 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/px.py +++ b/src/pymcnp/files/inp/surface_cards/px.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/py.py b/src/pymcnp/files/inp/surface_cards/py.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/py.py rename to src/pymcnp/files/inp/surface_cards/py.py index 9297b3f..ede2a81 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/py.py +++ b/src/pymcnp/files/inp/surface_cards/py.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/pz.py b/src/pymcnp/files/inp/surface_cards/pz.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/pz.py rename to src/pymcnp/files/inp/surface_cards/pz.py index c57bf5b..0272339 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/pz.py +++ b/src/pymcnp/files/inp/surface_cards/pz.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/rcc.py b/src/pymcnp/files/inp/surface_cards/rcc.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/rcc.py rename to src/pymcnp/files/inp/surface_cards/rcc.py index c84eff4..aba8b5f 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/rcc.py +++ b/src/pymcnp/files/inp/surface_cards/rcc.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/rec.py b/src/pymcnp/files/inp/surface_cards/rec.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_surfaces/rec.py rename to src/pymcnp/files/inp/surface_cards/rec.py index ed7298d..538b4d7 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/rec.py +++ b/src/pymcnp/files/inp/surface_cards/rec.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/rhp.py b/src/pymcnp/files/inp/surface_cards/rhp.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_surfaces/rhp.py rename to src/pymcnp/files/inp/surface_cards/rhp.py index 9c66174..b349e60 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/rhp.py +++ b/src/pymcnp/files/inp/surface_cards/rhp.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/rpp.py b/src/pymcnp/files/inp/surface_cards/rpp.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/rpp.py rename to src/pymcnp/files/inp/surface_cards/rpp.py index d2aca1e..a097108 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/rpp.py +++ b/src/pymcnp/files/inp/surface_cards/rpp.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/s.py b/src/pymcnp/files/inp/surface_cards/s.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/s.py rename to src/pymcnp/files/inp/surface_cards/s.py index 0683bc0..7dcb86e 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/s.py +++ b/src/pymcnp/files/inp/surface_cards/s.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/so.py b/src/pymcnp/files/inp/surface_cards/so.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/so.py rename to src/pymcnp/files/inp/surface_cards/so.py index e67b652..fbfbece 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/so.py +++ b/src/pymcnp/files/inp/surface_cards/so.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/sph.py b/src/pymcnp/files/inp/surface_cards/sph.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/sph.py rename to src/pymcnp/files/inp/surface_cards/sph.py index d3486b2..b68dbd5 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/sph.py +++ b/src/pymcnp/files/inp/surface_cards/sph.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/sq.py b/src/pymcnp/files/inp/surface_cards/sq.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/sq.py rename to src/pymcnp/files/inp/surface_cards/sq.py index 342772a..ecec736 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/sq.py +++ b/src/pymcnp/files/inp/surface_cards/sq.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/sx.py b/src/pymcnp/files/inp/surface_cards/sx.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/sx.py rename to src/pymcnp/files/inp/surface_cards/sx.py index 964c9ad..27fce5a 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/sx.py +++ b/src/pymcnp/files/inp/surface_cards/sx.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/sy.py b/src/pymcnp/files/inp/surface_cards/sy.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/sy.py rename to src/pymcnp/files/inp/surface_cards/sy.py index 146c1de..2702ae6 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/sy.py +++ b/src/pymcnp/files/inp/surface_cards/sy.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/sz.py b/src/pymcnp/files/inp/surface_cards/sz.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/sz.py rename to src/pymcnp/files/inp/surface_cards/sz.py index 4526549..78119b5 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/sz.py +++ b/src/pymcnp/files/inp/surface_cards/sz.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/trc.py b/src/pymcnp/files/inp/surface_cards/trc.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/trc.py rename to src/pymcnp/files/inp/surface_cards/trc.py index 4cffc82..64d2952 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/trc.py +++ b/src/pymcnp/files/inp/surface_cards/trc.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/tx.py b/src/pymcnp/files/inp/surface_cards/tx.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/tx.py rename to src/pymcnp/files/inp/surface_cards/tx.py index 10ef1a5..9de2fbe 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/tx.py +++ b/src/pymcnp/files/inp/surface_cards/tx.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/ty.py b/src/pymcnp/files/inp/surface_cards/ty.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/ty.py rename to src/pymcnp/files/inp/surface_cards/ty.py index 6dca86b..6634c7b 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/ty.py +++ b/src/pymcnp/files/inp/surface_cards/ty.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/tz.py b/src/pymcnp/files/inp/surface_cards/tz.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/tz.py rename to src/pymcnp/files/inp/surface_cards/tz.py index 24d3003..4b8f4df 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/tz.py +++ b/src/pymcnp/files/inp/surface_cards/tz.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/wed.py b/src/pymcnp/files/inp/surface_cards/wed.py similarity index 99% rename from src/pymcnp/files/inp/subclasses_surfaces/wed.py rename to src/pymcnp/files/inp/surface_cards/wed.py index 9c3f064..8d12e04 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/wed.py +++ b/src/pymcnp/files/inp/surface_cards/wed.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/x.py b/src/pymcnp/files/inp/surface_cards/x.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/x.py rename to src/pymcnp/files/inp/surface_cards/x.py index 3b6292b..cfd5511 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/x.py +++ b/src/pymcnp/files/inp/surface_cards/x.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/y.py b/src/pymcnp/files/inp/surface_cards/y.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/y.py rename to src/pymcnp/files/inp/surface_cards/y.py index 52db9b3..5500483 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/y.py +++ b/src/pymcnp/files/inp/surface_cards/y.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/subclasses_surfaces/z.py b/src/pymcnp/files/inp/surface_cards/z.py similarity index 98% rename from src/pymcnp/files/inp/subclasses_surfaces/z.py rename to src/pymcnp/files/inp/surface_cards/z.py index b35d118..06c540c 100644 --- a/src/pymcnp/files/inp/subclasses_surfaces/z.py +++ b/src/pymcnp/files/inp/surface_cards/z.py @@ -4,7 +4,8 @@ from typing import Final -from ..surface import Surface, SurfaceMnemonic +from ..surface import Surface +from ..surface_mnemonic import SurfaceMnemonic from ...utils import types, errors, _parser diff --git a/src/pymcnp/files/inp/surface_mnemonic.py b/src/pymcnp/files/inp/surface_mnemonic.py new file mode 100644 index 0000000..9217de5 --- /dev/null +++ b/src/pymcnp/files/inp/surface_mnemonic.py @@ -0,0 +1,79 @@ +""" +Contains classes representing INP surface card mnemonics. +""" + +from . import _card +from ..utils import errors +from ..utils import _parser + + +class SurfaceMnemonic(_card.CardMnemonic): + """ + Represents INP surface card mnemonics. + + ``SurfaceMnemonic`` implements ``_card.CardMnemonic``. + """ + + P = 'p' + PX = 'px' + PY = 'py' + PZ = 'pz' + SO = 'so' + S = 's' + SX = 'sx' + SY = 'sy' + SZ = 'sz' + C_X = 'c/x' + C_Y = 'c/y' + C_Z = 'c/z' + CX = 'cx' + CY = 'cy' + CZ = 'cz' + K_X = 'k/x' + K_Y = 'k/y' + K_Z = 'k/z' + KX = 'kx' + KY = 'ky' + KZ = 'kz' + SQ = 'sq' + GQ = 'gq' + TX = 'tx' + TY = 'ty' + TZ = 'tz' + X = 'x' + Y = 'y' + Z = 'z' + BOX = 'box' + RPP = 'rpp' + SPH = 'sph' + RCC = 'rcc' + RHP = 'rhp' + REC = 'rec' + TRC = 'trc' + ELL = 'ell' + WED = 'wed' + ARB = 'arb' + + @staticmethod + def from_mcnp(source: str): + """ + Generates ``SurfaceMnemonic`` objects from INP. + + ``from_mcnp`` translates from INP to PyMCNP; it parses INP. + + Parameters: + source: INP for ``SurfaceMnemonic``. + + Returns: + ``SurfaceMnemonic`` object. + + Raises: + McnpError: INVALID_SURFACE_MNEMONIC. + """ + + source = _parser.Preprocessor.process_inp(source) + + try: + return SurfaceMnemonic(source) + except ValueError: + raise errors.McnpError(errors.McnpCode.INVALID_SURFACE_MNEMONIC)