model.DofError while invoking equilibrium

63 views
Skip to first unread message

emanuel...@gmail.com

unread,
Nov 10, 2017, 2:19:50 PM11/10/17
to pycalphad
Hello,

I am trying to calculate the equilibrium (specific?) enthalpy and entropy for an alloy of composition:
  • 93% Al
  • 7% Si
at atmospheric pressure (i.e. 101325 Pa) and temperature of 1053.15 K (i.e. 780 °C).

I am using the database attached to this post.

Here is my script:
import numpy as np
from pycalphad import Database, calculate, equilibrium
import pycalphad.variables as v
db
= Database('al-matcalc.tdb')
comps
= ['AL','SI']
phases
= list(db.phases.keys())
eq
= equilibrium(db, comps, phases, {v.X('AL'): 0.93, v.X('SI'): 0.07, v.P: 101325, v.T: 1053.15}, output=['enthalpy', 'entropy'])

This is the output:
Traceback (most recent call last):
 
File "./pycalphad_minimal.py", line 7, in <module>
    eq
= equilibrium(db, comps, phases, {v.X('AL'): 0.93, v.X('SI'): 0.07, v.P: 101325, v.T: 1053.15}, output=['enthalpy', 'entropy'])
 
File "/usr/local/lib/python3.4/dist-packages/pycalphad/core/equilibrium.py", line 243, in equilibrium
    models
[name] = mod = mod(dbf, comps, name, parameters=parameters)
 
File "/usr/local/lib/python3.4/dist-packages/pycalphad/core/calculate.py", line 32, in __new__
    ret
= CompiledModel(*args, **kwargs)
 
File "pycalphad/core/compiled_model.pyx", line 62, in pycalphad.core.compiled_model.CompiledModel.__init__
pycalphad
.model.DofError: AL11MN4: Sublattice frozenset({'MN', 'FE', 'ZN'}) of (frozenset({'AL'}), frozenset({'MN', 'FE', 'ZN'})) has no components in {'AL'}

Python 3.4.3 and pycalphad 0.5.2.post1.

What am I doing wrong?

Thanks for your time.

Regards,

Emanuele

Brandon Bocklund

unread,
Nov 11, 2017, 4:55:00 PM11/11/17
to emanuel...@gmail.com, pycalphad
Hi Emanuele,

The issue here is that you are including phases when that don't have Al and/or Si in their sublattices when you run phases = list(db.phases.keys()) 

In the error message, it is telling you that the phase AL11MN4 has sublattices (Al)(Mn, Fe, Zn) and the second sublattice does not have any Al. 

Specifically, pycalphad does not automatically suspend phases that are like this. In order to get this behavior, I suggest using some function such as the following, which is an open pull request to make it in to the development version of pycalphad (https://github.com/pycalphad/pycalphad/pull/141):

def filter_phases(dbf, comps):
"""Return phases that are valid for equilibrium calculations for the given database and components

Filters out phases that
* Have no active components in any sublattice of a phase
* Are disordered phases in an order-disorder model

Parameters
----------
dbf : Database
Thermodynamic database containing the relevant parameters.
comps : list
Names of components to consider in the calculation.

Returns
-------
list
Sorted list of phases that are valid for the Database and components
"""

def all_sublattices_active(comps, phase):
active_sublattices = [len(set(comps).intersection(subl)) > 0 for
subl in phase.constituents]
return all(active_sublattices)

candidate_phases = dbf.phases.keys()
disordered_phases = [dbf.phases[phase].model_hints.get('disordered_phase') for phase in candidate_phases]
phases = [phase for phase in candidate_phases if
all_sublattices_active(comps, dbf.phases[phase]) and
phase not in disordered_phases]
return sorted(phases)
comps = ['AL', 'SI', 'VA']
phases = filter_phases(dbf, comps)
By the way, pycalphad does not implicitly define the VA component, and you probably mean to use it, so I included it in the example above.

Best,

Brandon


-- 
You received this message because you are subscribed to the Google Groups "pycalphad" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pycalphad+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pycalphad/7b8897d0-538b-4639-a873-a54d82968b86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

emanuel...@gmail.com

unread,
Nov 11, 2017, 7:26:12 PM11/11/17
to pycalphad
Hi Brandon,

thanks again. I have included the filter_phases function in my script and now I have two doubts.

1) It appears that the database that I am using at the moment does not include vacancies. In fact, including the line
comps = ['AL','SI','VA']

I obtain  and error terminating with

pycalphad
.core.equilibrium.EquilibriumError: Components not found in database: VA

So I suspect your suggestion (very appreciated) was generic and not specific to this case. I hope I'm not on the wrong path here.

2) The following revised script:

#!/usr/bin/python3
from pycalphad import Database, equilibrium
import pycalphad.variables as v



db
= Database('al-matcalc.tdb')

comps
= ['AL','SI']

phases
= filter_phases(db,comps)
eq
= equilibrium(db, comps, phases, {v.X('SI'): 0.07, v.P: 101325, v.T: 1053.15}, output=['enthalpy', 'entropy'])

returns the following error that I cannot decode:

/usr/local/lib/python3.5/dist-packages/dask/async.py:13: UserWarning: `dask.async.get_sync` has been moved to `dask.local.get_sync`, please update your imports
  warnings
.warn(_msg.format('get_sync'))

Traceback (most recent call last):

 
File "./pycalphad_minimal.py", line 40, in <module>
    eq
= equilibrium(db, comps, phases, {v.X('SI'): 0.07, v.P: 101325, v.T: 1053.15}, output=['enthalpy', 'entropy'])
 
File "/usr/local/lib/python3.5/dist-packages/pycalphad/core/equilibrium.py", line 358, in equilibrium
    properties
= dask.compute(properties, get=scheduler)[0]
 
File "/usr/local/lib/python3.5/dist-packages/dask/base.py", line 206, in compute
    results
= get(dsk, keys, **kwargs)
 
File "/usr/local/lib/python3.5/dist-packages/dask/async.py", line 14, in get_sync
   
return local.get_sync(*args, **kwargs)
 
File "/usr/local/lib/python3.5/dist-packages/dask/local.py", line 562, in get_sync
   
return get_async(apply_sync, 1, dsk, keys, **kwargs)
 
File "/usr/local/lib/python3.5/dist-packages/dask/local.py", line 529, in get_async
    fire_task
()
 
File "/usr/local/lib/python3.5/dist-packages/dask/local.py", line 504, in fire_task
    callback
=queue.put)
 
File "/usr/local/lib/python3.5/dist-packages/dask/local.py", line 551, in apply_sync
    res
= func(*args, **kwds)
 
File "/usr/local/lib/python3.5/dist-packages/dask/local.py", line 295, in execute_task
    result
= pack_exception(e, dumps)
 
File "/usr/local/lib/python3.5/dist-packages/dask/local.py", line 290, in execute_task
    result
= _execute_task(task, data)
 
File "/usr/local/lib/python3.5/dist-packages/dask/local.py", line 271, in _execute_task
   
return func(*args2)
 
File "/usr/local/lib/python3.5/dist-packages/dask/compatibility.py", line 47, in apply
   
return func(*args, **kwargs)
 
File "/usr/local/lib/python3.5/dist-packages/pycalphad/core/equilibrium.py", line 138, in _eqcalculate
    points
=points, broadcast=False, **statevars)
 
File "/usr/local/lib/python3.5/dist-packages/pycalphad/core/calculate.py", line 512, in calculate
    largest_energy
=float(largest_energy), fake_points=fp)
 
File "/usr/local/lib/python3.5/dist-packages/pycalphad/core/calculate.py", line 318, in _compute_phase_values
    phase_compositions
[..., :, col] = np.divide(np.dot(points[..., :, :], avector),
ValueError: shapes (1,7) and (2,) not aligned: 7 (dim 1) != 2 (dim 0)

Do I have a problem with the database?

Regards,

Emanuele

Brandon Bocklund

unread,
Nov 11, 2017, 7:27:56 PM11/11/17
to emanuel...@gmail.com, pycalphad
Yes, I was just speaking generally as most databases I have come across consider vacancies. If you don't have them, then what I wrote does not apply and you are correct.


emanuel...@gmail.com

unread,
Nov 14, 2017, 6:15:08 AM11/14/17
to pycalphad
Thanks Brandon.

Do you have any insight into the error at point 2 of my last reply?

I have tried to fiddle a bit with my script but I did not achieve anything. I have no idea about what is happening: if it's a problem of my script, of the database or in pycalphad. I think my lack of experience with python is playing a role in my confusion.

I would appreciate any pointers, if possible. Thanks you.

Regards,

Emanuele

Brandon Bocklund

unread,
Nov 14, 2017, 2:57:00 PM11/14/17
to pycalphad
Sorry, I missed the bottom half of your message before.

It seems to be a problem with the outputs. I am able to confirm that using the outputs=['enthalpy', 'entropy'] argument does work. On the other hand, I am able to get that to work as expected using another database.

I can narrow it down to even output='GM' works, but any other output does not.

emanuel...@gmail.com

unread,
Nov 14, 2017, 3:39:29 PM11/14/17
to pycalphad
Thanks Brandon.

It seems that there are no free databases that I can use for my purposes. Also COST507 seem to have problems.

Regards,

Emanuele

Brandon Bocklund

unread,
Nov 14, 2017, 3:56:08 PM11/14/17
to emanuel...@gmail.com, pycalphad
The attached database and following code seems to work for me.

With regard to the large databases like cost, matcalc, etc., it seems that simple is better because the large ones use many specialized features specific to the software.

from pycalphad import Database, equilibrium
import pycalphad.variables as v


db = Database('Al-Si_mey.tdb')
comps = ['AL', 'SI']
phases = list(db.phases.keys())
eq = equilibrium(db, comps, phases, {v.X('SI'): 0.07, v.P: 101325, v.T: 1053.15}, output=['enthalpy', 'entropy'])
print(eq)

Al-Si_mey.tdb

emanuel...@gmail.com

unread,
Nov 14, 2017, 4:10:35 PM11/14/17
to pycalphad
Wow, thank you very much! It worked!

I can see this is linked to a publication. Can I ask you where did you find the database? It is usually published together with papers? This is what I hoped, but I didn't have luck so far. If you could give me only some pointers, I may be able to find what I need on a more specific case to case basis.

Thanks again, Brandon! You made my evening! :)

Emanuele

Brandon Bocklund

unread,
Nov 14, 2017, 4:26:06 PM11/14/17
to emanuel...@gmail.com, pycalphad
Publishing TDB files with databases has only become common since ~2014.

This, many binaries, some ternaries can be found at NIMS (http://cpddb.nims.go.jp/cpddb/periodic.htm) (requires free sign up)



-- 
You received this message because you are subscribed to the Google Groups "pycalphad" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pycalphad+...@googlegroups.com.

emanuel...@gmail.com

unread,
Nov 14, 2017, 4:28:52 PM11/14/17
to pycalphad
Thank you very much.

Emanuele

Brandon Bocklund

unread,
Nov 14, 2017, 4:34:40 PM11/14/17
to emanuel...@gmail.com, pycalphad
No problem! Feel free to let us know if you need more help on here or in the pycalphad Gitter channel - https://gitter.im/pycalphad/pycalphad

Brandon


Reply all
Reply to author
Forward
0 new messages