libamtrack / web

Web interface for libamtrack
https://libamtrack.github.io/web/
GNU General Public License v3.0
7 stars 2 forks source link

Include possibility to change input units #616

Open grzanka opened 3 years ago

grzanka commented 3 years ago

I.e. specify energy in MeV or in MeV/amu

marwin1991 commented 3 years ago

Something like that? A drop down list with units ?

image

grzanka commented 3 years ago

Yes, exactly. Some of the units are easy to convert (like MeV to GeV), but for some others knowledge of other input fields is needed. For example to convert from MeV/u to MeV one needs to know particle type.

marwin1991 commented 3 years ago

So I see it lke that:

define available units with multiplier.

units: {
    "MeV": 1.0
    "GeV": 0.001
}

the first one is default one.

marwin1991 commented 3 years ago

But what about funtions where user can change particle ?

grzanka commented 3 years ago

Let us consider https://libamtrack.github.io/web/#Particlerangeandstoppingpower/Stoppingpowervsenergy First of all there is a basic reference unit for energy: MeV/u - the one which is expected by AT_Stopping_Power_with_no function (https://github.com/libamtrack/web/blob/master/src/functionsFromC/AT_Mass_Stopping_Power_with_no.js)

Right now we specify energy in MeV/u. The problem is that users are used to specify energy for protons in MeV, while for other ions in MeV/u.

Ideally user should define energy start and stop numerical values, then set the unit (MeV or MeV/u). Then user selects particle (proton or other particle). Finally when user clicks "Submit" all values are recalculated to basic reference unit (here MeV/u).

For plotting and output we should stay for now with fixed unit.

We could add a dictionary like you mention, but they should include not only multipliers, but also "converter functions". The tricky part is how to pass also their parameters.

marwin1991 commented 3 years ago

Maybe let's consider some example:

https://libamtrack.github.io/web/#Particlerangeandstoppingpower/Stoppingpowervsenergy

User defines start/end Energy in MeV: start 1.0 end 500.0, then picks "He" from particles, and for further calculations we have to find out MeV/u. And it would be start: 1.0/4.0026 and end 500.0/4.0026 (4,0026 is a "He" weight? )

The second thing is a question: should we change user input after submit ? Maybe it would be better to display converted values in some table, because user will have to remeber that he inserted 500.0 and recalculated value is 124,918 MeV/u and the next end value he want 600 MeV so he have to change units and if he forgets the calculations will be performed for 600MeV/u and results will be really confusing

grzanka commented 3 years ago

@marwin1991 good point. Information what kind of units were used should not be lost. I could imagine also another solution.

First a remark - user will probably need no more than 3-4 different units (most often only 2 be used).

By default only main unit is presented to the user. But there is small "Show more units button" somewhere. If this is clicked few more columns appear (next to start/stop fields or others with units). Each column correspond to different unit. Description of field should be compressed and go over the field or be closer to the input field. If users enter a number in one field, automatically other fields in same row are being recalculated. The field with entered number is being highlighted in green, other (recalculated) fields are highlighted in red. This should be similar to what is done in webinterface to Catima: https://isotopea.com/webatima/#!/projectile (try fillling beta or energy values).

The tricky part is when user is changing projectile. Then I'd keep fixed the value which was changed as last (green fields). Other fields would need to be recalculated.

It seems that the logic behind would need to be somehow complex.

marwin1991 commented 3 years ago

1. Something like that?

image

And chaning particle will recalculate MeV/u ?

2. I am also thinking about proposition https://github.com/libamtrack/web/issues/616#issuecomment-767629168 and additionaly add something like validation inforamiton but green

image

and it would be displaying conversion to default value.

F.e. Stopping power has default MeV/u. User picks from dropdown MeV and inputs 1000 and below green validation info apears and displays "It is: XXX.XXX MeV/u" Then user picks diffrent particle and green validation now changes to "It is: YYYY.YYYY MeV/u"

marwin1991 commented 3 years ago

Maybe we should use https://docs.github.com/en/discussions/quickstart ?