Skip to content

Commit

Permalink
eliminate properties manager, flatten properties management
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchute committed Apr 17, 2024
1 parent 7994e8e commit 1a25d1d
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 110 deletions.
20 changes: 17 additions & 3 deletions glhe/input_processor/input_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

from jsonschema import SchemaError, ValidationError, validate

from glhe.properties.props_manager import PropsMGR
from glhe.ground_temps.ground_temp_factory import make_ground_temp_model
from glhe.properties.fluid_factory import get_fluid
from glhe.properties.base_properties import PropertiesBase
from glhe.utilities.functions import load_json, lower_obj


Expand All @@ -30,8 +32,20 @@ def __init__(self, json_input_path: Path):
self.validate_inputs(self.input_dict)

# load properties for later use
self.props_mgr = PropsMGR()
self.props_mgr.load_properties(self.input_dict)
try:
self.fluid = get_fluid(self.input_dict['fluid'])
except KeyError:
pass

try:
self.soil = PropertiesBase(self.input_dict['soil'])
try:
self.soil.get_temp = make_ground_temp_model(self.input_dict['ground-temperature-model']).get_temp
except KeyError:
pass

except KeyError:
pass

@staticmethod
def validate_inputs(input_dict: dict) -> None:
Expand Down
2 changes: 1 addition & 1 deletion glhe/profiles/constant_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def simulate_time_step(self, inputs: SimulationResponse) -> SimulationResponse:
if flow_rate == 0:
return inputs

specific_heat = self.ip.props_mgr.fluid.cp(self.inlet_temp)
specific_heat = self.ip.fluid.cp(self.inlet_temp)
self.outlet_temp = self.load / (flow_rate * specific_heat) + self.inlet_temp
return SimulationResponse(inputs.time, inputs.time_step, inputs.flow_rate, self.outlet_temp)

Expand Down
2 changes: 1 addition & 1 deletion glhe/profiles/external_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def simulate_time_step(self, inputs: SimulationResponse) -> SimulationResponse:
inlet_temp = inputs.temperature

self.load = self.get_value(t + dt)
specific_heat = self.ip.props_mgr.fluid.cp(inlet_temp)
specific_heat = self.ip.fluid.cp(inlet_temp)
self.outlet_temp = self.load / (flow_rate * specific_heat) + inlet_temp
return SimulationResponse(inputs.time, inputs.time_step, inputs.flow_rate, self.outlet_temp)

Expand Down
2 changes: 1 addition & 1 deletion glhe/profiles/pulse_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def simulate_time_step(self, inputs: SimulationResponse) -> SimulationResponse:

inlet_temp = inputs.temperature

specific_heat = self.ip.props_mgr.fluid.cp(inlet_temp)
specific_heat = self.ip.fluid.cp(inlet_temp)
self.outlet_temp = self.load / (flow_rate * specific_heat) + inlet_temp
return SimulationResponse(inputs.time, inputs.time_step, inputs.flow_rate, self.outlet_temp)
else:
Expand Down
2 changes: 1 addition & 1 deletion glhe/profiles/sinusoid_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def simulate_time_step(self, inputs: SimulationResponse) -> SimulationResponse:
inlet_temp = inputs.temperature

self.load = self.amplitude * sin(2 * pi * (t + dt) / self.period) + self.offset
specific_heat = self.ip.props_mgr.fluid.cp(inlet_temp)
specific_heat = self.ip.fluid.cp(inlet_temp)
self.outlet_temp = self.load / (flow_rate * specific_heat) + inlet_temp
return SimulationResponse(inputs.time, inputs.time_step, inputs.flow_rate, self.outlet_temp)

Expand Down
2 changes: 1 addition & 1 deletion glhe/profiles/synthetic_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def simulate_time_step(self, inputs: SimulationResponse) -> SimulationResponse:
inlet_temp = inputs.temperature

self.load = self.get_value(t + dt)
specific_heat = self.ip.props_mgr.fluid.cp(inlet_temp)
specific_heat = self.ip.fluid.cp(inlet_temp)
self.outlet_temp = self.load / (flow_rate * specific_heat) + inlet_temp
return SimulationResponse(inputs.time, inputs.time_step, inputs.flow_rate, self.outlet_temp)

Expand Down
56 changes: 0 additions & 56 deletions glhe/properties/props_manager.py

This file was deleted.

4 changes: 2 additions & 2 deletions glhe/topology/ground_heat_exchanger_long_time_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def __init__(self, inputs: dict, ip: InputProcessor, op: OutputProcessor):
self.op = op

# props instances
self.fluid = ip.props_mgr.fluid
self.soil = ip.props_mgr.soil
self.fluid = ip.fluid
self.soil = ip.soil

# geometry and other config parameters needed externally
self.h = inputs['length']
Expand Down
4 changes: 2 additions & 2 deletions glhe/topology/ground_heat_exchanger_short_time_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def __init__(self, inputs: dict, ip: InputProcessor, op: OutputProcessor):
self.op = op

# props instances
self.fluid = ip.props_mgr.fluid
self.soil = ip.props_mgr.soil
self.fluid = ip.fluid
self.soil = ip.soil

# init paths
self.paths = []
Expand Down
2 changes: 1 addition & 1 deletion glhe/topology/pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, inputs, ip, op):
PropertiesBase.__init__(self, pipe_props)

# local fluids reference
self.fluid = self.ip.props_mgr.fluid
self.fluid = self.ip.fluid

# key geometric parameters
self.inner_diameter = pipe_props["inner-diameter"]
Expand Down
4 changes: 2 additions & 2 deletions glhe/topology/single_u_tube_grouted_borehole.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def __init__(self, inputs, ip, op):
self.ip = ip
self.op = op

self.fluid = ip.props_mgr.fluid
self.soil = ip.props_mgr.soil
self.fluid = ip.fluid
self.soil = ip.soil

# get borehole definition data
if 'average-borehole' in inputs:
Expand Down
4 changes: 2 additions & 2 deletions glhe/topology/single_u_tube_grouted_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class SingleUTubeGroutedSegment:

def __init__(self, inputs, ip, op):
self.name = inputs['segment-name']
self.fluid = ip.props_mgr.fluid
self.soil = ip.props_mgr.soil
self.fluid = ip.fluid
self.soil = ip.soil

if 'average-pipe' in inputs:
pipe_inputs = {'average-pipe': inputs['average-pipe'], 'length': inputs['length']}
Expand Down
2 changes: 1 addition & 1 deletion glhe/topology/swedish_heat_pump.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, inputs, ip, op):
self.op = op

# local fluids reference
self.fluid = self.ip.props_mgr.fluid
self.fluid = self.ip.fluid

# input data
self.max_htg_set_point = inputs['max-heating-set-point']
Expand Down
36 changes: 0 additions & 36 deletions unit_tests/glhe/properties/tests_props_manager.py

This file was deleted.

0 comments on commit 1a25d1d

Please sign in to comment.