Menu

Get parameters from Flowsheet Simulation Objects

2019-09-24
2019-09-25
  • Patrick Veiltl

    Patrick Veiltl - 2019-09-24

    Hello Community,

    I'm currently trying to create a dynamic simulation by familiarizing myself with simple process simulations.
    I can plot simple values like Temperature, Pressure and Massflow, because Daniel referenced them in various examples on the infosite.
    When it comes to parameters like phase count of a fluid, concentration of a certain compound in the gaseous phase or the removed heat of a cooling block I run into the problem of not knowing the specific description I have to use in my scripts to get the results I want to plot on my graph.
    Is there some way of finding the correct wording I need, like a online database or a bigger list of examples?

    As an example. If I try to get the molar fraction of water in the vapour phase in a Liquid-Vapor-Mixture, how do I achieve it? Is this the right basic approach?

        water_in = Flowsheet.GetFlowsheetSimulationObject("Water_EtOH_Stream")
        water_in.Phases[0].Compounds("Water").Properties.molarfraction
    

    Thanks in advance.

     

    Last edit: Patrick Veiltl 2019-09-24
  • Luca Finardi

    Luca Finardi - 2019-09-24

    Hi Patrick,

    One basic way to see the available parameters for example in one stream is to list object properties through the command dir().
    Example:

    water_in = Flowsheet.GetFlowsheetSimulationObject("Water_EtOH_Stream")
    OverallProp = water_in.GetPhase('Overall').Properties
    print dir(OverallProp)
    

    or for components composition

    EtOHProp = water_in.GetPhase('Overall').Compounds['Ethanol']
    print dir(EtOHProp)
    

    you can use either GetPhase('Liquid') or GetPhase('Vapor') to retrieve the parameters in the single phases.

    Hope this helps.

    Luca

     
  • Daniel Medeiros

    Daniel Medeiros - 2019-09-24

    You can also set a breaking point on your script code and run the script in debug mode (third 'play' button on the toolbar). This will give you a list of all variables and their properties as the code runner stops at the breaking point location.

     

    Last edit: Daniel Medeiros 2019-09-24
  • Daniel Medeiros

    Daniel Medeiros - 2019-09-24

    Also, when clicking on a property item with the right mouse button you'll have access to the API help and source code location for that property:

     
  • Patrick Veiltl

    Patrick Veiltl - 2019-09-25

    Thanks a lot Luca and Daniel, your solutions really helped me get a lot further.

    Daniel, as I understand your response, the debug mode is only availible in DWSIM and not in New UI right. I have solely been working on New UI, so I have some open questions.
    The window "Variables" only appears shortly after I press "debug" and doesn't stay open, how do I access it?

    Building on Lucas answer, about displaying the attributes of MassFlows, I need to ask how to open the list of attributes of Flowsheet Objects like Reactors, Heaters and Compressors.

    Thank you again guys.

     
  • Luca Finardi

    Luca Finardi - 2019-09-25

    Well, the scheme is pretty the same as for the material streams, i.e.

    # compressor
    mycomp = Flowsheet.GetFlowsheetSimulationObject('COMP-012')
    print dir(mycomp)
    # heat exchanger
    myHE = Flowsheet.GetFlowsheetSimulationObject('HE-013')
    print dir(myHE)
    # CSTR reactor
    cstr = Flowsheet.GetFlowsheetSimulationObject('CSTR-001')
    print dir(cstr)
    

    However sometime, to retrieve useful parameters you need dig into the properties of subobjects but to understand in which and where, you need to go through the source code, as Daniel mentioned, to see where they calculated and stored.

    As an example, for a cstr if you want to have information regarding the reaction kinetics you should have in your script something like

    import System
    import clr
    import System.Math as m
    
    from System import *
    from DWSIM import *
    
    cstr = Flowsheet.GetFlowsheetSimulationObject('CSTR-001')
    print cstr.ResidenceTimeL
    
    rxt= cstr.RxiT
    rx_ks = list(Flowsheet.Reactions.Keys)
    rx_key1 = rx_ks[0]
    rxn = Flowsheet.Reactions[rx_key1]      
    print rxn.ReactionBasis
    print rxn.VelUnit
    print rxt[rx_key1]
    
    A = rxn.A_Forward
    E = rxn.E_Forward
    print A, E
    
    kxf = rxn.A_Forward * m.Exp(-rxn.E_Forward / (8.314 * T))
    print kxf
    

    Hope this helps.

    Luca

     
  • Patrick Veiltl

    Patrick Veiltl - 2019-09-25

    Yes this definetly helps, thank you Luca!

    My project does indeed include accessing and tweaking reaction parameters, especially the "Conversion Expression" of some main chemical reactions .
    Does the scheme you wrote translate to a Conversion Reactor and can I directly change the expressions in my dynamic simulation?

     
  • Luca Finardi

    Luca Finardi - 2019-09-25

    In principle yes, you could access the reaction(s) kinetic parameters through a script and 'dynamically' change them.
    For an first outlook on how the parameters are handled inside DWSim and how you can access them , have a look at this code

    https://github.com/DanWBR/dwsim5/blob/windows/DWSIM.UnitOperations/Reactors/CSTR.vb#L126

    On the specific topic of the conversion calcualtion, refer to a recent thread in the Help section as Daniel is fixing for DW rel 5.8 a current inconsistency in the UOM conversion.

    Luca

     
  • Patrick Veiltl

    Patrick Veiltl - 2019-09-25

    Ok, I will certainly take a look at it. Thank you both a lot for your support.

     

Log in to post a comment.