3. Generating a JSON input file#
SAFIRE uses an input file in .json format to set parameters in calculations. This example covers generating a .json input file for AFQMC. It assumes that you already have an HDF5 file containing a Hamiltonian and trial wavefunction. If not, see the examples in Setting Up AFQMC.
For demonstration, it is assumed that a Hamiltonian exists in an HDF5 file called afqmc_ham.h5 and a trial wavefunction is saved in an HDF5 file called afqmc_wfn.h5. Of course, the Hamiltonian and wavefunction can exist within the same HDF5 file if desired.
The input file is explained in detail in Input file. We can use the afqmctools Python module to generate one for us using the same keywords as in the input file. In the example below, we show how to set the “execute” block parameters with all possible options explicitly enumerated with the exception of the “estimator” block(s). Each type of “estimator” block has it’s own set of possible arguments.
from afqmctools.inputs.from_hdf import write_json
# these will be written to the "execute" block
# in the .json input file using the same keywards
# as in the .json format
# Here are all of the possible inputs for the "execute" block
# *except* for the "estimator" key which has additional internal options.
afqmc_execution_options = {
"timestep": 0.01,
"steps": 10000,
"population_control_interval" : 10, # in units of steps
"measure_interval_multiplier": 1, # measurement interval = measure_interval_multiplier * population_control_interval
"walker_ortho_interval" : 10 , # in units of steps
"n_walkers_per_mpi_task": 10,
"seed" : 42,
"estimator": {
"name": "energy",
"overwrite": True,
"print_components": True
}
}
write_json(
"afqmc.json",
fwfn0="afqmc_wfn.h5",
fham0="afqmc_ham.h5",
exec_opts=afqmc_execution_options
)
print("Done")
Note that all intervals are expressed in units of “steps”. Running the example Python script above will generate a file called afqmc.json with the following content:
See Basic Ground State Energy with CPU build for an example of running AFQMC given an input file.