From 760a530817d885bfdd724492003c1db696f8de3c Mon Sep 17 00:00:00 2001 From: Mark Owkes Date: Wed, 19 Jun 2024 13:51:24 -0600 Subject: [PATCH] Added precompiling - runs case 1 --- Project.toml | 1 + src/Biofilm.jl | 2 ++ src/parameters.jl | 4 +-- src/precompile.jl | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 src/precompile.jl diff --git a/Project.toml b/Project.toml index 1dfe754..1847140 100644 --- a/Project.toml +++ b/Project.toml @@ -13,6 +13,7 @@ Measures = "442fdcdd-2543-5da2-b0f3-8c86c306513e" OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" +PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" diff --git a/src/Biofilm.jl b/src/Biofilm.jl index af919f4..d10588d 100644 --- a/src/Biofilm.jl +++ b/src/Biofilm.jl @@ -11,5 +11,7 @@ include("solver.jl") include("parameters.jl") include("computes.jl") include("postprocess.jl") +include("precompile.jl") + end \ No newline at end of file diff --git a/src/parameters.jl b/src/parameters.jl index 6dc49e3..2acc5e2 100644 --- a/src/parameters.jl +++ b/src/parameters.jl @@ -98,8 +98,8 @@ function checkType_setDef(err,d,type,name; default=nothing) @reset d[name] = (d[name], ) end end - # Check type - type(d[name]) + # Enforce type + @reset d[name] = type(d[name]) catch err = printError(err,"Parameter $name should be of type $type") end diff --git a/src/precompile.jl b/src/precompile.jl new file mode 100644 index 0000000..8372c46 --- /dev/null +++ b/src/precompile.jl @@ -0,0 +1,64 @@ +using PrecompileTools: @setup_workload, @compile_workload +@setup_workload begin + # Putting some things in `@setup_workload` instead of `@compile_workload` can reduce the size of the + # precompile file and potentially make loading faster. + + @compile_workload begin + # all calls in this block will be precompiled, regardless of whether + # they belong to your package or not (on Julia 1.8 and higher) + # Input parameters + mumax = 20; KM = 3; + p = ( + # --------------------- # + # Simulation Parameters # + # --------------------- # + Title = "Single Solute and Particulate Case", + tFinal = 1.0, # Simulation time [days] + tol = 1e-2, # Tolerance + outPeriod =0.1, # Time between outputs [days] + makePlots = true, + savePlots = true, + + # ---------------------- # + # Particulate Parameters # + # ---------------------- # + XNames =["Heterotroph"], # Particulate names + Xto = [10.0], # Tank particulate concentration initial condition(s) + Pbo = [0.08], # Biofilm particulates volume fraction initial condition(s) + rho = [2.0E4], # Particulate densities + Kdet = 20000.0, # Particulates detachment coefficient + srcX = [(S,X,Lf,t,z,p) -> 0.0], # Source of particulates + # Growthrates for each particulate + mu = [(S,X,Lf,t,z,p) -> (mumax * S[1]) ./ (KM .+ S[1])], + + # ----------------- # + # Solute Parameters # + # ----------------- # + SNames =["Nutrient"], # Solute names + Sin = [(t) -> 100], # Solute inflow (can be function of time) + Sto = [10.0], # Tank solute concentration initial condition(s) + Sbo = [0.0], # Biofilm solutes concentration initial condition(s) + Yxs = [2.646], # Biomass yield coefficient on solute + Dt = [4.0E-5], # Aquious solute diffusion through tank fluid + Db = [6.9E-5], # Effective solute diffusion through biofilm + srcS = [(S,X,Lf,t,z,p) -> 0.0], # Source of solutes + + # --------------- # + # Tank Parameters # + # --------------- # + V = 0.1, # Volume of tank [m³] + A = 1, # Surface area of biofilm [m²] + Q = 1, # Flowrate through tank [m³/d] + + # ------------------ # + # Biofilm Parameters # + # ------------------ # + Nz = 50, # Number of grid points in biofilm + Lfo = 1.0E-5, # Biofilm initial thickness [m] + LL = 1.00E-7, # Boundary layer thickness [m] + ) + + t,zm,Xt,St,Pb,Sb,Lf,sol = BiofilmSolver(p) # Run solver + biofilm_plot(sol,p) # Plot final results + end +end \ No newline at end of file