Skip to content

Commit

Permalink
Documented how to use parse.
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahGale committed Nov 22, 2024
1 parent 085cc3f commit fb68afb
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions doc/source/starting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,35 @@ If a ``Cell`` or a group of ``Cells`` are cloned their numbers will be to change
However, if a whole :class:`~montepy.mcnp_problem.MCNP_Problem` is cloned these objects will not have their numbers changed.
For an example for how to clone a numbered object see :ref:`Cloning a Cell`.

Creating Objects from a String
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Sometimes its more convenient to create an MCNP object from its input string for MCNP, rather than setting a lot of properties,
or the object you need isn't supported by MontePy yet.
In this case there are a few ways to generate this object.
First all :class:`~montepy.mcnp_object.MCNP_Object` constructors can take a string:

.. doctest::

>>> cell = montepy.Cell("1 0 -2 imp:n=1")
>>> cell.number
1
>>> cell.importance[montepy.particle.NEUTRON]
1.0

This object is still unlinked from other objects, and won't be kept with a problem.
So there is also :func:`~montepy.mcnp_problem.MCNP_Problem.parse`.
This takes a string, and then creates the MCNP object,
links it to the problem,
links it to its other objects (e.g., surfaces, materials, etc.),
and appends it to necessary collections:

.. testcode::

cell = problem.parse("123 0 -1005")
assert cell in problem.cells
assert cell.surfaces[1005] is problem.surfaces[1005]

Surfaces
--------

Expand Down

0 comments on commit fb68afb

Please sign in to comment.