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

Compute metastable/unstable single phase driving forces in ZPF error #151

Merged
merged 26 commits into from Apr 19, 2021

Conversation

bocklund
Copy link
Member

@bocklund bocklund commented Apr 4, 2021

Thanks to Tobias Spitaler for suggesting this and to @richardotis for brainstorming this solution concept.

This PR introduces two new functions in ZPF error, _solve_sitefracs_composition and _sample_solution_constitution. Their purpose is to facilitate computing metastable or unstable single phase driving forces when a phase has a miscibility gap. This should improve the convergence for any phase that has a stable or metastable miscibility gap.

Rationale

ESPEI currently computes the "single-phase hyperplane" at a vertex by performing an equilibrium calculate at a black point and then subtracting that from the target hyperplane energy at that composition. As illustrated in the figure Tobias constructed (below), this is problematic for phases with a miscibility gap because a "single-phase" equilibrium calculation in pycalphad will always compute the global minimum energy and give two composition sets.

driving-force-Spitaler

What ESPEI should do is what Tobias illustrates by the orange x and the green driving force line. This solution ensures that minimizing the driving force will force the Gibbs energy curve to match the energy of the black points on the multi-phase target hyperplane.

Historically, we didn't implement this because one would like to use equilibrium to minimize the internal degeres of freedom, but pycalphad always computes the global minimum energy, so it was not possible to do via equilibrium. More recently, ESPEI had introduced the idea of approximate_equilibrium, which uses starting_point to more quickly determine a minimum energy solution from a discrete point smapling grid. The approximate_equilibrium method we use still has the same problem as pycalphad's equilibrium because starting_point will still give the global minimum solution for the discrete sampling.

Solution

In an ideal world, pycalphad should be able to turn off global minimization (automatically introducing new composition sets) and enable a condition to be set for the composition of a phase, i.e. X(BCC,B). In practice, being able to turn off global minimum and provide a valid starting point for only one composition set that has a global composition condition would simulate a phase composition condition. Unfortunately, neither turning off global minimization nor phase composition conditions are currently implemented. So we need to do a workaround.

The two functions introduced here consider each single phase composition at a tie-vertex and construct a point grid that only contains points which satisfy the prescribed overall composition (and the internal phase constraints). This can be used in either approximate or exact equilibrium modes to find lowest energy starting point and then to pass that equilibrium with the constrained point grid so the global minimization step has no new composition sets to introduce (i.e. it cannot detect a miscibility gap).

For perfomance, we pre-compute the grid of points for every phase composition in the ZPF datasets and re-use them to compute the grid, starting point and equilibrium at every parameter iteration (note that this would be invalid if a parameter changes the number of moles, like varying coordination number in the MQMQA).

To summarize the impact:

  1. This method will be entirely backwards compatible for phases without a miscibility gap.
  2. For cases where a miscibility gap is present in the parameters, but a single phase is prescribed, there will be a driving force to eliminate the miscibility gap, so the single phase compositions are more meaningful too. This is significant because you can prescribe single phase regions in ZPF datasets and it will enforce that no miscibility gap occurs, which is not true today.
  3. For phase compositions inside a miscibilty gap, the Gibbs energy curve will match the multi-phase global minimum hyperplane at the phase compositions (at convergence).

@bocklund
Copy link
Member Author

bocklund commented Apr 4, 2021

This requires the following before it can be merged:

  • Validation that this works better for systems with a miscibility (both manual validation and automated in the form of a test or two for the driving force in a miscibility gap). This is a pretty significant algorithmic change to how ZPF error is computed and I don't want to rush merging it in.
  • "Fix" the test broken by the new error for an invalid composition so that it tests equilibrium failures properly
  • Create a new test for the error raised by _solve_site_fractions (previous item) and add some unit tests for the other two functions for some common cases (unary, binary, ternary and single-sublattice, multi-sublattice and with/without various internal degrees of freedom)
  • Address or remove newly introduced TODO items
  • Make sure this works for the associate model (i.e. that the mass condition is solved correctly and that the site fractions are correct)
  • More manual testing
  • Add driving force plot script to recipes docs
  • Update dataplot to handle single phase ZPF data, which is available for fitting now

@bocklund
Copy link
Member Author

bocklund commented Apr 5, 2021

I constructed a super simple Cu-Ni comparison in the miscibility gap using two ZPF data points and no other data (thermochemical, ZPF, etc.). Below are the phase diagram comparisons of the optimal parameter set after 500 iterations.

The "global min" version uses the master branch, while the "local min" version is this branch. Clearly the local min version is converging much better to the phase compositions, while the global min version shows that the miscibility gap has poor agreement with the data.

pd-global
pd-local

@bocklund bocklund added this to the 0.8 milestone Apr 7, 2021
@tobiasspt
Copy link

Thanks Brandon for bringing up this solution!
I have a question regarding the driving force for single-phase data points in connection with approx_equilibrium: True within this new branch.
The Ti-W system I am working on shows a miscibility gap of BCC(Ti) (β1) and BCC(W) (β2) with a critical point at around 1500 K, above which only a single BCC phase is present.
The starting point is one of my previous results, where the miscibility gap intersects the solidus. (See figure below). I wanted to see how the phase diagram changes, when I am using only single-phase ZPF data (the circles in the figure below represent experimental single phase BCC data points).

start_approx_true_beschriftet

I am running an MCMC optimization with only this single-phase-ZPF data and no other data. The color of the circles (color map on the right of the above figure) represents the driving force for the individual data points at the start of the optimization. (With approx_equilibrium = True)
What puzzles me, is the very high driving force of the two points on the left in the figure (X(W) = 0.15, T = 1375 K and 1650 K). These two points lie in a region, where the phase diagram predicts only a single BCC phase and the points have a higher driving force than points which lie within the miscibility gap.

Still the MCMC using only the single phase ZPF data changes the PD in a manner that the experimental ZPF data lie in a single phase region of the phase diagram (see figure below). The two points which had previously a large driving force still have a very large driving force compared to the other points. The logarithmic probability went from -295 to -269.

end_approx_true_beschriftet

All of the above calculations were done with approx_equilibrium: True, due to performance. I have checked how the driving force looks like with approx_equilibrium: False for the starting point (see figure below). In this case the driving force looks how I would expect it: almost 0 in the region, where the phase diagram predicts a single phase and larger errors for points which lie further away from a single phase region.

start_approx_false_beschriftet

Should one avoid using approx_equilibrium: True within the new branch?

@bocklund
Copy link
Member Author

bocklund commented Apr 9, 2021

Hi @tobiasspt, thanks for your question.

I think what’s happening is that the approximate equilibrium target hyperplane is less accurate than the exact for these points. I’d have to have the database and data in hand to check for sure. Since you have a development version installed, you could try to increase the pdens parameter of calculate_ in espei.error_functions.zpf_error.estimate_hyperplane from 500 to something like 5000 to see if that gets you closer to the exact equilibrium case.

You give the log probability decrease, what’s the decrease in the driving force? Also, what’s the total probability for all the data? If the driving forces/probabilities of these high driving force points stay relatively constant compared to the other data, it’s probably safe to continue using approximate equilibrium. If I am correct that it’s just poor sampling and a poor target hyperplane in approximate compared to exact, then the driving force and probability will stay relatively constant and not influence whether parameters are accepted or rejected by the Metropolis criteria.

@bocklund
Copy link
Member Author

bocklund commented Apr 9, 2021

Also, I’d love to see the code you are using to color code the driving forces like this. That would be an extremely useful debugging tool for me and many others.

Have you been extracting the driving force data by hand? I’ve been toying with an idea to add an extra function that returns the driving forces for the data as a list instead of the log probability sum, which would make it easier to generate these type of figure programmatically.

@tobiasspt
Copy link

Thx for the help @bocklund.

Increasing the pdens parameter of calculate_ in espei.error_functions.zpf_error.estimate_hyperplane to 5000 or even 50000 gives me exactly the same driving force as with pdens 500.

The change in driving force is depicted in the figure below. It is clearly seen that the highest change is in the middle, where at the start of the run the miscibility gap was. This would explain, why the miscibility gap dissapears after the run. Also the driving force of the high driving force points stay relatively constant, suggesting that using approx_equilibrium:True is safe.
decrease_drving_force

The total probability of all the ZPF data at the beginning of the run is -1236 out of which -295 stem from the single-phase-ZPF data.

@tobiasspt
Copy link

tobiasspt commented Apr 9, 2021

I am extracting the driving forces from the ESPEI logfile (verbosity 3) with a simple python function (more or less by hand), which manipultes the text to read out the desired value. This function is not very general and works for the the start of a run. (In order to extract the driving forces for the end of the run, I simply start an MCMC with the optimised parameters with 1 iteration). See the small code below:

import numpy as np
import matplotlib.pyplot as plt
...

s_sinlgephase = np.array([[1.47853379e-01, 1.48555962e-01, 2.52279075e-01, 2.51956578e-01, ...

def read_ZPF_error_from_log(logfile):
    """
    Reading the driving force and lnprob for single phase data from ESPEIs 
    logfile with verbosity 3. (Start of run, driving force of initial 
    parameters). 
    """
    
    #Looking at the error of the single-phase data: reading the data:
    with open(logfile,'r') as f:
        
        #reding logfile, until we reach the ZPF error
        while True:
            line = f.readline()
            if 'DEBUG:root:ZPF error - Equilibria:' in line:
                break
            
        #Reading the driving forces and lnprobs from the logfile
        # NOTE! This does not work in general. The line of text is simply split
        # by commas and the right value within words[] picked for this
        # situation. If the number of commas changes in the logfile for a 
        # ZPF entry, function needs to be adjusted. 
        # Works only if only single phase zpf-data is present
        dforces = []
        lnprobs = []
        #reding the ZPF error
        while True:    
            words = line.split(',')
            dforces.append(float(words[-3].split(' ')[-1]))
            lnprobs.append(float(words[-2].split(' ')[-1]))
    
            #line done, reading the next line. if no more ZPF data, break
            line = f.readline()
            if not 'DEBUG:root:ZPF error - Equilibria:' in line:
                break        
    return np.array(dforces),np.array(lnprobs)

#%% ZPF_error at start
dforces_start,lnprob_start = read_ZPF_error_from_log('log.txt')

plt.figure(figsize=[9,12])
dbf2 = Database('Ti-W.TDB') 

binplot(dbf2, comps, phases, conds)

# Plotting the single phase data, which is saved in the array s_singlephase
# The value of the colormap is given by c = dforces_start
plt.scatter(s_singlephase[0,:],s_singlephase[1,:],c = dforces_start,cmap= 'hot',edgecolors = 'k')
plt.colorbar(pad=0.25)

A function which writes out the driving forces into a list would indeed be very helpfull

@bocklund
Copy link
Member Author

bocklund commented Apr 9, 2021

Increasing the pdens parameter of calculate_ in espei.error_functions.zpf_error.estimate_hyperplane to 5000 or even 50000 gives me exactly the same driving force as with pdens 500.

Huh - that is puzzling indeed. Can you share a TDB (or two: before & after) with me, along with some of those tricky points around 10% W?

@tobiasspt
Copy link

single_phase_zpf.zip
If you need more files, let me know

@bocklund
Copy link
Member Author

bocklund commented Apr 9, 2021

Thanks for sending the data! This helped uncover the issue.

The target hyperplane is well sampled, that's why increasing the point density of the target hyperplane doesn't do much. The problem lies in the sampling of the single phase site fraction space.

TL;DR

The problem is that having vacancies in the first sublattice of BCC produces is causing the _sample_solution_constitution function to sample the space near the true solution poorly.

I would update my reccomendation to "proceed with caution" when using approximate equilibrium when there are independent vacancy site fractions. Moving forward, this is how I see the options:

  1. (The easiest by far) If possible, remove VA as a constituent of the first sublattice
  2. Accept this issue without making any changes. The samples of site fraction space are pre-calculated, so the error in the driving force should roughly cancel out when using the Metropolis criteria to compare the likelihoods of two proposals
  3. Modify the driving_force_to_hyperplane function to always use exact equilibrium and see if the performance regression is worth the improved accurate in the results
  4. Figure out how to sample near the solution better when vacancy site fractions are dependent in the symbolic solution. Maybe by changing variables in the symbolic solution to make vacancy site fractions independent.

Explanation

Without vacancies in the first sublattice, there are no degrees of freedom to sample because the site fractions of Ti and W must be equal to the mole fractions.

With vacancies in the first sublattice, it's more complicated. For one data point: (conds: ({P: 101325.0, T: 1396.4309366811585, N: 1.0}), comps: (BCC_A2: {X_W: 0.14785337902041507})), the symbolic solution to one of your looks like this:

{
    BCC_A20TI: 5.76345719404846*BCC_A20W, 
    BCC_A20VA: 1.0 - 6.76345719404846*BCC_A20W,
    BCC_A21VA: 1.00000000000000
}

That is, the independent site fraction is the site fraction of W in the first sublattice. Notably, the expression for the site fraction of vacancies in the first sublattice is BCC_A20VA: 1.0 - 6.76345719404846*BCC_A20W. Using exact equilibrium, we can find that the site fraction of vacancies is on the order of 1e-6, so that means we need to be sampling near such that 1.0 - 6.76345719404846*BCC_A20W = 1e-6 , i.e. we need to sample tightly around the W site fraction that is near the prescribed composition condition (0.14785337902041507).

Right now, _sample_solution_constitution does a np.linspace sampling of the independent site fractions on the interval of [0, 1] and then filters out the invalid site fractions (where the dependent site fractions become less than 0, greater than 1, or are NaN). This means that most of the sampled points are very far from the sampling that we want, which ideally would look like sampling between [X(BCC,W) - 1e-3, X(BCC,W) + 1e-3], where X(BCC,W) is the prescribed amount, 0.14785337902041507.

It's not clear to me how to achieve sampling around that solution. One idea is to try to change the variables to make all the vacancy-like site fractions independent. That would allow us to sample:

  1. The log space between 1e-12 and 0.01
  2. The linear space between 0.01 and 0.99
  3. The log space between 0.99 and 1.0

This sampling would catch edge cases like this and efficiently sample the site fractions of vacancy-like species. Unfortunately, SymPy doesn't seem like it lets you specify a "preference" for which variables should be independent in the solution. I spent some time last weekend when I was implementing this trying to change the variables on my own, but I wasn't successful in coming up with a way to do it.

We might have to require exact equilibrium for only the driving force calculation in these cases. It will increase the cost a little bit, but the single phase driving force calculations with restricted points will still be much faster than the total cost for exact equilibrium everywhere, since the multi-phase calculations with global minimization are more expensive.

(Note that this sampling issue does not affect target hyperplane determination because all the site fractions are sampled independently - the root cause is that the site fractions here are not all independent.)

@bocklund
Copy link
Member Author

bocklund commented Apr 9, 2021

With a second look from @richardotis, we were able to come up with a way to prefer vacancy and vacancy-like species as independent symbols in the symbolic solution. After these last two commits, I now get much better agreement:

Before the changes:

approx.txt
32:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1396.4309366811585, N: 1.0}), comps: (BCC_A2: {X_W: 0.14785337902041507})), current phase: BCC_A2, driving force: -5287.874209501038, probability: -21.807500639939924, reference: Single_Phase_Rudy
33:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1654.3227561979897, N: 1.0}), comps: (BCC_A2: {X_W: 0.14855596187624165})), current phase: BCC_A2, driving force: -6894.8807944836735, probability: -31.596384397256713, reference: Single_Phase_Rudy
34:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1664.6880128998814, N: 1.0}), comps: (BCC_A2: {X_W: 0.25227907512453496})), current phase: BCC_A2, driving force: -798.0615797829378, probability: -8.145144954749629, reference: Single_Phase_Rudy
35:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1546.311440006909, N: 1.0}), comps: (BCC_A2: {X_W: 0.2519565780759595})), current phase: BCC_A2, driving force: -621.110014122547, probability: -8.019582637008465, reference: Single_Phase_Rudy
36:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1662.5111578219921, N: 1.0}), comps: (BCC_A2: {X_W: 0.3583518097267412})), current phase: BCC_A2, driving force: -2401.2355360007205, probability: -10.709659861863143, reference: Single_Phase_Rudy
37:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1544.134584929021, N: 1.0}), comps: (BCC_A2: {X_W: 0.35802931267816485})), current phase: BCC_A2, driving force: -2132.665875914885, probability: -10.100825681332712, reference: Single_Phase_Rudy
38:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1659.9110253678473, N: 1.0}), comps: (BCC_A2: {X_W: 0.45727202050159776})), current phase: BCC_A2, driving force: -1537.5379434525094, probability: -9.008705275964896, reference: Single_Phase_Rudy
39:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1661.397535201128, N: 1.0}), comps: (BCC_A2: {X_W: 0.5538195744190727})), current phase: BCC_A2, driving force: -580.738604125625, probability: -7.995322475347699, reference: Single_Phase_Rudy
40:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1399.3485271674963, N: 1.0}), comps: (BCC_A2: {X_W: 0.5542975611160695})), current phase: BCC_A2, driving force: -561.0330505512102, probability: -7.984072854092208, reference: Single_Phase_Rudy
41:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1400.9761294595287, N: 1.0}), comps: (BCC_A2: {X_W: 0.6532292896426611})), current phase: BCC_A2, driving force: -331.0174299135688, probability: -7.881480081640102, reference: Single_Phase_Rudy
42:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1662.954591263785, N: 1.0}), comps: (BCC_A2: {X_W: 0.6515592156411066})), current phase: BCC_A2, driving force: -165.59679269492335, probability: -7.840404961062232, reference: Single_Phase_Rudy
43:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1975.8069624809245, N: 1.0}), comps: (BCC_A2: {X_W: 0.652411529269486})), current phase: BCC_A2, driving force: -330.8277088669565, probability: -7.881417298663889, reference: Single_Phase_Rudy
44:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1982.9976388608939, N: 1.0}), comps: (BCC_A2: {X_W: 0.7024907138126631})), current phase: BCC_A2, driving force: -315.9864714340074, probability: -7.876617537251467, reference: Single_Phase_Rudy
45:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1984.8368798410552, N: 1.0}), comps: (BCC_A2: {X_W: 0.8049987042529293})), current phase: BCC_A2, driving force: -613.3575772028853, probability: -8.014797570942907, reference: Single_Phase_Rudy
46:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1998.9360476834918, N: 1.0}), comps: (BCC_A2: {X_W: 0.9003887241210508})), current phase: BCC_A2, driving force: -23.46581522184715, probability: -7.826969134428823, reference: Single_Phase_Rudy
47:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2590.8189121483488, N: 1.0}), comps: (BCC_A2: {X_W: 0.9020012093639315})), current phase: BCC_A2, driving force: -235.49439324453124, probability: -7.854422616811615, reference: Single_Phase_Rudy
48:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2399.2254311958304, N: 1.0}), comps: (BCC_A2: {X_W: 0.8073195312275036})), current phase: BCC_A2, driving force: -1155.0290021383844, probability: -8.493739810077205, reference: Single_Phase_Rudy
49:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2278.8685248639476, N: 1.0}), comps: (BCC_A2: {X_W: 0.7021048691295454})), current phase: BCC_A2, driving force: -297.30141903457115, probability: -7.870887879066794, reference: Single_Phase_Rudy
50:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2172.812347029859, N: 1.0}), comps: (BCC_A2: {X_W: 0.5528290477698746})), current phase: BCC_A2, driving force: -534.7362143172359, probability: -7.969665221637974, reference: Single_Phase_Rudy
51:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1974.108813959514, N: 1.0}), comps: (BCC_A2: {X_W: 0.5522877134383363})), current phase: BCC_A2, driving force: -378.3847590696241, probability: -7.8982813251348984, reference: Single_Phase_Rudy
52:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1972.6928503556096, N: 1.0}), comps: (BCC_A2: {X_W: 0.45693224682541933})), current phase: BCC_A2, driving force: -1729.9061390902643, probability: -9.322981437217901, reference: Single_Phase_Rudy
53:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2217.760373175156, N: 1.0}), comps: (BCC_A2: {X_W: 0.45521610181692496})), current phase: BCC_A2, driving force: -1402.9461117839674, probability: -8.810822708471687, reference: Single_Phase_Rudy
54:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2110.227763540556, N: 1.0}), comps: (BCC_A2: {X_W: 0.3524201675832874})), current phase: BCC_A2, driving force: -733.9406198416254, probability: -8.096028228913564, reference: Single_Phase_Rudy
55:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1974.869705433499, N: 1.0}), comps: (BCC_A2: {X_W: 0.35085951222321365})), current phase: BCC_A2, driving force: -202.27778997801943, probability: -7.847151964346005, reference: Single_Phase_Rudy
56:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2095.916957009991, N: 1.0}), comps: (BCC_A2: {X_W: 0.2534538858014913})), current phase: BCC_A2, driving force: -1622.2546498712036, probability: -9.14254888670118, reference: Single_Phase_Rudy
57:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2030.7322410665429, N: 1.0}), comps: (BCC_A2: {X_W: 0.15196521638976057})), current phase: BCC_A2, driving force: -1478.9010480832949, probability: -8.920267967197743, reference: Single_Phase_Rudy
58:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1971.5439546200569, N: 1.0}), comps: (BCC_A2: {X_W: 0.15180396786547257})), current phase: BCC_A2, driving force: -1301.1996806711686, probability: -8.673254116676185, reference: Single_Phase_Rudy
59:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1973.31264937084, N: 1.0}), comps: (BCC_A2: {X_W: 0.25311987100118016})), current phase: BCC_A2, driving force: -1358.964653533796, probability: -8.750086276963925, reference: Single_Phase_Rudy

