|
27 | 27 | compositional, thermodynamic and thermoelastic properties. |
28 | 28 | * How to use the stoichiometric and reaction affinity methods to solve |
29 | 29 | simple thermodynamic equilibrium problems. |
| 30 | +
|
| 31 | +Please see example_equilibrate.py for more advanced (and user-friendly) |
| 32 | +examples of equilibration of a composite material. |
30 | 33 | """ |
31 | 34 |
|
32 | 35 | import numpy as np |
|
35 | 38 |
|
36 | 39 |
|
37 | 40 | import burnman |
| 41 | +from burnman import equilibrate |
38 | 42 | from burnman import minerals |
39 | 43 |
|
40 | 44 |
|
@@ -213,19 +217,20 @@ def delta_affinity_two_binaries_P_x_Fe_wad(x, T): |
213 | 217 |
|
214 | 218 | # Now solve for the equilibrium state at a range of pressures |
215 | 219 | # less than the univariant pressure |
216 | | - def delta_affinity_two_binaries_x_Fe_ol_wad(x, P, T): |
217 | | - x_fe_ol, x_fe_wad = x |
218 | | - rock.set_state(P, T) |
219 | | - ol.set_composition([1.0 - x_fe_ol, x_fe_ol]) |
220 | | - wad.set_composition([1.0 - x_fe_wad, x_fe_wad]) |
221 | | - return rock.reaction_affinities |
222 | | - |
223 | 220 | pressures = np.linspace(10.0e9, fo_mwd.pressure, 21) |
224 | | - x_fe_ols = np.zeros_like(pressures) |
225 | | - x_fe_wads = np.zeros_like(pressures) |
226 | | - for i, P in enumerate(pressures[:-1]): |
227 | | - sol = fsolve(delta_affinity_two_binaries_x_Fe_ol_wad, [0.1, 0.1], args=(P, T)) |
228 | | - x_fe_ols[i], x_fe_wads[i] = sol |
| 221 | + free_compositional_vectors = [{"Mg": 1.0, "Fe": -1.0}] |
| 222 | + composition = {"Mg": 1.8, "Fe": 0.2, "Si": 1.0, "O": 4.0} |
| 223 | + equality_constraints = [["P", pressures], ["T", T], ["phase_fraction", [ol, 0.5]]] |
| 224 | + sol, prm = equilibrate( |
| 225 | + composition, rock, equality_constraints, free_compositional_vectors |
| 226 | + ) |
| 227 | + |
| 228 | + x_fe_ols = np.array( |
| 229 | + [s.assemblage.phases[0].molar_fractions[1] if s.success else 0 for s in sol] |
| 230 | + ) |
| 231 | + x_fe_wads = np.array( |
| 232 | + [s.assemblage.phases[1].molar_fractions[1] if s.success else 0 for s in sol] |
| 233 | + ) |
229 | 234 |
|
230 | 235 | # Pretty-print the results |
231 | 236 | print(f"Olivine-wadsleyite equilibria at {T} K:") |
|
0 commit comments