I am working on a simulation tool for a certain heat exchange system. I first design the system using a certain routine, and then assess it's off-design performance. For the off-design performance I use a single gekko model instance that I want to run at different off-design operating points. To set the the initial values in the off-design model close to a reasonable value for the off-design simulations, I run the off-design model at the design point. After this, I run the off-design points. For some off-design points, the simulation converges, but for others it doesn't. Th
ough, most of the unconverged off-design points do converge when I run the simulation without first running the design point in the off-design model.
Is there some way I can hard reset the gekko model to a state before the first solve? In that way I can control when initial guesses from the design simulation are used. I've tried numerous things, but none seem to work. Unfortunately I can't post the exact script I'm using since it is too large. I've tried the following to reset the model though:
- Setting any combination of the following solver options: COLDSTART, CSV_READ, CSV_WRITE, AUTO_COLD, BAD_CYCLES, DBS_READ, DBS_WRITE, SPECS
- Manually resetting the variables values using:
# Save initial variable values before initial solve:
if init_variable_vals = None:
init_variable_vals = {deepcopy(vi.name): deepcopy(float(str(vi.value)))
for vi in m._variables}
... # Calling solve, handling exception
for vi in m._variables:
vi.value = init_variable_vals[vi.name]
... # Setting off-design point and attempting solve
I also tried this in combination with setting vi.value.change to 'True', 'False', and its value before the first solve (not sure why this changes between solves).
- Replacing the entire model object:
# Save model object before solving it for the first time.
init_m = deepcopy(m)
... # Calling solve, handling exception
m = init_m
... # Setting off-design point and attempting solve
None of these seem to work well. Is there some way of forcing the variables to go back to their initial state before a previous solve?