Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate gives the wrong result if pressure and temperature are not both specified. #116

Closed
bocklund opened this issue Aug 3, 2017 · 3 comments
Assignees
Labels
bug
Milestone

Comments

@bocklund
Copy link
Collaborator

@bocklund bocklund commented Aug 3, 2017

In the binary example, we see the following code produce this plot

from pycalphad import calculate
from pycalphad.plot.utils import phase_legend
import numpy as np

legend_handles, colorlist = phase_legend(my_phases_nbre)

fig = plt.figure(figsize=(9,6))
ax = fig.gca()
for name in my_phases_nbre:
    result = calculate(db_nbre, ['NB', 'RE'], name, T=2800, output='GM')
    ax.scatter(result.X.sel(component='RE'), result.GM,
               marker='.', s=5, color=colorlist[name.upper()])
ax.set_xlim((0, 1))
ax.legend(handles=legend_handles, loc='center left', bbox_to_anchor=(1, 0.6))
plt.show()

image

But changing the temperature to 300 or 1000000 gives the same plot (and the same values from calculate). If you specify pressure in calculate e.g. result = calculate(db_nbre, ['NB', 'RE'], name, T=2800, P=101325, output='GM') the resulting plot is
image

Further changes to temperature produce expected results. The energy surface plotted when P is not specified gives a similar result to T>=6000 (piecewise max in TDB). I assume this is a bug and not the intended result?

@amjokisaari
Copy link

@amjokisaari amjokisaari commented Sep 26, 2017

Please make this throw an error if something isn't specified, instead of silently calculating the wrong thing, as suggested by @richardotis.

@richardotis
Copy link
Collaborator

@richardotis richardotis commented Nov 5, 2017

In https://github.com/pycalphad/pycalphad/blob/develop/pycalphad/core/calculate.py#L428
The assigned values to statevar_dict need to be wrapped with a call to unpack_condition()
That should fix it.

@richardotis
Copy link
Collaborator

@richardotis richardotis commented Nov 5, 2017

That does not fix the issue. Still investigating.

richardotis added a commit that referenced this issue Nov 5, 2017
…ariables is left as default. Fixes gh-116.
richardotis added a commit that referenced this issue Nov 12, 2017
…ariables is left as default. Fixes gh-116.
richardotis added a commit that referenced this issue Nov 12, 2017
…ariables is left as default. Fixes gh-116. (#140)
richardotis added a commit that referenced this issue Nov 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.