File size: 4,074 Bytes
87d8d0b
 
 
 
 
747c020
87d8d0b
 
 
 
 
 
 
 
 
 
747c020
 
 
 
 
87d8d0b
 
 
 
 
 
 
 
747c020
 
87d8d0b
 
 
 
 
747c020
 
 
 
 
 
 
 
87d8d0b
 
747c020
87d8d0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
747c020
87d8d0b
 
 
 
3203f03
 
87d8d0b
3203f03
 
87d8d0b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import pandas as pd
import numpy as np
import math

class SteamPipe:
    def __init__(self, steam_flow, inlet_pressure, superheat, steam_temp, line_size, ambient_temp, ambient_velocity, insulation_material, cladding_material, user_insulation_thickness=None):
        self.steam_flow = steam_flow  # kg/hr
        self.inlet_pressure = inlet_pressure  # kg/cm²g
        self.superheat = superheat  # °C
        self.steam_temp = steam_temp  # °C
        self.line_size = float(line_size) * 0.0254  # Convert inch to meters (direct input, no lookup)
        self.ambient_temp = ambient_temp  # °C
        self.ambient_velocity = ambient_velocity  # m/s
        self.insulation_material = insulation_material
        self.cladding_material = cladding_material
        self.user_insulation_thickness = user_insulation_thickness  # User-defined insulation thickness
        
        # Load data from CSV files
        self.insulation_data = pd.read_csv("insulation_data.csv")
        self.cladding_data = pd.read_csv("cladding_data.csv")
        self.steam_properties = pd.read_csv("steam_properties.csv")
    
    def get_nearest_upper_value(self, df, column, value):
        """Gets the nearest upper value from a given dataframe column."""
        filtered_values = df[df[column] >= value]
        return filtered_values[column].min() if not filtered_values.empty else df[column].max()
    
    def get_steam_property(self):
        """Fetches steam property (enthalpy, specific heat, etc.) based on pressure."""
        pressure = self.get_nearest_upper_value(self.steam_properties, 'Pressure (Kg/cm²g)', self.inlet_pressure)
        row = self.steam_properties[self.steam_properties['Pressure (Kg/cm²g)'] == pressure]
        if not row.empty:
            return row.iloc[0]
        else:
            raise ValueError("Steam property not found for given pressure")

    def get_cladding_emissivity(self):
        """Fetches emissivity of selected cladding material."""
        row = self.cladding_data[self.cladding_data['Material'] == self.cladding_material]
        if not row.empty:
            return row['Emissivity'].values[0]
        else:
            raise ValueError("Cladding material not found")
    
    def calculate_heat_loss(self, insulation_thickness):
        """Calculates heat loss per unit length using Fourier’s Law for cylindrical surfaces."""
        k_insulation = self.get_nearest_upper_value(self.insulation_data[self.insulation_data['Material'] == self.insulation_material], 'Thermal_Conductivity (W/mK)', 0)
        
        r_inner = self.line_size / 2  # Inner radius (m)
        r_outer = r_inner + insulation_thickness  # Outer radius (m)
        
        # Fourier’s Law for cylindrical coordinates
        heat_loss = (2 * math.pi * (self.steam_temp - self.ambient_temp)) / (math.log(r_outer / r_inner) / k_insulation)
        return heat_loss  # W/m
    
    def calculate_insulation_thickness(self):
        """Determines required insulation thickness to minimize heat loss, or uses user-defined value."""
        if self.user_insulation_thickness is not None:
            return self.user_insulation_thickness * 0.001  # Convert mm to meters
        thickness = self.get_nearest_upper_value(self.insulation_data[self.insulation_data['Material'] == self.insulation_material], 'Thickness', 0)
        return thickness * 0.001  # Convert mm to meters
    
    def calculate_outlet_temperature(self, heat_loss):
        """Estimates outlet temperature based on heat loss."""
        steam_property = self.get_steam_property()
        specific_heat = steam_property['Specific Heat (Cp) (kJ/kg·K)']  # kJ/kgK
        mass_flow_rate = self.steam_flow / 3600  # Convert kg/hr to kg/s
        delta_T = heat_loss / (mass_flow_rate * specific_heat)
        return max(self.steam_temp - delta_T, self.ambient_temp)
    
    def calculate(self, required_thickness):
        heat_loss = self.calculate_heat_loss(required_thickness)
        outlet_temp = self.calculate_outlet_temperature(heat_loss)
        return outlet_temp, heat_loss