Simple calculations in numeric input fields

First, I tried it this way, and the problem that I found is that when a user edits an existing load of 20 MPa and wants to multiply the load with a factor of 1.2, this is not possible by simply adding “* 1.2” to the value of the numeric field since 20 MPa is written there. And 20 MPa * 1.2 is not working, and a warning is displayed. So first, the unit must be deleted/replaced by the multiplication and the factor to get the equation 20 *1.2. Maybe it is hard to explain but trying it out really felt strange.

And equation evaluator covers all operators and basic math functions: GitHub - ncalc/ncalc: Mathematical Expressions Evaluator for .NET

I have added test support for simple calculations without units. To evaluate an expression, the first non-space entry in the data field must be an equal sign =. Then values, operators (+,-,…) and functions (sin(), abs(), …) can be added. Something like = 2 * sin(45/180*Pi).

I will update the current 1.3.5 release version shortly and then this functionality could be tested but only on fields where the pressure units are used.

2 Likes

I have tested this feature with today’s (12.10.2022) unstable PPM version 1.3.5. On my computer:

  1. Calculations in pressure field work only if = sign is not used. Namely, 100*2 works properly, =100*2 gives parser error.

  2. Using sin, cos and other trigonometric functions leads to warning “Use Sin (Cos) functions instead”. Using (a bit uncommon) Sin or Cos functions works properly.

Is it a bug or expected behavior?

Please update the code. The final commit is called: Modified the expression evaluator for pressure converter. You can check it using VStudio->Git->View Branch History.

1 Like

GPa units are said not to be supported and a warning emerges containing GPa as a supported pressure abbreviation.

It works with Gpa. I would not give much importance but it’s a very common unit.

As there is no ambiguity maybe could be interesting to add both options (GPa , Gpa).

(Not GPA: Gallons Per Acre)

This is strange. I use GPa all the time to demonstrate the unit conversion capabilities (v.1.3.5). For me, all three abbreviations: Gpa, GPa and GPA result in 1000 MPa.

I have my model originally set up in m Kg s in case this makes any difference.


I tried it now with new material and a unit system using m Kg s, which also works for me. Can you share the model that is causing the problems?