Menu

#49 Units

Next_Release
open
nobody
None
1
2019-04-25
2016-07-12
No

I have many ideas, some of them I don't know how to implement and it's hard to explain.

ToDo list:
1.Add more units to units.imath
2.Add list of units in gui
3.Add physical constants
4.Increase usability
5.SI prefixes as multiplier
6.Usability of Celsius-Kelvin conversion

Discussion

1 2 > >> (Page 1 of 2)
  • zeon_account_will_be_deleted

    Hi, Jan.

    This is a lot of work and it's not for upcoming release. But some upgrade may be done right now.

    I've created "units.ods". It's useful for correcting units.imath. You may see all changes I've done there.
    What I've done for now:
    1.Added several units like %km, %kPa, %mbar... All new units are marked as "new".
    2.Added current list of units taken from units.imath to "Insert iFormula" and "Format" dialogs. I'd like to group units in this list by their type (length, time, mass etc.), not by their origin (SI, British etc...). It is better not to sort them directly in units.imath, right?

     
  • zeon_account_will_be_deleted

    I have some proposals:

    3.Add something like constants.imath. Where we may add physical constants like speed of light, Planck constant and others. With units of course.

    4.It's complicated to define complex units like "m^3/h" or "kJ/{kg K}" for print. I've solved first example, but it was a mystery for me for a long time. It's enough to add {units={%h}}. But I still don't understand how to get value in "kJ/{kg K}". Which units I need to add? Should I create new UNITDEF? Well, it's complicated to think of name for it. "kJokgK"?. Could you add support for some more simbols: .,^/. And numbers? Or this option would be better: implement combination of units as expression {units={"kJ"/{"kg" "K"}; "m"^3/"h"}}.

    5.I've seen SI prefixes in units.imath. How it actually work? In the ideal I'd like to use any SI prefix free with combination of any unit in equation or in the field "Unit" in the dialogs. So I may get %cm, %dm, %nm, %kton, %kVA (kilo volt vmper) etc... Now it means that I have to create new UNITDEF for each unit with prefix. If I add all possible units with all prefixes, this is thousands of combinations. Maybe it's possible at least do it this way: {units={%k%ton}}? In the ideal: {units={%kton}}. Bad thing is that unit "m" and prefix "m" are both "m" and this may become a problem for parser.

    6.Is it really necessary to use function "celsiustokelvin" always? It doesn't solve the problem that user may concider 20°C as temperature OR the temperature difference? The unit %degreecelsius is inconvenient too. It's too long. First I thought: why don't we add these items to units.imath?

    %%ii UNITDEF{"K", %K = val (celsiustokelvin(%degreecelsius))}
    %%ii UNITDEF{"°C", %celsius = val (kelvintocelsius(%kelvin))}
    

    Also I wish %degreecelsius is build-in function in iMath, instead of %celsius.
    Anyway then I've realized, that this may cause mistakes, e.g. we have an expression: "20C - 5K". How to calculate its value? This expression is "not right", because it has two solutions. We may keep in mind that 5K=5C (temperature difference) or 5K=-268.1 °C. But none of programs knows it. I was taught to use K in formulas as far as it's possible. Not only celsius, all other scales of temperature have this issue. I have no idea how to solve it now. But I'll think of it.
    I've marked four items as "remove", but actually did not any change in units.imath.

     
    • zeon_account_will_be_deleted

      Forgot attachment. This is about item 4.

       
  • Jan Rheinlaender

    Hi zeon,

    lots of good ideas. Some things can be done without code.
    The problem with creating a lot of units and constants will be that there are names that have two meanings. Which usually is no problem because they occur in quite different areas of physics, but if you put it all in one file, then you have the problem.
    Another problem about creating lots of units and constants is that all these names are already defined and the user cannot use them for his own variables. That is the reason why I made a long name for celsiustokelvin. If it is too long then the user can always define his own function as abbreviation.

    1. We should make a file extraunits.imath and keep only SI units in units.imath. This can be included by the user with "iMath" "Document options" "include further files". The current content of units.imath is taken from ctex.org/documents/packages/special/SIunits.pdf .
    2. As I said this list of units should be generated by code from all current units known to the document. If we want to group the list of units then we will have to introduce a category parameter into UNITDEF.
    3. This can also be done without code and included with "include further files" (for now)
    4. units={} takes only SINGLE units in the list, not expressions of units. About "kJ/{kg K}": It should work with units={%kg;%kJ} but it doesn't, so it is a bug.
    5. SI prefixes: You can write "kilo""m" or %kilo%m. Not perfect yet but a start. With this syntax we can avoid introducing a lot of new units (which are really abbreviations) like %mm (short for %milli%m), %cm, %dm, %km.
    6. Did you read at the end of iMath-tour.odt about Kelvin/Celsius problem?

    Maybe we should think of creating a library of iMath include files. So mechanical engineers can include the typical units for their work, electrical engineers can include others, etc. That would reduce possible name clashes.

     
  • zeon_account_will_be_deleted

    Yes, I've read iMath-tour. I know how it works, but I don't understand, why we can't add these strings to units.imath?
    %%ii UNITDEF{"K", %K = val (celsiustokelvin(%degreecelsius))}
    %%ii UNITDEF{"°C", %celsius = val (kelvintocelsius(%kelvin))}
    These ones may ease celsius-to-kelvin conversion. It's not very convenient to use function to convert units. And the primary issue is not the function "celsiustokelvin", but the usage of these units. Maybe it's possible to let user define that 20K is a temperature difference somehow? Or we just leave it to intelligence of user? I think there may be some good solution.

     
  • Jan Rheinlaender

    Hi zeon,

    I am trying to encourage users to use either K or °C in a document, but not a mix of both. So the functions are only defined to present the result of a calculation to the reader at the very end.

    We might also define UNITDEF{"K", %K = %celsius} which is also true if we talk about temperature differences only...

    We could define a different unit for absolute temperatures and for temperature differences, e.g. "ΔK", %deltaK. Then this would have to be a further base unit which cannot be converted into any of the other SI base units. But fact is that in normal practice "K" and "°C" is used for both absolute temperature and temperature difference and the reader has to decide from the context what it means.

     
  • zeon_account_will_be_deleted

    Hi Jan!

    The irony is that it doesn't really matter how to convert Celsius to Kelvin. Anybody still may convert t=20°C with your function and get t=293,15K. And so what?

    I agree with you partly. Mixing K or °C may cause mistakes if they rely on different bases. Implementing more base units will only raise possible number of mistakes. But what if we keep the only base in iMath?

     
  • zeon_account_will_be_deleted

    1.Yes, we may create more than one file to include. I think "include further files" option has a bug or I don't understand how it works. I've unchecked "units.imath" and tried to include this file thru "include further files" and got error:
    "In included file: Line 1, column 16
    Could not open include file"
    2.Ok, good idea for future release. Could we just fill a list of units directly for now? It's complicated to use it just because lack of examples. I'm not sure that many users unpack "imath.oxt" archive and search for "units.imath" file to discover, which units are available now. By the way, this list of units doesn't support multiple selection, but it supports free text input.
    3.Ok.
    4.Could you fix it?
    5.In ideal I'd like to print exactly "km", because of formatting issues, that are present currently. But it's Ok for now. Because it requires editing code of parser and may cost a lot of time.
    6.Yes.

     
    • zeon_account_will_be_deleted

      SI prefixes: no, it seems it ain't work. Could you attach an example? E.g. how to get a kilo ton unit at print?

       
      • Jan Rheinlaender

        That's not possible yet because preferred units will only take single units (so you need an abbreviation like %km = %kilo%meter).
        It is only possible to write %kilo%meter which iMath will interpret correctly as 1000%metre.

         
    • Jan Rheinlaender

      1. Include file: Works for me on Linux and Windows.
        What path are you using? Does it have spaces or special characters maybe?
      2. Yes I will use the list you posted here, but only with the units currently in units.imath
      3. I suppose you know you can work around this with %%ii UNITDEF {"{\"kg\" over {\"kJ\" \"K\"}}", %kgkJK = %kg / {%kJ %K}}?

      I would like to leave all changes to units for next release. In this release only your improvements to the dialogs with the list of units same as in units.imath except abbreviations (those should be a separate include file in the future). Because removing celsius as base unit is a big change and might break older documents, so we have to test carefully.

       

      Last edit: Jan Rheinlaender 2016-07-14
      • Jan Rheinlaender

        About Nr. 3: Displaying [K]^(-1)*[m]^(-2)*[s]^2 in the preferred units %kg;%kJ cannot work now because the algorithm works by substituting [kg]*[m]^2*[s]^(-2) = 1/1000*[kJ] . But the expression doesn't contain this so it cannot be substituted. What is required is to change the algorithm to accept a preferred unit that is an expression, in this case %kg/%kJ.

         
        • Jan Rheinlaender

          Hi zeon,

          I uploaded iMath-2.1.5~beta1-only-for-testing.oxt where the following works:

          %%ii UNITDEF { "k", %kilo = 1000 }
          %%ii @1@ {autoformat=true; units={%kilo%m/%h}} EQDEF y = 1000 %m/%s

          That is only the first step, of course.

           
      • zeon_account_will_be_deleted

        Ok. So we wait for next stable release soon.

        You probably would like to remove %degreecelsius unit and all variants of %kelvin from that list (not from units.imath of course). Because they are currently useless.

        Maybe it's better to improve formula parser once, so it's possible to consider %km as "kilo" "meter", than to create thousands of %unitnames. I suppose every unit and SI prefix have their unique abbreviation (except "m" and "h"). Even "m" may be parsed as "milli" at the beginning of word and as "meter" at the end. The same about "hecto" and "hour". I can collect all the units I'll find into one file and discover more coincidences. We'll have time to think abot it.

         
      • zeon_account_will_be_deleted

        Yes, there are spaces in the path. Moving file to another directory solved the problem.

         
        • Jan Rheinlaender

          Actually I don't think the spaces are the problem. I just tested on LInux and Windows. You probably used units.imath for testing and there were already units defined in your document. I did the same and got an error.

          If the file cannot be found the error will say "cannot open include file".

           
          • zeon_account_will_be_deleted

            Hi, Jan!

            This is because of cyrillic symbols in a path or filename. I couldn't recognize it because when I tested it first time at work, there was a directory with spaces and cyrillic symbols. So I thought it was spaces as it often is in such cases.

             
            • zeon_account_will_be_deleted

              This is a bug, right? Could you fix it before 2.1.4?

               
              • Jan Rheinlaender

                Are you sure the cyrillic is the problem? I just tested Persian characters plus spaces and it worked fine. What is the content of the file you are including?

                 
                • zeon_account_will_be_deleted

                  New empty Writer file + include "units.imath" in document options. In global options only init.imath is included. It only happens on windows for me. On Ubuntu both spaces and cyrillic characters do not affect, everything works.

                   
                  • Jan Rheinlaender

                    Just uploaded iMath-2.1.4.oxt (replacing the old file) with the problem of UTF-8 file paths on Windows fixed.

                     
                    • zeon_account_will_be_deleted

                      Great! Fixed.

                       
    • Jan Rheinlaender

      Hi zeon,

      find attached my suggestion for a new "Include file" dialog and 6 new unit definition files. The include file dialog would be a second menu entry under Extras-Options-Writer called "iMath files" (for example).

      Under menu iMath-Document options we could have a multi-page dialog which is navigated with "forward"/"back" buttons.

      What do you think?

       
  • Jan Rheinlaender

    Hi

    I just uploaded beta7. Hopefully last beta before next release - unless you find more bugs...

     
  • zeon_account_will_be_deleted

    Hi, Jan!

    I think there are so much included files now. So a separate dialog is a good solution. Let's create new menu entry for document options, multipage dialogs are not a strong side of XDL format.
    Document Options:
    - Settings
    - External references

    Of course I'd like to see something that looks like the "External References" manager in... AutoCad. It's designed as an interactive table, you may see some info about all referenced files, their status (loaded, not found, unloaded), and easily remove or attach files. But this is most likely impossible with XDL format.

    "Included" files are not included somewhere inside the ODT file, are they? If someone saves a document with "included" files on a USB drive and opens it on another PC, he/she won't find them. Yes, I also suggest to rename this to "External references" in any case. And to add an option to attach file, if possible. It may be resolved with additional chackboxes or a drop-down list.

     
1 2 > >> (Page 1 of 2)

Anonymous
Anonymous

Add attachments
Cancel