The Snakefile sets up a series of rules for calculation. It decomposes the workflow into small steps. We only need to specify the filename of final output, and the Snakefile will figure out the rule which outputs this filename. And it will look for the inputs of this rule. If there is no input available in the directory, but are rules that can generate these inputs. It will automatically run these rules to make inputs first. The rules in Snakefile are written in order.
We will step through a VMC calculation for molecule H2 with bond length r=1.4 and basis ccpvtz.
First we need to initiate the file {dir}/geom.xyz.
{dir}=h2_1.4/hf/vtz
We used to name directories in this way, so we can use gather.py later to deal with data.
And geom.xyz should contain
H 0. 0. 0.
H 0. 0. 1.4
We choose the starting wavefunction for VMC to be generated by Restricted Hartree-Fork using pyscf in rule MEAN_FIELD. If we want the starting wavefunction from Unrestricted Hartree-Fork, we should name {dir}=h2_1.4/uhf/vtz.
The rule OPTIMIZE_MF and rule OPTIMIZE_HCI optimize the starting wavefunction for VMC.
For rule OPTIMIZE_MF, we need to specify variables for the output.
{variables}={startingwf}_{orbitals}_{statenumber}_{nconfig}
rule VMC will take the same variables.
rule VMC:
input: mf = "{dir}/mf.chk", opt = "{dir}/opt_{variables}.chk"
output: "{dir}/vmc_{variables}.chk"
run:
#calculations#
In the calculations it will call functions in functons.py, which import functions from pyscf and pyqmc.
As talked before, rule VMC will automatically look for the inputs. Therefore, it will run
rule DEFAULT_SETTINGSrule MEAN_FIELDrule OPTIMIZE_MF
in order before rule VMC.
We can run the following command
snakemake.snakemake("Snakefile",cores=1,targets=["h2_1.4/hf/vtz/vmc_mf_orbitals_0_400.chk"])
In run_workflow.py, we generate a list of filenames. We only need to call Snakemake once, by replacing with targets=[list of filenames].
We also have rule CC, rule HCI, rule DMC, etc. The calculations will be done similar to VMC.
The gather.py will gather and calculate data such as energy and entropy from the outputs(.chk files) and generate a csv file. See more details in shunyue's or Nirvaan's branch.