How do I access the latent heat of evaporation or alternatively the specific enthalpy at boiling and dew point of a material stream from withtin a Python Script Unit Operation? I could not manage to find anything in this Forum or teh API documentation.
BR
Christian
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
importclrimportSystemimportDWSIMfromSystemimport*clr.AddReference("System.Core")clr.ImportExtensions(System.Linq)ms=Flowsheet.GetFlowsheetSimulationObject("MSTR-000")pp=ms.PropertyPackagepp.CurrentMaterialStream=ms# get mixture compositionVz=ms.Phases[0].Compounds.Values.Select(lambdax:x.MoleFraction).Cast[Double]().ToArray()# get temperatureT=ms.Phases[0].Properties.temperature# get pressureP=ms.Phases[0].Properties.pressure# calculate mixture enthalpy as vaporhv=pp.DW_CalcEnthalpy(Vz,T,P,DWSIM.Thermodynamics.PropertyPackages.State.Vapor)# calculate mixture enthalpy as liquidhl=pp.DW_CalcEnthalpy(Vz,T,P,DWSIM.Thermodynamics.PropertyPackages.State.Liquid)# enthalpy of vaporizationhvap=hv-hl# kJ/kgprintstr(hvap)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
thank you very much for the quick response. Works like charm!
However, I am still a bit confused regarding the function calls and assignments and I was wondering if you could explain a bit what is actually happening with the following code:
pp = ms.PropertyPackage
pp.CurrentMaterialStream = ms
Translated this looks like the following to me:
ms.PropertyPackage.CurrentMaterialStream = ms
So, the object 'ms', which is an instance of Class 'MaterialStream' has the Property 'PropertyPackage', which again has the property 'CurrentMaterialStream', which is then set to 'ms', the "root" object itself. I would have assumed that the MaterialStream-object 'ms' should already now that its CurrentMaterialstream is 'itself'. Somehow I am missing something ...
Another curiosity regards your temperature call
T = ms.Phases[0].Properties.temperature
because I would have used the following instead:
T = fluid.GetPhase('Liquid1').Properties.temperature
Can you explain what is the difference? And what is the '[0]' referring to behind 'Phases'?
Best regards
Christian
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Every object in the flowsheet has an associated property package, if not explicitly then the default one is selected. Although the object knows about the property package, the opposite is not true.
The property package can only make calculations using only one material stream at a time, and it can be associated with another "foreign" stream when you get a reference to it from your stream.
Before making a calculation, we must associate the material stream with the property package so it can get the properties from that stream. This is done through the CurrentMaterialStream property.
Hello!
How do I access the latent heat of evaporation or alternatively the specific enthalpy at boiling and dew point of a material stream from withtin a Python Script Unit Operation? I could not manage to find anything in this Forum or teh API documentation.
BR
Christian
Hi Daniel,
thank you very much for the quick response. Works like charm!
However, I am still a bit confused regarding the function calls and assignments and I was wondering if you could explain a bit what is actually happening with the following code:
Translated this looks like the following to me:
So, the object 'ms', which is an instance of Class 'MaterialStream' has the Property 'PropertyPackage', which again has the property 'CurrentMaterialStream', which is then set to 'ms', the "root" object itself. I would have assumed that the MaterialStream-object 'ms' should already now that its CurrentMaterialstream is 'itself'. Somehow I am missing something ...
Another curiosity regards your temperature call
because I would have used the following instead:
Can you explain what is the difference? And what is the '[0]' referring to behind 'Phases'?
Best regards
Christian
Hi Christian,
For the first question:
For the second question: