Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cmd/validate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**

Expand Down
4 changes: 2 additions & 2 deletions internal/hdcp/pipeline.go → internal/pipeline/pipeline.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package hdcp
package pipeline

import (
"fmt"
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package hdcp
package pipeline

import (
"io"
Expand Down
48 changes: 0 additions & 48 deletions internal/service/hdcp_service.go

This file was deleted.

48 changes: 48 additions & 0 deletions internal/service/ignis_service.go
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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 {
Expand Down
Loading