Skip to content

Commit ec38576

Browse files
committed
inp: added cutoff to from_formula
1 parent 363b9c2 commit ec38576

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

docs/source/examples/create.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ Code:
2626

2727
Output:
2828

29-
m1 001001 0.1118855432927602 001002 0.000012868317335160966 008016 0.8859435015301171 008017 0.00033747860358816377 008018 0.0018206082561993046
29+
m1 001001 0.1118855432927602 008016 0.8859435015301171
30+
m1 001001 0.1118855432927602 008016 0.8859435015301171
3031

3132
## Creating Surface Cards
3233

@@ -64,15 +65,11 @@ Output:
6465
11 rpp -1 1 -1 1 -1 1
6566
99 so 67
6667

67-
m21 007014 -0.797088 007015 -0.002912 008016 -0.199514 008017 -7.6e-05 008018 &
68-
-0.00041000000000000005
69-
m22 008016 -0.19984179019595494 008017 -7.612486369323746e-05 008018 &
70-
-0.00041067360676614944 022046 -0.02472289143502082 022047 &
71-
-0.02229555300321877 022048 -0.22091776443511935 022049 &
72-
-0.016212223353146985 022050 -0.015522979107079737 008016 &
73-
-0.03575396279808631 008017 -1.361960149490542e-05 008018 &
74-
-7.347416595935819e-05 082204 -0.006498225208082432 082206 &
75-
-0.11186230536770471 082207 -0.10257912649901553 082208 &
76-
-0.24321928635965673
68+
m21 007014 -0.797088 008016 -0.199514
69+
m22 008016 -0.19984179019595494 022046 -0.02472289143502082 022047 &
70+
-0.02229555300321877 022048 -0.22091776443511935 022049 &
71+
-0.016212223353146985 022050 -0.015522979107079737 008016 &
72+
-0.03575396279808631 082206 -0.11186230536770471 082207 &
73+
-0.10257912649901553 082208 -0.24321928635965673
7774
m23 082204 -0.014 082206 -0.241 082207 -0.221 082208 -0.524
7875

examples/create_material.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Creating material using ``__init__``.
88
material = pymcnp.inp.data.M_0(
9-
suffix=1, substances=['001001 0.1118855432927602', '001002 1.2868317335160966e-05', '008016 0.8859435015301171', '008017 0.00033747860358816377', '008018 0.0018206082561993046']
9+
suffix=1, substances=['001001 0.1118855432927602', '008016 0.8859435015301171']
1010
)
1111

1212
print(material)

src/pymcnp/inp/data/M_0.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import re
2+
import math
23

34
import molmass
45

@@ -155,14 +156,15 @@ def options(self, options: list[str] | list[m_0.MOption_0]) -> None:
155156
self._options: types.Tuple(m_0.MOption_0) = options
156157

157158
@staticmethod
158-
def from_formula(number: int, formulas: dict[str, float], is_weight: bool = True):
159+
def from_formula(number: int, formulas: dict[str, float], is_weight: bool = True, cutoff: float = 0.01):
159160
"""
160161
Generates ``M_0`` from INP.
161162
162163
Parameters:
163164
number: Arbitrary material number.
164165
formulas: Dictionary of formulas and atomic/weight fractions.
165166
is_weight: Weight (atomic) fraction true (false) flag.
167+
cutoff: Nuclide fraction cutoff.
166168
167169
Returns:
168170
``M_0`` object.
@@ -184,16 +186,14 @@ def from_formula(number: int, formulas: dict[str, float], is_weight: bool = True
184186
)
185187
for a, isotropic_fraction in _elements.ELEMENTS[element]['fraction'].items()
186188
]
187-
subcomments = [f'{element}-{zaid.a:03}' for zaid, _ in zaids]
188189
entries = [
189190
types.Substance(
190191
zaid,
191192
types.Real((-1 if is_weight else 1) * mixture_fraction * compound_fraction * isotropic_fraction),
192193
)
193-
for zaid, isotropic_fraction in zaids
194+
for zaid, isotropic_fraction in zaids if mixture_fraction * compound_fraction * isotropic_fraction > cutoff
194195
]
195196

196-
comments += subcomments
197197
substances += entries
198198

199199
material = M_0(types.Integer(number), types.Tuple(types.Substance)(substances))

0 commit comments

Comments
 (0)