def test_isotherm_create(self):
        """Check isotherm can be created from basic data."""

        isotherm_param = {
            'material': 'carbon',
            'adsorbate': 'nitrogen',
            'temperature': 77,
        }
        pressure = [1, 2, 3, 4, 5, 3, 2]
        loading = [1, 2, 3, 4, 5, 3, 2]

        pygaps.PointIsotherm(
            pressure=pressure,
            loading=loading,
            **isotherm_param,
        )

        pygaps.PointIsotherm(
            isotherm_data=pandas.DataFrame({
                'pressure': pressure,
                'loading': loading
            }),
            pressure_key='pressure',
            loading_key='loading',
            **isotherm_param,
        )

        # Wrong branch
        with pytest.raises(pgEx.ParameterError):
            pygaps.PointIsotherm(
                pressure=pressure,
                loading=loading,
                branch='random',
                **isotherm_param,
            )
Exemple #2
0
def basic_pointisotherm(isotherm_data, isotherm_parameters):
    """Create a point isotherm from basic data."""
    return pygaps.PointIsotherm(isotherm_data=isotherm_data,
                                loading_key=LOADING_KEY,
                                pressure_key=PRESSURE_KEY,
                                other_keys=[OTHER_KEY],
                                **isotherm_parameters)
Exemple #3
0
    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_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)
Exemple #5
0
    def test_isotherm_create_branches(self, isotherm_parameters, isotherm_data,
                                      branch, expected):
        "Tests if isotherm branches are well specified"

        isotherm = pygaps.PointIsotherm(isotherm_data=isotherm_data,
                                        loading_key='loading',
                                        pressure_key='pressure',
                                        other_keys=['enthalpy'],
                                        branch=branch,
                                        **isotherm_parameters)

        assert isotherm.pressure(branch='des')[0] == expected
Exemple #6
0
    def test_isotherm_equality(self, isotherm_parameters, isotherm_data,
                               basic_pointisotherm):
        "Checks isotherm id's are unique"

        isotherm = pygaps.PointIsotherm(isotherm_data=isotherm_data,
                                        loading_key='loading',
                                        pressure_key='pressure',
                                        other_keys=['enthalpy'],
                                        **isotherm_parameters)

        assert isotherm == basic_pointisotherm

        isotherm.t_iso = 0
        assert isotherm != basic_pointisotherm
Exemple #7
0
    def test_isotherm_create(self):
        "Checks isotherm can be created from basic data"

        isotherm_param = {
            'material_name': 'carbon',
            'material_batch': 'X1',
            'adsorbate': 'nitrogen',
            't_iso': 77,
        }
        pressure = [1, 2, 3, 4, 5, 3, 2]
        loading = [1, 2, 3, 4, 5, 3, 2]

        pygaps.PointIsotherm(pressure=pressure,
                             loading=loading,
                             **isotherm_param)

        pygaps.PointIsotherm(isotherm_data=pandas.DataFrame({
            'pressure': pressure,
            'loading': loading
        }),
                             pressure_key='pressure',
                             loading_key='loading',
                             **isotherm_param)
Exemple #8
0
    def test_isotherm_miss_key(self, isotherm_parameters, isotherm_data,
                               missing_key):
        "Tests exception throw for missing data primary key (loading/pressure)"

        keys = dict(
            pressure_key="pressure",
            loading_key="loading",
        )

        del keys[missing_key]

        with pytest.raises(pygaps.ParameterError):
            pygaps.PointIsotherm(isotherm_data=isotherm_data,
                                 loading_key=keys.get('loading_key'),
                                 pressure_key=keys.get('pressure_key'),
                                 **isotherm_parameters)
 def test_isotherm_existing_branches(
     self,
     isotherm_parameters,
     isotherm_data,
 ):
     """Tests if isotherm branches are well specified."""
     isotherm_datab = isotherm_data.copy()
     isotherm_datab['branch'] = [
         False, False, True, True, True, True, True, True
     ]
     isotherm = pygaps.PointIsotherm(isotherm_data=isotherm_datab,
                                     loading_key='loading',
                                     pressure_key='pressure',
                                     other_keys=['enthalpy'],
                                     **isotherm_parameters)
     assert isotherm.pressure(branch='des')[0] == 3.0
Exemple #10
0
def build_isotherm(inputParams):
    isotherm = pygaps.PointIsotherm(
        pressure=inputParams["pressure"],  # pressure here
        loading=inputParams["loading"],  # loading here
        # Now the model details can be specified
        # Unit parameters can be specified
        pressure_mode=inputParams[
            "pressureMode"],  # Working in absolute pressure
        pressure_unit=inputParams["pressureUnit"],  # with units of bar
        material_basis=inputParams[
            "materialBasis"],  # Working on a mass material basis
        material_unit=inputParams["materialUnit"],  # with units of kg
        loading_basis=inputParams[
            "loadingBasis"],  # Working on a loading mass basis
        loading_unit=inputParams["loadingUnit"],  # with units of g
        # Finally the isotherm parameters
        material=inputParams["material"],  # Required
        adsorbate=inputParams["adsorbate"],  # Required
        temperature=inputParams["temperature"],  # Required
    )
    return isotherm