Math.Nonlinear.quadratureNewtonCotes - #4800
Conversation
|
I managed to implement the first 4 closed Newton-Cotes formulas in 1 function, just distinguished by 1 parameter. |
|
pinging potential reviewers @christiankral @casella @HansOlsson @henrikt-ma @maltelenz @MartinOtter |
|
@HansOlsson to explain the motivation to implement rather simple quadrature formulas: |
|
Looking at the code and at: https://www.researchgate.net/publication/226706221_Adaptive_Quadrature-Revisited (which should replace the ftp-link) my only reaction is that the code is stupid and stupidly obscure. Without looking further: Do you see and understand the stopping criteria for the recursion, and how it relates to tolerance? The correct answer is: There are a number of issues with that:
|
|
@HansOlsson no I don't understand the code, and I don't trust it. |
As far as I understand the code implements the algorithm from the paper, it's just that the paper is more trying to be clever than correct and robust; so the problem isn't so much the Modelica-implementation as the underlying paper (although there are at least two issues with the Modelica implementation - related to the convergence criteria). Looking more at this and the paper contents:
I have tried to patch it as follows: |
When investigating the relation between spatial flux density distribution of a rotating rotor (with permanent magnets) and the flux linkage of a coil in the stator core (to calculate the induce voltage), I have to calculate an integral over the angle spanned by the coil. Since quadratureLobatto has some problems with a moving integration interval, I implemented two less sophisticated quadrature functions: quadratureTrapezoidal (based on the trapezoidal rule) and quadratureSimpson (based on Simpson's rule).
Both are tested in the example MovingIntegral (using the utility function funB). That's also a nice example for the usage of quadrature functions. Defined comparison signals, no backwards compatibility issues.