repESP.respin_generation module¶
Creating resp program input for predefined ESP fitting types
This module may be useful if you require custom instructions for the resp
program. Otherwise, the functions in the resp_wrapper module should be
sufficient and more convenient.
-
class
RespinGenerator[source]¶ Bases:
abc.ABCInterface for creators of
respfitting instructionsThis interface will be implemented differently for different types of fitting with the
respprogram. This module provides implementations for the most common fitting types.An implementation of this interface is required by the prepare_respin function.
-
class
RespRespinGenerator(ivary: repESP.respin_format.Respin.Ivary)[source]¶ Bases:
repESP.respin_generation.RespinGeneratorBase class providing “respin” creation methods for RESP charges
-
get_ivary() → repESP.respin_format.Respin.Ivary[source]¶ Create the “ivary” section of the “respin” file
-
classmethod
from_respin(respin: repESP.respin_format.Respin) → RespRespinGeneratorT[source]¶ Alternative initialization from a “respin” file
This alternative initializer expresses the fact that this object can be created directly from an existing “respin” file, when the contained “ivary” section expresses the desired per-atom fitting instructions.
Parameters: respin (Respin) – An object representing pre-existing instructions to the respprogram.
-
classmethod
from_methyl_and_methylene(equivalence: repESP.equivalence.Equivalence, methyl_methylene_mask: List[bool]) → RespRespinGeneratorT[source]¶ Alternative initialization from chemical information
The per-atom fitting instructions in the RESP charge optimization depend on the chemical equivalence and whether a given carbon or hydrogen atom belongs to a methyl or methylene group.
Parameters: - equivalence (Equivalence) – The chemical equivalence relations between atoms in the molecule.
- methyl_methylene_mask (typing.List[bool]) – A list, in which each value describes an atom of the molecule. The value should be True when the atom is a carbon or hydrogen atom in a methyl or methylene group and False otherwise.
Raises: ValueError– Raised when the length of the values attribute of the equivalence argument is not equal to the length of the methyl_methylene_mask argument.
-
-
class
RespStage1RespinGenerator(ivary: repESP.respin_format.Respin.Ivary)[source]¶ Bases:
repESP.respin_generation.RespRespinGeneratorCreator of “respin” files for 1st stage RESP fitting
The original RESP procedure is conducted in two stages and this object prepares the input for the first stage. In this stage, carbon and hydrogen atoms in methyl and methylene groups vary freely, while other atoms need to obey chemical equivalence relations. The magnitudes of charges on all atoms are constrained with hyperbolic constraints with a weight factor of 0.0005.
Parameters: ivary (Respin.Ivary) – The “ivary” section of a “respin” file for 1st stage RESP fitting.
-
class
RespStage2RespinGenerator(ivary: repESP.respin_format.Respin.Ivary)[source]¶ Bases:
repESP.respin_generation.RespRespinGeneratorCreator of “respin” files for 2nd stage RESP fitting
The original RESP procedure is conducted in two stages and this object prepares the input for the second stage. In this stage, carbon and hydrogen atoms in methyl and methylene groups are varied subject to equivalence relations and the magnitudes of the charges are constrained with hyperbolic constraints with a weight factor of 0.001. Other atoms are frozen at initial charge values, which should come from 1st stage fitting.
Parameters: ivary (Respin.Ivary) – The “ivary” section of a “respin” file for 2nd stage RESP fitting.
-
class
FitHydrogensOnlyRespinGenerator(equivalence: repESP.equivalence.Equivalence, molecule: repESP.types.Molecule[repESP.types.Atom][repESP.types.Atom])[source]¶ Bases:
repESP.respin_generation.RespinGeneratorSupports creation of “respin” files for fitting only hydrogen atoms
The generated “respin” file instructs
respto perform fitting in which only hydrogen atoms are free to vary, subject to equivalence relations.Parameters: - equivalence (Equivalence) – The equivalence relations between atoms of the molecule.
- molecule (Molecule[Atom]) – The molecule which charges are being fitted. Only atom identities are required.
-
class
EquivalenceOnlyRespinGenerator(equivalence: repESP.equivalence.Equivalence)[source]¶ Bases:
repESP.respin_generation.RespinGeneratorSupports creation of “respin” files with no constraints beyond equivalence
The generated “respin” file instructs
respto perform fitting in which atoms are free to vary, subject only to equivalence relations.Parameters: equivalence (Equivalence) – The equivalence relations between atoms of the molecule.
-
class
FrozenAtomsRespinGenerator(equivalence: repESP.equivalence.Equivalence, frozen_atoms: List[int])[source]¶ Bases:
repESP.respin_generation.RespinGeneratorSupports creation of “respin” files excluding selected atoms from fitting
The generated “respin” file instructs
respto perform fitting in which atoms are free to vary (subject to equivalence relations) unless they are explicitly excluded from the fitting by being listed in the frozen_atoms argument.Parameters: - equivalence (Equivalence) – The equivalence relations between atoms of the molecule.
- frozen_atoms (typing.List[int]) – List of zero-based indices of atoms in the molecule which are to be excluded from the fitting.
-
prepare_respin(respin_generator: repESP.respin_generation.RespinGenerator, total_charge: int, molecule: repESP.types.Molecule[repESP.types.Atom][repESP.types.Atom], title: Optional[str] = None, subtitle: Optional[str] = None, read_charges: bool = False) → repESP.respin_format.Respin[source]¶ Create
respprogram instructions based on input optionsThis function allows to create
respprogram instructions from higher-level abstractions.Parameters: - respin_generator (RespinGenerator) – An object implementing the RespinGenerator interface.
This object expresses a given type of charge fitting through
instructions understood by
resp. Implementations of this interface for common fitting types are provided in this module. - total_charge (int) – The total charge of the molecule.
- molecule (Molecule[Atom]) – The molecule which charges are being fitted. Only atom identities are required.
- title (Optional[str], optional) – The title for the optimization. If set to None (default), a default title will be used, referencing the repESP library and the type of the fitting as given by the respin_generator used.
- subtitle (Optional[str], optional) – The subttitle for the fitted structure. If set to None (default), a default generic subtitle will be used.
- read_charges (bool, optional) –
If this option is set to True,
respwill require initial charges for the fitting. Defaults to False.Note
It is the responsibility of the respin_generator to instruct
respto read initial charges when they affect the result of the optimization. This parameter should only be used when the user wishes to aid the optimization by supplying an initial guess.
Returns: An object representing the fitting instructions for the
respprogram.Return type: - respin_generator (RespinGenerator) – An object implementing the RespinGenerator interface.
This object expresses a given type of charge fitting through
instructions understood by