I know that it is possible to get order constitution data for phases when using Thermo-Calc's GUI (e.g. to get "BCC_B2 DISORD" instead of just "BCC_B2") for a single equilibrium calculation, but I can't find a way to do it in TC-Python. I can get ordering data from TC_Python when using the PropertyDiagram module, but again, I am interested in getting it from single equilibrium calculations. I think it might be possible to do by using the "Sublattice()" method on the individual phases, but I haven't been able to get it to work. If someone could provide some example code how to do this or at least outline the approach that would be great!

Here's a basic example of how I would get phase data with TC_python. This does NOT tell me the order constitution which is the problem.

from tc_python import *

This example shows how to create a single equilibrium calculation                
from a ternary system and configure it to calculate the solidus 
and liquidus temperature using fixed phase conditions for the 
liquid phase. 
There can be multiple solutions to a fixed phase condition and it is 
good practice to perform a regular equilibrium calculation close to 
where the phase transition is. This example starts with an equilibrium 
calculation at 1700K in order to get good start values.           

def list_stable_phases(calc_result):
    List the stable phases and their amount on screen.

        calc_result: Calculation result from an equilibrium calculation
    stable_phases = calc_result.get_stable_phases()
    for phase in stable_phases:
        print("Amount of " + phase + " = {0:.3f}".format(calc_result.get_value_of('NP(' + phase + ')')))

with TCPython() as session:
    # create equilibrium calculation object and set conditions
    eq_calculation = (
            set_cache_folder(os.path.basename(__file__) + "_cache").
            select_database_and_elements("FEDEMO", ["Fe", "Cr", "C"]).
            set_condition(ThermodynamicQuantity.temperature(), 1700.0).
            set_condition(ThermodynamicQuantity.mass_fraction_of_a_component("Cr"), 0.1).
            set_condition(ThermodynamicQuantity.mass_fraction_of_a_component("C"), 0.01)


    # calculate equilibrium and list stable phases
    calc_result = eq_calculation.calculate()
  • 1
    $\begingroup$ Perhaps you could show us the input and output that you tried which you said you weren't able to get to work? $\endgroup$ – Nike Dattani Mar 13 at 22:41
  • 2
    $\begingroup$ As Nike suggested, it may help to have the input and output from your attempt to generate this data. It may be easier for an answerer to modify your existing routines rather than start from scratch. $\endgroup$ – Tyberius Apr 19 at 16:47
  • $\begingroup$ @Tyberius I just added a basic version of how I normally query TC_python for phase data. I think somewhere in there I need to add either an option for order constitution or I need to query it specifically from "calc_result", I just don't know how to do that. $\endgroup$ – sgp45 Apr 21 at 23:12
  • 1
    $\begingroup$ I don't have ThermoCalc to test this, but there is a note in the documentation that reads "Detailed information about the sublattices can be obtained by getting the Phase object of a phase from the System object using tc_python.system.System.get_phase_in_system(). For each phase the sublattices are obtained by using tc_python.system.Phase. get_sublattices()." I'm not sure if this is what you meant by using Sublattice, but it could be worth trying. $\endgroup$ – Tyberius Apr 22 at 14:17

I don't have access to TC-Python, so I can't offer advice on how to use the API specifically. This is more of a workaround than a direct way to get Thermo-Calc to tell you whether the phase is ordered or disordered.

Are you able to get the site fractions from an equilibrium calculation? In console mode, you can use the Y(CR,BCC_B2#2) syntax. My understanding is that you can use console mode syntax in TC-Python, but I'm not sure if this particular property is supported. If you can get the site fractions for each species, it is pretty easy to write your own function to quantify whether a phase is ordered or disordered.

I have written a function that does this for site fractions from pycalphad here, which I adapted below:

import itertools
import numpy as np
def is_ordered(site_fracs, symmetric_subl_idx):
    Return True if the site fraction configuration is ordered

    site_fracs : list[list[float]]
        Nested site fraction lists. Each inner list must sum to unity.
    symmetric_subl_idx : list[list[int]]
        List of sets of symmetrically equivalent sublattice indexes (as a list).
        If sublattices at index 0 and index 1 are symmetric, as index 2 and
        index 3, then the symmetric_subl_idx will be [[0, 1], [2, 3]].


    # For each set of symmetrically equivalent sublattices
    for symm_subl in symmetric_subl_idx:
        # Check whether the site fractions of each pair of symmetrically
        # equivalent sublattices are ordered or disordered
        for subl_idx1, subl_idx2 in itertools.combinations(symm_subl, 2):
            # A phase is ordered if any pair of sublattices does not have
            # equal (within numerical tolerance) site fractions
            pair_is_ordered = np.any(~np.isclose(site_fracs[subl_idx1], site_fracs[subl_idx2]))
            if pair_is_ordered:
                return True
    return False

# For your case, I assume that the sublattice model for BCC_B2 has two substitutional
# sublattices and one interstitial sublatticewith the model (Cr,Fe)(Cr,Fe)(C,VA), with
# VA being vacancy. The first and second sublattices are symmetrically equivalent.
# The third sublattice is only equivalent to itself.
symmetric_subl_idxs = [[0, 1], [2]]  # note: [[0, 1]] would do the same thing.

# Making up a possible disordered configuration of site fractions:
# You would construct these from TC-Python, looping over the sublattices and
# species in each sublattice
disordered_site_fracs = [[0.25, 0.75], [0.25, 0.75], [0.001, 0.999]]
print(is_ordered(disordered_site_fracs, symmetric_subl_idxs))  # False

# Making up a possible ordered configuration of site fractions:
ordered_site_fracs = [[0.5, 0.5], [0.25, 0.75], [0.001, 0.999]]
print(is_ordered(ordered_site_fracs, symmetric_subl_idxs))  # True
  • 2
    $\begingroup$ +1 Thanks so much for answering my email so quickly and helping out this user!! Thanks also for sharing your code here :) $\endgroup$ – Nike Dattani Apr 23 at 17:56
  • $\begingroup$ Yes, I think I can query TC-Python for the sublattice data. I wasn't sure before how to use that to make the ordered/disordered classification, but thanks to your detailed response I think I understand it. Thank you very much! $\endgroup$ – sgp45 Apr 24 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.