Addressing bug caused when units="SI"
in a call to write_inp()
#410
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Related: #409
When the
units
keyword argument is set to "SI" inwrite_inp
, WNTR will generate an INP file with values in SI units and the UNITS option set to "SI". The file can be loaded into EPANET file, where the "SI" gets changed to "LPS." No other values seem to be changed in the inp file, but I think that is correct since the only difference between "SI" units and "LPS" would be flow values and maybe pressure, which are not recorded in the inp file.I recommend not allowing "SI" to be passed as an argument here as one potential option to address this unintuitive behavior. My PR implements a basic approach by throwing an exception when "SI" is passed. Another option would be to allow "SI", but specify to the user what is happening when they load the "SI" inpfile into EPANET (this would require first really understanding what is going on ourselves). There seems to be special behavior in EPANET when you pass "SI" as UNITS, because the same conversion to "LPS" does not occur if you load an inp file with a nonsense unit like "ASDF" into EPANET.
Tests and documentation
Clarification of what values should be input as
units
should be added somewhere, perhaps the docstring.Acknowledgement
By contributing to this software project, I acknowledge that I have reviewed the software quality assurance guidelines and that my contributions are submitted under the Revised BSD License.