File size: 3,623 Bytes
b1b3bae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using DWSIM.Interfaces.Enums.GraphicObjects;
using DWSIM.Thermodynamics.Streams;
using DWSIM.UnitOperations.Reactors;
using DWSIM.UnitOperations.Streams;
using DWSIM.UnitOperations.UnitOperations;

namespace DWSIM.Automation.Tests.CSharp
{
    class distColumn
    {
        [STAThread]
        static void Main()
        {
            System.IO.Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            //create automation manager

            var interf = new DWSIM.Automation.Automation3();

            var sim = interf.CreateFlowsheet();

            // add compounds

            sim.AddCompound("Water");
            sim.AddCompound("Ethanol");

            // add objects

            var m1 = (MaterialStream)sim.AddObject(ObjectType.MaterialStream, 50, 50, "feed");
            var m2 = (MaterialStream)sim.AddObject(ObjectType.MaterialStream, 250, 50, "distillate");
            var m3 = (MaterialStream)sim.AddObject(ObjectType.MaterialStream, 250, 50, "bottoms");
            var e1 = (EnergyStream)sim.AddObject(ObjectType.EnergyStream, 100, 50, "cond. duty");
            var e2 = (EnergyStream)sim.AddObject(ObjectType.EnergyStream, 100, 50, "reb. duty");
            var d1 = (DistillationColumn)sim.AddObject(ObjectType.DistillationColumn, 100, 50, "column");

            d1.SetNumberOfStages(20);
            d1.ConnectFeed(m1, 10);
            d1.ConnectDistillate(m2);
            d1.ConnectBottoms(m3);
            d1.ConnectCondenserDuty(e1);
            d1.ConnectReboilerDuty(e2);

            d1.SetCondenserSpec("Reflux Ratio", 2, "");
            d1.SetReboilerSpec("Product Molar Flow Rate", 75, "mol/s", "");

            d1.SetTopPressure(101325.0);
            d1.ColumnPressureDrop = 0.0;

            sim.AutoLayout();

            // property package

            sim.CreateAndAddPropertyPackage("NRTL");

            m1.SetTemperature(300); // K
            m1.SetMolarFlow(100.0); // mol/s

            m1.SetOverallCompoundMolarFlow("Water", 50.0);
            m1.SetOverallCompoundMolarFlow("Ethanol", 50.0);

            // request a calculation

            interf.CalculateFlowsheet2(sim);

            Console.WriteLine(String.Format("Condenser Duty: {0} kW", e1.EnergyFlow.GetValueOrDefault()));
            Console.WriteLine(String.Format("Reboiler Duty: {0} kW", e2.EnergyFlow.GetValueOrDefault()));

            Console.WriteLine();

            Console.WriteLine(String.Format("Distillate Flow Rate: {0} mol/s", m2.GetMolarFlow()));
            Console.WriteLine(String.Format("Bottoms Flow Rate Duty: {0} mol/s", m3.GetMolarFlow()));

            Console.WriteLine();

            Console.WriteLine(String.Format("Distillate Temperature: {0} K", m2.GetTemperature()));
            Console.WriteLine(String.Format("Bottoms Temperature: {0} K", m3.GetTemperature()));

            Console.WriteLine();

            Console.WriteLine(String.Format("Distillate Composition: Water: {0}, Ethanol: {1}", 
                m2.Phases[0].Compounds["Water"].MoleFraction.GetValueOrDefault(),
                m2.Phases[0].Compounds["Ethanol"].MoleFraction.GetValueOrDefault()));
            Console.WriteLine(String.Format("Bottoms Composition: Water: {0}, Ethanol: {1}",
                m3.Phases[0].Compounds["Water"].MoleFraction.GetValueOrDefault(),
                m3.Phases[0].Compounds["Ethanol"].MoleFraction.GetValueOrDefault()));


            Console.WriteLine("Done! press any key to close.");
            Console.ReadKey();

        }
    }
}