Failed while parsing database

295 views
Skip to first unread message

emanuel...@gmail.com

unread,
Nov 9, 2017, 3:10:56 PM11/9/17
to pycalphad
Hello,

I am trying to import a Matcalc open database. Specifically, this one:
http://matcalc.tuwien.ac.at/images/stories/Download/Database/mc_al_v2.029.tdb

I had to re-encode it to utf-8 first and now it reads:
$ file -bi mc_al_v2.029_utf8.tdb
text
/plain; charset=utf-8

However, this is the error that I obtain:

Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> from pycalphad import Database, calculate
>>> db = Database('mc_al_v2.029_utf8.tdb')
Failed while parsing:  ELEMENT CU FCC_A1 63.546 5004. 33.15
Tokens: None
Traceback (most recent call last):
 
File "<stdin>", line 1, in <module>
 
File "/usr/local/lib/python3.4/dist-packages/pycalphad/io/database.py", line 128, in __new__
   
return cls.from_file(fname, fmt=fmt)
 
File "/usr/local/lib/python3.4/dist-packages/pycalphad/io/database.py", line 222, in from_file
    format_registry
[fmt.lower()].read(dbf, fd)
 
File "/usr/local/lib/python3.4/dist-packages/pycalphad/io/tdb.py", line 845, in read_tdb
    tokens
= _tdb_grammar().parseString(command)
 
File "/usr/lib/python3/dist-packages/pyparsing.py", line 1041, in parseString
   
raise exc
 
File "/usr/lib/python3/dist-packages/pyparsing.py", line 1031, in parseString
    loc
, tokens = self._parse( instring, 0 )
 
File "/usr/lib/python3/dist-packages/pyparsing.py", line 962, in _parseCache
    value
= self._parseNoCache( instring, loc, doActions, callPreParse )
 
File "/usr/lib/python3/dist-packages/pyparsing.py", line 905, in _parseNoCache
    loc
,tokens = self.parseImpl( instring, preloc, doActions )
 
File "/usr/lib/python3/dist-packages/pyparsing.py", line 2412, in parseImpl
   
raise maxException
 
File "/usr/lib/python3/dist-packages/pyparsing.py", line 2398, in parseImpl
    ret
= e._parse( instring, loc, doActions )
 
File "/usr/lib/python3/dist-packages/pyparsing.py", line 962, in _parseCache
    value
= self._parseNoCache( instring, loc, doActions, callPreParse )
 
File "/usr/lib/python3/dist-packages/pyparsing.py", line 905, in _parseNoCache
    loc
,tokens = self.parseImpl( instring, preloc, doActions )
 
File "/usr/lib/python3/dist-packages/pyparsing.py", line 2288, in parseImpl
    loc
, exprtokens = e._parse( instring, loc, doActions )
 
File "/usr/lib/python3/dist-packages/pyparsing.py", line 962, in _parseCache
    value
= self._parseNoCache( instring, loc, doActions, callPreParse )
 
File "/usr/lib/python3/dist-packages/pyparsing.py", line 909, in _parseNoCache
    loc
,tokens = self.parseImpl( instring, preloc, doActions )
 
File "/usr/lib/python3/dist-packages/pyparsing.py", line 2068, in parseImpl
   
raise ParseException(instring, loc, self.errmsg, self)
pyparsing
.ParseException: Expected end of line (at char 30), (line:1, col:31)

I am clueless about the problem that is causing the error.

Any idea?

Regards,

Emanuele

Brandon Bocklund

unread,
Nov 9, 2017, 4:17:58 PM11/9/17
to emanuel...@gmail.com, pycalphad
Hi Emanuele,

You found a bug!

The problem is that the CU entropy ends in a decimal point with no number after and is not being parsed as a float!
If you fix this as well as the same problem in Si, you will be on your way.

There are some other issues with parsing this TDB which I have addressed below I attached a TDB with all of these things fixed that is properly parsed by pycalphad so you do not have to do it!

Matcalc databases also have some special syntax that is not part of the typical Thermo-Calc TDB which we typically standardize our parsing on.

You'll have to comment out 

REFERENCE_ELEMENT AL !
ATTACH_CONTRIBUTION GP_MAT FCC_A1 ORDER_DISORDER !
ADD_COMPOSITION_SET TH_DP_GPB :MG:MG:AL:CU:CU: !

All the HMVA parameters, e.g.
PARAMETER HMVA(FCC_A1,AL:*;0) 273.00 +64200; 6000.00  N
REF:pov10 !

Everything after the sublattice definition in the PHASE keyword, e.g.

 PHASE LIQUID % 1  1.0 > 
Random substitutional model. 
>>  !

Must become 

 PHASE LIQUID % 1  1.0  !

The SE parameter must be removed

PARAMETER SE(GP_MAT) 273.00 +0.1; 6000.00  N
REF:koze12 !

Finally, extraneous 0s in the sigma phase end temperature must be removed

PARAMETER G(SIGMA,FE:CR:FE;0) 273.00 +117300-95.96*T+8*GFEFCC#
   +4*GHSERCR#+18*GHSERFE#; 6000.00.00  N
REF:20 !

to 6000.00

In summary:

- I'll open an issue for the float parsing bug
- I don't know if pycalphad will support the special matcalc syntax. Things like the ADD_COMPOSITION_SET have no meaning in pycalphad. I am not sure if we should support comments in the phases after the ">" or what the HMVA/SE parameters mean.

Thank you,

Brandon Bocklund


al-matcalc.tdb

emanuel...@gmail.com

unread,
Nov 10, 2017, 10:27:35 AM11/10/17
to pycalphad
Thanks Brandon!

I'm glad I've been of help and I'm very grateful to you for attaching the fixed TDB database.

Unfortunately, I still haven't had time to test it and I'll report back soonest.

Cheers,

Emanuele

emanuel...@gmail.com

unread,
Nov 10, 2017, 2:05:40 PM11/10/17
to pycalphad
Just to confirm that the attached file works, thanks Brandon!

I've run into another problem now and I'll open another thread.

Regards,


Emanuele


On Thursday, 9 November 2017 21:17:58 UTC, Brandon Bocklund wrote:

Jeff Sowards

unread,
Feb 7, 2021, 10:42:12 PM2/7/21
to pycalphad
Hello Brandon, 

I stumbled across this conversation, and I'm curious, have you fixed the Fe and Ni Matcalc databases so that they are also compatible with pycalphad?  Would you be willing to share or point me in a direction to do this?

Thanks,
Jeff

Richard Otis

unread,
Feb 8, 2021, 4:07:27 PM2/8/21
to Jeff Sowards, pycalphad
Hi Jeff,

I've attached the Matcalc Al, Fe, and Ni databases which have been modified to work with pycalphad. Please note that, other than a few spot checks, we haven't validated these databases, either to ensure they get the same energetics as Matcalc, or that they are physically accurate. Use at your own risk, and we would appreciate hearing from you and other users on your experiences using them.

Thanks,
Richard

From: pyca...@googlegroups.com <pyca...@googlegroups.com> on behalf of Jeff Sowards <jwso...@gmail.com>
Sent: Sunday, February 7, 2021 10:42 PM
To: pycalphad <pyca...@googlegroups.com>
Subject: Re: Failed while parsing database
 
--
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/e1eb36d7-a33c-487c-8521-768e9a508483n%40googlegroups.com.
mc_al_v2.032.pycalphad.tdb
mc_fe_v2.059.pycalphad.tdb
mc_ni_v2.034.pycalphad.tdb

Jeff Sowards

unread,
Feb 9, 2021, 11:38:48 PM2/9/21
to pycalphad
Hi Richard,

Thanks for sharing these databases here and for getting pycalpad out to the community.

