0

I have a project to simulate the pressure exchange between multiple connected volumes with valves.

Example of my problem

In the picture above you can see that each tank has a Pressure, Volume, and Temperature. There are valves between each of the volumes that can be open or closed. Some of the volumes are at vacuum and so chocked and unchoked flow will be present during the analysis. Also, I have a hard constraint that I need to open and close these valves based on the Pressure of other volumes, and this analysis needs a clear output of pressures over time. These volumes are rather large, so I think I can also assume constant temperature for this problem. Speed is critical for this analysis, and I don't need anything complex. (You can assume each volume as a 1 dimensional node connected to other nodes)

Over the years I have tried to solve this problem, but my models always seem to be unstable. The reason for this is probably because I've always coded this problem from scratch. I think I need to start thinking about using an analysis library. I'd highly prefer python for this problem.

However, every fluid python library I look at confuses me with technical jargon. I'm hoping folks with more experience in this field can point me in the the right direction.

Questions:

  1. Are there Python Libraries that solve my problem? (Time simulation of 1D nodes exchanging air between each other)
  2. What are some of these python libraries?
  3. Can you point me to any examples or provide any simple examples similar to my problem?

Thank you for your help!

  • 1
    What exactly do you mean by **1 dimensional node**? Each tank has a single uniform pressure, volume and temperature? How do you model the flow in case of open valves? – Peter Meisrimel Aug 04 '20 at 17:05
  • Yes - Each tank has a single uniform pressure, volume, and temperature. As soon as you open up the valve then the 2 tanks would start to equalize with each other. I'm interested in the time to specific equalization pressures of the tanks, the flow rate between the tanks, and etc. – Fly Dangerous o7 Aug 04 '20 at 17:25
  • How have you modeled this in the past? This sounds like system of differential equations akin to chemical reactions, where one would describe the changes of pressure/temp/volume in each tank via in -and outflow over valves. (Plus some pressure/temperature loss I suppose). Solving this with `scipy.integrate.odeint` should not be difficult, however, sudden openings/closings of the valves (discontinuities) will likely cause issues here. – Peter Meisrimel Aug 04 '20 at 17:44
  • I should look into solving via differential equations. Right now I define tanks using a class in python with properties like pressure, volume, temperature, mass and etc. I also define flowpaths with properties like cd, flowpath source, flowpath destination, and etc. I connected the tanks by using flowpaths. I then use a loop to loop through all modules and flowpaths to manually calculate the flowrate between volumes and using the flowrate calculation I exchange air mass between volumes(I have a timestep parameter). This includes calculations to determine if the flow is chocked or not chocked. – Fly Dangerous o7 Aug 04 '20 at 17:55
  • The funny thing is that I do get results, but they change everytime I run the program. I'm under the impression that this is an indicator that the model is unstable. I've used this exact idea to program a similar model in C#, python, and excel vba. Each time with similar unstable results. – Fly Dangerous o7 Aug 04 '20 at 17:59
  • What do you mean with they change every time you run? Same inputs yield different outputs? I suppose the weakness of your discrete model would be that it very much depends on the order of computations? – Peter Meisrimel Aug 04 '20 at 18:06
  • Concur - Same inputs will yield different outputs after only a few iterations. It is odd to me that the order of computations changes order, but I think that would make sense. – Fly Dangerous o7 Aug 04 '20 at 18:08
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/219220/discussion-between-peter-meisrimel-and-donnie). – Peter Meisrimel Aug 04 '20 at 18:31

0 Answers0