diff --git a/glhe/profiles/constant_load.py b/glhe/profiles/constant_load.py index 7a9c0643..0fbbac19 100644 --- a/glhe/profiles/constant_load.py +++ b/glhe/profiles/constant_load.py @@ -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.get_cp(self.inlet_temp) + specific_heat = self.ip.props_mgr.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) diff --git a/glhe/profiles/external_load.py b/glhe/profiles/external_load.py index 6576c0b4..64127fc5 100644 --- a/glhe/profiles/external_load.py +++ b/glhe/profiles/external_load.py @@ -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.get_cp(inlet_temp) + specific_heat = self.ip.props_mgr.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) diff --git a/glhe/profiles/pulse_load.py b/glhe/profiles/pulse_load.py index 607167a6..595c5afd 100644 --- a/glhe/profiles/pulse_load.py +++ b/glhe/profiles/pulse_load.py @@ -29,7 +29,7 @@ def simulate_time_step(self, inputs: SimulationResponse) -> SimulationResponse: inlet_temp = inputs.temperature - specific_heat = self.ip.props_mgr.fluid.get_cp(inlet_temp) + specific_heat = self.ip.props_mgr.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: diff --git a/glhe/profiles/sinusoid_load.py b/glhe/profiles/sinusoid_load.py index 6cabda8b..9e900092 100644 --- a/glhe/profiles/sinusoid_load.py +++ b/glhe/profiles/sinusoid_load.py @@ -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.get_cp(inlet_temp) + specific_heat = self.ip.props_mgr.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) diff --git a/glhe/profiles/synthetic_load.py b/glhe/profiles/synthetic_load.py index 4c8f4e5b..be04fc97 100644 --- a/glhe/profiles/synthetic_load.py +++ b/glhe/profiles/synthetic_load.py @@ -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.get_cp(inlet_temp) + specific_heat = self.ip.props_mgr.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) diff --git a/glhe/properties/fluid_factory.py b/glhe/properties/fluid_factory.py new file mode 100644 index 00000000..0ba694e3 --- /dev/null +++ b/glhe/properties/fluid_factory.py @@ -0,0 +1,28 @@ +from __future__ import annotations + +from scp.ethyl_alcohol import EthylAlcohol +from scp.ethylene_glycol import EthyleneGlycol +from scp.methyl_alcohol import MethylAlcohol +from scp.propylene_glycol import PropyleneGlycol +from scp.water import Water + + +def get_fluid(inputs: dict) -> EthylAlcohol | EthyleneGlycol | MethylAlcohol | PropyleneGlycol | Water: + fluid_type_str = inputs['fluid-type'].upper() + if fluid_type_str == "WATER": + concentration = 0 + return Water() + elif fluid_type_str == "EA": + concentration = inputs['concentration'] / 100.0 + return EthylAlcohol(concentration) + elif fluid_type_str == "EG": + concentration = inputs['concentration'] / 100.0 + return EthyleneGlycol(concentration) + elif fluid_type_str == "MA": + concentration = inputs['concentration'] / 100.0 + return MethylAlcohol(concentration) + elif fluid_type_str == "PG": + concentration = inputs['concentration'] / 100.0 + return PropyleneGlycol(concentration) + else: + raise ValueError(f"Fluid '{fluid_type_str}' fluid is not valid.") diff --git a/glhe/properties/fluid_properties.py b/glhe/properties/fluid_properties.py deleted file mode 100644 index 57f7c2ff..00000000 --- a/glhe/properties/fluid_properties.py +++ /dev/null @@ -1,92 +0,0 @@ -from __future__ import annotations - -from scp.ethyl_alcohol import EthylAlcohol -from scp.ethylene_glycol import EthyleneGlycol -from scp.methyl_alcohol import MethylAlcohol -from scp.propylene_glycol import PropyleneGlycol -from scp.water import Water - - -class Fluid: - def __init__(self, inputs: dict): - self.type = inputs['fluid-type'].upper() - if self.type == "WATER": - concentration = 0 - self.fluid = Water() - elif self.type == "EA": - concentration = inputs['concentration'] / 100.0 - self.fluid = EthylAlcohol(concentration) - elif self.type == "EG": - concentration = inputs['concentration'] / 100.0 - self.fluid = EthyleneGlycol(concentration) - elif self.type == "MA": - concentration = inputs['concentration'] / 100.0 - self.fluid = MethylAlcohol(concentration) - elif self.type == "PG": - concentration = inputs['concentration'] / 100.0 - self.fluid = PropyleneGlycol(concentration) - else: - raise ValueError("Fluid '{}' fluid is not valid.".format(self.type)) - - self.min_temp = self.fluid.t_min - self.max_temp = self.fluid.t_max - - def get_cp(self, temperature: int | float) -> float: - """ - Computes the fluid specific heat - - :param temperature: temperature, in Celsius - :returns fluid specific heat in [J/kg-K] - """ - - return self.fluid.specific_heat(temperature) - - def get_k(self, temperature: int | float) -> float: - """ - Computes the fluid conductivity - - :param temperature: temperature, in Celsius - :return: fluid conductivity in [W/m-K] - """ - - return self.fluid.conductivity(temperature) - - def get_mu(self, temperature: int | float) -> float: - """ - Computes the fluid viscosity - - :param temperature: temperature, in Celsius - :return: fluid viscosity in [Pa-s] - """ - - return self.fluid.viscosity(temperature) - - def get_pr(self, temperature: int | float) -> float: - """ - Computes the fluid Prandtl number - - :param temperature: temperature, in Celsius - :return: fluid Prandtl number - """ - - return self.fluid.prandtl(temperature) - - def get_rho(self, temperature: int | float) -> float: - """ - Computes the fluid density - - :param temperature: temperature, in Celsius - :return: fluid density in [kg/m^3] - """ - - return self.fluid.density(temperature) - - def get_rho_cp(self, temperature: int | float) -> float: - """ - Computes the fluid volume-specific heat capacity - - :param temperature: temperature, in Celsius - :return: fluid volume-specific heat capacity in [J/m3-K] - """ - - return self.fluid.density(temperature) * self.fluid.specific_heat(temperature) diff --git a/glhe/properties/fluid_property_types.py b/glhe/properties/fluid_property_types.py deleted file mode 100644 index a112820a..00000000 --- a/glhe/properties/fluid_property_types.py +++ /dev/null @@ -1,9 +0,0 @@ -from enum import Enum - - -class FluidPropertyType(Enum): - CONDUCTIVITY = 1 - SPECIFIC_HEAT = 2 - DENSITY = 3 - PRANDTL = 4 - VISCOSITY = 5 diff --git a/glhe/properties/props_manager.py b/glhe/properties/props_manager.py index c3186201..133a4d0c 100644 --- a/glhe/properties/props_manager.py +++ b/glhe/properties/props_manager.py @@ -1,6 +1,6 @@ from glhe.ground_temps.ground_temp_factory import make_ground_temp_model from glhe.properties.base_properties import PropertiesBase -from glhe.properties.fluid_properties import Fluid +from glhe.properties.fluid_factory import get_fluid class PropsMGR: @@ -36,7 +36,7 @@ def _add_fluid_props_inst(self, inputs: dict) -> None: :param inputs: fluid input dict """ - self.fluid = Fluid(inputs) + self.fluid = get_fluid(inputs) def _add_soil_props_inst(self, inputs: dict) -> None: """ diff --git a/glhe/topology/ground_heat_exchanger_long_time_step.py b/glhe/topology/ground_heat_exchanger_long_time_step.py index aa1552f6..9900a6c6 100644 --- a/glhe/topology/ground_heat_exchanger_long_time_step.py +++ b/glhe/topology/ground_heat_exchanger_long_time_step.py @@ -113,7 +113,7 @@ def simulate_time_step(self, inputs: SimulationResponse) -> SimulationResponse: c_2 = (self.c_0 * g + resist_b * g_b) - cp = self.fluid.get_cp(inlet_temp) + cp = self.fluid.cp(inlet_temp) c_3 = (flow_rate_path * cp) / self.h q_prev = self.load_agg.get_q_prev() diff --git a/glhe/topology/ground_heat_exchanger_short_time_step.py b/glhe/topology/ground_heat_exchanger_short_time_step.py index c26f30f0..8d620d8b 100644 --- a/glhe/topology/ground_heat_exchanger_short_time_step.py +++ b/glhe/topology/ground_heat_exchanger_short_time_step.py @@ -168,8 +168,8 @@ def generate_g(self) -> None: 'diameter': d_ave_bh['diameter'], 'borehole-resistance': d_ave_bh['borehole-resistance'], 'convection-resistance': d_ave_bh['pipe-conv-resistance'], - 'fluid-specific-heat': self.fluid.get_cp(20), - 'fluid-density': self.fluid.get_rho(20), + 'fluid-specific-heat': self.fluid.cp(20), + 'fluid-density': self.fluid.rho(20), 'pipe-conductivity': d_ave_bh['pipe-conductivity'], 'pipe-specific-heat': d_ave_bh['pipe-specific-heat'], 'pipe-density': d_ave_bh['pipe-density'], @@ -219,7 +219,7 @@ def generate_g_b(self, flow_rate=0.5): g_b = [] for t in times: - cp = self.fluid.get_cp(temperature) + cp = self.fluid.cp(temperature) temperature = temperature + q_tot / (flow_rate * cp) response = SimulationResponse(t, dt, flow_rate, temperature) temperature = self.simulate_time_step(response).temperature @@ -235,7 +235,7 @@ def generate_g_b(self, flow_rate=0.5): end_time = self.ip.input_dict['simulation']['runtime'] while err > 0.02: t += dt - cp = self.fluid.get_cp(temperature) + cp = self.fluid.cp(temperature) temperature = temperature + q_tot / (flow_rate * cp) response = SimulationResponse(t, dt, flow_rate, temperature) temperature = self.simulate_time_step(response).temperature @@ -306,7 +306,7 @@ def simulate_time_step(self, inputs: SimulationResponse) -> SimulationResponse: # update report variables # TODO: generalize first-law computations everywhere - cp = self.fluid.get_cp(inlet_temp) + cp = self.fluid.cp(inlet_temp) self.heat_rate = flow * cp * (inlet_temp - outlet_temp) self.heat_rate_bh = self.get_heat_rate_bh() self.inlet_temperature = inputs.temperature @@ -333,7 +333,7 @@ def mix_paths(self, responses: list) -> float: for r in responses: temp = r.temperature m_dot = r.flow_rate - cp = self.fluid.get_cp(temp) + cp = self.fluid.cp(temp) sum_mdot_cp_temp += m_dot * cp * temp sum_mdot += m_dot sum_cp += cp diff --git a/glhe/topology/pipe.py b/glhe/topology/pipe.py index 6a6e9a89..45abf90b 100644 --- a/glhe/topology/pipe.py +++ b/glhe/topology/pipe.py @@ -88,7 +88,7 @@ def calc_transit_time(self, flow_rate: float, temperature: float) -> float: :param temperature: temperature, C :return: transit time, s """ - v_dot = flow_rate / self.fluid.get_rho(temperature) + v_dot = flow_rate / self.fluid.rho(temperature) return self.fluid_vol / v_dot def simulate_time_step(self, inputs: SimulationResponse) -> SimulationResponse: @@ -136,7 +136,7 @@ def simulate_time_step(self, inputs: SimulationResponse) -> SimulationResponse: tau_0 = tau - num_cells * tau_n # volume flow rate - v_dot = m_dot / self.fluid.get_rho(inlet_temp) + v_dot = m_dot / self.fluid.rho(inlet_temp) # volume for ideal-mixed cells v_n = tau_n * v_dot @@ -238,7 +238,7 @@ def m_dot_to_re(self, flow_rate, temp) -> float: :param temp: temperature, C :return: Reynolds number """ - self.re = 4 * flow_rate / (self.fluid.get_mu(temp) * pi * self.inner_diameter) + self.re = 4 * flow_rate / (self.fluid.mu(temp) * pi * self.inner_diameter) return self.re def calc_friction_factor(self, re: float) -> float: @@ -305,7 +305,7 @@ def calc_conv_resist(self, flow_rate: float, temperature: float): nu = (1 - sigma) * nu_low + sigma * nu_high else: nu = self.turbulent_nusselt(re, temperature) - self.resist_conv = 1 / (nu * pi * self.fluid.get_k(temperature)) + self.resist_conv = 1 / (nu * pi * self.fluid.k(temperature)) return self.resist_conv def calc_resist(self, flow_rate: float, temperature: float): @@ -344,7 +344,7 @@ def turbulent_nusselt(self, re: float, temperature: float): """ f = self.calc_friction_factor(re) - pr = self.fluid.get_pr(temperature) + pr = self.fluid.pr(temperature) return (f / 8) * (re - 1000) * pr / (1 + 12.7 * (f / 8) ** 0.5 * (pr ** (2 / 3) - 1)) @staticmethod diff --git a/glhe/topology/single_u_tube_grouted_borehole.py b/glhe/topology/single_u_tube_grouted_borehole.py index 57719cfe..41423126 100644 --- a/glhe/topology/single_u_tube_grouted_borehole.py +++ b/glhe/topology/single_u_tube_grouted_borehole.py @@ -247,7 +247,7 @@ def calc_bh_effective_resistance_uhf(self, temperature: float, self.calc_bh_average_resistance(temperature, flow_rate, pipe_resist) pt_1 = 1 / (3 * self.resist_bh_total_internal) - pt_2 = (self.h / (self.fluid.get_cp(temperature) * flow_rate)) ** 2 + pt_2 = (self.h / (self.fluid.cp(temperature) * flow_rate)) ** 2 resist_short_circuiting = pt_1 * pt_2 self.resist_bh_effective = self.resist_bh_ave + resist_short_circuiting @@ -337,7 +337,7 @@ def simulate_time_step(self, inputs: SimulationResponse) -> SimulationResponse: # update report variables self.inlet_temperature = inlet_temp self.outlet_temperature = self.pipe_2.outlet_temperature - cp = self.fluid.get_cp(inlet_temp) + cp = self.fluid.cp(inlet_temp) self.heat_rate = flow_rate * cp * (inlet_temp - self.outlet_temperature) self.heat_rate_bh = self.get_heat_rate_bh() diff --git a/glhe/topology/single_u_tube_grouted_segment.py b/glhe/topology/single_u_tube_grouted_segment.py index 99e5d518..c7888f46 100644 --- a/glhe/topology/single_u_tube_grouted_segment.py +++ b/glhe/topology/single_u_tube_grouted_segment.py @@ -155,8 +155,8 @@ def simulate_time_step(self, time_step: float, inputs: TimeStepStructure) -> np. self.boundary_temp = inputs.boundary_temp self.bh_resist = inputs.bh_resist self.dc_resist = inputs.dc_resist - self.fluid_cp = self.fluid.get_cp(self.inlet_temp_1) - self.fluid_heat_capacity = self.fluid.get_rho(self.inlet_temp_1) * self.fluid_cp + self.fluid_cp = self.fluid.cp(self.inlet_temp_1) + self.fluid_heat_capacity = self.fluid.rho(self.inlet_temp_1) * self.fluid_cp solver = RK45(self.right_hand_side, 0, self.y, time_step) while solver.status != 'finished': diff --git a/glhe/topology/swedish_heat_pump.py b/glhe/topology/swedish_heat_pump.py index 109786ee..25ef61a4 100644 --- a/glhe/topology/swedish_heat_pump.py +++ b/glhe/topology/swedish_heat_pump.py @@ -283,7 +283,7 @@ def simulate_time_step(self, inputs: SimulationResponse) -> SimulationResponse: self.hp_rtf = self.wtr_htg_rtf + self.htg_rtf self.heat_extraction = -self.wtr_htg_heat_extraction - self.htg_heat_extraction - cp = self.fluid.get_cp(inlet_temp) + cp = self.fluid.cp(inlet_temp) outlet_temp = inlet_temp + self.heat_extraction / (flow_rate * cp) response = SimulationResponse(time, dt, flow_rate, outlet_temp, hp_src_heat_rate=self.heat_extraction) diff --git a/unit_tests/glhe/input_processor/test_input_processor.py b/unit_tests/glhe/input_processor/test_input_processor.py index 78af5dbd..312a4d0e 100644 --- a/unit_tests/glhe/input_processor/test_input_processor.py +++ b/unit_tests/glhe/input_processor/test_input_processor.py @@ -74,15 +74,15 @@ def test_validate_fluid(self): self.run_validate(d) - d = {'fluid': {'fluid-type': 'EA', 'concentration': 100}} + d = {'fluid': {'fluid-type': 'EA', 'concentration': 60}} self.run_validate(d) - d = {'fluid': {'fluid-type': 'EG', 'concentration': 100}} + d = {'fluid': {'fluid-type': 'EG', 'concentration': 60}} self.run_validate(d) - d = {'fluid': {'fluid-type': 'PG', 'concentration': 100}} + d = {'fluid': {'fluid-type': 'PG', 'concentration': 60}} self.run_validate(d) diff --git a/unit_tests/glhe/properties/test_fluid.py b/unit_tests/glhe/properties/test_fluid.py index 9d0c308e..82c9223c 100644 --- a/unit_tests/glhe/properties/test_fluid.py +++ b/unit_tests/glhe/properties/test_fluid.py @@ -6,28 +6,28 @@ from scp.propylene_glycol import PropyleneGlycol from scp.water import Water -from glhe.properties.fluid_properties import Fluid +from glhe.properties.fluid_factory import get_fluid class TestFluid(unittest.TestCase): def test_init(self): - tst_w = Fluid({'fluid-type': 'water'}) - self.assertTrue(isinstance(tst_w.fluid, Water)) + tst_w = get_fluid({'fluid-type': 'water'}) + self.assertTrue(isinstance(tst_w, Water)) - tst_ea = Fluid({'fluid-type': 'EA', 'concentration': 50}) - self.assertTrue(isinstance(tst_ea.fluid, EthylAlcohol)) + tst_ea = get_fluid({'fluid-type': 'EA', 'concentration': 50}) + self.assertTrue(isinstance(tst_ea, EthylAlcohol)) - tst_eg = Fluid({'fluid-type': 'EG', 'concentration': 50}) - self.assertTrue(isinstance(tst_eg.fluid, EthyleneGlycol)) + tst_eg = get_fluid({'fluid-type': 'EG', 'concentration': 50}) + self.assertTrue(isinstance(tst_eg, EthyleneGlycol)) - tst_ma = Fluid({'fluid-type': 'MA', 'concentration': 50}) - self.assertTrue(isinstance(tst_ma.fluid, MethylAlcohol)) + tst_ma = get_fluid({'fluid-type': 'MA', 'concentration': 50}) + self.assertTrue(isinstance(tst_ma, MethylAlcohol)) - tst_pg = Fluid({'fluid-type': 'PG', 'concentration': 50}) - self.assertTrue(isinstance(tst_pg.fluid, PropyleneGlycol)) + tst_pg = get_fluid({'fluid-type': 'PG', 'concentration': 50}) + self.assertTrue(isinstance(tst_pg, PropyleneGlycol)) - self.assertRaises(ValueError, lambda: Fluid({'fluid-type': 'Not A Fluid', 'concentration': 0})) + self.assertRaises(ValueError, lambda: get_fluid({'fluid-type': 'Not A Fluid', 'concentration': 0})) def test_cond(self): """ @@ -42,11 +42,11 @@ def test_cond(self): # TODO: convert to fractional error tolerance = 1E-2 - tst = Fluid({'fluid-type': 'water'}) - self.assertAlmostEqual(tst.get_k(20), 0.598, delta=tolerance) - self.assertAlmostEqual(tst.get_k(40), 0.631, delta=tolerance) - self.assertAlmostEqual(tst.get_k(60), 0.654, delta=tolerance) - self.assertAlmostEqual(tst.get_k(80), 0.670, delta=tolerance) + tst = get_fluid({'fluid-type': 'water'}) + self.assertAlmostEqual(tst.k(20), 0.598, delta=tolerance) + self.assertAlmostEqual(tst.k(40), 0.631, delta=tolerance) + self.assertAlmostEqual(tst.k(60), 0.654, delta=tolerance) + self.assertAlmostEqual(tst.k(80), 0.670, delta=tolerance) def test_cp(self): """ @@ -61,11 +61,11 @@ def test_cp(self): # TODO: convert to fractional error tolerance = 4.0 - tst = Fluid({'fluid-type': 'water'}) - self.assertAlmostEqual(tst.get_cp(20), 4182, delta=tolerance) - self.assertAlmostEqual(tst.get_cp(40), 4179, delta=tolerance) - self.assertAlmostEqual(tst.get_cp(60), 4185, delta=tolerance) - self.assertAlmostEqual(tst.get_cp(80), 4197, delta=tolerance) + tst = get_fluid({'fluid-type': 'water'}) + self.assertAlmostEqual(tst.cp(20), 4182, delta=tolerance) + self.assertAlmostEqual(tst.cp(40), 4179, delta=tolerance) + self.assertAlmostEqual(tst.cp(60), 4185, delta=tolerance) + self.assertAlmostEqual(tst.cp(80), 4197, delta=tolerance) def test_dens(self): """ @@ -80,11 +80,11 @@ def test_dens(self): # TODO: convert to fractional error tolerance = 1.0 - tst = Fluid({'fluid-type': 'water'}) - self.assertAlmostEqual(tst.get_rho(20), 998.0, delta=tolerance) - self.assertAlmostEqual(tst.get_rho(40), 992.1, delta=tolerance) - self.assertAlmostEqual(tst.get_rho(60), 983.3, delta=tolerance) - self.assertAlmostEqual(tst.get_rho(80), 971.8, delta=tolerance) + tst = get_fluid({'fluid-type': 'water'}) + self.assertAlmostEqual(tst.rho(20), 998.0, delta=tolerance) + self.assertAlmostEqual(tst.rho(40), 992.1, delta=tolerance) + self.assertAlmostEqual(tst.rho(60), 983.3, delta=tolerance) + self.assertAlmostEqual(tst.rho(80), 971.8, delta=tolerance) def test_pr(self): """ @@ -99,11 +99,11 @@ def test_pr(self): # TODO: convert to fractional error tolerance = 1E-1 - tst = Fluid({'fluid-type': 'water'}) - self.assertAlmostEqual(tst.get_pr(20), 7.01, delta=tolerance) - self.assertAlmostEqual(tst.get_pr(40), 4.32, delta=tolerance) - self.assertAlmostEqual(tst.get_pr(60), 2.99, delta=tolerance) - self.assertAlmostEqual(tst.get_pr(80), 2.22, delta=tolerance) + tst = get_fluid({'fluid-type': 'water'}) + self.assertAlmostEqual(tst.pr(20), 7.01, delta=tolerance) + self.assertAlmostEqual(tst.pr(40), 4.32, delta=tolerance) + self.assertAlmostEqual(tst.pr(60), 2.99, delta=tolerance) + self.assertAlmostEqual(tst.pr(80), 2.22, delta=tolerance) def test_visc(self): """ @@ -118,8 +118,8 @@ def test_visc(self): # TODO: convert to fractional error tolerance = 1E-4 - tst = Fluid({'fluid-type': 'water'}) - self.assertAlmostEqual(tst.get_mu(20), 1.002E-3, delta=tolerance) - self.assertAlmostEqual(tst.get_mu(40), 0.653E-3, delta=tolerance) - self.assertAlmostEqual(tst.get_mu(60), 0.467E-3, delta=tolerance) - self.assertAlmostEqual(tst.get_mu(80), 0.355E-3, delta=tolerance) + tst = get_fluid({'fluid-type': 'water'}) + self.assertAlmostEqual(tst.mu(20), 1.002E-3, delta=tolerance) + self.assertAlmostEqual(tst.mu(40), 0.653E-3, delta=tolerance) + self.assertAlmostEqual(tst.mu(60), 0.467E-3, delta=tolerance) + self.assertAlmostEqual(tst.mu(80), 0.355E-3, delta=tolerance)