Deborah.Miriam.EnsembleUtils
Deborah.Miriam.EnsembleUtils.build_dummy_param — Functionbuild_dummy_param(
cfg::TOMLConfigMiriam.FullConfigMiriam,
ens::String,
jobid::Union{Nothing, String}=nothing
) -> Params{Float64}Construct a dummy Params{Float64} object from config and ensemble name.
Arguments
cfg::TOMLConfigMiriam.FullConfigMiriam: Configuration object containing lattice input metadata.ens::String: Ensemble name string containing encoded $\kappa$ (must matchk13580format).jobid::Union{Nothing, String}: Optional job ID for logging.
Returns
Params{Float64}: Lattice parameter object with extracted $\kappa$ value from ensemble name.
Deborah.Miriam.EnsembleUtils.build_ensemble_array_from_trace — Functionbuild_ensemble_array_from_trace(
grouped_data::Dict{String, Dict{String, NamedTuple}},
cfg::TOMLConfigMiriam.FullConfigMiriam,
jobid::Union{Nothing, String}=nothing
) -> Tuple{Ensemble.EnsembleArray{Float64}, Vector{String}}Build an EnsembleArray{Float64} (collection of EnsembleStruct) and the corresponding ensemble-name list from grouped trace data.
Arguments
grouped_data::Dict{String, Dict{String, NamedTuple}}: Outer dictionary keyed by ensemble name (e.g.,"L8T4b1.60k13570"). Each inner dictionary maps trace prefixes (e.g.,"Y_tr","Y_bc","Y_ul","YP_bc","YP_ul";"Y_info"is ignored) to aNamedTuplewith fields:values::Vector{Vector{Float64}}— rows of rescaled $\text{Tr} \, M^{-n}$ (length 4 or 5)values_raw::Vector{Vector{Float64}}— rows of un-rescaled raw $\text{Tr} \, M^{-n}$ (length 4 or 5)conf_nums::Vector{Int}— configuration numbers
cfg::TOMLConfigMiriam.FullConfigMiriam: Configuration used to determine the ensemble set and to build dummy parameters.jobid::Union{Nothing, String}: Optional job identifier for structured logging.
Returns
(ensemble_array, key_list):ensemble_array::EnsembleArray{Float64}: Holds oneDeborah.Miriam.Ensemble.EnsembleStructper ensemble. Each struct includes:trMi(rescaled, rows of length 5; a placeholder may be appended by the loader),trMi_raw(un-rescaled, rows of length 5; a placeholder may be appended by the loader),source_tags(0:Y_tr,1:Y_bc/YP_bc,2:Y_ul/YP_ul),secondary_tags(0:Y_lb,1:Y_ul), and alignedconf_nums.
key_list::Vector{String}: The list of ensemble names sorted lexicographically (as insort(cfg.data.ensembles)).
Notes
- Internally calls
flatten_trace_blockswhich concatenates all prefixes (except"Y_info"), appends a placeholder 5th component when needed for both rescaled and un-rescaled traces, and sorts rows by configuration number. - Missing or malformed inputs are reported via
Deborah.Sarah.JobLoggerTools.error_benji/Deborah.Sarah.JobLoggerTools.warn_benjiin the upstream loader/flattening routines.
Deborah.Miriam.EnsembleUtils.dS — MethoddS(
ens::Ensemble.EnsembleStruct{T},
paramT::Ensemble.Params{T},
i::Int
) -> TCompute the total action shift $\Delta S$ between an ensemble configuration and a target parameter set. Currently only includes the fermionic part dSf, which may involve mass ($\kappa$) reweighting.
Arguments
ens::Ensemble.EnsembleStruct{T}: Source ensemble with original parameters and trace dataparamT::Ensemble.Params{T}: Target parameters (includeskappa)i::Int: Gauge configuration index.
Returns
T: Total action difference $\Delta S$ (currently equal todSf)
Deborah.Miriam.EnsembleUtils.dSf — MethoddSf(
ens::Ensemble.EnsembleStruct{T},
cswT::T,
kappaT::T,
i::Int
) -> TCompute the fermionic action shift from mass reweighting only. Currently ignores clover term variation (cswT) and delegates to dSf_m.
Arguments
ens::Ensemble.EnsembleStruct{T}: Ensemble data containing trace momentstrMicswT::T: Target clover coefficient (unused)kappaT::T: Target hopping parameteri::Int: Gauge configuration index.
Returns
dSf_m: Estimated shift in fermionic action from mass difference only
Deborah.Miriam.EnsembleUtils.dSf_m — MethoddSf_m(
ens::Ensemble.EnsembleStruct{T},
kappaT::T,
i::Int
) -> TCompute the derivative of the fermion action $S_f$ with respect to the mass parameter $m$, expanded around the original $\kappa$ in the ensemble and evaluated at a target $\kappa$.
Arguments
ens::Ensemble.EnsembleStruct{T}: Ensemble containing trace momentstrMikappaT::T: Target hopping parameter ($\kappa$) for reweightingi::Int: Gauge configuration index.
Returns
T: Estimated value of $\Delta S_f$ for gauge configuration indexi
Notes
Fermion Action Shift via Mass Taylor Expansion
Evaluates the mass-dependent shift in the fermion action $\Delta S_f$, expanded around the original $\kappa$ of the ensemble and evaluated at a target $\kappa$.
Mass Shift
The hopping-mass shift is defined as:
\[\delta m = \frac{1}{2} \left( \frac{1}{\kappa} - \frac{1}{\kappa_{\text{target}}} \right)\]
Taylor Expansion of Fermion Action
The action shift is approximated by:
\[\Delta S_f (\kappa_{\text{target}}) \approx \frac{(\delta m)^1}{1} \left[\text{Tr}\,M^{-1}\right]\left(\kappa\right) + \frac{(\delta m)^2}{2} \left[\text{Tr}\,M^{-2}\right]\left(\kappa\right) + \frac{(\delta m)^3}{3} \left[\text{Tr}\,M^{-3}\right]\left(\kappa\right) + \frac{(\delta m)^4}{4} \left[\text{Tr}\,M^{-4}\right]\left(\kappa\right)\]
Each trace term is obtained from the stored vector ens.trMi[i] in the ensemble:
\[\texttt{trMi[i]} = \left\{ \; 12 N_f V ,\; \text{Tr}\, M^{-1} ,\; \text{Tr}\, M^{-2} ,\; \text{Tr}\, M^{-3} ,\; \text{Tr}\, M^{-4} \;\right\}\]
In this context, we assume that all $\text{Tr} \, M^{-n} \; (n=1,2,3,4)$ have already been properly rescaled. (For the rescaling process in Deborah.Miriam, see Deborah.Miriam.MultiEnsembleLoader.generate_trMi_vector or Deborah.Miriam.Cumulants.calc_Q. Note, however, that the rescaling convention in Deborah.Esther is slightly different; to check it, see Deborah.Esther.TraceRescaler.rescale_trace.)
Deborah.Miriam.EnsembleUtils.flatten_trace_blocks — Functionflatten_trace_blocks(
trace_dict::Dict{String, NamedTuple},
jobid::Union{Nothing, String}=nothing
) -> Tuple{Vector{Vector{Float64}}, Vector{Vector{Float64}}, Vector{UInt8}, Vector{UInt8}, Vector{Int}}Flatten per-prefix trace blocks into unified arrays (sorted by configuration) suitable for Deborah.Miriam.Ensemble.EnsembleStruct.
Arguments
trace_dict::Dict{String, NamedTuple}: Mapping from trace prefix (e.g.,"Y_tr","Y_bc","Y_ul","YP_bc","YP_ul";"Y_info"is ignored) to aNamedTuplewith fields:.values::Vector{Vector{Float64}}— per-configuration rescaled trace vectors (length 4 or 5)..values_raw::Vector{Vector{Float64}}— per-configuration un-rescaled raw trace vectors (length 4 or 5)..conf_nums::Vector{Int}— per-configuration IDs.
jobid::Union{Nothing, String}: Optional job ID for logging.
Returns
Vector{Vector{Float64}}(trMi): Flattened rescaled trace rows (each of length 5). If an input row has length 4, a placeholder fifth component is appended asval[1]^5(do not use this placeholder as a physical observable).Vector{Vector{Float64}}(trMi_raw): Flattened un-rescaled raw trace rows (each of length 5). If an input row has length 4, a placeholder fifth component is appended asval_raw[1]^5.Vector{UInt8}(source_tags): Fine-grained source code per row0→"Y_tr"1→"Y_bc","YP_bc"2→"Y_ul","YP_ul"
Vector{UInt8}(secondary_tags): Coarse class tag per row0→"Y_lb"(originated from"Y_tr","Y_bc","YP_bc")1→"Y_ul"(originated from"Y_ul","YP_ul")
Vector{Int}(conf_nums): Configuration numbers aligned with the outputs; rows are globally sorted by configuration.
Notes
- Concatenates all prefixes present in
trace_dictexcept"Y_info", then sorts by configuration number. - Replacement prefixes (
"YP_*") map to the same source/secondary classes as their non-replacement counterparts. .values,.values_raw, and.conf_numsmust have equal lengths per prefix; mismatches and unknown prefixes raise errors viaDeborah.Sarah.JobLoggerTools.error_benji.
Deborah.Miriam.EnsembleUtils.secondary_source_to_tag — Functionsecondary_source_to_tag(
prefix::String,
jobid::Union{Nothing, String}=nothing
) -> UInt8Map a trace prefix to a secondary class tag used for coarse grouping.
Arguments
prefix::String: Trace data prefix (e.g.,"Y_tr","Y_bc","YP_ul").jobid::Union{Nothing, String}: Optional job ID for logging.
Returns
UInt8: Encoded secondary tag0→"Y_lb"(for"Y_tr","Y_bc","YP_bc")1→"Y_ul"(for"Y_ul","YP_ul")
Throws
- Raises an error via
Deborah.Sarah.JobLoggerTools.error_benjiifprefixis unknown.
Deborah.Miriam.EnsembleUtils.source_to_tag — Functionsource_to_tag(
prefix::String,
jobid::Union{Nothing, String}=nothing
) -> UInt8Map a trace prefix string to its source tag (compact UInt8 code).
Arguments
prefix::String: Trace data prefix (e.g.,"Y_tr","Y_bc","YP_ul").jobid::Union{Nothing, String}: Optional job ID for logging.
Returns
UInt8: Encoded source tag0→"Y_tr"1→"Y_bc","YP_bc"2→"Y_ul","YP_ul"
Throws
- Raises an error via
Deborah.Sarah.JobLoggerTools.error_benjiifprefixis unknown.
Notes
- Replacement prefixes (
"YP_bc","YP_ul") are mapped to the same source classes as their non-replacement counterparts.
Deborah.Miriam.EnsembleUtils.trMiT — MethodtrMiT(
ens::Ensemble.EnsembleStruct{T},
paramT::Ensemble.Params{T},
i::Int
) -> Vector{T}Evaluate the trace moment trMi at index i, reweighted to a different $\kappa$ value.
Arguments
ens::Ensemble.EnsembleStruct{T}: Original ensemble containing trace momentsparamT::Ensemble.Params{T}: Target parameter with new $\kappa$ valuei::Int: Gauge configuration index
Returns
Vector{T}: Reweighted trace moment vector of same length asens.trMi[i]
Notes
Trace Moment Shift via Taylor Expansion
Evaluates the trace moment vector ens.trMi[i] at a shifted $\kappa$ value using a 4th-order Taylor expansion in the hopping mass.
Input Format
Each original trace moment is assumed to be of the form:
\[\texttt{trMi[i]} = \left\{ \; 12 \, N_{\text{f}} \, V \, , \; \text{Tr} \, M^{-1} \, , \; \text{Tr} \, M^{-2} \, , \; \text{Tr} \, M^{-3} \, , \; \text{Tr} \, M^{-4} \; \right \}\]
Here, the first entry is the rescaling factor, and the remaining entries represent trace moments of the inverse Dirac operator raised to powers 1 through 4.
In this context, we assume that all $\text{Tr} \, M^{-n} \; (n=1,2,3,4)$ have already been properly rescaled. (For the rescaling process in Deborah.Miriam, see Deborah.Miriam.MultiEnsembleLoader.generate_trMi_vector or Deborah.Miriam.Cumulants.calc_Q. Note, however, that the rescaling convention in Deborah.Esther is slightly different; to check it, see Deborah.Esther.TraceRescaler.rescale_trace.)
Mass Shift
The mass shift is defined by:
\[\delta m = \frac{1}{2} \left( \frac{1}{\kappa} - \frac{1}{\kappa_{\text{target}}} \right)\]
Shifted Output
The reweighted trace moments are computed via:
\[\begin{aligned} \texttt{ret[1]} &= 12 N_f V \\ \texttt{ret[2]} &= \left[\text{Tr}\,M^{-1}\right]\left(\kappa_{\text{target}}\right)=\left[\text{Tr}\,M^{-1}\right]\left(\kappa\right)+\delta m\;\left[\text{Tr}\,M^{-2}\right]\left(\kappa\right)+\left(\delta m\right)^{2}\;\left[\text{Tr}\,M^{-3}\right]\left(\kappa\right)+\left(\delta m\right)^{3}\;\left[\text{Tr}\,M^{-4}\right]\left(\kappa\right)\\ \texttt{ret[3]} &= \left[\text{Tr}\,M^{-2}\right]\left(\kappa_{\text{target}}\right)=\left[\text{Tr}\,M^{-2}\right]\left(\kappa\right)+2\;\left(\delta m\right)\;\left[\text{Tr}\,M^{-3}\right]\left(\kappa\right)+3\;\left(\delta m\right)^{2}\;\left[\text{Tr}\,M^{-4}\right]\left(\kappa\right)\\ \texttt{ret[4]} &= \left[\text{Tr}\,M^{-3}\right]\left(\kappa_{\text{target}}\right)=\left[\text{Tr}\,M^{-3}\right]\left(\kappa\right)+3\;\left(\delta m\right)\;\left[\text{Tr}\,M^{-4}\right]\left(\kappa\right)\\ \texttt{ret[5]} &= \left[\text{Tr}\,M^{-4}\right]\left(\kappa_{\text{target}}\right)=\left[\text{Tr}\,M^{-4}\right]\left(\kappa\right) \end{aligned}\]
This corresponds to a 4th-order Taylor reweighting of trace observables in the hopping parameter $\kappa$.
Deborah.Miriam.EnsembleUtils.trMi_rawT — MethodtrMi_rawT(
ens::Ensemble.EnsembleStruct{T},
paramT::Ensemble.Params{T},
i::Int
) -> Vector{T}Utility variant of trMiT that operates on un-rescaled raw trace moments. (For details on un-rescaling, see Deborah.Miriam.MultiEnsembleLoader.generate_trMi_raw_vector; for details on rescaling, see Deborah.Miriam.MultiEnsembleLoader.generate_trMi_vector.)
It reads ens.trMi_raw[i] (typically [1.0, trM1, trM2, trM3, trM4]) and applies the same $\kappa$-shift logic as trMiT. The first entry is preserved as-is.
Arguments
ens::Ensemble.EnsembleStruct{T}: Source ensemble providingens.trMi_raw[i].paramT::Ensemble.Params{T}: Target parametersi::Int: Configuration index intoens.trMi_raw[i].
Returns
Vector{T}: Reweighted raw trace vector with the same length asens.trMi_raw[i]. The first component is passed through unchanged (commonly $1.0$), and entries $2,3,4,5$ are the raw traces.
Notes