Skip to content

Commit

Permalink
Merge pull request #47 from BattModels/pb_tweak2
Browse files Browse the repository at this point in the history
add I_start and start_guess to phase_diagram function
  • Loading branch information
rkurchin authored Aug 2, 2022
2 parents 149da25 + 5e85c79 commit 6f8a333
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 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.1"
version = "0.1.2"

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

"""
phase_diagram(km; I_step=1, I_max=Inf, verbose=false, intercalate=true, kwargs...)
phase_diagram(km; I_start=0, I_step=1, I_max=Inf, verbose=false, intercalate=true, start_guess=[0.05, 0.95], kwargs...)
Construct electrochemical phase diagram for the model `km` as a function of composition and current, in steps of `I_step`.
Construct electrochemical phase diagram for the model `km` as a function of composition and current, from `I_start` to `I_max`, in steps of `I_step`. To aid in convergence, you may also provide `start_guess` for the phase boundaries at `I_start`.
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...)
function phase_diagram(km::KineticModel; I_start=0, I_step=1, I_max=Inf, verbose=false, intercalate=true, start_guess=[0.05, 0.95], kwargs...)
I = I_start
pbs_here = find_phase_boundaries(I, km; intercalate=intercalate, guess=start_guess, kwargs...)
pbs = pbs_here'
I_vals = [0]
I_vals = [I_start]
while abs(pbs_here[2] - pbs_here[1]) > 1e-3 && I < I_max
I = I + I_step
if verbose
Expand Down

2 comments on commit 6f8a333

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

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.2 -m "<description of version>" 6f8a333423021fd396a52de9b59411585da4a744
git push origin v0.1.2

Please sign in to comment.