exact.txt
32:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1396.4309366811585, N: 1.0}), comps: (BCC_A2: {X_W: 0.14785337902041507})), current phase: BCC_A2, driving force: -5.270005203783512e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
33:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1654.3227561979897, N: 1.0}), comps: (BCC_A2: {X_W: 0.14855596187624165})), current phase: BCC_A2, driving force: 2.0827428670600057e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
34:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1664.6880128998814, N: 1.0}), comps: (BCC_A2: {X_W: 0.25227907512453496})), current phase: BCC_A2, driving force: 3.519264282658696e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
35:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1546.311440006909, N: 1.0}), comps: (BCC_A2: {X_W: 0.2519565780759595})), current phase: BCC_A2, driving force: -6.5062049543485045e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
36:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1662.5111578219921, N: 1.0}), comps: (BCC_A2: {X_W: 0.3583518097267412})), current phase: BCC_A2, driving force: -1.9319471903145313e-05, probability: -7.82669381218681, reference: Single_Phase_Rudy
37:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1544.134584929021, N: 1.0}), comps: (BCC_A2: {X_W: 0.35802931267816485})), current phase: BCC_A2, driving force: -1.2657110346481204e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
38:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1659.9110253678473, N: 1.0}), comps: (BCC_A2: {X_W: 0.45727202050159776})), current phase: BCC_A2, driving force: 9.578230674378574e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
39:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1661.397535201128, N: 1.0}), comps: (BCC_A2: {X_W: 0.5538195744190727})), current phase: BCC_A2, driving force: 4.2615283746272326e-07, probability: -7.826693812186809, reference: Single_Phase_Rudy
40:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1399.3485271674963, N: 1.0}), comps: (BCC_A2: {X_W: 0.5542975611160695})), current phase: BCC_A2, driving force: 1.406908268108964e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
41:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1400.9761294595287, N: 1.0}), comps: (BCC_A2: {X_W: 0.6532292896426611})), current phase: BCC_A2, driving force: 4.969493602402508e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
42:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1662.954591263785, N: 1.0}), comps: (BCC_A2: {X_W: 0.6515592156411066})), current phase: BCC_A2, driving force: 6.004120223224163e-07, probability: -7.826693812186809, reference: Single_Phase_Rudy
43:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1975.8069624809245, N: 1.0}), comps: (BCC_A2: {X_W: 0.652411529269486})), current phase: BCC_A2, driving force: -1.9862345652654767e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
44:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1982.9976388608939, N: 1.0}), comps: (BCC_A2: {X_W: 0.7024907138126631})), current phase: BCC_A2, driving force: 1.2474629329517484e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
45:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1984.8368798410552, N: 1.0}), comps: (BCC_A2: {X_W: 0.8049987042529293})), current phase: BCC_A2, driving force: 5.788620910607278e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
46:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1998.9360476834918, N: 1.0}), comps: (BCC_A2: {X_W: 0.9003887241210508})), current phase: BCC_A2, driving force: 2.144515747204423e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
47:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2590.8189121483488, N: 1.0}), comps: (BCC_A2: {X_W: 0.9020012093639315})), current phase: BCC_A2, driving force: -2.6219087885692716e-05, probability: -7.82669381218681, reference: Single_Phase_Rudy
48:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2399.2254311958304, N: 1.0}), comps: (BCC_A2: {X_W: 0.8073195312275036})), current phase: BCC_A2, driving force: -1.7033657059073448e-05, probability: -7.82669381218681, reference: Single_Phase_Rudy
49:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2278.8685248639476, N: 1.0}), comps: (BCC_A2: {X_W: 0.7021048691295454})), current phase: BCC_A2, driving force: -1.9931758288294077e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
50:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2172.812347029859, N: 1.0}), comps: (BCC_A2: {X_W: 0.5528290477698746})), current phase: BCC_A2, driving force: -9.694515028968453e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
51:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1974.108813959514, N: 1.0}), comps: (BCC_A2: {X_W: 0.5522877134383363})), current phase: BCC_A2, driving force: -2.9959483072161674e-07, probability: -7.826693812186809, reference: Single_Phase_Rudy
52:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1972.6928503556096, N: 1.0}), comps: (BCC_A2: {X_W: 0.45693224682541933})), current phase: BCC_A2, driving force: -1.3446260709315538e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
53:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2217.760373175156, N: 1.0}), comps: (BCC_A2: {X_W: 0.45521610181692496})), current phase: BCC_A2, driving force: 4.762696335092187e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
54:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2110.227763540556, N: 1.0}), comps: (BCC_A2: {X_W: 0.3524201675832874})), current phase: BCC_A2, driving force: -1.3269134797155857e-05, probability: -7.82669381218681, reference: Single_Phase_Rudy
55:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1974.869705433499, N: 1.0}), comps: (BCC_A2: {X_W: 0.35085951222321365})), current phase: BCC_A2, driving force: -7.162569090723991e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
56:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2095.916957009991, N: 1.0}), comps: (BCC_A2: {X_W: 0.2534538858014913})), current phase: BCC_A2, driving force: 6.852904334664345e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
57:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2030.7322410665429, N: 1.0}), comps: (BCC_A2: {X_W: 0.15196521638976057})), current phase: BCC_A2, driving force: -1.1156720574945211e-05, probability: -7.82669381218681, reference: Single_Phase_Rudy
58:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1971.5439546200569, N: 1.0}), comps: (BCC_A2: {X_W: 0.15180396786547257})), current phase: BCC_A2, driving force: 5.214998964220285e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
59:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1973.31264937084, N: 1.0}), comps: (BCC_A2: {X_W: 0.25311987100118016})), current phase: BCC_A2, driving force: 1.7975398804992437e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy

