Some sample code that removes phases that have sublattices with only inactive components from the phase list
The database loaded is a Al-Co-Cr-Ni database. We have defined components that are only Al-Ni-Co (excluding Cr). The goal is to filter out phases that are invalid because they have sublattices that contain Cr
In [13]:
from pycalphad import Database
from pycalphad.tests.datasets import ALCOCRNI_TDB
dbf = Database.from_string(ALCOCRNI_TDB, fmt='tdb')
In [14]:
comps = ['AL', 'NI', 'CO', 'VA'] # missing CR
phases = [phase for phase in dbf.phases.keys() if all(
len(set(comps).intersection(subl)) > 0 for subl in dbf.phases[phase].constituents)]
In [15]:
print('Phases included: {}\n'.format(phases))
print('Phases excluded: {}'.format(dbf.phases.keys()-set(phases)))
In [16]:
print('Constituents of excluded phases:')
for ph in dbf.phases.keys()-set(phases):
print('{:10}: {}'.format(ph, dbf.phases[ph].constituents))