Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 10 18:46
    bocklund commented #5
  • Jun 10 18:45
    bocklund commented #5
  • Jun 10 18:45
    bocklund commented #5
  • Jun 08 20:59

    github-actions[bot] on website

    DOC: Deploy latest docs to webs… (compare)

  • Jun 08 20:56

    bocklund on develop

    MAINT: Refactor solver internal… (compare)

  • Jun 08 20:56
    bocklund closed #357
  • Jun 08 20:54
    richardotis commented #357
  • Jun 08 20:50
    bocklund commented #357
  • Jun 08 20:35
    codecov[bot] commented #357
  • Jun 08 20:23
    codecov[bot] commented #357
  • Jun 08 20:23
    bocklund synchronize #357
  • Jun 08 15:17
    richardotis commented #357
  • Jun 08 13:37
    bocklund review_requested #357
  • Jun 08 03:39
    bocklund edited #319
  • Jun 08 03:38
    codecov[bot] commented #357
  • Jun 08 03:37
    bocklund edited #357
  • Jun 08 03:32
    codecov[bot] commented #357
  • Jun 08 03:24
    bocklund synchronize #357
  • Jun 08 03:23
    bocklund opened #357
  • Jun 07 15:13
    bocklund labeled #356
Richard Otis
@rotis:matrix.org
[m]
Multi component visualization is a hard problem, even with the commercial tools. My suggestion is to try a phase amount versus temperature plot at a fixed composition, or maybe pick a few interesting compositions.
davidkleiven
@davidkleiven
Thanks, I will try that
george-ts-github
@george-ts-github

Hi everyone, I am a beginner at pycalphad and am running into this error with the example code:

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

dbf = Database('mmc1.tdb')
comps = ['NI', 'TI']
calc_result = calculate(dbf, 'FCC_A1', comps, P=101325, T=[500, 1000])
print(calc_result)

The error I get is:
Failed while parsing: PARAMETER G(FCC_A1,FE:VA;0) 2.98150E+02 10; 6.00000E+03 N
Tokens: None

And at the very end of the error sequence:
ValueError: Expression from TDB file not in whitelist: 0

The tdb database is from https://avdwgroup.engin.brown.edu/ > (Fe,Ni,Ti Zhou et al. (2015) (kinetic))

Could you pls help with this?

1 reply
hjy4090
@hjy4090

Hi, I am trying to use Scheil simulation by pycalphad.
I am using Python 3.8.8 version and 0.8.4 version of pycalphad.
I runned the given example of Al-Zn without any problem. But after I tried to use the code with different data, I got the error messages.
Could you help me with this?

tdb data: [2008Wit] The Al-B-Nb-Ti system Ⅲ.Thermodynamic re-evaluation of the constituent binary system Al-Ti,V.T.Witusiewicz, A.A.Bonder, U.Hecht, S.Rex, T.Ya.Velikanova, J. Alloys Compd. 465 (2008) 64-77.

import matplotlib.pyplot as plt
from pycalphad import Database, variables as v
from scheil import simulate_scheil_solidification

dbf = Database('alti_wit-2.tdb')
comps = ['AL', 'TI', 'VA']
phases = sorted(dbf.phases.keys())

liquid_phase_name = 'LIQUID'
initial_composition = {v.X('TI'): 0.3}
start_temperature = 1900

sol_res = simulate_scheil_solidification(dbf, comps, phases, initial_composition, start_temperature, step_temperature=1.0)

for phase_name, amounts in sol_res.cum_phase_amounts.items():
plt.plot(sol_res.temperatures, amounts, label=phase_name)
plt.plot(sol_res.temperatures, sol_res.fraction_liquid, label='LIQUID')
plt.ylabel('Phase Fraction')
plt.xlabel('Temperature (K)')
plt.title('AL-30TI Scheil simulation, phase fractions')
plt.legend(loc='best')
plt.show()

Here is the error:


UnicodeDecodeError Traceback (most recent call last)

<ipython-input-30-63b6e2bf5283> in <module>
3 from scheil import simulate_scheil_solidification
4
----> 5 dbf = Database('alti_wit-2.tdb')
6 comps = ['AL', 'TI', 'VA']
7 phases = sorted(dbf.phases.keys())

~/opt/anaconda3/envs/calphad/lib/python3.8/site-packages/pycalphad/io/database.py in new(cls, *args)
117 elif fname.find('\n') == -1:
118 # Single-line string; it's probably a filename
--> 119 return cls.from_file(fname, fmt=fmt)
120 else:
121 # Newlines found: probably a full database string

~/opt/anaconda3/envs/calphad/lib/python3.8/site-packages/pycalphad/io/database.py in from_file(fname, fmt)
211 try:
212 dbf = Database()
--> 213 format_registry[fmt.lower()].read(dbf, fd)
214 finally:
215 # Close file descriptors created in this routine

~/opt/anaconda3/envs/calphad/lib/python3.8/site-packages/pycalphad/io/tdb.py in read_tdb(dbf, fd)
921 File descriptor.
922 """
--> 923 lines = fd.read()
924 lines = lines.replace('\t', ' ')
925 lines = lines.strip()

~/opt/anaconda3/envs/calphad/lib/python3.8/codecs.py in decode(self, input, final)
320 # decode input (taking the buffer into account)
321 data = self.buffer + input
--> 322 (result, consumed) = self._buffer_decode(data, self.errors, final)
323 # keep undecoded input until the next call
324 self.buffer = data[consumed:]

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x87 in position 498: invalid start byte

Richard Otis
@rotis:matrix.org
[m]
Try dbf = Database(open('alti_wit-2.tdb', encoding='latin-1).read())
Sometimes there are incorrectly encoded characters in the references section of TDB files
Well, maybe not incorrect, but they don't conform to the UTF-8 standard
Richard Otis
@rotis:matrix.org
[m]
:point_up: Edit: Try dbf = Database(open('alti_wit-2.tdb', encoding='latin-1').read())
hjy4090
@hjy4090
Thank you for your help. Now it works fine.
stefanc88
@stefanc88
error_1.png
error_2.png

Hi guys,

I have just installed pycalphad with the newest version and tried the same code to calculate the phase-diagram of Al-Zn you used in the examples on your site for pycalphad, however, i wanted to use a different Al-database

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

Database: mc_al_v2.032.pycalphad.tdb

i also used encoding "latin-1" because i thought there might by some charater issues why the programm can't read it.

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

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
@bocklund:matrix.org
[m]
@stefanc88: does this one work for you? I re-encoded it to UTF-8, so you should be able to just do dbf = Database("mc_al_v2.032.pycalphad.tdb"). I tested locally using pycalphad version 0.8.4 and it works for me.
Richard Otis
@rotis:matrix.org
[m]
That is not the correct modified database. The corrected databases do not have the phase descriptions
Brandon Bocklund
@bocklund:matrix.org
[m]
What version of pycalphad are you using?
import pycalphad
print(pycalphad.__version__)
Lines like PHASE LIQUID % 1 1.0 > Random substitutional model. >> 6 ! can be read as of pycalphad 0.8.4
stefanc88
@stefanc88

hi brandon, it works now, i deinstalled the previous version and installed the newest one, it works now!!

just out of curiosity, it takes now several minutes to calcualte the phase-diagram with your mc_al_v2.032.tdb database (i calculated the Al-Mg phase diagram) whereas it took me some 20-30 seconds if i only had the "pure" Al-Mg database, does the calculation time change now simply because the program has to go through a larger database or is there a different reason to that??

Nevertheless many thanks you for your help!!

Brandon Bocklund
@bocklund:matrix.org
[m]

Great, I’m glad it’s working!

My guess is that the slowness could be due to the phases you are passing in. Are you setting phases = list(dbf.phases.keys())? The MatCalc database will have many more active candidate phases which are metastable and will add computational expense.

Does it take several minutes to calculate the diagram a second time too? Before the first equilibrium calculations, pycalpjad needs to compile Gibbs energy functions and derivatives for every phase, which can add some startup time for the first time you run an equilibrium calculation. The results are cached, so subsequent calls to equilibrium/binplot won’t require paying that startup cost again during the same session.

tniac
@tniac:matrix.org
[m]
Hi, does anyone know what happens to https://avdwgroup.engin.brown.edu/ ???
I can't access the site
Brandon Bocklund
@bocklund:matrix.org
[m]
I'm not sure, it appears down for me too. It might be good to reach out to Axel via email
Marat Latypov
@latmarat
Hi @richardotis, when are your office hours? I am interested exploring dash GUI.
Richard Otis
@rotis:matrix.org
[m]
@latmarat: Thanks for reaching out. Since the last time I mentioned this issue, I've done some additional exploration and developed an alternative GUI approach based on jupyterlab-starters: https://github.com/deathbeds/jupyterlab-starters
Is that still interesting to you, or are you really looking more towards what's possible in dash
Marat Latypov
@latmarat
Yes, I am more interested in exploring what pycalphad can do together with modern UX platforms
Richard Otis
@rotis:matrix.org
[m]
You are latmarat on GitHub?
Marat Latypov
@latmarat
Yes
Richard Otis
@rotis:matrix.org
[m]
Do you have a UCSB email address?
2 replies
Or rather, you can tell me the domain name of your preferred email address. I'll add you to the system by email
Richard Otis
@rotis:matrix.org
[m]
You've been invited to this private repo https://github.com/richardotis/pycalphad-starters and if you want to see what it looks like so far all integrated together, you can go to https://hubsource.cloud/services/binder/v2/gh/richardotis/pycalphad-starters/main (sign in with that email)
Marat Latypov
@latmarat
thank you
Richard Otis
@rotis:matrix.org
[m]
Sure. I do office hours on Mondays, 3-6pm PT, until the middle of May. I'm also reachable by appointment, which is good since my students often come to office hours
Brandon Bocklund
@bocklund:matrix.org
[m]
The TDBDB is back up now: https://avdwgroup.engin.brown.edu. cc tniac
stefanc88
@stefanc88
AL_SI_plot.png
stefanc88
@stefanc88

Hello Brandon,

i tried the procedure you suggested in this post:

"Great, I’m glad it’s working!

My guess is that the slowness could be due to the phases you are passing in. Are you setting phases = list(dbf.phases.keys())? The MatCalc database will have many more active candidate phases which are metastable and will add computational expense.

Does it take several minutes to calculate the diagram a second time too? Before the first equilibrium calculations, pycalpjad needs to compile Gibbs energy functions and derivatives for every phase, which can add some startup time for the first time you run an equilibrium calculation. The results are cached, so subsequent calls to equilibrium/binplot won’t require paying that startup cost again during the same session. "

It took the same amount of time for multiple runs, i calculated the AL:Si phase diagram, it took 1:27 minutes for the calcualtion with all variaties of settings.

I have one question concerning the data which is calculated and then plotted using the script i posted in the screenshot, is there a way to get the data which is plotted in an array or something similar, for a simulation i need the data of the liqidus and solid-lines (temperature, composition-points or intervals) is there a way to get those??

Additionally, for all the phase diagrams I have calculated-plotted so far it looks that alway a certain part of the phase-diagram is missing in the plot (in the screenshot for example the liqidusline in the left part of the phase-diagram is not visible, i had the same issue for all other plots) is this a sort of "resolution-problem" during plotting, that the data was calculated but couldn't be properly plotted??

thank you!!!!

1 reply
Richard Otis
@rotis:matrix.org
[m]
@stefanc88: It is possible to extract the phase boundaries, though you have to do a little array hacking to make it work. I'll attach something I used recently to make plotly plotting of binary phase diagrams work
from pycalphad.plot.binary.map import map_binary
from pycalphad.plot.utils import phase_legend
import numpy as np

boundary_sets = map_binary(dbf, comps, phases, conds)
_, phase_dict = phase_legend(sorted(boundary_sets.get_phases()))
color_to_phase = {v: k for k, v in phase_dict.items()}
boundaries = boundary_sets.get_scatter_plot_boundaries()[0]
compositions = np.array(boundaries['x'])
temperatures = np.array(boundaries['y'])
phase_colors = boundaries['c']
phase_names = np.array([color_to_phase[color] for color in phase_colors])

for phase in boundary_sets.get_phases():
    phase_indices = np.argwhere(phase_names == phase).flatten()
    if len(phase_indices) == 0:
        continue
    phase_color = phase_dict[phase]
    phase_compositions = compositions[phase_indices]
    phase_temps = temperatures[phase_indices]
    # do what you want with these
    x = phase_compositions
    y = phase_temps
Brandon Bocklund
@bocklund:matrix.org
[m]
FYI: the boundaries you get back from the code Richard shared are going to give you the phase compositions for the fixed temperatures on your condition grid (v.T: (300, 2800, 10)). If that's not what you need, let us know and we can help you get the data you're after
stefanc88
@stefanc88
Sheill_Gulliver_error.png

Hi Richard and Brandon,

@ Richard: thanks for your code, i was able to plot the results to a CSV-file that was exactly what i was looking for!!!

I have an additional question. I tried your Sheill-Gulliver script which you use, i changed the primary settings to this:

"""
import matplotlib.pyplot as plt
from pycalphad import Database, variables as v
from scheil import simulate_scheil_solidification

