CP2K_methods

libra_py.CP2K_methods.CP2K_input_static(cp2k_sample_energy_input: str, project_name: str, trajectory_file: str, time_step: int)[source]

This function provides the inputs required for single point calculations used for calculation of NACs and overlap matrix. This function requires a sample CP2K input used for ENERGY calculations and the project name which will used to identify the produced cube files. :param cp2k_sample_energy_input: The CP2K sample input file for energy calculations. :type cp2k_sample_energy_input: string :param project_name: The poject name of the CP2K sample input (in &GLOBAL-> PROJECT)

This is required for identifying the cube files.

Parameters
  • trajectory_file (string) – The .xyz trajectory file obtained from previous molecular dynamics calculations

  • time_step (integer) – The time step of the single point calculation. It starts from 0.

Returns

None

libra_py.CP2K_methods.cp2k_distribute(istep, fstep, nsteps_this_job, cp2k_positions, cp2k_input, curr_job_number)[source]

Distributes cp2k jobs for trivial parallelization *** Make sure that your cp2k input file has absolute paths to the following input parameters:

BASIS POTENTIAL < any other file dependent parameter (dftd3, etc) >

Parameters
  • istep (int) – The initial time step for molecular dynamics trajectory which the user wants to start the calculations with. This paramter is set in the input file for submitting the jobs.

  • fstep (int) – The final time step for molecular dynamics trajectory which the user wants to start the calculations with. This paramter is set in the input file for submitting the jobs.

  • nsteps_this_job (int) – The number of step for the job to be distributed.

  • cp2k_positions (str) – The full path to the molecular dynamics trajectory xyz file.

  • curr_job_number (int) – The current job number.

Returns

None

libra_py.CP2K_methods.cube_file_names_cp2k(params)[source]

This function will produce the cube file names produced by CP2K both for energy calculations and molecular dynamics.

Parameters

params (dictionary) –

contains dynamical paramters

project_name ( string ): The project name used in CP2K input file.

min_band ( integer ): The minimum state number to be considered.

max_band ( integer ): The maximum state number to be considered.

curr_step ( integer ): The time current step in CP2K calculations.

isUKS ( int ): 1 if spin-polarized calculations used

Returns

The list of cube file names.

Return type

names ( list )

libra_py.CP2K_methods.ndigits(integer_number: int)[source]

This function calculates the number of digits for an integer number.

Parameters

integer_number (integer) – An integer number.

Returns

The number of digits for ‘num’.

Return type

digit_num ( integer )

libra_py.CP2K_methods.read_cp2k_tddfpt_log_file(params)[source]

This function reads log files generated from TD-DFPT calculations using CP2K and returns the TD-DFPT excitation energies, Slater determinent states in terms of the Kohn-Sham orbital indicies, and the Slater determinent coefficients that comprise the multi-configurational electronic states

Parameters

params (dictionary) –

parameters dictionary

logfile_name ( string ): name of the log file for this particular timestep

number_of_states ( int ): how many ci states to consider

tolerance ( float ): the tolerance for accepting SDs are members of the CI wavefunctions

isUKS ( Boolean ): flag for whether or not a spin-polarized Kohn-Sham basis is being used. TRUE means

that a spin-polarized Kohn-Sham basis is being used.

Returns

The excitation energies in the log file.

ci_basis ( list ): The CI-basis configuration.

ci_coefficients ( list ): The coefficients of the CI-states.

spin_components (list): The spin component of the excited states.

Return type

excitation_energies ( list )

libra_py.CP2K_methods.read_energies_from_cp2k_log_file(params)[source]

This function reads the energies from CP2K log file for a specific spin.

Parameters

params (dictionary) –

logfile_name (str): The output file produced by CP2K

time (int): The time step of the molecular dynamics. For single point calculations

it should be set to 0.

min_band (int): The minimum state number.

max_band (int): The maximum state number.

spin (int): This number can only accept two values: 1 for alpha and 2 for beta spin.

Returns

The vector consisting of the KS energies from min_band to max_band.

total_energy (float): The total energy obtained from the log file.

Return type

E (1D numpy array)

libra_py.CP2K_methods.read_energies_from_cp2k_md_log_file(params)[source]

This function reads the energies from CP2K molecular dynamics log file for a specific spin. The difference between this function and the function read_energies_from_cp2k_log_file is that it is more efficient and faster for molecular dynamics energy levels.

Parameters

params (dictionary) –

logfile_name (str): The output file produced by CP2K

init_time (int): The initial time step of the molecular dynamics.

final_time (int): The final time step of the molecular dynamics.

min_band (int): The minimum state number.

max_band (int): The maximum state number.

spin (int): This number can only accept two values: 1 for alpha and 2 for beta spin.

Returns

The vector consisting of the KS energies from min_band to max_band.

total_energy (float): The total energy obtained from the log file.

Return type

E (1D numpy array)

libra_py.CP2K_methods.read_trajectory_xyz_file(file_name: str, step: int)[source]

This function reads the trajectory of a molecular dynamics .xyz file and extract the ‘step’ th step then writes it to coord-step.xyz file. This function is used in single point calculations for calculations of the NACs where one has previously obtained the trajectory via any molecular dynamics packages.

Parameters

file_name (string) –

The trajectory .xyz file name. step (integer): The desired time to extract its .xyz

coordinates which starts from zero.

Returns

None

libra_py.CP2K_methods.state_num_cp2k(state_num: int)[source]

This function turns an integer number to a string. This string has the format in five digits and if the number of digits is less than five it will append zeros before the number. This is necessary to read the .cube files produced by CP2K.

Parameters

state_num (integer) – Integer number which is in fact the energy level.

Returns

The number in five digits (or more) in string format.

Return type

state_num_str (string)