-
Notifications
You must be signed in to change notification settings - Fork 52
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
Ask for help with sCPA calculating the molar volume of water #265
Comments
hello, at first glance, your delta is ok: function delta_scpa(v,T)
R = 8.314
Tc = 647.29 #K
omega = 0.345 #ω
a0 = 0.12277 #Pa*m6/mol2
b = 1e-5 * 1.4515 #m3/mol
c1 = 0.67359
bm_liq = b
am_liq = a0*(1+c1*(1-sqrt(T/Tc)))^2
c1 = 0.67359 # no units
epsilon = 16655 #Pa*m3/mol
beta = 1e-3 * 69.2;
RDF = v / (v - 0.475 * bm_liq)
delta = RDF * (exp(epsilon / R / T) - 1) * bm_liq * beta
return delta
end in the julia REPL:
So the problem is upstream. May i suggest using an exact solver for single components? for an associating model with just one association pair, the exact solution for the two sites that interact is the following: function X_assoc_scpa(V,T)
rho = 1/V
#for water, the association scheme has two acceptor sites and two donor sites
na = 2
nb = 2
#for water, the molar fraction of the donor site and the molar fraction of the acceptor site are the same
zi = 1.0
zj = 1.0
delta = delta_scpa(V,T)
kia = na*zi*rho*delta
kjb = nb*zj*rho*delta
#solving a quadratic eq a*xx + b*x + c = 0
a = kia
b = 1 - kia + kjb
c = -1
denom = b + sqrt(b*b - 4*a*c)
xia = -2*c/denom #equivalent to (-b + denom)/2a
xk_ia = kia*xia
xjb = (1- xk_ia)/(1 - xk_ia*xk_ia)
#in this case, because na == nb, the nonbonding fractions have the same value. this is not always true.
return xia,xjb
end what is |
Thanks for the reply, for a single component, this x(1) I have always treated as 1, I checked this issue and found that when the correct v and xA1 values are entered, Oddly enough, my program was able to get the correct results (I think the error is within the acceptable range) for Triethylene glycol (TEG), which is also a 4C-scheme.
In the TEG-CH4 system (298.15 K, 1e5 Pa, [0.5, 0.5]):
and the calculation method you proposed for a single component looks cool (I don't fully understand it yet), but my main purpose is not to calculate a single component, to be precise, my code mainly wants to implement the flash calculation of the H2O-TEG-CH4 system, and the calculation implemented in the code is as follows: The equation of state of the system is as follows: site monomer fraction: Associative Strength: Enter my code to do the flash calculation:
In my code I get the following result:
The v and x,y calculated in ASPEN are as follows:
This seems to be only a partial error, but this error is much larger than when there is no water component, and it is fatal, and when I want to increase the molar fraction z of water, the program will error, indicating that the solved nonlinear equations (4eq of XAi, 1eq of CPA) have gone wrong, However, I could never find the cause of the error, leading me to think for a moment that there was an error in each of the water parameters (a, b, epsilon, beta), but there wasn't, and here is a look at all of the parameters in my H2O-TEG-CH4 calculations above:
Thanks again for taking time out of your busy schedule to answer my questions. |
This comment was marked as outdated.
This comment was marked as outdated.
hello, at a quick glance and for earlier comments, you are solving association and volume simultaneously, right? as far as i know, association problems are really stiff, so if you don't have good initial points, the problem quickly converges to wrong values. for CPA in particular, i recommend a nested iterative procedure for the solution of the volume at a set pressure:
for the association solver, i reccomend a successive substitution approach, you start with non bonded fractions equal to 1 and solve iteratively using the relations for monomer fraction (with a damping factor of 0.5, that is for the volume, the problem form of p-p0 is also not ideal, as it can venture into the metastable phase of the p-v diagram. in Clapeyron we use the
On Clapeyron, due to how we solve volumes, we start (in CPA) with v0 = 1.25*b, on the gas phase, the SRK initial point seems fine. alternatively, if you dont want to solve the roots of an SRK model, you could use a virial approximation, and the second virial coefficient of a cubic equation of state is just |
The equation you mentioned in your last reply for volume calculations
In my code, the gas phase is calculated entirely by the SRK equation, and since I don't think there is any associative in the gas phase, the CPA equation is simplified to the SRK equation. Thanks again for providing guidance on the issues I raised! |
Some comments:
|
I have no more questions and request to close this issues. Thank you so much for your patience and help! Your guidance was invaluable in resolving my issue. I really appreciate the time and effort you took to answer my questions. Thanks again! |
I plan to realize the calculation of TP flash by sCPA state equation through matlab programming. However, I’ve been unable to obtain accurate results for the water component. Specifically, the molar volume obtained from Newton’s iteration for the state equation is inaccurate (no solution within the given interval). I’ve tried other compounds like triethylene glycol (associating compounds) and methane (non-associating compounds), both of which yield correct results. Therefore, I believe there are no issues with subsequent calculations involving fugacity coefficients and solving the nonlinear equation system.
Below is the part of my MATLAB program where I solve the water state equation (eq1 and eq2):
The water properties in my code are as follows:
At 298.15 K and 1e5 Pa:
Using the Broyden method to solve eq1 and eq2, I got the following results:
Here are the correct results using Clapeyron's calculations:
v = 1.792601107455581e-5
This problem has bothered me for many days, forgive me for not reading the Clapeyron source code completely, my thermodynamics and programming foundation are not good, but I still hope that someone can help me solve this problem, if you are willing to take a short time for me, I would be very grateful.
The text was updated successfully, but these errors were encountered: