Files

101 lines
2.2 KiB
Python

from abc import ABC, abstractmethod
class Layer(ABC):
@property
@abstractmethod
def R(self) -> float: ...
class MaterialLayer(Layer):
def __init__(self, thermal_coefficient: float, thickness: float):
self.thermal_coefficient = thermal_coefficient
self.thickness = thickness
@property
def R(self) -> float:
return self.thickness / self.thermal_coefficient
class FixedRLayer(Layer):
def __init__(self, r_value: float):
self.r_value = r_value
@property
def R(self) -> float:
return self.r_value
class Interface(ABC):
@property
@abstractmethod
def HT(self) -> float: ...
class Surface(Interface):
def __init__(self, name: str, area: float, b: float = 1.0):
self.name = name
self.area = area
self.b = b
@property
@abstractmethod
def U(self) -> float: ...
@property
def HT(self) -> float:
return self.b * self.U * self.area
class LinearThermalBridge(Interface):
def __init__(self, name: str, length: float, psi: float):
self.name = name
self.length = length
self.psi = psi
@property
def HT(self) -> float:
return self.psi * self.length
class PointThermalBridge(Interface):
def __init__(self, name: str, chi: float):
self.name = name
self.chi = chi
@property
def HT(self) -> float:
return self.chi
class LayeredSurface(Surface):
def __init__(
self,
name: str,
area: float,
layers: list[Layer],
r_surface_1: float,
r_surface_2: float,
b: float = 1.0,
):
super().__init__(name, area, b)
self.layers = layers
self.r_surface_1 = r_surface_1
self.r_surface_2 = r_surface_2
@property
def U(self) -> float:
R_layers = sum(layer.R for layer in self.layers)
R = self.r_surface_1 + R_layers + self.r_surface_2
return 1 / R
class FixedUSurface(Surface):
def __init__(self, name: str, area: float, u_value: float, b: float = 1.0):
super().__init__(name, area, b)
self.u_value = u_value
@property
def U(self) -> float:
return self.u_value