From 63e628ac47b2fe54b7b20fb00c29fb1f3415537d Mon Sep 17 00:00:00 2001 From: singularitti Date: Sun, 15 Oct 2023 03:58:54 -0400 Subject: [PATCH 01/12] Use complete type names of `Calculation`s --- src/PhononWorkflow/actions.jl | 43 ++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/src/PhononWorkflow/actions.jl b/src/PhononWorkflow/actions.jl index 095138d..663f858 100644 --- a/src/PhononWorkflow/actions.jl +++ b/src/PhononWorkflow/actions.jl @@ -1,8 +1,12 @@ -using AbInitioSoftwareBase: Input, Setter, parentdir -using AbInitioSoftwareBase.Commands: MpiexecConfig +using AbInitioSoftwareBase: Input, Setter using Dates: format, now -using Express: Calculation, SCF -using Express.PhononWorkflow: DFPT, RealSpaceForceConstants, PhononDispersion, VDOS +using ExpressBase: + Calculation, + SelfConsistentField, + DensityFunctionalPerturbationTheory, + RealSpaceForceConstants, + PhononDispersion, + VDOS # using QuantumESPRESSO: QuantumESPRESSOInput using QuantumESPRESSO.PWscf: PWInput, @@ -19,8 +23,8 @@ using UnifiedPseudopotentialFormat # To work with `download_potential` import Express.PhononWorkflow: CreateInput, RunCmd, parsecell, inputtype, buildjob inputtype(x::Calculation) = inputtype(typeof(x)) -inputtype(::Type{SCF}) = PWInput -inputtype(::Type{DFPT}) = PhInput +inputtype(::Type{SelfConsistentField}) = PWInput +inputtype(::Type{DensityFunctionalPerturbationTheory}) = PhInput inputtype(::Type{RealSpaceForceConstants}) = Q2rInput inputtype(::Type{<:Union{PhononDispersion,VDOS}}) = MatdynInput @@ -28,11 +32,13 @@ function parsecell(str) return tryparsefinal(AtomicPositionsCard, str), tryparsefinal(CellParametersCard, str) end -function (::CreateInput{SCF})(template::PWInput, args...) - return (customizer(args...) ∘ normalizer(SCF(), template))(template) +function (::CreateInput{SelfConsistentField})(template::PWInput, args...) + return (customizer(args...) ∘ normalizer(SelfConsistentField(), template))(template) end -function (::CreateInput{DFPT})(template::PhInput, previnp::PWInput) - return normalizer(DFPT(), previnp)(template) +function (::CreateInput{DensityFunctionalPerturbationTheory})( + template::PhInput, previnp::PWInput +) + return normalizer(DensityFunctionalPerturbationTheory(), previnp)(template) end function (::CreateInput{RealSpaceForceConstants})(template::Q2rInput, previnp::PhInput) return normalizer(RealSpaceForceConstants(), previnp)(template) @@ -44,7 +50,7 @@ function (::CreateInput{T})( end struct CalculationSetter <: Setter - calc::Union{SCF,DFPT} + calc::Union{SelfConsistentField,DensityFunctionalPerturbationTheory} end function (::CalculationSetter)(template::PWInput) @set! template.control.calculation = "scf" @@ -81,10 +87,11 @@ function (x::PseudoDirSetter)(template::PWInput) return template end -function normalizer(::SCF, args...) - return VerbositySetter("high") ∘ CalculationSetter(SCF()) ∘ PseudoDirSetter() +function normalizer(::SelfConsistentField, args...) + return VerbositySetter("high") ∘ CalculationSetter(SelfConsistentField()) ∘ + PseudoDirSetter() end -function normalizer(::DFPT, input::PWInput) +function normalizer(::DensityFunctionalPerturbationTheory, input::PWInput) return RelayArgumentsSetter(input) ∘ VerbositySetter("high") ∘ RecoverySetter() end normalizer(::RealSpaceForceConstants, input::PhInput) = RelayArgumentsSetter(input) @@ -121,10 +128,14 @@ function customizer( AtomicPositionsCardSetter(ap) end -function (x::RunCmd{SCF})(input, output=mktemp(parentdir(input))[1]; kwargs...) +function (x::RunCmd{SelfConsistentField})( + input, output=mktemp(parentdir(input))[1]; kwargs... +) return pw(input, output; kwargs...) end -function (x::RunCmd{DFPT})(input, output=mktemp(parentdir(input))[1]; kwargs...) +function (x::RunCmd{DensityFunctionalPerturbationTheory})( + input, output=mktemp(parentdir(input))[1]; kwargs... +) return ph(input, output; kwargs...) end function (x::RunCmd{RealSpaceForceConstants})( From 5de2f26e377111986400279b41324585339d9f34 Mon Sep 17 00:00:00 2001 From: singularitti Date: Sun, 15 Oct 2023 03:59:14 -0400 Subject: [PATCH 02/12] Remove `timefmt` in `customizer` --- src/PhononWorkflow/actions.jl | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/PhononWorkflow/actions.jl b/src/PhononWorkflow/actions.jl index 663f858..fbfe32d 100644 --- a/src/PhononWorkflow/actions.jl +++ b/src/PhononWorkflow/actions.jl @@ -121,12 +121,9 @@ function (x::OutdirSetter)(template::PWInput) return template end -function customizer( - ap::AtomicPositionsCard, cp::CellParametersCard, timefmt::AbstractString="Y-m-d_H:M:S" -) - return OutdirSetter(timefmt) ∘ CellParametersCardSetter(cp) ∘ - AtomicPositionsCardSetter(ap) -end +customizer(ap::AtomicPositionsCard, cp::CellParametersCard) = + OutdirSetter("Y-m-d_H:M:S") ∘ CellParametersCardSetter(cp) ∘ + AtomicPositionsCardSetter(ap) function (x::RunCmd{SelfConsistentField})( input, output=mktemp(parentdir(input))[1]; kwargs... From d5a36a4c8aaa8695c0b50e15a41bdab6703b4230 Mon Sep 17 00:00:00 2001 From: singularitti Date: Sun, 15 Oct 2023 18:12:09 -0400 Subject: [PATCH 03/12] Deprecate `inputtype` & `buildjob` See https://github.com/MineralsCloud/Express.jl/pull/295 --- src/PhononWorkflow/actions.jl | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/PhononWorkflow/actions.jl b/src/PhononWorkflow/actions.jl index fbfe32d..b7b2c79 100644 --- a/src/PhononWorkflow/actions.jl +++ b/src/PhononWorkflow/actions.jl @@ -20,13 +20,7 @@ using QuantumESPRESSO.Commands: pw, ph, q2r, matdyn using Setfield: @set! using UnifiedPseudopotentialFormat # To work with `download_potential` -import Express.PhononWorkflow: CreateInput, RunCmd, parsecell, inputtype, buildjob - -inputtype(x::Calculation) = inputtype(typeof(x)) -inputtype(::Type{SelfConsistentField}) = PWInput -inputtype(::Type{DensityFunctionalPerturbationTheory}) = PhInput -inputtype(::Type{RealSpaceForceConstants}) = Q2rInput -inputtype(::Type{<:Union{PhononDispersion,VDOS}}) = MatdynInput +import Express.PhononWorkflow: CreateInput, RunCmd, parsecell function parsecell(str) return tryparsefinal(AtomicPositionsCard, str), tryparsefinal(CellParametersCard, str) From 92e655b3f5708f51d8568b4cdb2398564b6e8ccc Mon Sep 17 00:00:00 2001 From: singularitti Date: Sun, 15 Oct 2023 18:12:17 -0400 Subject: [PATCH 04/12] Fix importing `QuantumESPRESSOInput` --- src/PhononWorkflow/actions.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/PhononWorkflow/actions.jl b/src/PhononWorkflow/actions.jl index b7b2c79..3748dc1 100644 --- a/src/PhononWorkflow/actions.jl +++ b/src/PhononWorkflow/actions.jl @@ -7,7 +7,6 @@ using ExpressBase: RealSpaceForceConstants, PhononDispersion, VDOS -# using QuantumESPRESSO: QuantumESPRESSOInput using QuantumESPRESSO.PWscf: PWInput, CellParametersCard, From e27a3a20885be80b8f92fa445836da262f6dcfac Mon Sep 17 00:00:00 2001 From: singularitti Date: Sun, 15 Oct 2023 18:12:48 -0400 Subject: [PATCH 05/12] Fix `CreateInput` for --- src/PhononWorkflow/actions.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PhononWorkflow/actions.jl b/src/PhononWorkflow/actions.jl index 3748dc1..84ff07b 100644 --- a/src/PhononWorkflow/actions.jl +++ b/src/PhononWorkflow/actions.jl @@ -41,6 +41,8 @@ function (::CreateInput{T})( ) where {T<:Union{PhononDispersion,VDOS}} return normalizer(T(), (a, b))(template) end +(action::CreateInput)(template::MatdynInput, a::PhInput, b::Q2rInput) = + action(template, b, a) struct CalculationSetter <: Setter calc::Union{SelfConsistentField,DensityFunctionalPerturbationTheory} From a328f91ceb6cbd6d699179ad477bea5595e6e3dc Mon Sep 17 00:00:00 2001 From: singularitti Date: Sun, 15 Oct 2023 18:12:55 -0400 Subject: [PATCH 06/12] Uncomment `PhononWorkflow` --- src/QuantumESPRESSOExpress.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/QuantumESPRESSOExpress.jl b/src/QuantumESPRESSOExpress.jl index bded312..3b1b534 100644 --- a/src/QuantumESPRESSOExpress.jl +++ b/src/QuantumESPRESSOExpress.jl @@ -15,7 +15,7 @@ currentsoftware() = QE() include("ConvergenceTestWorkflow/ConvergenceTestWorkflow.jl") include("EquationOfStateWorkflow/EquationOfStateWorkflow.jl") -# include("PhononWorkflow/PhononWorkflow.jl") +include("PhononWorkflow/PhononWorkflow.jl") function (x::RunCmd)(input, output=mktemp(parentdir(input))[1]; kwargs...) return pw(input, output; kwargs...) From 3565dd7a7d72f71496a1847a65d1b100f705c991 Mon Sep 17 00:00:00 2001 From: singularitti Date: Sun, 15 Oct 2023 18:20:23 -0400 Subject: [PATCH 07/12] Move `MpiexecOptions`, etc., to src/SoftwareConfig.jl --- src/ConvergenceTestWorkflow/Config.jl | 128 +------------------------- src/EquationOfStateWorkflow/Config.jl | 128 +------------------------- src/QuantumESPRESSOExpress.jl | 1 + src/SoftwareConfig.jl | 125 +++++++++++++++++++++++++ 4 files changed, 130 insertions(+), 252 deletions(-) create mode 100644 src/SoftwareConfig.jl diff --git a/src/ConvergenceTestWorkflow/Config.jl b/src/ConvergenceTestWorkflow/Config.jl index 4e6e433..1aeee2f 100644 --- a/src/ConvergenceTestWorkflow/Config.jl +++ b/src/ConvergenceTestWorkflow/Config.jl @@ -4,6 +4,8 @@ using Configurations: OptionField, @option using ExpressBase.Config: SoftwareConfig using QuantumESPRESSO.PWscf: PWInput +using ..QuantumESPRESSOExpress: QuantumESPRESSOConfig, MpiexecConfig, PwxConfig + import Configurations: from_dict import Express.ConvergenceTestWorkflow.Config: StaticConfig, _update! @@ -13,132 +15,6 @@ function _update!(conf, template::AbstractString) return conf end -@option struct MpiexecOptions <: SoftwareConfig - path::String = "mpiexec" - f::String = "" - hosts::Vector{String} = String[] - wdir::String = "" - configfile::String = "" - env::Union{Dict,Vector} = Dict(ENV) - np::UInt = 1 -end - -const MpiexecConfig = MpiexecOptions - -""" - ParallelizationFlags(; nimage=0, npool=0, ntg=0, nyfft=0, nband=0, ndiag=0) - -Construct parallelization flags of QuantumESPRESSO commands. -""" -@option mutable struct ParallelizationFlags - nimage::UInt = 0 - npool::UInt = 0 - ntg::UInt = 0 - nyfft::UInt = 0 - nband::UInt = 0 - ndiag::UInt = 0 -end - -""" - PwxConfig(; path, chdir, options) - -Create configurations for `pw.x`. - -# Arguments -- `path::String="pw.x"`: the path to the executable. -- `chdir::Bool=true`: whether to change directory to where the input file is - stored when running `pw.x`. If `false`, stay in the current directory. -- `options::ParallelizationFlags=ParallelizationFlags()`: the parallelization - flags of `pw.x`. -""" -@option mutable struct PwxConfig <: SoftwareConfig - path::String = "pw.x" - chdir::Bool = true - options::ParallelizationFlags = ParallelizationFlags() - env::Union{Dict,Vector} = Dict(ENV) -end -""" - PhxConfig(; path, chdir, options) - -Create configurations for `ph.x`. - -# Arguments -- `path::String="ph.x"`: the path to the executable. -- `chdir::Bool=true`: whether to change directory to where the input file is - stored when running `ph.x`. If `false`, stay in the current directory. -- `options::ParallelizationFlags=ParallelizationFlags()`: the parallelization - flags of `ph.x`. -""" -@option mutable struct PhxConfig <: SoftwareConfig - path::String = "ph.x" - chdir::Bool = true - options::ParallelizationFlags = ParallelizationFlags() - env::Union{Dict,Vector} = Dict(ENV) -end -""" - Q2rxConfig(; path, chdir, options) - -Create configurations for `q2r.x`. - -# Arguments -- `path::String="q2r.x"`: the path to the executable. -- `chdir::Bool=true`: whether to change directory to where the input file is - stored when running `q2r.x`. If `false`, stay in the current directory. -- `options::ParallelizationFlags=ParallelizationFlags()`: the parallelization - flags of `q2r.x`. -""" -@option mutable struct Q2rxConfig <: SoftwareConfig - path::String = "q2r.x" - chdir::Bool = true - options::ParallelizationFlags = ParallelizationFlags() - env::Union{Dict,Vector} = Dict(ENV) -end -""" - MatdynxConfig(; path, chdir, options) - -Create configurations for `matdyn.x`. - -# Arguments -- `path::String="matdyn.x"`: the path to the executable. -- `chdir::Bool=true`: whether to change directory to where the input file is - stored when running `matdyn.x`. If `false`, stay in the current directory. -- `options::ParallelizationFlags=ParallelizationFlags()`: the parallelization - flags of `matdyn.x`. -""" -@option mutable struct MatdynxConfig <: SoftwareConfig - path::String = "matdyn.x" - chdir::Bool = true - options::ParallelizationFlags = ParallelizationFlags() - env::Union{Dict,Vector} = Dict(ENV) -end -""" - DynmatxConfig(; path, chdir, options) - -Create configurations for `dynmat.x`. - -# Arguments -- `path::String="dynmat.x"`: the path to the executable. -- `chdir::Bool=true`: whether to change directory to where the input file is - stored when running `dynmat.x`. If `false`, stay in the current directory. -- `options::ParallelizationFlags=ParallelizationFlags()`: the parallelization - flags of `dynmat.x`. -""" -@option mutable struct DynmatxConfig <: SoftwareConfig - path::String = "dynmat.x" - chdir::Bool = true - options::ParallelizationFlags = ParallelizationFlags() - env::Union{Dict,Vector} = Dict(ENV) -end - -@option mutable struct QuantumESPRESSOConfig <: SoftwareConfig - mpi::MpiexecConfig = MpiexecConfig() - pw::PwxConfig = PwxConfig() - ph::PhxConfig = PhxConfig() - q2r::Q2rxConfig = Q2rxConfig() - matdyn::MatdynxConfig = MatdynxConfig() - dynmat::DynmatxConfig = DynmatxConfig() -end - function from_dict( ::Type{<:StaticConfig}, ::OptionField{:cli}, ::Type{SoftwareConfig}, dict ) diff --git a/src/EquationOfStateWorkflow/Config.jl b/src/EquationOfStateWorkflow/Config.jl index 00c42b2..95c23c2 100644 --- a/src/EquationOfStateWorkflow/Config.jl +++ b/src/EquationOfStateWorkflow/Config.jl @@ -4,6 +4,8 @@ using Configurations: OptionField, @option using ExpressBase.Config: SoftwareConfig using QuantumESPRESSO.PWscf: PWInput +using ..QuantumESPRESSOExpress: QuantumESPRESSOConfig, MpiexecConfig, PwxConfig + import Configurations: from_dict import Express.EquationOfStateWorkflow.Config: StaticConfig, _update! @@ -13,132 +15,6 @@ function _update!(conf, template::AbstractString) return conf end -@option struct MpiexecOptions <: SoftwareConfig - path::String = "mpiexec" - f::String = "" - hosts::Vector{String} = String[] - wdir::String = "" - configfile::String = "" - env::Union{Dict,Vector} = Dict(ENV) - np::UInt = 1 -end - -const MpiexecConfig = MpiexecOptions - -""" - ParallelizationFlags(; nimage=0, npool=0, ntg=0, nyfft=0, nband=0, ndiag=0) - -Construct parallelization flags of QuantumESPRESSO commands. -""" -@option mutable struct ParallelizationFlags - nimage::UInt = 0 - npool::UInt = 0 - ntg::UInt = 0 - nyfft::UInt = 0 - nband::UInt = 0 - ndiag::UInt = 0 -end - -""" - PwxConfig(; path, chdir, options) - -Create configurations for `pw.x`. - -# Arguments -- `path::String="pw.x"`: the path to the executable. -- `chdir::Bool=true`: whether to change directory to where the input file is - stored when running `pw.x`. If `false`, stay in the current directory. -- `options::ParallelizationFlags=ParallelizationFlags()`: the parallelization - flags of `pw.x`. -""" -@option mutable struct PwxConfig <: SoftwareConfig - path::String = "pw.x" - chdir::Bool = true - options::ParallelizationFlags = ParallelizationFlags() - env::Union{Dict,Vector} = Dict(ENV) -end -""" - PhxConfig(; path, chdir, options) - -Create configurations for `ph.x`. - -# Arguments -- `path::String="ph.x"`: the path to the executable. -- `chdir::Bool=true`: whether to change directory to where the input file is - stored when running `ph.x`. If `false`, stay in the current directory. -- `options::ParallelizationFlags=ParallelizationFlags()`: the parallelization - flags of `ph.x`. -""" -@option mutable struct PhxConfig <: SoftwareConfig - path::String = "ph.x" - chdir::Bool = true - options::ParallelizationFlags = ParallelizationFlags() - env::Union{Dict,Vector} = Dict(ENV) -end -""" - Q2rxConfig(; path, chdir, options) - -Create configurations for `q2r.x`. - -# Arguments -- `path::String="q2r.x"`: the path to the executable. -- `chdir::Bool=true`: whether to change directory to where the input file is - stored when running `q2r.x`. If `false`, stay in the current directory. -- `options::ParallelizationFlags=ParallelizationFlags()`: the parallelization - flags of `q2r.x`. -""" -@option mutable struct Q2rxConfig <: SoftwareConfig - path::String = "q2r.x" - chdir::Bool = true - options::ParallelizationFlags = ParallelizationFlags() - env::Union{Dict,Vector} = Dict(ENV) -end -""" - MatdynxConfig(; path, chdir, options) - -Create configurations for `matdyn.x`. - -# Arguments -- `path::String="matdyn.x"`: the path to the executable. -- `chdir::Bool=true`: whether to change directory to where the input file is - stored when running `matdyn.x`. If `false`, stay in the current directory. -- `options::ParallelizationFlags=ParallelizationFlags()`: the parallelization - flags of `matdyn.x`. -""" -@option mutable struct MatdynxConfig <: SoftwareConfig - path::String = "matdyn.x" - chdir::Bool = true - options::ParallelizationFlags = ParallelizationFlags() - env::Union{Dict,Vector} = Dict(ENV) -end -""" - DynmatxConfig(; path, chdir, options) - -Create configurations for `dynmat.x`. - -# Arguments -- `path::String="dynmat.x"`: the path to the executable. -- `chdir::Bool=true`: whether to change directory to where the input file is - stored when running `dynmat.x`. If `false`, stay in the current directory. -- `options::ParallelizationFlags=ParallelizationFlags()`: the parallelization - flags of `dynmat.x`. -""" -@option mutable struct DynmatxConfig <: SoftwareConfig - path::String = "dynmat.x" - chdir::Bool = true - options::ParallelizationFlags = ParallelizationFlags() - env::Union{Dict,Vector} = Dict(ENV) -end - -@option mutable struct QuantumESPRESSOConfig <: SoftwareConfig - mpi::MpiexecConfig = MpiexecConfig() - pw::PwxConfig = PwxConfig() - ph::PhxConfig = PhxConfig() - q2r::Q2rxConfig = Q2rxConfig() - matdyn::MatdynxConfig = MatdynxConfig() - dynmat::DynmatxConfig = DynmatxConfig() -end - function from_dict( ::Type{<:StaticConfig}, ::OptionField{:cli}, ::Type{SoftwareConfig}, dict ) diff --git a/src/QuantumESPRESSOExpress.jl b/src/QuantumESPRESSOExpress.jl index 3b1b534..ac66acf 100644 --- a/src/QuantumESPRESSOExpress.jl +++ b/src/QuantumESPRESSOExpress.jl @@ -13,6 +13,7 @@ const QE = QuantumESPRESSO currentsoftware() = QE() +include("SoftwareConfig.jl") include("ConvergenceTestWorkflow/ConvergenceTestWorkflow.jl") include("EquationOfStateWorkflow/EquationOfStateWorkflow.jl") include("PhononWorkflow/PhononWorkflow.jl") diff --git a/src/SoftwareConfig.jl b/src/SoftwareConfig.jl new file mode 100644 index 0000000..67adb1e --- /dev/null +++ b/src/SoftwareConfig.jl @@ -0,0 +1,125 @@ +@option struct MpiexecOptions <: SoftwareConfig + path::String = "mpiexec" + f::String = "" + hosts::Vector{String} = String[] + wdir::String = "" + configfile::String = "" + env::Union{Dict,Vector} = Dict(ENV) + np::UInt = 1 +end + +const MpiexecConfig = MpiexecOptions + +""" + ParallelizationFlags(; nimage=0, npool=0, ntg=0, nyfft=0, nband=0, ndiag=0) + +Construct parallelization flags of QuantumESPRESSO commands. +""" +@option mutable struct ParallelizationFlags + nimage::UInt = 0 + npool::UInt = 0 + ntg::UInt = 0 + nyfft::UInt = 0 + nband::UInt = 0 + ndiag::UInt = 0 +end + +""" + PwxConfig(; path, chdir, options) + +Create configurations for `pw.x`. + +# Arguments +- `path::String="pw.x"`: the path to the executable. +- `chdir::Bool=true`: whether to change directory to where the input file is + stored when running `pw.x`. If `false`, stay in the current directory. +- `options::ParallelizationFlags=ParallelizationFlags()`: the parallelization + flags of `pw.x`. +""" +@option mutable struct PwxConfig <: SoftwareConfig + path::String = "pw.x" + chdir::Bool = true + options::ParallelizationFlags = ParallelizationFlags() + env::Union{Dict,Vector} = Dict(ENV) +end +""" + PhxConfig(; path, chdir, options) + +Create configurations for `ph.x`. + +# Arguments +- `path::String="ph.x"`: the path to the executable. +- `chdir::Bool=true`: whether to change directory to where the input file is + stored when running `ph.x`. If `false`, stay in the current directory. +- `options::ParallelizationFlags=ParallelizationFlags()`: the parallelization + flags of `ph.x`. +""" +@option mutable struct PhxConfig <: SoftwareConfig + path::String = "ph.x" + chdir::Bool = true + options::ParallelizationFlags = ParallelizationFlags() + env::Union{Dict,Vector} = Dict(ENV) +end +""" + Q2rxConfig(; path, chdir, options) + +Create configurations for `q2r.x`. + +# Arguments +- `path::String="q2r.x"`: the path to the executable. +- `chdir::Bool=true`: whether to change directory to where the input file is + stored when running `q2r.x`. If `false`, stay in the current directory. +- `options::ParallelizationFlags=ParallelizationFlags()`: the parallelization + flags of `q2r.x`. +""" +@option mutable struct Q2rxConfig <: SoftwareConfig + path::String = "q2r.x" + chdir::Bool = true + options::ParallelizationFlags = ParallelizationFlags() + env::Union{Dict,Vector} = Dict(ENV) +end +""" + MatdynxConfig(; path, chdir, options) + +Create configurations for `matdyn.x`. + +# Arguments +- `path::String="matdyn.x"`: the path to the executable. +- `chdir::Bool=true`: whether to change directory to where the input file is + stored when running `matdyn.x`. If `false`, stay in the current directory. +- `options::ParallelizationFlags=ParallelizationFlags()`: the parallelization + flags of `matdyn.x`. +""" +@option mutable struct MatdynxConfig <: SoftwareConfig + path::String = "matdyn.x" + chdir::Bool = true + options::ParallelizationFlags = ParallelizationFlags() + env::Union{Dict,Vector} = Dict(ENV) +end +""" + DynmatxConfig(; path, chdir, options) + +Create configurations for `dynmat.x`. + +# Arguments +- `path::String="dynmat.x"`: the path to the executable. +- `chdir::Bool=true`: whether to change directory to where the input file is + stored when running `dynmat.x`. If `false`, stay in the current directory. +- `options::ParallelizationFlags=ParallelizationFlags()`: the parallelization + flags of `dynmat.x`. +""" +@option mutable struct DynmatxConfig <: SoftwareConfig + path::String = "dynmat.x" + chdir::Bool = true + options::ParallelizationFlags = ParallelizationFlags() + env::Union{Dict,Vector} = Dict(ENV) +end + +@option mutable struct QuantumESPRESSOConfig <: SoftwareConfig + mpi::MpiexecConfig = MpiexecConfig() + pw::PwxConfig = PwxConfig() + ph::PhxConfig = PhxConfig() + q2r::Q2rxConfig = Q2rxConfig() + matdyn::MatdynxConfig = MatdynxConfig() + dynmat::DynmatxConfig = DynmatxConfig() +end From 3185137d80740ba4b0578c62306f11263ed52d77 Mon Sep 17 00:00:00 2001 From: singularitti Date: Sun, 15 Oct 2023 18:22:24 -0400 Subject: [PATCH 08/12] Fix imports --- src/ConvergenceTestWorkflow/Config.jl | 2 +- src/EquationOfStateWorkflow/Config.jl | 2 +- src/SoftwareConfig.jl | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ConvergenceTestWorkflow/Config.jl b/src/ConvergenceTestWorkflow/Config.jl index 1aeee2f..878bdfc 100644 --- a/src/ConvergenceTestWorkflow/Config.jl +++ b/src/ConvergenceTestWorkflow/Config.jl @@ -1,6 +1,6 @@ module Config -using Configurations: OptionField, @option +using Configurations: OptionField using ExpressBase.Config: SoftwareConfig using QuantumESPRESSO.PWscf: PWInput diff --git a/src/EquationOfStateWorkflow/Config.jl b/src/EquationOfStateWorkflow/Config.jl index 95c23c2..f16efa0 100644 --- a/src/EquationOfStateWorkflow/Config.jl +++ b/src/EquationOfStateWorkflow/Config.jl @@ -1,6 +1,6 @@ module Config -using Configurations: OptionField, @option +using Configurations: OptionField using ExpressBase.Config: SoftwareConfig using QuantumESPRESSO.PWscf: PWInput diff --git a/src/SoftwareConfig.jl b/src/SoftwareConfig.jl index 67adb1e..e030036 100644 --- a/src/SoftwareConfig.jl +++ b/src/SoftwareConfig.jl @@ -1,3 +1,6 @@ +using Configurations: @option +using ExpressBase.Config: SoftwareConfig + @option struct MpiexecOptions <: SoftwareConfig path::String = "mpiexec" f::String = "" From faa5b13510f0fe27208360dfbf6f95ba3391bfa4 Mon Sep 17 00:00:00 2001 From: singularitti Date: Sun, 15 Oct 2023 18:56:08 -0400 Subject: [PATCH 09/12] Fix imports --- src/ConvergenceTestWorkflow/Config.jl | 2 +- src/EquationOfStateWorkflow/Config.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ConvergenceTestWorkflow/Config.jl b/src/ConvergenceTestWorkflow/Config.jl index 878bdfc..839e643 100644 --- a/src/ConvergenceTestWorkflow/Config.jl +++ b/src/ConvergenceTestWorkflow/Config.jl @@ -4,7 +4,7 @@ using Configurations: OptionField using ExpressBase.Config: SoftwareConfig using QuantumESPRESSO.PWscf: PWInput -using ..QuantumESPRESSOExpress: QuantumESPRESSOConfig, MpiexecConfig, PwxConfig +using ...QuantumESPRESSOExpress: QuantumESPRESSOConfig, MpiexecConfig, PwxConfig import Configurations: from_dict import Express.ConvergenceTestWorkflow.Config: StaticConfig, _update! diff --git a/src/EquationOfStateWorkflow/Config.jl b/src/EquationOfStateWorkflow/Config.jl index f16efa0..b032444 100644 --- a/src/EquationOfStateWorkflow/Config.jl +++ b/src/EquationOfStateWorkflow/Config.jl @@ -4,7 +4,7 @@ using Configurations: OptionField using ExpressBase.Config: SoftwareConfig using QuantumESPRESSO.PWscf: PWInput -using ..QuantumESPRESSOExpress: QuantumESPRESSOConfig, MpiexecConfig, PwxConfig +using ...QuantumESPRESSOExpress: QuantumESPRESSOConfig, MpiexecConfig, PwxConfig import Configurations: from_dict import Express.EquationOfStateWorkflow.Config: StaticConfig, _update! From 07bfce78abb3040a92d2280e28b54ac03e06988b Mon Sep 17 00:00:00 2001 From: singularitti Date: Sun, 15 Oct 2023 18:56:17 -0400 Subject: [PATCH 10/12] Fix src/PhononWorkflow/Config.jl --- src/PhononWorkflow/Config.jl | 46 ++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/PhononWorkflow/Config.jl b/src/PhononWorkflow/Config.jl index 6261a6e..6283ead 100644 --- a/src/PhononWorkflow/Config.jl +++ b/src/PhononWorkflow/Config.jl @@ -1,34 +1,44 @@ module Config -using AbInitioSoftwareBase.Commands: MpiexecConfig using Configurations: OptionField -using Express.PhononWorkflow.Config: StaticConfig, Template +using Express.PhononWorkflow.Config: StaticConfig +using ExpressBase: + SelfConsistentField, + DensityFunctionalPerturbationTheory, + RealSpaceForceConstants, + PhononDispersion, + PhononDensityOfStates using ExpressBase.Config: SoftwareConfig -using QuantumESPRESSO.Commands: - QuantumESPRESSOConfig, PwxConfig, PhxConfig, Q2rxConfig, MatdynxConfig using QuantumESPRESSO.PWscf: PWInput using QuantumESPRESSO.PHonon: PhInput, Q2rInput, MatdynInput +using ...QuantumESPRESSOExpress: + MpiexecConfig, QuantumESPRESSOConfig, PwxConfig, PhxConfig, Q2rxConfig, MatdynxConfig + import Configurations: from_dict -import Express.PhononWorkflow.Config: ExpandConfig +import Express.PhononWorkflow.Config: StaticConfig, _update! -function (::ExpandConfig)(template::Template) - inputs = map( - (:scf, :dfpt, :q2r, :disp), (PWInput, PhInput, Q2rInput, MatdynInput) - ) do field, T - str = read(getproperty(template, field), String) - parse(T, str) +function _update!(conf, templates::Vector{String}) + stage, T = if conf.calculation isa SelfConsistentField + 1, PWInput + elseif conf.calculation isa DensityFunctionalPerturbationTheory + 2, PhInput + elseif conf.calculation isa RealSpaceForceConstants + 3, Q2rInput + elseif conf.calculation isa PhononDispersion + 4, MatdynInput + elseif conf.calculation isa PhononDensityOfStates + 4, MatdynInput + else + 4, DynmatInput end - return (; zip((:scf, :dfpt, :q2r, :disp), inputs)...) + str = read(templates[stage], String) + conf.template = parse(T, str) + return conf end function from_dict( - ::Type{<:StaticConfig}, ::OptionField{:cli}, ::Type{<:SoftwareConfig}, dict -) - return from_dict(StaticConfig, OptionField{:cli}(), QuantumESPRESSOConfig, dict) -end -function from_dict( - ::Type{<:StaticConfig}, ::OptionField{:cli}, ::Type{QuantumESPRESSOConfig}, dict + ::Type{<:StaticConfig}, ::OptionField{:cli}, ::Type{SoftwareConfig}, dict ) return QuantumESPRESSOConfig(; mpi=get(dict, "mpi", MpiexecConfig()), From e240c28787c0ec6b8f06f7ad7dfaad5bb61caa0a Mon Sep 17 00:00:00 2001 From: singularitti Date: Sun, 15 Oct 2023 18:56:52 -0400 Subject: [PATCH 11/12] Move `RunCmd` to src/QuantumESPRESSOExpress.jl --- src/PhononWorkflow/actions.jl | 21 --------------------- src/QuantumESPRESSOExpress.jl | 31 ++++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/PhononWorkflow/actions.jl b/src/PhononWorkflow/actions.jl index 84ff07b..9f1b631 100644 --- a/src/PhononWorkflow/actions.jl +++ b/src/PhononWorkflow/actions.jl @@ -119,24 +119,3 @@ end customizer(ap::AtomicPositionsCard, cp::CellParametersCard) = OutdirSetter("Y-m-d_H:M:S") ∘ CellParametersCardSetter(cp) ∘ AtomicPositionsCardSetter(ap) - -function (x::RunCmd{SelfConsistentField})( - input, output=mktemp(parentdir(input))[1]; kwargs... -) - return pw(input, output; kwargs...) -end -function (x::RunCmd{DensityFunctionalPerturbationTheory})( - input, output=mktemp(parentdir(input))[1]; kwargs... -) - return ph(input, output; kwargs...) -end -function (x::RunCmd{RealSpaceForceConstants})( - input, output=mktemp(parentdir(input))[1]; kwargs... -) - return q2r(input, output; kwargs...) -end -function (x::RunCmd{<:Union{VDOS,PhononDispersion}})( - input, output=mktemp(parentdir(input))[1]; kwargs... -) - return matdyn(input, output; kwargs...) -end diff --git a/src/QuantumESPRESSOExpress.jl b/src/QuantumESPRESSOExpress.jl index ac66acf..80c2a60 100644 --- a/src/QuantumESPRESSOExpress.jl +++ b/src/QuantumESPRESSOExpress.jl @@ -1,6 +1,13 @@ module QuantumESPRESSOExpress using AbInitioSoftwareBase: AbInitioSoftware +using ExpressBase: + SelfConsistentField, + VariableCellOptimization, + DensityFunctionalPerturbationTheory, + RealSpaceForceConstants, + PhononDispersion, + PhononDensityOfStates using ExpressBase.Files: parentdir # import Express: current_software @@ -18,8 +25,30 @@ include("ConvergenceTestWorkflow/ConvergenceTestWorkflow.jl") include("EquationOfStateWorkflow/EquationOfStateWorkflow.jl") include("PhononWorkflow/PhononWorkflow.jl") -function (x::RunCmd)(input, output=mktemp(parentdir(input))[1]; kwargs...) +function (x::RunCmd{SelfConsistentField})( + input, output=mktemp(parentdir(input))[1]; kwargs... +) return pw(input, output; kwargs...) end +function (x::RunCmd{VariableCellOptimization})( + input, output=mktemp(parentdir(input))[1]; kwargs... +) + return pw(input, output; kwargs...) +end +function (x::RunCmd{DensityFunctionalPerturbationTheory})( + input, output=mktemp(parentdir(input))[1]; kwargs... +) + return ph(input, output; kwargs...) +end +function (x::RunCmd{RealSpaceForceConstants})( + input, output=mktemp(parentdir(input))[1]; kwargs... +) + return q2r(input, output; kwargs...) +end +function (x::RunCmd{<:Union{PhononDensityOfStates,PhononDispersion}})( + input, output=mktemp(parentdir(input))[1]; kwargs... +) + return matdyn(input, output; kwargs...) +end end From 22a72471a6481c1fb138acfba26939bd2c02fe50 Mon Sep 17 00:00:00 2001 From: singularitti Date: Sun, 15 Oct 2023 18:57:05 -0400 Subject: [PATCH 12/12] Fix imports in src/PhononWorkflow/actions.jl --- src/PhononWorkflow/actions.jl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/PhononWorkflow/actions.jl b/src/PhononWorkflow/actions.jl index 9f1b631..dc0fdc3 100644 --- a/src/PhononWorkflow/actions.jl +++ b/src/PhononWorkflow/actions.jl @@ -6,7 +6,7 @@ using ExpressBase: DensityFunctionalPerturbationTheory, RealSpaceForceConstants, PhononDispersion, - VDOS + PhononDensityOfStates using QuantumESPRESSO.PWscf: PWInput, CellParametersCard, @@ -15,7 +15,6 @@ using QuantumESPRESSO.PWscf: AtomicPositionsCardSetter, tryparsefinal using QuantumESPRESSO.PHonon: PhInput, Q2rInput, MatdynInput, VerbositySetter, relayinfo -using QuantumESPRESSO.Commands: pw, ph, q2r, matdyn using Setfield: @set! using UnifiedPseudopotentialFormat # To work with `download_potential` @@ -38,7 +37,7 @@ function (::CreateInput{RealSpaceForceConstants})(template::Q2rInput, previnp::P end function (::CreateInput{T})( template::MatdynInput, a::Q2rInput, b::PhInput -) where {T<:Union{PhononDispersion,VDOS}} +) where {T<:Union{PhononDispersion,PhononDensityOfStates}} return normalizer(T(), (a, b))(template) end (action::CreateInput)(template::MatdynInput, a::PhInput, b::Q2rInput) = @@ -95,7 +94,9 @@ function normalizer( ) return RelayArgumentsSetter(inputs) ∘ DosSetter(false) end -function normalizer(::VDOS, inputs::Union{Tuple{Q2rInput,PhInput},Tuple{PhInput,Q2rInput}}) +function normalizer( + ::PhononDensityOfStates, inputs::Union{Tuple{Q2rInput,PhInput},Tuple{PhInput,Q2rInput}} +) return RelayArgumentsSetter(inputs) ∘ DosSetter(true) end