Opened 15 years ago

Last modified 14 years ago

#1176 closed defect (fixed)

Bug in functionDAE_res() -> breaks program-state

Reported by: asodja Owned by: asodja
Priority: normal Milestone:
Component: Simulation Code Generation Version: 1.5.0RC2
Keywords: Cc: asodja,

Description

In functionDAE_res() does not restore the old value of localData->algebraics on exit, as it does with localData->timeValue, localData->states and localData->statesDerivatives.

DASSL still suprisingly works (correctly?), but Sundials' IDA fails with wierd error.

A work-around is to implement its own functionDAE_res() which calls functionODE() and makes sure, nothing get messed.

Change History (3)

comment:1 by Martin Sjölund, 14 years ago

Fixed in r5946

comment:2 by Willi Braun, 14 years ago

This not a Bug. The algebraic variables aren't varianing by dassl, so we don't need to save them.

comment:3 by asodja, 14 years ago

Technically, this is not yet a bug, but it is certainly a bad programming practice.

A call to functionDAE_res() modifies values of algebraics vars and leaves them in undefined state.
Currently, this doesn't matter, because functionODE() is called each time after DASL returns.
But if some future use of this function (in let's say different solver) would decide not to accept values and haven't saved previous values of public_data->algebraics (and it is not clear it have to), a behaviour might be quite undefined.

It may not be the best solution, to save and then restore public_data->algebraics inside functionDAE_res(), but the current implementation must be fixed somehow -- as I said, it is a bad programming practice.

Note: See TracTickets for help on using tickets.