From 4253972404166ba65a988e55ca1092afe756a6b5 Mon Sep 17 00:00:00 2001 From: Philipp Rehner Date: Mon, 26 Dec 2022 15:55:35 +0100 Subject: [PATCH 1/4] Theory guide: properties --- docs/theory/eos/properties.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/theory/eos/properties.md b/docs/theory/eos/properties.md index 29f0332d2..11c032cf0 100644 --- a/docs/theory/eos/properties.md +++ b/docs/theory/eos/properties.md @@ -113,4 +113,4 @@ If the Helmholtz energy model includes information about the molar weigt $MW_i$ | Specific Helmholtz energy $a^{(m)}$ | $\frac{A}{m}$ | yes | | Specific internal energy $u^{(m)}$ | $\frac{U}{m}$ | yes | | Specific Gibbs energy $g^{(m)}$ | $\frac{G}{m}$ | yes | -| Speed of sound $c$ | $\sqrt{\left(\frac{\partial p}{\partial\rho^{(m)}}\right)_{S,n_i}}$ | no | \ No newline at end of file +| Speed of sound $c$ | $\sqrt{\left(\frac{\partial p}{\partial\rho^{(m)}}\right)_{S,n_i}}$ | no | From 54932c6fe6813221d9076126c2fa134a5711b7f3 Mon Sep 17 00:00:00 2001 From: Philipp Rehner Date: Tue, 27 Dec 2022 15:48:39 +0100 Subject: [PATCH 2/4] Theory guide: critical points --- docs/theory/eos/critical_points.md | 35 ++++++++++++++++++++++++++++++ docs/theory/eos/index.md | 1 + 2 files changed, 36 insertions(+) create mode 100644 docs/theory/eos/critical_points.md diff --git a/docs/theory/eos/critical_points.md b/docs/theory/eos/critical_points.md new file mode 100644 index 000000000..245c1b323 --- /dev/null +++ b/docs/theory/eos/critical_points.md @@ -0,0 +1,35 @@ +# Spinodal and critical points + +The stability of an isothermal system is determined by the inequality[1] + +$$A-A_0-\sum_i\mu_{i0}\Delta N_i>0$$ + +where $A_0$ and $\mu_{i0}$ are the Helmholtz energy and chemical potentials of the state which stability is being assessed and $A$ is the Helmholtz energy of any state that is obtained from state 0 by adding the amounts $\Delta N_i$. The Helmholtz energy can be expanded around the test point, giving + +$$\sum_{ij}\left(\frac{\partial^2 A}{\partial N_i\partial N_j}\right)\Delta N_i\Delta N_j+\sum_{ijk}\left(\frac{\partial^3 A}{\partial N_i\partial N_j\partial N_k}\right)\Delta N_i\Delta N_j\Delta N_k+\mathcal{O}\left(\Delta N^4\right)>0$$(eqn:stability) + +The inequality must be fulfilled for any $\Delta N_i$. Therefore, a necessary criterion for stability is that the quadratic form (the first term) in eq. {eq}`eqn:stability` is [positive definite](https://en.wikipedia.org/wiki/Definite_quadratic_form). The **spinodal** or limit of stability consists of the points for which the quadratic form is positive semi-definite. The stability is then determined by the higher-order terms in eq. {eq}`eqn:stability`. Mathematically there exists a $\Delta N_i$ that fulfills + +$$\sum_i\left(\frac{\partial^2 A}{\partial N_i\partial N_j}\right)\Delta N_i=0$$ + +A **critical point** is defined as a stable point on the limit of stability.[2] For that to be the case, the quadratic and cubic terms in eq. {eq}`eqn:stability` need to vanish[1] which leads to the second criticality condition + +$$\sum_{ijk}\left(\frac{\partial^3 A}{\partial N_i\partial N_j\partial N_k}\right)\Delta N_i\Delta N_j\Delta N_k=0$$ + +The criticality conditions can be reformulated by defining the matrix $M$ with[3] + +$$M_{ij}=\sqrt{x_ix_j}\left(\frac{\partial^2\beta A}{\partial N_i\partial N_j}\right)$$ + +and $u$ as the eigenvector corresponding to the smallest eigenvalue $\lambda_1$ of $M$. $M$ and in conclusion the quadratic form in eq. {eq}`eqn:stability` is positive semi-definite if and only if its smallest eigenvalue is 0. Therefore the first criticality condition simplifies to + +$$\lambda_1=0$$ + +For the second criticality condition $\Delta N_i$ a step $s$ is defined that acts on the mole numbers $N_i$ as + +$$N_i=z_i+su_i\sqrt{z_i}$$ + +Then the derivative $\left.\frac{\partial^3 A}{\partial s^3}\right|_{s=0}$ can be rewritten as + +$$\left.\frac{\partial^3 A}{\partial s^3}\right|_{s=0}=\sum_{ijk}\left(\frac{\partial^3 A}{\partial N_i\partial N_j\partial N_k}\right)u_iu_ju_k\sqrt{z_iz_jz_k}$$ + +$$C=\sum_{ij}\left(\sum_k\left(\frac{\partial^3 A}{\partial N_i\partial N_j\partial N_k}\right)\Delta N_k\right)\Delta N_i\Delta N_j$$ \ No newline at end of file diff --git a/docs/theory/eos/index.md b/docs/theory/eos/index.md index a1cddf5f3..59e58fb22 100644 --- a/docs/theory/eos/index.md +++ b/docs/theory/eos/index.md @@ -6,6 +6,7 @@ This section explains the thermodynamic principles and algorithms used for equat :maxdepth: 1 properties + critical_points ``` It is currently still under construction. You can help by [contributing](https://github.com/feos-org/feos/issues/70). \ No newline at end of file From f994b241ed0b81b02c59657a3313e78c1c73add8 Mon Sep 17 00:00:00 2001 From: Philipp Rehner Date: Mon, 2 Jan 2023 17:58:38 +0100 Subject: [PATCH 3/4] rebase --- docs/theory/eos/critical_points.md | 14 ++++++++++---- docs/theory/eos/properties.md | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/theory/eos/critical_points.md b/docs/theory/eos/critical_points.md index 245c1b323..2cc89a671 100644 --- a/docs/theory/eos/critical_points.md +++ b/docs/theory/eos/critical_points.md @@ -1,6 +1,6 @@ -# Spinodal and critical points +# Stability and critical points -The stability of an isothermal system is determined by the inequality[1] +The stability of an isothermal system is determined by the inequality ([Heidemann and Khalil 1980](https://doi.org/10.1002/aic.690260510)) $$A-A_0-\sum_i\mu_{i0}\Delta N_i>0$$ @@ -8,10 +8,16 @@ where $A_0$ and $\mu_{i0}$ are the Helmholtz energy and chemical potentials of t $$\sum_{ij}\left(\frac{\partial^2 A}{\partial N_i\partial N_j}\right)\Delta N_i\Delta N_j+\sum_{ijk}\left(\frac{\partial^3 A}{\partial N_i\partial N_j\partial N_k}\right)\Delta N_i\Delta N_j\Delta N_k+\mathcal{O}\left(\Delta N^4\right)>0$$(eqn:stability) -The inequality must be fulfilled for any $\Delta N_i$. Therefore, a necessary criterion for stability is that the quadratic form (the first term) in eq. {eq}`eqn:stability` is [positive definite](https://en.wikipedia.org/wiki/Definite_quadratic_form). The **spinodal** or limit of stability consists of the points for which the quadratic form is positive semi-definite. The stability is then determined by the higher-order terms in eq. {eq}`eqn:stability`. Mathematically there exists a $\Delta N_i$ that fulfills +The inequality must be fulfilled for any $\Delta N_i$. Therefore, a necessary criterion for stability is that the quadratic form (the first term) in eq. {eq}`eqn:stability` is [positive definite](https://en.wikipedia.org/wiki/Definite_quadratic_form). The **spinodal** or limit of stability consists of the points for which the quadratic form is positive semi-definite. The stability is then determined by the higher-order terms in eq. {eq}`eqn:stability`. Mathematically, this implies that there exists a $\Delta N_i$ that fulfills $$\sum_i\left(\frac{\partial^2 A}{\partial N_i\partial N_j}\right)\Delta N_i=0$$ +Following [Michelsen and Mollerup](), the matrix $M$ can be defined with + +$$M_{ij}=\sqrt{x_ix_j}\left(\frac{\partial^2\beta A}{\partial N_i\partial N_j}\right)$$ + +Then, the criterion for a point on the spinodal can be reformulated as either the smallest eigenvalue of $M$ or its determinant being 0. + A **critical point** is defined as a stable point on the limit of stability.[2] For that to be the case, the quadratic and cubic terms in eq. {eq}`eqn:stability` need to vanish[1] which leads to the second criticality condition $$\sum_{ijk}\left(\frac{\partial^3 A}{\partial N_i\partial N_j\partial N_k}\right)\Delta N_i\Delta N_j\Delta N_k=0$$ @@ -32,4 +38,4 @@ Then the derivative $\left.\frac{\partial^3 A}{\partial s^3}\right|_{s=0}$ can b $$\left.\frac{\partial^3 A}{\partial s^3}\right|_{s=0}=\sum_{ijk}\left(\frac{\partial^3 A}{\partial N_i\partial N_j\partial N_k}\right)u_iu_ju_k\sqrt{z_iz_jz_k}$$ -$$C=\sum_{ij}\left(\sum_k\left(\frac{\partial^3 A}{\partial N_i\partial N_j\partial N_k}\right)\Delta N_k\right)\Delta N_i\Delta N_j$$ \ No newline at end of file +$$C=\sum_{ij}\left(\sum_k\left(\frac{\partial^3 A}{\partial N_i\partial N_j\partial N_k}\right)\Delta N_k\right)\Delta N_i\Delta N_j$$ diff --git a/docs/theory/eos/properties.md b/docs/theory/eos/properties.md index 11c032cf0..29f0332d2 100644 --- a/docs/theory/eos/properties.md +++ b/docs/theory/eos/properties.md @@ -113,4 +113,4 @@ If the Helmholtz energy model includes information about the molar weigt $MW_i$ | Specific Helmholtz energy $a^{(m)}$ | $\frac{A}{m}$ | yes | | Specific internal energy $u^{(m)}$ | $\frac{U}{m}$ | yes | | Specific Gibbs energy $g^{(m)}$ | $\frac{G}{m}$ | yes | -| Speed of sound $c$ | $\sqrt{\left(\frac{\partial p}{\partial\rho^{(m)}}\right)_{S,n_i}}$ | no | +| Speed of sound $c$ | $\sqrt{\left(\frac{\partial p}{\partial\rho^{(m)}}\right)_{S,n_i}}$ | no | \ No newline at end of file From 047d3bc29b5851f19062b087b816ec14908b9c88 Mon Sep 17 00:00:00 2001 From: Philipp Rehner Date: Thu, 7 Dec 2023 17:09:44 +0100 Subject: [PATCH 4/4] rewrite and simplify --- docs/theory/eos/critical_points.md | 45 +++++++++++------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/docs/theory/eos/critical_points.md b/docs/theory/eos/critical_points.md index 2cc89a671..72cff703b 100644 --- a/docs/theory/eos/critical_points.md +++ b/docs/theory/eos/critical_points.md @@ -1,41 +1,30 @@ # Stability and critical points -The stability of an isothermal system is determined by the inequality ([Heidemann and Khalil 1980](https://doi.org/10.1002/aic.690260510)) +The implementation of critical points in $\text{FeO}_\text{s}$ follows the algorithm by [Michelsen and Mollerup](https://tie-tech.com/new-book-release/). A necessary condition for stability is the positive-definiteness of the quadratic form ([Heidemann and Khalil 1980](https://doi.org/10.1002/aic.690260510)) -$$A-A_0-\sum_i\mu_{i0}\Delta N_i>0$$ +$$\sum_{ij}\left(\frac{\partial^2 A}{\partial N_i\partial N_j}\right)_{T,V}\Delta N_i\Delta N_j$$ -where $A_0$ and $\mu_{i0}$ are the Helmholtz energy and chemical potentials of the state which stability is being assessed and $A$ is the Helmholtz energy of any state that is obtained from state 0 by adding the amounts $\Delta N_i$. The Helmholtz energy can be expanded around the test point, giving +The **spinodal** or limit of stability consists of the points for which the quadratic form is positive semi-definite. Following Michelsen and Mollerup, the matrix $M$ can be defined as -$$\sum_{ij}\left(\frac{\partial^2 A}{\partial N_i\partial N_j}\right)\Delta N_i\Delta N_j+\sum_{ijk}\left(\frac{\partial^3 A}{\partial N_i\partial N_j\partial N_k}\right)\Delta N_i\Delta N_j\Delta N_k+\mathcal{O}\left(\Delta N^4\right)>0$$(eqn:stability) +$$M_{ij}=\sqrt{z_iz_j}\left(\frac{\partial^2\beta A}{\partial N_i\partial N_j}\right)$$ -The inequality must be fulfilled for any $\Delta N_i$. Therefore, a necessary criterion for stability is that the quadratic form (the first term) in eq. {eq}`eqn:stability` is [positive definite](https://en.wikipedia.org/wiki/Definite_quadratic_form). The **spinodal** or limit of stability consists of the points for which the quadratic form is positive semi-definite. The stability is then determined by the higher-order terms in eq. {eq}`eqn:stability`. Mathematically, this implies that there exists a $\Delta N_i$ that fulfills +with the molar compositon $z_i$. Further, the variable $s$ is introduced that acts on the mole numbers $N_i$ via -$$\sum_i\left(\frac{\partial^2 A}{\partial N_i\partial N_j}\right)\Delta N_i=0$$ - -Following [Michelsen and Mollerup](), the matrix $M$ can be defined with - -$$M_{ij}=\sqrt{x_ix_j}\left(\frac{\partial^2\beta A}{\partial N_i\partial N_j}\right)$$ - -Then, the criterion for a point on the spinodal can be reformulated as either the smallest eigenvalue of $M$ or its determinant being 0. - -A **critical point** is defined as a stable point on the limit of stability.[2] For that to be the case, the quadratic and cubic terms in eq. {eq}`eqn:stability` need to vanish[1] which leads to the second criticality condition - -$$\sum_{ijk}\left(\frac{\partial^3 A}{\partial N_i\partial N_j\partial N_k}\right)\Delta N_i\Delta N_j\Delta N_k=0$$ - -The criticality conditions can be reformulated by defining the matrix $M$ with[3] - -$$M_{ij}=\sqrt{x_ix_j}\left(\frac{\partial^2\beta A}{\partial N_i\partial N_j}\right)$$ - -and $u$ as the eigenvector corresponding to the smallest eigenvalue $\lambda_1$ of $M$. $M$ and in conclusion the quadratic form in eq. {eq}`eqn:stability` is positive semi-definite if and only if its smallest eigenvalue is 0. Therefore the first criticality condition simplifies to +$$N_i=z_i+su_i\sqrt{z_i}$$ -$$\lambda_1=0$$ +with $u_i$ the elements of the eigenvector of $M$ corresponding to the smallest eigenvector $\lambda_1$. Then, the limit of stability can be expressed as -For the second criticality condition $\Delta N_i$ a step $s$ is defined that acts on the mole numbers $N_i$ as +$$c_1=\left.\frac{\partial^2\beta A}{\partial s^2}\right|_{s=0}=\sum_{ij}u_iu_jM_{ij}=\lambda_1=0$$ -$$N_i=z_i+su_i\sqrt{z_i}$$ +A **critical point** is defined as a stable point on the limit of stability. This leads to the second criticality condition -Then the derivative $\left.\frac{\partial^3 A}{\partial s^3}\right|_{s=0}$ can be rewritten as +$$c_2=\left.\frac{\partial^3\beta A}{\partial s^3}\right|_{s=0}=0$$ -$$\left.\frac{\partial^3 A}{\partial s^3}\right|_{s=0}=\sum_{ijk}\left(\frac{\partial^3 A}{\partial N_i\partial N_j\partial N_k}\right)u_iu_ju_k\sqrt{z_iz_jz_k}$$ +The derivatives of the Helmholtz energy can be calculated efficiently in a single evaluation using [generalized hyper-dual numbers](https://doi.org/10.3389/fceng.2021.758090). The following methods of `State` are available to determine spinodal or critical points for different specifications: -$$C=\sum_{ij}\left(\sum_k\left(\frac{\partial^3 A}{\partial N_i\partial N_j\partial N_k}\right)\Delta N_k\right)\Delta N_i\Delta N_j$$ +||specified|unkonwns|equations| +|-|-|-|-| +|`spinodal`|$T,N_i$|$\rho$|$c_1(T,\rho,N_i)=0$| +|`critical_point`|$N_i$|$T,\rho$|$c_1(T,\rho,N_i)=0$
$c_2(T,\rho,N_i)=0$| +|`critical_point_binary_t`|$T$|$\rho_1,\rho_2$|$c_1(T,\rho_1,\rho_2)=0$
$c_2(T,\rho_1,\rho_2)=0$| +|`critical_point_binary_p`|$p$|$T,\rho_1,\rho_2$|$c_1(T,\rho_1,\rho_2)=0$
$c_2(T,\rho_1,\rho_2)=0$
$p(T,\rho_1,\rho_2)=p$|