Tray Column and its Properties (Shortcut Method)

posted in: C#, Code Snippets 0

This code-snippet in C# shows how to read the tray column properties like liquid density, entropy etc.

using CCAPI;
using CCAPI.UnitOperations;
using System;
using System.IO;

//Read the distillation column properties like liquid density,
//vapor density, enthalpy, entropy etc. 


namespace TrayColumn
{
    class Program
    {
        static void Main(string[] args)
        {
            // Initiate a new instance of CHEMCAD
            Console.WriteLine("Initializing CC-API...");
            Server chemcad;
            //Put your .NET Interface key here
            var license_key = "8d52f61549aaf3c17146f8a48e4f9b72";
            try
            {
                chemcad = new Server(license_key);
            }
            // If the server doesn't respond or
            // if reply results in end of program:
            catch (Exception ex)
            {
                // Display server message and close after key is pushed
                Console.WriteLine(ex.Message);
                Console.ReadLine();
                return;
            }

            // Open a CHEMCAD file relative from the current directory
            string path = Path.Combine(Directory.GetCurrentDirectory(),
                "...\\...\Deisobutanizer.cc7");
            Console.WriteLine("Opening: " + path + "...\n");
            try
            {
                chemcad.LoadFlowsheet(path);
            }
            // If flowsheet cannot be opened:
            catch (Exception ex)
            {
                // Display error message and close after key is pushed
                Console.WriteLine(ex.Message);
                Console.WriteLine("Press Any Key To Exit");
                Console.ReadLine();
                return;
            }
            // Load the flowsheet
            Flowsheet flowsheet = chemcad.CurrentFlowsheet;

            /* Get an array containing pressure of each tray
             *  from first column in your flowsheet.
             */

            SCDSColumn column = flowsheet.GetUnitOperationById(1) as SCDSColumn;
            int noStages = (int)column.NoOfStages;
            //Read the column hydraulics
            var hydraulics = column.GetColumnHydraulicsFromSizing(ColumnType.Tray);
            var stagedata = hydraulics.StageData;
            for (int stageNumber = 1; stageNumber < noStages; stageNumber++)
            {

                var liquidDensity = column.GetTrayProperty(ColumnType.Tray, stageNumber,StreamProperty.LiquidActualDensity);
                Console.WriteLine("The density of tray number " + stageNumber + " is " + liquidDensity + " " + flowsheet.UnitsCurrent.LiquidDensity);
            }
             
           
           
            
            Console.WriteLine("Press Any Key To Exit");


            Console.ReadLine();
        }
    }
}


Output:

Files:
Download Deisobutanizer.cc7