Skip to content

Commit 8ea5823

Browse files
committed
examples: updated OUTP examples
1 parent 7d25ea4 commit 8ea5823

Some content is hidden

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

49 files changed

+1155
-175183
lines changed

examples/example_read_F1F8out.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

examples/example_read_energy_and_time.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

examples/example_read_outp.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

examples/example_read_time.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

examples/get_cell.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Examples for reading INP cells using ``from_mcnp``.
3+
"""
4+
5+
import pathlib
6+
7+
import pymcnp
8+
9+
# Reading INP.
10+
path = pathlib.Path(__file__).parent / 'files' / 'inp' / 'F1F8.i'
11+
inp = pymcnp.Inp.from_file(path)
12+
13+
# Reading cell.
14+
cell = inp.cells[0]
15+
16+
print(cell)

examples/get_material.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Examples for reading INP materials using ``from_mcnp``.
3+
"""
4+
5+
import pathlib
6+
7+
import pymcnp
8+
9+
# Reading INP.
10+
path = pathlib.Path(__file__).parent / 'files' / 'inp' / 'F1F8.i'
11+
inp = pymcnp.Inp.from_file(path)
12+
13+
# Reading material.
14+
material = inp.data[0]
15+
16+
print(material)

examples/get_surface.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Examples for reading INP surfaces using ``from_mcnp``.
3+
"""
4+
5+
import pathlib
6+
7+
import pymcnp
8+
9+
# Reading INP.
10+
path = pathlib.Path(__file__).parent / 'files' / 'inp' / 'F1F8.i'
11+
inp = pymcnp.Inp.from_file(path)
12+
13+
# Reading surface.
14+
surface = inp.surfaces[0]
15+
16+
print(surface)

examples/get_tally1.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
Example reading OUTP type-1 tallies.
3+
"""
4+
5+
import pathlib
6+
7+
import pymcnp
8+
import matplotlib.pyplot as plt
9+
10+
TALLY = '1'
11+
SURFACE = '2.1'
12+
BIN_WIDTH = 5
13+
14+
# Reading OUTP.
15+
path = pathlib.Path(__file__).parent / 'files' / 'outp' / 'F1.o'
16+
outp = pymcnp.Outp.from_file(path)
17+
18+
# Reading tallies.
19+
tallies = outp.to_dataframe()
20+
tally = tallies[TALLY]
21+
surface = tally.loc[tally['surface'] == SURFACE]
22+
23+
# Plotting tally.
24+
plt.figure()
25+
plt.bar(surface['bins'], surface['counts'], width=BIN_WIDTH)
26+
plt.xlabel('Bins')
27+
plt.ylabel('Counts')
28+
plt.title(f'Type-1 Tally: Bins vs Counts')
29+
plt.show()

examples/get_tally2.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
Example reading OUTP type-2 tallies.
3+
"""
4+
5+
import pathlib
6+
7+
import pymcnp
8+
import matplotlib.pyplot as plt
9+
10+
TALLY = '2'
11+
SURFACE = '8'
12+
BIN_WIDTH = 5
13+
14+
# Reading tallies.
15+
path = pathlib.Path(__file__).parent / 'files' / 'outp' / 'png_tmp.o'
16+
outp = pymcnp.Outp.from_file(path)
17+
tallies = outp.to_dataframe()
18+
tally = tallies[TALLY]
19+
surface = tally.loc[tally['surface'] == SURFACE]
20+
21+
# Plotting tally.
22+
plt.figure()
23+
plt.bar(surface['bins'], surface['counts'], width=BIN_WIDTH)
24+
plt.xlabel('Bins')
25+
plt.ylabel('Counts')
26+
plt.title(f'Type-2 Tally: Bins vs Counts')
27+
plt.show()

examples/get_tally4.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
Example reading OUTP type-4 tallies.
3+
"""
4+
5+
import pathlib
6+
7+
import pymcnp
8+
import matplotlib.pyplot as plt
9+
10+
TALLY = '14'
11+
CELL = '12'
12+
BIN_WIDTH = 5
13+
14+
# Reading tallies.
15+
path = pathlib.Path(__file__).parent / 'files' / 'outp' / 'F4.o'
16+
outp = pymcnp.Outp.from_file(path)
17+
tallies = outp.to_dataframe()
18+
tally = tallies[TALLY]
19+
cell = tally.loc[tally['cell'] == CELL]
20+
21+
# Plotting tally.
22+
plt.figure()
23+
plt.bar(cell['bins'], cell['counts'], width=BIN_WIDTH)
24+
plt.xlabel('Bins')
25+
plt.ylabel('Counts')
26+
plt.title(f'Type-4 Tally: Bins vs Counts')
27+
plt.show()

0 commit comments

Comments
 (0)