SLACKHA / pyJac

Creates C and CUDA analytical Jacobians for chemical kinetics ODE systems
http://slackha.github.io/pyJac/
MIT License
52 stars 23 forks source link

pyJac has high accracy, why? #48

Open banyangtju opened 7 months ago

banyangtju commented 7 months ago

It can be found that pyJac has high accuracy compared with Standard in OpenFOAM. But why? Is the accumulated roundoff error ?

kahilah commented 7 months ago

Hi, accuracy has many levels. If you refer to the elementwise accuracy of the Jacobian matrix, pyjac provides an analytical expression for each element so it results in high accuracy. In the past openfoam did not use detailed analytical solution in each element which caused some deviation. In the latest OF-Foundation version, this has been revised though.

If you refer to some other aspect of accuracy, like overall solution of kinetics, then it's not only pyjac which plays a role but how you compute your RHS of the equations and which ODE integrator you use for the solution.

banyangtju commented 7 months ago

Thanks for your explaination. I refer to the elementwise accuracy of the Jacobian matrix. It is well konwn that pyJac can provide accurate expressions of omega and Jacobian for a given mechanism. However, in OpenFOAM after v6, the fully analytic Jacobian is also provided. And there is a significant gap between OF6+Standard and CHEMKIN, while a small gap between OF6+pyJac and CHEMKIN is found although using the same ODE solver and tolerances.

Is the high accuracy of pyJac can be attributed to the accurate expressions leading to low roundoff error?

kyleniemeyer commented 7 months ago

I can't really comment on why the built-in chemistry model in OF6 differ from Chemkin/pyJac - I haven't seen any sort of verification of that.

I would expect pyJac and Chemkin to agree closely, with some small numerical differences due to slight differences in the implementations - though the commercial version of Chemkin is closed source and therefore cannot really be checked. I would not treat Chemkin as the definitive version :)