From 079da59e43cafb0d0128cef6884d6cec26ff2913 Mon Sep 17 00:00:00 2001 From: Marc Berliner Date: Tue, 5 Oct 2021 15:12:31 -0400 Subject: [PATCH 1/5] init --- src/checks.jl | 245 +++++++++++------- src/external.jl | 81 ++++-- src/generate_functions.jl | 16 +- src/model_evaluation.jl | 4 +- src/outputs.jl | 1 + .../auxiliary_states_and_coefficients.jl | 92 +++++-- src/physics_equations/residuals.jl | 31 ++- src/physics_equations/scalar_residual.jl | 7 +- src/set_variables.jl | 14 +- src/structures.jl | 28 +- 10 files changed, 359 insertions(+), 160 deletions(-) diff --git a/src/checks.jl b/src/checks.jl index cf5730f..9befdde 100644 --- a/src/checks.jl +++ b/src/checks.jl @@ -1,37 +1,84 @@ -@inline function check_simulation_stop!(model::R1, t::Float64, Y::R2, YP::R2, run::R3, p::R4, bounds::R5, opts::R6; +@inline function check_simulation_stop!(model, t::Float64, Y, YP, run::AbstractRun, p, bounds, opts::options_model; ϵ::Float64 = t < 1.0 ? opts.reltol : 0.0, - ) where {R1<:model_output, R2<:Vector{Float64}, method<:AbstractMethod, R3<:AbstractRun{method},R4<:param,R5<:boundary_stop_conditions,R6<:options_model} - tf = run.tf + ) - if t ≥ tf + if t ≥ run.tf run.info.flag = 0 run.info.exit_reason = "Final time reached" + return nothing end # continue checking the bounds or return after only evaluating the time !opts.check_bounds && (return nothing) + + I = calc_I(Y,p) + + check_stop_I( p, run, model, Y, YP, bounds, ϵ, I) + check_stop_V( p, run, model, Y, YP, bounds, ϵ, I) + check_stop_SOC( p, run, model, Y, YP, bounds, ϵ, I) + check_stop_T( p, run, model, Y, YP, bounds, ϵ, I) + check_stop_c_s_surf( p, run, model, Y, YP, bounds, ϵ, I) + check_stop_c_e( p, run, model, Y, YP, bounds, ϵ, I) + check_stop_η_plating( p, run, model, Y, YP, bounds, ϵ, I) + check_stop_dfilm( p, run, model, Y, YP, bounds, ϵ, I) + + return nothing +end + +@inline check_stop_I(p::R4, run::R3, model, Y::R2, YP::R2, bounds::R5, ϵ::Float64, I::Float64 + ) where {R2<:Vector{Float64}, R3<:AbstractRun{method_I},R4<:param,R5<:boundary_stop_conditions} = nothing +@inline function check_stop_I(p::R4, run::R3, model, Y::R2, YP::R2, bounds::R5, ϵ::Float64, I::Float64 + ) where {R2<:Vector{Float64}, method, R3<:AbstractRun{method},R4<:param,R5<:boundary_stop_conditions} + + if (I - bounds.I_max > ϵ) + t_frac = (bounds.I_prev - bounds.I_max)/(bounds.I_prev - I) + if t_frac < bounds.t_final_interp_frac + bounds.t_final_interp_frac = t_frac + run.info.flag = 7 + run.info.exit_reason = "Above maximum permitted C-rate" + end + elseif (bounds.I_min - I > ϵ) + t_frac = (bounds.I_prev - bounds.I_min)/(bounds.I_prev - I) + if t_frac < bounds.t_final_interp_frac + bounds.t_final_interp_frac = t_frac + run.info.flag = 8 + run.info.exit_reason = "Below minimum permitted C-rate" + end + end + bounds.I_prev = I + + return nothing +end + +@inline check_stop_V(p::R4, run::R3, model, Y::R2, YP::R2, bounds::R5, ϵ::Float64, I::Float64 +) where {R2<:Vector{Float64}, R3<:AbstractRun{method_V},R4<:param,R5<:boundary_stop_conditions} = nothing +@inline function check_stop_V(p::R4, run::R3, model, Y::R2, YP::R2, bounds::R5, ϵ::Float64, I::Float64 + ) where {R2<:Vector{Float64}, method, R3<:AbstractRun{method},R4<:param,R5<:boundary_stop_conditions} V = calc_V(Y,p) - I = calc_I(Y,p) - if !(method === method_V) - if (bounds.V_min - V > ϵ) && I < 0 - t_frac = (bounds.V_prev - bounds.V_min)/(bounds.V_prev - V) - if t_frac < bounds.t_final_interp_frac - bounds.t_final_interp_frac = t_frac - run.info.flag = 1 - run.info.exit_reason = "Below minimum voltage limit" - end + if (bounds.V_min - V > ϵ) && I < 0 + t_frac = (bounds.V_prev - bounds.V_min)/(bounds.V_prev - V) + if t_frac < bounds.t_final_interp_frac + bounds.t_final_interp_frac = t_frac + run.info.flag = 1 + run.info.exit_reason = "Below minimum voltage limit" end - - if (V - bounds.V_max > ϵ) && I > 0 - t_frac = (bounds.V_prev - bounds.V_max)/(bounds.V_prev - V) - if t_frac < bounds.t_final_interp_frac - bounds.t_final_interp_frac = t_frac - run.info.flag = 2 - run.info.exit_reason = "Above maximum voltage limit" - end + elseif (V - bounds.V_max > ϵ) && I > 0 + t_frac = (bounds.V_prev - bounds.V_max)/(bounds.V_prev - V) + if t_frac < bounds.t_final_interp_frac + bounds.t_final_interp_frac = t_frac + run.info.flag = 2 + run.info.exit_reason = "Above maximum voltage limit" end end + bounds.V_prev = V + + return nothing +end + +@inline function check_stop_SOC(p::R4, run::R3, model::model_output, Y::R2, YP::R2, bounds::R5, ϵ::Float64, I::Float64 + ) where {R2<:Vector{Float64}, R3<:AbstractRun,R4<:param,R5<:boundary_stop_conditions} + SOC = @inbounds model.SOC[end] if (bounds.SOC_min - SOC > ϵ) && I < 0 t_frac = (bounds.SOC_prev - bounds.SOC_min)/(bounds.SOC_prev - SOC) @@ -40,8 +87,7 @@ run.info.flag = 3 run.info.exit_reason = "Below minimum SOC limit" end - end - if (SOC - bounds.SOC_max > ϵ) && I > 0 + elseif (SOC - bounds.SOC_max > ϵ) && I > 0 t_frac = (bounds.SOC_prev - bounds.SOC_max)/(bounds.SOC_prev - SOC) if t_frac < bounds.t_final_interp_frac bounds.t_final_interp_frac = t_frac @@ -49,8 +95,16 @@ run.info.exit_reason = "Above maximum SOC limit" end end - - if p.numerics.temperature + bounds.SOC_prev = SOC + + return SOC +end + +@inline check_stop_T(p::param_temp{false}, run, model, Y, YP, bounds, ϵ, I) = nothing +@inline function check_stop_T(p::R4, run::R3, model, Y::R2, YP::R2, bounds::R5, ϵ::Float64, I::Float64 + ) where {R2<:Vector{Float64}, R3<:AbstractRun,R4<:param_temp{true},R5<:boundary_stop_conditions} + + if !isnan(bounds.T_max) T = temperature_weighting(calc_T(Y,p),p) if T - bounds.T_max > ϵ t_frac = (bounds.T_prev - bounds.T_max)/(bounds.T_prev - T) @@ -60,48 +114,75 @@ run.info.exit_reason = "Above maximum permitted temperature" end end - else - T = -1.0 + bounds.T_prev = T + end + + return nothing +end + +@inline function c_s_n_maximum(Y::Vector{Float64},p::param_solid_diff{:Fickian}) + c_s_n_max = -Inf + @inbounds for i in 1:p.N.n + @inbounds c_s_n_max = max(c_s_n_max, Y[p.ind.c_s_avg.n[p.N.r_n*(i-1)]]) + end + return c_s_n_max +end +@inline function c_s_n_maximum(Y::Vector{Float64},p::Union{param_solid_diff{:polynomial},param_solid_diff{:quadratic}}) + c_s_n_max = -Inf + @inbounds for ind in p.ind.c_s_avg.n + @inbounds c_s_n_max = max(c_s_n_max, Y[ind]) + end + return c_s_n_max +end + +@inline function check_stop_c_s_surf(p::R4, run::R3, model, Y::R2, YP::R2, bounds::R5, ϵ::Float64, I::Float64 + ) where {R2<:Vector{Float64}, R3<:AbstractRun,R4<:param,R5<:boundary_stop_conditions} + + if !isnan(bounds.c_s_n_max) + c_s_n_max = c_s_n_maximum(Y,p) + + if I > 0 + if c_s_n_max - bounds.c_s_n_max*p.θ[:c_max_n] > ϵ + t_frac = (bounds.c_s_n_prev - bounds.c_s_n_max*(p.θ[:c_max_n]))/(bounds.c_s_n_prev - c_s_n_max) + if t_frac < bounds.t_final_interp_frac + bounds.t_final_interp_frac = t_frac + run.info.flag = 6 + run.info.exit_reason = "Above c_s_n saturation threshold" + end + end + end + bounds.c_s_n_prev = c_s_n_max end + + return nothing +end + +@inline function check_stop_c_e(p::R4, run::R3, model, Y::R2, YP::R2, bounds::R5, ϵ::Float64, I::Float64 + ) where {R2<:Vector{Float64}, R3<:AbstractRun, R4<:param, R5<:boundary_stop_conditions} - c_s_avg = calc_c_s_avg(Y,p) - if !isnan(bounds.c_s_n_max) && I > 0 - if p.numerics.solid_diffusion === :Fickian - c_s_n_max = maximum((@inbounds @views c_s_avg[(p.N.p)*(p.N.r_p)+1:end])) - else - c_s_n_max = maximum((@inbounds @views c_s_avg[(p.N.p)+1:end])) + if !isnan(bounds.c_e_min) + c_e_min = -Inf + @inbounds for ind in p.ind.c_e + @inbounds c_e_min = max(c_e_min, Y[ind]) end - - if c_s_n_max - bounds.c_s_n_max*p.θ[:c_max_n] > ϵ - t_frac = (bounds.c_s_n_prev - bounds.c_s_n_max*(p.θ[:c_max_n]))/(bounds.c_s_n_prev - c_s_n_max) + if bounds.c_e_min - c_e_min > ϵ + t_frac = (bounds.c_e_min_prev - bounds.c_e_min)/(bounds.c_e_min_prev - c_e_min) if t_frac < bounds.t_final_interp_frac bounds.t_final_interp_frac = t_frac - run.info.flag = 6 - run.info.exit_reason = "Above c_s_n saturation threshold" + run.info.flag = 9 + run.info.exit_reason = "Below minimum permitted c_e" end end - else - c_s_n_max = -1.0 + bounds.c_e_min_prev = c_e_min end - if !(method === method_I) && (I - bounds.I_max > ϵ) - t_frac = (bounds.I_prev - bounds.I_max)/(bounds.I_prev - I) - if t_frac < bounds.t_final_interp_frac - bounds.t_final_interp_frac = t_frac - run.info.flag = 7 - run.info.exit_reason = "Above maximum permitted C-rate" - end - end - if !(method === method_I) && (bounds.I_min - I > ϵ) - t_frac = (bounds.I_prev - bounds.I_min)/(bounds.I_prev - I) - if t_frac < bounds.t_final_interp_frac - bounds.t_final_interp_frac = t_frac - run.info.flag = 8 - run.info.exit_reason = "Below minimum permitted C-rate" - end - end + return nothing +end - η_plating = @inbounds Y[p.ind.Φ_s.n[1]] - Y[p.ind.Φ_e.n[1]] +@inline function check_stop_η_plating(p::R4, run::R3, model, Y::R2, YP::R2, bounds::R5, ϵ::Float64, I::Float64 + ) where {R2<:Vector{Float64}, R3<:AbstractRun, R4<:param, R5<:boundary_stop_conditions} + + η_plating = calc_η_plating(Y,p) if !isnan(bounds.η_plating_min) && bounds.η_plating_min - η_plating > ϵ t_frac = (bounds.η_plating_prev - bounds.η_plating_min)/(bounds.η_plating_prev - η_plating) if t_frac < bounds.t_final_interp_frac @@ -110,45 +191,35 @@ run.info.exit_reason = "Below minimum permitted η_plating" end end + bounds.η_plating_prev = η_plating + + return nothing +end - c_e_min = minimum(calc_c_e(Y,p)) - if !isnan(bounds.c_e_min) && bounds.c_e_min - c_e_min > ϵ - t_frac = (bounds.c_e_min_prev - bounds.c_e_min)/(bounds.c_e_min_prev - c_e_min) +@inline check_stop_dfilm(::param_age{false}, run, model, Y, YP, bounds, ϵ, I) = nothing +@inline function check_stop_dfilm(p::R4, run::R3, model, Y::R2, YP::R2, bounds::R5, ϵ::Float64, I::Float64 + ) where {R2<:Vector{Float64}, R3<:AbstractRun, R4<:param_age{:SEI}, R5<:boundary_stop_conditions} + + dfilm_max = -Inf + @inbounds for i in 1:p.N.n + @inbounds dfilm_max = max(dfilm_max, YP[p.ind.film[i]]) + end + + if !isnan(bounds.dfilm_max) && dfilm_max - bounds.dfilm_max > ϵ + t_frac = (bounds.dfilm_prev - bounds.dfilm_max)/(bounds.dfilm_prev - dfilm_max) if t_frac < bounds.t_final_interp_frac bounds.t_final_interp_frac = t_frac - run.info.flag = 9 - run.info.exit_reason = "Below minimum permitted c_e" - end - end - - if !(p.numerics.aging === false) - dfilm = maximum(calc_film(YP,p)) - if !isnan(bounds.dfilm_max) && dfilm - bounds.dfilm_max > ϵ - t_frac = (bounds.dfilm_prev - bounds.dfilm_max)/(bounds.dfilm_prev - dfilm) - if t_frac < bounds.t_final_interp_frac - bounds.t_final_interp_frac = t_frac - run.info.flag = 10 - run.info.exit_reason = "Above maximum film growth rate" - end + run.info.flag = 10 + run.info.exit_reason = "Above maximum film growth rate" end - else - dfilm = -1.0 - end - - if within_bounds(run) - bounds.V_prev = V - bounds.I_prev = I - bounds.SOC_prev = SOC - bounds.T_prev = T - bounds.c_s_n_prev = c_s_n_max - bounds.c_e_min_prev = c_e_min - bounds.η_plating_prev = η_plating - bounds.dfilm_prev = dfilm end + bounds.dfilm_prev = dfilm_max return nothing end + + @inline function check_solve(run::run_constant, model::R1, int::R2, p, bounds, opts::R5, funcs, keep_Y::Bool, iter::Int64, Y::Vector{Float64}, t::Float64) where {R1<:model_output,R2<:Sundials.IDAIntegrator,R5<:options_model} if t === int.tprev # Sometimes the initial step at t = 0 can be too large. This reduces the step size diff --git a/src/external.jl b/src/external.jl index 42fc476..4ea8312 100644 --- a/src/external.jl +++ b/src/external.jl @@ -313,6 +313,7 @@ function state_indices(N, numerics) Q_tot = numerics.solid_diffusion === :polynomial ? (1:(N.p+N.n)) : nothing j_tot = 1:(N.p+N.n) j_s_tot = numerics.aging ∈ (:SEI, :R_aging) ? (1:N.n) : nothing + SOH_tot = numerics.aging ∈ (:SEI, :R_aging) ? 1 : nothing Φ_e_tot = 1:(N.p+N.s+N.n) Φ_s_tot = 1:(N.p+N.n) I_tot = 1 @@ -322,6 +323,7 @@ function state_indices(N, numerics) T = add(:T, T_tot, (:a, :p, :s, :n, :z), :differential) film = add(:film, film_tot, (:n,), :differential) Q = add(:Q, Q_tot, (:p, :n), :differential) + SOH = add(:SOH, SOH_tot, (), :differential) j = add(:j, j_tot, (:p, :n), :algebraic) j_s = add(:j_s, j_s_tot, (:n,), :algebraic) Φ_e = add(:Φ_e, Φ_e_tot, (:p, :s, :n), :algebraic) @@ -334,7 +336,7 @@ function state_indices(N, numerics) Y = YP = t = V = P = SOC = index_state() runs = nothing - ind = indices_states(Y, YP, c_e, c_s_avg, T, film, Q, j, j_s, Φ_e, Φ_s, I, t, V, P, SOC, runs) + ind = indices_states(Y, YP, c_e, c_s_avg, T, film, Q, j, j_s, Φ_e, Φ_s, I, t, V, P, SOC, SOH, runs) return ind, N_diff, N_alg, N_tot end @@ -360,36 +362,27 @@ end build_OCV!(states, p) - function guess_differential!() + # differential + states[:c_e] = repeat([p.θ[:c_e₀]], (p.N.p+p.N.s+p.N.n)) - states[:c_e] = repeat([p.θ[:c_e₀]], (p.N.p+p.N.s+p.N.n)) + states[:T] = repeat([p.θ[:T₀]], (p.N.p+p.N.s+p.N.n)+p.N.a+p.N.z) - states[:T] = repeat([p.θ[:T₀]], (p.N.p+p.N.s+p.N.n)+p.N.a+p.N.z) + states[:film] = zeros(p.N.n) - states[:film] = zeros(p.N.n) - - states[:Q] = zeros(p.N.p+p.N.n) - - return nothing - end + states[:Q] = zeros(p.N.p+p.N.n) + + if p.numerics.aging ∈ (:SEI, :R_aging) states[:SOH] = 1.0 end - function guess_algebraic!() - states[:j] = 0.0 + # algebraic + states[:j] = 0.0 - states[:Φ_e] = 0.0 + states[:Φ_e] = 0.0 - states[:Φ_s] = states[:U] + states[:Φ_s] = states[:U] - states[:I] = X_applied + states[:I] = X_applied - if !isempty(states[:j_s]) states[:j_s] .= 0.0 end - - return nothing - end - - # creating initial guess vectors Y and YP - guess_differential!() - guess_algebraic!() + if !isempty(states[:j_s]) states[:j_s] .= 0.0 end build_residuals!(Y0, states, p) @@ -435,4 +428,46 @@ function strings_directory_func(p::AbstractParam, x; create_dir=false) strings_directory = string("$(strings_directory_func(p; create_dir=create_dir))/$x.jl") return strings_directory +end + + +@inline function trapz(x::T1,y::T2) where {T1<:AbstractVector,T2<:AbstractVector} + """ + Trapezoidal rule with SIMD vectorization + """ + @assert length(x) === length(y) + out = 0.0 + @inbounds @simd for i in 2:length(x) + out += 0.5*(x[i] - x[i-1])*(y[i] + y[i-1]) + end + return out +end + +function extrap_x_0(x::AbstractVector,y::AbstractVector) + @inbounds y[1] - ((y[3] - y[1] - (((x[2] - x[1])^-1)*(x[3] - x[1])*(y[2] - y[1])))*((x[3]^2 - (x[1]^2) - (((x[2] - x[1])^-1)*(x[2]^2 - (x[1]^2))*(x[3] - x[1])))^-1)*(x[1]^2)) - ((y[2] - y[1] - (((x[3]^2 - (x[1]^2) - (((x[2] - x[1])^-1)*(x[2]^2 - (x[1]^2))*(x[3] - x[1])))^-1)*(x[2]^2 - (x[1]^2))*(y[3] - y[1] - (((x[2] - x[1])^-1)*(x[3] - x[1])*(y[2] - y[1])))))*((x[2] - x[1])^-1)*x[1]) +end +function extrapolate_section(y::AbstractVector,p::AbstractParam,section::Symbol) + """ + Extrapolate to the edges of the FVM sections with a second-order polynomial + """ + + N = getproperty(p.N, section) + + x_range = [ + 0 + collect(range(1/2N,1-1/2N,length=N)) + 1 + ] + + x_interp = @views @inbounds x_range[2:4] + + y_range = [ + extrap_x_0(x_interp,y) + y + extrap_x_0(x_interp,(@inbounds @views y[end:-1:end-2])) + ] + + x_range *= p.θ[Symbol(:l_,section)] + + return x_range, y_range end \ No newline at end of file diff --git a/src/generate_functions.jl b/src/generate_functions.jl index 13c3d95..1352225 100644 --- a/src/generate_functions.jl +++ b/src/generate_functions.jl @@ -55,20 +55,18 @@ function load_functions_symbolic(p::AbstractParam) return initial_guess!, f_alg!, f_diff!, J_y!, J_y_alg!, θ_keys end -function generate_functions_symbolic(p::AbstractParam; verbose=true) +function generate_functions_symbolic(p::AbstractParam; verbose=options[:SAVE_SYMBOLIC_FUNCTIONS]) - println_v(x...) = verbose ? println(x...) : nothing - - println_v("Creating the functions for $p\n\nMay take a few minutes...") + if verbose println("Creating the functions for $p\n\nMay take a few minutes...") end θ_sym, Y_sym, YP_sym, t_sym, SOC_sym, X_applied, γ_sym, p_sym, θ_keys = get_symbolic_vars(p) ## Y0 function - println_v("1/4: Making initial guess function") + if verbose println("1/4: Making initial guess function") end Y0_sym = _symbolic_initial_guess(p_sym, SOC_sym, θ_sym, X_applied) ## batteryModel function - println_v("2/4: Making symbolic model") + if verbose println("2/4: Making symbolic model") end res = _symbolic_residuals(p_sym, t_sym, Y_sym, YP_sym) θ_sym_slim, θ_keys_slim = get_only_θ_used_in_model(θ_sym, θ_keys, res, Y0_sym) @@ -76,10 +74,10 @@ function generate_functions_symbolic(p::AbstractParam; verbose=true) Y0Func = build_function(Y0_sym, SOC_sym, θ_sym_slim, X_applied, fillzeros=false, checkbounds=false)[2] ## jacobian - println_v("3/4: Making symbolic Jacobian") + if verbose println("3/4: Making symbolic Jacobian") end Jac, jacFunc, J_sp = _symbolic_jacobian(p, res, t_sym, Y_sym, YP_sym, γ_sym, θ_sym, θ_sym_slim, verbose=verbose) - println_v("4/4: Making initial condition functions") + if verbose println("4/4: Making initial condition functions") end res_algFunc, res_diffFunc = _symbolic_initial_conditions_res(p, res, t_sym, Y_sym, YP_sym, θ_sym, θ_sym_slim) jac_algFunc = _symbolic_initial_conditions_jac(p, Jac, t_sym, Y_sym, YP_sym, γ_sym, θ_sym_slim) @@ -102,7 +100,7 @@ function generate_functions_symbolic(p::AbstractParam; verbose=true) @save dir * "J_sp.jl" J_y_sp θ_keys end - println_v("Finished\n") + if verbose println("Finished\n") end return Y0Func, res_algFunc, res_diffFunc, jacFunc, jac_algFunc, J_y_sp, θ_keys end diff --git a/src/model_evaluation.jl b/src/model_evaluation.jl index 82274c0..42c475f 100644 --- a/src/model_evaluation.jl +++ b/src/model_evaluation.jl @@ -341,7 +341,7 @@ end return key, key_exists end -@inline function initialize_states!(p::param{T}, Y0::R1, YP0::R1, run::AbstractRun, opts::options_model, funcs::Jac_and_res, SOC::Float64;kw...) where {T<:AbstractJacobian,R1<:Vector{Float64}} +@inline function initialize_states!(p::param, Y0::T, YP0::T, run::AbstractRun, opts::options_model, funcs::Jac_and_res, SOC::Float64;kw...) where {T<:Vector{Float64}} if opts.save_start key, key_exists = save_start_init!(Y0, run, p, SOC) @@ -378,7 +378,7 @@ end Y_old .= Y_new Y_new .-= L\res - if norm(Y_old .- Y_new) < opts.reltol_init || maximum(abs, res) < opts.abstol_init + if norm(Y_old .- Y_new) < opts.reltol_init # || maximum(abs, res) < opts.abstol_init break elseif iter === itermax error("Could not initialize DAE in $itermax iterations.") diff --git a/src/outputs.jl b/src/outputs.jl index c196235..e31e856 100644 --- a/src/outputs.jl +++ b/src/outputs.jl @@ -21,6 +21,7 @@ Base.@kwdef struct model_states{vec1D,vec2D,R1} V::vec1D = ( vec1D === Array{Float64,1} ) ? Float64[] : nothing P::vec1D = ( vec1D === Array{Float64,1} ) ? Float64[] : nothing SOC::vec1D = ( vec1D === Array{Float64,1} ) ? Float64[] : nothing + SOH::vec1D = ( vec1D === Array{Float64,1} ) ? Float64[] : nothing # Culmination of all the runs results::R1 = R1 === Array{run_results,1} ? run_results[] : nothing end diff --git a/src/physics_equations/auxiliary_states_and_coefficients.jl b/src/physics_equations/auxiliary_states_and_coefficients.jl index 10a241a..60a4d30 100644 --- a/src/physics_equations/auxiliary_states_and_coefficients.jl +++ b/src/physics_equations/auxiliary_states_and_coefficients.jl @@ -74,8 +74,8 @@ function build_j_total!(states, p::AbstractParam) return nothing end -build_T!(states, p::AbstractParam{jac,true}) where {jac} = nothing -function build_T!(states, p::AbstractParam{jac,false}) where {jac} +build_T!(states, p::AbstractParamTemp{true}) = nothing +function build_T!(states, p::AbstractParamTemp{false}) """ If temperature is not enabled, include a vector of temperatures using the specified initial temperature. """ @@ -533,43 +533,105 @@ end end @inline function temperature_weighting(T::AbstractVector{<:Number},p::AbstractParam) - @views @inbounds ( - mean(T[1:p.N.a])*p.θ[:l_a]+ - mean(T[1:p.N.p .+ (p.N.a)])*p.θ[:l_p]+ - mean(T[1:p.N.s .+ (p.N.a+p.N.p)])*p.θ[:l_s]+ - mean(T[1:p.N.n .+ (p.N.a+p.N.p+p.N.s)])*p.θ[:l_n]+ - mean(T[1:p.N.z .+ (p.N.a+p.N.p+p.N.s+p.N.n)])*p.θ[:l_z] - )/(p.θ[:l_a]+p.θ[:l_p]+p.θ[:l_s]+p.θ[:l_n]+p.θ[:l_z]) + l_a,l_p,l_s,l_n,l_z = (p.θ[:l_a], p.θ[:l_p], p.θ[:l_s], p.θ[:l_n], p.θ[:l_z]) + + ratio_a = l_a/p.N.a + ratio_p = l_p/p.N.p + ratio_s = l_s/p.N.s + ratio_n = l_n/p.N.n + ratio_z = l_z/p.N.z + + T_mean = 0.0 + @inbounds for i in (1:p.N.a) + T_mean += T[i]*ratio_a + end + @inbounds for i in (1:p.N.p) .+ (p.N.a) + T_mean += T[i]*ratio_p + end + @inbounds for i in (1:p.N.s) .+ (p.N.a+p.N.p) + T_mean += T[i]*ratio_s + end + @inbounds for i in (1:p.N.n) .+ (p.N.a+p.N.p+p.N.s) + T_mean += T[i]*ratio_n + end + @inbounds for i in (1:p.N.z) .+ (p.N.a+p.N.p+p.N.s+p.N.n) + T_mean += T[i]*ratio_z + end + + return T_mean/(l_a+l_p+l_s+l_n+l_z) end @inline function constant_temperature(t,Y,YP::AbstractVector{<:Number},p::AbstractParam) temperature_weighting((@views @inbounds YP[p.ind.T]),p) end temperature_weighting(T::VectorOfArray,p::AbstractParam) = [temperature_weighting(_T,p) for _T in T] -calc_η_plating(Y::AbstractVector{<:Number},p::AbstractParam) = @views @inbounds Y[p.ind.Φ_s.n[1]] - Y[p.ind.Φ_e.n[1]] +export calc_η_plating +calc_η_plating(Y::Vector{<:Number},p::AbstractParam) = @views @inbounds Y[p.ind.Φ_s.n[1]] - Y[p.ind.Φ_e.n[1]] calc_η_plating(t,Y,YP,p) = calc_η_plating(Y,p) +export calc_OCV +function calc_OCV(Y::AbstractVector{<:Number}, p::AbstractParam) + """ + Calculate the open circuit voltages for the positive & negative electrodes + """ + p_indices = c_s_indices(p, :p; surf=true, offset=false) + n_indices = c_s_indices(p, :n; surf=true, offset=false) + + c_s_star_p = @views @inbounds Y[p_indices] + c_s_star_n = @views @inbounds Y[n_indices] + + T = calc_T(Y,p) + T_p = T[(1:p.N.p) .+ (p.N.a)] + T_n = T[(1:p.N.n) .+ (p.N.a+p.N.p+p.N.s)] + + # Put the surface concentration into a fraction + θ_p = c_s_star_p./p.θ[:c_max_p] + θ_n = c_s_star_n./p.θ[:c_max_n] + + # Compute the OCV for the positive & negative electrodes. + U_p = p.numerics.OCV_p(θ_p, T_p, p)[1] + U_n = p.numerics.OCV_n(θ_n, T_n, p)[1] + + return return U_p, U_n +end + +export calc_R_internal +function calc_R_internal(Y::AbstractVector{<:Number}, p::AbstractParam) + I = calc_I(Y,p)*calc_I1C(p) + V = calc_V(Y,p) + + U_p, U_n = calc_OCV(Y,p) + OCV = @inbounds U_p[1] - U_n[end] + + R_internal = abs((V - OCV)/I) + + return R_internal +end + +Base.broadcasted(f::typeof(calc_η_plating), Y::T, p::AbstractParam) where T<:PETLION.VectorOfArray{Float64, 2, Vector{Vector{Float64}}} = Float64[f(y,p) for y in Y] +Base.broadcasted(f::typeof(calc_R_internal), Y::T, p::AbstractParam) where T<:PETLION.VectorOfArray{Float64, 2, Vector{Vector{Float64}}} = Float64[f(y,p) for y in Y] + d_x(::Val{index}) where {index} = (t,Y,YP::AbstractVector{<:Number},p::AbstractParam) -> YP[index] d_x(index::Int64) = d_x(Val(index)) -function c_s_indices(p::AbstractParam{jac,temp,:Fickian},x...;kw...) where {jac,temp} +function c_s_indices(p::AbstractParamSolidDiff{:Fickian}, section::Symbol; surf::Bool=true,offset::Bool=true) N = p.N ind_p = N.r_p:N.r_p:N.r_p*N.p ind_n = N.r_n:N.r_n:N.r_n*N.n - return _c_s_indices(p,ind_p,ind_n,x...;kw...) + return _c_s_indices(p, ind_p, ind_n, section, surf, offset) end -function c_s_indices(p::Union{AbstractParam{jac,temp,:quadratic},AbstractParam{jac,temp,:polynomial}},x...;kw...) where {jac,temp} +function c_s_indices(p::Union{AbstractParamSolidDiff{:quadratic},AbstractParamSolidDiff{:polynomial}}, section::Symbol; surf::Bool=true,offset::Bool=true) N = p.N ind_p = 1:N.p ind_n = 1:N.n - return _c_s_indices(p,ind_p,ind_n,x...;kw...) + return _c_s_indices(p, ind_p, ind_n, section, surf, offset) end -function _c_s_indices(p::AbstractParam,ind_p::T,ind_n::T,section::Symbol;surf::Bool=true,offset::Bool=true) where T<:AbstractRange{Int64} +function _c_s_indices(p::AbstractParam,ind_p::T,ind_n::T,section::Symbol,surf::Bool,offset::Bool) where T<:AbstractRange{Int64} ind = p.ind.c_s_avg if section === :p diff --git a/src/physics_equations/residuals.jl b/src/physics_equations/residuals.jl index a769d1e..c6cbcc4 100644 --- a/src/physics_equations/residuals.jl +++ b/src/physics_equations/residuals.jl @@ -37,6 +37,7 @@ function residuals_PET!(residuals, t, x, ẋ, p::AbstractParam) # Lithium plating film thickness, film if p.numerics.aging === :SEI residuals_film!(res, states, ∂states, p) + residuals_SOH!(res, states, ∂states, p) end # Check if the thermal dynamics are enabled. @@ -204,7 +205,7 @@ function residuals_c_e!(res, states, ∂states, p::AbstractParam) return nothing end -function residuals_c_s_avg!(res, states, ∂states, p::Union{AbstractParam{jac,temp,:quadratic},AbstractParam{jac,temp,:polynomial}}) where {jac,temp} +function residuals_c_s_avg!(res, states, ∂states, p::Union{AbstractParamSolidDiff{:quadratic},AbstractParamSolidDiff{:polynomial}}) """ Calculate the solid particle concentrations residuals with quadratic or polynomial approximations [mol/m³] """ @@ -224,7 +225,7 @@ function residuals_c_s_avg!(res, states, ∂states, p::Union{AbstractParam{jac,t return nothing end -function residuals_c_s_avg!(res, states, ∂states, p::AbstractParam{jac,temp,:Fickian,:finite_difference}) where {jac,temp} +function residuals_c_s_avg!(res, states, ∂states, p::AbstractParamFickian{:finite_difference}) where {jac,temp} """ Calculate the volume-averaged solid particle concentration residuals using a 9th order accurate finite difference method (FDM) [mol/m³] """ @@ -278,7 +279,7 @@ function residuals_c_s_avg!(res, states, ∂states, p::AbstractParam{jac,temp,:F return nothing end -function residuals_c_s_avg!(res, states, ∂states, p::AbstractParam{jac,temp,:Fickian,:spectral}) where {jac,temp} +function residuals_c_s_avg!(res, states, ∂states, p::AbstractParamSolidDiff{:spectral}) """ Calculate the volume-averaged solid particle concentration residuals using a spectral method [mol/m³] """ @@ -335,7 +336,7 @@ function residuals_c_s_avg!(res, states, ∂states, p::AbstractParam{jac,temp,:F return nothing end -function residuals_Q!(res, states, ∂states, p::AbstractParam{jac,temp,:polynomial}) where {jac,temp} +function residuals_Q!(res, states, ∂states, p::AbstractParamSolidDiff{:polynomial}) """ residuals_Q! is used to implement the three parameters reduced model for solid phase diffusion [mol/m⁴] This model has been taken from the paper "Efficient Macro-Micro Scale Coupled @@ -378,6 +379,28 @@ function residuals_film!(res, states, ∂states, p::AbstractParam) return nothing end +function residuals_SOH!(res, states, ∂states, p::AbstractParam) + """ + residuals_SOH! integrates the SOH when aging is enabled and there are losses + """ + + j_s = states[:j_s] + I = states[:I][1]/calc_I1C(p) + + ∂SOH = ∂states[:SOH][1] + + res_SOH = res[:SOH] + + j_s_int = -trapz(extrapolate_section(j_s, p, :n)...) + j_s_int *= const_Faradays*surface_area_to_volume_ratio(p)[2]/(3600*calc_I1C(p.θ)) + + rhs_SOH = -j_s_int + + res_SOH .= rhs_SOH - ∂SOH + + return nothing +end + function residuals_T!(res, states, ∂states, p) """ Calculate the 1D temperature residuals [K] diff --git a/src/physics_equations/scalar_residual.jl b/src/physics_equations/scalar_residual.jl index 5f435f7..69bff7f 100644 --- a/src/physics_equations/scalar_residual.jl +++ b/src/physics_equations/scalar_residual.jl @@ -1,9 +1,9 @@ @inline calc_V(Y::Vector{<:Number}, p::AbstractParam) = @inbounds Y[p.ind.Φ_s[1]] - Y[p.ind.Φ_s[end]] @inline calc_I(Y::Vector{<:Number}, p::AbstractParam) = @inbounds Y[p.ind.I[1]] @inline calc_P(Y::Vector{<:Number}, p::AbstractParam) = calc_I(Y,p)*p.θ[:I1C]*calc_V(Y,p) -@inline calc_T(Y::Vector{<:Number}, p::AbstractParam) = @inbounds @views Y[p.ind.T] @inline calc_c_e(Y::Vector{<:Number}, p::AbstractParam) = @inbounds @views Y[p.ind.c_e] @inline calc_c_s_avg(Y::Vector{<:Number}, p::AbstractParam) = @inbounds @views Y[p.ind.c_s_avg] +@inline calc_SOH(Y::Vector{<:Number}, p::AbstractParam) = @inbounds @views Y[p.ind.SOH[1]] @inline calc_j(Y::Vector{<:Number}, p::AbstractParam) = @inbounds @views Y[p.ind.j] @inline calc_Φ_e(Y::Vector{<:Number}, p::AbstractParam) = @inbounds @views Y[p.ind.Φ_e] @inline calc_Φ_s(Y::Vector{<:Number}, p::AbstractParam) = @inbounds @views Y[p.ind.Φ_s] @@ -11,6 +11,9 @@ @inline calc_j_s(Y::Vector{<:Number}, p::AbstractParam) = @inbounds @views Y[p.ind.j_s] @inline calc_Q(Y::Vector{<:Number}, p::AbstractParam) = @inbounds @views Y[p.ind.Q] +@inline calc_T(Y::Vector{<:Number}, p::AbstractParamTemp{true}) = @inbounds @views Y[p.ind.T] +@inline calc_T(::Vector{<:Number}, p::AbstractParamTemp{false}) = repeat([p.θ[:T₀]], p.N.a+p.N.p+p.N.s+p.N.n+p.N.z) + @inline method_I(Y, p) = calc_I(Y,p) @inline method_V(Y, p) = calc_V(Y,p) @inline method_P(Y, p) = calc_P(Y,p) @@ -226,7 +229,7 @@ function truncated_res_diff(p::AbstractParam,ind_differential) ind = PETLION.find_next(str, ind[1], out_char(i)) ind_last = PETLION.find_next(str, ind[end], '\n') if i ∈ ind_differential - # skip this one + # keep this line and skip over it ind = ind_last[end] else deleteat!(str, ind[1]:ind_last[end]) diff --git a/src/set_variables.jl b/src/set_variables.jl index 4722dd2..8134124 100644 --- a/src/set_variables.jl +++ b/src/set_variables.jl @@ -45,23 +45,25 @@ # exist as an optional output if the model uses them if ( p.numerics.temperature === true && keep.T ) modify!(model.T, calc_T(Y,p) ) end if ( p.numerics.aging === :SEI && keep.film ) modify!(model.film, calc_film(Y,p) ) end + if ( p.numerics.aging === :SEI && keep.SOH ) modify!(model.SOH, calc_SOH(Y, p) ) end if ( !(p.numerics.aging === false) && keep.j_s ) modify!(model.j_s, calc_j_s(Y,p) ) end if ( p.numerics.solid_diffusion === :quadratic && keep.Q ) modify!(model.Q, calc_Q(Y,p) ) end return nothing end -@inline function set_var!(x::T1, x_val::T2, append::Bool=true) where {T1<:Vector{Float64},T2<:Float64} - append ? push!(x, x_val) : (@inbounds x[1] = x_val) +@inline set_var!(x, x_val) = push!(x, x_val) +@inline function set_var!(x::T1, x_val::T2, keep::Bool) where {T1<:Vector{Float64},T2<:Float64} + keep ? push!(x, x_val) : (@inbounds x[1] = x_val) end -@inline function set_var!(x::T1, x_val::T2, append::Bool=true) where {T1<:VectorOfArray{Float64,2,Array{Array{Float64,1},1}},T2<:AbstractVector{Float64}} - append ? push!(x, x_val) : (@inbounds x[1] .= x_val) +@inline function set_var!(x::T1, x_val::T2, keep::Bool) where {T1<:VectorOfArray{Float64,2,Array{Array{Float64,1},1}},T2<:AbstractVector{Float64}} + keep ? push!(x, x_val) : (@inbounds x[1] .= x_val) end -@inline function set_var_last!(x::T1, x_val::T2, append=true) where {T1<:Vector{Float64},T2<:Float64} +@inline function set_var_last!(x::T1, x_val::T2, keep=true) where {T1<:Vector{Float64},T2<:Float64} @inbounds x[end] = x_val end -@inline function set_var_last!(x::T1, x_val::T2, append=true) where {T1<:VectorOfArray{Float64,2,Array{Array{Float64,1},1}},T2<:AbstractVector{Float64}} +@inline function set_var_last!(x::T1, x_val::T2, keep=true) where {T1<:VectorOfArray{Float64,2,Array{Array{Float64,1},1}},T2<:AbstractVector{Float64}} @inbounds x[end] .= x_val end diff --git a/src/structures.jl b/src/structures.jl index ac0294a..9f850c8 100644 --- a/src/structures.jl +++ b/src/structures.jl @@ -11,15 +11,6 @@ struct method_I <: AbstractMethod end struct method_V <: AbstractMethod end struct method_P <: AbstractMethod end -struct _discretizations_per_section - p::Int64 - s::Int64 - n::Int64 - a::Int64 - z::Int64 - r_p::Int64 - r_n::Int64 -end struct discretizations_per_section p::Int64 s::Int64 @@ -32,6 +23,7 @@ struct discretizations_per_section alg::Int64 tot::Int64 end +discretizations_per_section(p,s,n,a,z,r_p,r_n) = discretizations_per_section(p,s,n,a,z,r_p,r_n,-1,-1,-1) Base.@kwdef mutable struct run_info exit_reason::String = "" @@ -222,13 +214,13 @@ end options_numerical(temp,solid_diff,Fickian,age,x...) = options_numerical{temp,solid_diff,Fickian,age}(temp,solid_diff,Fickian,age,x...) -states_logic = model_states{ +const states_logic = model_states{ Bool, Bool, Tuple } -indices_states = model_states{ +const indices_states = model_states{ index_state, index_state, Nothing, @@ -303,6 +295,18 @@ struct param{T<:AbstractJacobian,temp,solid_diff,Fickian,age} <: AbstractParam{T funcs::model_funcs{<:Function,<:Function,<:Function,T,<:AbstractJacobian} end +const param_jac{jac} = param{jac,<:Any,<:Any,<:Any,<:Any} +const param_temp{temp} = param{<:AbstractJacobian,temp,<:Any,<:Any,<:Any} +const param_solid_diff{solid_diff} = param{<:AbstractJacobian,<:Any,solid_diff,<:Any,<:Any} +const param_Fickian{Fickian} = param{<:AbstractJacobian,<:Any,<:Any,Fickian,<:Any} +const param_age{age} = param{<:AbstractJacobian,<:Any,<:Any,<:Any,age} + +const AbstractParamJac{jac} = AbstractParam{jac,<:Any,<:Any,<:Any,<:Any} +const AbstractParamTemp{temp} = AbstractParam{<:AbstractJacobian,temp,<:Any,<:Any,<:Any} +const AbstractParamSolidDiff{solid_diff} = AbstractParam{<:AbstractJacobian,<:Any,solid_diff,<:Any,<:Any} +const AbstractParamFickian{Fickian} = AbstractParam{<:AbstractJacobian,<:Any,<:Any,Fickian,<:Any} +const AbstractParamAge{age} = AbstractParam{<:AbstractJacobian,<:Any,<:Any,<:Any,age} + struct param_skeleton{temp,solid_diff,Fickian,age} <: AbstractParam{AbstractJacobian,temp,solid_diff,Fickian,age} θ::Dict{Symbol,Any} numerics::options_numerical{temp,solid_diff,Fickian,age} @@ -326,7 +330,7 @@ struct run_results{T<:AbstractRun} p::param end -model_output = model_states{ +const model_output = model_states{ Array{Float64,1}, VectorOfArray{Float64,2,Array{Array{Float64,1},1}}, Array{run_results,1}, From fdc7129f0398b7c90b319c0123df6b41f83b9f36 Mon Sep 17 00:00:00 2001 From: Marc Berliner Date: Tue, 5 Oct 2021 15:12:54 -0400 Subject: [PATCH 2/5] fix file name --- Project.toml | 1 + src/PETLION.jl | 1 + src/external.jl | 46 +++++++++++++++++++++++++++++++-------- src/generate_functions.jl | 11 +++++++++- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/Project.toml b/Project.toml index d326f37..c3a2466 100644 --- a/Project.toml +++ b/Project.toml @@ -11,6 +11,7 @@ IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd" +SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce" SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804" diff --git a/src/PETLION.jl b/src/PETLION.jl index 9dce78d..3854bd0 100644 --- a/src/PETLION.jl +++ b/src/PETLION.jl @@ -11,6 +11,7 @@ using RecursiveArrayTools: VectorOfArray using Symbolics: @variables, Num, gradient, jacobian_sparsity, expand_derivatives, Differential, get_variables, sparsejacobian, substitute, simplify, build_function, IfElse using RecipesBase using SpecialFunctions: erf +using SHA: sha1 import Sundials import LinearAlgebra diff --git a/src/external.jl b/src/external.jl index 4ea8312..f0b33f0 100644 --- a/src/external.jl +++ b/src/external.jl @@ -389,9 +389,31 @@ end return Y0, YP0 end -function strings_directory_func(N::discretizations_per_section, numerics::numerical; create_dir=false) where numerical<:options_numerical +model_info(p::AbstractParam) = model_info(p.N, p.numerics) +function model_info(N::T1,numerics::T2) where {T1<:discretizations_per_section,T2<:options_numerical} + version = "PETLION version: v"*join(Symbol.(PETLION.PETLION_VERSION),".") + + numerical = ["$field: $(getproperty(numerics,field))" for field in fieldnames(T2)] + + discretization = [ + "N.p: $(N.p)"; + "N.s: $(N.s)"; + "N.n: $(N.n)"; + numerics.temperature ? "N.a: $(N.a)\nN.z: $(N.z)" : ""; + numerics.solid_diffusion === :Fickian ? "N.r_p: $(N.r_p)\nN.r_n: $(N.r_n)" : ""; + ] + filter!(!isempty,discretization) + + str = version * "\n"^2 + str *= "options_numerical\n" * join(numerical, "\n") * "\n"^2 + str *= "discretizations_per_section\n" * join(discretization, "\n") + + return str +end + +function strings_directory_func(N::discretizations_per_section, numerics::T; create_dir=false) where T<:options_numerical - dir_saved_models = "saved_models" + dir_saved_models = joinpath(options[:FILE_DIRECTORY], "saved_models") if create_dir && !isdir(dir_saved_models) mkdir(dir_saved_models) @@ -401,7 +423,7 @@ function strings_directory_func(N::discretizations_per_section, numerics::numeri str = join( [ - ["$(getproperty(numerics,field))" for field in filter(x->!(x ∈ (:cathode,:anode)), fieldnames(numerical))]; + ["$(getproperty(numerics,field))" for field in filter(x->!(x ∈ (:cathode,:anode)), fieldnames(T))]; "Np$(N.p)"; "Ns$(N.s)"; "Nn$(N.n)"; @@ -411,12 +433,18 @@ function strings_directory_func(N::discretizations_per_section, numerics::numeri "_" ) - dir = "$dir_cell/$str" + str = Base.bytes2hex(sha1(str)) - if create_dir && !isdir(dir_saved_models) mkdir(dir_saved_models) end - if create_dir && !isdir(dir_cell) mkdir(dir_cell) end - if create_dir && !isdir(dir) mkdir(dir) end + dir = "$dir_cell/$str" + if create_dir + for x in (dir_saved_models, dir_cell, dir) + if !isdir(x) + mkdir(x) + end + end + end + return dir end @@ -424,8 +452,8 @@ function strings_directory_func(p::AbstractParam; create_dir=false) strings_directory_func(p.N, p.numerics; create_dir=create_dir) end -function strings_directory_func(p::AbstractParam, x; create_dir=false) - strings_directory = string("$(strings_directory_func(p; create_dir=create_dir))/$x.jl") +function strings_directory_func(p::AbstractParam, x; kw...) + strings_directory = string("$(strings_directory_func(p; kw...))/$x.jl") return strings_directory end diff --git a/src/generate_functions.jl b/src/generate_functions.jl index 1352225..c1735d3 100644 --- a/src/generate_functions.jl +++ b/src/generate_functions.jl @@ -1,5 +1,7 @@ -options = Dict{Symbol,Bool}( +const PETLION_VERSION = (0,1,5) +const options = Dict{Symbol,Any}( :SAVE_SYMBOLIC_FUNCTIONS => true, + :FILE_DIRECTORY => pwd(), ) function load_functions(p::AbstractParam) @@ -88,6 +90,13 @@ function generate_functions_symbolic(p::AbstractParam; verbose=options[:SAVE_SYM if options[:SAVE_SYMBOLIC_FUNCTIONS] dir = strings_directory_func(p; create_dir=true) * "/" + + ## file info + str = model_info(p) + + open(dir * "info.txt", "w") do f + write(f, str) + end save_string(x) = (string(x) |> remove_comments |> rearrange_if_statements |> join) From 0f8694bc081f4a09e59b348e03bf2fafa3006323 Mon Sep 17 00:00:00 2001 From: Marc Berliner Date: Tue, 5 Oct 2021 15:50:03 -0400 Subject: [PATCH 3/5] Update params.jl --- src/params.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/params.jl b/src/params.jl index e4421e5..5007dcc 100644 --- a/src/params.jl +++ b/src/params.jl @@ -281,7 +281,7 @@ function system_LCO_LiC6(θ, funcs, cathode, anode; #### DO NOT MODIFY BELOW ### - N = discretizations_per_section(N_p, N_s, N_n, N_a, N_z, N_r_p, N_r_n, -1, -1, -1) + N = discretizations_per_section(N_p, N_s, N_n, N_a, N_z, N_r_p, N_r_n) numerics = options_numerical(temperature, solid_diffusion, Fickian_method, aging, cathode, anode, rxn_p, rxn_n, OCV_p, OCV_n, D_s_eff, rxn_rate, D_eff, K_eff, thermodynamic_factor, jacobian) return θ, bounds, opts, N, numerics @@ -498,7 +498,7 @@ function system_NMC_LiC6(θ, funcs, cathode, anode; #### DO NOT MODIFY BELOW ### - N = discretizations_per_section(N_p, N_s, N_n, N_a, N_z, N_r_p, N_r_n, -1, -1, -1) + N = discretizations_per_section(N_p, N_s, N_n, N_a, N_z, N_r_p, N_r_n) numerics = options_numerical(temperature, solid_diffusion, Fickian_method, aging, cathode, anode, rxn_p, rxn_n, OCV_p, OCV_n, D_s_eff, rxn_rate, D_eff, K_eff, thermodynamic_factor, jacobian) return θ, bounds, opts, N, numerics From 0aada1e1ba9b589c2f64636e6c684995dce6aa96 Mon Sep 17 00:00:00 2001 From: Marc Berliner Date: Tue, 5 Oct 2021 16:01:45 -0400 Subject: [PATCH 4/5] changed version --- Manifest.toml | 256 +++++++++++++++++++++++--------------- Project.toml | 2 +- src/generate_functions.jl | 2 +- 3 files changed, 157 insertions(+), 103 deletions(-) diff --git a/Manifest.toml b/Manifest.toml index c1616d3..2af964a 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -21,10 +21,10 @@ uuid = "ec485272-7323-5ecc-a04f-4719b315124d" version = "0.1.0" [[ArrayInterface]] -deps = ["IfElse", "LinearAlgebra", "Requires", "SparseArrays", "Static"] -git-tree-sha1 = "cdb00a6fb50762255021e5571cf95df3e1797a51" +deps = ["Compat", "IfElse", "LinearAlgebra", "Requires", "SparseArrays", "Static"] +git-tree-sha1 = "b8d49c34c3da35f220e7295659cd0bab8e739fed" uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" -version = "3.1.23" +version = "3.1.33" [[Artifacts]] uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" @@ -37,22 +37,39 @@ version = "0.3.3" [[Base64]] uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" +[[Bijections]] +git-tree-sha1 = "705e7822597b432ebe152baa844b49f8026df090" +uuid = "e2ed5e7c-b2de-5872-ae92-c73ca462fb04" +version = "0.1.3" + +[[BitTwiddlingConvenienceFunctions]] +deps = ["Static"] +git-tree-sha1 = "652aab0fc0d6d4db4cc726425cadf700e9f473f1" +uuid = "62783981-4cbd-42fc-bca8-16325de8dc4b" +version = "0.1.0" + [[CEnum]] git-tree-sha1 = "215a9aa4a1f23fbd05b92769fdd62559488d70e9" uuid = "fa961155-64e5-5f13-b03f-caf6b980ea82" version = "0.4.1" +[[CPUSummary]] +deps = ["Hwloc", "IfElse", "Static"] +git-tree-sha1 = "38d0941d2ce6dd96427fd033d45471e1f26c3865" +uuid = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9" +version = "0.1.5" + [[ChainRulesCore]] deps = ["Compat", "LinearAlgebra", "SparseArrays"] -git-tree-sha1 = "bdc0937269321858ab2a4f288486cb258b9a0af7" +git-tree-sha1 = "a325370b9dd0e6bf5656a6f1a7ae80755f8ccc46" uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" -version = "1.3.0" +version = "1.7.2" [[CloseOpenIntervals]] deps = ["ArrayInterface", "Static"] -git-tree-sha1 = "4fcacb5811c9e4eb6f9adde4afc0e9c4a7a92f5a" +git-tree-sha1 = "ce9c0d07ed6e1a4fecd2df6ace144cbd29ba6f37" uuid = "fb6a15b2-703c-40df-9091-08a04967cfa9" -version = "0.1.1" +version = "0.1.2" [[Combinatorics]] git-tree-sha1 = "08c8b6831dc00bfea825826be0bc8336fc369860" @@ -72,9 +89,9 @@ version = "0.3.0" [[Compat]] deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] -git-tree-sha1 = "344f143fa0ec67e47917848795ab19c6a455f32c" +git-tree-sha1 = "31d0151f5716b655421d9d75b7fa74cc4e744df2" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "3.32.0" +version = "3.39.0" [[CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] @@ -98,9 +115,9 @@ uuid = "754358af-613d-5f8d-9788-280bf1605d4c" version = "0.2.0" [[DataAPI]] -git-tree-sha1 = "ee400abb2298bd13bfc3df1c412ed228061a2385" +git-tree-sha1 = "cc70b17275652eb47bc9e5f81635981f13cea5c8" uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" -version = "1.7.0" +version = "1.9.0" [[DataStructures]] deps = ["Compat", "InteractiveUtils", "OrderedCollections"] @@ -135,9 +152,9 @@ version = "0.0.1+0" [[DiffEqBase]] deps = ["ArrayInterface", "ChainRulesCore", "DEDataArrays", "DataStructures", "Distributions", "DocStringExtensions", "FastBroadcast", "ForwardDiff", "FunctionWrappers", "IterativeSolvers", "LabelledArrays", "LinearAlgebra", "Logging", "MuladdMacro", "NonlinearSolve", "Parameters", "PreallocationTools", "Printf", "RecursiveArrayTools", "RecursiveFactorization", "Reexport", "Requires", "SciMLBase", "Setfield", "SparseArrays", "StaticArrays", "Statistics", "SuiteSparse", "ZygoteRules"] -git-tree-sha1 = "8d703accf0f334cf8eaf0237875d7d69848861cf" +git-tree-sha1 = "420ad175d5e420e2c55a0ed8a9c18556e6735f80" uuid = "2b5f629d-d688-5b77-993f-72d75c75574e" -version = "6.72.0" +version = "6.73.2" [[DiffResults]] deps = ["StaticArrays"] @@ -147,19 +164,19 @@ version = "1.0.3" [[DiffRules]] deps = ["NaNMath", "Random", "SpecialFunctions"] -git-tree-sha1 = "85d2d9e2524da988bffaf2a381864e20d2dae08d" +git-tree-sha1 = "7220bc21c33e990c14f4a9a319b1d242ebc5b269" uuid = "b552c78f-8df3-52c6-915a-8e097449b14b" -version = "1.2.1" +version = "1.3.1" [[Distributed]] deps = ["Random", "Serialization", "Sockets"] uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" [[Distributions]] -deps = ["FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SparseArrays", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns"] -git-tree-sha1 = "3889f646423ce91dd1055a76317e9a1d3a23fff1" +deps = ["ChainRulesCore", "FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SparseArrays", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns"] +git-tree-sha1 = "ff7890c74e2eaffbc0b3741811e3816e64b6343d" uuid = "31c24e10-a181-5473-b8eb-7969acd0382f" -version = "0.25.11" +version = "0.25.18" [[DocStringExtensions]] deps = ["LibGit2"] @@ -168,10 +185,10 @@ uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" version = "0.8.5" [[DomainSets]] -deps = ["CompositeTypes", "IntervalSets", "LinearAlgebra", "StaticArrays", "Statistics", "Test"] -git-tree-sha1 = "6cdd99d0b7b555f96f7cb05aa82067ee79e7aef4" +deps = ["CompositeTypes", "IntervalSets", "LinearAlgebra", "StaticArrays", "Statistics"] +git-tree-sha1 = "627844a59d3970db8082b778e53f86741d17aaad" uuid = "5b8099bc-c8ec-5219-889f-1d9e522a28bf" -version = "0.5.2" +version = "0.5.7" [[Downloads]] deps = ["ArgTools", "LibCURL", "NetworkOptions"] @@ -179,9 +196,9 @@ uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" [[DynamicPolynomials]] deps = ["DataStructures", "Future", "LinearAlgebra", "MultivariatePolynomials", "MutableArithmetics", "Pkg", "Reexport", "Test"] -git-tree-sha1 = "e9d82a6f35d199d3821c069932115e19ca2a2b3d" +git-tree-sha1 = "1b4665a7e303eaa7e03542cfaef0730cb056cb00" uuid = "7c1d4256-1411-5781-91ec-d7bc3513ac07" -version = "0.3.19" +version = "0.3.21" [[EllipsisNotation]] deps = ["ArrayInterface"] @@ -202,9 +219,9 @@ version = "0.1.8" [[FillArrays]] deps = ["LinearAlgebra", "Random", "SparseArrays", "Statistics"] -git-tree-sha1 = "8c8eac2af06ce35973c3eadb4ab3243076a408e7" +git-tree-sha1 = "29890dfbc427afa59598b8cfcc10034719bd7744" uuid = "1a297f60-69ca-5386-bcde-b61e274b549b" -version = "0.12.1" +version = "0.12.6" [[FiniteDiff]] deps = ["ArrayInterface", "LinearAlgebra", "Requires", "SparseArrays", "StaticArrays"] @@ -220,9 +237,9 @@ version = "0.4.2" [[ForwardDiff]] deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "LinearAlgebra", "NaNMath", "Printf", "Random", "SpecialFunctions", "StaticArrays"] -git-tree-sha1 = "b5e930ac60b613ef3406da6d4f42c35d8dc51419" +git-tree-sha1 = "c4203b60d37059462af370c4f3108fb5d155ff13" uuid = "f6369f11-7733-5829-9624-2563aa707210" -version = "0.10.19" +version = "0.10.20" [[FunctionWrappers]] git-tree-sha1 = "241552bc2209f0fa068b6415b1942cc0aa486bcc" @@ -239,6 +256,12 @@ git-tree-sha1 = "dd95197f27ebf3268dfe7401f982e0ede98cea51" uuid = "6b9d7cbe-bcb9-11e9-073f-15a7a543e2eb" version = "0.3.2" +[[HostCPUFeatures]] +deps = ["BitTwiddlingConvenienceFunctions", "IfElse", "Libdl", "Static"] +git-tree-sha1 = "3169c8b31863f9a409be1d17693751314241e3eb" +uuid = "3e5b6fbb-0976-4d2c-9146-d79de83f2fb0" +version = "0.1.4" + [[Hwloc]] deps = ["Hwloc_jll"] git-tree-sha1 = "92d99146066c5c6888d5a3abc871e6a214388b91" @@ -271,6 +294,11 @@ git-tree-sha1 = "3cc368af3f110a767ac786560045dceddfc16758" uuid = "8197267c-284f-5f27-9208-e0e47529a953" version = "0.5.3" +[[IrrationalConstants]] +git-tree-sha1 = "f76424439413893a832026ca355fe273e93bce94" +uuid = "92d709cd-6900-40b7-9082-c6be49f344b6" +version = "0.1.0" + [[IterativeSolvers]] deps = ["LinearAlgebra", "Printf", "Random", "RecipesBase", "SparseArrays"] git-tree-sha1 = "1a8c6237e78b714e901e406c096fc8a65528af7d" @@ -301,9 +329,9 @@ version = "1.2.1" [[LabelledArrays]] deps = ["ArrayInterface", "LinearAlgebra", "MacroTools", "StaticArrays"] -git-tree-sha1 = "bdde43e002847c34c206735b1cf860bc3abd35e7" +git-tree-sha1 = "8f5fd068dfee92655b79e0859ecad8b492dfe8b1" uuid = "2ee39098-c373-598a-b85f-a56591580800" -version = "1.6.4" +version = "1.6.5" [[Latexify]] deps = ["Formatting", "InteractiveUtils", "LaTeXStrings", "MacroTools", "Markdown", "Printf", "Requires"] @@ -311,6 +339,12 @@ git-tree-sha1 = "a4b12a1bd2ebade87891ab7e36fdbce582301a92" uuid = "23fbe1c1-3f47-55db-b15f-69d7ec21a316" version = "0.15.6" +[[LayoutPointers]] +deps = ["ArrayInterface", "LinearAlgebra", "ManualMemory", "SIMDTypes", "Static"] +git-tree-sha1 = "d2bda6aa0b03ce6f141a2dc73d0bcb7070131adc" +uuid = "10f19ff3-798f-405d-979b-55457f8fc047" +version = "0.1.3" + [[LibCURL]] deps = ["LibCURL_jll", "MozillaCACerts_jll"] uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" @@ -341,19 +375,19 @@ deps = ["Libdl"] uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" [[LogExpFunctions]] -deps = ["DocStringExtensions", "LinearAlgebra"] -git-tree-sha1 = "7bd5f6565d80b6bf753738d2bc40a5dfea072070" +deps = ["ChainRulesCore", "DocStringExtensions", "IrrationalConstants", "LinearAlgebra"] +git-tree-sha1 = "34dc30f868e368f8a17b728a1238f3fcda43931a" uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688" -version = "0.2.5" +version = "0.3.3" [[Logging]] uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" [[LoopVectorization]] -deps = ["ArrayInterface", "DocStringExtensions", "IfElse", "LinearAlgebra", "OffsetArrays", "Polyester", "Requires", "SLEEFPirates", "Static", "StrideArraysCore", "ThreadingUtilities", "UnPack", "VectorizationBase"] -git-tree-sha1 = "6643933c619b292cb1fe566f5a411dddddec3db9" +deps = ["ArrayInterface", "CPUSummary", "CloseOpenIntervals", "DocStringExtensions", "HostCPUFeatures", "IfElse", "LayoutPointers", "LinearAlgebra", "OffsetArrays", "PolyesterWeave", "Requires", "SLEEFPirates", "Static", "ThreadingUtilities", "UnPack", "VectorizationBase"] +git-tree-sha1 = "c2c1a765d943267ffc01fd6a127fcb482e80f63a" uuid = "bdcacae8-1622-11e9-2a5c-532679323890" -version = "0.12.63" +version = "0.12.82" [[MLStyle]] git-tree-sha1 = "594e189325f66e23a8818e5beb11c43bb0141bcd" @@ -362,9 +396,9 @@ version = "0.4.10" [[MacroTools]] deps = ["Markdown", "Random"] -git-tree-sha1 = "0fb723cd8c45858c22169b2e42269e53271a6df7" +git-tree-sha1 = "5a5bc6bf062f0f95e62d0fe0a2d99699fed82dd9" uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" -version = "0.5.7" +version = "0.5.8" [[ManualMemory]] git-tree-sha1 = "9cb207b18148b2199db259adfa923b45593fe08e" @@ -381,9 +415,9 @@ uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" [[Missings]] deps = ["DataAPI"] -git-tree-sha1 = "4ea90bd5d3985ae1f9a908bd4500ae88921c5ce7" +git-tree-sha1 = "bf210ce90b6c9eed32d25dbcae1ebc565df2687f" uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28" -version = "1.0.0" +version = "1.0.2" [[Mmap]] uuid = "a63ad114-7e13-5084-954f-fe012c677804" @@ -424,20 +458,24 @@ uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" [[NonlinearSolve]] deps = ["ArrayInterface", "FiniteDiff", "ForwardDiff", "IterativeSolvers", "LinearAlgebra", "RecursiveArrayTools", "RecursiveFactorization", "Reexport", "SciMLBase", "Setfield", "StaticArrays", "UnPack"] -git-tree-sha1 = "f2530482ef6447c8ae24c660914436f1ae3917e0" +git-tree-sha1 = "e9ffc92217b8709e0cf7b8808f6223a4a0936c95" uuid = "8913a72c-1f9b-4ce2-8d82-65094dcecaec" -version = "0.3.9" +version = "0.3.11" [[OffsetArrays]] deps = ["Adapt"] -git-tree-sha1 = "c0f4a4836e5f3e0763243b8324200af6d0e0f90c" +git-tree-sha1 = "c0e9e582987d36d5a61e650e6e543b9e44d9914b" uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" -version = "1.10.5" +version = "1.10.7" [[OpenBLAS_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" +[[OpenLibm_jll]] +deps = ["Artifacts", "Libdl"] +uuid = "05823500-19ac-5b8b-9628-191a04bc5112" + [[OpenSpecFun_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] git-tree-sha1 = "13652491f6856acfd2db29360e1bbcd4565d04f1" @@ -457,25 +495,31 @@ version = "0.11.1" [[Parameters]] deps = ["OrderedCollections", "UnPack"] -git-tree-sha1 = "2276ac65f1e236e0a6ea70baff3f62ad4c625345" +git-tree-sha1 = "34c0e9ad262e5f7fc75b10a9952ca7692cfc5fbe" uuid = "d96e819e-fc66-5662-9728-84c9c7592b0a" -version = "0.12.2" +version = "0.12.3" [[Pkg]] deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" [[Polyester]] -deps = ["ArrayInterface", "IfElse", "ManualMemory", "Requires", "Static", "StrideArraysCore", "ThreadingUtilities", "VectorizationBase"] -git-tree-sha1 = "81c59c2bed8c8a76843411ddb33e548bf2bcc9b2" +deps = ["ArrayInterface", "BitTwiddlingConvenienceFunctions", "CPUSummary", "IfElse", "ManualMemory", "PolyesterWeave", "Requires", "Static", "StrideArraysCore", "ThreadingUtilities"] +git-tree-sha1 = "97794179584fbb0336821d6c03c93682f19803bf" uuid = "f517fe37-dbe3-4b94-8317-1923a5111588" -version = "0.3.8" +version = "0.5.3" + +[[PolyesterWeave]] +deps = ["BitTwiddlingConvenienceFunctions", "CPUSummary", "IfElse", "Static", "ThreadingUtilities"] +git-tree-sha1 = "371a19bb801c1b420b29141750f3a34d6c6634b9" +uuid = "1d0040c9-8b98-4ee7-8388-3f51789ca0ad" +version = "0.1.0" [[PreallocationTools]] deps = ["ArrayInterface", "ForwardDiff", "LabelledArrays"] -git-tree-sha1 = "9e917b108c4aaf47e8606542325bd2ccbcac7ca4" +git-tree-sha1 = "361c1f60ffdeeddf02f36b463ab8b138194e5f25" uuid = "d236fae5-4411-538c-8e31-a6e3d9e00b46" -version = "0.1.0" +version = "0.1.1" [[Preferences]] deps = ["TOML"] @@ -494,9 +538,9 @@ uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" [[QuadGK]] deps = ["DataStructures", "LinearAlgebra"] -git-tree-sha1 = "12fbe86da16df6679be7521dfb39fbc861e1dc7b" +git-tree-sha1 = "78aadffb3efd2155af139781b8a8df1ef279ea39" uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" -version = "2.4.1" +version = "2.4.2" [[REPL]] deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] @@ -507,26 +551,26 @@ deps = ["Serialization"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [[RecipesBase]] -git-tree-sha1 = "b3fb709f3c97bfc6e948be68beeecb55a0b340ae" +git-tree-sha1 = "44a75aa7a527910ee3d1751d1f0e4148698add9e" uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" -version = "1.1.1" +version = "1.1.2" [[RecursiveArrayTools]] -deps = ["ArrayInterface", "ChainRulesCore", "DocStringExtensions", "LinearAlgebra", "RecipesBase", "Requires", "StaticArrays", "Statistics", "ZygoteRules"] -git-tree-sha1 = "6cf3169ab34096657b79ea7d26f64ad79b3a5ea7" +deps = ["ArrayInterface", "ChainRulesCore", "DocStringExtensions", "FillArrays", "LinearAlgebra", "RecipesBase", "Requires", "StaticArrays", "Statistics", "ZygoteRules"] +git-tree-sha1 = "ff7495c78a192ff7d59531d9f14db300c847a4bc" uuid = "731186ca-8d62-57ce-b412-fbd966d074cd" -version = "2.17.0" +version = "2.19.1" [[RecursiveFactorization]] deps = ["LinearAlgebra", "LoopVectorization", "Polyester", "StrideArraysCore", "TriangularSolve"] -git-tree-sha1 = "9ac54089f52b0d0c37bebca35b9505720013a108" +git-tree-sha1 = "575c18c6b00ce409f75d96fefe33ebe01575457a" uuid = "f2c3362d-daeb-58d1-803e-2bc74f2840b4" -version = "0.2.2" +version = "0.2.4" [[Reexport]] -git-tree-sha1 = "5f6c21241f0f655da3952fd60aa18477cf96c220" +git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" uuid = "189a3867-3050-52da-a836-e630ba90ab69" -version = "1.1.0" +version = "1.2.2" [[Requires]] deps = ["UUIDs"] @@ -555,17 +599,22 @@ version = "0.5.3" [[SHA]] uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" +[[SIMDTypes]] +git-tree-sha1 = "330289636fb8107c5f32088d2741e9fd7a061a5c" +uuid = "94e857df-77ce-4151-89e5-788b33177be4" +version = "0.1.0" + [[SLEEFPirates]] deps = ["IfElse", "Static", "VectorizationBase"] -git-tree-sha1 = "bfdf9532c33db35d2ce9df4828330f0e92344a52" +git-tree-sha1 = "2e8150c7d2a14ac68537c7aac25faa6577aff046" uuid = "476501e8-09a2-5ece-8869-fb82de89a1fa" -version = "0.6.25" +version = "0.6.27" [[SciMLBase]] deps = ["ArrayInterface", "CommonSolve", "ConstructionBase", "Distributed", "DocStringExtensions", "IteratorInterfaceExtensions", "LinearAlgebra", "Logging", "RecipesBase", "RecursiveArrayTools", "StaticArrays", "Statistics", "Tables", "TreeViews"] -git-tree-sha1 = "f4bcc1bc78857e0602de2ec548b08ac73bf29acc" +git-tree-sha1 = "91e29a2bb257a4b992c48f35084064578b87d364" uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462" -version = "1.18.4" +version = "1.19.0" [[Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" @@ -601,27 +650,27 @@ uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [[SparseDiffTools]] deps = ["Adapt", "ArrayInterface", "Compat", "DataStructures", "FiniteDiff", "ForwardDiff", "LightGraphs", "LinearAlgebra", "Requires", "SparseArrays", "StaticArrays", "VertexSafeGraphs"] -git-tree-sha1 = "083ad77eeb56e40fd662373f4ba3302a4d90f77f" +git-tree-sha1 = "36a4d27a02af48a1eafd2baff58b32deeeb68926" uuid = "47a9eef4-7e08-11e9-0b38-333d64bd3804" -version = "1.16.3" +version = "1.16.5" [[SpecialFunctions]] -deps = ["ChainRulesCore", "LogExpFunctions", "OpenSpecFun_jll"] -git-tree-sha1 = "a322a9493e49c5f3a10b50df3aedaf1cdb3244b7" +deps = ["ChainRulesCore", "IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"] +git-tree-sha1 = "793793f1df98e3d7d554b65a107e9c9a6399a6ed" uuid = "276daf66-3868-5448-9aa4-cd146d93841b" -version = "1.6.1" +version = "1.7.0" [[Static]] deps = ["IfElse"] -git-tree-sha1 = "62701892d172a2fa41a1f829f66d2b0db94a9a63" +git-tree-sha1 = "a8f30abc7c64a39d389680b74e749cf33f872a70" uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3" -version = "0.3.0" +version = "0.3.3" [[StaticArrays]] deps = ["LinearAlgebra", "Random", "Statistics"] -git-tree-sha1 = "3240808c6d463ac46f1c1cd7638375cd22abbccb" +git-tree-sha1 = "3c76dde64d03699e074ac02eb2e8ba8254d428da" uuid = "90137ffa-7385-5640-81b9-e52037218182" -version = "1.2.12" +version = "1.2.13" [[Statistics]] deps = ["LinearAlgebra", "SparseArrays"] @@ -634,21 +683,21 @@ version = "1.0.0" [[StatsBase]] deps = ["DataAPI", "DataStructures", "LinearAlgebra", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"] -git-tree-sha1 = "fed1ec1e65749c4d96fc20dd13bea72b55457e62" +git-tree-sha1 = "8cbbc098554648c84f79a463c9ff0fd277144b6c" uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" -version = "0.33.9" +version = "0.33.10" [[StatsFuns]] -deps = ["LogExpFunctions", "Rmath", "SpecialFunctions"] -git-tree-sha1 = "30cd8c360c54081f806b1ee14d2eecbef3c04c49" +deps = ["ChainRulesCore", "IrrationalConstants", "LogExpFunctions", "Reexport", "Rmath", "SpecialFunctions"] +git-tree-sha1 = "95072ef1a22b057b1e80f73c2a89ad238ae4cfff" uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c" -version = "0.9.8" +version = "0.9.12" [[StrideArraysCore]] -deps = ["ArrayInterface", "ManualMemory", "Requires", "ThreadingUtilities", "VectorizationBase"] -git-tree-sha1 = "e1c37dd3022ba6aaf536541dd607e8d5fb534377" +deps = ["ArrayInterface", "CloseOpenIntervals", "IfElse", "LayoutPointers", "ManualMemory", "Requires", "SIMDTypes", "Static", "ThreadingUtilities"] +git-tree-sha1 = "1258e25e171aec339866f283a11e7d75867e77d7" uuid = "7792a7ef-975c-4747-a70f-980b88e8d1da" -version = "0.1.17" +version = "0.2.4" [[SuiteSparse]] deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"] @@ -660,9 +709,9 @@ uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" [[Sundials]] deps = ["CEnum", "DataStructures", "DiffEqBase", "Libdl", "LinearAlgebra", "Logging", "Reexport", "SparseArrays", "Sundials_jll"] -git-tree-sha1 = "75412a0ce4cd7995d7445ba958dd11de03fd2ce5" +git-tree-sha1 = "12d529a67c232bd27e9868fbcfad4997435786a5" uuid = "c3572dad-4567-51f8-b174-8c6c989267f4" -version = "4.5.3" +version = "4.6.0" [[Sundials_jll]] deps = ["CompilerSupportLibraries_jll", "Libdl", "OpenBLAS_jll", "Pkg", "SuiteSparse_jll"] @@ -671,16 +720,16 @@ uuid = "fb77eaff-e24c-56d4-86b1-d163f2edb164" version = "5.2.0+1" [[SymbolicUtils]] -deps = ["AbstractTrees", "ChainRulesCore", "Combinatorics", "ConstructionBase", "DataStructures", "DocStringExtensions", "DynamicPolynomials", "IfElse", "LabelledArrays", "LinearAlgebra", "MultivariatePolynomials", "NaNMath", "Setfield", "SparseArrays", "SpecialFunctions", "StaticArrays", "TimerOutputs"] -git-tree-sha1 = "591440eabc9407917b1fedd1e929710dba5b0958" +deps = ["AbstractTrees", "Bijections", "ChainRulesCore", "Combinatorics", "ConstructionBase", "DataStructures", "DocStringExtensions", "DynamicPolynomials", "IfElse", "LabelledArrays", "LinearAlgebra", "MultivariatePolynomials", "NaNMath", "Setfield", "SparseArrays", "SpecialFunctions", "StaticArrays", "TermInterface", "TimerOutputs"] +git-tree-sha1 = "b747ed621b12281f9bc69e7a6e5337334b1d0c7f" uuid = "d1185830-fcd6-423d-90d6-eec64667417b" -version = "0.13.3" +version = "0.16.0" [[Symbolics]] deps = ["ConstructionBase", "DiffRules", "Distributions", "DocStringExtensions", "DomainSets", "IfElse", "Latexify", "Libdl", "LinearAlgebra", "MacroTools", "NaNMath", "RecipesBase", "Reexport", "Requires", "RuntimeGeneratedFunctions", "SciMLBase", "Setfield", "SparseArrays", "SpecialFunctions", "StaticArrays", "SymbolicUtils", "TreeViews"] -git-tree-sha1 = "6a7d84c33afd675e63f55f6c8859d169b1887c85" +git-tree-sha1 = "e17bd63d88ae90df2ef3c0505a687a534f86f263" uuid = "0c5d862f-8b57-4792-8d23-62f2024744c7" -version = "3.0.0" +version = "3.4.1" [[TOML]] deps = ["Dates"] @@ -694,14 +743,19 @@ version = "1.0.1" [[Tables]] deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "TableTraits", "Test"] -git-tree-sha1 = "d0c690d37c73aeb5ca063056283fde5585a41710" +git-tree-sha1 = "fed34d0e71b91734bf0a7e10eb1bb05296ddbcd0" uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" -version = "1.5.0" +version = "1.6.0" [[Tar]] deps = ["ArgTools", "SHA"] uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" +[[TermInterface]] +git-tree-sha1 = "02a620218eaaa1c1914d228d0e75da122224a502" +uuid = "8ea1fca8-c5ef-4a55-8b96-4e9afe9c9a3c" +version = "0.1.8" + [[Test]] deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" @@ -714,9 +768,9 @@ version = "0.4.6" [[TimerOutputs]] deps = ["ExprTools", "Printf"] -git-tree-sha1 = "209a8326c4f955e2442c07b56029e88bb48299c7" +git-tree-sha1 = "7cb456f358e8f9d102a8b25e8dfedf58fa5689bc" uuid = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f" -version = "0.5.12" +version = "0.5.13" [[TreeViews]] deps = ["Test"] @@ -725,10 +779,10 @@ uuid = "a2a6695c-b41b-5b7d-aed9-dbfdeacea5d7" version = "0.3.0" [[TriangularSolve]] -deps = ["CloseOpenIntervals", "IfElse", "LinearAlgebra", "LoopVectorization", "Polyester", "Static", "VectorizationBase"] -git-tree-sha1 = "cb80cf5e0dfb1aedd4c6dbca09b5faaa9a300c62" +deps = ["CloseOpenIntervals", "IfElse", "LayoutPointers", "LinearAlgebra", "LoopVectorization", "Polyester", "Static", "VectorizationBase"] +git-tree-sha1 = "ed55426a514db35f58d36c3812aae89cfc057401" uuid = "d5829a12-d9aa-46ab-831f-fb7c9ab06edf" -version = "0.1.3" +version = "0.1.6" [[UUIDs]] deps = ["Random", "SHA"] @@ -743,10 +797,10 @@ version = "1.0.2" uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" [[VectorizationBase]] -deps = ["ArrayInterface", "Hwloc", "IfElse", "Libdl", "LinearAlgebra", "Static"] -git-tree-sha1 = "32a3252a00a8e4aa23129e2c36a237e812f71eeb" +deps = ["ArrayInterface", "CPUSummary", "HostCPUFeatures", "Hwloc", "IfElse", "LayoutPointers", "Libdl", "LinearAlgebra", "SIMDTypes", "Static"] +git-tree-sha1 = "a6ca373834ec22aa850c09392399add8f13d476a" uuid = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f" -version = "0.20.33" +version = "0.21.13" [[VertexSafeGraphs]] deps = ["LightGraphs"] @@ -760,9 +814,9 @@ uuid = "83775a58-1f1d-513f-b197-d71354ab007a" [[ZygoteRules]] deps = ["MacroTools"] -git-tree-sha1 = "9e7a1e8ca60b742e508a315c17eef5211e7fbfd7" +git-tree-sha1 = "8c1a8e4dfacb1fd631745552c8db35d0deb09ea0" uuid = "700de1a5-db45-46bc-99cf-38207098b444" -version = "0.2.1" +version = "0.2.2" [[nghttp2_jll]] deps = ["Artifacts", "Libdl"] diff --git a/Project.toml b/Project.toml index c3a2466..417d181 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PETLION" uuid = "5e0a28e4-193c-47fa-bbb8-9c901cc1ac2c" authors = ["Marc D. Berliner", "Richard D. Braatz"] -version = "0.1.3" +version = "0.1.4" [deps] BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0" diff --git a/src/generate_functions.jl b/src/generate_functions.jl index c1735d3..2a6e6b1 100644 --- a/src/generate_functions.jl +++ b/src/generate_functions.jl @@ -1,4 +1,4 @@ -const PETLION_VERSION = (0,1,5) +const PETLION_VERSION = (0,1,4) const options = Dict{Symbol,Any}( :SAVE_SYMBOLIC_FUNCTIONS => true, :FILE_DIRECTORY => pwd(), From 48314bcd8dba7a39b04d95b91c39c027a41cb23e Mon Sep 17 00:00:00 2001 From: Marc Berliner Date: Tue, 5 Oct 2021 16:59:01 -0400 Subject: [PATCH 5/5] Fixed multiple dispatch on some functions --- src/checks.jl | 4 ++-- src/physics_equations/auxiliary_states_and_coefficients.jl | 6 +++--- src/physics_equations/residuals.jl | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/checks.jl b/src/checks.jl index 9befdde..c1a1c83 100644 --- a/src/checks.jl +++ b/src/checks.jl @@ -161,9 +161,9 @@ end ) where {R2<:Vector{Float64}, R3<:AbstractRun, R4<:param, R5<:boundary_stop_conditions} if !isnan(bounds.c_e_min) - c_e_min = -Inf + c_e_min = +Inf @inbounds for ind in p.ind.c_e - @inbounds c_e_min = max(c_e_min, Y[ind]) + @inbounds c_e_min = min(c_e_min, Y[ind]) end if bounds.c_e_min - c_e_min > ϵ t_frac = (bounds.c_e_min_prev - bounds.c_e_min)/(bounds.c_e_min_prev - c_e_min) diff --git a/src/physics_equations/auxiliary_states_and_coefficients.jl b/src/physics_equations/auxiliary_states_and_coefficients.jl index 60a4d30..3d210a7 100644 --- a/src/physics_equations/auxiliary_states_and_coefficients.jl +++ b/src/physics_equations/auxiliary_states_and_coefficients.jl @@ -87,7 +87,7 @@ function build_T!(states, p::AbstractParamTemp{false}) end -function build_c_s_star!(states, p::AbstractParam{jac,temp,:Fickian}) where {jac,temp} +function build_c_s_star!(states, p::AbstractParamSolidDiff{:Fickian}) """ Evaluates the concentration of Li-ions at the electrode surfaces. """ @@ -106,7 +106,7 @@ function build_c_s_star!(states, p::AbstractParam{jac,temp,:Fickian}) where {jac return nothing end -function build_c_s_star!(states, p::AbstractParam{jac,temp,:quadratic}) where {jac,temp} +function build_c_s_star!(states, p::AbstractParamSolidDiff{:quadratic}) """ Evaluates the concentration of Li-ions at the electrode surfaces. """ @@ -128,7 +128,7 @@ function build_c_s_star!(states, p::AbstractParam{jac,temp,:quadratic}) where {j return nothing end -function build_c_s_star!(states, p::AbstractParam{jac,temp,:polynomial}) where {jac,temp} +function build_c_s_star!(states, p::AbstractParamSolidDiff{:polynomial}) """ Evaluates the concentration of Li-ions at the electrode surfaces. """ diff --git a/src/physics_equations/residuals.jl b/src/physics_equations/residuals.jl index c6cbcc4..d8299e9 100644 --- a/src/physics_equations/residuals.jl +++ b/src/physics_equations/residuals.jl @@ -205,7 +205,7 @@ function residuals_c_e!(res, states, ∂states, p::AbstractParam) return nothing end -function residuals_c_s_avg!(res, states, ∂states, p::Union{AbstractParamSolidDiff{:quadratic},AbstractParamSolidDiff{:polynomial}}) +function residuals_c_s_avg!(res, states, ∂states, p::T) where {T<:Union{AbstractParamSolidDiff{:polynomial},AbstractParamSolidDiff{:quadratic}}} """ Calculate the solid particle concentrations residuals with quadratic or polynomial approximations [mol/m³] """ @@ -225,7 +225,7 @@ function residuals_c_s_avg!(res, states, ∂states, p::Union{AbstractParamSolidD return nothing end -function residuals_c_s_avg!(res, states, ∂states, p::AbstractParamFickian{:finite_difference}) where {jac,temp} +function residuals_c_s_avg!(res, states, ∂states, p::T) where {jac,temp,T<:AbstractParam{jac,temp,:Fickian,:finite_difference}} """ Calculate the volume-averaged solid particle concentration residuals using a 9th order accurate finite difference method (FDM) [mol/m³] """ @@ -279,7 +279,7 @@ function residuals_c_s_avg!(res, states, ∂states, p::AbstractParamFickian{:fin return nothing end -function residuals_c_s_avg!(res, states, ∂states, p::AbstractParamSolidDiff{:spectral}) +function residuals_c_s_avg!(res, states, ∂states, p::T) where {jac,temp,T<:AbstractParam{jac,temp,:Fickian,:spectral}} """ Calculate the volume-averaged solid particle concentration residuals using a spectral method [mol/m³] """