API reference#
Calculations#
CalcJob for one run of the jqmc command-line program.
- class aiida_jqmc.calculations.jqmc.JqmcCalculation(*args, **kwargs)#
Run
jqmc <input.toml>for one of the job types mcmc, vmc, lrdmc-bra or lrdmc-tau.The plugin only wires files and wall time. Every physical or statistical parameter is taken verbatim from the
parametersinput.New run: give
hamiltonian(hamiltonian_data.h5).Restart: give
parent_folder(theremote_folderof a previous JqmcCalculation). The checkpoint is symlinked,control.restartis set, and the step counters stored in the checkpoint keep accumulating, i.e.num_mcmc_steps/num_opt_stepsare additional steps. The job type, the number of MPI processes and the number of walkers must not change, because the checkpoint is stored per MPI rank. Keys that jqmc restores from the checkpoint (“frozen on restart”) may be omitted.control.max_timeis set tomax_wallclock_seconds - max_time_marginso that jqmc stops gracefully and writes its checkpoint before the scheduler kills the job;max_wallclock_secondsis therefore required.control.verbositydefaults to"high", so thatoutput_parametersholds every diagnostic the parser knows (optimizer diagnostics, top coordinates, block statistics, environment); give"low"to override.
- Parameters:
args (Any)
kwargs (Any)
- Return type:
StateMachine
- classmethod define(spec)#
Define inputs, outputs and exit codes.
- prepare_for_submission(folder)#
Write the TOML input and link the Hamiltonian or the parent checkpoint.
CalcJob for one run of the jqmc-tool command-line program.
- class aiida_jqmc.calculations.tool.JqmcToolCalculation(*args, **kwargs)#
Run one
jqmc-toolsubcommand: a conversion or the post-processing of checkpoints.commandselects the subcommand (seeSUBCOMMANDS) andoptionsholds its options verbatim. The plugin only wires the files:conversions (
trexio convert-to,hamiltonian conv-wf) readinput_fileand produceoutput_hamiltonian;qereads a Quantum ESPRESSO output directory: the one entry ofparent_folders(e.g. theremote_folderof a PwCalculation) is linked whole (orinput_folder, a FolderData, is copied), andsave_pathpoints inside it atprefix.saveor its parent (outfor aiida-quantumespresso); it producesoutput_hamiltonian;post-processing (
compute-energy,compute-force,extrapolate-energy) reads the checkpointrestart.h5of eachparent_foldersentry (a JqmcCalculationremote_folder) and reports the parsed stdout inoutput_parameters.
- Parameters:
args (Any)
kwargs (Any)
- Return type:
StateMachine
- classmethod define(spec)#
Define inputs, outputs and exit codes.
- prepare_for_submission(folder)#
Link the input file or the checkpoints and build the command line.
Parsers#
Parser for aiida_jqmc.calculations.jqmc.JqmcCalculation.
The log is parsed by jqmc.output_parser. This module only maps its
result onto AiiDA outputs and exit codes. It reports what jqmc printed and does
not judge whether the values are physically sensible.
- class aiida_jqmc.parsers.jqmc.JqmcParser(node)#
Turn the jqmc stdout into
output_parameters(andoutput_hamiltonianfor VMC).- Parameters:
node (CalcJobNode)
- aiida_jqmc.parsers.jqmc.add_plugin_fields(results)#
What the plugin adds to the dict of
jqmc.output_parser:parser_jqmc(with its warning) andnon_finite_values, the NaN or infinite values replaced by None so that AiiDA can store the dict.
- aiida_jqmc.parsers.jqmc.finite_or_none(value, path, replaced)#
valuewith every NaN or infinite float replaced by None (AiiDA cannot store them);replacedcollects the paths, e.g.energyorsteps.3.energy.
- aiida_jqmc.parsers.jqmc.parser_jqmc(results)#
The jqmc whose output_parser read the log (on the AiiDA host), and a warning when it is not the jqmc that ran.
Parser for aiida_jqmc.calculations.tool.JqmcToolCalculation.
The stdout is parsed by jqmc.output_parser. As for jqmc itself, the
parser reports what jqmc-tool printed and does not judge the values.
- class aiida_jqmc.parsers.tool.JqmcToolParser(node)#
Turn the jqmc-tool stdout into
output_parametersoroutput_hamiltonian.- Parameters:
node (CalcJobNode)
- parse(**kwargs)#
Parse the retrieved files.
- Return type:
ExitCode | None
- aiida_jqmc.parsers.tool.add_tool_fields(results, stderr)#
What the plugin adds to a jqmc-tool result:
environment(the version and git commit jqmc-tool prints on stderr for every subcommand),warnings(the plugin’s) and the fields ofadd_plugin_fields().
Work chains#
Run one jqmc calculation to completion, across as many jobs as needed.
- class aiida_jqmc.workflows.restart.JqmcRestartWorkChain(*args, **kwargs)#
Run a JqmcCalculation until the requested number of steps is done.
The
jqmc.parametersinput describes the whole calculation, exactly as for a single uninterrupted jqmc run:num_mcmc_steps(mcmc, lrdmc) ornum_opt_steps(vmc) is the number of steps to perform in this work chain, counted on top of the parent checkpoint whenjqmc.parent_folderis given.The work chain makes execution decisions only. Every physical or statistical parameter is passed to each job unchanged. It
continues from the latest checkpoint when a job stops on
max_time,resubmits from the last good checkpoint when a job was cut off before jqmc ended (wall time, node failure), and then doubles
max_time_margin,and stops on anything else (invalid input, exceptions in jqmc, NaN, …), leaving the decision to the caller.
The outputs are those of the last job: an MCMC or LRDMC continuation restores the whole history of measurements from the checkpoint, so its energy and counter cover the whole run. A VMC job reports only its own optimization steps, so a VMC run split into several jobs returns
output_parameterswith thestepsof every job (merge_vmc_jobs) and theoutput_hamiltoniansof every job.- Parameters:
args (Any)
kwargs (Any)
- Return type:
StateMachine
- classmethod define(spec)#
Define inputs, outputs and the outline.
- setup()#
Work out the target counter from the parent checkpoint and the requested steps.
- handle_unfinished(node)#
A job ended normally (e.g. stopped on
max_time) before the target was reached.
- handle_interrupted(node)#
A job was cut off before jqmc ended: resubmit from the last good checkpoint.
- results()#
The outputs of the last job; for a VMC run split into several jobs, the steps and the Hamiltonians of all.
- aiida_jqmc.workflows.restart.merge_vmc_jobs(**jobs)#
The
output_parametersof one VMC optimization run in several jobs (continuations,job_000first).Each job reports only its own steps and timings. The merged dict is that of the last job, except:
steps: those of every job (a step done twice keeps its later record);dumped_hamiltonians: those of every job, in order;total_opt_time_sec: the sum over the jobs, andopt_timing_breakdown: per step, averaged over all steps;num_jobs, andwarningsof every job (plus one when the jobs ran different jqmc commits).
- Parameters:
jobs (Dict)
- Return type:
Dict
Output schemas#
JSON Schemas of output_parameters of JqmcCalculation and JqmcToolCalculation.
The schemas describe every field that jqmc.output_parser extracts and
the plugin stores, with its type, unit and meaning, so that a driver (for
example an AI agent) can read the results without reading the log. Every
object is closed (additionalProperties: false): the tests validate the
outputs of real logs against these schemas, so a field added in jqmc without
a description here fails them.
A key whose line was not printed is present with value None; the values are
what jqmc printed, with no judgement of whether they are physically sensible.
Use output_parameters_schema() and tool_output_parameters_schema().
- aiida_jqmc.schemas.output_parameters_schema(job_type)#
JSON Schema of
output_parametersof a JqmcCalculation of job_type.
- aiida_jqmc.schemas.tool_commands_with_parameters()#
jqmc-tool subcommands whose JqmcToolCalculation has
output_parameters.
Statistics (run-length and convergence numbers)#
Run-length estimates from finished calculations, for the caller to use or not.
These helpers compute numbers; they decide nothing. A caller (an AI agent or a
person) that wants an energy error bar of a given size can ask how many more
steps the central-limit scaling error ~ 1/sqrt(N) predicts, and then
extend the calculation with JqmcRestartWorkChain if it agrees with the
estimate. The scaling assumes that the binning already captures the
autocorrelation; check that the error bar is stable against the binning
before trusting it.
- aiida_jqmc.statistics.additional_steps_for_target_error(accumulated_steps, warmup_steps, current_error, target_error)#
Additional measurements that bring
current_errordown totarget_error.Only the
accumulated_steps - warmup_stepsmeasurements after the warmup enter the estimate:N_needed = ceil(N_used * (current_error / target_error)**2).
- aiida_jqmc.statistics.crossing(values, observed, target)#
Where the piecewise-linear interpolation of
observed(values)reachestarget.The points are sorted by value. Returns the value of the first crossing between two neighbouring points (an exact hit returns that point’s value), or None when
targetis not bracketed.
- aiida_jqmc.statistics.energy_slope(energies, errors)#
Weighted least-squares slope of the energy per optimization step, and its standard error.
Model
E_k = a + b kwith weights1 / sigma_k**2(non-positive errors take the median positive error), as jqmc_workflow’s plateau criterion uses it.
- aiida_jqmc.statistics.error_of_error(error, num_blocks)#
Statistical uncertainty of an error bar estimated from
num_blocksblocks:sigma / sqrt(2 (b - 1)).For independent, normally distributed block averages the relative uncertainty of the sample standard error is about
1 / sqrt(2 (b - 1)).
- aiida_jqmc.statistics.extrapolation_error_factor(lattice_spacings, polynomial_order)#
Error bar of the
a -> 0extrapolated value relative to the (equal) error bar of each point.The fit is
E(a) = E_0 + E_2 a^2 + ... + E_{2p} a^{2p}(p = polynomial_order) by least squares with equal weights; the factor issqrt([(X^T X)^{-1}]_{00})for the design matrixX.
- aiida_jqmc.statistics.steps_to_target_error(calculation, target_error)#
Additional steps for a finished MCMC or LRDMC calculation (or its restart work chain).
The counter and the energy error come from
output_parameters, the warmup from the input of the job (jqmc’s default when not given). For a work chain pass the work chain node: its outputs are those of the last job.
- aiida_jqmc.statistics.vmc_indicators(calculations, window=10)#
Numbers a caller can use to judge a VMC optimization, over its last
windowsteps.calculationsare VMC calculations (or their restart work chains) in order, e.g. an optimization and its continuations; their steps are joined.- Returns:
steps(step numbers in the window),signal_to_noise_meanandsignal_to_noise_last(largest generalized-force S/N of each step),energy_slopeandenergy_slope_error(Ha per step), andenergy_last/energy_last_error.- Return type:
- Parameters:
- aiida_jqmc.statistics.vmc_sampling_steps_for_target_error(calculation, target_error)#
num_mcmc_stepsper optimization step for a target energy error of each VMC step.Uses the last optimization step of a finished VMC calculation (e.g. a short pilot): its sampling steps, warmup and energy error.
Orbital tiling#
Read orbital-tiling provenance from a Hamiltonian produced by jQMC.
The converter remains the sole owner of coset selection, orbital phases, normalization and supercell construction. This module only asks jQMC to deserialize its own output and translates the resulting physical structure and metadata into AiiDA data types.
- aiida_jqmc.tiling.inspect_tiled_hamiltonian(path, *, stdout='', source=None, requested=None)#
Return converter-owned tiling metadata and the physical QMC structure.
Loading and validation are delegated to the jQMC release that parses the HDF5. A non-tiled result is an error because this function is called only for a conversion that explicitly requested
tiling.
Utilities#
Helpers for preparing JqmcCalculation inputs.
- aiida_jqmc.utils.parameters_from_toml(source)#
Turn a jqmc CLI input (TOML file or dict) into
parametersfor JqmcCalculation.The
controlkeys that the plugin sets itself (restart,restart_chk,hamiltonian_h5,max_time) are removed and returned separately, so that nothing is dropped silently: the Hamiltonian becomes thehamiltonianinput, the checkpoint theparent_folderinput, andmax_timefollows from the wall time. Every other key is kept unchanged.