After the changes:

approx.txt
32:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1396.4309366811585, N: 1.0}), comps: (BCC_A2: {X_W: 0.14785337902041507})), current phase: BCC_A2, driving force: 0.10105856032168958, probability: -7.826693817293226, reference: Single_Phase_Rudy
33:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1654.3227561979897, N: 1.0}), comps: (BCC_A2: {X_W: 0.14855596187624165})), current phase: BCC_A2, driving force: 0.10641876749286894, probability: -7.826693817849287, reference: Single_Phase_Rudy
34:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1664.6880128998814, N: 1.0}), comps: (BCC_A2: {X_W: 0.25227907512453496})), current phase: BCC_A2, driving force: 0.09715374730876647, probability: -7.826693816906235, reference: Single_Phase_Rudy
35:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1546.311440006909, N: 1.0}), comps: (BCC_A2: {X_W: 0.2519565780759595})), current phase: BCC_A2, driving force: 0.10378534502524417, probability: -7.826693817572508, reference: Single_Phase_Rudy
36:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1662.5111578219921, N: 1.0}), comps: (BCC_A2: {X_W: 0.3583518097267412})), current phase: BCC_A2, driving force: 0.1003028440172784, probability: -7.82669381721714, reference: Single_Phase_Rudy
37:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1544.134584929021, N: 1.0}), comps: (BCC_A2: {X_W: 0.35802931267816485})), current phase: BCC_A2, driving force: 0.10172443870396819, probability: -7.8266938173607405, reference: Single_Phase_Rudy
38:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1659.9110253678473, N: 1.0}), comps: (BCC_A2: {X_W: 0.45727202050159776})), current phase: BCC_A2, driving force: 0.0985483738622861, probability: -7.826693817042701, reference: Single_Phase_Rudy
39:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1661.397535201128, N: 1.0}), comps: (BCC_A2: {X_W: 0.5538195744190727})), current phase: BCC_A2, driving force: 0.10796915646642447, probability: -7.826693818015479, reference: Single_Phase_Rudy
40:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1399.3485271674963, N: 1.0}), comps: (BCC_A2: {X_W: 0.5542975611160695})), current phase: BCC_A2, driving force: 0.09205847037083004, probability: -7.82669381642419, reference: Single_Phase_Rudy
41:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1400.9761294595287, N: 1.0}), comps: (BCC_A2: {X_W: 0.6532292896426611})), current phase: BCC_A2, driving force: 0.07316983757482376, probability: -7.826693814863722, reference: Single_Phase_Rudy
42:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1662.954591263785, N: 1.0}), comps: (BCC_A2: {X_W: 0.6515592156411066})), current phase: BCC_A2, driving force: 0.09597281488822773, probability: -7.8266938167922, reference: Single_Phase_Rudy
43:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1975.8069624809245, N: 1.0}), comps: (BCC_A2: {X_W: 0.652411529269486})), current phase: BCC_A2, driving force: 0.13374342120368965, probability: -7.826693821130461, reference: Single_Phase_Rudy
44:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1982.9976388608939, N: 1.0}), comps: (BCC_A2: {X_W: 0.7024907138126631})), current phase: BCC_A2, driving force: 0.13745765923522413, probability: -7.826693821634113, reference: Single_Phase_Rudy
45:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1984.8368798410552, N: 1.0}), comps: (BCC_A2: {X_W: 0.8049987042529293})), current phase: BCC_A2, driving force: 0.14299827684590127, probability: -7.826693822411063, reference: Single_Phase_Rudy
46:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1998.9360476834918, N: 1.0}), comps: (BCC_A2: {X_W: 0.9003887241210508})), current phase: BCC_A2, driving force: 0.17636219268024433, probability: -7.826693827738621, reference: Single_Phase_Rudy
47:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2590.8189121483488, N: 1.0}), comps: (BCC_A2: {X_W: 0.9020012093639315})), current phase: BCC_A2, driving force: 0.17194235199713148, probability: -7.826693826968896, reference: Single_Phase_Rudy
48:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2399.2254311958304, N: 1.0}), comps: (BCC_A2: {X_W: 0.8073195312275036})), current phase: BCC_A2, driving force: 0.15108179568778723, probability: -7.826693823599664, reference: Single_Phase_Rudy
49:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2278.8685248639476, N: 1.0}), comps: (BCC_A2: {X_W: 0.7021048691295454})), current phase: BCC_A2, driving force: 0.15421341263572685, probability: -7.826693824077697, reference: Single_Phase_Rudy
50:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2172.812347029859, N: 1.0}), comps: (BCC_A2: {X_W: 0.5528290477698746})), current phase: BCC_A2, driving force: 0.12503027755883522, probability: -7.826693820003094, reference: Single_Phase_Rudy
51:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1974.108813959514, N: 1.0}), comps: (BCC_A2: {X_W: 0.5522877134383363})), current phase: BCC_A2, driving force: 0.129914552642731, probability: -7.826693820625705, reference: Single_Phase_Rudy
52:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1972.6928503556096, N: 1.0}), comps: (BCC_A2: {X_W: 0.45693224682541933})), current phase: BCC_A2, driving force: 0.09884860928286798, probability: -7.826693817072333, reference: Single_Phase_Rudy
53:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2217.760373175156, N: 1.0}), comps: (BCC_A2: {X_W: 0.45521610181692496})), current phase: BCC_A2, driving force: 0.12909842425142415, probability: -7.826693820520011, reference: Single_Phase_Rudy
54:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2110.227763540556, N: 1.0}), comps: (BCC_A2: {X_W: 0.3524201675832874})), current phase: BCC_A2, driving force: 0.12330502737313509, probability: -7.826693819788875, reference: Single_Phase_Rudy
55:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1974.869705433499, N: 1.0}), comps: (BCC_A2: {X_W: 0.35085951222321365})), current phase: BCC_A2, driving force: 0.10826075114891864, probability: -7.826693818047005, reference: Single_Phase_Rudy
56:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2095.916957009991, N: 1.0}), comps: (BCC_A2: {X_W: 0.2534538858014913})), current phase: BCC_A2, driving force: 0.1498393445799593, probability: -7.826693823412724, reference: Single_Phase_Rudy
57:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2030.7322410665429, N: 1.0}), comps: (BCC_A2: {X_W: 0.15196521638976057})), current phase: BCC_A2, driving force: 0.1376115880557336, probability: -7.826693821655284, reference: Single_Phase_Rudy
58:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1971.5439546200569, N: 1.0}), comps: (BCC_A2: {X_W: 0.15180396786547257})), current phase: BCC_A2, driving force: 0.14558030250191223, probability: -7.826693822783621, reference: Single_Phase_Rudy
59:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1973.31264937084, N: 1.0}), comps: (BCC_A2: {X_W: 0.25311987100118016})), current phase: BCC_A2, driving force: 0.13470978965051472, probability: -7.826693821260173, reference: Single_Phase_Rudy

