Skip to content

Commit

Permalink
Fix ExtractData in src/ConvergenceTestWorkflow/actions.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
singularitti committed Oct 15, 2023
1 parent 1eab39e commit c40e3cc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/ConvergenceTestWorkflow/actions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@ using UnitfulAtomic
import Express.ConvergenceTestWorkflow: CreateInput, ExtractData
import ExpressBase: RunCmd

struct DataExtractionFailed <: Exception
msg::String
end

function (::ExtractData)(file)
str = read(file, String)
preamble = tryparse(Preamble, str)
e = try
parse_electrons_energies(str, :converged)
catch
end
return e.ε[end] * u"Ry"
if preamble !== nothing && !isempty(e)
return preamble.ecutwfc * u"Ry" => e.ε[end] * u"Ry" # volume, energy
else
throw(DataExtractionFailed("no data found in file $file."))
end
end

(::CreateInput)(template::PWInput, args...) = (customizer(args...) normalizer())(template)
Expand Down

0 comments on commit c40e3cc

Please sign in to comment.