diff --git a/pygfunction/gfunction.py b/pygfunction/gfunction.py index 2a431544..4ec827a5 100644 --- a/pygfunction/gfunction.py +++ b/pygfunction/gfunction.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from time import perf_counter import warnings +from abc import ABC, abstractmethod import matplotlib.pyplot as plt import numpy as np @@ -226,15 +227,15 @@ def __init__(self, boreholes_or_network, alpha, time=None, self._check_inputs() # Load the chosen solver - if self.method.lower()=='similarities': + if self.method.lower() == 'similarities': self.solver = _Similarities( self.boreholes, self.network, self.time, self.boundary_condition, **self.options) - elif self.method.lower()=='detailed': + elif self.method.lower() == 'detailed': self.solver = _Detailed( self.boreholes, self.network, self.time, self.boundary_condition, **self.options) - elif self.method.lower()=='equivalent': + elif self.method.lower() == 'equivalent': self.solver = _Equivalent( self.boreholes, self.network, self.time, self.boundary_condition, **self.options) @@ -1368,7 +1369,7 @@ def mixed_inlet_temperature( return gFunc.gFunc -class _BaseSolver(object): +class _BaseSolver(ABC): """ Template for solver classes. @@ -1499,11 +1500,13 @@ def __init__(self, boreholes, network, time, boundary_condition, return + @abstractmethod def initialize(self, *kwargs): """ Perform any calculation required at the initialization of the solver and returns the number of finite line heat sources in the borefield. + Raises ------ NotImplementedError @@ -1515,13 +1518,12 @@ def initialize(self, *kwargs): initialize the matrix of segment-to-segment thermal response factors (of size: nSources x nSources). - """ - raise NotImplementedError( - 'initialize class method not implemented, this method should ' - 'return the number of finite line heat sources in the borefield ' - 'used to initialize the matrix of segment-to-segment thermal ' - 'response factors (of size: nSources x nSources)') - return None + """ + pass + + @abstractmethod + def thermal_response_factors(self, time, alpha, kind='linear'): + pass def solve(self, time, alpha): """ @@ -2140,7 +2142,6 @@ def _thermal_response_factors_borehole_to_self(self, time, alpha): return h, i_segment, j_segment - class _Similarities(_BaseSolver): """ Similarities solver for the evaluation of the g-function.