setup the simulation parameters

dbf = Database("mc_al_v2.032.pycalphad.tdb")
comps = ['AL', 'MG', 'VA']
phases = sorted(dbf.phases.keys())

liquid_phase_name = 'LIQUID'
initial_composition = {v.X('MG'): 0.1}
start_temperature = 850

perform the simulation

sol_res = simulate_scheil_solidification(dbf, comps, phases, initial_composition, start_temperature, step_temperature=1.0)

plot the result

for phase_name, amounts in sol_res.cum_phase_amounts.items():
plt.plot(sol_res.temperatures, amounts, label=phase_name)
plt.plot(sol_res.temperatures, sol_res.fraction_liquid, label='LIQUID')
plt.ylabel('Phase Fraction')
plt.xlabel('Temperature (K)')
plt.title('Al-30Zn Scheil simulation, phase fractions')
plt.legend(loc='best')
plt.show()

"""
so I changed the settings from 'ZN' to 'MG' and the amount of MG to 0.1 percent but got this error_message:

"UnboundLocalError: local variable 'current_fraction_solid' referenced before assignment"

any clue what might cause this error message??

Many Thanks!!!

Richard Otis
@rotis:matrix.org
[m]
That error could be hiding a convergence failure in the calculation. The easiest way to check would be to try perturbing the initial composition a little bit. I'd also try doing a call to equilibrium at the initial composition and temperature to see if it converges.
Kim, Young Gee::Bases Q++
@wegLwLoDay27ePN_twitter
Hi.
I am a newbie.
I have experienced to code.
But I do not know CALPHAD method well.
what a tutorial course ?
1 reply
stefanc88
@stefanc88
error_Al_MG.png
al_mg_error.png
stefanc88
@stefanc88
grafik.png

Hello Richard,

i tried to use your advice on the sheill-gulliver problem in which you think convergence could be an issue, could you give me the code-instructions on how to use "equilibrium" to see if temperature and initial composition converge?? Is there also some way to get the data from the curves which are plotted?? I would like to have the data of the solid-liquid fraction plotted in columns (csv.file or txt.file or whatever file-format).

Additionally, i tried to use your code-snippet which you provided me to calculate the values along the lines of the phase-diagram and got an error once i decreased the temperature-step to 1K:

"ValueError: cannot copy sequence with size 4 to array axis with dimension 3"

(or sometimes i get a similar error when i change the concentration-step), what could be the cause of this problem?

in addition, the composition-temperature i get with your code-snippet sometimes has some "jumps" in the concentration at certain points, what could be the reason for that?? i hope you can see how the concentration in the window with the csv.file drops from roughly 1.65% to almost zero for several lines and then jumps back to roughly 1.65 %. It also seems that i cannot get all the values of liquidus-solidus lines of the phase diagram with the code-snippet, i would need the characteristic points of the phase diagram:
maximum solubility [%]
eutectic-concentration [%]
eutectic-temperature [K]
temperature of the pure metal [K]

is it somehow able to get those values??

Thanks a lot!!

stefanc88
@stefanc88
or could brandon maybe anwer my questions??
Richard Otis
@rotis:matrix.org
[m]
pycalphad 0.9.0 is now released! Check it out: https://pycalphad.org/docs/latest/CHANGES.html
Highlights (see link above for longer list):
  • A brand new energy minimizer
  • You can now pip install -U pycalphad on all platforms
stefanc88
@stefanc88

Hi Brandon and Richard,

do you by any chance know, how I can calculate the quasi-binary phase diagram of Al-Mg2Si ??

what do I have to type in in COMPS = ['AL', 'Here Mg2Si should be entered', 'VA'] in order to be able to do some calculations with the 6xxx alloy-group?? All my trials gave me error-messages and aborts so far......

Thank you guys!!!!

1 reply