aiida-cp2k icon indicating copy to clipboard operation
aiida-cp2k copied to clipboard

How to set multiple basis set files in aiida-cp2k builder

Open sylviancadars opened this issue 4 years ago • 4 comments

Hi, I am trying to execute via aiidza-cp2k an example of CP2K calculation wherein the sample input file points to 2 distinct basis set files in the [DFT] section :

BASIS_SET_FILE_NAME [REMOTE_CP2K_DADA_DIR]/GTH_BASIS_SETS BASIS_SET_FILE_NAME [REMOTE_CP2K_DADA_DIR]/BASIS_MOLOPT_UCL POTENTIAL_FILE_NAME [REMOTE_CP2K_DADA_DIR]/GTH_POTENTIALS

I would like to re-define these 2 basis set files within the aiida-cp2k builder. I tried the following, which did not work :

from aiida.orm import (Code, Dict, SinglefileData)

localCP2KDataDir = r'[lOCAL_CP2K_DADA_DIR]' basis_files = [ SinglefileData(file=os.path.join(localCP2KDataDir,'GTH_BASIS_SETS')) , SinglefileData(file=os.path.join(localCP2KDataDir,'BASIS_MOLOPT_UCL')) ] pseudo_file = SinglefileData(file=os.path.join(localCP2KDataDir,'GTH_POTENTIALS'))

cp2k_code = Code.get_from_string('[MY_CP2K_VERSION]@[MY_REMOTE_COMPUTER]) builder = cp2k_code.get_builder()

builder.file = { 'basis': basis_file, 'pseudo': pseudo_file }

It seems that the builder does not accet a list as the value to the 'basis' key.

Is there a way to do this ?

Thank you very much for your help. Best wishes.

Sylvian.

sylviancadars avatar May 03 '21 08:05 sylviancadars

builder.file is a port namespace. What this means is that the input has to be a dict, where the keys are strings of the form [a-zA-Z0-9_] (if I remember correctly) and the values have to be either a SinglefileData or a StructureData instance. Hence a list of either SinglefileData or StructureData are not allowed. But for SinglefileData the key is actually not used, so what you can do is this for a list of files:

builder.file = {
  'pseudo': pseudo_file,
  **{f'basis{idx}': singlefile for idx, singlefile in enumerate(basis_files)},
}

dev-zero avatar May 07 '21 13:05 dev-zero

Hi Tiziano, Thank you very much for the clarification and for the suggestion. And interesting side effect : having a limited experience with python, I've learned a lot in the process of understanding the syntax ! Best wishes. Sylvian

sylviancadars avatar May 10 '21 17:05 sylviancadars

Sorry to insist, but it seems, however, that the aiida-cp2k builder is not able to deal with the resulting dict :

builder.file = { 'pseudo': pseudo_file, 'basis0': BASIS_SINGLEFILE_0, 'basis1': BASIS_SINGLEFILE_1, }

At least this is what I infere from the absense of BASIS_SET_FILE_NAME and POTENTIAL_FILE_NAME sections in the aiida.inp file generated on the remote server.

Am I correct ? If this is true, is there any chance this can be fixed ?

Thanks. Best wishes.

Sylvian

sylviancadars avatar May 10 '21 17:05 sylviancadars

well, the build.file is a general endpoint, it only tells aiida-cp2k to upload the files, but it can't infer what you want to do with them, so you have to add those in the parameter section yourself. Can you verify that the files have at least been uploaded?

Alternatively you can look into my aiida-gaussian-datatypes which make the basisset and pseudopotential management a bit more explizit, but will also write the basis set files.

dev-zero avatar May 10 '21 19:05 dev-zero