Skip to content

Commit

Permalink
Updated example to work and be recognizable by doctest.
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahGale committed Oct 17, 2024
1 parent a5e89ef commit 02265e4
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,34 +51,34 @@ and the Python API documentation.
Here is a quick example showing multiple tasks in MontePy:

```python
import montepy
# read in file
problem = montepy.read_input("foo.imcnp")
>>> import montepy
>>> # read in file
>>> problem = montepy.read_input("tests/inputs/test.imcnp")

# set photon importance for multiple cells
importances = {1: 0.005,
2: 0.1,
3: 1.0,
99: 1.235
}
for cell_num, importance in importances.items():
problem.cells[cell_num].importance.photon = importance

#create a universe and fill another cell with it
universe = montepy.Universe(123)
problem.univeres.append(universe)
# add all cells with numbers between 1 and 4
universe.claim(problem.cells[1:5])
# fill cell 99 with universe 123
problem.cells[99].fill.universe = universe

# update all surfaces numbers by adding 1000 to them
for surface in problem.surfaces:
surface.number += 1000
# all cells using these surfaces will be automatically updated as well

#write out an updated file
problem.write_problem("foo_update.imcnp")
>>> # set photon importance for multiple cells
>>> importances = {1: 0.005,
... 2: 0.1,
... 3: 1.0,
... 99: 1.235
... }
>>> for cell_num, importance in importances.items():
... problem.cells[cell_num].importance.photon = importance

>>> #create a universe and fill another cell with it
>>> universe = montepy.Universe(123)
>>> problem.universes.append(universe)
>>> # add all cells with numbers between 1 and 4
>>> universe.claim(problem.cells[1:5])
>>> # fill cell 99 with universe 123
>>> problem.cells[99].fill.universe = universe

>>> # update all surfaces numbers by adding 1000 to them
>>> for surface in problem.surfaces:
... surface.number += 1000
>>> # all cells using these surfaces will be automatically updated as well

>>> #write out an updated file
>>> problem.write_problem("foo_update.imcnp")

```

Expand Down

0 comments on commit 02265e4

Please sign in to comment.