From 3d68a95155887fdaa3957a80f06ded9412a49ce3 Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Mon, 20 Jul 2020 16:10:43 -0400 Subject: [PATCH 1/4] switch from using Dierckx to SmoothingSplines for cubic interpolation --- src/Domain.jl | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Domain.jl b/src/Domain.jl index 7dc69b0d..b95a38a4 100644 --- a/src/Domain.jl +++ b/src/Domain.jl @@ -1,8 +1,8 @@ using Parameters using LinearAlgebra using StaticArrays -using Dierckx using Calculus +using SmoothingSplines abstract type AbstractDomain end export AbstractDomain @@ -263,16 +263,14 @@ function ParametrizedTPDomain(;phase::Z,initialconds::Dict{X,Any},constantspecie end @assert V != 0.0 || (T != 0.0 && P != 0.0) if isa(T,AbstractArray) - q = Spline1D(ts,T;k=3,s=1e-11) - Tfcn(x::Float64) = q(x) + Tfcn = getspline(ts,T) elseif isa(T,Function) Tfcn = T else throw(error("ParametrizedTPDomain must take \"T\" as a function or if an array of times for \"ts\" is supplied as an array of volumes")) end if isa(P,AbstractArray) - v = Spline1D(ts,P;k=3,s=1e-11) - Pfcn(x::Float64) = v(x) + Pfcn = getspline(ts,P) elseif isa(P,Function) Pfcn = P else @@ -346,8 +344,7 @@ function ParametrizedVDomain(;phase::Z,initialconds::Dict{X,Any},constantspecies end @assert isa(V,Function) || isa(V,AbstractArray) if isa(V,AbstractArray) - q = Spline1D(ts,V;k=3,s=1e-11) - Vfcn = f(x::Float64) = q(x) + Vfcn = getspline(ts,V) elseif isa(V,Function) Vfcn = V else @@ -422,8 +419,7 @@ function ParametrizedPDomain(;phase::Z,initialconds::Dict{X,Any},constantspecies end @assert isa(P,Function) || isa(P,AbstractArray) if isa(P,AbstractArray) - q = Spline1D(ts,P;k=3,s=1e-11) - Pfcn = f(x::Float64) = q(x) + Pfcn = getspline(ts,P) elseif isa(P,Function) Pfcn = P else @@ -577,8 +573,7 @@ function ParametrizedTConstantVDomain(;phase::IdealDiluteSolution,initialconds:: end end if isa(T,AbstractArray) - q = Spline1D(ts,T;k=3,s=1e-11) - Tfcn = f(x::Float64) = q(x) + Tfcn = getspline(ts,T) elseif isa(T,Function) Tfcn = T else @@ -943,3 +938,12 @@ function getreactionindices(ig::Q) where {Q<:AbstractPhase} return arr end export getreactionindices + +""" +fit a cubic spline to data and return a function evaluating that spline +""" +function getspline(xs,vals;s=1e-10) + smspl = fit(SmoothingSpline,xs,vals,s) + F(x::T) where {T} = predict(smspl,x) + return F +end \ No newline at end of file From a9d574503f5f1430e00e090cf83d2c7264415c0c Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Mon, 20 Jul 2020 16:11:52 -0400 Subject: [PATCH 2/4] loosen compatibility requirements swap Dierckx for SmoothingSplines reduce compatibility requirements for most 0.*.* packages to <1 --- Manifest.toml | 50 ++++++++++++++++++++++---------------------------- Project.toml | 40 ++++++++++++++++++++-------------------- 2 files changed, 42 insertions(+), 48 deletions(-) diff --git a/Manifest.toml b/Manifest.toml index 4aa75e5d..04c90eb1 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -26,9 +26,9 @@ version = "0.0.4" [[ArrayInterface]] deps = ["LinearAlgebra", "Requires", "SparseArrays"] -git-tree-sha1 = "0eccdcbe27fd6bd9cba3be31c67bdd435a21e865" +git-tree-sha1 = "066d1e7a9eb4873660791db7f0d8c7902600b81c" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "2.9.1" +version = "2.11.0" [[AxisAlgorithms]] deps = ["LinearAlgebra", "Random", "SparseArrays", "WoodburyMatrices"] @@ -45,12 +45,6 @@ version = "0.4.3" [[Base64]] uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" -[[BinaryProvider]] -deps = ["Libdl", "Logging", "SHA"] -git-tree-sha1 = "ecdec412a9abc8db54c0efc5548c64dfce072058" -uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" -version = "0.5.10" - [[CEnum]] git-tree-sha1 = "215a9aa4a1f23fbd05b92769fdd62559488d70e9" uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82" @@ -58,9 +52,9 @@ version = "0.4.1" [[CSV]] deps = ["CategoricalArrays", "DataFrames", "Dates", "Mmap", "Parsers", "PooledArrays", "SentinelArrays", "Tables", "Unicode"] -git-tree-sha1 = "a100a1dd6ab63fc49e79c90dae67e5bc126419ff" +git-tree-sha1 = "f095e44feec53d0ae809714a78c25908d1f370e6" uuid = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" -version = "0.7.3" +version = "0.7.4" [[Calculus]] deps = ["LinearAlgebra"] @@ -82,9 +76,9 @@ version = "0.8.1" [[ChainRulesCore]] deps = ["MuladdMacro"] -git-tree-sha1 = "87e289253a5fc690c4860a41bbd427e16576f716" +git-tree-sha1 = "9907341fe861268ddd0fc60be260633756b126a2" uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" -version = "0.9.3" +version = "0.9.4" [[ColorTypes]] deps = ["FixedPointNumbers", "Random"] @@ -191,17 +185,11 @@ uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" deps = ["Mmap"] uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" -[[Dierckx]] -deps = ["BinaryProvider", "Libdl", "Random", "Test"] -git-tree-sha1 = "956bfe5c4f9b794545f6527424fc0294cc5decbe" -uuid = "39dd38d3-220a-591b-8e3c-4c3a8c710a94" -version = "0.4.2" - [[DiffEqBase]] deps = ["ArrayInterface", "ChainRulesCore", "ConsoleProgressMonitor", "DataStructures", "Distributed", "DocStringExtensions", "FunctionWrappers", "IterativeSolvers", "IteratorInterfaceExtensions", "LabelledArrays", "LinearAlgebra", "Logging", "LoggingExtras", "MuladdMacro", "Parameters", "Printf", "ProgressLogging", "RecipesBase", "RecursiveArrayTools", "RecursiveFactorization", "Requires", "Roots", "SparseArrays", "StaticArrays", "Statistics", "SuiteSparse", "TableTraits", "TerminalLoggers", "TreeViews", "ZygoteRules"] -git-tree-sha1 = "71499ee24ffe00892a9e80cc953fe0421a54b552" +git-tree-sha1 = "7f241c049129a0e765ef449b634990409286ed75" uuid = "2b5f629d-d688-5b77-993f-72d75c75574e" -version = "6.40.8" +version = "6.40.9" [[DiffResults]] deps = ["StaticArrays"] @@ -262,15 +250,15 @@ version = "3.3.9+5" [[FileIO]] deps = ["Pkg"] -git-tree-sha1 = "202335fd24c2776493e198d6c66a6d910400a895" +git-tree-sha1 = "f354b2087a3b01c1d7152c19f45886c8a036fa5e" uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" -version = "1.3.0" +version = "1.4.0" [[FiniteDiff]] deps = ["ArrayInterface", "LinearAlgebra", "Requires", "SparseArrays", "StaticArrays"] -git-tree-sha1 = "b02b6f6ea2c33f86a444f9cf132c1d1180a66cfd" +git-tree-sha1 = "80becc23db3942d9e5eb8d0d42e725b9c46616f8" uuid = "6a86dc24-6348-571c-b903-95158fe2bd41" -version = "2.4.1" +version = "2.5.0" [[FixedPointNumbers]] git-tree-sha1 = "4aaea64dd0c30ad79037084f8ca2b94348e65eaa" @@ -486,9 +474,9 @@ version = "0.4.2" [[LoopVectorization]] deps = ["DocStringExtensions", "LinearAlgebra", "OffsetArrays", "SIMDPirates", "SLEEFPirates", "UnPack", "VectorizationBase"] -git-tree-sha1 = "4c002de66221639174e081ec74c156e9013e4afa" +git-tree-sha1 = "8c19b0c629dae1cea52a990d6303d03fe4328795" uuid = "bdcacae8-1622-11e9-2a5c-532679323890" -version = "0.8.17" +version = "0.8.19" [[METIS_jll]] deps = ["Libdl", "Pkg"] @@ -720,9 +708,9 @@ version = "0.5.4" [[SentinelArrays]] deps = ["Dates", "Random"] -git-tree-sha1 = "41e78a6419de2279b23cc70342c7147dc4c98860" +git-tree-sha1 = "cd9dccb026262a46d5a81ef1ce1e595150b2b8d2" uuid = "91c51154-3ec4-41a3-a24f-3f23e20d615c" -version = "1.2.8" +version = "1.2.9" [[Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" @@ -737,6 +725,12 @@ git-tree-sha1 = "2ee666b24ab8be6a922f9d6c11a86e1a703a7dda" uuid = "699a6c99-e7fa-54fc-8d76-47d257e15c1d" version = "0.9.2" +[[SmoothingSplines]] +deps = ["LinearAlgebra", "Random", "Reexport", "StatsBase", "Test"] +git-tree-sha1 = "9e47150ea38107ba762fb26bd5c2a000b27ecf94" +uuid = "102930c3-cf33-599f-b3b1-9a29a5acab30" +version = "0.2.1" + [[Sockets]] uuid = "6462fe0b-24de-5631-8697-dd941f90decc" diff --git a/Project.toml b/Project.toml index d96d1c64..06967dbe 100644 --- a/Project.toml +++ b/Project.toml @@ -7,7 +7,6 @@ version = "0.2.0" CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" Calculus = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9" Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" -Dierckx = "39dd38d3-220a-591b-8e3c-4c3a8c710a94" DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0" @@ -18,6 +17,7 @@ Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a" PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0" PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee" QuartzImageIO = "dca85d43-d64c-5e67-8c65-017450d5d020" +SmoothingSplines = "102930c3-cf33-599f-b3b1-9a29a5acab30" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" @@ -27,22 +27,22 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6" [compat] -julia = "^1.0.0" -CSV = "^0.7.3" -Calculus = "^0.5.1" -Colors = "^0.12.3" -Dierckx = "^0.4.2" -DiffEqBase = "^6.40.8" -ForwardDiff = "^0.10.12" -Images = "^0.22.4" -IterTools = "^1.3.0" -OrdinaryDiffEq = "^5.41.0" -Parameters = "^0.12.1" -PyCall = "^1.91.4" -PyPlot = "^2.9.0" -QuartzImageIO = "^0.7.1" -SpecialFunctions = "^0.10.3" -StaticArrays = "^0.12.4" -Sundials = "^4.2.5" -Unitful = "^1.3.0" -YAML = "^0.4.0" +CSV = "<1" +Calculus = "<1" +Colors = "<1" +DiffEqBase = "6.6.0" +ForwardDiff = "<1" +Images = "<1" +IterTools = "1.3.0" +OrdinaryDiffEq = "<6" +Parameters = "<1" +PyCall = "1.91.4" +PyPlot = "2.9.0" +QuartzImageIO = "<1" +SmoothingSplines = "<1" +SpecialFunctions = "<1" +StaticArrays = "<1" +Sundials = "<5" +Unitful = "1.3.0" +YAML = "<1" +julia = "1" From 87e8059e307b00ec398d3acb6fadb7747c4b0e8d Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Mon, 20 Jul 2020 16:12:13 -0400 Subject: [PATCH 3/4] update travis to work with python 3 --- .travis.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 25660a9f..1a4122c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,17 +13,13 @@ before_install: - bash miniconda.sh -b -p $HOME/miniconda - export PATH=$HOME/miniconda/bin:$PATH #create julia conda enviornment - - conda create -n conda_jl --yes python=2.7 conda + - conda create -n conda_jl --yes python=3.7 conda - source activate conda_jl - #install used packages - conda install -c rmg --yes rmg - - conda install -c rmg --yes rdkit - - conda install --yes pydot - - conda install --yes yaml - conda update --yes conda script: - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - travis_wait julia -e 'using Pkg; Pkg.clone("https://github.com/ReactionMechanismGenerator/ReactionMechanismSimulator.jl.git");' + - travis_wait julia -e 'using Pkg; Pkg.add(PackageSpec(path="ReactionMechanismSimulator.jl"));' - travis_wait julia -e 'using Pkg; Pkg.build("ReactionMechanismSimulator"); Pkg.test("ReactionMechanismSimulator"; coverage=true);' after_success: - julia -e 'cd(Pkg.dir("ReactionMechanismSimulator")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())' From 7f63ffb5a334a9b233f7b17bcad50f9e9bde2297 Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Mon, 20 Jul 2020 16:12:25 -0400 Subject: [PATCH 4/4] increment version number --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 06967dbe..13cde6ee 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ReactionMechanismSimulator" uuid = "c2d78dd2-25c4-5b79-bebc-be6c69dd440f" authors = ["Matt Johnson "] -version = "0.2.0" +version = "0.2.1" [deps] CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"