Source code for geom.functions.output

import sys

# -------------------------------------------------------------------------------------
[docs] def error(error_message): """ Prints an error message and terminates execution. Args: error_message (str): The error message to be displayed. Returns: None: The function exits the program. """ print("") print("") print(" ERROR: " + error_message) print("") print("") sys.exit()
# -------------------------------------------------------------------------------------
[docs] def warn(warning_message): """ Prints an warning message and terminates execution. Args: warn_message (str): The warning message to be displayed. Returns: None: The function prints a warning message. """ print("") print("") print(" WARNING: " + warning_message) print("") print("")
# -------------------------------------------------------------------------------------
[docs] def error_dir_axis(dir_axis_input): """ Prints an error message related to an unsupported axis input and exits. Args: dir_axis_input (str): The invalid direction axis input. Returns: None: The function exits the program. Notes: - Accepted values: `+x`, `+y`, `+z`, `-x`, `-y`, `-z`. """ print(' ') print(' ERROR: Sense or direction axis "' + dir_axis_input + '" not supported') print(' ') print(' Options:') print(' --------') print(' +x, +y, +z') print(' -x, -y, -z') print(' ') sys.exit()
# -------------------------------------------------------------------------------------
[docs] def logfile_init(): """ Initializes and opens a logfile for writing. Returns: file object: An open logfile in write mode (`logfile.txt`). """ out_log = open('results_geom/logfile.txt','w') return(out_log)
# -------------------------------------------------------------------------------------
[docs] def logfile_close(out_log): """ Closes the logfile. Args: out_log (file object): The logfile object to close. Returns: None """ out_log.close() return(out_log)
# ------------------------------------------------------------------------------------- # ------------------------------------------------------------------------------------- # ------------------------------------------------------------------------------------- # ------------------------------------------------------------------------------------- # ------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------
[docs] def save_distance_opt(out_log,distance,dist_new,dir_axis_input): """ Saves the optimized distance information in the logfile. Args: out_log (file object): The logfile object. distance (float): The initial distance target. dist_new (float): The final achieved distance. dir_axis_input (str): The translation or rotation axis. Returns: None """ out_log.write(f"\n" f" {' ------ Optimizing d =':>22} {distance:20.8f} {'Å ------ ':>12}\n\n") out_log.write(f" {' Convergence achieved to distance':>34} {dist_new:20.8f} {'Å':>5}\n\n\n")
# ------------------------------------------------------------------------------------- # ------------------------------------------------------------------------------------- # ------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------