Skip to content

Commit

Permalink
Fix last does not work on EachParsed
Browse files Browse the repository at this point in the history
  • Loading branch information
singularitti committed Oct 30, 2023
1 parent 9ca81ad commit ccaf234
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/ConvergenceTestWorkflow/actions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ end
function (::ExtractData)(file)
str = read(file, String)
preamble = tryparse(Preamble, str)
energies = eachconvergedenergy(str)
energies = collect(eachconvergedenergy(str))
if !isnothing(preamble) && !isempty(energies)
return preamble.ecutwfc * u"Ry" => last(energies) * u"Ry" # volume, energy
else
Expand Down
9 changes: 5 additions & 4 deletions src/EquationOfStateWorkflow/EquationOfStateWorkflow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ end
function (::ExtractData{SelfConsistentField})(file)
str = read(file, String)
preamble = tryparse(Preamble, str)
energies = eachconvergedenergy(str)
energies = collect(eachconvergedenergy(str))
if !isnothing(preamble) && !isempty(energies)
return preamble.omega * u"bohr^3" => last(energies) * u"Ry" # volume, energy
else
Expand All @@ -36,7 +36,8 @@ function (::ExtractData{VariableCellOptimization})(file)
if !isoptimized(str)
@warn "Cell is not completely optimized!"
end
cards, energies = eachcellparameterscard(str), eachconvergedenergy(str)
cards, energies = collect(eachcellparameterscard(str)),
collect(eachconvergedenergy(str))
if !isempty(cards) && !isempty(energies)
lastcell, lastenergy = last(cards), last(energies)
return cellvolume(lastcell) * u"bohr^3" => lastenergy * u"Ry" # volume, energy
Expand All @@ -47,8 +48,8 @@ end

function (::ExtractCell)(file)
str = read(file, String)
cell_parameters = last(eachcellparameterscard(str))
atomic_positions = last(eachatomicpositionscard(str))
cell_parameters = last(collect(eachcellparameterscard(str)))
atomic_positions = last(collect(eachatomicpositionscard(str)))
return Cell(cell_parameters, atomic_positions)
end

Expand Down
4 changes: 2 additions & 2 deletions src/PhononWorkflow/actions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ using UnifiedPseudopotentialFormat # To work with `download_potential`
import Express.PhononWorkflow: CreateInput, RunCmd, parsecell

function parsecell(str)
cell_parameters = last(eachcellparameterscard(str))
atomic_positions = last(eachatomicpositionscard(str))
cell_parameters = last(collect(eachcellparameterscard(str)))
atomic_positions = last(collect(eachatomicpositionscard(str)))
return atomic_positions, cell_parameters
end

Expand Down

0 comments on commit ccaf234

Please sign in to comment.