Skip to content

Commit

Permalink
updated pydantic models
Browse files Browse the repository at this point in the history
  • Loading branch information
jkwan2011 committed Oct 18, 2023
1 parent e641b32 commit 1ca7e1d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 66 deletions.
59 changes: 4 additions & 55 deletions rules-engine/src/rules_engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 10 additions & 11 deletions rules-engine/src/rules_engine/pydantic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 1ca7e1d

Please sign in to comment.