From 787faaa0586438cadac34424c01b903c0f1357db Mon Sep 17 00:00:00 2001 From: salvador Date: Sat, 23 Nov 2024 15:33:50 -0300 Subject: [PATCH] keep working later - term3 of second derivative is wrong --- doc/page/usage/excessmodels/uniquac.md | 32 ++++++-------------------- src/models/excess_gibbs/uniquac.f90 | 16 +++++++------ 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/doc/page/usage/excessmodels/uniquac.md b/doc/page/usage/excessmodels/uniquac.md index 08c66c57..6817cb05 100644 --- a/doc/page/usage/excessmodels/uniquac.md +++ b/doc/page/usage/excessmodels/uniquac.md @@ -144,48 +144,30 @@ $$ \(\qquad G^E\): -$$ -\frac{\partial \frac{G^E}{RT}}{\partial n_i} = \ln \left(\frac{\phi_i}{x_i} -\right) + \sum_k n_k \left(\frac{\frac{d \phi_k}{dn_i}}{\phi_k} - -\frac{\frac{dx_k}{dn_i}}{x_k}\right) + -\frac{z}{2}{q}_{i}\ln{\left(\frac{\theta_{i}}{\phi_{i}} \right)} + \frac{z}{2} -\sum_k {n}_{k} {q}_{k} \left(\frac{\frac{d \theta_{k}}{d {n}_{i}}}{\theta_k} - -\frac{\frac{d \phi_{k}}{d {n}_{i}}}{\phi_k} \right) - {q}_{i} -\ln{\left(\sum_l \theta_{l} {\tau}_{li} \right)} - \sum_k {n}_{k} {q}_{k} -\frac{\sum_l \frac{d \theta_{l}}{d {n}_{i}} {\tau}_{lk}}{\sum_l \theta_{l} -{\tau}_{lk}} -$$ - -Nueva: $$ \frac{\partial \frac{G^E}{RT}}{\partial n_i} = \ln \left(\frac{n_T r_i}{\sum_l r_l n_l} \right) + \sum_k n_k -\left(\frac{r_k \sum_l r_l n_l - n_T r_k r_i}{(\sum_l r_l n_l)^2}\right) + -\frac{z}{2} q_i n_i \ln \left(\frac{q_i \sum_l r_l n_l}{r_i \sum_l q_l n_l} -\right) - {q}_{i} +\left(\frac{\sum_l r_l n_l - n_T r_i}{n_T \sum_l r_l n_l}\right) + +\frac{z}{2} q_i \ln \left(\frac{q_i \sum_l r_l n_l}{r_i \sum_l q_l n_l} +\right) + \frac{z}{2} \sum_k n_k q_k \left(\frac{r_i \sum_l n_l q_l - q_i +\sum_l n_l r_l}{(\sum_l n_l q_l) (\sum_l n_l r_l)} \right) - {q}_{i} \ln{\left(\sum_l \theta_{l} {\tau}_{li} \right)} - \sum_k {n}_{k} {q}_{k} \frac{\sum_l \frac{d \theta_{l}}{d {n}_{i}} {\tau}_{lk}}{\sum_l \theta_{l} {\tau}_{lk}} $$ - - Differentiating each term of the first compositional derivative respect to \(n_j\) we get: \(\frac{\partial \frac{G^E}{RT}}{\partial n_i \partial n_j} =\) $$ -\frac{\frac{d \phi_i}{d n_j}}{\phi_i} - \frac{\frac{d x_i}{d n_j}}{x_i} +\frac{\sum_l n_l r_l - n_T r_j}{n_T \sum_l n_l r_l} $$ $$ -+\frac{\frac{d \phi_j}{dn_i}}{\phi_j} - -\frac{\frac{dx_j}{dn_i}}{x_j} -+ \sum_k n_k \left(\frac{\frac{d^2\phi_k}{dn_i dn_j} \phi_k - - \frac{d\phi_k}{dn_i} \frac{d\phi_k}{dn_j}}{\phi_k^2} \right) -- \sum_k n_k \left(\frac{\frac{d^2x_k}{dn_i dn_j} x_k - - \frac{dx_k}{dn_i} \frac{dx_k}{dn_j}}{x_k^2} \right) ++ \frac{\sum_l n_l r_l - n_T r_i}{n_T \sum_l r_l n_l} ++ \sum_k n_k \left(\frac{r_i r_j}{(\sum_l n_l r_l)^2} - \frac{1}{n_T^2} \right) $$ $$ diff --git a/src/models/excess_gibbs/uniquac.f90 b/src/models/excess_gibbs/uniquac.f90 index 8fe73113..4fa8762f 100644 --- a/src/models/excess_gibbs/uniquac.f90 +++ b/src/models/excess_gibbs/uniquac.f90 @@ -361,8 +361,8 @@ subroutine excess_gibbs(self, n, T, Ge, GeT, GeT2, Gen, GeTn, Gen2) ! Combinatorial term Gen_comb(i) = (& log(n_tot * self%rs(i) / sum_nr) & - + sum(n * (self%rs * sum_nr - n_tot * self%rs(i)* self%rs) / sum_nr**2) & - + self%z / 2.0_pr * self%qs(i) * n(i) * log(self%qs(i) * sum_nr / self%rs(i) / sum_nq) & + + sum(n * (sum_nr - n_tot * self%rs(i)) / n_tot / sum_nr) & + + self%z / 2.0_pr * self%qs(i) * log(self%qs(i) * sum_nr / self%rs(i) / sum_nq) & + self%z / 2.0_pr * sum(n * self%qs * (self%rs(i) * sum_nq - self%qs(i) * sum_nr) / sum_nq / sum_nr) & ) @@ -379,15 +379,17 @@ subroutine excess_gibbs(self, n, T, Ge, GeT, GeT2, Gen, GeTn, Gen2) ! dn2 if (dn2) then do concurrent(i=1:nc, j=1:nc) - trm1 = dphik_dn(i,j) / phik(i) - dxk_dni(i,j) / xk(i) + trm1 = (sum_nr - n_tot * self%rs(j)) / n_tot / sum_nr trm2 = (& - dphik_dn(j,i) / phik(j) - dxk_dni(j,i) / xk(j) & - + sum(n * (d2phik_dnidnj(:,i,j) * phik - dphik_dn(:,i) * dphik_dn(:,j)) / phik**2) & - - sum(n * (d2xk_dnidnj(:,i,j) * xk - dxk_dni(:,i) * dxk_dni(:,j)) / xk**2) & + (sum_nr - n_tot * self%rs(i)) / n_tot / sum_nr & + + sum(n * (self%rs(i) * self%rs(j) / sum_nr**2 - 1.0_pr / n_tot**2)) & ) - trm3 = self%z / 2 * self%qs(i) * (dthetak_dni(i,j) / thetak(i) - dphik_dn(i,j) / phik(i)) + trm3 = (& + self%z / 2 * self%qs(i) * (self%rs(i) * self%rs(j) * sum_nq - & + self%rs(i) * self%qs(j) * sum_nr) / sum_nq / sum_nr & + ) trm4 = (& self%z / 2 * self%qs(j) * (dthetak_dni(j,i) / thetak(j) - dphik_dn(j,i) / phik(j)) &