When I run a VASP calculation in a workchain, it uploads the INCAR, KPOINTS, POSCAR, POTCAR, and submission files to the supercomputer and launches the calculation. I would like to know if there’s an easy way to add another file to this specific directory, such as using a SingleFileNode. Specifically, I am trying to perform a Lobster calculation using the VASP outputs and need to write the lobsterin file to this directory.
The only workaround I have found so far is to use builder.append_text to create the file in bash format (cat << EOF > lobsterin …) after the execution of VASP and then launch the Lobster code. While this method works, it is somewhat sluggish and troublesome to maintain and scale up.
Any suggestions or insights would be greatly appreciated.
Unless the VASP plugin explicitly provides an input namespace to add additional files to write to the working directory, there isn’t really a better solution. It is not provided by the CalcJob base class of aiida-core.
You mention you don’t just need to upload additional files for VASP itself, but are really running a post-processing tool in the same working directory after the VASP run finishes. Is there a reason you want to run the post-processesing tool in the same job and not just run a separate job afterwards? Then you can upload whatever file you want.
Well, in the specific case I’m trying I do not know how to run it in a separate job, because it is another program that I need to run and there’s no plugin for it yet. I want to run the ‘lobster’ binary (for a COHP calculation http://www.cohp.de/) on the same directory as I ran the VASP calculation. So my idea was to add an append after the ‘mpirun … vasp_std’ in the submission script. The thing is, I also need to specify the ‘lobsterin’ file in this directory. Is there a better way to do this?
I see the problem now. Yes, there is a better way to run the lobster binary. You can use aiida-shell, an AiiDA plugin that allows running any executable without writing dedicated plugins. Just install it with
pip install aiida-shell
I don’t know the specifics of lobster, but you would use it something like the following:
from aiida_shell import launch_shell_job
vasp_calculation_node = .... # Here you run your VASP calculation
lobster_input = """
LOBSTER INPUT FILE HERE
"""
results, node = launch_shell_job(
'lobster', # Just requires that `lobster` binary is in the PATH on the remote,
# Here you can optionally add any command line arguments.
# Not sure if the input file is defined through an option but
# just sketching this as an example.
arguments='-in {input_file}',arguments for lobster
nodes={
# Define the input script. It is automatically copied as a
# file to the working directory and replaces the filename in
# the command line arguments
'input_file': SinglefileData.from_string(lobster_input),
# Pass the remote folder of the VASP calculation and aiida-shell
# will copy the files to the working directory of lobster
'remote_folder': vasp_calculation_node.outputs.remote_folder,
},
metadata={
# Define the target computer to be the one of the VASP calculation
'computer': vasp_calculation_node.inputs.code.computer
}
)
Note that in this example I use aiida-shell to run lobster on the same computer, but you don’t have to. You could also retrieve the necessary files and run it locally. Depends on how big the files are and how heavy lobster is to run.