Tutorial 9: Working with HDF5 files

Learning Goals
  • Create HDF5 file to store all information
  • Read HDF5 for evaluation
Tip

Keep in mind that you can speed up simulations by using multiple threads as described in the Using Multithreading with VSCode section.

Input File Setup

While interactively working with RSA simulations is often a first step, productions runs are usually performed on high-performance computing centers and require the results to be stored. For this you must use the HDF5 features of this packaged. In this way you enable yourself to evaluate the RSA simulations at a later point and in addition are able to upload your data for any publication. Within this tutorial you can use the coordinates of Pyridine from the Molecule Library. The main input file is identical to previous tutorials:

# Adsorption on Cu(111)
Molecule
    rotationmodus = angle
    rotationangle = 60.0
    fixpointtype = atoms
    fixpointatoms = 1
    structure = ...ADJUST-YOUR-PATH.../pyridine-upright.xyz
End

Molecule
    rotationmodus = angle
    rotationangle = 60.0
    fixpointtype = atoms
    fixpointatoms = 1
    structure = ...ADJUST-YOUR-PATH.../pyridine-tilted.xyz
End

# Lattice of the Cu(111) surface
Lattice
    transx = 30
    transy = 18
    
    vectors
        2.51883   0.00000   0.00000
        0.00000   4.36274   0.00000
        0.00000   0.00000   1.00000
    end
End

# On-top grid points of the Cu(111) surface
Grid
    points
        0.00000   0.00000   0.00000
        1.25942   2.18137   0.00000
    end
End

# General settings for adsorption of pyridine  
Events
    steps = 1000
    #coverageconvergence = 100
    #forceadsorption = 25

    eventlist
	    1 ads 1 1.0
        2 ads 1 1.0
        1 con 2 1 10.0
    end
End

Running the Simulation

To start the simulations you still use the perform_multiple_rsa_runs function but this time with the optional hdf5 flag enabled:

NRuns = 1000
inputfile_path = "...ADJUST-YOUR-PATH.../input.inp"
rsa_results, Nmolecules, molecules, Ngrids, grids, lattice, events, timings = perform_multiple_rsa_runs(NRuns, inputfile_path, hdf5 = true);

This time a "h5" file is created storing all information of the RSA simulations - for the naming the "inp" ending of your input file is replaced with "h5".

Evaluation

The evaluation of the RSA simulations is identical to previous tutorials. The main difference is, that information are read from the previously created HDF5 file by using the read_hdf5_output_file function:

hdf5_file = "...ADJUST-YOUR-PATH.../input.h5"
rsa_results, Nmolecules, molecules, Ngrids, grids, lattice, events, timings = read_hdf5_output_file(hdf5_file);
histo, mean, variance, minvalue, minvalue_id, maxvalue, maxvalue_id, avgvalue, avgvalue_id = plot_count_area_histograms(NRuns, rsa_results, Nmolecules, molecules, lattice, plotonly = false, area = 0.6);
avgvalue_id[6]
surfaceplot = plot_RSA_run(rsa_results[ID of most average run].status, Ngrids, grids, Nmolecules, molecules, lattice)
Info

This package is never deleting or replacing an existing HDF5 file. It is your responsibility as a user to ensure that every RSA run can create a new HDF5 file.