def test_reverse_iast_checks(self, load_iast, load_iast_models): """Checks for built-in safeguards.""" ch4, c2h6 = load_iast # Raises "not enough components error" with pytest.raises(pygaps.ParameterError): pygaps.reverse_iast([ch4], [0.1], 1) # Raises "different dimensions of arrays" with pytest.raises(pygaps.ParameterError): pygaps.reverse_iast([ch4, c2h6], [0.1], 1) # Raises "fractions do not add up to 1" with pytest.raises(pygaps.ParameterError): pygaps.reverse_iast([ch4, c2h6], [0.1, 0.4], 1) # Raises "model cannot be used with IAST" ch4_m = pygaps.ModelIsotherm.from_pointisotherm(ch4, model='Virial') with pytest.raises(pygaps.ParameterError): pygaps.reverse_iast([ch4_m, c2h6], [0.6, 0.4], 1) # Warning "extrapolate outside range" with pytest.warns(Warning): pygaps.reverse_iast(load_iast_models, [0.5, 0.5], 100)
def test_reverse_iast_model(self, load_iast_models): """Test on pre-calculated data.""" ideal_ads_fraction = [0.5, 0.5] ideal_gas_fraction = [0.885, 0.115] gas_fraction, actual_loading = pygaps.reverse_iast( load_iast_models, ideal_ads_fraction, 1) actual_ads_fraction = actual_loading / numpy.sum(actual_loading) assert numpy.isclose(ideal_gas_fraction[0], gas_fraction[0], atol=0.1) assert numpy.isclose(ideal_ads_fraction[0], actual_ads_fraction[0], atol=0.05)
def test_reverse_iast(self, load_iast): ch4, c2h6 = load_iast ideal_loadings = [0.23064, 0.76936] ideal_pressures = [0.5, 0.5] partial_pressures, loadings = pygaps.reverse_iast([ch4, c2h6], ideal_loadings, 1, verbose=True) assert numpy.isclose(ideal_loadings[0], loadings[0], atol=0.05) assert numpy.isclose(ideal_pressures[0], partial_pressures[0], atol=0.1)
def test_iast_checks(self, load_iast): ch4, c2h6 = load_iast # IAST CHECKS # Raises error components with pytest.raises(ParameterError): pygaps.iast([ch4], [0.1]) # Raises error different dimensions with pytest.raises(ParameterError): pygaps.iast([ch4, c2h6], [0.1]) # REVERSE IAST CHECKS # Raises error components with pytest.raises(ParameterError): pygaps.reverse_iast([ch4], [0.1], 2) # Raises error different dimensions with pytest.raises(ParameterError): pygaps.reverse_iast([ch4, c2h6], [0.1], 2) # Raises error sum not adds to one with pytest.raises(ParameterError): pygaps.reverse_iast([ch4, c2h6], [0.1, 0.4], 2) # VLE CHECKS # Raises error components with pytest.raises(ParameterError): pygaps.iast_binary_vle([ch4], 1) # SVP CHECKS # Raises error components with pytest.raises(ParameterError): pygaps.iast_binary_svp([ch4], [0.1], [1, 2]) # Raises error not adds to one with pytest.raises(ParameterError): pygaps.iast_binary_svp([ch4, c2h6], [0.1, 0.4], [1, 2])
def test_reverse_iast_verbose(self, load_iast): """Test verbosity.""" pygaps.reverse_iast(load_iast, [0.23064, 0.76936], 1, verbose=True)