Simulations in jupyter notebook fail after error due to bad parameters

Hey everyone,

I have a bit of a problem I continue running into since I started working with cadet.
I am running a simulation with e.g. certain parameters for the user_solution_times and everything is working just fine. After the simulation is finished, I change the parameters. When I put in bad parameters (such as the end of the user_solution_times not being the end of the section_times) the simulation takes about 5-10 minutes before giving me this error:

CompletedProcess(args=['C:/cadet_from_source/cadet/bin/cadet-cli', 'C:\\Users\\Hannah Lanzrath\\29skmuos.h5'], returncode=3, stdout=b"[Error: idasErrorHandler::200] In function 'IDASolve' of module 'IDAS', error code 'IDA_ILL_INPUT':\r\nAt t = 56.0561, , mxstep steps taken before reaching tout.\r\n[Error: integrate::1364] IDASolve returned IDA_TOO_MUCH_WORK at t = 56.0561\r\n", stderr=b'SOLVER ERROR: Error in IDASolve: IDA_TOO_MUCH_WORK at t = 56.056056\r\n')

When I now put in again the old (previously working) parameters the simulation now also takes 5-10 minutes and gives me the same error every time I try to run it.

CompletedProcess(args=['C:/cadet_from_source/cadet/bin/cadet-cli', 'C:\\Users\\Hannah Lanzrath\\7eumr3x1.h5'], returncode=3, stdout=b"[Error: idasErrorHandler::200] In function 'IDASolve' of module 'IDAS', error code 'IDA_ILL_INPUT':\r\nAt t = 55.6557, , mxstep steps taken before reaching tout.\r\n[Error: integrate::1364] IDASolve returned IDA_TOO_MUCH_WORK at t = 55.6557\r\n", stderr=b'SOLVER ERROR: Error in IDASolve: IDA_TOO_MUCH_WORK at t = 55.655656\r\n')

It also happens when I interrupt or kill and restart the kernel while the simulation is running.

I could get it to run again sometimes with restarting the kernel, clearing output, killing the kernel several times or restarting my PC. Sometimes that also does not work anymore and the only thing that seems help then is: Restart PC, create new Notebook with new name, copy over code from old Notebook, delete old Notebook, Restart Kernel, Clear all Output, Run code.

As it is exactly the same code running that does not work in the notebook that got the error before but does work in a new one (that is not a copy of the old one), I think it must have something to do with the notebooks saving some data that doesn’t get reset when restarting and clearing the output. I tried it in several browsers, once a notebook starts to take long for the simulation and giving the error, it does it in every browser.

Do you have any idea on what is causing this and how I can prevent having to make new notebooks and copy over code that should work to get it running again? Since I am still new with cadet I cannot prevent putting in bad parameters when trying things out and it takes me around 15 mins everytime to get it running again.

Cheers,
Hannah

Can you share your notebook (just to check what is going on)?

I cannot upload a file here but will gladly provide the file who is interested in it via other sharing platforms.

@w.heymann proposed exchanging the run_simulation() I used from the utils.ipynb to

model.filename = "file.h5"
model.save()
model.run()
model.load()

When I try to recreate the problem introduced above I now get

ValueError: invalid __array_struct__

EDIT: I now realised that this error above is when I try to create the figures since the simulation gave back an empty array.

and the notebook breaks again so simply putting in the previously working parameters now also gives that same error but killing the Kernel now seems to make it work again after restarting jupyter notebook. So huge improvement!

Cheers,
Hannah