コード例 #1
0
ファイル: conftest.py プロジェクト: Kitkim160/pyGAPS
def basic_modelisotherm(isotherm_data, isotherm_parameters):
    """Creates a model isotherm from basic data."""
    return pygaps.ModelIsotherm(isotherm_data=isotherm_data,
                                loading_key=LOADING_KEY,
                                pressure_key=PRESSURE_KEY,
                                model="Henry",
                                **isotherm_parameters)
コード例 #2
0
 def test_isotherm_create_from_model(self, basic_isotherm):
     """Check isotherm can be created from a model."""
     model = pygaps.modelling.get_isotherm_model('Henry')
     pygaps.ModelIsotherm(model=model,
                          material='Test',
                          temperature=303,
                          adsorbate='nitrogen')
コード例 #3
0
 def test_isotherm_create_from_model(self, basic_isotherm):
     """Check isotherm can be created from a model."""
     model = pygaps.calculations.models_isotherm.get_isotherm_model('Henry')
     pygaps.ModelIsotherm(model=model,
                          material_name='Test',
                          material_batch='Henry',
                          t_iso=303,
                          adsorbate='nitrogen')
コード例 #4
0
    def test_isotherm_create(self):
        """Check isotherm can be created from basic data."""
        isotherm_param = {
            'loading_key': 'loading',
            'pressure_key': 'pressure',
            'material': 'carbon',
            'adsorbate': 'nitrogen',
            'temperature': 77,
        }

        pressure = [1, 2, 3, 4, 5, 3, 2]
        loading = [1, 2, 3, 4, 5, 3, 2]

        isotherm_data = pandas.DataFrame({
            'pressure': pressure,
            'loading': loading
        })

        # regular creation
        pygaps.ModelIsotherm(pressure=pressure,
                             loading=loading,
                             model='Henry',
                             **isotherm_param)

        # regular creation, DataFrame
        pygaps.ModelIsotherm(isotherm_data=isotherm_data,
                             model='Henry',
                             **isotherm_param)

        # regular creation, desorption
        pygaps.ModelIsotherm(isotherm_data=isotherm_data,
                             model='Henry',
                             branch='des',
                             **isotherm_param)

        # regular creation, guessed parameters
        pygaps.ModelIsotherm(isotherm_data=isotherm_data,
                             model='Henry',
                             param_guess={'K': 1.0},
                             **isotherm_param)

        # Missing pressure/loading
        with pytest.raises(pgEx.ParameterError):
            pygaps.ModelIsotherm(pressure=pressure,
                                 loading=None,
                                 **isotherm_param)

        # Missing model
        with pytest.raises(pgEx.ParameterError):
            pygaps.ModelIsotherm(isotherm_data=isotherm_data, **isotherm_param)

        # Wrong model
        with pytest.raises(pgEx.ParameterError):
            pygaps.ModelIsotherm(isotherm_data=isotherm_data,
                                 model='Wrong',
                                 **isotherm_param)

        # Wrong branch
        with pytest.raises(pgEx.ParameterError):
            pygaps.ModelIsotherm(
                isotherm_data=isotherm_data,
                model='Henry',
                branch='random',
            )

        # Wrong parameters
        with pytest.raises(pgEx.ParameterError):
            pygaps.ModelIsotherm(isotherm_data=isotherm_data,
                                 model='Henry',
                                 param_guess={'K9': 'woof'},
                                 **isotherm_param)