equinor / neqsim

NeqSim is a library for calculation of fluid behavior, phase equilibrium and process simulation
https://equinor.github.io/neqsimhome/
Apache License 2.0
65 stars 30 forks source link

bug: Bad input causing `ProcessSystem.runAsThread()` to run into an infinite loop #1142

Open soofstad opened 3 weeks ago

soofstad commented 3 weeks ago

Stacktrace from the bug causing ML/OilSep to loop indefinitely.

Just want to get this out there. @Sviatose might have some more information on the issue.

Hopefully it's possible to patch Neqsim so that is raises the Variable Molar volume is Nan-exception, instead of just logging it, and subsequently exits the loop.

07:39:42.131 [Thread-38067834] ERROR neqsim.thermo.phase.PhaseEos - PhasePrEos:molarVolume - Variable Molar volume is NaN
07:39:42.131 [Thread-38067834] ERROR neqsim.processSimulation.processSystem.ProcessSystem - neqsim.util.exception.IsNaNException: PhasePrEos:molarVolume - Variable Molar volume is NaN
java.lang.RuntimeException: neqsim.util.exception.IsNaNException: PhasePrEos:molarVolume - Variable Molar volume is NaN
    at neqsim.thermo.phase.PhaseEos.init(PhaseEos.java:112) ~[?:?]
    at neqsim.thermo.system.SystemThermo.initAnalytic(SystemThermo.java:3193) ~[?:?]
    at neqsim.thermo.system.SystemThermo.init(SystemThermo.java:3137) ~[?:?]
    at neqsim.thermodynamicOperations.flashOps.TPflash.run(TPflash.java:209) ~[?:?]
    at neqsim.thermodynamicOperations.ThermodynamicOperations.TPflash(ThermodynamicOperations.java:156) ~[?:?]
    at neqsim.processSimulation.processEquipment.util.Recycle.run(Recycle.java:326) ~[?:?]
    at neqsim.processSimulation.processSystem.ProcessSystem.run(ProcessSystem.java:446) [?:?]
    at neqsim.processSimulation.SimulationInterface.run(SimulationInterface.java:99) [?:?]
    at java.lang.Thread.run(Thread.java:840) [?:?]
Caused by: neqsim.util.exception.IsNaNException: PhasePrEos:molarVolume - Variable Molar volume is NaN
    at neqsim.thermo.phase.PhaseEos.molarVolume(PhaseEos.java:384) ~[?:?]
    at neqsim.thermo.phase.PhaseEos.init(PhaseEos.java:105) ~[?:?]
    ... 8 more
INFO:     10.8.21.208:35292 - "POST /ML/oil-separation HTTP/1.1" 504 Gateway Timeout
INFO:2024-09-23 07:39:42,550 POST /ML/oil-separation - 55676ms - 504
asmfstatoil commented 3 weeks ago

@soofstad Are you experiencing the same with the current version of neqsim? The line numbers does not match for me...

The function PhaseEos Init also appears to reraise the exception so perhaps it is already solved?

Image

soofstad commented 3 weeks ago

Should have mentioned, this was in v2.5.35. If you think the bug no longer can arise, we can close this issue 👍

asmfstatoil commented 3 weeks ago

I have looked around, but I am currently not able to reproduce.

That said, there have not been made significant changes to the exception handling parts of this code since v2.5.35, so I will not close the issue yet.