Skip to content

ContinuousClock is not suitable for testing derivatives in ModelicaTest.Tables #4325

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
henrikt-ma opened this issue Feb 16, 2024 · 3 comments
Assignees
Labels
L: ModelicaTest Issue addresses ModelicaTest, ModelicaTestConversion4 or ModelicaTestOverdetermined

Comments

@henrikt-ma
Copy link
Contributor

When testing derivatives of table outputs, the use of ContinuousClock as table input is a poor choice due to its very poor excitation in the derivatives. This is especially the case when testing second order derivatives, as the second order derivative of the source signal is zero.

In detail, my concern is that if we describe the table mapping as

y = f(u)

then the general chain rule form of the derivatives would be this:

y' = f_der(u, u') = f'(u) * u'
y'' = f_der2(u, u', u'') = f''(u) * u'^2 + f'(u) * u''

If there would be an error in the f'(u) factor of the f_der2 implementation, it would go unnoticed because of the multiplication with u'' which is zero in this case.

With more knowledge about f_der2 is implemented, one could argue that the f'(u) part is probably correct, but it seems unnecessary to have test models relying on such inside information.

@henrikt-ma henrikt-ma added the L: Blocks Issue addresses Modelica.Blocks label Feb 16, 2024
@beutlich beutlich added L: ModelicaTest Issue addresses ModelicaTest, ModelicaTestConversion4 or ModelicaTestOverdetermined and removed L: Blocks Issue addresses Modelica.Blocks labels Feb 18, 2024
@beutlich
Copy link
Member

I am not sure what should be done here.

@beutlich beutlich removed their assignment Feb 18, 2024
@henrikt-ma
Copy link
Contributor Author

I'd suggest changing the source block to something like Cosine or with suitable choice of offset, amplitude, and phase. This would give variation in both the input itself and its first and second derivatives. Of course, this would require that reference results are re-generated.

@HansOlsson
Copy link
Contributor

I'd suggest changing the source block to something like Cosine or with suitable choice of offset, amplitude, and phase. This would give variation in both the input itself and its first and second derivatives. Of course, this would require that reference results are re-generated.

I think that Sine-block be more similar to the current test; it starts almost as a time - but then it becomes non-linear.
However, both of them require special care for the amplitude and offset to ensure that the entire table is tested.

Having a Sine-block plus Clock might be simpler to ensure that there's a 2nd derivative and it increases without bound.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
L: ModelicaTest Issue addresses ModelicaTest, ModelicaTestConversion4 or ModelicaTestOverdetermined
Projects
None yet
Development

No branches or pull requests

3 participants