Skip to content

Commit

Permalink
Add field criteria to type StaticConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
singularitti committed Oct 10, 2023
1 parent 947eaa1 commit c5394a3
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/ConvergenceTestWorkflow/Config.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
module Config

using Configurations: from_dict, @option
using Configurations: OptionField, @option
using EasyConfig: Config as Conf
using ExpressBase.Config: AbstractConfig, SoftwareConfig, SamplingPoints, IO, list_io
using Unitful: FreeUnits
using ExpressBase: Calculation
using ExpressBase.Config:
AbstractConfig, SoftwareConfig, SamplingPoints, IO, list_io, _uparse
using Unitful: FreeUnits, Quantity

import Configurations: from_dict

@option "ecut" struct CutoffEnergies <: SamplingPoints
numbers::Vector{Float64}
Expand Down Expand Up @@ -34,15 +38,16 @@ end
recipe::String
template::String
with::Union{CutoffEnergies,MonkhorstPackGrids}
criteria::Quantity
io::IO = IO()
data::Data = Data()
cli::SoftwareConfig
function StaticConfig(recipe, template, with, io, data, cli)
function StaticConfig(recipe, template, with, criteria, io, data, cli)
@assert recipe in ("ecut", "kmesh")
if !isfile(template)
@warn "I cannot find template file `$template`!"
end
return new(recipe, template, with, io, data, cli)
return new(recipe, template, with, criteria, io, data, cli)
end
end

Expand Down Expand Up @@ -87,4 +92,8 @@ function expand(config::StaticConfig, calculation::Calculation)
return conf
end

from_dict(
::Type{StaticConfig}, ::OptionField{:criteria}, ::Type{Quantity}, str::AbstractString
) = eval(_uparse(str))

end

0 comments on commit c5394a3

Please sign in to comment.