Menu

Extracting compound properties in python

The One
2019-05-10
2023-05-19
  • The One

    The One - 2019-05-10

    Hi. I am coding for a batch reactor in DWSIM. I require data of specific heat capacity of individual species in order to complete the reactor. Can someone help me out on how to extract the heat capacity data of individual species from ChemSep, CheDL database?

     
  • Daniel Medeiros

    Daniel Medeiros - 2019-05-14

    Do you require the Cp value itself or the parameters to calculate it?

     
  • The One

    The One - 2019-05-17

    I require the parameters to solve it. Also is there a way i can extract the appropriate equation for the corresponding phase? Thank you.

     

    Last edit: The One 2019-05-17
  • Daniel Medeiros

    Daniel Medeiros - 2019-05-17

    What exactly do you need? Describe how and what for you would use these parameters.

     
  • The One

    The One - 2019-05-18

    i am designing a batch reactor. I wanted the parameters of Cp value for the adiabatic condition. I am using the equation (Heat of reaction at temperature T)=(Increase in sensible heat of final products) + (Heat taken by products as latent heat). As of now, i am ignoring phase change and want to design for homogenous system. I require the value of parameters of Cp for finding the heat of reaction at temperature T. I am using the formula (Heat of reaction at standard temperature T0) + (integral from T0 to T of ((delta Cp) * dT)) where delta Cp = sum over all components (stoichometry * Cp). To find the integral value, I require the value of Cp parameters. Please suggest if you know a better method to do this. Thank you.

     
  • The One

    The One - 2019-05-22

    Thank you. Would be great if you could give an example of how to execute this in python.

     
  • The One

    The One - 2019-06-13

    Hey Daniel, I just wanted to see how GetTDependentProperty works. So i made just a material stream with only Argon as component in it. I have written the code as:
    a=feed[0].GetTDependentProperty("idealgasheatcapacity",298.15,"Argon","mass")
    I am getting the result of a as: Arrayfloat. Can u tell me how to input the parameters?
    Thank You

     
  • Daniel Medeiros

    Daniel Medeiros - 2019-06-18

    CAPE-OPEN functions always require and return array parameters. In this case just get the first element of the array.

     

    Last edit: Daniel Medeiros 2019-10-11
  • The One

    The One - 2019-06-18

    I had written the code:
    from DWSIM.Thermodynamics import
    import math
    from System import Array
    import clr
    clr.AddReference('DWSIM.MathOps.DotNumerics')
    from DotNumerics.ODE import

    feed=[0]
    feed[0]=ims1
    a=feed[0].GetTDependentProperty("idealgasheatcapacity",298.15,"Argon",None)
    Flowsheet.WriteMessage(str(a))

    DWSIM is returning an empty array. I think I have written the arguments in wrong format.
    The prescribed format suggested in VB code is:
    GetTDependentProperty(ByVal props As Object, ByVal temperature As Double, ByVal compIds As Object, ByRef propVals As Object)
    Can you tell me in which argument i have committed an error? Thank you.

     
  • Daniel Medeiros

    Daniel Medeiros - 2019-06-18

    compIds must be a string array:

    compIds = Array[string]("Argon")
    a=feed[0].GetTDependentProperty("idealgasheatcapacity",298.15,compIds,None)
    
     
  • The One

    The One - 2019-06-18

    Even after this modification, it is returning an empty array for a. I am using version 5.6 update 12. This version has the values for heat capacities. right?

     
  • Daniel Medeiros

    Daniel Medeiros - 2019-06-18
    compIds = ['Argon']
    props = ['idealgasheatcapacity']
    values = feed[0].GetTDependentProperty(props, 298.15, compIds, None)
    Flowsheet.ShowMessage(str(values[0]), 0, "")
    

    The returned value will be in kJ/kg.

     

    Last edit: Daniel Medeiros 2019-06-18
  • The One

    The One - 2019-06-19

    Thanks it worked.

     
  • red_doctor

    red_doctor - 2023-05-19

    I accidentally posted the following question in Help (Classic UI):

    "I've written a user-defined method for "Density" and "Viscosity" and added it to the NRTL package.

    Now how do I get a specific viscosity in a PythonScript unit operation? I'd like to calculate the viscosity and density for some arbitrary point, something similar to

    enthalpy = propertypackage.DW_CalcEnthalpy(mix, temp, press, state)
    "

    So now I've found this thread. Seems similar, but I can't use GetTDependentProperty, because I want it to depend on the mixture of different liquids in the stream. So I started reading PropertyPackages/FluidProperties.vb . Initially I thought that I could just call AUX_LIQDENS, for example, because it's declared as Overrideable, and I have written overrides in the package. But unfortunately neither the material stream nor the property package knows about AUX_LIQDENS().

    So what should I try next?

    Thanks for the help!!!

     
  • Daniel Medeiros

    Daniel Medeiros - 2023-05-19
    pp = ims1.PropertyPackage
    pp.CurrentMaterialStream = ims1
    dens = pp.AUX_LIQDENS(T, P) # T in K, P in Pa
    visc = pp.AUX_LIQVISCm(T, P, 1) # T in K, P in Pa
    

    In the above, DWSIM will use the liquid phase composition from ims1 to calculate liquid density and viscosity.

     
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.