I have to find out the maximum time the cooling water can be turned off before being reinstated to avoid the reactor exploding (happens at T = 500 K or P = 45 atm). I want to use the backbone of the code I used for the previous part of my work and have a function keep on picking temperatures to turn on the cooling water above 455 K. The objective for me is to find out how late I can turn the cooling water on and the reactor not explode. Does anyone know what function or code I could use to have UA turn from 0 (NO COOLING WATER) to 2.77E6 (COOLING WATER ON) running the code again for each different temperature the water is turned on? (represents cooling water in the dT derivative)
I think a loop of some sort would help me run this code over and over again with the UA part of the dT/dt derivative changing at different temperatures. However, i'm very unfamiliar with loops and I would appreciate any help.If you need me to provide the code I've been using for the ode, the derivatives, variables, constants etc. let me know. I've posted below the code I used to make an event for previous work on the same problem where the cooling water turns on at 455K.
Any help would be greatly appreciated, thanks.
initial_conditions = [4.3 5.1 3 0 4.4 422];
options = odeset('Events',@myEventsFcn);
[t1,y1,te,ye,ie] = ode15s(@(t,y)fun(t,y(1),y(2),y(3),y(4),y(5),y(6),iflag), tspan, initial_conditions,options);
[t2,y2] = ode15s(@(t,y)fun(t,y(1),y(2),y(3),y(4),y(5),y(6),iflag), [te tspan(end)], ye);
function [value,isterminal,direction] = myEventsFcn(t,y)