QSD-Group / QSDsan

Quantitative Sustainable Design (QSD) of sanitation and resource recovery systems.
https://qsdsan.com
Other
29 stars 11 forks source link

Problem in logic of calculating inner diameter of pipe. #118

Closed RaiSaumitra closed 8 months ago

RaiSaumitra commented 8 months ago

The select_pipe function calculates the minimum inner diameter (d) based on influent flowrate (Q) and liquid velocity (v), and then outputs the immediate larger inner diameter value from ANSI chart.

But according to Shoener et al., 2016, the liquid velocity here is the minimum permissible liquid velocity, which means it would lead to calculation of maximum inner diameter, NOT minimum inner diameter. Accordingly the 'select_pipe' function should be modified, to select the inner diameter from ANSI which is lower than the applicable maximum Inner diameter.

Steps to reproduce the behavior, e.g.:

  1. Go to 'https://github.com/QSD-Group/QSDsan/blob/main/qsdsan/utils/construction.py#L522C1-L522C1'
  2. Run the complete file 'construction.py'
  3. You can go through the following code:

Q = 10 v = 3 select_pipe(Q, v) Out[3]: (26.0, 0.25, 25.5) A = Q / v # cross-section area d = (4*A/np.pi) * 0.5 # maximum inner diameter, [ft] d = 12 # maximum inner diameter, [in] d Out[7]: 24.7215489294841364. See error

So, the output inner diameter from ANSI pipe chart is 25.5 inches which is larger than the maximum diameter, 24.72 inches.

Reference:

Shoener et al., Design of Anaerobic Membrane Bioreactors for the Valorization of Dilute Organic Carbon Waste Streams. Energy Environ. Sci. 2016, 9 (3), 1102–1112. https://doi.org/10.1039/C5EE03715H.

yalinli2 commented 8 months ago

@RaiSaumitra thanks for looking into this! I feel like what you said makes sense, I based that off Brian's Matlab code: https://github.com/QSD-Group/AnMBR/blob/main/Codes_Data/pipe.m

I think the Matlab code would give 25.5 in this case - was there a bug or did I understand the script wrong?

RaiSaumitra commented 8 months ago

Thanks for looking into this promptly @yalinli2. Actually @joyxyz1994 and I were discussing how the script should work, and we noticed that currently it is not working like it is supposed to.

Yes, If matlab gives 25.5 too then I think that code has a bug. Your interpretation of the METAB script seems to be correct since python too gives 25.5.

RaiSaumitra commented 8 months ago

Hi @yalinli2,

I have alternatively made more changes to the select_pipe function to ensure that the selected inner diameter is actually less than the diameter obtained through the ANSI dictionary. For this purpose I have changed the key of the dictionary to inner diameter. I have updated these changes to the metro branch of QSDsan. The changes are based on discussion I had with @joyxyz1994.

Let me know if they make sense to you. If not, we can discuss them in a meet.

yalinli2 commented 8 months ago

@RaiSaumitra looks good to me! I basically copied your codes into main since we can't merge it in now a7181ca. Sorry it took me so long to get to it (Happy Holidays!)

RaiSaumitra commented 8 months ago

Thanks @yalinli2! No worries about the timeline. Happy Holidays to you too :)