Skip to content

Commit

Permalink
Merge pull request #12 from MineralsCloud:FreeEnergyTempVolPlot
Browse files Browse the repository at this point in the history
Implement `FreeEnergyTempVolPlot` in src/recipes.jl
  • Loading branch information
singularitti authored Aug 22, 2023
2 parents ca02bd6 + 0391ec7 commit bd1bdd5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
PythonCallHelpers = "82926614-86f1-43a3-92dc-771be2bbc0fa"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"

[compat]
CondaPkg = "0.2"
Expand Down
1 change: 1 addition & 0 deletions src/PyQHA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ include("io.jl")
include("run.jl")
include("plot.jl")
include("convert.jl")
include("recipes.jl")

end
43 changes: 43 additions & 0 deletions src/recipes.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using RecipesBase: @recipe, @userplot, @series

@userplot FreeEnergyTempVolPlot
@recipe function f(plot::FreeEnergyTempVolPlot)
# See http://juliaplots.org/RecipesBase.jl/stable/types/#User-Recipes-2
path = first(plot.args)
data = read_f_tv(path)
volumes = map(Base.Fix1(parse, Float64), names(data)[2:end])
r = length(plot.args) == 2 ? plot.args[end] : range(1; stop=size(data, 1), length=5)
r = convert(StepRange{Int64,Int64}, r)
temperatures = collect(data[r, 1])
free_energies = collect(collect(values(row)) for row in eachrow(data[r, 2:end]))
size --> (600, 400)
markersize --> 2
markerstrokecolor --> :auto
markerstrokewidth --> 0
xlims --> extrema(volumes)
xguide --> "volumes"
yguide --> "free energy"
guidefontsize --> 10
tickfontsize --> 8
legendfontsize --> 8
legend_foreground_color --> nothing
legend_position --> :top
frame --> :box
palette --> :tab20
grid --> nothing
for (temperature, free_energy) in Iterators.reverse(zip(temperatures, free_energies))
@series begin
seriestype --> :path
z_order --> :back
label --> "T=" * string(temperature) * " K"
volumes, free_energy
end
index = argmin(free_energy)
@series begin
seriestype --> :scatter
label := ""
# @show [volumes[index]], [free_energy[index]]
[volumes[index]], [free_energy[index]]
end
end
end

0 comments on commit bd1bdd5

Please sign in to comment.