muon-spectroscopy-computational-project / mudirac

A muonic atom Dirac equation solver
https://muon-spectroscopy-computational-project.github.io/mudirac/
MIT License
5 stars 4 forks source link

Handling of negative spec_step and spec_linewidth #15

Open patrick-austin opened 1 month ago

patrick-austin commented 1 month ago

Describe the bug Submitting a negative spec_step results in the command never completing. Submitting a negative spec_linewidth results in a completing job, but don't think that a negative width is physically valid.

To Reproduce

element: Au
isotope: -1
xr_lines: K1:L3-K1:L3
uehling_correction: false
nuclear_model: POINT
output: 1
write_spec: true
spec_step: -10000.0
spec_linewidth: 100000.0
element: Au
isotope: -1
xr_lines: K1:L3-K1:L3
uehling_correction: false
nuclear_model: POINT
output: 1
write_spec: true
spec_step: 10000.0
spec_linewidth: -100000.0

Expected behavior The former should definitely not be allowed. A validation error should prevent a negative step being used to prevent the command never completing. I also don't think that a negative linewidth is physically valid, but this is less of an issue as it doesn't cause a total failure like the step does.

Screenshots Spectrum with 1e5 linewidth image

Spectrum with -1e5 linewidth image

~Desktop~VM (please complete the following information):

leandro-liborio commented 1 month ago

Hi both,

Good point Patrick. None of those negative values should be allowed, as they do not have any physical meaning.

patrick-austin commented 1 week ago

Other parameters that can cause issues when given negative values:

At this point I think it's likely that a lack of input validation is the rule rather than the exception. A general review of all numeric parameters to ensure they are being validated is probably sensible.

leandro-liborio commented 1 day ago

with regards to spec-step and spec-line-width being negative. We now have a message when a negative value is used. It is this one: ' Parameter spec_step: Value ('-10.0') must fulfill float('0.0') <= float(value) <= float('inf')'. Now... I understand that error message. It says that the values has to be between 0 and inf. However... Is there any way of putting this error message in human-like language?