Skip to content

Implement HalfSpace.mcnp_str() and HalfSpace.format_for_mcnp_input() #942

@tjlaboss

Description

@tjlaboss

Is your feature request related to a problem? Please describe.

I'm always frustrated when...

...working with a cell definition and wanting to print out just the geometry string.

>>> cell = montepy.Cell("1 0 -123 234 imp:n=1 u=2")
>>> cell.mcnp_str()
1 0 -123 234 imp:n=1 u=2
>>> cell.geometry
(l: s: False, is_c: False, div: SURFACE: 123, CZ| op: Operator.INTERSECTION| r:s: True, is_c: False, div: SURFACE: 234, PZ)
>>> cell.geometry.mcnp_str()
AttributeError: 'HalfSpace' object has no attribute 'mcnp_str'

Describe the solution you'd like

Implement HalfSpace.format_for_mcnp_input(). Move the geometry/region formatting to HalfSpace.format_for_mcnp_input(). Call that function from within Cell.format_for_mcnp_input(). Finally, implement HalfSpace.mcnp_str().

>>> cell.geometry.mcnp_str()
-123 234

Describe alternatives you've considered

Doing the same thing with an inheritance scheme for all printable objects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions