0

Hello from a python newbe

I want to calculate some physical values. Therefore I have package loaded which works. I can use it with single values. But I do not only have single values, I have 100 of values, in two list. I want to calculate with given pressures and a temperatures the enthalpy. So I have two list, one for the pressure values one for the temperature values. I want to use them both in the package pyXSteam.

Here is my idea:

from pyXSteam.XSteam import XSteam
steamTable = XSteam(XSteam.UNIT_SYSTEM_MKS) 
T_ein= [398,397,396] #°C
P_ein=[29,27,26] #bara
Hin = steamTable.h_pt(P_ein,T_ein)

However, I don't understand how I give the two values form the lists (pressure, temperature - for testing I only used 3 values) to calculate the steamTable values. Can somebody explain me how to do this?

Thank you Thomas

THZ
  • 21
  • 3

2 Answers2

0

I assume that you are looking to loop through two lists at the same time. The zip() function should do what you need:

from pyXSteam.XSteam import XSteam

steamTable = XSteam(XSteam.UNIT_SYSTEM_MKS) 
T_ein= [398,397,396] #°C
P_ein=[29,27,26] #bara

Hin = []  # Declare a list
for t, p in zip(T_ein, P_ein):
    Hin.append(steamTable.h_pt(P_ein,T_ein))
    print(steamTable.h_pt(P_ein,T_ein)) # Comment out

print(Hin)
Daniel Lee
  • 7,189
  • 2
  • 26
  • 44
0
from pyXSteam.XSteam import XSteam
steamTable = XSteam(XSteam.UNIT_SYSTEM_MKS) 
T_ein = [398, 397, 396]
P_ein = [29, 27, 26]
Hin = []

for i in range(len(T_ein)):
    Hin.append(steamTable.h_pt(P_ein[i],T_ein[i]))

print(Hin)

Which will give you result as : [3228.718854742986, 3229.858248382559, 3229.3075222556217]

Kaustubh Ghole
  • 537
  • 1
  • 10
  • 25