Menu

stream pump

2019-06-09
2020-05-18
  • Petr Zaruba

    Petr Zaruba - 2019-06-09

    I have problem with output temperature. In script is the temperature set, but output material stream has a wrong value. Can you help me ?
    Flowsheet is attached.

     
  • Daniel Medeiros

    Daniel Medeiros - 2019-06-09

    When the stream contains a single compound, the spec is automatically set to pressure/enthalpy, so you must set the stream enthalpy instead of temperature, which will then be calculated by the flash algorithm.

    Regards
    Daniel

     
  • Petr Zaruba

    Petr Zaruba - 2019-06-09

    Thank you,
    but how can I get the enthalpy of input streams ? Is this right:
    H1i = i1.GetProp("enthalpy", "Overall", None, "", "")
    H2i = i2.GetProp("enthalpy", "Overall", None, "", "")
    next lines are not funcional :
    H1 = float(H1i[0])
    H2 = float(H2i[0])
    What is wrong ?
    When I will set the enthalpy of output stream, can I write :
    out.SetProp("enthalpy", "Overall", None, "", "", H)

     
  • Petr Zaruba

    Petr Zaruba - 2019-06-09

    Solved !
    Right was :
    H1i = i1.GetProp("enthalpy", "Overall", None, "", "mass")
    H2i = i2.GetProp("enthalpy", "Overall", None, "", "mass")
    h1 = 0
    h2 = 0
    for i in range(0, n):
    h1 += H1i[i] # J/kg
    h2 += H2i[i] # J/kg
    H = h1+h2
    out.SetProp("enthalpy", "Overall", None, "", "mass", [H]) # J/kg

    Thank you Daniel

    Regards
    Petr Záruba

     
  • Antonio P.

    Antonio P. - 2020-04-10

    Hello everyone,
    I have tried basically the same syntax Petr was talking about, namely:

    H = feed.GetProp("enthalpy", "Overall", None, "", "mass")

    but also

    H = feed.GetProp("enthalpy", "Vapor", None, "", "mass")

    for a feed stream.
    If I print the result I have in all cases that H equals the total (mixture) specific enthalpy, but I can't get the specific enthalpies of the vapor or liquid phases. Also, I expected H to be an array with as many elements as the number of compounds (like when I call the property "fraction"), while H is a single element array.
    Where am I doing wrong?

     
  • Daniel Medeiros

    Daniel Medeiros - 2020-04-12

    Your syntax will return a single enthalpy value for the phase you've specified. Is your stream single phase or mixed? Why would you expect an array with enthalpy values for each compound?

     
  • Antonio P.

    Antonio P. - 2020-04-12

    Ok Daniel. I was trying, as an exercise, to reproduce the functioning of a mixer. Initially it didn't work using the overall values, but maybe there was some other error.
    Now it seems that the Python UnitOp works.
    So, in any case, the enthalpy returned will always be a single value and not an array: either overall, or relative to the single phase.

     
  • Antonio P.

    Antonio P. - 2020-04-12

    sorry, there was a typo in the script.
    the acquisition of the input properties should have been:
    M1 = in1.GetProp("totalflow", "Overall", None, "", "mass")[0]
    m1 = in1.GetProp("totalflow", "Overall", None, "", "mole")[0]
    f1 = in1.GetProp("fraction", "Overall", None, "", "mole")
    P1 = in1.GetProp("pressure", "Overall", None, "", "")[0]
    T1 = in1.GetProp("temperature", "Overall", None, "", "")[0]
    H1 = in1.GetProp("enthalpy", "Overall", None, "", "mass")[0]

    but at this point I wonder why it worked...

     
  • Daniel Medeiros

    Daniel Medeiros - 2020-04-13

    Antonio, there is a mixer sample which can be added as a Snippet through the script editor:

    # for more details, go to http://dwsim.inforside.com.br/wiki/index.php?title=Model_Customization
    
    import clr
    
    clr.AddReference('DWSIM.MathOps')
    clr.AddReference('DWSIM.UnitOperations')
    clr.AddReference('DWSIM.Interfaces')
    
    from DWSIM import *
    from DWSIM.Thermodynamics.Streams import *
    from DWSIM.UnitOperations import *
    from DWSIM.MathOps.MathEx import *
    from System import *
    from System.Collections.Generic import *
    
    # gets the mixer object
    
    mixer = Flowsheet.GetFlowsheetSimulationObject('MIX-004')
    
    def CalcMixer():
    
        ms = MaterialStream()
    
        P = 0.0
        W = 0.0
        H = 0.0
    
        i = 1
    
        for cp in mixer.GraphicObject.InputConnectors:
            if cp.IsAttached:
                ms = Flowsheet.SimulationObjects[cp.AttachedConnector.AttachedFrom.Name]
                ms.Validate()
                if mixer.PressureCalculation == UnitOperations.Mixer.PressureBehavior.Minimum:
                    print '[' + mixer.GraphicObject.Tag + '] ' + 'Mixer Mode: Outlet Pressure = Minimum Inlet Pressure'
                    if ms.Phases[0].Properties.pressure < P:
                        P = ms.Phases[0].Properties.pressure
                    elif P == 0.0:
                        P = ms.Phases[0].Properties.pressure
                elif mixer.PressureCalculation == UnitOperations.Mixer.PressureBehavior.Maximum:
                    print '[' + mixer.GraphicObject.Tag + '] ' + 'Mixer Mode: Outlet Pressure = Maximum Inlet Pressure'
                    if ms.Phases[0].Properties.pressure > P:
                        P = ms.Phases[0].Properties.pressure
                    elif P == 0:
                        P = ms.Phases[0].Properties.pressure
                else:
                    print '[' + mixer.GraphicObject.Tag + '] ' + 'Mixer Mode: Outlet Pressure = Inlet Average'
                    P += ms.Phases[0].Properties.pressure
                    i += 1
                We = ms.Phases[0].Properties.massflow
                W += We
                if not Double.IsNaN(ms.Phases[0].Properties.enthalpy): H += We * ms.Phases[0].Properties.enthalpy
    
        if W != 0.0: 
            Hs = H / W 
        else:
            Hs = 0.0
    
        if mixer.PressureCalculation == UnitOperations.Mixer.PressureBehavior.Average: P = P / (i - 1)
    
        print '[' + mixer.GraphicObject.Tag + '] ' + 'Mixture Pressure (Pa): ' + str(P)
        print '[' + mixer.GraphicObject.Tag + '] ' + 'Mixture Mass Flow (kg/s): ' + str(W)
        print '[' + mixer.GraphicObject.Tag + '] ' + 'Mixture Enthalpy (kJ/kg): ' + str(Hs)
    
        T = 0.0
    
        n = Flowsheet.SelectedCompounds.Count
        Vw = Dictionary[String, Double]()
        for cp in mixer.GraphicObject.InputConnectors:
            if cp.IsAttached:
                ms = Flowsheet.SimulationObjects[cp.AttachedConnector.AttachedFrom.Name]
                for comp in ms.Phases[0].Compounds.Values:
                    if not Vw.ContainsKey(comp.Name):
                        Vw.Add(comp.Name, 0)
                    Vw[comp.Name] += comp.MassFraction * ms.Phases[0].Properties.massflow
                if W != 0.0: T += ms.Phases[0].Properties.massflow / W * ms.Phases[0].Properties.temperature
    
        if W == 0.0: T = 273.15
    
        print '[' + mixer.GraphicObject.Tag + '] ' + 'Mixture Temperature Estimate (K): ' + str(T)
    
        omstr = Flowsheet.SimulationObjects[mixer.GraphicObject.OutputConnectors[0].AttachedConnector.AttachedTo.Name]
        omstr.Clear()
        omstr.ClearAllProps()
        if W != 0.0: omstr.Phases[0].Properties.enthalpy = Hs
        omstr.Phases[0].Properties.pressure = P
        omstr.Phases[0].Properties.massflow = W
        omstr.Phases[0].Properties.molarfraction = 1
        omstr.Phases[0].Properties.massfraction = 1
        for comp in omstr.Phases[0].Compounds.Values:
            if W != 0.0: comp.MassFraction = Vw[comp.Name] / W
        mass_div_mm = 0.0
        for sub1 in omstr.Phases[0].Compounds.Values:
            mass_div_mm += sub1.MassFraction / sub1.ConstantProperties.Molar_Weight
        for sub1 in omstr.Phases[0].Compounds.Values:
            if W != 0.0:
                sub1.MoleFraction = sub1.MassFraction / sub1.ConstantProperties.Molar_Weight / mass_div_mm
            else:
                sub1.MoleFraction = 0.0
            print '[' + mixer.GraphicObject.Tag + '] ' + sub1.Name + ' outlet molar fraction: ' + str(sub1.MoleFraction)
        omstr.Phases[0].Properties.temperature = T
        omstr.SpecType = Interfaces.Enums.StreamSpec.Pressure_and_Enthalpy
    
        print '[' + mixer.GraphicObject.Tag + '] ' + 'Outlet Stream variables set successfully.'
    
        return None
    
    mixer.OverrideCalculationRoutine = True
    
    mixer.CalculationRoutineOverride = CalcMixer
    
     
  • Antonio P.

    Antonio P. - 2020-04-14

    Thanks Daniel, I will study the code.

     
  • Vincent Doucet

    Vincent Doucet - 2020-05-18

    Hi Petr, Antonio and Daniel,
    as I was searching on the word ejector in DWSIM it came up with this thread.
    Is there an existing ejector unit operation?
    I'm looking for a gas-gas ejector and so far I didn't find much ...
    Best Regards,
    Vincent

     

    Last edit: Vincent Doucet 2020-05-18
    • Antonio P.

      Antonio P. - 2020-05-18

      Hi Vincent, I think a specific unit operation does not exist, and you should try to simulate the ejector putting together other unit-ops, namely expander, mixer, compressor.
      Maybe this paper could inspire some ideas:
      https://pdfslide.net/documents/ejector-modeling-in-hysys.html

       
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.