Menu

Create, Manipulate RGibbs Reactor and Controller Block

Seb
2023-02-02
2023-02-02
  • Seb

    Seb - 2023-02-02

    Hi everybody,

    i create a Gibbsreactor and also a Controller Block from an ironpython code. That works really well.

    If i try to manipulate the check boxes for the choosen compounds of the reactor, this only works, if the window/dock was opened by clicking on the reactor, because only then are the fields RGibbs.f (EditingForm_ReactorConvEqGibbs) active. For the Controller Block i have the same issue for the fields.

    I have tried to set the fields active by RGibbs.f = EditingForm_ReactorConvEqGibbs(), but it creates an error.

    How is it possible to fixed this issue in the code? How can i set the fields active/open the window/dock via code?

    I have attached my code for the reactor below.
    Thanks in advance,
    Seb

    import clr
    import System

    clr.AddReference ('DWSIM.Interfaces')
    clr.AddReference('System')
    clr.AddReference('DWSIM.UnitOperations')
    clr.AddReference('DWSIM.Thermodynamics')
    clr.AddReference('DWSIM.Automation')
    clr.AddReference('DWSIM.GlobalSettings')
    clr.AddReference('DWSIM.SharedClasses')
    clr.AddReference('DWSIM.Inspector')
    clr.AddReference('System.Buffers')
    clr.AddReference('DWSIM.MathOps')
    clr.AddReference('DWSIM.Drawing.SkiaSharp')

    from DWSIM import * from DWSIM.MathOps import * from DWSIM import Interfaces
    from DWSIM.UnitOperations import
    from DWSIM import Thermodynamics
    from DWSIM.Automation import Automation3
    from DWSIM.GlobalSettings import Settings
    from DWSIM.Drawing.SkiaSharp import

    from System import*
    from System.Windows import * from System.Collections.Generic import *

    inter = Interfaces.Enums.GraphicObjects.ObjectType

    en1 = Flowsheet.AddObject(inter.EnergyStream,100,300,'EN1')
    ms1 = Flowsheet.AddObject(inter.MaterialStream,100,100,'MS1')
    ms2 = Flowsheet.AddObject(inter.MaterialStream,300,100,'MS2')
    ms3 = Flowsheet.AddObject(inter.MaterialStream,300,300,'MS3')
    r1 = Flowsheet.AddObject(inter.RCT_Gibbs,200,200,'R1')

    en1.GraphicObject.CreateConnectors(1,1)
    ms1.GraphicObject.CreateConnectors(1,1)
    ms2.GraphicObject.CreateConnectors(1,1)
    ms3.GraphicObject.CreateConnectors(1,1)

    Flowsheet.ConnectObjects(ms1.GraphicObject, r1.GraphicObject,0,0)
    Flowsheet.ConnectObjects(r1.GraphicObject, ms2.GraphicObject,0,0)
    Flowsheet.ConnectObjects(r1.GraphicObject, ms3.GraphicObject,1,0)
    Flowsheet.ConnectObjects(en1.GraphicObject, r1.GraphicObject,-1,-1)

    r1.ReactorOperationMode = r1.ReactorOperationMode.OutletTemperature
    r1.OutletTemperature = 873.15
    r1.DeltaP = 1000

    r1List = ListSystem.Object

    r1List.Add('Methane')
    r1List.Add('Carbon dioxide')
    r1List.Add('Hydrogen')

    '# only possible when the window for the reactor is open
    r1.f.ListViewCompounds.Items['Methane'].Checked = True
    r1.f.ListViewCompounds.Items['Carbon dioxide'].Checked = True
    r1.f.ListViewCompounds.Items['Hydrogen'].Checked = True

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.