idaholab / MontePy

MontePy is the most user friendly Python library (API) to read, edit, and write MCNP input files.
https://www.montepy.org/
MIT License
32 stars 7 forks source link

Botched Integer Interpolation Expansion #489

Closed tjlaboss closed 2 months ago

tjlaboss commented 3 months ago

Describe the bug

MontePy expands shortcuts for data entry:

image

The linear interpolation shortcut gets botched upon expansion, being converted to floating point and dropping necessary padding.

To Reproduce

Just load an MCNP input file with the shortcut and write it back out.

import montepy
montepy.read_input("testi.i").write_to_file("testo.i")

MCNP input file snippet

If applicable, please include a small section of the input file you were working on. If it includes any specific values please change or remove them. For example:

MCNP Test Model
C Cells
C Seven spheres within a sphere
1 1 -10 -1001  imp:n,p=2
2 1 -10 -1002  imp:n,p=2
3 1 -10 -1003  imp:n,p=2
4 1 -10 -1004  imp:n,p=2
5 1 -10 -1005  imp:n,p=2
6 1 -10 -1006  imp:n,p=2
7 1 -10 -1007  imp:n,p=2
C This cell breaks MontePy 0.3.3
8     0 -1010  1001  5i  1007  imp:n,p=1
C Graveyard
99    0 +1010     imp:n,p=0

C surfaces
1001 SO      0.1
1002 SX -1.1 0.1
1003 SX +1.1 0.1
1004 SY -1.1 0.1
1005 SY +1.1 0.1
1006 SZ -1.1 0.1
1007 SZ +1.1 0.1
1010 SO 3

C data
C materials
C UO2 5 atpt enriched
m1        92235.80c           5
          92238.80c          95
C execution
ksrc 0 0 0
kcode 100000 1.000 50 1050
mode n p

Error Message (if any)

MCNP Test Model
C Cells
C Seven spheres within a sphere
1 1 -10 -1001  imp:n,p=2
2 1 -10 -1002  imp:n,p=2
3 1 -10 -1003  imp:n,p=2
4 1 -10 -1004  imp:n,p=2
5 1 -10 -1005  imp:n,p=2
6 1 -10 -1006  imp:n,p=2
7 1 -10 -1007  imp:n,p=2
C This cell breaks MontePy 0.3.3
8     0 -1010  1001  1002.01003.01004.01005.01006.01007  imp:n,p=1
C Graveyard
99    0 +1010     imp:n,p=0

C surfaces
1001 SO      0.1
1002 SX -1.1 0.1
1003 SX +1.1 0.1
1004 SY -1.1 0.1
1005 SY +1.1 0.1
1006 SZ -1.1 0.1
1007 SZ +1.1 0.1
1010 SO 3

C data
C materials
C UO2 5 atpt enriched
m1        92235.80c           5
          92238.80c          95
C execution
ksrc 0 0 0
kcode 100000 1.000 50 1050
mode n p

Version

Additional context

MontePy currently expands interpolation shortcuts and does not recompress them (#397).

MicahGale commented 3 months ago

Oh yikes. I suspect that #397 is a common-mode failure. Part of this is we need to use context to change a shortcut to int from float.