exact.txt
32:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1396.4309366811585, N: 1.0}), comps: (BCC_A2: {X_W: 0.14785337902041507})), current phase: BCC_A2, driving force: -5.270005203783512e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
33:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1654.3227561979897, N: 1.0}), comps: (BCC_A2: {X_W: 0.14855596187624165})), current phase: BCC_A2, driving force: 2.0827428670600057e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
34:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1664.6880128998814, N: 1.0}), comps: (BCC_A2: {X_W: 0.25227907512453496})), current phase: BCC_A2, driving force: 3.519264282658696e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
35:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1546.311440006909, N: 1.0}), comps: (BCC_A2: {X_W: 0.2519565780759595})), current phase: BCC_A2, driving force: -6.5062049543485045e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
36:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1662.5111578219921, N: 1.0}), comps: (BCC_A2: {X_W: 0.3583518097267412})), current phase: BCC_A2, driving force: -1.9319471903145313e-05, probability: -7.82669381218681, reference: Single_Phase_Rudy
37:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1544.134584929021, N: 1.0}), comps: (BCC_A2: {X_W: 0.35802931267816485})), current phase: BCC_A2, driving force: -1.2657110346481204e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
38:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1659.9110253678473, N: 1.0}), comps: (BCC_A2: {X_W: 0.45727202050159776})), current phase: BCC_A2, driving force: 9.578230674378574e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
39:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1661.397535201128, N: 1.0}), comps: (BCC_A2: {X_W: 0.5538195744190727})), current phase: BCC_A2, driving force: 4.2615283746272326e-07, probability: -7.826693812186809, reference: Single_Phase_Rudy
40:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1399.3485271674963, N: 1.0}), comps: (BCC_A2: {X_W: 0.5542975611160695})), current phase: BCC_A2, driving force: 1.406908268108964e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
41:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1400.9761294595287, N: 1.0}), comps: (BCC_A2: {X_W: 0.6532292896426611})), current phase: BCC_A2, driving force: 4.969493602402508e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
42:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1662.954591263785, N: 1.0}), comps: (BCC_A2: {X_W: 0.6515592156411066})), current phase: BCC_A2, driving force: 6.004120223224163e-07, probability: -7.826693812186809, reference: Single_Phase_Rudy
43:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1975.8069624809245, N: 1.0}), comps: (BCC_A2: {X_W: 0.652411529269486})), current phase: BCC_A2, driving force: -1.9862345652654767e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
44:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1982.9976388608939, N: 1.0}), comps: (BCC_A2: {X_W: 0.7024907138126631})), current phase: BCC_A2, driving force: 1.2474629329517484e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
45:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1984.8368798410552, N: 1.0}), comps: (BCC_A2: {X_W: 0.8049987042529293})), current phase: BCC_A2, driving force: 5.788635462522507e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
46:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1998.9360476834918, N: 1.0}), comps: (BCC_A2: {X_W: 0.9003887241210508})), current phase: BCC_A2, driving force: 2.144515747204423e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
47:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2590.8189121483488, N: 1.0}), comps: (BCC_A2: {X_W: 0.9020012093639315})), current phase: BCC_A2, driving force: -2.6219029678031802e-05, probability: -7.82669381218681, reference: Single_Phase_Rudy
48:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2399.2254311958304, N: 1.0}), comps: (BCC_A2: {X_W: 0.8073195312275036})), current phase: BCC_A2, driving force: -1.7033657059073448e-05, probability: -7.82669381218681, reference: Single_Phase_Rudy
49:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2278.8685248639476, N: 1.0}), comps: (BCC_A2: {X_W: 0.7021048691295454})), current phase: BCC_A2, driving force: -1.9931758288294077e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
50:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2172.812347029859, N: 1.0}), comps: (BCC_A2: {X_W: 0.5528290477698746})), current phase: BCC_A2, driving force: -9.694515028968453e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
51:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1974.108813959514, N: 1.0}), comps: (BCC_A2: {X_W: 0.5522877134383363})), current phase: BCC_A2, driving force: -2.9959483072161674e-07, probability: -7.826693812186809, reference: Single_Phase_Rudy
52:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1972.6928503556096, N: 1.0}), comps: (BCC_A2: {X_W: 0.45693224682541933})), current phase: BCC_A2, driving force: -1.3446260709315538e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
53:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2217.760373175156, N: 1.0}), comps: (BCC_A2: {X_W: 0.45521610181692496})), current phase: BCC_A2, driving force: 4.762696335092187e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
54:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2110.227763540556, N: 1.0}), comps: (BCC_A2: {X_W: 0.3524201675832874})), current phase: BCC_A2, driving force: -1.3269134797155857e-05, probability: -7.82669381218681, reference: Single_Phase_Rudy
55:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1974.869705433499, N: 1.0}), comps: (BCC_A2: {X_W: 0.35085951222321365})), current phase: BCC_A2, driving force: -7.162569090723991e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
56:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2095.916957009991, N: 1.0}), comps: (BCC_A2: {X_W: 0.2534538858014913})), current phase: BCC_A2, driving force: 6.852904334664345e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
57:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2030.7322410665429, N: 1.0}), comps: (BCC_A2: {X_W: 0.15196521638976057})), current phase: BCC_A2, driving force: -1.1156720574945211e-05, probability: -7.82669381218681, reference: Single_Phase_Rudy
58:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1971.5439546200569, N: 1.0}), comps: (BCC_A2: {X_W: 0.15180396786547257})), current phase: BCC_A2, driving force: 5.214998964220285e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
59:DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1973.31264937084, N: 1.0}), comps: (BCC_A2: {X_W: 0.25311987100118016})), current phase: BCC_A2, driving force: 1.7975398804992437e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy

@bocklund
Copy link
Member Author

bocklund commented Apr 9, 2021

We use the ability to isolate the independent vacancy-like site fractions to be able to sample in logspace near the site fraction limits [~0, 0.01] and [0.99, 1.0] to get better fidelity for dilute vacancy concentrations.

@tobiasspt can you try pulling the latest commits and trying again? I'd be curious to see how the driving forces of the starting points compare between the exact and approximate.

@bocklund
Copy link
Member Author

bocklund commented Apr 10, 2021

I refactored the internals a little to make it easier to calculate the driving forces programmatically. This makes it a lot easier plot driving forces directly in Python. You can also provide your own

import numpy as np
import matplotlib.pyplot as plt
from pycalphad import Database, binplot, variables as v
from pycalphad.core.utils import extract_parameters
from espei.datasets import load_datasets, recursive_glob
from espei.error_functions.zpf_error import get_zpf_data, calculate_zpf_driving_forces

# User input variables
TDB_PATH = '/Users/brandon/Downloads/single_phase_zpf/ti-w_end.tdb'
DATASETS_DIR = '/Users/brandon/Downloads/single_phase_zpf/input-data'
COMPS = ['TI', 'W', 'VA']
INDEP_COMP = v.X('W')  # binary assumed
CONDS = {v.N: 1, v.P: 101325, v.T: (500, 3800, 20), INDEP_COMP: (0, 1, 0.01)}
CMAP = 'hot'
parameters = {}  # e.g. {'VV0001': 10000.0}
approximate_equilibrium = True

# Script below:
dbf = Database(TDB_PATH) 
phases = list(dbf.phases.keys())

# Get the datasets, construct ZPF data and compute driving forces
# Driving forces and weights are ragged 2D arrays of shape (len(zpf_data), len(vertices in each zpf_data))
ds = load_datasets(recursive_glob(DATASETS_DIR, '*.json'))
zpf_data = get_zpf_data(dbf, COMPS, phases, ds, parameters=parameters)
param_vec = extract_parameters(parameters)[1]
driving_forces, weights = calculate_zpf_driving_forces(zpf_data, param_vec, approximate_equilibrium=approximate_equilibrium)

# Construct the plotting compositions, temperatures and driving forces
# Each should have len() == (number of vertices)
# Driving forces already have the vertices unrolled so we can concatenate directly
Xs = []  
Ts = []
dfs = np.concatenate(driving_forces)
for data in zpf_data:
    for phase_region in data['phase_regions']:
        for vertex_comp_cond in phase_region.comp_conds:
            Ts.append(phase_region.potential_conds[v.T])
            # Binary assumptions here
            assert len(vertex_comp_cond) == 1
            if INDEP_COMP in vertex_comp_cond:
                Xs.append(vertex_comp_cond[INDEP_COMP])
            else:
                # Switch the dependent and independent component
                Xs.append(1.0 - vertex_comp_cond[INDEP_COMP])


# Plot the phase diagram with driving forces
fig = plt.figure(dpi=100)
ax = fig.gca()
binplot(dbf, COMPS, phases, CONDS, plot_kwargs={'ax': ax}, eq_kwargs={'parameters': parameters})
sm = plt.cm.ScalarMappable(cmap=CMAP)
sm.set_array(dfs)
ax.scatter(Xs, Ts, c=dfs, cmap=CMAP, edgecolors='k')
fig.colorbar(sm, ax=ax, pad=0.25)
fig.show()

Here's the ending point TDB that you sent with approximate and exact equilibrium, respecitvely:

Ti-W-end-approx-driving-forces

Ti-W-end-exact-driving-forces

@bocklund
Copy link
Member Author

bocklund commented Apr 11, 2021

@tobiasspt I rebased this on master, so you might have to reset this branch back even to master before you pull

@tobiasspt
Copy link

Thanks a lot for the detailed explanation and the help with my question!
I have pulled the last commits (espei -v gives version 0.7.12+26.g7766946).
I had a look at the driving forces at the start of the run and compared exact and approximate.
The agreement between approximate and exact is much better now.

Comparison before the changes:

DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1396.4309366811585, N: 1.0}), comps: (BCC_A2: {X_W: 0.14785337902041507})), current phase: BCC_A2, driving force: -5497.625756298512, probability: -22.938638290345203, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1654.3227561979897, N: 1.0}), comps: (BCC_A2: {X_W: 0.14855596187624165})), current phase: BCC_A2, driving force: -7078.8703834566695, probability: -32.881896765076796, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1664.6880128998814, N: 1.0}), comps: (BCC_A2: {X_W: 0.25227907512453496})), current phase: BCC_A2, driving force: -1012.1133204180951, probability: -8.33888049887068, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1546.311440006909, N: 1.0}), comps: (BCC_A2: {X_W: 0.2519565780759595})), current phase: BCC_A2, driving force: -817.2808836877084, probability: -8.16066783360749, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1662.5111578219921, N: 1.0}), comps: (BCC_A2: {X_W: 0.3583518097267412})), current phase: BCC_A2, driving force: -3196.058295963434, probability: -12.934088127785154, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1544.134584929021, N: 1.0}), comps: (BCC_A2: {X_W: 0.35802931267816485})), current phase: BCC_A2, driving force: -2891.6340126667783, probability: -12.007467443792496, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1659.9110253678473, N: 1.0}), comps: (BCC_A2: {X_W: 0.45727202050159776})), current phase: BCC_A2, driving force: -2648.328342900655, probability: -11.333515318092275, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1661.397535201128, N: 1.0}), comps: (BCC_A2: {X_W: 0.5538195744190727})), current phase: BCC_A2, driving force: -1519.5717744267313, probability: -8.981243001004012, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1399.3485271674963, N: 1.0}), comps: (BCC_A2: {X_W: 0.5542975611160695})), current phase: BCC_A2, driving force: -1360.360785010169, probability: -8.751984544883552, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1400.9761294595287, N: 1.0}), comps: (BCC_A2: {X_W: 0.6532292896426611})), current phase: BCC_A2, driving force: -614.8139279976167, probability: -8.015691895216738, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1662.954591263785, N: 1.0}), comps: (BCC_A2: {X_W: 0.6515592156411066})), current phase: BCC_A2, driving force: -542.710044237916, probability: -7.97396090824517, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1975.8069624809245, N: 1.0}), comps: (BCC_A2: {X_W: 0.652411529269486})), current phase: BCC_A2, driving force: -826.0166844614869, probability: -8.167845593691183, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1982.9976388608939, N: 1.0}), comps: (BCC_A2: {X_W: 0.7024907138126631})), current phase: BCC_A2, driving force: -496.4753430369892, probability: -7.949937695308657, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1984.8368798410552, N: 1.0}), comps: (BCC_A2: {X_W: 0.8049987042529293})), current phase: BCC_A2, driving force: -649.3697991772788, probability: -8.037534380228578, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1998.9360476834918, N: 1.0}), comps: (BCC_A2: {X_W: 0.9003887241210508})), current phase: BCC_A2, driving force: -26.25235468772007, probability: -7.827038405250135, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2590.8189121483488, N: 1.0}), comps: (BCC_A2: {X_W: 0.9020012093639315})), current phase: BCC_A2, driving force: -246.52883424330503, probability: -7.857082045243491, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2399.2254311958304, N: 1.0}), comps: (BCC_A2: {X_W: 0.8073195312275036})), current phase: BCC_A2, driving force: -1190.4238400143222, probability: -8.535248271624031, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2278.8685248639476, N: 1.0}), comps: (BCC_A2: {X_W: 0.7021048691295454})), current phase: BCC_A2, driving force: -654.5767490793369, probability: -8.040929172404446, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2172.812347029859, N: 1.0}), comps: (BCC_A2: {X_W: 0.5528290477698746})), current phase: BCC_A2, driving force: -1785.424245693226, probability: -9.420563680741422, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1974.108813959514, N: 1.0}), comps: (BCC_A2: {X_W: 0.5522877134383363})), current phase: BCC_A2, driving force: -1514.263966315557, probability: -8.97319149202767, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1972.6928503556096, N: 1.0}), comps: (BCC_A2: {X_W: 0.45693224682541933})), current phase: BCC_A2, driving force: -3005.174111824599, probability: -12.342229533377195, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2217.760373175156, N: 1.0}), comps: (BCC_A2: {X_W: 0.45521610181692496})), current phase: BCC_A2, driving force: -2846.2311603200797, probability: -11.877209721175303, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2110.227763540556, N: 1.0}), comps: (BCC_A2: {X_W: 0.3524201675832874})), current phase: BCC_A2, driving force: -1727.7298934266437, probability: -9.31921910450683, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1974.869705433499, N: 1.0}), comps: (BCC_A2: {X_W: 0.35085951222321365})), current phase: BCC_A2, driving force: -1148.1555987214815, probability: -8.485824451624552, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2095.916957009991, N: 1.0}), comps: (BCC_A2: {X_W: 0.2534538858014913})), current phase: BCC_A2, driving force: -1898.96604298288, probability: -9.629729828387838, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2030.7322410665429, N: 1.0}), comps: (BCC_A2: {X_W: 0.15196521638976057})), current phase: BCC_A2, driving force: -1509.3175105149858, probability: -8.965713485960386, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1971.5439546200569, N: 1.0}), comps: (BCC_A2: {X_W: 0.15180396786547257})), current phase: BCC_A2, driving force: -1331.259798544168, probability: -8.71282013779674, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1973.31264937084, N: 1.0}), comps: (BCC_A2: {X_W: 0.25311987100118016})), current phase: BCC_A2, driving force: -1618.2932884685433, probability: -9.136130395937975, reference: Single_Phase_Rudy

exact before
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1396.4309366811585, N: 1.0}), comps: (BCC_A2: {X_W: 0.14785337902041507})), current phase: BCC_A2, driving force: -3.65760934073478e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1654.3227561979897, N: 1.0}), comps: (BCC_A2: {X_W: 0.14855596187624165})), current phase: BCC_A2, driving force: 8.4372004494071e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1664.6880128998814, N: 1.0}), comps: (BCC_A2: {X_W: 0.25227907512453496})), current phase: BCC_A2, driving force: -209.90040871623205, probability: -7.84872290297643, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1546.311440006909, N: 1.0}), comps: (BCC_A2: {X_W: 0.2519565780759595})), current phase: BCC_A2, driving force: -188.45014211525267, probability: -7.844450540218439, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1662.5111578219921, N: 1.0}), comps: (BCC_A2: {X_W: 0.3583518097267412})), current phase: BCC_A2, driving force: -860.9270963523741, probability: -8.197291544803674, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1544.134584929021, N: 1.0}), comps: (BCC_A2: {X_W: 0.35802931267816485})), current phase: BCC_A2, driving force: -807.4889666915406, probability: -8.152713027851096, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1659.9110253678473, N: 1.0}), comps: (BCC_A2: {X_W: 0.45727202050159776})), current phase: BCC_A2, driving force: -1173.8824615582416, probability: -8.515693828963828, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1661.397535201128, N: 1.0}), comps: (BCC_A2: {X_W: 0.5538195744190727})), current phase: BCC_A2, driving force: -956.6955694395729, probability: -8.284327018479464, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1399.3485271674963, N: 1.0}), comps: (BCC_A2: {X_W: 0.5542975611160695})), current phase: BCC_A2, driving force: -805.8503056454065, probability: -8.151391169741206, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1400.9761294595287, N: 1.0}), comps: (BCC_A2: {X_W: 0.6532292896426611})), current phase: BCC_A2, driving force: -270.2368965622736, probability: -7.863207802318614, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1662.954591263785, N: 1.0}), comps: (BCC_A2: {X_W: 0.6515592156411066})), current phase: BCC_A2, driving force: -374.6908282168006, probability: -7.896890420561705, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1975.8069624809245, N: 1.0}), comps: (BCC_A2: {X_W: 0.652411529269486})), current phase: BCC_A2, driving force: -498.668807478025, probability: -7.951029101962587, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1982.9976388608939, N: 1.0}), comps: (BCC_A2: {X_W: 0.7024907138126631})), current phase: BCC_A2, driving force: -175.47132589011744, probability: -7.842088905291627, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1984.8368798410552, N: 1.0}), comps: (BCC_A2: {X_W: 0.8049987042529293})), current phase: BCC_A2, driving force: -2.918386599048972e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1998.9360476834918, N: 1.0}), comps: (BCC_A2: {X_W: 0.9003887241210508})), current phase: BCC_A2, driving force: -1.9136685295961797e-05, probability: -7.82669381218681, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2590.8189121483488, N: 1.0}), comps: (BCC_A2: {X_W: 0.9020012093639315})), current phase: BCC_A2, driving force: 1.2034346582368016e-05, probability: -7.82669381218681, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2399.2254311958304, N: 1.0}), comps: (BCC_A2: {X_W: 0.8073195312275036})), current phase: BCC_A2, driving force: 3.378954716026783e-07, probability: -7.826693812186809, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2278.8685248639476, N: 1.0}), comps: (BCC_A2: {X_W: 0.7021048691295454})), current phase: BCC_A2, driving force: -358.39022644169745, probability: -7.890915589391275, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2172.812347029859, N: 1.0}), comps: (BCC_A2: {X_W: 0.5528290477698746})), current phase: BCC_A2, driving force: -1281.4214796561282, probability: -8.64771431644886, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1974.108813959514, N: 1.0}), comps: (BCC_A2: {X_W: 0.5522877134383363})), current phase: BCC_A2, driving force: -1155.3101971119904, probability: -8.494064637962282, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1972.6928503556096, N: 1.0}), comps: (BCC_A2: {X_W: 0.45693224682541933})), current phase: BCC_A2, driving force: -1365.6052878447954, probability: -8.759132713281643, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2217.760373175156, N: 1.0}), comps: (BCC_A2: {X_W: 0.45521610181692496})), current phase: BCC_A2, driving force: -1529.231640151731, probability: -8.995968516807386, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2110.227763540556, N: 1.0}), comps: (BCC_A2: {X_W: 0.3524201675832874})), current phase: BCC_A2, driving force: -1029.1455594012805, probability: -8.356264103404497, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1974.869705433499, N: 1.0}), comps: (BCC_A2: {X_W: 0.35085951222321365})), current phase: BCC_A2, driving force: -956.4948880938755, probability: -8.284135047661668, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2095.916957009991, N: 1.0}), comps: (BCC_A2: {X_W: 0.2534538858014913})), current phase: BCC_A2, driving force: -296.98004507558653, probability: -7.870792385773358, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2030.7322410665429, N: 1.0}), comps: (BCC_A2: {X_W: 0.15196521638976057})), current phase: BCC_A2, driving force: -7.340218871831894e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1971.5439546200569, N: 1.0}), comps: (BCC_A2: {X_W: 0.15180396786547257})), current phase: BCC_A2, driving force: 9.817827958613634e-06, probability: -7.826693812186809, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1973.31264937084, N: 1.0}), comps: (BCC_A2: {X_W: 0.25311987100118016})), current phase: BCC_A2, driving force: -270.81662348010286, probability: -7.863364633963391, reference: Single_Phase_Rudy

