pyiron_base.jobs.flex.executablecontainer module
- class pyiron_base.jobs.flex.executablecontainer.ExecutableContainerJob(project, job_name)
Bases:
TemplateJob
The ExecutableContainerJob is designed to wrap any kind of external executable into a pyiron job object by providing a write_input(input_dict, working_directory) and a collect_output(working_directory) function.
Example:
>>> import os >>> >>> def write_input(input_dict, working_directory="."): >>> with open(os.path.join(working_directory, "input_file"), "w") as f: >>> f.write(str(input_dict["energy"])) >>> >>> >>> def collect_output(working_directory="."): >>> with open(os.path.join(working_directory, "output_file"), "r") as f: >>> return {"energy": float(f.readline())} >>> >>> >>> from pyiron_base import Project >>> pr = Project("test") >>> pr.create_job_class( >>> class_name="CatJob", >>> write_input_funct=write_input, >>> collect_output_funct=collect_output, >>> default_input_dict={"energy": 1.0}, >>> executable_str="cat input_file > output_file", >>> ) >>> job = pr.create.job.CatJob(job_name="job_test") >>> job.input["energy"] = 2.0 >>> job.run() >>> print(job.output) DataContainer({'energy': 2.0})
- collect_output()
Collect the output files of the external executable and store the information in the HDF5 file. This method has to be implemented in the individual hamiltonians.
- from_dict(job_dict)
- run_static()
The run static function is called by run to execute the simulation.
- set_job_type(executable_str, write_input_funct=None, collect_output_funct=None, default_input_dict=None)
Set the pre-defined write_input() and collect_output() function plus a dictionary of default inputs and an executable string.
- Parameters:
executable_str (str) – Call to an external executable
write_input_funct (callable) – The write input function write_input(input_dict, working_directory)
collect_output_funct (callable) – The collect output function collect_output(working_directory)
default_input_dict (dict/None) – Default input for the newly created job class
- Returns:
Function which requires a project and a job_name as input and returns a job object
- Return type:
callable
- to_dict()
- write_input()
Write the input files for the external executable. This method has to be implemented in the individual hamiltonians.