cp2k / cp2k-input-tools

Fully validating pure-python CP2K input file tools including preprocessing capabilities
MIT License
45 stars 10 forks source link

Problem with phonopy, cp2k_input_tools and transitions #105

Open luizfcpe opened 3 months ago

luizfcpe commented 3 months ago

I have found an error message when building supercells with atomic displacements using a combination of phonopy (2.23.1, 2.24.1, 2.24.2), cp2k_input_tools (0.9.1, 0.8.2, 0.7.2, 0.6.0, etc) and transitions (0.8.11, 0.7.2, 0.7.0, etc), also python versions 3.8 and 3.12. I do not understand the error message below, so I will appreciate any suggestions. Thanks.

pereira@debye:~/WORK/CP2K/Force% phonopy --cp2k -c aGST_ENERGYFORCE.inp -d --dim 1 1 1 _ | | | ' | ' \ / | ' \ / \ | ' | | | | | |) | | | | () | | | | () || |) | |_| | | ./|| ||_/|| ||_() ./ \, | || || |/ 2.23.1

Compiled with OpenMP support (max 8 threads). Python version 3.12.3 Spglib version 2.3.1

Traceback (most recent call last): File "/opt/homebrew/Caskroom/miniforge/base/envs/phonopy/bin/phonopy", line 45, in main(**argparse_control) File "/opt/homebrew/Caskroom/miniforge/base/envs/phonopy/lib/python3.12/site-packages/phonopy/cui/phonopy_script.py", line 1853, in main cell_info = get_cell_info(settings, cell_filename, log_level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/phonopy/lib/python3.12/site-packages/phonopy/cui/phonopy_script.py", line 1641, in get_cell_info cell_info = collect_cell_info( ^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/phonopy/lib/python3.12/site-packages/phonopy/cui/collect_cell_info.py", line 142, in collect_cell_info unitcell, optional_structure_info = read_crystal_structure( ^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/phonopy/lib/python3.12/site-packages/phonopy/interface/calculator.py", line 472, in read_crystal_structure unitcell, config_tree = read_cp2k(cell_filename) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/phonopy/lib/python3.12/site-packages/phonopy/interface/cp2k.py", line 78, in read_cp2k tree = parser.parse(fhandle) ^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/phonopy/lib/python3.12/site-packages/cp2k_input_tools/parser.py", line 215, in parse self._parse_as_keyword(line) File "/opt/homebrew/Caskroom/miniforge/base/envs/phonopy/lib/python3.12/site-packages/cp2k_input_tools/parser.py", line 149, in _parse_as_keyword kw = Keyword.from_string(kw_node, kw_value, self._key_trafo) # the key_trafo is needed to mangle keywords ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/phonopy/lib/python3.12/site-packages/cp2k_input_tools/keyword_helpers.py", line 106, in from_string tokens = tokenize(vstring) ^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/phonopy/lib/python3.12/site-packages/cp2k_input_tools/tokenizer.py", line 129, in tokenize char_map.get(char, tokenizer.token_char)(string, colnr) File "/opt/homebrew/Caskroom/miniforge/base/envs/phonopy/lib/python3.12/site-packages/transitions/core.py", line 405, in trigger return self.machine._process(func) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/phonopy/lib/python3.12/site-packages/transitions/core.py", line 1079, in _process return trigger() ^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/phonopy/lib/python3.12/site-packages/transitions/core.py", line 421, in _trigger raise MachineError(msg) transitions.core.MachineError: "Can't trigger event quote_char from state comment!"

luizfcpe commented 3 months ago

For the record, I get the same error message on RedHat Enterprise Linux 7 and Mac OS Sonoma 14.3.1

luizfcpe commented 3 months ago

Ok, so I can run the NaCl example that comes with phonopy. I should have checked that before. Nonetheless, my input file aGST_ENERGY_FORCE.inp runs fine in CP2K 2024.1. Perhaps there is something in that file that transitions or cp2k_input_tools do not like, although it is within the syntax rules of CP2K. Any advice is highly appreciated.

luizfcpe commented 3 months ago

Found the problem. One of the comments contained quotation marks "". For some reason transition didn't like that, even though CP2K accepts this type of thing.