Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sylviancadars opened this issue May 3, 2021 · 4 comments
Open

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

sylviancadars opened this issue May 3, 2021 · 4 comments

Comments

@sylviancadars
Copy link

sylviancadars commented May 3, 2021

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.

@dev-zero
Copy link
Contributor

dev-zero commented May 7, 2021

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)},
}

@sylviancadars
Copy link
Author

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
Copy link
Author

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

@dev-zero
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants