Skip to content

Commit

Permalink
Merge pull request #46 from BattModels/pd_tweak
Browse files Browse the repository at this point in the history
add I_max parameter to phase_diagram function
  • Loading branch information
rkurchin authored Jul 26, 2022
2 parents d6284f1 + 0535768 commit 149da25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 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.0"
version = "0.1.1"

[deps]
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Expand Down
14 changes: 11 additions & 3 deletions src/phase_diagrams.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,21 @@ function find_phase_boundaries(I, km::KineticModel; guess=[0.05, 0.95], intercal
x1.zero
end

# TODO: add T_max to handle low-T BV cases
function phase_diagram(km::KineticModel; I_step=10, verbose=false, intercalate=true, kwargs...)
"""
phase_diagram(km; I_step=1, I_max=Inf, verbose=false, intercalate=true, kwargs...)
Construct electrochemical phase diagram for the model `km` as a function of composition and current, in steps of `I_step`.
NOTE 1: appropriate values of `I_step` depend strongly on the prefactor of your model. For example, for `ButlerVolmer` with a prefactor of 1, the phase diagram at T=330K closes at I=5, but with a prefactor of 10, it reaches up to I=44.
NOTE 2: at lower temperatures (<=320K or so), ButlerVolmer models with the default thermodynamic parameters have a two-phase region at every current, so setting a finite value of I_max is necessary for this function to finish running.
"""
function phase_diagram(km::KineticModel; I_step=1, I_max=Inf, verbose=false, intercalate=true, kwargs...)
I = 0
pbs_here = find_phase_boundaries(I, km; intercalate=intercalate, kwargs...)
pbs = pbs_here'
I_vals = [0]
while abs(pbs_here[2] - pbs_here[1]) > 1e-3
while abs(pbs_here[2] - pbs_here[1]) > 1e-3 && I < I_max
I = I + I_step
if verbose
println("Solving at I=", I, "...")
Expand Down

2 comments on commit 149da25

@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/65031

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.1 -m "<description of version>" 149da25f88b037d7bc702134130888dd964d2c15
git push origin v0.1.1

Please sign in to comment.