Closed RossWorrall closed 3 years ago
Hi Ross - thanks for finding this bug.
Indeed this was a bit naive from me (although I never really finished the input file creator module so it is not really production ready).
The problem is the code responsible is too simplistic and doesn't allow formatting for floats. Plus we should really be using f-strings here for formatting too (my bad).
# in file inputdata.py
def addkeyword(keyword, args=[]):
strargs = ' '.join([str(a) for a in args])
inputdata.append("{} {}".format(keyword, strargs))
I will try and patch this but it's really stupid from FISPACT-II to not support 15 decimal places. Another legacy hangover
@RossWorrall - does this https://github.com/fispact/pypact/commit/386175161b3fb99f41a3153e59474ee55f44bb8f fix your issue? I set the default precision to 10 sig fig for the input file writer, but it can be changed when initialised, something like:
inpd = pp.InputData(name="myrun1", precision=8)
inpd.setProjectile(pp.PROJECTILE_PROTON)
inpd.readGammaGroup()
inpd.enableSystemMonitor()
inpd.setAtomsThreshold(3.4e-8)
inpd.addIrradiation(5.4, 1.14678324e12)
inpd.addIrradiation(10.4, 1.3432525435e12)
# etc ....
It is a bit of a sloppy fix though since the precision will be the same for all floats - time, flux, atoms, mass, etc.... but at least gives control to the caller to avoid precision=16+.
Hi @thomasms,
Thanks for the fix, this works for me.
The following Irradiation time causes FISPACT to produce the error:
ERROR in INPUT file Expecting a keyword, but token 1.0318823828959384e+16 is too long Detected on line number = 120 Skipping to next keyword
This was generated via pypact using the .addIrradiation(1.0, 1.0318823828959384e+16) method. This can be fixed manually (in the FISPACT input file) be reducing the number of decimal places.