Ejemplo n.º 1
0
    static void Main()
    {
        System.IO.Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

        //create automation manager

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

        var sim = interf.LoadFlowsheet(@"C:\Users\Daniel\Downloads\150747-205762.dwxml");

        sim.SetMessageListener((s, mt) => Console.WriteLine(s));

        var msobj = sim.GetFlowsheetSimulationObject("PRODUCED GAS");

        msobj.SetPropertyValue("PROP_MS_104/Metano", 10);

        interf.SaveFlowsheet(sim, @"C:\Users\Daniel\Downloads\150747-205762.dwxml", false);

        var errors = interf.CalculateFlowsheet3(sim, 3600);

        var obj         = sim.GetSelectedFlowsheetSimulationObject("compressed gas");
        var temperature = obj.GetPropertyValue("PROP_MS_0");

        Console.WriteLine("Solved.");

        Console.ReadLine();
    }
Ejemplo n.º 2
0
    static void Main()
    {
        System.IO.Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

        //create automation manager

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

        var sim = interf.CreateFlowsheet();

        // add water

        var water = sim.AvailableCompounds["Water"];

        sim.SelectedCompounds.Add(water.Name, water);

        var m1 = (MaterialStream)sim.AddObject(ObjectType.MaterialStream, 50, 50, "inlet");
        var m2 = (MaterialStream)sim.AddObject(ObjectType.MaterialStream, 150, 50, "outlet");
        var e1 = sim.AddObject(ObjectType.EnergyStream, 100, 50, "power");
        var h1 = (Heater)sim.AddObject(ObjectType.Heater, 100, 50, "heater");

        sim.ConnectObjects(m1.GraphicObject, h1.GraphicObject, -1, -1);
        sim.ConnectObjects(h1.GraphicObject, m2.GraphicObject, -1, -1);
        sim.ConnectObjects(e1.GraphicObject, h1.GraphicObject, -1, -1);

        sim.AutoLayout();

        // steam table sproperty package

        var stables = new DWSIM.Thermodynamics.PropertyPackages.SteamTablesPropertyPackage();

        sim.AddPropertyPackage(stables);

        // set inlet stream temperature
        // default properties: T = 298.15 K, P = 101325 Pa, Mass Flow = 1 kg/s

        m1.SetTemperature(300); // K
        m1.SetMassFlow(100);    // kg/s

        // set heater outlet temperature

        h1.CalcMode          = Heater.CalculationMode.OutletTemperature;
        h1.OutletTemperature = 400; // K

        // request a calculation

        interf.CalculateFlowsheet2(sim);

        Console.WriteLine(String.Format("Heater Heat Load: {0} kW", h1.DeltaQ.GetValueOrDefault()));

        // save file

        string fileNameToSave = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "heatersample.dwxml");

        interf.SaveFlowsheet(sim, fileNameToSave, false); //use true for dwxmz

        Console.WriteLine("Done! press any key to close.");
        Console.ReadKey();
    }
Ejemplo n.º 3
0
    static void Main()
    {
        System.IO.Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
        var interf = new DWSIM.Automation.Automation2();

        for (var i = 0; i <= 200; i++)
        {
            Console.WriteLine($"Iteration #{i + 1}");
            var sim = interf.LoadFlowsheet("samples" + System.IO.Path.DirectorySeparatorChar + "Carbon Combustion.dwxml");
            interf.ReleaseResources();
        }
        Console.WriteLine("Done.");
        Console.ReadLine();
    }
Ejemplo n.º 4
0
    static void Main()
    {
        System.IO.Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

        //create automation manager

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

        var sim = interf.LoadFlowsheet(@"");

        sim.SetMessageListener((s, mt) => Console.WriteLine(s));

        var errors = interf.CalculateFlowsheet2(sim);

        Console.WriteLine("Solved.");

        Console.ReadLine();
    }