Hello and thanks for the great work on this software. I'm quite new to both programming and numerical solving, so I hope this question makes the slightest bit of sense.
I am currently implementing some functions for modeling the pressure change inside a fuel tank, which is currently only dependent on the fuel mass rate from the network and the current heat transfer rate (dependent on flight conditions). It does not return anything back to the network. It calculates the the pressures for the time steps in the segment according to "P = P[0] + np.dot(I, dPdt)", where "dPdt" is a function of the fuel flow vector and heat rate as mentioned.
Now I want to implement some kind of pressure control system, where if the calculated pressure inside the tank at a certain time step exceeds a "P_max", threshold an extra mass flow vector becomes non-zero to lower the pressure (it's venting boil-off gas from a cryo liquid basically). The pressure calculations are now returning an additional mass rate back to the network.
My concern is that if I feed the solver an unknown, mass flow gas, and a residual that is the "over-pressure" for the time steps in the vector that have p>p_max, then the solver might "see into the future" and correct the over-pressures in a way that is unrealistic.
Has anyone done something similar in SUAVE or for this type of numerical scheme? For time-marching this would be quite easy but I'm a bit lost here, so any suggestions or solutions to similar problems would be very helpful.
In my head there would be some kind of way to make a residual which only acts on the first over-pressure, introduces a correction by making the mass flow gas in this time step non-zero, and iterates this mass flow so the pressure becomes exactly P=Pmax. After this it converges the subsequent time step's pressures, and looks for other over-pressures.
Thanks,
Christian