-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Results sensitive on inital composition and setting parameters #40
Comments
It looks like there is something wrong in the code, the temperature difference is too large, especially the equilibrium temperature is different. Perhaps there is some issue with the thermodynamic data? In the worse case, there is something wrong in ReacTorch. Which mechanism is used in the above code? |
composition = 'IC8H18:0.5,O2:12.5,N2:34.0' |
Bug dected on Solution_test----with tolerance delta=1e-4, kf (forward_rate_constants) kc ( equilibrium_constants ) kr (reverse_rate_constants) are correct. But net rates of progress & net rates of production are considered to be wrong.
|
All dection errors on net_rate progress are all with the same feature: the ratio_min would be something like -exp(+278), ratio_max are all normal, Pointing the bug in wdot function. More details need to be explored further. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Nice catch. I guess you can figure out the difference among those reactions shows wrong rates and the rest. It looks like the error happens when the reaction is irreversible. |
Testing the code_exploring further:
|
Both reversible and irreversible reactions are detected. At the first begining, only something irreversbile. as the time goes by(maybe because the molar concentration and the temperature is already different from the last time states, the miss rise up to involve in more reactions) |
Can you check what the reverse rate constants for the irreversible reaction are? For both cantera and ReacTorch |
I have check it before in the previous coding and no abnormals are found. The constants including equilibrium &reverse constants as well as forward rate constants, they are safe. I have check the reactant orders as well as the product stoi_coefficiency, they are safe as well. After some endevors been made, I figure out some bizzar things. It is really strange but I have tried many times, it did work like what I was guessing. |
Bizzar things occur. when the initial settings with the mechanism IC8H18_reduced.yaml are:
Then many negtive values of Y are detected. While for reactorch, values of Y are limited to be >=0. Relating code in solution-set_states(TPY)
Thus, huge differences are detected for the calculation of species concentration and certainly on forward rate progress. (The normalization of Y has been commented: Such differences between cantera and reactorch disappear when the code modified as:
The testing code on Solution_test:
|
For irreversible reaction, the rate constants should be zero. What's the value you observed? |
I think Cantera may also clips the concentration to be within zero and one. |
The mass fraction but not the concentration. Give a look at the code, you will find at this setting,
You will see many negtive numbers have been detected |
I guess allowing negative mass fraction has a lot of other consequences, for example, computing density |
Yes, so when I modified the code in reactorch, the mismatch of reactorch and cantera in terms of concentration and mass fraction as well as abnormal reactions all disappear. |
I only check the difference between cantera and reactorch. No special attentions on irreversible constants are paid yet. But I would try. |
I agree with you the problem is probably mainly related to the tiny negative mass fractions |
Testing code on Solution_test:
|
I would continue to commit my time figuring out the mismatch in mass density for Solution_test since they shows obvious (nonnegligible) difference for cantera and reactorch. Would this be Okay? If not, what are your suggestions. |
Sure. But I think you had better keep the normalization of the mass fraction, eventually. Although you can relax it for debugging code. |
While new issue arises:
Runing the code in exaples/constant_pressure_autoignition: bug comes again, reactorch cannot calculate but cantera succeeded. Detailed information is still exploring.
|
Abnormal things detected again, the reasons for bug are figured out. But the way of clear is still under investigation. It is because of negtive C, when exp log runs in wdot function, nan and inf occurs. But python would let it happen without warning. When it is calculated through solve_ivp, the bug shows out. |
Testing cantera clippings and normalization, results show: Testing code:
|
Personal thought about this investigation: |
Thanks a lot for looking into this. It is a very interesting analysis. I think an easy way to workaround is
Then it should be identical to Cantera. Allowing tiny negative Y and X should be alright in the code. |
See the testing code, and try to evaluate different initial mole fraction on N2, you will find various digree of mismatch on the results from cantera and reactorch. This phenomenon happends for reduced mechanism for IC8H18 as well as NC7H16.
Runing Solution_test with the same initial parameters, with tolerance delta=1e-4, No obvious difference is observed, which may means the kf (forward_rate_constants) kc (equilibrium_constants) kr (reverse_rate_constants) are correct.
The reasons of such mismatch are still unknown.
Testing Code:
The text was updated successfully, but these errors were encountered: