Files
heatloss/interfaces.py
T
omicron 2bda913270 Change the dataclass Interface into a regular class Surface.
Done for all subclasses of Interface too. This is a preparation for
later abstraction.
2026-06-08 14:25:46 +02:00

58 lines
1.2 KiB
Python

from abc import ABC, abstractmethod
from dataclasses import dataclass
@dataclass
class Layer:
thermal_coefficient: float
thickness: float
@property
def R(self):
return self.thickness / self.thermal_coefficient
class Surface(ABC):
def __init__(self, name: str, area: float):
self.name = name
self.area = area
@property
@abstractmethod
def U(self) -> float: ...
@property
def HT(self) -> float:
return self.U * self.area
class LayeredSurface(Surface):
def __init__(
self,
name: str,
area: float,
layers: list[Layer],
r_surface_1: float,
r_surface_2: float,
):
super().__init__(name, area)
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):
super().__init__(name, area)
self.u_value = u_value
@property
def U(self) -> float:
return self.u_value