Skip to content
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

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

Open
soofstad opened this issue Oct 21, 2024 · 4 comments

Comments

@soofstad
Copy link

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
Copy link
Collaborator

@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
Copy link
Author

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

@asmfstatoil
Copy link
Collaborator

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.

@EvenSol
Copy link
Collaborator

EvenSol commented Jan 2, 2025

@asmfstatoil @Sviatose @AndreasHNyhus

This issue has been fixed in #1227 and fix is available in release 3.0.12+.

The problem was that a process thread is not stoped by calling join(time). Program continued to run in background.

In NeqSim versjon 3.0.12+ a process should be stopped using:

processThread.join(time_in_milliseconds);
if (processThread.isAlive()) {
processThread.interrupt();
processThread.join();
}

This will make sure the process will stop running, and should be used for all models running as Threads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants