OpenCalphad Thermodynamic Software

repository·master·Indexed 42 days ago

https://github.com/sundmanbo/opencalphad

A free thermodynamic software package for calculating multicomponent equilibria, generating property and phase diagrams, and database development. It features a command-line interface and the OpenCalphad Application Software Interface (OCASI) for integration into simulation environments, with support for parallel calculations using OpenMP.

Tokens
4.6K
Snippets
17
Records
22
Agent score
53%

What's inside OpenCalphad

  1. Overview of OpenCalphad

    master

    OpenCalphad is a free thermodynamic software package designed for:

    • Calculation of multicomponent equilibria.
    • Generation of property and phase diagrams.
    • Database development.

    It supports parallel calculations using OpenMP for simulations and provides two primary ways to interact with it: a command line interface and the OpenCalphad Application Software Interface (OCASI) for integration into other simulation software.

  2. Accessing OpenCalphad versions and GUIs

    master

    Depending on your needs, you can access different versions and interfaces of OpenCalphad:

    • Stable Version: Available at http://opencalphad.org as a zip file or a precompiled Windows installation.
    • Development Version: This repository contains the development version, which is updated frequently.
    • Graphical User Interface (GUI): A third-party GUI named OpenCalphad CAE is available for Windows via Dropbox.
  3. Compile the TQ C++ example

    master

    This example demonstrates using the TQ library with isoC bindings to Fortran. To compile the example, you must have OpenCalphad (OC) installed with liboceq.a and liboceqplus.mod available.

    Prerequisites

    • OpenCalphad installed with liboceq.a and liboceqplus.mod.
    • The library files must be located two directories above the example directory (matching the structure of the downloaded zip file).

    Compilation Steps

    1. Prepare Environment: The build process copies liboceq.a, liboceq.mod, and the Fortran TQ library liboctq.F90 into the local directory.
    2. Compile Fortran components:
      • gfortran -c liboctq.F90
      • gfortran -c liboctqisoc.F90
    3. Link and compile the C++ main program:
      • Use g++ to link the C++ source with the compiled Fortran objects and the OpenCalphad library.

    Platform Specifics

    • Windows: Use linkmake. You may need to rename the executable to linkmake.cmd before execution.
    • UNIX: Use the provided Makefile.
    g++ -o tqintf -lstdc++ tqintf.cpp liboctqiso.o liboctq.o liboceq.a -lgfortran -lm
  4. Overview of OCASI implementations

    master

    The Open Calphad Application Software Interface (OCASI) is based on the TQ standard for interfacing thermodynamic software. It is available in two primary implementations:

    • Fortran (F90): Contains the liboctq.F90 source code. This version includes various subdirectories for specific implementations and examples (e.g., crfe/, feni/, and parallel-alnipt/).
    • C++ (iso-C): A tentative iso-C version designed for C++ integration. This version has been extended to support additional subroutine calls.

    Note that versions may vary across subdirectories as the interface is under active development.

  5. Understand automatic composition set creation in TQ

    master

    When using the grid minimizer in OpenCalphad, the system may automatically create new composition sets to represent different stable states of the same phase (e.g., in a miscibility gap).

    Composition Set Naming Convention

    • Suffix _AUTO: Indicates the composition set was created automatically by the grid minimizer.
    • Hash # and Number: A number following a hash (e.g., BCC_A2_AUTO#2) identifies the specific composition set number.

    Key Behaviors

    • Persistence: A phase tuple that has been stable in one calculation will not be removed automatically; it is only removed via explicit commands.
    • Indexing: For the first composition set, the set number is not required. For subsequent sets, you typically specify the set number after a hash character.
    • Dynamic Phase Lists: Be aware that the total number of phase tuples may change during a session as new composition sets are discovered.
  6. Compile and link the Scheil solidification example on Windows

    master

    To build the Scheil solidification example using OCASI on a Windows environment, follow these steps:

    1. Generate OCASI libraries: Navigate to your OpenCalphad installation directory and run makeocasi. This generates libocasi.a and liboceqplus.mod.
    2. Prepare the build script: Navigate to the example directory (examples/TQ4lib/Cpp/Scheil) and copy the existing link script: copy linkscheil linkscheil.cmd.
    3. Execute the build: Run linkscheil. This command copies libocasi.a and other necessary files to the current directory, compiles the Fortran files (liboctq.F90 and liboctqisoc.F90), and links the final executable using g++.
    4. Run the simulation: Once compiled, execute the sample case using the input file: scheil input.txt.
    # 1. In installation directory
    makeocasi
    
    # 2. In example directory
    copy linkscheil linkscheil.cmd
    linkscheil
    
    # 3. Run the example
    scheil input.txt
  7. Run the TQ interface test program

    master

    Once compiled, execute the program (e.g., ./tqex1 or tqex1.exe). The program is interactive and will prompt you for thermodynamic conditions. You can press RETURN to accept default values enclosed in slashes (e.g., //800//).

    Interactive Prompts

    • Temperature (K)
    • Pressure (Pa)
    • Mole fraction of [Component]
    • Any more calculations? (Enter y to continue or N to exit)

    Silent Mode

    Enabling silent mode reduces the amount of output generated by OpenCalphad during calculations.

    ./tqex1
  8. Compile and link the Fortran TQ interface example

    master

    To compile the TQ1-crfe.F90 test program using the Fortran OCTQ interface, you must have the OpenCalphad (OC) main program installed. The installation must provide liboceq.a and liboceqplus.mod. You also need the liboctq.F90 source file.

    Prerequisites

    • liboceq.a: Static library from the OC main program.
    • liboceqplus.mod: Module file from the OC main program.
    • liboctq.F90: TQ interface source code.

    Compilation Steps (Linux/Windows with gfortran)

    Assuming the OC libraries are located two directories above the example directory:

    1. Copy the required library files to the current directory:
      copy ../../../liboceq.a .
      copy ../../../liboceqplus.mod .
      copy ../liboctq.F90 .
    2. Compile the TQ interface source:
      gfortran -c liboctq.F90
    3. Link the test program with the interface object and the OC library:
      gfortran -o tqex1 TQ1-crfe.F90 liboctq.o liboceq.a
    gfortran -c liboctq.F90
    gfortran -o tqex1 TQ1-crfe.F90 liboctq.o liboceq.a
  9. Compile and run the AlNiPt parallel example

    master

    To run the AlNiPt diffusion simulation example, you must manually gather specific OpenCalphad library files and object files into your local directory before compiling. This example uses OpenMP for parallelization.

    Prerequisites

    Ensure you have the following files copied into your working directory:

    1. liboceq.a (must be compiled with -fopenmp)
    2. liboceqplus.mod (must be compiled with -fopenmp)
    3. getkey.o (Required for Linux/Mac users)
    4. liboctq.F90 (The version provided in this example directory)

    Compilation Steps

    1. Compile the provided liboctq.F90 to produce liboctq.o.
    2. Compile and link the main simulation file sim-alnipt.F90 using gfortran.

    Note: On Linux/Mac, you must include getkey.o in the linking command.

    Execution

    Run the resulting executable using the setup.dat input file. This file defines parameters such as databasefile, elements, and gridpoints.

    Output

    • The simulation results are written to ocsim.plt.
    • Results can be visualized using GNUPLOT.
    • The model simulates 1D diffusion where elements move between gridpoints based on a constant mobility value.
    # 1. Compile the library
    gfortran -c liboctq.F90
    
    # 2. Compile and link the simulation (Linux/Mac example)
    gfortran -o sim-alnipt -fopenmp sim-alnipt.F90 liboctq.o getkey.o liboceq.a
    
    # 3. Run the simulation
    ./sim-alnipt
  10. Compile and link the OCASI Fortran TQ interface example

    master

    To compile and link the Fortran 95/08 test program (TQ2-feni.F90) using the OCASI TQ interface, you must satisfy the following dependencies and follow these steps:

    Prerequisites

    1. OC Main Program: Must be installed. You need the following files generated by the installation:
      • liboceq.a (Static library)
      • liboceqplus.mod (Fortran module file)
    2. TQ Library Source: The liboctq.F90 source code file (located in the directory above the example).

    Compilation Steps (Linux/gfortran)

    Assuming the OC main program files are located two directories above the current example directory:

    1. Prepare files: Copy the required library and source files into your local directory.
    2. Compile the TQ library: Compile liboctq.F90 into an object file.
    3. Link the test program: Link the test program with the TQ object file and the OC static library.

    On Windows, you can use the provided linkmake file (rename to .cmd to run as a batch file). On Linux, you should adapt linkmake into a Makefile.

    # 1. Copy libraries and source (adjust paths as necessary)
    copy ..\..\..\liboceq.a .
    copy ..\..\..\liboceqplus.mod .
    copy ..\liboctq.F90 .
    
    # 2. Compile the TQ library
    gfortran -c liboctq.F90
    
    # 3. Compile and link the test program
    gfortran -o tqex2 TQ2-feni.F90 liboctq.o liboceq.a
  11. Build the OCASI library

    master

    To use the Open Calphad Application Software Interface (OCASI) examples, you must first compile and link the main Open Calphad (OC) program. Once the main program is working, you need to build a special library that excludes the tinyfiledialogs file browser.

    On Windows, this is done using the makeocasilib command file. You must rename the file to include the .cmd extension before executing it as a batch file.

    Successful execution generates two essential files required for compiling and linking applications:

    1. libocasi.a
    2. liboceqplus.mod
    # Rename the file to add the extension
    makeocasilib -> makeocasilib.cmd
    
    # Execute as a command/batch file
    makeocasilib.cmd