From c5394a30d8a0c440775d567d91f9ee1c353b6851 Mon Sep 17 00:00:00 2001 From: singularitti Date: Tue, 10 Oct 2023 05:44:17 -0400 Subject: [PATCH] Add field `criteria` to type `StaticConfig` --- src/ConvergenceTestWorkflow/Config.jl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/ConvergenceTestWorkflow/Config.jl b/src/ConvergenceTestWorkflow/Config.jl index 86be0762..f30557d7 100644 --- a/src/ConvergenceTestWorkflow/Config.jl +++ b/src/ConvergenceTestWorkflow/Config.jl @@ -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} @@ -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 @@ -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