Skip to content

Commit 9222270

Browse files
committed
inp: fixed DAWWG card
1 parent c7becbb commit 9222270

170 files changed

Lines changed: 120 additions & 260 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

files/inp/valid_18.inp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ mesh geom cyl
4545
jints 2 $ 2 axial divisions
4646
kmesh 1 $ azimuth-single rotation (0-2pi)
4747
kints 4 $ 4 azimuthal divisions (0, pi/2, pi, 3pi/2, 2pi)
48-
c dawwg xsec=ndilib points=10
48+
dawwg xsec=ndilib points=10
4949

5050
(MCNP Manual 6.2 Section 4.1.4)

scripts/inp_code.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,11 @@ def ATTR_BUILDER(element, attribute, t):
166166
o += f'{TABS(t)} elif isinstance(item, int):\n'
167167
o += f'{TABS(t)} array.append({attribute.type[12:-1]}(item))\n'
168168
if 'types.Real' in attribute.type:
169-
o += f'{TABS(t)} elif isinstance(item, int):\n'
170-
o += f'{TABS(t)} array.append({attribute.type[12:-1]}(item))\n'
171-
o += f'{TABS(t)} elif isinstance(item, float):\n'
169+
o += f'{TABS(t)} elif isinstance(item, int) or isinstance(item, float):\n'
172170
o += f'{TABS(t)} array.append({attribute.type[12:-1]}(item))\n'
173171

174172
o += f'{TABS(t)} elif isinstance(item, str):\n'
175173
o += f'{TABS(t)} array.append({attribute.type[12:-1]}.from_mcnp(item))\n'
176-
o += f'{TABS(t)} else:\n'
177-
o += f'{TABS(t)} raise TypeError\n'
178174
o += f'{TABS(t)} {attribute.name} = types.Tuple(array)\n'
179175
else:
180176
o += f'{TABS(t)} if isinstance({attribute.name}, {attribute.type}):\n'
@@ -184,15 +180,11 @@ def ATTR_BUILDER(element, attribute, t):
184180
o += f'{TABS(t)} elif isinstance({attribute.name}, int):\n'
185181
o += f'{TABS(t)} {attribute.name} = {attribute.type}({attribute.name})\n'
186182
if 'types.Real' in attribute.type:
187-
o += f'{TABS(t)} elif isinstance({attribute.name}, int):\n'
188-
o += f'{TABS(t)} {attribute.name} = {attribute.type}({attribute.name})\n'
189-
o += f'{TABS(t)} elif isinstance({attribute.name}, float):\n'
183+
o += f'{TABS(t)} elif isinstance({attribute.name}, int) or isinstance({attribute.name}, float):\n'
190184
o += f'{TABS(t)} {attribute.name} = {attribute.type}({attribute.name})\n'
191185

192186
o += f'{TABS(t)} elif isinstance({attribute.name}, str):\n'
193187
o += f'{TABS(t)} {attribute.name} = {attribute.type}.from_mcnp({attribute.name})\n'
194-
o += f'{TABS(t)} else:\n'
195-
o += f'{TABS(t)} raise TypeError\n'
196188

197189
return o.strip()
198190

