def test_density_at_temp_single_out_of_range(self): dc = Density([ (990.0, 270.0), ]) D = dc.at_temp(260) assert D == 990 - (10 * -0.00085)
def test_density_at_temp_out_of_range(self): dc = Density([ (990.0, 270.0), (985.0, 280.0), (980.0, 290.0), ]) D = dc.at_temp((300, 260)) assert D[0] < 980 assert D[1] > 990
def test_density_at_temp_vector_interp(self): dc = Density([ (990.0, 270.0), (984.0, 280.0), (980.0, 290.0), ]) print("k_rho_default:", dc.k_rho_default) D = dc.at_temp((275, 286)) assert 984 < D[0] < 990 assert 980 < D[1] < 984
def test_density_at_temp_single_20C(self): """ there seemed to be an error when there was a single value at ref temp 20C (293.15K) Checking at 60F (288.716): used to compute API """ dc = Density([ (990.0, 293.15), ]) D = dc.at_temp(288.716) result = 990 + ((288.716 - 293.15) * -0.0008) assert D == result
def test_initiliaze_three_plus_densities(self): oil = self.make_oil_with_densities([982, 984, 991], [288, 278, 268]) dc = Density(oil) print(dc.k_rho_default) assert isclose(dc.k_rho_default, -0.45)
def test_initiliaze_two_densities(self): oil = self.make_oil_with_densities([980.0, 990.0], [288.15, 268.15]) dc = Density(oil) print(dc.k_rho_default) assert isclose(dc.k_rho_default, -0.5)
def test_initilization_zero_densities(self): """ no density data -- ValueError trying to initilize a Density object """ oil = self.make_oil_with_densities([], []) with pytest.raises(ValueError): _dc = Density(oil)
def test_initilize_sort(self): """ make sure the data are sorted when added """ oil = self.make_oil_with_densities([980.0, 990.0, 985.0], [288, 287, 289]) dc = Density(oil) assert dc.temps == (287.0, 288.0, 289.0) assert dc.densities == (990.0, 980.0, 985.0)
def test_density_at_temp_vector_exact(self): dc = Density([(980.0, 288.15), (990.0, 273.15), (985.0, 280.0)]) assert np.all( dc.at_temp((288.15, 273.15, 280.0)) == (980.0, 990.0, 985.0))
def test_density_at_temp(self): dc = Density([(980.0, 288.15), (990.0, 273.15)]) assert dc.at_temp(288.15) == 980.0 assert dc.at_temp(273.15) == 990.0
def test_initiliaze_one_density(self, density, temp, k_rho): oil = self.make_oil_with_densities([density], [temp]) dc = Density(oil) print(dc.k_rho_default) assert dc.k_rho_default == k_rho