Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SimonEnsemble/a58ecbe7bc58f4afa817e36bf458be4a to your computer and use it in GitHub Desktop.
Save SimonEnsemble/a58ecbe7bc58f4afa817e36bf458be4a to your computer and use it in GitHub Desktop.
construct pyIAST `ModelIsotherm` without data, using only isotherm parameters
## for example, construct a Lanmguir model with params M, K
def construct_langmuir_model(M, K):
df_bogus = pd.DataFrame([[1.0, 1.0]], columns=["P_bogus", "N_bogus"]) # bogus data
m = pyiast.ModelIsotherm(df, model="Langmuir", pressure_key="P", loading_key="N") # will fit Langmuir model with bogus params
# overwrite bogus model params
m.params['M'] = M
m.params['K'] = K
# overwrite bogus data to be sure it is never used.
m.df = pd.DataFrame([[np.NaN, np.NaN]], columns=["P_bogus", "N_bogus"]) # bogus data
return m
# some tests to convince yourself it's all right
m = construct_langmuir_model(1.0, 10.0) # M = 1, K = 10
m.loading(1000.0) # n(inf) = M
m.loading(1 / 10.0) # n(1/K) = 0.5 M
m.df # should have NaN's to clarify this is bogus data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment