diff --git a/cmd/validate/main.go b/cmd/validate/main.go index 1f29cae..564171e 100644 --- a/cmd/validate/main.go +++ b/cmd/validate/main.go @@ -5,8 +5,8 @@ import ( "encoding/json" "fmt" "github.com/thd-spatial-ai/ignis/internal/config" - "github.com/thd-spatial-ai/ignis/internal/hdcp" "github.com/thd-spatial-ai/ignis/internal/models" + "github.com/thd-spatial-ai/ignis/internal/pipeline" "log" "math" "os" @@ -190,11 +190,11 @@ func runPipelineTest(pool *pgxpool.Pool, tableName string, rowID int) TestResult // } // Create ignis instance and run pipeline - logger := hdcp.NewLogger(log.New(os.Stdout, "", 0)) - pipeline := hdcp.NewPipeline(tabulaData, logger) + logger := pipeline.NewLogger(log.New(os.Stdout, "", 0)) + p := pipeline.NewPipeline(tabulaData, logger) // Run the calculation pipeline - calculatedQHND, err := pipeline.Run() + calculatedQHND, err := p.Run() if err != nil { result.ErrorMessage = fmt.Sprintf("pipeline error: %v", err) return result diff --git a/data/README.md b/data/README.md index cd85e99..b8ec557 100644 --- a/data/README.md +++ b/data/README.md @@ -12,7 +12,7 @@ This directory contains the TABULA Webtool workbook used to seed the heat demand | **Project** | Intelligent Energy Europe, IEE/09/739/SI2.558245 | | **License** | [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) | -The workbook contains per-country building typology data (U-values, areas, infiltration rates, climate parameters) and reference heating demand values (`q_h_nd`) used to validate the HDCP pipeline within ±2.5 %. +The workbook contains per-country building typology data (U-values, areas, infiltration rates, climate parameters) and reference heating demand values (`q_h_nd`) used to validate the calculation pipeline within ±2.5 %. **Citation:** diff --git a/internal/hdcp/pipeline.go b/internal/pipeline/pipeline.go similarity index 97% rename from internal/hdcp/pipeline.go rename to internal/pipeline/pipeline.go index 2ad3e2e..e4cac04 100644 --- a/internal/hdcp/pipeline.go +++ b/internal/pipeline/pipeline.go @@ -1,4 +1,4 @@ -package hdcp +package pipeline import ( "fmt" @@ -52,7 +52,7 @@ type Pipeline struct { Lvl17 *calc.CalcLevel17 } -// NewPipeline initializes the HDCP pipeline with initial calculation level and logger. +// NewPipeline initializes the heating demand calculation pipeline with initial calculation level and logger. func NewPipeline(lvl0 *models.TabulaBuildingParameters, logger *Logger) *Pipeline { return &Pipeline{ Lvl0: lvl0, diff --git a/internal/hdcp/pipeline_test.go b/internal/pipeline/pipeline_test.go similarity index 99% rename from internal/hdcp/pipeline_test.go rename to internal/pipeline/pipeline_test.go index d2e5ee5..b519312 100644 --- a/internal/hdcp/pipeline_test.go +++ b/internal/pipeline/pipeline_test.go @@ -1,4 +1,4 @@ -package hdcp +package pipeline import ( "io" diff --git a/internal/service/hdcp_service.go b/internal/service/hdcp_service.go deleted file mode 100644 index c7d21d5..0000000 --- a/internal/service/hdcp_service.go +++ /dev/null @@ -1,48 +0,0 @@ -package service - -import ( - "log" - "os" - - "github.com/thd-spatial-ai/ignis/internal/hdcp" - "github.com/thd-spatial-ai/ignis/internal/models" -) - -// Re-export types for easier use in handlers -type TabulaBuildingParameters = models.TabulaBuildingParameters - -// IgnisService provides business logic for HDCP calculations -type IgnisService struct { - logger *hdcp.Logger -} - -// NewIgnisService creates a new HDCP service instance -func NewIgnisService() *IgnisService { - return &IgnisService{ - logger: hdcp.NewLogger(log.New(os.Stdout, "", 0)), - } -} - -// NewIgnisServiceWithLogger creates a new HDCP service with custom logger -func NewIgnisServiceWithLogger(logger *hdcp.Logger) *IgnisService { - return &IgnisService{ - logger: logger, - } -} - -// CalculateHeatingDemand executes the HDCP calculation pipeline. -// Returns the calculated q_h_nd (annual heating energy demand in kWh/(m²·a)). -func (s *IgnisService) CalculateHeatingDemand(buildingParams *models.TabulaBuildingParameters) (float64, error) { - pipeline := hdcp.NewPipeline(buildingParams, s.logger) - return pipeline.Run() -} - -// CalculateHeatingDemandWithDetails executes the HDCP calculation pipeline -// and returns the fully populated Pipeline struct for inspection of intermediate levels. -func (s *IgnisService) CalculateHeatingDemandWithDetails(buildingParams *models.TabulaBuildingParameters) (*hdcp.Pipeline, error) { - pipeline := hdcp.NewPipeline(buildingParams, s.logger) - if _, err := pipeline.Run(); err != nil { - return nil, err - } - return pipeline, nil -} diff --git a/internal/service/ignis_service.go b/internal/service/ignis_service.go new file mode 100644 index 0000000..abb9292 --- /dev/null +++ b/internal/service/ignis_service.go @@ -0,0 +1,48 @@ +package service + +import ( + "log" + "os" + + "github.com/thd-spatial-ai/ignis/internal/models" + "github.com/thd-spatial-ai/ignis/internal/pipeline" +) + +// Re-export types for easier use in handlers +type TabulaBuildingParameters = models.TabulaBuildingParameters + +// IgnisService provides business logic for heating demand calculations +type IgnisService struct { + logger *pipeline.Logger +} + +// NewIgnisService creates a new IgnisService instance +func NewIgnisService() *IgnisService { + return &IgnisService{ + logger: pipeline.NewLogger(log.New(os.Stdout, "", 0)), + } +} + +// NewIgnisServiceWithLogger creates a new IgnisService with custom logger +func NewIgnisServiceWithLogger(logger *pipeline.Logger) *IgnisService { + return &IgnisService{ + logger: logger, + } +} + +// CalculateHeatingDemand executes the heating demand calculation pipeline. +// Returns the calculated q_h_nd (annual heating energy demand in kWh/(m²·a)). +func (s *IgnisService) CalculateHeatingDemand(buildingParams *models.TabulaBuildingParameters) (float64, error) { + p := pipeline.NewPipeline(buildingParams, s.logger) + return p.Run() +} + +// CalculateHeatingDemandWithDetails executes the heating demand calculation pipeline +// and returns the fully populated Pipeline struct for inspection of intermediate levels. +func (s *IgnisService) CalculateHeatingDemandWithDetails(buildingParams *models.TabulaBuildingParameters) (*pipeline.Pipeline, error) { + p := pipeline.NewPipeline(buildingParams, s.logger) + if _, err := p.Run(); err != nil { + return nil, err + } + return p, nil +} diff --git a/internal/service/hdcp_service_test.go b/internal/service/ignis_service_test.go similarity index 94% rename from internal/service/hdcp_service_test.go rename to internal/service/ignis_service_test.go index baee455..a1cd973 100644 --- a/internal/service/hdcp_service_test.go +++ b/internal/service/ignis_service_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/thd-spatial-ai/ignis/internal/hdcp" "github.com/thd-spatial-ai/ignis/internal/models" + "github.com/thd-spatial-ai/ignis/internal/pipeline" ) // newTestParams returns a fully initialised TabulaBuildingParameters with all @@ -46,7 +46,7 @@ func TestNewIgnisService(t *testing.T) { } func TestNewIgnisServiceWithLogger(t *testing.T) { - logger := hdcp.NewLogger(log.New(os.Stdout, "", 0)) + logger := pipeline.NewLogger(log.New(os.Stdout, "", 0)) s := NewIgnisServiceWithLogger(logger) if s.logger != logger { t.Error("expected the provided logger to be used") @@ -56,7 +56,7 @@ func TestNewIgnisServiceWithLogger(t *testing.T) { func TestCalculateHeatingDemand_success(t *testing.T) { s := NewIgnisService() // An all-zero building is a division-by-zero case in the pipeline's own - // arithmetic (see internal/hdcp's own zero-input test) and legitimately + // arithmetic (see internal/pipeline's own zero-input test) and legitimately // yields NaN, not an error - the point here is that it completes without panicking. _, err := s.CalculateHeatingDemand(newTestParams()) if err != nil {