<jupyter_start><jupyter_text>IAST examplesThe IAST method is used to predict the composition of the adsorbed phase in amulticomponent adsorption system, starting from pure component isotherms. First,make sure the data is imported by running the import notebook.<jupyter_code># import isotherms
%run import.ipynb

# import the iast module
import pygaps
import pygaps.iast as pgi

import matplotlib.pyplot as plt
import numpy<jupyter_output>Selected 5 isotherms with nitrogen at 77K
Selected 2 room temperature calorimetry isotherms
Selected 2 isotherms for IAST calculation
Selected 3 isotherms for isosteric enthalpy calculation<jupyter_text>Using modelsThe IAST calculation is often performed by fitting a model to the isothermrather than on the isotherms themselves, as spreading pressure can be computedefficiently when using most common models. Let's first fit the Langmuir model toboth isotherms.<jupyter_code>isotherms_iast_models = []

isotherm = next(i for i in isotherms_iast if i.material=='MOF-5(Zn)')
print('Isotherm sample:', isotherm.material)

for isotherm in isotherms_iast:
    model = pygaps.ModelIsotherm.from_pointisotherm(isotherm, model='Langmuir', verbose=True)
    isotherms_iast_models.append(model)<jupyter_output>Isotherm sample: MOF-5(Zn)
Attempting to model using Langmuir.
Model Langmuir success, RMSE is 0.901
Attempting to model using Langmuir.
Model Langmuir success, RMSE is 0.272<jupyter_text>Now we can perform the IAST calculation with the resulting models. We specifythe partial pressures of each component in the gaseous phase to obtain thecomposition of the adsorbed phase.<jupyter_code>gas_fraction = [0.5, 0.5]
total_pressure = 10
pgi.iast_point_fraction(isotherms_iast_models, gas_fraction, total_pressure, verbose=True)<jupyter_output>2 components.
	Partial pressure component 0 = 5
	Partial pressure component 1 = 5
Component 0
	p = 5
	p^0 = 5.71
	Loading = 11.01
	x = 0.8757
	Spreading pressure = 18.18
Component 1
	p = 5
	p^0 = 40.21
	Loading = 1.563
	x = 0.1243
	Spreading pressure = 18.18<jupyter_text>Alternatively, if we are interested in a binary system, we can use the extensionfunctions `iast_binary_svp` and `iast_binary_vle` to obtain how the selectivitychanges based on pressure in a constant composition or, respectively, how thegas phase-adsorbed phase changes with gas composition, at constant pressure.These functions perform the IAST calculation at every point in the range passedand can plot the results. If interested in the selectivity for one component inan equimolar mixture over a pressure range:<jupyter_code>mole_fractions = [0.5, 0.5]
pressure_range = numpy.linspace(0.01, 20, 30)

result_dict = pgi.iast_binary_svp(
    isotherms_iast_models,
    mole_fractions,
    pressure_range,
    verbose=True,
)<jupyter_output><empty_output><jupyter_text>Or if interested on a adsorbed - gas phase equilibrium line:<jupyter_code>total_pressure = 2
result_dict = pgi.iast_binary_vle(
    isotherms_iast_models,
    total_pressure,
    verbose=True,
)<jupyter_output><empty_output><jupyter_text>Using isotherms directly - interpolation The isotherms themselves can be used directly. However, instead of spreadingpressure being calculated from the model, it will be approximated throughinterpolation and numerical quadrature integration.<jupyter_code>gas_fraction = [0.5, 0.5]
total_pressure = 10
pgi.iast_point_fraction(
    isotherms_iast_models,
    gas_fraction,
    total_pressure,
    verbose=True,
)<jupyter_output>2 components.
	Partial pressure component 0 = 5
	Partial pressure component 1 = 5
Component 0
	p = 5
	p^0 = 5.71
	Loading = 11.01
	x = 0.8757
	Spreading pressure = 18.18
Component 1
	p = 5
	p^0 = 40.21
	Loading = 1.563
	x = 0.1243
	Spreading pressure = 18.18<jupyter_text>The binary mixture functions can also accept PointIsotherm objects.<jupyter_code>mole_fraction = [0.5, 0.5]
pressure_range = numpy.linspace(0.01, 20, 30)

result_dict = pgi.iast_binary_svp(
    isotherms_iast,
    mole_fraction,
    pressure_range,
    verbose=True,
)
result_dict = pgi.iast_binary_vle(
    isotherms_iast,
    total_pressure=2,
    verbose=True,
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0650759219088937, 'fraction_numerical': 0.033743070619426364, 'mean_word_length': 5.345565749235474, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '546178', 'license': 'MIT', 'n_tokens_mistral': 1484, 'n_tokens_neox': 1309, 'n_words': 435, 'path': 'docs/examples/iast.ipynb', 'repo_name': 'pauliacomi/adsutils', 'size': '4149'}