Hi,
you’re on the right track!
First of all, yes, INIT_C
is just a vector that is applied to all points in space at t = 0. You can set INIT_STATE
for each unit separately (see here). However, currently it is not possible to save the state of each unit individually after the simulation (see here) so that’s probably not very practical for you. It should be an easy fix in C++, though, if you want to contribute to the project!
Hence, your approach to use the final state and its derivative of the entire system is preferred (and it’s also much simpler). Generally I don’t see where things went wrong. Probably it’s just a dictionary indexing error. As you said, first you set
model.root.input['return'].WRITE_SOLUTION_LAST = True
Then, after the every cycle, you save the state
state_y = model.root.output.last_state_y
state_ydot = model.root.output.last_state_ydot
and for the next cycle, you set:
model.root.input.model.INIT_STATE_Y = state_y
model.root.input.model.INIT_STATE_YDOT = state_ydot
Hope this helps. If not, feel free to upload the script or the h5
file and we can have a look.
Best
Jo
Edit: Clarified the bit about the INIT_STATE
of unit operations
Edit2: This post contains some mistake. Please see below for why. In summary, use the following (lower case letters):
model.root.input.model.init_state_y = state_y
model.root.input.model.init_state_ydot = state_ydot