Importing isotherms

The first thing to do is to create some isotherms. Example data can be found in the /data directory, in the pyGAPS JSON format. Let's import all the example data. First, we'll do the necessary top-level imports for the session.


In [1]:
import os
import matplotlib.pyplot as plt
import pygaps

json_path = os.path.join(os.getcwd(), 'data')

Then we'll import the json files. To do this, we need to find all the files with the .json extension and open them for reading. We can use the pygaps.util_get_file_paths function to get all the file paths in a folder.

Then we'll open the files and create the isotherms with the isotherm_from_json method which converts a string, or simply by using the isotherm_from_jsonf method which reads a file directly. There are three folders:

  • One containing nitrogen adsorption data at 77 kelvin
  • Another with room-temperature adsorption of $CO_2$ combined with microcalorimetry
  • Some room-temperature isotherms which we will use for IAST calculations
  • Finally a set of isotherms with $C_4H_{10}$ at different temperature, for isosteric enthalpy calculations

In [2]:
# Get the nitrogen data at 77 kelvin
isotherms_n2_77k_paths = pygaps.util_get_file_paths(
                            os.path.join(json_path, 'characterisation'), '.json')
isotherms_n2_77k = []
for filepath in isotherms_n2_77k_paths:
    with open(filepath, 'r') as text_file:
        isotherms_n2_77k.append(pygaps.isotherm_from_json(text_file.read()))
        
print('Selected', len(isotherms_n2_77k), 'isotherms with nitrogen at 77K')


Selected 5 isotherms with nitrogen at 77K

In [3]:
# Get the combined isotherm-calorimetry data
isotherms_calorimetry_paths = pygaps.util_get_file_paths(
                            os.path.join(json_path, 'calorimetry'), '.json')
isotherms_calorimetry = []
for filepath in isotherms_calorimetry_paths:
    isotherms_calorimetry.append(pygaps.isotherm_from_jsonf(filepath))
        
print('Selected', len(isotherms_calorimetry), 'room temperature calorimetry isotherms')


Selected 2 room temperature calorimetry isotherms

In [4]:
# Get the isotherms for IAST calculations
isotherms_iast_paths = pygaps.util_get_file_paths(
                            os.path.join(json_path, 'iast'), '.json')
isotherms_iast = []
for filepath in isotherms_iast_paths:
    isotherms_iast.append(pygaps.isotherm_from_jsonf(filepath))
        
print('Selected', len(isotherms_iast), 'isotherms for IAST calculation')


Selected 2 isotherms for IAST calculation

In [5]:
# Get the isotherms for isosteric enthalpy calculations
isotherms_isosteric_paths = pygaps.util_get_file_paths(
                            os.path.join(json_path, 'isosteric'), '.json')
isotherms_isosteric = []
for filepath in isotherms_isosteric_paths:
    isotherms_isosteric.append(pygaps.isotherm_from_jsonf(filepath))
        
print('Selected', len(isotherms_isosteric), 'isotherms for isosteric enthalpy calculation')


Selected 3 isotherms for isosteric enthalpy calculation