Comparison after the changes:

approximate 
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1396.4309366811585, N: 1.0}), comps: (BCC_A2: {X_W: 0.14785337902041507})), current phase: BCC_A2, driving force: 0.11030671450134832, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1654.3227561979897, N: 1.0}), comps: (BCC_A2: {X_W: 0.14855596187624165})), current phase: BCC_A2, driving force: 0.10364937844860833, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1664.6880128998814, N: 1.0}), comps: (BCC_A2: {X_W: 0.25227907512453496})), current phase: BCC_A2, driving force: -209.82714336224308, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1546.311440006909, N: 1.0}), comps: (BCC_A2: {X_W: 0.2519565780759595})), current phase: BCC_A2, driving force: -188.3888464555057, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1662.5111578219921, N: 1.0}), comps: (BCC_A2: {X_W: 0.3583518097267412})), current phase: BCC_A2, driving force: -860.8540571164922, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1544.134584929021, N: 1.0}), comps: (BCC_A2: {X_W: 0.35802931267816485})), current phase: BCC_A2, driving force: -807.4279792525776, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1659.9110253678473, N: 1.0}), comps: (BCC_A2: {X_W: 0.45727202050159776})), current phase: BCC_A2, driving force: -1173.8073817765398, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1661.397535201128, N: 1.0}), comps: (BCC_A2: {X_W: 0.5538195744190727})), current phase: BCC_A2, driving force: -956.6198047536309, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1399.3485271674963, N: 1.0}), comps: (BCC_A2: {X_W: 0.5542975611160695})), current phase: BCC_A2, driving force: -805.7955071509059, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1400.9761294595287, N: 1.0}), comps: (BCC_A2: {X_W: 0.6532292896426611})), current phase: BCC_A2, driving force: -270.18945203817566, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1662.954591263785, N: 1.0}), comps: (BCC_A2: {X_W: 0.6515592156411066})), current phase: BCC_A2, driving force: -374.618209197346, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1975.8069624809245, N: 1.0}), comps: (BCC_A2: {X_W: 0.652411529269486})), current phase: BCC_A2, driving force: -498.5892217148794, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1982.9976388608939, N: 1.0}), comps: (BCC_A2: {X_W: 0.7024907138126631})), current phase: BCC_A2, driving force: -175.3896789788996, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1984.8368798410552, N: 1.0}), comps: (BCC_A2: {X_W: 0.8049987042529293})), current phase: BCC_A2, driving force: 0.15506335282407235, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1998.9360476834918, N: 1.0}), comps: (BCC_A2: {X_W: 0.9003887241210508})), current phase: BCC_A2, driving force: 0.2454600189521443, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2590.8189121483488, N: 1.0}), comps: (BCC_A2: {X_W: 0.9020012093639315})), current phase: BCC_A2, driving force: 0.17932839013519697, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2399.2254311958304, N: 1.0}), comps: (BCC_A2: {X_W: 0.8073195312275036})), current phase: BCC_A2, driving force: 0.14481582384905778, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2278.8685248639476, N: 1.0}), comps: (BCC_A2: {X_W: 0.7021048691295454})), current phase: BCC_A2, driving force: -358.30781442837906, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2172.812347029859, N: 1.0}), comps: (BCC_A2: {X_W: 0.5528290477698746})), current phase: BCC_A2, driving force: -1281.300694546895, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1974.108813959514, N: 1.0}), comps: (BCC_A2: {X_W: 0.5522877134383363})), current phase: BCC_A2, driving force: -1155.2291390658502, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1972.6928503556096, N: 1.0}), comps: (BCC_A2: {X_W: 0.45693224682541933})), current phase: BCC_A2, driving force: -1365.522458228079, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2217.760373175156, N: 1.0}), comps: (BCC_A2: {X_W: 0.45521610181692496})), current phase: BCC_A2, driving force: -1529.17697634059, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2110.227763540556, N: 1.0}), comps: (BCC_A2: {X_W: 0.3524201675832874})), current phase: BCC_A2, driving force: -1029.0391459683888, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1974.869705433499, N: 1.0}), comps: (BCC_A2: {X_W: 0.35085951222321365})), current phase: BCC_A2, driving force: -956.4070579393447, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2095.916957009991, N: 1.0}), comps: (BCC_A2: {X_W: 0.2534538858014913})), current phase: BCC_A2, driving force: -296.87443742883625, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2030.7322410665429, N: 1.0}), comps: (BCC_A2: {X_W: 0.15196521638976057})), current phase: BCC_A2, driving force: 0.1383659568382427, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1971.5439546200569, N: 1.0}), comps: (BCC_A2: {X_W: 0.15180396786547257})), current phase: BCC_A2, driving force: 0.15167743551137391, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1973.31264937084, N: 1.0}), comps: (BCC_A2: {X_W: 0.25311987100118016})), current phase: BCC_A2, driving force: -270.7229908174195, reference: Single_Phase_Rudy

exact 
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1396.4309366811585, N: 1.0}), comps: (BCC_A2: {X_W: 0.14785337902041507})), current phase: BCC_A2, driving force: -3.65760934073478e-06, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1654.3227561979897, N: 1.0}), comps: (BCC_A2: {X_W: 0.14855596187624165})), current phase: BCC_A2, driving force: 8.4372004494071e-06, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1664.6880128998814, N: 1.0}), comps: (BCC_A2: {X_W: 0.25227907512453496})), current phase: BCC_A2, driving force: -209.90040871623205, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1546.311440006909, N: 1.0}), comps: (BCC_A2: {X_W: 0.2519565780759595})), current phase: BCC_A2, driving force: -188.45014211525267, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1662.5111578219921, N: 1.0}), comps: (BCC_A2: {X_W: 0.3583518097267412})), current phase: BCC_A2, driving force: -860.9270963523741, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1544.134584929021, N: 1.0}), comps: (BCC_A2: {X_W: 0.35802931267816485})), current phase: BCC_A2, driving force: -807.4889666915406, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1659.9110253678473, N: 1.0}), comps: (BCC_A2: {X_W: 0.45727202050159776})), current phase: BCC_A2, driving force: -1173.8824615582416, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1661.397535201128, N: 1.0}), comps: (BCC_A2: {X_W: 0.5538195744190727})), current phase: BCC_A2, driving force: -956.6955694395729, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1399.3485271674963, N: 1.0}), comps: (BCC_A2: {X_W: 0.5542975611160695})), current phase: BCC_A2, driving force: -805.8503056454065, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1400.9761294595287, N: 1.0}), comps: (BCC_A2: {X_W: 0.6532292896426611})), current phase: BCC_A2, driving force: -270.2368965622736, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1662.954591263785, N: 1.0}), comps: (BCC_A2: {X_W: 0.6515592156411066})), current phase: BCC_A2, driving force: -374.6908282168006, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1975.8069624809245, N: 1.0}), comps: (BCC_A2: {X_W: 0.652411529269486})), current phase: BCC_A2, driving force: -498.668807478025, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1982.9976388608939, N: 1.0}), comps: (BCC_A2: {X_W: 0.7024907138126631})), current phase: BCC_A2, driving force: -175.47132589011744, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1984.8368798410552, N: 1.0}), comps: (BCC_A2: {X_W: 0.8049987042529293})), current phase: BCC_A2, driving force: -2.9183720471337438e-06, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1998.9360476834918, N: 1.0}), comps: (BCC_A2: {X_W: 0.9003887241210508})), current phase: BCC_A2, driving force: -1.9136714399792254e-05, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2590.8189121483488, N: 1.0}), comps: (BCC_A2: {X_W: 0.9020012093639315})), current phase: BCC_A2, driving force: 1.2034346582368016e-05, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2399.2254311958304, N: 1.0}), comps: (BCC_A2: {X_W: 0.8073195312275036})), current phase: BCC_A2, driving force: 3.378954716026783e-07, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2278.8685248639476, N: 1.0}), comps: (BCC_A2: {X_W: 0.7021048691295454})), current phase: BCC_A2, driving force: -358.39022644172655, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2172.812347029859, N: 1.0}), comps: (BCC_A2: {X_W: 0.5528290477698746})), current phase: BCC_A2, driving force: -1281.4214796561282, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1974.108813959514, N: 1.0}), comps: (BCC_A2: {X_W: 0.5522877134383363})), current phase: BCC_A2, driving force: -1155.3101971119904, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1972.6928503556096, N: 1.0}), comps: (BCC_A2: {X_W: 0.45693224682541933})), current phase: BCC_A2, driving force: -1365.6052878447954, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2217.760373175156, N: 1.0}), comps: (BCC_A2: {X_W: 0.45521610181692496})), current phase: BCC_A2, driving force: -1529.231640151731, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2110.227763540556, N: 1.0}), comps: (BCC_A2: {X_W: 0.3524201675832874})), current phase: BCC_A2, driving force: -1029.1455594012805, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1974.869705433499, N: 1.0}), comps: (BCC_A2: {X_W: 0.35085951222321365})), current phase: BCC_A2, driving force: -956.4948880938755, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2095.916957009991, N: 1.0}), comps: (BCC_A2: {X_W: 0.2534538858014913})), current phase: BCC_A2, driving force: -296.98004507558653, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 2030.7322410665429, N: 1.0}), comps: (BCC_A2: {X_W: 0.15196521638976057})), current phase: BCC_A2, driving force: -7.340218871831894e-06, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1971.5439546200569, N: 1.0}), comps: (BCC_A2: {X_W: 0.15180396786547257})), current phase: BCC_A2, driving force: 9.817827958613634e-06, reference: Single_Phase_Rudy
DEBUG:root:ZPF error - Equilibria: (conds: ({P: 101325.0, T: 1973.31264937084, N: 1.0}), comps: (BCC_A2: {X_W: 0.25311987100118016})), current phase: BCC_A2, driving force: -270.81662348010286, reference: Single_Phase_Rudy

@tobiasspt
Copy link

Ì also much appreciate the code to calculate and plot the driving forces.
I used it to plot the driving forces at the start of the run for the exact and approsimate with the new commits.

dfs_e2_start_approx
dfs_e2_start_exact

@tobiasspt
Copy link

Small question. It seems that with the new commits in my logfiles the driving force for the ZPF data is printed, but the probability is omitted. This is not much of a problem for me right now and I could have made some mistake while getting the new commits installed.

@bocklund
Copy link
Member Author

Part of the refactoring was to move all the probabilities to be calculated in bulk from the driving forces, so they are now logged at the end of calculating the ZPF error in each step in something like:

DEBUG:espei.error_functions.zpf_error - Data weight: 1.0, driving forces: [-7.02012549e+04  0.00000000e+00 -6.85528133e+04  0.00000000e+00 -6.55775570e+04  0.00000000e+00 -6.22599261e+04  1.45519152e-11 -6.18913997e+04  7.27595761e-12 -6.16167679e+04  0.00000000e+00 -5.42154368e+04  7.27595761e-12 -5.35499992e+04  0.00000000e+00 -4.83546674e+04  0.00000000e+00 -4.37496661e+04  0.00000000e+00 -4.29690719e+04  0.00000000e+00 -4.24091730e+04  0.00000000e+00 -4.22085579e+04  0.00000000e+00 -4.09194563e+04  0.00000000e+00 -3.79805224e+04  0.00000000e+00 -3.71058672e+04  7.27595761e-12 -1.92921751e+04  0.00000000e+00  8.46475319e-03 -3.59939570e+04  9.41316137e-02 -3.13470132e+04  7.77658187e-02 -2.54824515e+04  2.90004206e-02 -1.83794178e+04  1.58618370e-03 -1.45632007e+04  2.43617285e-02 -1.06158698e+04  1.99163616e-03 -8.45220098e+03  1.33850910e-02 -6.73227133e+03  1.04819061e-02 -6.00293643e+03  1.56791857e-02 -5.64608895e+03  1.89831015e-04 -5.44768938e+03  1.31403232e-02 -3.76839532e+03  2.02868183e-02 -2.54263369e+03  9.39890368e-03 -1.88847596e+04  2.33961066e-04 -8.80482704e+03  8.01982169e-04 -5.69650985e+03  1.91485312e-02 -5.24771521e+03  9.54264746e-04 -3.77742631e+03  1.80815516e-03 -2.01467830e+03  4.04945085e-02 -1.52205003e+03 -4.41179475e+04  0.00000000e+00 -3.45846187e+04  0.00000000e+00 -1.93326033e+04  0.00000000e+00 -1.46599595e+04  0.00000000e+00  2.84940124e-03 -2.84181976e+04  1.02588315e-03 -2.69723167e+04  3.89896892e-02 -2.06294996e+04  2.94093306e-02 -1.51834488e+04  9.26957683e-03 -1.34638582e+04  9.28598905e-03 -2.54263369e+03  2.73951804e-02 -2.47728510e+03  3.02939658e-02 -2.35133695e+03  4.14584239e-02 -1.58596661e+03 -6.98869950e+04  1.45519152e-11 -6.91135273e+04  0.00000000e+00 -6.89225541e+04  0.00000000e+00 -6.72497916e+04  0.00000000e+00 -6.62284125e+04  1.45519152e-11 -6.28090102e+04 -1.45519152e-11 -6.10959327e+04 -7.27595761e-12 -5.87076660e+04  0.00000000e+00 -1.76094943e+04  3.63797881e-12 -1.70027748e+04  3.63797881e-12 -1.59419037e+04  3.63797881e-12 -3.34835222e+01 -9.19705044e+02 -5.93950382e+01 -9.05850140e+01], weights: [1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.], probabilities: [-2471.93478821    -7.82669381 -2357.57079805    -7.82669381 -2158.03468399    -7.82669381 -1945.97589438    -7.82669381 -1923.09937348    -7.82669381 -1906.1397367     -7.82669381 -1477.48349       -7.82669381 -1441.62790274    -7.82669381 -1176.91362492    -7.82669381  -964.84333507    -7.82669381  -930.99726184    -7.82669381  -907.09567226    -7.82669381  -898.60787479    -7.82669381  -845.02764609    -7.82669381  -729.08673283    -7.82669381  -696.24938555    -7.82669381  -193.92070388    -7.82669381    -7.82669381  -655.60916315    -7.82669382  -499.14431363    -7.82669382  -332.50436023    -7.82669381  -176.72819253    -7.82669381  -113.8701015     -7.82669381   -64.17503987    -7.82669381   -43.54654449    -7.82669381   -30.48843242    -7.82669381   -25.84431672    -7.82669381   -23.76585403    -7.82669381   -22.6653536     -7.82669381   -14.92709547    -7.82669381   -11.05918684    -7.82669381  -186.1437666     -7.82669381   -46.58918341    -7.82669381   -24.05180605    -7.82669381   -21.59595129    -7.82669381   -14.96116856    -7.82669381    -9.85615814    -7.82669381    -8.98501196  -981.02333978    -7.82669381  -605.87462008    -7.82669381  -194.70146899    -7.82669381  -115.28390052    -7.82669381    -7.82669381  -411.62367106    -7.82669381  -371.57962772    -7.82669381  -220.61482018    -7.82669381  -123.09525206    -7.82669381   -98.46443315    -7.82669381   -11.05918684    -7.82669381   -10.89516456    -7.82669381   -10.59108653    -7.82669381    -9.08433886 -2449.92272897    -7.82669381 -2396.16652497    -7.82669381 -2382.985923      -7.82669381 -2269.09393154    -7.82669381 -2200.92800185    -7.82669381 -1980.31257299    -7.82669381 -1874.18319195    -7.82669381 -1731.1217166     -7.82669381  -162.87383941    -7.82669381  -152.37386843    -7.82669381  -134.89883993    -7.82669381    -7.82725439    -8.2496225     -7.8284577     -7.83079663]

I tried to move it out so it was a little cleaner in the code as far as where the driving forces were calculated and where the probabilities were calculted, but maybe it would make more sense to do them together like we used to. Instead of calculate_zpf_driving_forces returning a tuple of (driving_forces, weights), calculate_zpf_driving_forces could return (driving_forces, probabilities) and log preserve the old logging behavior. What do you think?

@tobiasspt
Copy link

Acutally I think that the new behaviour of calculating the probabilities from the driving forces in bulk after the ZPF error is a good solution. Thx agaun for the answer!

@bocklund
Copy link
Member Author

Thanks for the feedback 😄 - it helps to have more fresh eyes look at this.

@bocklund bocklund merged commit 3463ea7 into PhasesResearchLab:master Apr 19, 2021
bocklund added a commit that referenced this pull request May 8, 2021
* Make `PhaseRegion` a dataclass
* Introduce a `RegionVertex` dataclass instead of storing the vertex data in lists of `PhaseRegion`
* Fix a regression in ZPF data introduced by #151 where prescribed phase compositions of stoichiometric phases that used to work no longer work because the phase composition of a stoichiometric phase may be unsatisfiable. Now there's a check for stoichiometric phases that will not try to solve for the points.
* Fixes a bug where stoichiometric phases used `equilibrium` in driving force calculations which could give bad energies for exact equilibrium where mass balance could not be satisfied (approximate was not affected). Now exact and approximate equilibrium use driving force estimation via `calculate` which is always exact for stoichiometric phases because they have exactly one point.
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

Successfully merging this pull request may close these issues.

None yet

2 participants