Menu

Column.SetStreamFeedStage Method (String, String)

2022-04-21
2022-05-25
  • Mustafa Anıl ÖZ

    Hello Everyone,
    I have been trying to create a distillation column simulation but I'm stuck in setting a stream as feed that will enter the column at stage 7. Could you help me find out what is the problem with the following script ?

    # create and connect objects
    
    m1 = sim.AddObject(ObjectType.MaterialStream, 50, 100, "inlet")
    d1 = sim.AddObject(ObjectType.DistillationColumn, 150, 50, "column")
    e1 = sim.AddObject(ObjectType.EnergyStream, 400, 50, "condenser duty")
    m2 = sim.AddObject(ObjectType.MaterialStream, 400, 110, "distillate")
    e2 = sim.AddObject(ObjectType.EnergyStream, 325, 140, "reboiler duty")
    m3 = sim.AddObject(ObjectType.MaterialStream, 400, 250, "bottom")
    
    sim.ConnectObjects(m1.GraphicObject, d1.GraphicObject, -1, -1)  
    sim.ConnectObjects(e2.GraphicObject, d1.GraphicObject, -1, -1)
    sim.ConnectObjects(d1.GraphicObject, m2.GraphicObject, -1, -1)
    sim.ConnectObjects(d1.GraphicObject, e1.GraphicObject, -1, -1)
    sim.ConnectObjects(d1.GraphicObject, m3.GraphicObject, -1, -1)
    
    # Distillation Column Parameters
    
    d1.SetNumberOfStages(14)
    d1.SetStreamFeedStage(m1.Name, "Stage7")
    

    Output:

    Initializing DWSIM Automation Interface...
    DWSIM Automation Interface initialized successfully.
    Initializing the Flowsheet, please wait...
    start creating workbook...
    creating workbook done: 2 ms.
    start creating worksheet...
    init srm takes 404 ms.
    creating worksheet done: 457 ms.
    Set ScrollBarHorizontalLargeChange to -1
    Set ScrollBarVerticalLargeChange to -1
    Renderer Dispose Time: 22,0001 ms
    update new visible region text takes 38 ms.
    update viewport bounds done: 61 ms.
    Traceback (most recent call last):
      File "distillation_sim.py", line 89, in <module>
        d1.SetStreamFeedStage(m1.Name, "Stage7")
    System.NullReferenceException: Nesne başvurusu bir nesnenin örneğine ayarlanmadı.
       konum: DWSIM.UnitOperations.UnitOperations.Column.SetStreamFeedStage(String streamName, String stageID) C:\Users\Daniel\source\repos\DanWBR\dwsim\DWSIM.UnitOperations\UnitOperations\RigorousColumn.vb içinde: satır 1931
    
     

    Last edit: Mustafa Anıl ÖZ 2022-04-21
  • Albert Emil

    Albert Emil - 2022-05-25

    I am trying to achieve this as well and am stuck at exact the same point. Unfortunately, I did not figure out how to define the feed stage.

    My current approach looks like this:

    column.NumberOfStages = 20
    column.SetStreamFeedStage(feed_stream.Name, 1)
    

    Is the issue due to passing .Name or passing the stageIndex to the method? How could I resolve it?

    I tried to iterate over column.MaterialStreams to get some more information about the stream(s), but this did not print anything at all:

    for stream in column.MaterialStreams:
        print(stream)
    
     
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.