kim_tools.vc package

Submodules

kim_tools.vc.core module

Helper routines for KIM Verification Checks

exception kim_tools.vc.core.KimpyError

Bases: Exception

A call to a kimpy function resulted in a RuntimeError being raised

kim_tools.vc.core.check_kimpy_call(vc, func, *args)

Call a kimpy function using its arguments and, if a RuntimeError is raised, catch it and raise a KimpyError with the exception's message. A VC object is optionally passed in so that, if an exception occurs, it can be echoed to the VC report as well.

(Starting with kimpy 2.0.0, a RuntimeError is the only exception type raised when something goes wrong.)

Parameters:
  • vc (VerificationCheck or None) -- An instance of the VerificationCheck class defined in kim_python_utils.vc. If None, then any error messages are printed to stdout alone without being written to the report.txt file the verification check creates.

  • f (function) -- The kimpy function that is to be called.

Raises:

KimpyError -- If the kimpy function raises a RuntimeError when called.

kim_tools.vc.core.get_kim_model_supported_species_and_codes(vc, kim_model)

Get all the supported species of a KIM model and the corresponding codes used by the model. The codes are required

Parameters:
  • vc (VerificationCheck) -- An instance of the VerificationCheck class defined in kim_python_utils.vc

  • kim_model (str) -- The KIM ID of the model

Returns:

species_map -- Keys are chemical symbol strings (e.g. "Ar") and the corresponding values are the corresponding integer codes that the model uses internally to represent these

Return type:

dict

exception kim_tools.vc.core.KIMVCError(msg)

Bases: Exception

kim_tools.vc.core.vc_stripall(string)

In "string", remove leading and trailing newlines, replace internal newlines with spaces, and remove carriage returns.

Primary purpose is to process docstring at top of VC code and convert to vc_description.

kim_tools.vc.core.vc_letter_grade_machine_precision(error, Amax=7.5, Bmax=10.0, Cmax=12.5, Dmax=15.0)

This function assigns a letter grade in the range A-D and F for fail based on the obtained 'error' as compared with the machine precision of the computation.

kim_tools.vc.core.setup_and_run_vc(do_vc, model, vc_name, vc_author, vc_description, vc_category, vc_grade_basis, vc_files, vc_debug)

Construct VerificationCheck object containing all info related to VC, and perform the VC by calling the user supplied do_vc function. The VC report and property instance re generated. If vc_debug is True, errors generate exceptions will full traceback, otherwise exceptions are trapped and an error message is reported.

class kim_tools.vc.core.VerificationCheck(vc_name, vc_author, vc_description, vc_category, vc_grade_basis, vc_files, vc_debug)

Bases: object

Features routines related to outputting VC information and results.

Initialize a VC object.

rwrite(string)

Write 'string' with appended newline to report and echo to stdout

write_results(results)

Use jinja2 to Process the template file 'results.edn.tpl' (expected in the current working directory) to replace the keys in 'results'. Place the new 'results.edn' file in a directory called 'output', creating it if it does not already exist.

write_aux_ase_atoms(aux_file, atoms, format)

Write the configuration in the ASE 'atoms' object to an auxiliary file 'aux_file' in the output directory in the specified 'format'. For supported formats, see https://wiki.fysik.dtu.dk/ase/ase/io/io.html

write_aux_x_y(aux_file, x, y)

Write a file containing the lists x and y: x[0] y[0] x[1] y[1] ... If the lists are not the same length, the shorter sets the size.

write_aux_string(aux_file, string)

Write a file containing the contents in 'string'

Module contents