Skip to content

Commit

Permalink
Merge pull request #50 from BattModels/shhh
Browse files Browse the repository at this point in the history
add option for overpotential not to warn as it makes phase diagram co…
  • Loading branch information
rkurchin authored Aug 3, 2022
2 parents 6f8a333 + 2e515d0 commit a843dcf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ElectrochemicalKinetics"
uuid = "a2c6e634-85ca-418a-9c67-9b5417ce2d04"
authors = ["Rachel Kurchin <[email protected]>", "Holden Parks <[email protected]>", "Dhairya Gandhi <[email protected]>"]
version = "0.1.2"
version = "0.1.3"

[deps]
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Expand Down
4 changes: 2 additions & 2 deletions src/fitting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Given values for current/rate constant and specified model parameters, find the
NOTE that this currently only solves for net reaction rates.
"""
function overpotential(k, model::KineticModel, guess = _get_guess(k, model); T = 298, loss = janky_log_loss, autodiff = true, verbose=false, kwargs...)
function overpotential(k, model::KineticModel, guess = _get_guess(k, model); T = 298, loss = janky_log_loss, autodiff = true, verbose=false, warn=true, kwargs...)
# wherever k=0 we can shortcut since the answer has to be 0
k_solve = k
if k==0 # scalar k=0, possibly vector model
Expand Down Expand Up @@ -91,7 +91,7 @@ function overpotential(k, model::KineticModel, guess = _get_guess(k, model); T =
else
Vs = nlsolve(compare_k!, guess, show_trace=verbose)
end
if !converged(Vs)
if !converged(Vs) && warn
@warn "Overpotential fit not fully converged...you may have fed in an unreachable reaction rate!"
end
sol = Vs.zero
Expand Down
10 changes: 5 additions & 5 deletions src/phase_diagrams.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ prefactor(x, intercalate::Bool) = intercalate ? (1 .- x) : x
These functions return single-argument functions (to easily use common-tangent function below while
still being able to swap out model parameters by calling "function-builders" with different arguments).
"""
function µ_kinetic(I, km::KineticModel; intercalate=true, kwargs...)
function µ_kinetic(I, km::KineticModel; intercalate=true, warn=true, kwargs...)
thermo_term(x) = μ_thermo(x; kwargs...)
μ(x::Real) = thermo_term(x) .+ overpotential(I, prefactor(x, intercalate)*km)
μ(x::AbstractVector) = thermo_term(x) .+ overpotential(I, prefactor(x, intercalate).*Ref(km))
μ(x::Real) = thermo_term(x) .+ overpotential(I, prefactor(x, intercalate)*km, warn=warn)
μ(x::AbstractVector) = thermo_term(x) .+ overpotential(I, prefactor(x, intercalate).*Ref(km), warn=warn)
return μ
end

function g_kinetic(I, km::KineticModel; intercalate=true, kwargs...)
function g_kinetic(I, km::KineticModel; intercalate=true, warn=true, kwargs...)
thermo_term(x) = g_thermo(x; kwargs...)
#TODO: gradient of this term is just value of overpotential(x)
function kinetic_term(x)
f(x) = ElectrochemicalKinetics.overpotential(I, prefactor(x, intercalate) * km)
f(x) = ElectrochemicalKinetics.overpotential(I, prefactor(x, intercalate) * km, warn=warn)
n, w = ElectrochemicalKinetics.scale_coarse(zero.(x), x)
map((w, n) -> sum(w .* f(n)), eachcol(w), eachcol(n))
end
Expand Down

2 comments on commit a843dcf

@rkurchin
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/65571

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.3 -m "<description of version>" a843dcf89ef15b4a578f74fc4195fc89e0d9e0c0
git push origin v0.1.3

Please sign in to comment.