CP2K¶
This module is used to call CP2K simulation and parse its output The user need to supply a complete input script with ENERGY_FORCE or ENERGY runtype, and CELL, COORD blocks. Example scripts can be found in tests/test_files/cp2k_input…
The module will copy the input template to a new file with “_run” suffix, edit the atomic coordination in the COORD blocks and run the similation with the parallel set up given.
We note that, if the CP2K executable is only for serial run, using it along with MPI setting can lead to repeating output in the output file, wrong number of forces and error in the other modules.
-
flare.dft_interface.cp2k_util.
dft_input_to_structure
(dft_input: str)¶ Parses a qe input and returns the atoms in the file as a Structure object :param dft_input: input file to parse :return: atomic structure
-
flare.dft_interface.cp2k_util.
edit_dft_input_positions
(dft_input: str, structure)¶ Write the current configuration of the OTF structure to the qe input file
Parameters: - dft_input – intput file name
- structure (class Structure) – structure to print
Return newfilename: the name of the edited intput file. with “_run” suffix
-
flare.dft_interface.cp2k_util.
parse_dft_forces
(outfile: str)¶ Get forces from a pwscf file in eV/A
Parameters: outfile – str, Path to dft.output file Returns: list[nparray] , List of forces acting on atoms
-
flare.dft_interface.cp2k_util.
parse_dft_forces_and_energy
(outfile: str)¶ Get forces from a pwscf file in eV/A the input run type to be ENERGY_FORCE
Parameters: outfile – str, Path to dft.output file Returns: list[nparray] , List of forces acting on atoms Returns: float, total potential energy
-
flare.dft_interface.cp2k_util.
parse_dft_input
(dft_input: str)¶ Parse CP2K input file prepared by the user the parser is very limited. The user have to define things in a good format. It requires the “CELL”, “COORD” blocks
Parameters: dft_input – file name Returns: positions, species, cell, masses
-
flare.dft_interface.cp2k_util.
run_dft_en_par
(dft_input: str, structure, dft_loc: str, n_cpus: int, dft_out: str = 'dft.out', npool: int = None, mpi: str = 'mpi', **dft_kwargs)¶ run DFT calculation with given input template and atomic configurations. This function is not used atm.
Parameters: - dft_input – input template file name
- structure – atomic configuration
- dft_loc – relative/absolute executable of the DFT code
- n_cpus – # of CPU for mpi
- dft_out – output file name
- npool – not used
- mpi – not used
- **dft_wargs –
not used
Returns: forces, energy
-
flare.dft_interface.cp2k_util.
run_dft_par
(dft_input, structure, dft_loc, n_cpus=1, dft_out='dft.out', npool=None, mpi='mpi', **dft_kwargs)¶ run DFT calculation with given input template and atomic configurations. if n_cpus == 1, it executes serial run.
Parameters: - dft_input – input template file name
- structure – atomic configuration
- dft_loc – relative/absolute executable of the DFT code
- n_cpus – # of CPU for mpi
- dft_out – output file name
- npool – not used
- mpi – not used
- **dft_wargs –
not used
Returns: forces