Shivraj8615 commited on
Commit
747c020
verified
1 Parent(s): 87d8d0b

Update calculation.py

Browse files
Files changed (1) hide show
  1. calculation.py +18 -11
calculation.py CHANGED
@@ -3,7 +3,7 @@ import numpy as np
3
  import math
4
 
5
  class SteamPipe:
6
- def __init__(self, steam_flow, inlet_pressure, superheat, steam_temp, line_size, ambient_temp, ambient_velocity, insulation_material, cladding_material, insulation_data, cladding_data, steam_properties, user_insulation_thickness=None):
7
  self.steam_flow = steam_flow # kg/hr
8
  self.inlet_pressure = inlet_pressure # kg/cm虏g
9
  self.superheat = superheat # 掳C
@@ -13,11 +13,12 @@ class SteamPipe:
13
  self.ambient_velocity = ambient_velocity # m/s
14
  self.insulation_material = insulation_material
15
  self.cladding_material = cladding_material
16
-
17
- self.insulation_data = insulation_data
18
- self.cladding_data = cladding_data
19
- self.steam_properties = steam_properties
20
  self.user_insulation_thickness = user_insulation_thickness # User-defined insulation thickness
 
 
 
 
 
21
 
22
  def get_nearest_upper_value(self, df, column, value):
23
  """Gets the nearest upper value from a given dataframe column."""
@@ -26,16 +27,24 @@ class SteamPipe:
26
 
27
  def get_steam_property(self):
28
  """Fetches steam property (enthalpy, specific heat, etc.) based on pressure."""
29
- pressure = self.get_nearest_upper_value(self.steam_properties, 'Pressure', self.inlet_pressure)
30
- row = self.steam_properties[self.steam_properties['Pressure'] == pressure]
31
  if not row.empty:
32
  return row.iloc[0]
33
  else:
34
  raise ValueError("Steam property not found for given pressure")
35
 
 
 
 
 
 
 
 
 
36
  def calculate_heat_loss(self, insulation_thickness):
37
  """Calculates heat loss per unit length using Fourier鈥檚 Law for cylindrical surfaces."""
38
- k_insulation = self.get_nearest_upper_value(self.insulation_data, 'Thermal Conductivity', 0)
39
 
40
  r_inner = self.line_size / 2 # Inner radius (m)
41
  r_outer = r_inner + insulation_thickness # Outer radius (m)
@@ -54,7 +63,7 @@ class SteamPipe:
54
  def calculate_outlet_temperature(self, heat_loss):
55
  """Estimates outlet temperature based on heat loss."""
56
  steam_property = self.get_steam_property()
57
- specific_heat = steam_property['Specific Heat'] # J/kgK
58
  mass_flow_rate = self.steam_flow / 3600 # Convert kg/hr to kg/s
59
  delta_T = heat_loss / (mass_flow_rate * specific_heat)
60
  return max(self.steam_temp - delta_T, self.ambient_temp)
@@ -69,5 +78,3 @@ class SteamPipe:
69
 
70
  return outlet_temp, insulation_thickness, heat_loss
71
 
72
-
73
-
 
3
  import math
4
 
5
  class SteamPipe:
6
+ def __init__(self, steam_flow, inlet_pressure, superheat, steam_temp, line_size, ambient_temp, ambient_velocity, insulation_material, cladding_material, user_insulation_thickness=None):
7
  self.steam_flow = steam_flow # kg/hr
8
  self.inlet_pressure = inlet_pressure # kg/cm虏g
9
  self.superheat = superheat # 掳C
 
13
  self.ambient_velocity = ambient_velocity # m/s
14
  self.insulation_material = insulation_material
15
  self.cladding_material = cladding_material
 
 
 
 
16
  self.user_insulation_thickness = user_insulation_thickness # User-defined insulation thickness
17
+
18
+ # Load data from CSV files
19
+ self.insulation_data = pd.read_csv("insulation_data.csv")
20
+ self.cladding_data = pd.read_csv("cladding_data.csv")
21
+ self.steam_properties = pd.read_csv("steam_properties.csv")
22
 
23
  def get_nearest_upper_value(self, df, column, value):
24
  """Gets the nearest upper value from a given dataframe column."""
 
27
 
28
  def get_steam_property(self):
29
  """Fetches steam property (enthalpy, specific heat, etc.) based on pressure."""
30
+ pressure = self.get_nearest_upper_value(self.steam_properties, 'Pressure (Kg/cm虏g)', self.inlet_pressure)
31
+ row = self.steam_properties[self.steam_properties['Pressure (Kg/cm虏g)'] == pressure]
32
  if not row.empty:
33
  return row.iloc[0]
34
  else:
35
  raise ValueError("Steam property not found for given pressure")
36
 
37
+ def get_cladding_emissivity(self):
38
+ """Fetches emissivity of selected cladding material."""
39
+ row = self.cladding_data[self.cladding_data['Material'] == self.cladding_material]
40
+ if not row.empty:
41
+ return row['Emissivity'].values[0]
42
+ else:
43
+ raise ValueError("Cladding material not found")
44
+
45
  def calculate_heat_loss(self, insulation_thickness):
46
  """Calculates heat loss per unit length using Fourier鈥檚 Law for cylindrical surfaces."""
47
+ k_insulation = self.get_nearest_upper_value(self.insulation_data[self.insulation_data['Material'] == self.insulation_material], 'Thermal_Conductivity (W/mK)', 0)
48
 
49
  r_inner = self.line_size / 2 # Inner radius (m)
50
  r_outer = r_inner + insulation_thickness # Outer radius (m)
 
63
  def calculate_outlet_temperature(self, heat_loss):
64
  """Estimates outlet temperature based on heat loss."""
65
  steam_property = self.get_steam_property()
66
+ specific_heat = steam_property['Specific Heat (Cp) (kJ/kg路K)'] # kJ/kgK
67
  mass_flow_rate = self.steam_flow / 3600 # Convert kg/hr to kg/s
68
  delta_T = heat_loss / (mass_flow_rate * specific_heat)
69
  return max(self.steam_temp - delta_T, self.ambient_temp)
 
78
 
79
  return outlet_temp, insulation_thickness, heat_loss
80