I ran a few quick calcs with the Fe database.  Once I make some validations against experimental data and against some calculations made with other Fe databases, I'll be sure to report out anything noteworthy.  I wasn't so lucky with the Al and Ni Matcalc databases, e.g., getting some unicode errors when I try to run calcs (just FYI below).

Ni Database: 
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 367499: invalid start byte
Al Database: 
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 88859: invalid start byte

Also, I couldn't open either of the above db files in my Jupyter lab book as I usually do (error below just FYI).

File Load Error for mc_al_v2.032.pycalphad.tdb 
/Users/test/mc_al_v2.032.pycalphad.tdb is not UTF-8 encoded

I've tried resaving as UTF-8 in OSX text editor, etc.  Still no luck so far.

Thanks,
Jeff
 

Richard Otis

unread,
Feb 11, 2021, 10:55:02 AM2/11/21
to Jeff Sowards, pycalphad
Hi Jeff,

I think this bug should be fixed in the latest version of pycalphad, but in any case you can work around it by writing

dbf = Database(open('mc_al_v2.032.pycalphad.tdb', encoding='latin-1').read())


Thanks,
Richard

Sent: Tuesday, February 9, 2021 11:38 PM

Jeff Sowards

unread,
Feb 11, 2021, 10:21:42 PM2/11/21
to pycalphad
Thanks, Richard.  That did it.  I'm running 0.8.3.  I guess it's time for me to try an update.

Since the traffic is light here, and since I found the gitter, I'll move over to there for any future discussions.

Best,
Jeff

Stefan Culic

unread,
Apr 15, 2021, 5:42:03 AM4/15/21
to pycalphad
Hi Richard,

I have just installed pycalphad with the newest version and tried the same code you wrote to Jeff Sowards,
"
Hi Jeff,

I think this bug should be fixed in the latest version of pycalphad, but in any case you can work around it by writing

dbf = Database(open('mc_al_v2.032.pycalphad.tdb', encoding='latin-1').read())
"

but when i try to use the database to calculate an Al phase-diagram it shows me a ParseException Error.


error_1.png
error_2.png
I was wondering, could you maybe try to do a calculation with my "setup" and see if you can get it running and tell me the mistake??

I want to plot the Al-Mg phase-diagram with this database (looking through the database the necessary files/equations for that should be inside of the database)

Would appreciate any advice/help from your side!!!

Thaaaanks!!!!

Brandon Bocklund

unread,
Apr 15, 2021, 11:06:26 AM4/15/21
to pycalphad
I re-encoded all three databases as UTF-8 and attached them here for anyone coming along later. They parse correctly using pycalphad 0.8.4 using the usual Database constructor:

dbf = Database("<filename>")

Cheers,
Brandon

mc_al_v2.032.pycalphad.tdb
mc_fe_v2.059.pycalphad.tdb
mc_ni_v2.034.pycalphad.tdb

Max P

unread,
Dec 10, 2021, 2:14:09 AM12/10/21
to pycalphad
Dear Brandon! 

Sorry to bring this up again. I just yesterday learned about pycalphad wanted to try an equilibrium calculation. 

I'm using the version 0.9.2 (in an Anaconda environment), but I still seem to have the ParseException that is being talked about above. 

I used your attached databases and a very simple code.

from pycalphad import Database, equilibrium, variables as v


db = Database('mc_fe_v2.059.pycalphad.tdb')

#db = Database(open('mc_fe_v2.059.pycalphad.tdb', encoding='latin-1').read())

comps = ['FE', 'C', 'VA']  # note VA added

phases = ['BCC_A2', 'FCC_A1', 'CEMENTITE', 'LIQUID']
param = {v.X('C'):0.005, v.T:(600,1300,50), v.P:101325}


eq = equilibrium(db, comps, phases, param)
print(eq)
print(eq.Phase)

Do you know what might be the problem?

Any input would be greatly appreciated!

Thanks and cheers,
Max

Reply all
Reply to author
Forward
0 new messages