scripts/inp_data.py

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3182,9 +3182,9 @@ def draw(self):
31823182
mnemonic='points',
31833183
attributes=[
31843184
AttributeScheme(
3185-
name='name',
3186-
type='types.String',
3187-
description='Cross section library',
3185+
name='count',
3186+
type='types.Integer',
3187+
description='Number of sample points for each direction in each mesh',
31883188
),
31893189
],
31903190
),
@@ -3193,9 +3193,9 @@ def draw(self):
31933193
mnemonic='xsec',
31943194
attributes=[
31953195
AttributeScheme(
3196-
name='count',
3197-
type='types.Integer',
3198-
description='Number of sample points for each direction in each mesh',
3196+
name='name',
3197+
type='types.String',
3198+
description='Cross section library',
31993199
),
32003200
],
32013201
),
@@ -6655,6 +6655,16 @@ def from_formula(number: int, formulas: dict[str, float], is_weight: bool = True
66556655
name='ds_1',
66566656
mnemonic='ds',
66576657
regex='ds(\\d+) t((?: {types.IndependentDependent._REGEX.pattern[2:-2]})+?)',
6658+
extra='''
6659+
def to_mcnp(self):
6660+
"""
6661+
Generates INP from ``Ds_1``.
6662+
6663+
Returns:
6664+
INP for ``Ds_1``.
6665+
"""
6666+
return f'ds{self.suffix} t {self.ijs}'
6667+
''',
66586668
attributes=[
66596669
AttributeScheme(
66606670
name='suffix',
@@ -6674,6 +6684,16 @@ def from_formula(number: int, formulas: dict[str, float], is_weight: bool = True
66746684
name='ds_2',
66756685
mnemonic='ds',
66766686
regex='ds(\\d+) q((?: {types.IndependentDependent._REGEX.pattern[2:-2]})+?)',
6687+
extra='''
6688+
def to_mcnp(self):
6689+
"""
6690+
Generates INP from ``Ds_2``.
6691+
6692+
Returns:
6693+
INP for ``Ds_2``.
6694+
"""
6695+
return f'ds{self.suffix} q {self.vss}'
6696+
''',
66776697
attributes=[
66786698
AttributeScheme(
66796699
name='suffix',
@@ -7306,6 +7326,17 @@ def from_formula(number: int, formulas: dict[str, float], is_weight: bool = True
73067326
name='f_2',
73077327
mnemonic='f',
73087328
regex='([*+])?f(\\d*[5])([xyz])(?::(\\S+))?((?: \\S+ \\S+ \\S+)+?)( nd)?',
7329+
extra='''
7330+
def to_mcnp(self):
7331+
"""
7332+
Generates INP from ``F_2``.
7333+
7334+
Returns:
7335+
INP for ``F_2``.
7336+
"""
7337+
7338+
return f'{self.prefix or ""}f{self.suffix}{self.a}{f":{self.designator}" if self.designator else ""} {self.rings} {self.nd or ""}'
7339+
''',
73097340
attributes=[
73107341
AttributeScheme(
73117342
name='prefix',

src/pymcnp/inp/cell/Fill_0.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ def universes(self, universes: list[str] | list[int] | list[types.Integer]) -> N
232232
array.append(types.Integer(item))
233233
elif isinstance(item, str):
234234
array.append(types.Integer.from_mcnp(item))
235-
236235
universes = types.Tuple(array)
237236

238237
if universes is None:

src/pymcnp/inp/cell/Tmp.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ def temperature(self, temperature: list[str] | list[float] | list[types.Real]) -
103103
array.append(types.Real(item))
104104
elif isinstance(item, str):
105105
array.append(types.Real.from_mcnp(item))
106-
107106
temperature = types.Tuple(array)
108107

109108
if temperature is None or not (min(map(lambda temp: temp, temperature)) > 0):

src/pymcnp/inp/data/Act.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def options(self, options: list[str] | list[act.ActOption]) -> None:
6363
array.append(item)
6464
elif isinstance(item, str):
6565
array.append(act.ActOption.from_mcnp(item))
66-
6766
options = types.Tuple(array)
6867

6968
self._options: types.Tuple[act.ActOption] = options

src/pymcnp/inp/data/Area.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ def areas(self, areas: list[str] | list[float] | list[types.Real]) -> None:
6565
array.append(types.Real(item))
6666
elif isinstance(item, str):
6767
array.append(types.Real.from_mcnp(item))
68-
6968
areas = types.Tuple(array)
7069

7170
if areas is None:

src/pymcnp/inp/data/Awtab.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def weight_ratios(self, weight_ratios: list[str] | list[types.Substance]) -> Non
6363
array.append(item)
6464
elif isinstance(item, str):
6565
array.append(types.Substance.from_mcnp(item))
66-
6766
weight_ratios = types.Tuple(array)
6867

6968
if weight_ratios is None:

src/pymcnp/inp/data/Bbrem.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2128,7 +2128,6 @@ def materials(self, materials: list[str] | list[int] | list[types.Integer]) -> N
21282128
array.append(types.Integer(item))
21292129
elif isinstance(item, str):
21302130
array.append(types.Integer.from_mcnp(item))
2131-
21322131
materials = types.Tuple(array)
21332132

21342133
if materials is None:

src/pymcnp/inp/data/Bflcl.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ def numbers(self, numbers: list[str] | list[int] | list[types.Integer]) -> None:
6565
array.append(types.Integer(item))
6666
elif isinstance(item, str):
6767
array.append(types.Integer.from_mcnp(item))
68-
6968
numbers = types.Tuple(array)
7069

7170
if numbers is None:

0 commit comments

Comments
 (0)