diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index de6fc5c..3b4a0e3 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,21 +1,29 @@ name: CI on: - push: - branches: - - main - tags: ['*'] pull_request: - workflow_dispatch: + branches: + - master + paths-ignore: + - 'docs/**' + #- 'examples/**' + push: + paths-ignore: + - 'docs/**' + #- 'examples/**' +# needed to allow julia-actions/cache to delete old caches that it has created +permissions: + actions: write + contents: read concurrency: # Skip intermediate builds: always. - # Cancel intermediate builds: only if it is a pull request build. + # Cancel intermediate builds: always. group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} + cancel-in-progress: true jobs: test: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} runs-on: ${{ matrix.os }} - timeout-minutes: 60 + timeout-minutes: 30 permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created actions: write contents: read @@ -39,3 +47,8 @@ jobs: - uses: julia-actions/cache@v2 - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 + - uses: julia-actions/julia-processcoverage@v1 + - uses: codecov/codecov-action@v4 + with: + file: lcov.info + token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/Documentation.yml b/.github/workflows/Documentation.yml new file mode 100644 index 0000000..3762ab3 --- /dev/null +++ b/.github/workflows/Documentation.yml @@ -0,0 +1,25 @@ +name: Documentation +on: + push: + branches: + - main +# needed to allow julia-actions/cache to delete old caches that it has created +permissions: + actions: write + contents: read +concurrency: + # Skip intermediate builds: always. + # Cancel intermediate builds: always. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + docs: + name: Documentation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-docdeploy@latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} \ No newline at end of file diff --git a/LICENSE b/LICENSE index ddc8ae8..c4b6d0c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 longemen3000 and contributors +Copyright (c) 2024 Andrés Riedemann, Vinicius Viena, Pierre Walker, and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Project.toml b/Project.toml index a798c3b..b6c37e5 100644 --- a/Project.toml +++ b/Project.toml @@ -6,7 +6,6 @@ version = "0.1.1" [deps] BlackBoxOptim = "a134a8b2-14d6-55f6-9291-3336d3ab0209" CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2" -DynamicQuantities = "06fc5a27-2a28-4c7c-a15d-362465fb6821" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" Integrals = "de52edbc-65ea-441a-8357-d3a637375a31" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" @@ -21,7 +20,9 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" [compat] SciMLBase = "^2.65" +BlackBoxOptim = "^0.6.2" CommonSolve = "0.2.4" +DynamicQuantities = "1" ForwardDiff = "^0.10" Integrals = "4" LinearAlgebra = "1" @@ -30,9 +31,16 @@ NLSolvers = "0.5" PolyLog = "^2.5.0" Roots = "2.1" StaticArrays = "1" +TableOperations = "1" Tables = "^1.8" julia = "1.9" +[weakdeps] +DynamicQuantities = "06fc5a27-2a28-4c7c-a15d-362465fb6821" + +[extensions] +LangmuirDynamicQuantitiesExt = "DynamicQuantities" + [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/README.md b/README.md index 3db957b..e1ab76c 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,59 @@ -# AdsorbedSolutionTheory.jl - -[![Build Status](https://github.com/ClapeyronThermo/AdsorbedSolutionTheory.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ClapeyronThermo/AdsorbedSolutionTheory.jl/actions/workflows/CI.yml?query=branch%3Amain) +[![Build Status](https://github.com/ClapeyronThermo/Langmuir.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ClapeyronThermo/Langmuir.jl/actions/workflows/CI.yml?query=branch%3Amain) [![codecov](https://codecov.io/gh/ClapeyronThermo/Langmuir.jl/branch/main/graph/badge.svg?token=ZVGGR4AAFB)](https://codecov.io/gh/ClapeyronThermo/Langmuir.jl) [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://clapeyronthermo.github.io/Langmuir.jl/dev) +![logo](/docs/Langmuir_logo.svg) This package implements single adsorption and multicomponent adsorption through Ideal Absorbed Solution Theory (IAST). Some major features are: - - Explicit single component adsorption properties: loading, bulk phase properties - - Multicomponent adsorption +- Explicit single component adsorption properties: loading, bulk phase properties +- Multicomponent adsorption + +## Examples: + +```julia +using Langmuir + +#example from doi.org/10.1002/aic.14684 + +v = @MultiSite{LangmuirS1,LangmuirS1} #we create a multisite model, consisting + + x1 = [1.468 + 0.024 + 0 + 7.891 + 0.001645 + 0] + + x2 = [2.847 + 0.028 + 0. + 2.223 + 1.228 + 0.] + + x3 = [2.581 + 0.84 + 0.0 + 2.901 + 0.021 + 0.0] + + #creation of isotherms from vectors or other iterables. + #you can also use Langmuir.from_vec! or Langmuir.from_vec + #to create (or fill) vectors from isotherm models + m1,m2,m3 = Langmuir.from_vec(v,x1),Langmuir.from_vec(v,x2),AST.from_vec(v,x3) + models = (m1,m2,m3) + + #calculate loading of a single isotherm + #there are also functions to calculate the reduced spreading pressure, and inverse algorithms + l1 = loading(m1,p,T) + kh1 = henry_coefficient(m1,T) + lmax = saturated_loading(m1,T) + + y = [0.5,0.25,0.25] + T = 300 + p = 1000 + + + #total adsorbed amount, fractions of adsorbed components. + q_tot,x,status = iast(models,p,T,y) +``` diff --git a/docs/Langmuir_logo.svg b/docs/Langmuir_logo.svg new file mode 100644 index 0000000..2cead74 --- /dev/null +++ b/docs/Langmuir_logo.svg @@ -0,0 +1,175 @@ + +image/svg+xmlLangmuir + \ No newline at end of file diff --git a/ext/LangmuirDynamicQuantitiesExt.jl b/ext/LangmuirDynamicQuantitiesExt.jl new file mode 100644 index 0000000..cbe7382 --- /dev/null +++ b/ext/LangmuirDynamicQuantitiesExt.jl @@ -0,0 +1,11 @@ +module LangmuirDynamicQuantitiesExt + +import Langmuir +import DynamicQuantities +using DynamicQuantities: @u_str + +function Langmuir.Rgas(model::Langmuir.IsothermModel{<:DynamicQuantities.Quantity}) + return 8.31446261815324u"J/mol/K" +end + +end #module \ No newline at end of file diff --git a/src/Langmuir.jl b/src/Langmuir.jl index 85ef4f4..2b5ba7a 100644 --- a/src/Langmuir.jl +++ b/src/Langmuir.jl @@ -6,7 +6,6 @@ using ForwardDiff using LogExpFunctions using StaticArrays using Integrals -using DynamicQuantities using Tables, TableOperations using Roots: Roots, solve import PolyLog diff --git a/src/methods/iast.jl b/src/methods/iast.jl index ec0eb92..8d08931 100644 --- a/src/methods/iast.jl +++ b/src/methods/iast.jl @@ -233,7 +233,8 @@ function iast_step!(::FastIAS, models, p, T, y, state::S, maxiters, reltol, abst end end ΔRes = norm(δ,Inf) - ΔRes <= min(abstol,norm(Res,Inf)*reltol) && (converged = true) + ΔRes <= abstol && (converged = true) + norm(δ,1) <= reltol && (converged = true) return (;η,K,Diag,Res,δ,x,q_tot,iters,converged) end diff --git a/src/models/models.jl b/src/models/models.jl index e1f8f28..1de0d68 100644 --- a/src/models/models.jl +++ b/src/models/models.jl @@ -6,10 +6,6 @@ end Rgas(model) = 8.31446261815324 #J.mol⁻¹.K⁻¹ -function Rgas(model::IsothermModel{<:Quantity}) - return 8.31446261815324u"J/mol/K" -end - """ model_length(model::IsothermModel) diff --git a/test/runtests.jl b/test/runtests.jl index f90c4ad..99ad8d4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -128,6 +128,22 @@ end @test iast(models,p,T,y,FastIAS())[1] ≈ q_tot @test iast(models,p,T,y,IASTNestedLoop())[1] ≈ q_tot @test iast(models,p,T,y,IASTNestedLoop(),x0 = x0)[1] ≈ q_tot + + ethane_isotherm = Quadratic{Float64}(2.5087482698420104e-7, 2.1373377526197646e-19, 3.641079631515442, -6898.20708031339, -47789.60001500269) + ethylene_isotherm = Quadratic{Float64}(2.599227350906123e-8, 7.128313806215397e-19, 3.832139235999132, -11790.383728687304, -41702.74723166111) + p2 = 101325.0 + T2 = 303.0 + models2 = (ethane_isotherm,ethylene_isotherm) + yx = range(0.0, 1.00, 51) + for yi in yx + y = [yi,1-yi] + n1,w1,status1 = iast(models2,p2,T2,y,FastIAS()) + n2,w2,status2 = iast(models2,p2,T2,y,IASTNestedLoop()) + @test status1 == :success + @test status2 == :success + @test n1 ≈ n2 + @test w1 ≈ w2 + end end