Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SAFT gamma mie] How to calculate solubility of CO2 in aqueous amine solutions #12

Open
YouHyin opened this issue Mar 8, 2024 · 5 comments

Comments

@YouHyin
Copy link

YouHyin commented Mar 8, 2024

Hello, I have a question about calculating solubility of CO2 in aqueous amine solutions.
I want to draw these graphs using sgtpy.
images_large_je0c00746_0006

Partial pressure of CO2 in (a) piperazine aqueous solutions, (b) 30 wt % aqueous monoethanolamine solution, (c) 20 wt % diethanolamine solution and (d) 35 wt % diethanolamine solution, expressed as the partial vapor pressure of CO2 as a function of the CO2 loading αCO2, defined as the ratio of the number of moles of CO2 to the number of moles of amine. The curves represent calculations using SAFT-γ Mie while the symbols represent experimental data

For this, I have to consider the complex system of ternary mixture involving amine, water, and carbon dioxide, but I don't know how to do it.

I think I need to consider vle for the mixture of amine, water, and carbon dioxide. Is this possible with sgtpy??
As an example, only vle of binary fluid mixture is shown, so I wonder if this is possible.
I would really appreciate it if you could answer me.

@gustavochm
Copy link
Owner

Hi YouHyin,

Thank you for your question. I coded both SAFT-VR-Mie and SAFT-gamma-Mie to be used with "n" numbers of components. I know most examples are written for binary mixtures, but all the functions would work for mixtures with more components.

See for example this ternary LLE or this VLLE examples.

If you are interested in VLE, the only difference would be that you use either the flash or bubble/dew points routines.

I hope that helps.

Regards,
Gustavo

@YouHyin
Copy link
Author

YouHyin commented Mar 12, 2024

Thank you for your advice.
sgtpy/examples/GC SAFT-Gamma-Mie Examples/6. VLE for mixtures.ipynb at master · gustavochm/sgtpy (github.com)

However, I have a question because this modeling result seems to be different from the actual paper figure.
image

  1. Flash calculation for fluid mixures is shown, is it possible to calculate VLE for CO2 (gas state) and MEA, water state??

@gustavochm
Copy link
Owner

Hi YouHyin,

Let me know if I got this right. Let's take plot (d) as an example.
This is a mixture of diethanolamine, CO2, and water.

  • The weight fraction of diethanolamine is 35%.
  • The CO2 loading can go from 0 to 1.

First we define the mixture:

co2 = component(GC={'CO2': 1})

water = component(GC={'H2O': 1})

diethanolamine = component(GC={'NH': 1, 'CH2': 2, 'CH2OH': 2})

mixture = diethanolamine + co2 + water
mixture.saftgammamie()

eos = saftgammamie(mixture)

Then we obtain the mole fraction that you are interested on,

n = 100
alpha = np.linspace(1e-5, 1, n)

mass_base = 1. # g 

mass_amine = 0.35 #g  
moles_amine = mass_amine / eos.Mw[0] # moles

moles_co2 = alpha * moles_amine # moles
mass_co2 = moles_co2 * eos.Mw[1] # g

mass_water = mass_base - mass_amine - mass_co2
moles_water = mass_water / eos.Mw[2]

# moles for alpha from 0 to 1
moles_array = np.stack([moles_amine * np.ones(n), moles_co2, moles_water])

# mole fractions for alpha from 0 to 1
x = moles_array / np.sum(moles_array, axis=0)

Now, if I understood correctly, you want to compute the partial pressure of CO2 of each one of these possible liquid solutions. My understanding is that you are interested on the bubble point? In that case, the solution would be as follows:

T348 = 348.15 # K

y348 = np.zeros_like(x)
p348 = np.zeros(n)
vl348 =  np.zeros(n)
vv348 = np.zeros(n)

i = 0
y0 = np.array([0, 1, 0])
p0 = 1e5
sol = bubblePy(y0, p0, x[:, i], T348, eos, full_output=True)
y348[:, i] = sol.Y
p348[i] = sol.P
vl348[i] = sol.v1
vv348[i] = sol.v2
# print(i, y348[:, i], p348[i], vl348[i], vv348[i])

for i in range(1, n):
    y0 = y348[:, i-1]
    p0 =  p348[i-1]
    v0 = [vl348[i-1], vv348[i-1]]
    sol = bubblePy(y0, p0, x[:, i], T348, eos, full_output=True, v0=v0, good_initial=True)
    y348[:, i] = sol.Y
    p348[i] = sol.P
    vl348[i] = sol.v1
    vv348[i] = sol.v2
    # print(i, y348[:, i], p348[i], vl348[i], vv348[I])

However, after plotting the results, the partial pressure I obtained is several orders of magnitude different from the ones you show.

amine-co2

@YouHyin
Copy link
Author

YouHyin commented Mar 18, 2024

image
image

Hi I followed the code you gave me and it seems to have worked out well.
I was having a lot of trouble reproducing the figures in this paper, so thank you so much for your detailed instructions.

But here I get this error when running at T=298K in (d) 35 wt% diethanolamine solution.
C:\Users\user\anaconda3\lib\site-packages\sgtpy\gammamie_mixtures\ares.py:498: RuntimeWarning: invalid value encountered in log
aux1 = np.log(Xass) - Xass/2 + 1/2
C:\Users\user\anaconda3\lib\site-packages\sgtpy\gammamie_mixtures\ares.py:707: RuntimeWarning: invalid value encountered in log
aux1 = np.log(Xass) - Xass/2 + 1/2
C:\Users\user\anaconda3\lib\site-packages\sgtpy\gammamie_mixtures\saftgammamie_mixture.py:1238: RuntimeWarning: invalid value encountered in log
lnphi = mures - np.log(Z)

Do you have any idea why I'm getting this error?
Thanks again for letting me know.

@gustavochm
Copy link
Owner

Hi YouHyin,

Glad the code above was useful. The problem you are getting is telling you the association solver is failing, mainly due to poor initial guesses. The problem comes from when you have very low values of the loading; the next iteration uses the previous solution as the initial guess, but as soon as you increase the amount of CO2 in the liquid mixture, the bubble pressure drastically increases.

You have two options here,

  1. Change the range of values of alpha:
n = 100
alpha = np.linspace(1e-3, 1, n)
  1. Increase the number of data points
n = 2000
alpha = np.linspace(1e-5, 1, n)

Gustavo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants