Menu

Help on TP flash calculation

Anonymous
2016-09-22
2016-10-14
  • Anonymous

    Anonymous - 2016-09-22
     

    Last edit: Anonymous 2021-12-15
  • Anonymous

    Anonymous - 2016-09-29
     

    Last edit: Anonymous 2021-12-15
  • Daniel Medeiros

    Daniel Medeiros - 2016-09-29

    This is the same issue that I helped you with before: https://sourceforge.net/p/dwsim/discussion/scripting/thread/f8c48d5c/?limit=25#48f0

    When the stream contains a single compound, the material stream calculation routine will force a PH flash. You'll need to set the enthalpy instead of the temperature.

     
  • Anonymous

    Anonymous - 2016-09-30
     

    Last edit: Anonymous 2021-12-15
  • Anonymous

    Anonymous - 2016-10-03
     

    Last edit: Anonymous 2021-12-15
  • Daniel Medeiros

    Daniel Medeiros - 2016-10-03

    Reposting the answer incorrectly posted on another thread:

    You're right, my mistake. At least you should know by now to set the PH specs correctly...
    The reason why DWSIM switches to a PH flash when there's a single compound is because of the degrees of freedom. If you specify P and T with T being equal to the boiling point at P, how do we know if the state is liquid or vapor, or even worse, if there is any partial vaporization? The only way to know it is specifying enthalpy and finding the correct temperature and vapor fraction.

     
  • Daniel Medeiros

    Daniel Medeiros - 2016-10-03

    If you really want do to it your way, check the Calculate() routine: https://github.com/DanWBR/dwsim4/blob/master/DWSIM.Thermodynamics/Material%20Stream/MaterialStream.vb#L316

    Here is the logic for forcing a PH flash: https://github.com/DanWBR/dwsim4/blob/master/DWSIM.Thermodynamics/Material%20Stream/MaterialStream.vb#L383

    Calculate() has two bool parameters, the first one is to calculate equilibrium and the second one is to calculate stream phase properties. If you want to force a TP flash while still calculating the stream properties, call

    .DW_CalcEquilibrium(PropertyPackages.FlashSpec.T, PropertyPackages.FlashSpec.P)
    

    then

    .Calculate(false, true)
    

    I strongly believe that this should not be the standard calculation. DWSIM did this during its initial days and I ran into serious trouble with partial vaporization issues. There is no way to guarantee the state specification of a single compound with only T and P for simulation purposes. I believe that the correct way for you to do your procedure would be:

    1 - Define P, T and your desired state (V, L or S)
    2 - Calculate (or define) the enthalpy (H) with P, T and the desired state
    3 - Calculate equilibrium with P and H.

     

    Last edit: Daniel Medeiros 2016-10-03
  • Anonymous

    Anonymous - 2016-10-06
     

    Last edit: Anonymous 2021-12-15
  • Daniel Medeiros

    Daniel Medeiros - 2016-10-06

    Sorry, <redacted>.

    The DW_CalcEquilibrium is a routine from the Property Package class. It does an equilibrium calculation on the material stream currently associated with the property package instance, storing calculated phase amounts and composition on the respective Material Stream Phase instances.

    http://dwsim.inforside.com.br/api_help/html/M_DWSIM_Thermodynamics_PropertyPackages_PropertyPackage_DW_CalcEquilibrium.htm

    Here's how it is called from the Material Stream's Calculate routine (the property package is accessed through the PropertyPackage variable:

    https://github.com/DanWBR/dwsim4/blob/master/DWSIM.Thermodynamics/Material%20Stream/MaterialStream.vb#L353

    Your call would be something like:

    mystream.PropertyPackage.CurrentMaterialStream = mystream
    mystream.PropertyPackage.DW_CalcEquilibrium(DWSIM.Thermodynamics.PropertyPackages.FlashSpec.T, DWSIM.Thermodynamics.PropertyPackages.FlashSpec.P) 
    mystream.Calculate(false, true)
    

    Why don't you download the full source code from GitHub and open it on Visual Studio? It would be much easier to navigate and understand the code and the relations between the classes...

     

    Last edit: SourceForge Support 2021-12-20
  • Anonymous

    Anonymous - 2016-10-13
     

    Last edit: Anonymous 2021-12-15
  • Daniel Medeiros

    Daniel Medeiros - 2016-10-13

    The following snippet worked here:

    import clr
    import sys
    
    clr.AddReference("DWSIM.Thermodynamics")
    
    from System import *
    from DWSIM.Thermodynamics import *
    
    mystream = MSTR_001
    
    mystream.PropertyPackage.CurrentMaterialStream = mystream
    mystream.PropertyPackage.DW_CalcEquilibrium(PropertyPackages.FlashSpec.T, PropertyPackages.FlashSpec.P) 
    mystream.Calculate(False, True)
    

    I forgot to add a reference to DWSIM.Thermodynamics, where all thermo calculations are located now.

     
  • Anonymous

    Anonymous - 2016-10-13
     

    Last edit: Anonymous 2021-12-15
  • Anonymous

    Anonymous - 2016-10-14
     

    Last edit: Anonymous 2021-12-15
  • Daniel Medeiros

    Daniel Medeiros - 2016-10-14

    Your command tells the property package to perform a PV flash on the current material stream. First you'll need to set the vapor mole fraction, of course:

    vapphase = mystream.GetPhase("Vapor")
    vapphase.Properties.molarfraction = 0.5 # replace with the desired saturation value
    
    mystream.PropertyPackage.DW_CalcEquilibrium(PropertyPackages.FlashSpec.P, PropertyPackages.FlashSpec.VAP) 
    

    After that you can check the calculated temperature for the desired saturation..

     
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.