Update file gaussian.py: Allow gjf files to be read in without raising an exception if the gjf file contains charges and multiplcities of fragments
Description of merge request:
Currently, ASE will only read Gaussian gjf files that have a charge and multiplicity for the total system. However, this line can contain the charge and multiplicity of fragments (https://gaussian.com/molspec).
To allow ASE to read this line even if the line contains charges and multiplicities of fragments, the _re_chgmult
pattern has been modified to accept any even number of integers.
Details:
This is achieved by including {1,}
at the end of the line for the _re_chgmult
variable in gaussian.py
, which means the pattern will accept any line that contains any repeated pattern of (\s*[+-]?\d+(?:,\s*|\s+)[+-]?\d+\s*)
See https://docs.python.org/3/library/re.html --> {m,n} for a description of this addition to the pattern.
NOTE: I haven't bothered to allow the _get_charge_mult
method to do anything with the fragment charges and multiplicity. For me, I just need these types of inputs in the Gaussian gjf
file to be read in without raising an Exception. Currently, ASE raises an exception if more than 2 integers are given, so this update will allow ASE to accept any even number of integers as the charge+multiplicity line.