0% found this document useful (0 votes)
13 views11 pages

Macros OC7

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views11 pages

Macros OC7

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

OpenCalphad examples version 7

Bo Sundman, last update March 22, 2021


email: [email protected]

This is a short description of the macro files used to test and to demonstrate the facilities of
this version of OpenCalphad (OC). The macro files and the necessary datafiles are provided
with the software.

1 Introduction
OpenCalphad is an initiative of a group of scientists interested to develop a free software
for thermodynamic calculations in multicomponent systems. A setupfile for Windows can be
downloaded from
http://www.opencalphad.org
For Linux, MacOS or to use the OC Applications Software Interface (OCASI) the source code
can be downloaded from the opencalphad repository at
http://www.github.com/sundmanbo/opencalphad
There is extensive documentation and some publications[15Sun1, 15Sun2, 16Sun] describing
OC. For a general description of the Calphad technique and application please read [98Sau] and
for a description of thermodynamic modeling and assessments see [07Luk]. For a comprehensive
introduction to thermodynamics see [08Hil].
The OC software is modular and includes

ˆ basic libraries for numerics and user interaction,

ˆ the General Thermodynamic Package (GTP) for thermodynamic models,

ˆ the Hillert Minimizer Software (HMS) for equilibrium calculations,

ˆ the Step, Map and Plot (SMP) package for step, map and plotting connected to the
GNUPLOT graphical software,

ˆ the assessment facilities (part of several modules) for assessment of experimental and
theoretical data in terms of thermodynamic model parameters,

1
ˆ the Application Software Interface (OCASI) to provide thermodynamic data to other
software including multi-threading and an isoC binding for C++ and other programming
languages.

The software code is free with a GNU GPL license. Most of the software is written in the
new Fortran 08 standard. Any skilled programmer interested to use it in applications, develop
or add to the software is welcome. The software has been tested for use in parallel with the
OpenMP standard. Anyone interested in using OC in commercial software has to contact the
copyright owner for another type of license.
The graphics are generated by GNUPLOT, which is another free software the user must install
separately. The OC software creates a command and data file, ocgnu.plt, that can be run by
GNUPLOT from the OC software. One a few of all facilities provided by GNUPLOT has been
implemented in OC but the ocgnu.plt file can be edited for users who are interested to explore
the extensive facilities of GNUPLOT.
OC has a classical command interface, there is no “click and run” facility. If you prefer that
you are welcome to develop one for OC or use a commercial software.
The macro files contain commands to execute the OC software. The macros are useful to
learn how to calculate various things. They contain comment lines, which start with “@$”
and the macro will pause at lines with a,“@&”. Depending on the OS and the graphics driver
installed with GNUPLOT the user may have to click in the graphical window to continue after
each plot.
The macros described here are regularly used to test for errors in the software during the
development. There is a “super macro” all.OCM which executes all the macros. As shown by
the examples there are still many more problems inside OC to fix. Note that some examples
perform differently using different compilers and operating system. The development of OC
has been on a Windows system using MinGW and GNU Fortran but regular tests on a Linux
systems are made.

2 Macro examples
Changes in the command structure (new commands, new questions etc) require changes in the
macro files and old macro files many not work on a new release and vice versa. This is the set
used for version 7 of OC.
After installing OC please verify your installation by executing some of the macros. The
database files needed are provided with the macro files.
Many of the macros generate diagrams and a few figures are also shown. The name of the
macro is the heading of each description.
Phase diagram calculations now work quite well but are sensitive to the start point. There
can always be some lines missing or lines representing metastable extrapolations.

1. Unary This macro shows some calculations for pure Fe.

2
2. Testcond1 This macro shows the flexibility to set conditions for a multicomponent sys-
tem and how to calculate a T0 point and a metastable NPLE equilibrium. Many thermo-
dynamic software does not allow is to set the mole fraction of a phase as condition for
a calculation but that works with OC. There is a test setting the reference state for the
components, setting a phase fix, checking how the driving force for a metastable phase
changes with conditions and using enthalpy as condition.

3. Melting Calculations of equilibria in a multicomponent steel using different kinds of


conditions. As the previous example it shows the flexible way of setting conditions. First
a straightforward calculation with T, P and mole fractions. The command calculate
transition is used to calculate the melting temperature directly.
Then the carbon content of the fcc phase, x(fcc,c), is set as condition rather than the
overall carbon content, x(c). Then we set the status of the liquid phase as fix with zero
amount, and the condition on T is released to calculate the new melting T . Then the
current value of the enthalpy, H, is set as condition and the size of the system, N is
released. The equilibrium of the system does not change, just the way we control the
system.
In the final calculation the enthalpy of the system is changed and the system response is
to change its size, because all other conditions are potentials that is the only way it can
change its enthalpy.

4. Save A nice facility in OC is the possibility to save a calculation on a file and then read
in back and continue the calculations. The file is written as “unformatted” and can only
be read by OC. All thermodynamic data, and conditions for all entered equilibria are
saved but not yet results from STEP or MAP.

5. Parallel2 In this macro some 400 equilibria are entered using the enter many equilibria
command. They are then calculated in parallel (by the parallel version of OC linked with
OpenMP). On a PC with 4 kernels and 8 threads the gain in speed is more than a factor
of 3 and there are no significant memory leaks.

6. Allcost This macro calculates a few equilibria with the largest free database I have
access to, from the light alloy assessment project COST507. The quality of the database
is questionable for multicomponent calculations but many binary and ternary systems
are well assessed. The interest was to test OC calculations with a very large system, 20
elements and 191 phases.

7. Step1 A similar steel like in the example 3 is used. In these steels there is normally a cubic
carbide stable and this is described by the same model for FCC phase as the austenite.
To make it easier to identify these two phases we can enter a second composition set with
additional pre- and suffixes and predefined default composition limits. The software will
try to find the composition set with closest default composition if it has two composition
sets stable for a phase. We must then also set a default composition for the austenite
(the first composition set).

3
When we list the result after the equilibrium calculation we find two FCC phases, one
with the MC prefix which is high in carbon. That is the cubic carbide, the other FCC
phase is the austenite.
Then we set T as an axis variable with the limits 800 and 1800 K and an increment of
10 K and calculate equilibria along this axis. During the calculation the exact T value for
phase changes is calculated and all calculated equilibria are stored. They can be listed
and also the list of all stored node points with phase changes. Any property value or
derived symbol for these equilibria can be listed or plotted.
In Fig. 1(a) the amount (in moles) of the phases as function of T , in Fig. 1(b) the
heat capacity varies with T . The calculated heat capacity at the phase transitions also
includes what is normally called the “latent heat”, that is the sharp peaks in the diagram.
Fig. 1(c) show how the driving forces for some metastable phases varies with T . The cubic
carbide, which is the same phase as the austenite, creates some wiggles at high T . All
three diagrams are plotted from the same calculation step calculation.

8. Step2 Gibbs energy curves for Ag-Cu system. This was my first calculation of Gibbs
energy curves with OC so I have kept it.

9. Step3 This calculates the speciation of H2 O in a gas phase between 1000 and 6000 K as
shown in Fig. 1(d). At low T the system consists of just the H2 O molecule but around
2000 K this splits up in several molecules and above 5000 K only atomic H and O are
present. This changes the configurational entropy and enthalpy and also the heat capacity
as shown in Fig. 1(e).

10. step4 DFT calculated values for the different ordered forms of FCC in the Fe-Ni system is
used to calculate how the Gibbs energy curves and sublattice occupancy, i.e. constitution
varies with composition. The ordered forms are not stable across the whole composition
range.

11. step5 The same DFT data as in 10 are used for a fixed composition FeNi3 to calculate
the constituent fractions for varying T and their contribution to the heat capacity.

12. step6 The Gibbs energy curves for the phases in the Fe-Mo system are calculated at
1400 K.

13. step7 In this example the phase fraction fractions of a duplex stainless steel, SAF2507,
are calculated. The aim is to have high PRE (Pitting corrosion Resistance Equivalence)
and equal amount of ferrite (BCC) and austenite (FCC) and the latter is achieved around
1373 K (1100 ◦ C) as shown in Fig. 1(f). Rapid cooling from this temperature preserve the
phase amounts and compositions and avoid precipitation of nitrides and intermetallic.

14. step8 The adiabatic flame temperature of propane (C3 H8 ) is calculated as function of
the amount of O.
In this example we first calculate the adiabatic flame temperature of propan (C3 H8 ) in
pure oxygen. The first calculation using a fixed amount of N(O)=7, then we calculate a
diagram for varying oxygen content. There are about 70 species in the gas.

4
(a) Step 1 (b) Step 1 (c) Step 1

(d) Step 3 (e) Step 3 (f) Step 7

(g) Step EPZ (h) Step EPZ (i) Step EPZ

(j) Step Scheil (k) Step Scheil (l) Step Scheil

Figure 1: Figures from STEP calculations.

15. step9 This macro tests a model for adding SRO to the CEF model for LRO. The recipro-

5
cal parameter which gives a reasonable contribution to the Gibbs energy describing LRO
has been made T dependent to also give a contribution to the heat capacity. This has a
small influence on the 2nd order transition at low T .

16. step-tzero This macro calculates a T0 line between BCC and FCC in a ternary alloy.
Along the T0 line the two phases have the same Gibbs energy at the same composition
and this is the limit of a diffusionless transformation.

17. step-epz In this example the stable isopleth phase diagram for a steel with 1.5% Man,
0.3% Si (by mass) and varying C content is calculated and shown in Fig. 1(g). In Fig. 1(h)
this is overlayed by a paraequilibrium diagram where only C is allowed to redistirbute
between FCC and BCC. In Fig 1(i) we have also added a T0 curve.

18. step-scheil The Scheil-Gulliver model for solidification takes into accound segregation
and in this example for an Al alloy with Mg, Si and Zn the calculated equilibrium fraction
of phases are shown in Fig. 1(j). In Fig. 1(k) the fraction of liquid for a Scheil simulation
is shown with colors indicating which phases are preciptated and in Fig. 1(l) this is
compared with the equilibrium fractions. The last liquid is stable to much lower T and
its composition is far from the initial one.

19. map1 A simple eutectic binary phase diagram for Ag-Cu shown in Fig. 2(a). There is a
miscibility gap in the FCC phase which is detected by the grid minimizer. See section 8
for the Gibbs energy curves.
After a calculation the macro shows one can plot the calculated diagram with different
axis ranges and axis variables, for example the chemical potential of Cu is used instead
of the mole fraction.

20. map2 Calculates the phase diagram for Cr-Mo with miscibility gap in the BCC phase
and a minimum along the liquidus curve.

21. map3 The phase diagram for C-Fe system is a must. In Fig. 2(b) both the stable (with
graphite) and the metastable (with cementite) phase diagrams are plotted (from two
different calculations). In Fig. 2(c) the T axis is replaced by the enthalpy and we can
plot tie-lines.

22. map4 The phase diagram for O-U can now be calculated almost without problems al-
though the step length control is not very good.

23. map5 The Fe-Mo system in Fig. 2(d) requires two start points to include the γ-loop for
FCC. There are several intermetallic phases with narrow solubility ranges.

24. map6 An isopleth for 8 mass% Ni and varying amount of Cr in Fe is calculated.

25. map7 An isopleth phase diagram for a 6 component High Speed Steel (HSS) in shown in
Fig. 2(e). The lines represent changes of the set of stable phase, the composition of the
all the phases (except the liquid along the liquidus) are outside the plane of the diagram.
There are several invariant equilibria at constant T where there are 7 phases stable. Some
of the regions have the stable set of phases indicated. Crossing a line (except an invariant

6
(a) Map 1 (b) Map 3 (c) Map 3

(d) Map 5 (e) Map 7 (f) Map 10

(g) Map 11 (h) Map 13 (i) Map 14

(j) Map 16 (k) Map 17 (l) Map 18

Figure 2: Diagram from MAP calculations

line) means that the number of stable phases changes by 1. Note the number of lines

7
meeting at an invariant can vary.

26. map8 A metastable phase diagram for ordered FCC in Fe-Ni using DFT data. The 4
sublattice model for FCC can describe all ordered structures A1, L12 and L10 but OC
has some problems when a phase has a 2nd order transition.

27. map9 A metastable phase diagram for Re-W based on DFT calculated data for the TCP
phases as well as bcc and hcp in the Re-W system. An additional STEP SEPARATE
calculation gives the Gibbs energy at 2000 K for all phases and the site fractions for the
χ phase.

28. map10 This is the first isothermal section calculated with OC and is shown in Fig. 2(f).
The isothermal section of the Cr-Fe-Ni system at 1200 K is calculated and plotted. The
unique feature of an isothermal section is that both axis are extensive state variables.
In most other diagrams one axis is a potential (i.e. T ) and this have a single value for
all lines when plotted. That is true also for multicomponent isopleths. In this kind of
diagram one need tie-lines to know the composition of the phases in equilibrium. But
ticmarks on the axis are still missing.
Note GNUPLOT can write text with a slope and plot a Gibbs triangle. But in the
macro the diagram is plotted also wth the chemical potentials on one axis and then the
FCC/BCC two-phase region is a line and the sigma phase a bubble on the line.

29. map11 The Cr-Fe phase diagram may look simple in Fig. 2(g) but is problematic due
to the three separate regions and the low T miscibility gap that closes inside the bcc-σ
region. Frequently metastable extrapolations of the bcc-σ phase boundaries are calculated
because the miscibility gap is not detected when calculating from higher T .
There is no automatic scanning for startpoints in OC and thus three separate start points
were needed to calculate this diagram.

30. map12 The Mo-Re system is calculated from a database in PDB format.

31. map13 The binary Al-Ni system is calculated and plotted in Fig. 2(h). A 4 sublattice
ordering model is used for the ordered Ni3 Al phase.

32. map14 Another isothermal secrion for the Cr-Fe-Mo system at 1400 K showing several
intermetallic phases. Note the σ phase is stable inside the ternary at this T . At higher T
it moves to the Fe-Mo binary and at lower to the Cr-Fe binary.

33. map15 The Mo-Ni-Re system modelled with the Bond Energy Formalism (BEM) isother-
mal section is calculated at 500, 1500 and 2500 K.

34. Map16 A ternary isopleth for Fe-13%Cr-C (in mass) is calculated and plotted in Fig. 2(j).
There is a short invariant 4 phase equilibrium at 1087 K (814 ◦ C) between BCC/FCC/M7C3/M23C6.

35. map17 The binary Al-Fe phase diagram is calculated and plotted in Fig. 2(k). The
models used for this diagram include a 4 sublattice model for the BCC-A2 phase to handle
the B2 and D03 ordering. The magnetic ordering does also complicate the modeling.

8
In Fig. 2(k) the 2nd order transition between A2/B2 and A2/D03 is calculated with a
separate STEP command and appended as dashed.

36. map18 An isopleth in the Al-Mg-Zn system at 5 mol% Zn is calculated and plotted in
Fig. 2(l). To simplify the identification of the lines they are indicated by symbols as well
as colors.

37. uniquac Several diagrams using the uniquac model for a polymer liquid are calculated
and plotted.

3 Assessment examples
An essential part of a thermodynamic software is assessment of model parameters. There are
two examples how to enter and fit model parameters to experimental data.

3.1 Setup of an assessment with fictitious binary experimental data


Macro file opttest1.OCM
A tentative start of an assessment of a phase in a binary system. It shows how to enter
experimental data and optimizing coefficients and how the weighting can change the results. It
also shows how results from one equilibrium can be transfered to another.

3.2 Start of an assessment of the Cu-Mg binary system


Macro file opttest2.OCM
This enters a complete set of experimental data for the Cu-Mg system and performs the
first step in the assessment by fitting the data for the liquid phase. The enter many equilibria
command is used to enter several tables of experimental data.
The experimental data has been converted to an OC macro file from a Thermo-Calc POP file
created by Malin Selleby and Christine Guéneau. In OC the experimental data is entered as
a macro file. In the first row of diagrams below the enthalpy of mixing in the liquid has been
fitted and plotted together with experimental data and then the heat capacities for the two
compounds.
The remaining data on enthalpies, chemical potentials and the phase diagram are fitted step
by step and the phase diagram develops as shown in the figures below. The first diagram
below is with all solutions ideal and no parameters for the intermediate phases, the second
after liquid enthalpy has been assessed and its negative enthalpy makes it more stable than the
solid solutions at low T . In the rightmost diagram the Mg2 Cu compound has been fitted.
In the first diagram in the next set the Laves phase has been fitted and in the middle the
solubilities in the FCC and HCP phases. The last diagram shows a metastable phase diagram

9
(a) All phses ideal (b) Mixing in liquid (c) With liquid fittted

(d) Cp in CuMg2 (e) CuMg2 fitted (f) Laves ordering

(g) Laves Cp (h) Both intermallics fitted (i) Suspended intermallics

Figure 3: Diagrams for an assessment

10
without the intermediate phases, compare with the first two in the previous row! The example
does not make a total fit to all data, that is left to the user.
The SAVE facility, see example 4, implemented in OC4, is an important facility to save
assessments for a current set of model parameters. But save files are fragile, in a later version
of OC the data structures may have changed and then it may not be possible to read an old
save file.

4 Summary
Have fun and help make OC better!

References
[98Sau] Nigel Saunders and Peter Miodownik, Calphad, Pergamon Materials series, Vol 1 (1998)

[07Luk] H Leo Lukas, Suzana G Fries and Bo Sundman, Computational Thermodynamics,


Cambridge Univ Press (2007)

[08Hil] Mats Hillert, Phase equilibria, phase diagrams and phase transformations, 2nd ed.,
Cambridge University Press (2008)

[15Sun1] Bo Sundman, Ursula R Kattner, Mauro Palumbo and Suzana G Fries OpenCalphad - a
free thermodynamic software, (Open Access) Integrating Materials and Manufacturing
Innovation (2015) 4:1

[15Sun2] B Sundman, X-L Liu and H Ohtani, The implementation of an algorithm to calculate
thermodynamic equilibria for multi-component systems with non-ideal phases in a free
software, Computational Materials Science, 101 (2015) 127-137

[16Sun] B Sundman, U R Kattner, C Sigli, M Stratmann, R Le Tellier, M Palumbo and S G


Fries, The OpenCalphad thermodynamic software interface, Comp Mat Sci, 125 (2016)
188-196

[20Li] Jing Li, Bo Sundman, Jozef G. M. Winkelman, Antonis I. Vakis and Francesco Piccioni,
Implementation of the UNIQUAC model in the OpenCalphad software, Fluid Phase
Equilibria, 507 2020, 112398

11

You might also like