def test_alphas_checks(self, use_adsorbate, basic_pointisotherm): """Checks for built-in safeguards.""" # Will raise a "no reference isotherm" error with pytest.raises(pgEx.ParameterError): pygaps.alpha_s(basic_pointisotherm, None) # Will raise a "no reference isotherm" error with pytest.raises(pgEx.ParameterError): pygaps.alpha_s(basic_pointisotherm, 'isotherm') # Will raise a "adsorbate not the same" error ref_iso = pygaps.PointIsotherm(pressure=[0, 1], loading=[0, 1], material='test', adsorbate='argon', temperature=87) with pytest.raises(pgEx.ParameterError): pygaps.alpha_s(basic_pointisotherm, ref_iso) # Will raise a "bad reducing pressure" error with pytest.raises(pgEx.ParameterError): pygaps.alpha_s(basic_pointisotherm, basic_pointisotherm, reducing_pressure=1.3) # Will raise a "bad reference_area value" error with pytest.raises(pgEx.ParameterError): pygaps.alpha_s(basic_pointisotherm, basic_pointisotherm, reference_area='some')
def test_alphas_output(self, noplot): """Test verbosity""" data = DATA['MCM-41'] filepath = os.path.join(DATA_N77_PATH, data['file']) with open(filepath, 'r') as text_file: isotherm = pygaps.isotherm_from_json( text_file.read()) pygaps.alpha_s(isotherm, isotherm, verbose=True)
def test_alphas_checks(self, basic_pointisotherm): """Test checks""" # Will raise a "no reference isotherm exception" with pytest.raises(pygaps.ParameterError): pygaps.alpha_s(basic_pointisotherm, None) # Will raise a "bad reducing pressure exception" with pytest.raises(pygaps.ParameterError): pygaps.alpha_s(basic_pointisotherm, basic_pointisotherm, reducing_pressure=1.3) return
def test_alphas_checks(self, basic_pointisotherm): """Checks for built-in safeguards.""" # Will raise a "no reference isotherm error" with pytest.raises(pygaps.ParameterError): pygaps.alpha_s(basic_pointisotherm, None) # Will raise a "no reference isotherm error" with pytest.raises(pygaps.ParameterError): pygaps.alpha_s(basic_pointisotherm, 'isotherm') # Will raise a "adsorbate not same error" ref_iso = pygaps.PointIsotherm(pressure=[0, 1], loading=[0, 1], material='test', material_batch='test', adsorbate='argon', temperature=87) with pytest.raises(pygaps.ParameterError): pygaps.alpha_s(basic_pointisotherm, ref_iso) # Will raise a "bad reducing pressure error" with pytest.raises(pygaps.ParameterError): pygaps.alpha_s(basic_pointisotherm, basic_pointisotherm, reducing_pressure=1.3)
def test_alphas(self, sample): """Test calculation with several model isotherms.""" sample = DATA[sample] # exclude datasets where it is not applicable if sample.get('as_area', None): filepath = DATA_N77_PATH / sample['file'] isotherm = pygaps.isotherm_from_json(filepath) ref_filepath = DATA_N77_PATH / DATA[sample['as_ref']]['file'] ref_isotherm = pygaps.isotherm_from_json(ref_filepath) mref_isotherm = pygaps.ModelIsotherm.from_pointisotherm( ref_isotherm, model='BET') res = pygaps.alpha_s(isotherm, mref_isotherm) results = res.get('results') err_relative = 0.1 # 10 percent err_absolute_area = 0.1 # units err_absolute_volume = 0.01 # units assert isclose(results[-1].get('adsorbed_volume'), sample['as_volume'], err_relative, err_absolute_area) assert isclose(results[0].get('area'), sample['as_area'], err_relative, err_absolute_volume)
def test_alphas_choice(self): """Test choice of points.""" sample = DATA['MCM-41'] filepath = DATA_N77_PATH / sample['file'] isotherm = pygaps.isotherm_from_json(filepath) res = pygaps.alpha_s(isotherm, isotherm, limits=[0.7, 1.0]) results = res.get('results') err_relative = 0.1 # 10 percent err_absolute_area = 0.1 # units err_absolute_volume = 0.01 # units assert isclose(results[-1].get('adsorbed_volume'), 0, err_relative, err_absolute_area) assert isclose(results[-1].get('area'), sample['s_as_area'], err_relative, err_absolute_volume)
def test_alphas_choice(self): """Test choice of points""" data = DATA['MCM-41'] filepath = os.path.join(DATA_N77_PATH, data['file']) with open(filepath, 'r') as text_file: isotherm = pygaps.isotherm_from_json( text_file.read()) res = pygaps.alpha_s( isotherm, isotherm, limits=[0.7, 1.0]) results = res.get('results') err_relative = 0.1 # 10 percent err_absolute_area = 0.1 # units err_absolute_volume = 0.01 # units assert isclose(results[-1].get('adsorbed_volume'), 0, err_relative, err_absolute_area) assert isclose(results[-1].get('area'), data['bet_area'], err_relative, err_absolute_volume)
def test_alphas(self, file, area, micropore_volume): """Test calculation with several model isotherms""" filepath = os.path.join(DATA_N77_PATH, file) with open(filepath, 'r') as text_file: isotherm = pygaps.isotherm_from_json( text_file.read()) res = pygaps.alpha_s( isotherm, isotherm) results = res.get('results') assert results is not None err_relative = 0.1 # 10 percent err_absolute_area = 0.1 # units err_absolute_volume = 0.01 # units assert isclose(results[-1].get('adsorbed_volume'), micropore_volume, err_relative, err_absolute_area) assert isclose(results[-1].get('area'), area, err_relative, err_absolute_volume)
def test_alphas_output(self): """Test verbosity.""" sample = DATA['MCM-41'] filepath = DATA_N77_PATH / sample['file'] isotherm = pygaps.isotherm_from_json(filepath) pygaps.alpha_s(isotherm, isotherm, verbose=True)