Skip to content

Commit

Permalink
Merge pull request #121 from SimonEnsemble/fix_dataframe_mutation
Browse files Browse the repository at this point in the history
Fix dataframe mutation
  • Loading branch information
SimonEnsemble committed Nov 20, 2019
2 parents 7329a05 + 8593a25 commit 13d5d81
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/Misc.jl
Expand Up @@ -189,10 +189,10 @@ where N is the total adsorption, M is the maximum monolayer coverage, K is the L
"""
function fit_adsorption_isotherm(df::DataFrame, pressure_col_name::Symbol,
loading_col_name::Symbol, model::Symbol)
sort!(df, [pressure_col_name])
n = df[!, loading_col_name]
p = df[!, pressure_col_name]
θ0 = _guess(df, pressure_col_name, loading_col_name, model)
_df = sort(df, [pressure_col_name])
n = _df[!, loading_col_name]
p = _df[!, pressure_col_name]
θ0 = _guess(_df, pressure_col_name, loading_col_name, model)

if model == :langmuir
objective_function_langmuir(θ) = return sum([(n[i] - θ[1] * θ[2] * p[i] / (1 + θ[2] * p[i]))^2 for i = 1:length(n)])
Expand Down
2 changes: 1 addition & 1 deletion test/misc_test.jl
Expand Up @@ -29,7 +29,7 @@ using Random
@test isapprox(M, M_opt, rtol=1e-6)
@test isapprox(K, K_opt, rtol=1e-6)

df = CSV.read("Ni-MOF-74_isotherm_test.csv", copycols=true)
df = CSV.read("Ni-MOF-74_isotherm_test.csv")
x = fit_adsorption_isotherm(df, Symbol("P(bar)"), Symbol("mol_m3"), :langmuir)
M_opt, K_opt = x["M"], x["K"]
@test isapprox(M_opt, 8546.37534030619, atol=1e-5)
Expand Down

0 comments on commit 13d5d81

Please sign in to comment.