From 1ca7e1dd0c608be1ed6b63d81ce8e13326c40be4 Mon Sep 17 00:00:00 2001 From: Jonathan Kwan Date: Wed, 18 Oct 2023 00:56:11 +0000 Subject: [PATCH] updated pydantic models --- rules-engine/src/rules_engine/engine.py | 59 ++----------------- .../src/rules_engine/pydantic_models.py | 21 ++++--- 2 files changed, 14 insertions(+), 66 deletions(-) diff --git a/rules-engine/src/rules_engine/engine.py b/rules-engine/src/rules_engine/engine.py index a5653fab..e991c255 100644 --- a/rules-engine/src/rules_engine/engine.py +++ b/rules-engine/src/rules_engine/engine.py @@ -7,63 +7,12 @@ import numpy as np from pydantic import BaseModel, Field +from rules_engine.pydantic_models import SummaryInput, DhwInput, NaturalGasBillingInput, SummaryOutput, SensitivityGraph +def getOutputsNaturalGas(summaryInput: SummaryInput, dhwInput: Optional[DhwInput], naturalGasBillingInput: NaturalGasBillingInput)->(SummaryOutput, SensitivityGraph): + """""" -class SummaryInput(BaseModel): - """From Summary Tab""" - - name: str = Field(description="Summary!B4") - address: str = Field(description="Summary!B5") - design_temperature_override: Optional[float] = Field(description="Summary!B7") - living_area: float = Field(description="Summary!B10") - fuel_type: FuelType = Field(description="Summary!B11") - heat_sys_efficiency: float = Field(description="Summary!B12") - other_fuel_usage_override: Optional[float] = Field(description="Summary!B16") - thermostat_set_point: float = Field(description="Summary!B17") - setback_temp: float = Field(description="Summary!B18") - setback_hours_per_day: float = Field(description="Summary!B19") - - -class DhwInput(BaseModel): - """From DHW Tab""" - - number_of_occupants: int = Field(description="DHW!B4") - estimated_water_heating_efficiency: float = Field(description="DHW!B5") - stand_by_losses: float = Field(description="DHW!B6") - - -class OilPropaneBillingInput(BaseModel): - """From Oil-Propane tab""" - - period_end_date: date = Field(description="Oil-Propane!B") - gallons: float = Field(description="Oil-Propane!C") - - -class NaturalGasBillingInput(BaseModel): - """From Natural Gas tab""" - - period_end_date: date = Field(description="Natural Gas!B") - usage_therms: float = Field(description="Natural Gas!D") - - -class SummaryOutput(BaseModel): - """From Summary tab""" - - estimated_balance_point: float = Field( - description="Summary!B20" - ) # This is hand-calculated in the spreadsheet - other_fuel_usage: float = Field(description="Summary!B15") - average_indoor_temperature: float = Field(description="Summary!B24") - difference_between_ti_and_tbp: float = Field(description="Summary!B25") - design_temperature: float = Field(description="Summary!B26") - whole_home_ua: float = Field(description="Summary!B27") - standard_deviation_of_ua: float = Field(description="Summary!B28") - avg_heat_load: float = Field(description="Summary!B29") - max_heat_load: float = Field(description="Summary!B30") - - -class Constants: - balance_point_sensitivity: float = 2.0 + pass def hdd(avg_temp: float, balance_point: float) -> float: diff --git a/rules-engine/src/rules_engine/pydantic_models.py b/rules-engine/src/rules_engine/pydantic_models.py index b0b159d9..0db73cd4 100644 --- a/rules-engine/src/rules_engine/pydantic_models.py +++ b/rules-engine/src/rules_engine/pydantic_models.py @@ -17,20 +17,17 @@ class FuelType(Enum): class SummaryInput(BaseModel): """From Summary Tab""" - name: str = Field(description="Summary!B4") - address: str = Field(description="Summary!B5") - design_temperature_override: Optional[float] = Field(description="Summary!B7") + design_temperature: float living_area: float = Field(description="Summary!B10") fuel_type: FuelType = Field(description="Summary!B11") heating_system_efficiency: float = Field(description="Summary!B12") - other_fuel_usage_override: Optional[float] = Field(description="Summary!B16") thermostat_set_point: float = Field(description="Summary!B17") setback_temperature: float = Field(description="Summary!B18") setback_hours_per_day: float = Field(description="Summary!B19") class DhwInput(BaseModel): - """From DHW Tab""" + """From DHW (Domestic Hot Water) Tab """ number_of_occupants: int = Field(description="DHW!B4") estimated_water_heating_efficiency: float = Field(description="DHW!B5") stand_by_losses: float = Field(description="DHW!B6") @@ -60,22 +57,24 @@ class SummaryOutput(BaseModel): average_indoor_temperature: float = Field(description="Summary!B24") difference_between_ti_and_tbp: float = Field(description="Summary!B25") design_temperature: float = Field(description="Summary!B26") - whole_home_heat_loss_rate: float = Field(description="Summary!B27") + whole_home_heat_loss_rate: float = sField(description="Summary!B27") # UA = heat loss rate standard_deviation_of_heat_loss_rate: float = Field(description="Summary!B28") average_heat_load: float = Field(description="Summary!B29") maximum_heat_load: float = Field(description="Summary!B30") -class SensitivityGraphRow(BaseModel): - # From Summary page +class BalancePointGraphRow(BaseModel): + """From Summary page""" balance_pt: float = Field(description="Summary!G33:35") ua: float = Field(description="Summary!H33:35") change_in_ua: float = Field(description="Summary!I33:35") pct_change: float = Field(description="Summary!J33:35") std_dev: float = Field(description="Summary!K33:35") -class SensitivityGraph(BaseModel): - # From Summary page - records: List(SensitivityGraphRow) +class BalancePointGraph(BaseModel): + """From Summary page""" + records: List[BalancePointGraphRow] + + class Constants: