Skip to content

Commit e62bc9b

Browse files
authored
Merge pull request #44 from ReactionMechanismGenerator/splines
Replace Dierckx with SmoothingSplines
2 parents 838056a + 7f63ffb commit e62bc9b

4 files changed

Lines changed: 60 additions & 66 deletions

File tree

.travis.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,13 @@ before_install:
1313
- bash miniconda.sh -b -p $HOME/miniconda
1414
- export PATH=$HOME/miniconda/bin:$PATH
1515
#create julia conda enviornment
16-
- conda create -n conda_jl --yes python=2.7 conda
16+
- conda create -n conda_jl --yes python=3.7 conda
1717
- source activate conda_jl
18-
#install used packages
1918
- conda install -c rmg --yes rmg
20-
- conda install -c rmg --yes rdkit
21-
- conda install --yes pydot
22-
- conda install --yes yaml
2319
- conda update --yes conda
2420
script:
2521
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
26-
- travis_wait julia -e 'using Pkg; Pkg.clone("https://github.com/ReactionMechanismGenerator/ReactionMechanismSimulator.jl.git");'
22+
- travis_wait julia -e 'using Pkg; Pkg.add(PackageSpec(path="ReactionMechanismSimulator.jl"));'
2723
- travis_wait julia -e 'using Pkg; Pkg.build("ReactionMechanismSimulator"); Pkg.test("ReactionMechanismSimulator"; coverage=true);'
2824
after_success:
2925
- julia -e 'cd(Pkg.dir("ReactionMechanismSimulator")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'

Manifest.toml

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ version = "0.0.4"
2626

2727
[[ArrayInterface]]
2828
deps = ["LinearAlgebra", "Requires", "SparseArrays"]
29-
git-tree-sha1 = "0eccdcbe27fd6bd9cba3be31c67bdd435a21e865"
29+
git-tree-sha1 = "066d1e7a9eb4873660791db7f0d8c7902600b81c"
3030
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
31-
version = "2.9.1"
31+
version = "2.11.0"
3232

3333
[[AxisAlgorithms]]
3434
deps = ["LinearAlgebra", "Random", "SparseArrays", "WoodburyMatrices"]
@@ -45,22 +45,16 @@ version = "0.4.3"
4545
[[Base64]]
4646
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
4747

48-
[[BinaryProvider]]
49-
deps = ["Libdl", "Logging", "SHA"]
50-
git-tree-sha1 = "ecdec412a9abc8db54c0efc5548c64dfce072058"
51-
uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
52-
version = "0.5.10"
53-
5448
[[CEnum]]
5549
git-tree-sha1 = "215a9aa4a1f23fbd05b92769fdd62559488d70e9"
5650
uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82"
5751
version = "0.4.1"
5852

5953
[[CSV]]
6054
deps = ["CategoricalArrays", "DataFrames", "Dates", "Mmap", "Parsers", "PooledArrays", "SentinelArrays", "Tables", "Unicode"]
61-
git-tree-sha1 = "a100a1dd6ab63fc49e79c90dae67e5bc126419ff"
55+
git-tree-sha1 = "f095e44feec53d0ae809714a78c25908d1f370e6"
6256
uuid = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
63-
version = "0.7.3"
57+
version = "0.7.4"
6458

6559
[[Calculus]]
6660
deps = ["LinearAlgebra"]
@@ -82,9 +76,9 @@ version = "0.8.1"
8276

8377
[[ChainRulesCore]]
8478
deps = ["MuladdMacro"]
85-
git-tree-sha1 = "87e289253a5fc690c4860a41bbd427e16576f716"
79+
git-tree-sha1 = "9907341fe861268ddd0fc60be260633756b126a2"
8680
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
87-
version = "0.9.3"
81+
version = "0.9.4"
8882

8983
[[ColorTypes]]
9084
deps = ["FixedPointNumbers", "Random"]
@@ -191,17 +185,11 @@ uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
191185
deps = ["Mmap"]
192186
uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"
193187

194-
[[Dierckx]]
195-
deps = ["BinaryProvider", "Libdl", "Random", "Test"]
196-
git-tree-sha1 = "956bfe5c4f9b794545f6527424fc0294cc5decbe"
197-
uuid = "39dd38d3-220a-591b-8e3c-4c3a8c710a94"
198-
version = "0.4.2"
199-
200188
[[DiffEqBase]]
201189
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"]
202-
git-tree-sha1 = "71499ee24ffe00892a9e80cc953fe0421a54b552"
190+
git-tree-sha1 = "7f241c049129a0e765ef449b634990409286ed75"
203191
uuid = "2b5f629d-d688-5b77-993f-72d75c75574e"
204-
version = "6.40.8"
192+
version = "6.40.9"
205193

206194
[[DiffResults]]
207195
deps = ["StaticArrays"]
@@ -262,15 +250,15 @@ version = "3.3.9+5"
262250

263251
[[FileIO]]
264252
deps = ["Pkg"]
265-
git-tree-sha1 = "202335fd24c2776493e198d6c66a6d910400a895"
253+
git-tree-sha1 = "f354b2087a3b01c1d7152c19f45886c8a036fa5e"
266254
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
267-
version = "1.3.0"
255+
version = "1.4.0"
268256

269257
[[FiniteDiff]]
270258
deps = ["ArrayInterface", "LinearAlgebra", "Requires", "SparseArrays", "StaticArrays"]
271-
git-tree-sha1 = "b02b6f6ea2c33f86a444f9cf132c1d1180a66cfd"
259+
git-tree-sha1 = "80becc23db3942d9e5eb8d0d42e725b9c46616f8"
272260
uuid = "6a86dc24-6348-571c-b903-95158fe2bd41"
273-
version = "2.4.1"
261+
version = "2.5.0"
274262

275263
[[FixedPointNumbers]]
276264
git-tree-sha1 = "4aaea64dd0c30ad79037084f8ca2b94348e65eaa"
@@ -486,9 +474,9 @@ version = "0.4.2"
486474

487475
[[LoopVectorization]]
488476
deps = ["DocStringExtensions", "LinearAlgebra", "OffsetArrays", "SIMDPirates", "SLEEFPirates", "UnPack", "VectorizationBase"]
489-
git-tree-sha1 = "4c002de66221639174e081ec74c156e9013e4afa"
477+
git-tree-sha1 = "8c19b0c629dae1cea52a990d6303d03fe4328795"
490478
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
491-
version = "0.8.17"
479+
version = "0.8.19"
492480

493481
[[METIS_jll]]
494482
deps = ["Libdl", "Pkg"]
@@ -720,9 +708,9 @@ version = "0.5.4"
720708

721709
[[SentinelArrays]]
722710
deps = ["Dates", "Random"]
723-
git-tree-sha1 = "41e78a6419de2279b23cc70342c7147dc4c98860"
711+
git-tree-sha1 = "cd9dccb026262a46d5a81ef1ce1e595150b2b8d2"
724712
uuid = "91c51154-3ec4-41a3-a24f-3f23e20d615c"
725-
version = "1.2.8"
713+
version = "1.2.9"
726714

727715
[[Serialization]]
728716
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
@@ -737,6 +725,12 @@ git-tree-sha1 = "2ee666b24ab8be6a922f9d6c11a86e1a703a7dda"
737725
uuid = "699a6c99-e7fa-54fc-8d76-47d257e15c1d"
738726
version = "0.9.2"
739727

728+
[[SmoothingSplines]]
729+
deps = ["LinearAlgebra", "Random", "Reexport", "StatsBase", "Test"]
730+
git-tree-sha1 = "9e47150ea38107ba762fb26bd5c2a000b27ecf94"
731+
uuid = "102930c3-cf33-599f-b3b1-9a29a5acab30"
732+
version = "0.2.1"
733+
740734
[[Sockets]]
741735
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
742736

Project.toml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
name = "ReactionMechanismSimulator"
22
uuid = "c2d78dd2-25c4-5b79-bebc-be6c69dd440f"
33
authors = ["Matt Johnson <mjohnson541@gmail.com>"]
4-
version = "0.2.0"
4+
version = "0.2.1"
55

66
[deps]
77
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
88
Calculus = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9"
99
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
10-
Dierckx = "39dd38d3-220a-591b-8e3c-4c3a8c710a94"
1110
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
1211
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
1312
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
@@ -18,6 +17,7 @@ Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
1817
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
1918
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
2019
QuartzImageIO = "dca85d43-d64c-5e67-8c65-017450d5d020"
20+
SmoothingSplines = "102930c3-cf33-599f-b3b1-9a29a5acab30"
2121
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
2222
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
2323
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
@@ -27,22 +27,22 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
2727
YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"
2828

2929
[compat]
30-
julia = "^1.0.0"
31-
CSV = "^0.7.3"
32-
Calculus = "^0.5.1"
33-
Colors = "^0.12.3"
34-
Dierckx = "^0.4.2"
35-
DiffEqBase = "^6.40.8"
36-
ForwardDiff = "^0.10.12"
37-
Images = "^0.22.4"
38-
IterTools = "^1.3.0"
39-
OrdinaryDiffEq = "^5.41.0"
40-
Parameters = "^0.12.1"
41-
PyCall = "^1.91.4"
42-
PyPlot = "^2.9.0"
43-
QuartzImageIO = "^0.7.1"
44-
SpecialFunctions = "^0.10.3"
45-
StaticArrays = "^0.12.4"
46-
Sundials = "^4.2.5"
47-
Unitful = "^1.3.0"
48-
YAML = "^0.4.0"
30+
CSV = "<1"
31+
Calculus = "<1"
32+
Colors = "<1"
33+
DiffEqBase = "6.6.0"
34+
ForwardDiff = "<1"
35+
Images = "<1"
36+
IterTools = "1.3.0"
37+
OrdinaryDiffEq = "<6"
38+
Parameters = "<1"
39+
PyCall = "1.91.4"
40+
PyPlot = "2.9.0"
41+
QuartzImageIO = "<1"
42+
SmoothingSplines = "<1"
43+
SpecialFunctions = "<1"
44+
StaticArrays = "<1"
45+
Sundials = "<5"
46+
Unitful = "1.3.0"
47+
YAML = "<1"
48+
julia = "1"

src/Domain.jl

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using Parameters
22
using LinearAlgebra
33
using StaticArrays
4-
using Dierckx
54
using Calculus
5+
using SmoothingSplines
66

77
abstract type AbstractDomain end
88
export AbstractDomain
@@ -263,16 +263,14 @@ function ParametrizedTPDomain(;phase::Z,initialconds::Dict{X,Any},constantspecie
263263
end
264264
@assert V != 0.0 || (T != 0.0 && P != 0.0)
265265
if isa(T,AbstractArray)
266-
q = Spline1D(ts,T;k=3,s=1e-11)
267-
Tfcn(x::Float64) = q(x)
266+
Tfcn = getspline(ts,T)
268267
elseif isa(T,Function)
269268
Tfcn = T
270269
else
271270
throw(error("ParametrizedTPDomain must take \"T\" as a function or if an array of times for \"ts\" is supplied as an array of volumes"))
272271
end
273272
if isa(P,AbstractArray)
274-
v = Spline1D(ts,P;k=3,s=1e-11)
275-
Pfcn(x::Float64) = v(x)
273+
Pfcn = getspline(ts,P)
276274
elseif isa(P,Function)
277275
Pfcn = P
278276
else
@@ -346,8 +344,7 @@ function ParametrizedVDomain(;phase::Z,initialconds::Dict{X,Any},constantspecies
346344
end
347345
@assert isa(V,Function) || isa(V,AbstractArray)
348346
if isa(V,AbstractArray)
349-
q = Spline1D(ts,V;k=3,s=1e-11)
350-
Vfcn = f(x::Float64) = q(x)
347+
Vfcn = getspline(ts,V)
351348
elseif isa(V,Function)
352349
Vfcn = V
353350
else
@@ -422,8 +419,7 @@ function ParametrizedPDomain(;phase::Z,initialconds::Dict{X,Any},constantspecies
422419
end
423420
@assert isa(P,Function) || isa(P,AbstractArray)
424421
if isa(P,AbstractArray)
425-
q = Spline1D(ts,P;k=3,s=1e-11)
426-
Pfcn = f(x::Float64) = q(x)
422+
Pfcn = getspline(ts,P)
427423
elseif isa(P,Function)
428424
Pfcn = P
429425
else
@@ -577,8 +573,7 @@ function ParametrizedTConstantVDomain(;phase::IdealDiluteSolution,initialconds::
577573
end
578574
end
579575
if isa(T,AbstractArray)
580-
q = Spline1D(ts,T;k=3,s=1e-11)
581-
Tfcn = f(x::Float64) = q(x)
576+
Tfcn = getspline(ts,T)
582577
elseif isa(T,Function)
583578
Tfcn = T
584579
else
@@ -943,3 +938,12 @@ function getreactionindices(ig::Q) where {Q<:AbstractPhase}
943938
return arr
944939
end
945940
export getreactionindices
941+
942+
"""
943+
fit a cubic spline to data and return a function evaluating that spline
944+
"""
945+
function getspline(xs,vals;s=1e-10)
946+
smspl = fit(SmoothingSpline,xs,vals,s)
947+
F(x::T) where {T} = predict(smspl,x)
948+
return F
949+
end

0 commit comments

Comments
 (0)