Giter VIP home page Giter VIP logo

Comments (5)

bocklund avatar bocklund commented on June 21, 2024

On closer inspection, it's not clear whether this is a solver failure or starting point failure. I noticed that we are adding composition sets with positive driving force before even running the solver. I printed out the chemical potentials just before add nearly stable and got: [-39857.862145 10762.60958372 -22565.20996254]

The starting point composition sets are:

[
CompositionSet(LAVES_C15, [6.66666667e-01 3.33333333e-01 1.00000000e-14], NP=0.2795026017216821, GM=-22984.371568762246),
CompositionSet(BCC_A2, [1.00000000e-14 1.52542373e-01 8.47457627e-01], NP=0.2740378620490976, GM=-17481.305285989976), 
CompositionSet(BCC_A2, [0.03060733 0.14565728 0.8237354 ], NP=0.44645953622922036, GM=-18240.052345507993)
]

These chemical potentials do seem to be correct w.r.t. the composition sets (i.e. sum(MU(i) * X(i)) = GM and mass balance is satisfied w.r.t. the conditions), but the composition sets do not seem to be the global minimum amongst the grid.

from pycalphad.

richardotis avatar richardotis commented on June 21, 2024

Reproducing on Windows.

from pycalphad.

richardotis avatar richardotis commented on June 21, 2024

Looks like hyperplane is hitting max_iterations for this case and silently returning a metastable result.

best_guess_simplex [0 1 2]
best_guess_simplex [0 1 2]
best_guess_simplex [1091    1    2]
best_guess_simplex [93  1  2]
best_guess_simplex [93  1 68]
best_guess_simplex [ 93 265  68]
best_guess_simplex [ 93 230  68]
best_guess_simplex [ 93 174  68]
best_guess_simplex [122 174  68]
best_guess_simplex [358 174  68]
best_guess_simplex [358 506  68]
best_guess_simplex [643 506  68]
best_guess_simplex [578 506  68]
best_guess_simplex [583 506  68]
best_guess_simplex [602 506  68]
best_guess_simplex [602 506 601]
best_guess_simplex [519 506 601]
best_guess_simplex [524 506 601]
best_guess_simplex [524 539 601]
best_guess_simplex [524 541 601]
best_guess_simplex [524 541 723]
best_guess_simplex [524 541 643]
best_guess_simplex [524 541 650]
best_guess_simplex [692 541 650]
best_guess_simplex [297 541 650]
best_guess_simplex [ 34 541 650]
best_guess_simplex [ 34 541  57]
best_guess_simplex [ 40 541  57]
best_guess_simplex [ 34 541  57]
best_guess_simplex [ 40 541  57]
best_guess_simplex [ 34 541  57]
best_guess_simplex [ 40 541  57]
best_guess_simplex [ 34 541  57]
[snip]

There's some kind of oscillation happening. Details:

best_guess_simplex [ 34 541  57]
compositions [[4.74576271e-01 5.25423729e-01 1.00000000e-14]
 [3.06073251e-02 1.45657277e-01 8.23735398e-01]
 [8.64406780e-01 1.35593220e-01 1.00000000e-14]]
result_fractions [0.14641294 0.72838924 0.12519783]
candidate_potentials [-14195.14560945 -17018.56111746 -11985.99718834]
candidate_energy (NP*GM) -13434.339658386109

best_guess_simplex [ 40 541  57]
compositions [[5.76271186e-01 4.23728814e-01 1.00000000e-14]
 [3.06073251e-02 1.45657277e-01 8.23735398e-01]
 [8.64406780e-01 1.35593220e-01 1.00000000e-14]]
result_fractions [0.19808809 0.72838924 0.07352267]
candidate_potentials [-14099.24186462 -17629.94749077 -11881.45206683]
candidate_energy (NP*GM) -13474.709111175876

from pycalphad.

richardotis avatar richardotis commented on June 21, 2024

Here's a visualization of the candidate simplices (triangles here) with the target composition point marked. I don't see any problem numerically with estimating the barycentric coordinates (phase fractions) here. Both triangles are feasible, but one is lower energy than the other at the target point, so we shouldn't be seeing this oscillation.
download

from pycalphad.

richardotis avatar richardotis commented on June 21, 2024

There was no oscillation problem in the develop branch. I had made a mistake in some debugging code that accidentally changed the behavior.

The issue may be a problem in some code that is supposed to accelerate the hyperplane calculation by throwing out metastable points:

for i in range(num_points):
if driving_forces[i] < 1.0:
remaining_point_indices[ici] = remaining_point_indices[i]
if driving_forces[i] < lowest_df:
lowest_df = driving_forces[i]
min_df = ici
ici += 1

If I force that first branch to always be taken (if True:), the starting point/potentials are significantly improved and the test passes. The minimizer still adds some composition sets, but they are all metastable with respect to the starting point. The number of iterations in hyperplane also does not increase significantly for this case (from 7 to 10).

Components: CR TI V VA
Phases: BCC_A2
HCP_A3
LAVES_C14
LAVES_C15
LAVES_C36
LIQUID
[done]
candidate_potentials [-26080.7644499  -16842.67749394 -19577.50191689]
candidate_energy (MU*X) -20331.189538901348
smallest_fractions [  0.09676002 -34.50172414 -16.09090909]
best_guess_simplex [ 486   77 1937]
lowest_df -9.379164112033322e-13
trial_simplices [[1937   77 1937]
 [ 486 1937 1937]
 [ 486   77 1937]]
num_iterations 10
Adding metastable CompositionSet(LAVES_C14, [0.66666667 0.33333333 0.        ], NP=0.0, GM=-22373.026568761084) Driving force: -628.3564780091801
Adding metastable CompositionSet(LAVES_C36, [0.65536723 0.33333333 0.01129944], NP=0.0, GM=-22739.43040771062) Driving force: -188.48853107354807
Chemical Potentials [-26103.48124821 -16869.03299259 -19606.77561676]
[1.00000000e+00 1.01325000e+05 5.00000000e+02 5.11950690e-05
 9.93548306e-01 6.40049853e-03 1.00000000e+00 1.90022112e-01
 6.65953816e-03 8.03318350e-01 1.00000000e+00 9.84813523e-01
 6.02520547e-03 9.16127166e-03 1.73905853e-11 9.99975704e-01
 2.42964143e-05 1.66081420e-01 7.44900946e-01 8.90176345e-02]
Composition Sets [CompositionSet(HCP_A3, [5.11950690e-05 9.93548306e-01 6.40049853e-03], NP=0.1660814198904083, GM=-16887.02866843402), CompositionSet(BCC_A2, [0.19002211 0.00665954 0.80331835], NP=0.7449009455715806, GM=-20823.061237758367), CompositionSet(LAVES_C15, [0.65654235 0.33734204 0.00611561], NP=0.08901763453668607, GM=-22948.582313288694)]
[[[[[['HCP_A3' 'BCC_A2' 'LAVES_C15' '']]]]]]

The assumption made in the accelerator code (that any point metastable at any particular iteration must be metastable at every subsequent iteration, and at the solution) may be incorrect, or maybe the assumption is being implemented incorrectly. Either way, it may be worth it to turn it off since it's counterproductive here.

from pycalphad.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.