ModelicaStandardLibrary icon indicating copy to clipboard operation
ModelicaStandardLibrary copied to clipboard

Inconsistent use of `tol` in `ModelicaTest.MultiBody.Forces.Damper`

Open qlambert-pro opened this issue 2 years ago • 4 comments

The variable used as tolerance margin to decide whether two Real values are equal is used to compare position and speed at the same time.

We could turn tol into a constant as we don't expect the infer the unit of constants based on their usage or maybe use Modelica.Constants.eps?

qlambert-pro avatar Sep 18 '23 07:09 qlambert-pro

Same issue in ModelicaTest.MultiBody.Forces.Damper2, ModelicaTest.MultiBody.Forces.Spring and ModelicaTest.MultiBody.Forces.Spring2

qlambert-pro avatar Sep 18 '23 13:09 qlambert-pro

I don't understand the point of the issue. Can you explain in more detail?

Regarding ModelicaTest.MultiBody.Forces.Spring and ModelicaTest.MultiBody.Forces.Spring2, there is a mess in using toland assert. I will prepare a fix.

tobolar avatar Jan 22 '24 10:01 tobolar

This has to do with unit checking. When unit inference is applied, the tol should get an inferred unit which is consistent with how it is used, but this gets problematic if it is used inconsistently unit-wise. What @qlambert-pro said about using a constant instead of a parameter has to do with the current idea that unit inference in Modelica should not be allowed for constants, so that a constant with empty unit will behave just as a literal number.

henrikt-ma avatar Jan 22 '24 10:01 henrikt-ma

@henrikt-ma Many thanks. I didn't fully follow the unit discussion.

Then I guess both suggestions (changing to constant and equal to Modelica.Constants.eps) are fine. (At least Dymola didn't indicated any issue.)

tobolar avatar Jan 22 '24 11:01 tobolar