API Documentation

class factorpol.alphas_training.AlphasTrainer(workers: List[AlphaWorker], prior: Polarizability, working_directory: str = '/home/docs/checkouts/readthedocs.org/user_builds/factorpol/checkouts/latest/docs/data_alphas')[source]

Top level optimizer to train polarizability parameters

Parameters:
  • workers (List[AlphaWorker]) – A list of AlphaWorker

  • prior (Polarizability) – Initial polarizability

  • working_directory (str) – The path to the working directory

optimize(bounds, num_cpus=8)[source]

Distribute the optimization process with Ray

Parameters:
  • bounds (tuple) – The bounds of each polarizability type

  • num_cpus (int) – The number of CPUs available for optimization

Return type:

Returns the result object of optimizer.

worker(input_data: ndarray)[source]

A method to compute the loss

Parameters:

input_data (ndarray) – Polarizability solved from the previous optimization

Return type:

Returns the optimizer output object.

class factorpol.alphas_training.AlphaData(database_name: str, dataset: List[str], off_forcefield: ForceField, polarizability: Polarizability, num_cpus: int = 8)[source]

A class to prepare reference QM ESPs for optimization of polarizability

Parameters:
  • database_name (str) – The name of database to query

  • dataset (List[str]) – A list of molecules to query

  • off_forcefield (ForceField) – An OpenFF Force Field to specify SMIRNOFF patterns

  • polarizability (Polarizability) – A polarizability library

  • num_cpus (int) – The number of process to initialize to generate relevant data

class factorpol.alphas_training.AlphaWorker(record: MoleculeESPRecord, off_forcefield: ForceField, polarizability: Polarizability, coulomb14scale: float = 0.5)[source]

A class used to derive polarizability from QM ESPs.

Parameters:
  • record (MoleculeESPRecord) – QM reference record

  • off_forcefield (ForceField) – OpenFF force field to handle SMIRNOFF typing of polarizabilities

  • polarizability (Polarizability) – Input polarizabilities

  • coulomb14scale (float) – Scaling factor to scale Coulomb 1-4 interactions

class factorpol.bcc_training.BccTrainer(training_set: List[MoleculeESPRecord], polarizability: Polarizability, reference_collection: BCCCollection, off_forcefield: ForceField)[source]

A class to train BCC parameters with polarizabilities

Parameters:
  • training_set (List) – A list of molecules to train

  • polarizability (Polarizability) – Input polarizabilities

  • reference_collection (BCCCollection) – BCC parameters to generate AM1-BCC-dPol charges.

  • off_forcefield (ForceField) – Label atoms in molecule based on the input OpenFF force field

classmethod generate_charges(offmol: Molecule, bcc_collection: BCCCollection) ndarray[source]

This method is used to generate AM1-BCC-dPol partial charges on an OpenFF Molecule object.

Parameters:
  • offmol (Molecule) – The OpenFF molecule to generate partial charges for.

  • bcc_collection (BCCCollection) – A collection of BCC parameters

Returns:

Returns AM1-BCC-dPol partial charges, shape = (natoms)

Return type:

ndarray

training() Dict[source]

Train new BCCs with polarizability against baseline QM ESPs

Returns:

Returns the trained BCC result in a dictionary

Return type:

Dict

class factorpol.charge_training.ChargeTrainer(record: MoleculeESPRecord, polarizability: Polarizability, off_forcefield: ForceField, coulomb14scale: float = 0.5)[source]

A Class contains all information needed to do ESP-fitting related calculations.

All operations use atomic unit

Parameters:
  • record (MoleculeESPRecord) – MoleculeESPRecord contains all EPS-fitting related reference data.

  • polarizability (Polarizability) – Polarizabilities for all polarizability related operation

  • off_forcefield (ForceField) – An OpenFF ForceField used for labeling SMIRNOFF patterns.

  • coulomb14scale (float) – A scaling factor to scale 1-4 coulomb interactions. Default is 0.5 Commonly used values include 0.83333

calc_Esps(partial_charge: ndarray) ndarray[source]

A method to compute Coulomb potentials generated by permanent partial charges

\[V_{i} = \sum_{j=1}^{n} \frac{q_{j}}{r_{ij}}\]
Parameters:

partial_charge (ndarray) – Input partial charges to generate ESPs on grid points.

Returns:

Returns computed ESPs without polarizability.

Return type:

ndarray

calc_Esps_dpol(partial_charge: ndarray) Tuple[source]

Calculate Coulomb potentials on grid points using polarizabilities and input partial charges.

Parameters:

partial_charge (np.ndarray) – Input partial charges to compute ESPs on grid points.

Returns:

Total EPSs, ESPs from induced dopoles.

Return type:

ndarray, ndarray

calc_Esps_mpol(partial_charge: ndarray) Tuple[source]

Calculate Coulomb potentials using mutual polarization

\[{\mathbf{\mu}_{ind,j}} = {\alpha_j} {\mathbf{E}_j}\]

Electric field produced by induced dipole moments:

\[\mathbf{E}_{\mu} = \frac{1}{\mathbf{r}^3}[(3\mathbf{\mu}\cdot r) r - \mathbf{\mu}]\]
Parameters:

partial_charge (ndarray) – Input partial charges to compute MM ESPs on grid points

Returns:

Total ESPs and ESPs generated by induced dipoles

Return type:

ndarray, ndarray

calc_molecular_dipoles(partial_charges: ndarray) Quantity[source]

Compute molecular dipole moment

Parameters:

partial_charges (ndarray) – Input partial charges to calculate molecular dipole moments

Returns:

Returns molecular dipole moment.

Return type:

pint.Quantity

calc_molecular_dipoles_dpol(partial_charges: ndarray) Quantity[source]

Compute molecular dipole moments with polarizability and permanent partial charges

\[\mu = \sum_{j=1}^{n}(q_j + \mu_\mathrm{ind, j})~\mathrm{r}_j\]
Parameters:

partial_charges (ndarray) – Input partial charges to calculate molecular dipole moments

Returns:

Returns molecular dipole moment.

Return type:

pint.Quantity

derive_resp_dpol(pre_charge: ndarray) Tuple[source]

Derive RESP-dPol partial charges from baseline QM ESPs.

\[\chi^2 = \sum_{i=1}^{m} (V_{\mathrm{QM, i}} - V_{\mathrm{perm, i}} - V_{\mathrm{ind, i}}) + \lambda({\sum}_{j=1}^{n}q_j - q_{\mathrm{tot}}) + a\sum_{j=1}^{n}(\sqrt{q_j^2 + b^2} - b)\]

first stage: a = 0.005 a.u., b = 0.1 a.u.

second stage: a = 0.01 a.u., b = 0.1 a.u.

Parameters:

pre_charge (ndarray) – Plain ESP charges as a starting point

Returns:

matrix, vector, solution

Return type:

ndarray, ndarray, ndarray

forced_symmetry_esp_charges() Tuple[source]

Derived ESP-fitting partial charges from baseline QM ESPs with forced symmetry

Returns:

matrix, vector, solution

Return type:

ndarray, ndarray, ndarray

property mm_base_esps: Quantity
Returns:

Calculated MM ESPs without polarizability

Return type:

pint.Quantity

property mm_dpol_esps: Quantity
Returns:

Calculated MM ESPs with polarizability

Return type:

pint.Quantity

plain_esp_charges() Tuple[source]

Derive unconstrained ESP-fitting charges from baseline QM ESPs.

Returns:

matrix, vector, solution

Return type:

ndarray, ndarray, ndarray

property polar_region: List

A method used to select polar region for the second stage RESP-dPol fit.

Returns:

Returns a list of atoms that are defined as in polar region.

Return type:

List

property resp_dpol: Quantity

A method to generate RESP-dPol partial charges by fitting to baseline QM ESPs

Returns:

Returns RESP-dPol partial charges

Return type:

pint.Quantity

property respdpol_dipoles: Quantity
Returns:

Molecular dipole moment calculated using RESP-dPol charges.

Return type:

pint.Quantity

property smiles: str
Returns:

SMILES string without explicit hydrogens.

Return type:

str

class factorpol.qm_worker.QWorker(n_worker: int = 2, thread_per_worker: int = 8)[source]

Distribute QM calculations with Ray

Parameters:
  • n_worker (int) – Number of ray workers to run QM calculations

  • thread_per_worker (int) – Number of CPUs per ray worker to use

start(dataset: List[Molecule], method: str, basis: str, wd: str, n_conf: int = 1, msk_density: float = 1.0, msk_layers: float = 4.0, external_field: ndarray = array([0., 0., 0.])) List[source]

Start a calculation process.

Parameters:
  • dataset (List[Molecule]) – A list of OpenFF molecules to run QM ESPs calculations

  • method (str) – QM method

  • basis (str) – QM level of theory

  • wd (str) – Working directory

  • n_conf (int) – Number of conformers to generate if the input molecule does not contains coordinates.

  • msk_density (float) – Density of MSK grid points

  • msk_layers (float) – Number of layer s of MSK grid points

  • external_field (np.ndarray) – If impose electric field is desired. Default is none. np.array([0., 0. 0.])

Returns:

Returns all MoleculeESPRecord in a list

Return type:

List

store(my_session: Session, records: List[MoleculeESPRecord]) List[source]

Store a list of MoleculeESPRecord to the input session associated with user database.

Parameters:
  • my_session (session.Session) – A working session associated with a database for storing QM ESPs data.

  • records – A list of MoleculeESPRecords to be stored.

Returns:

Returns a list of SMILEs Strings of stored MoleculeESPRecords.

Return type:

List

class factorpol.utilities.StorageHandler(port: str = '5432', url: str = 'postgresql://localhost:', local_path: str = '/home/docs/checkouts/readthedocs.org/user_builds/factorpol/checkouts/latest/docs/data_tmp')[source]

This is a handler to interact with data stored in PostgreSQL database.

Parameters:
  • port (int) – The port where PostgreSQL server is running. Default is 5432.

  • url (str) – The url in form of a string which contains the path to a running PostgreSQL server.

  • local_path (str) – A local path to store temporary data. Default is a directory named data_tmp at current working directory.

session(database_name: str) Session[source]

This is a handy method to create a sqlalchemy session for input database to use in querying data.

Parameters:

database_name (str) – The name of database to query

Returns:

Returns a working Session to use in querying data.

Return type:

session.Session

start()[source]

This method will start a server if currently there is no active server running on specified url.

Returns:

Return output and/or error messages

Return type:

str

stop()[source]

This method will stop the server associated to this storage handler.

Returns:

Returns output and/or error messages

Return type:

str

This module contains useful functions to use with Factor-Pol model

class factorpol.utilities.BondChargeCorrections(data_source: str = '/home/docs/checkouts/readthedocs.org/user_builds/factorpol/checkouts/latest/factorpol/data/bcc_dPol.csv')[source]

A dataclass to read/write bond charge correction parameters for generating AM1-BCC-dPol charges

Parameters:

data_source (str) – The path of a .csv file which stores all bond charge correction parameters.

Examples

DefaultBccs = BondChargeCorrections(data_source=resource_filename("factorpol", os.path.join("data", "bcc_dPol.csv")))

property data: DataFrame

Store BCC parameters as a pandas.DataFrame

Returns:

Stored BCC parameters ad pandas DataFrame

Return type:

pd.core.frame.DataFrame

property parameters: Dict

Extract types and BCC parameters and store in a dictionary for easy parameterization.

Returns:

A dictionary of BCCs.

Return type:

Dict

property recharge_collection: BCCCollection

Create an openff-recharge BCC collection to generate AM1-BCC-dPol partial charges

Returns:

Returned BCCCollection

Return type:

BCCCollection

class factorpol.utilities.Polarizability(data_source: str = '/home/docs/checkouts/readthedocs.org/user_builds/factorpol/checkouts/latest/factorpol/data/alphas.example.csv')[source]

A dataclass to read/write polarizability parameters

Parameters:

data_source (str) – The path of a .csv file which stores all polarizabilities.

Examples

DefaultPol = Polarizability(data_source=resource_filename("factorpol", os.path.join("data", "alphas.example.csv")))

property data: DataFrame

Store polarizability parameters ad pandas DataFrame

Returns:

Stored polarizability parameters as a pandas.DataFrame

Return type:

pd.core.frame.DataFrame

property parameters: Dict

Extra types and polarizabilities and store in a dictionary for easy parameterization.

Returns:

A dictionary of polarizabilities.

Return type:

Dict

class factorpol.utilities.StorageHandler(port: str = '5432', url: str = 'postgresql://localhost:', local_path: str = '/home/docs/checkouts/readthedocs.org/user_builds/factorpol/checkouts/latest/docs/data_tmp')[source]

This is a handler to interact with data stored in PostgreSQL database.

Parameters:
  • port (int) – The port where PostgreSQL server is running. Default is 5432.

  • url (str) – The url in form of a string which contains the path to a running PostgreSQL server.

  • local_path (str) – A local path to store temporary data. Default is a directory named data_tmp at current working directory.

session(database_name: str) Session[source]

This is a handy method to create a sqlalchemy session for input database to use in querying data.

Parameters:

database_name (str) – The name of database to query

Returns:

Returns a working Session to use in querying data.

Return type:

session.Session

start()[source]

This method will start a server if currently there is no active server running on specified url.

Returns:

Return output and/or error messages

Return type:

str

stop()[source]

This method will stop the server associated to this storage handler.

Returns:

Returns output and/or error messages

Return type:

str

factorpol.utilities.calc_rmse(calc: ndarray, ref: ndarray)[source]

A function to calculate root mean squared error, RMSE, unit is the same as input data

Parameters:
  • calc (ndarray) – Calculated data

  • ref (ndarray) – Reference data

Returns:

Returns the RMSE value

Return type:

float

factorpol.utilities.calc_rrms(calc: ndarray, ref: ndarray)[source]

A function to calculate relative root mean squared error, RRMS error, unit less

\[RRMS =\sqrt{\frac{1}{N}\frac{\sum\limits_{i=1}^{N}(V_{qm,i}-V_{calc, i})^2}{\sum\limits_{i=1}^{N}(V_{qm, i})^2}}\]
Parameters:
  • calc (ndarray) – Calculated data

  • ref (ndarray) – Reference data

Returns:

Returns the RRMS error value

Return type:

float

factorpol.utilities.canonical_ranking(rdmol: Mol) List[source]

A function to calculte canonical ranking for forced symmetry using RDKit

Parameters:

rdmol (Chem.rdchem.Mol) – A rdkir molecule object

Returns:

A list of atomic features based on the canonical ranking of all atoms

Return type:

List

factorpol.utilities.coulomb_scaling(rdmol: Mol, coulomb14scale: float = 0.5) ndarray[source]

A function to create scaling matrix for scaling the 1-4 interactions in Coulomb interactions

Parameters:
  • rdmol (Chem.rdchem.Mol) – An input rdkit molecule used for specifying connectivity

  • coulomb14scale (float) – The coulomb14 scaling factor, default value is 0.5. Commonly used value includes 0.83333

Returns:

Returns a numpy ndarray as scaling matrix for using in scaling Coulomb interactions. This scaling matrix excludes all 1-2, 1-3 interactions and scales 1-4 by coulomb14scale factor.

Return type:

ndarray

factorpol.utilities.flatten_a_list(nest_list: List) List[source]

A handy funtion to flatten a nested list

Parameters:

nest_list (List) – A nested list that needed to be flatten into a 1-D list

Returns:

Return a 1-D list

Return type:

List

factorpol.utilities.pair_equivalent(pattern: List) ndarray[source]

A function to pair related patterns together for use as constraints

Parameters:

pattern (List) – A list of patterns, could be elements, SMIRNOFF patterns

Returns:

Return pairs of related patterns in a nested numpy ndarry.

Return type:

ndarry

factorpol.utilities.retrieve_records(my_session: Session, dataset: List = [], sqlite_path: str = '/home/docs/checkouts/readthedocs.org/user_builds/factorpol/checkouts/latest/docs/tmp.sqlite') Dict[source]

A function to retrieve data from the input session and create MoleculeESPRecords for use of polarizability or charge fitting.

Parameters:
  • my_session (session.Session) – A session associated to the PostgreSQL database to look for data.

  • dataset (List) – A list of SMILES string of molecules to look for.

  • sqlite_path (str) – The path to create and storage a local copy of MoleculeESPRecords.

Returns:

Returns a dictionary of retrieved records. SMILES string as key, MoleculeESPRecord as value.

Return type:

dict

factorpol.utilities.smirnoff_labels(offmol: Molecule, off_forcefield: ForceField) List[source]

A function to label OpenFF molecule objecit with SMIRNOFF patternes specified in the input OpenFF ForceField object.

Parameters:
  • offmol (Molecule) – The input molecule to label

  • off_forcefield (ForceField) – The input openff ForceField with SMIRNOFF patterns to label atoms in molecule.

Returns:

Return a list of SMIRNOFF patterns associated with atoms in molecule

Return type:

List

This module provide functionalities to generate reference QM ESPs and query existing ESPs data

This module is designed to be used with Ray to distribute QM calculations.

class factorpol.qm_worker.QWorker(n_worker: int = 2, thread_per_worker: int = 8)[source]

Distribute QM calculations with Ray

Parameters:
  • n_worker (int) – Number of ray workers to run QM calculations

  • thread_per_worker (int) – Number of CPUs per ray worker to use

start(dataset: List[Molecule], method: str, basis: str, wd: str, n_conf: int = 1, msk_density: float = 1.0, msk_layers: float = 4.0, external_field: ndarray = array([0., 0., 0.])) List[source]

Start a calculation process.

Parameters:
  • dataset (List[Molecule]) – A list of OpenFF molecules to run QM ESPs calculations

  • method (str) – QM method

  • basis (str) – QM level of theory

  • wd (str) – Working directory

  • n_conf (int) – Number of conformers to generate if the input molecule does not contains coordinates.

  • msk_density (float) – Density of MSK grid points

  • msk_layers (float) – Number of layer s of MSK grid points

  • external_field (np.ndarray) – If impose electric field is desired. Default is none. np.array([0., 0. 0.])

Returns:

Returns all MoleculeESPRecord in a list

Return type:

List

store(my_session: Session, records: List[MoleculeESPRecord]) List[source]

Store a list of MoleculeESPRecord to the input session associated with user database.

Parameters:
  • my_session (session.Session) – A working session associated with a database for storing QM ESPs data.

  • records – A list of MoleculeESPRecords to be stored.

Returns:

Returns a list of SMILEs Strings of stored MoleculeESPRecords.

Return type:

List

factorpol.qm_worker.add_molecule(record, my_session)[source]

Add one record to the input session

Parameters:
  • record (MoleculeESPRecord) – The record to be stored.

  • my_session (session.Session) – A working session associated with a database for storing QM ESPs data.

Returns:

Returns the SMILES string of stored record

Return type:

str

factorpol.qm_worker.from_conformer_to_molecule(dbconformer: DBConformerRecord)[source]

Reconstruct a conformer record to a molecule record.

Parameters:

dbconformer (DBConformerRecord) – A conformer record DB

Returns:

Returns a MoleculeESPRecord for this conformation.

Return type:

MoleculeESPRecord

factorpol.qm_worker.rebuild_molecule(my_session: Session, molecule: str) Dict[source]

Rebuild a molecule with baseline QM ESPs from all conformations.

Parameters:
  • my_session (session.Session) – A working session associated with a database for stored QM ESPs data.

  • molecule (str) – The SMILE String of the molecule of choice.

Returns:

Returns a dictionary of records Conformer names are keys and records are values.

Return type:

Dict

factorpol.qm_worker.retrieve_by_conformation(my_session: Session, molecule: str, conformation: ndarray) List[source]

Filter/retrieve records based on conformation

Parameters:
  • my_session (session.Session) – A working session associated with a database for stored QM ESPs data.

  • molecule (str) – The SMILES string of molecule to filter

  • conformation (ndarray) – The conformation coordinates to filter/query

Returns:

Returns a list of retrieved records

Return type:

List

factorpol.qm_worker.retrieve_by_external_field(my_session: Session, molecule: str, eefield: ndarray) List[source]

Query records according to imposed electric field.

Parameters:
  • my_session (session.Session) – A working session associated with a database for stored QM ESPs data.

  • molecule (str) – The SMILES string of the molecule to query

  • eefield (ndarray) – The imposed electric field to filter

Returns:

A list of returned records

Return type:

List

This module provides functionalities to derive and obtain typed polarizabilities from QM reference data.

This module uses Ray to distribute the optimization process. The optimization process is performed by scipy.optimize.minimize with Nelder-Mead method.

class factorpol.alphas_training.AlphaData(database_name: str, dataset: List[str], off_forcefield: ForceField, polarizability: Polarizability, num_cpus: int = 8)[source]

A class to prepare reference QM ESPs for optimization of polarizability

Parameters:
  • database_name (str) – The name of database to query

  • dataset (List[str]) – A list of molecules to query

  • off_forcefield (ForceField) – An OpenFF Force Field to specify SMIRNOFF patterns

  • polarizability (Polarizability) – A polarizability library

  • num_cpus (int) – The number of process to initialize to generate relevant data

class factorpol.alphas_training.AlphaWorker(record: MoleculeESPRecord, off_forcefield: ForceField, polarizability: Polarizability, coulomb14scale: float = 0.5)[source]

A class used to derive polarizability from QM ESPs.

Parameters:
  • record (MoleculeESPRecord) – QM reference record

  • off_forcefield (ForceField) – OpenFF force field to handle SMIRNOFF typing of polarizabilities

  • polarizability (Polarizability) – Input polarizabilities

  • coulomb14scale (float) – Scaling factor to scale Coulomb 1-4 interactions

class factorpol.alphas_training.AlphasTrainer(workers: List[AlphaWorker], prior: Polarizability, working_directory: str = '/home/docs/checkouts/readthedocs.org/user_builds/factorpol/checkouts/latest/docs/data_alphas')[source]

Top level optimizer to train polarizability parameters

Parameters:
  • workers (List[AlphaWorker]) – A list of AlphaWorker

  • prior (Polarizability) – Initial polarizability

  • working_directory (str) – The path to the working directory

static _calc_Esps_mu(worker: AlphaWorker) ndarray[source]

Calculate the MM ESPs on grid points using mutual polarization

Parameters:

worker (AlphaWorker) – The AlphaWorker that contains all ESP-fitting related data

Returns:

Returns the computed ESPs on grid points

Return type:

ndarray

optimize(bounds, num_cpus=8)[source]

Distribute the optimization process with Ray

Parameters:
  • bounds (tuple) – The bounds of each polarizability type

  • num_cpus (int) – The number of CPUs available for optimization

Return type:

Returns the result object of optimizer.

worker(input_data: ndarray)[source]

A method to compute the loss

Parameters:

input_data (ndarray) – Polarizability solved from the previous optimization

Return type:

Returns the optimizer output object.

factorpol.alphas_training._update_workers(workers: List[AlphaWorker], parameters_path: str, coulomb14scale: float = 0.5)[source]

Method to update charge workers for next optimization iteration

Parameters:
  • workers (List[AlphaWorker]) – A list of AlphaWorker

  • parameters_path (str) – Path to newly solved polarizabilities

  • coulomb14scale (float) – Scaling factor of Coulomb 1-4 interactions. Normally set as constant but it could be optimized.

Returns:

Returns updated AlphasWorker

Return type:

AlphaWorker

factorpol.alphas_training.optimize_alphas(worker_list: List[AlphaWorker], solved=True, num_cpus=8) ndarray[source]

A function to optimize the polarizability of a dataset to reference QM ESPs Atomic units

Objective Function:

\[{\chi}^2 = \sum_{k=1}^{N_{conf}} \sum_{l=1}^{6}\sum_{i=1}^{m} (V_{diff,ikl} -\sum_{j=1}^{n_k}\frac{{\mu}_{{ind,jl}}{r}_{ij}}{r_{ij}^3})^2\]
Parameters:
  • worker_list (List[AlphaWorker])

  • solved (bool) – Whether the polarizability is solved or not

  • num_cpus (int) – Number of CPUs to use for ray workers

Returns:

Returns matrix, vector, and polarizability types Returns the fitted polarizability alphas and objectives if solved is True

Return type:

ndarray, ndarray, ndarray

factorpol.alphas_training.optimize_alphas_fast(worker_list: List[AlphaWorker], solved=True, num_cpus=8) ndarray[source]

** This method is extremely experimental and not recommended for production use **

This implementation is not efficient enough and needs to be improved.

A fast method to optimize the polarizability of a dataset to reference QM ESPs

Atomic units

Objective Function:

Parameters:
  • worker_list (List[AlphaWorker])

  • solved (bool) – Whether the polarizability is solved or not

  • num_cpus (int) – Number of CPUs to use for ray workers

Returns:

Returns matrix, vector, and polarizability types Returns the fitted polarizability alphas and objectives if solved is True

Return type:

ndarray, ndarray, ndarray

This module is for parameterizing small molecules with typed polarizabilities, AM1-BCC-dPol partial charges, and bonded parameters from Open Force Field Sage Force Field or AMBER GAFF

factorpol.parameterization.add_force(parent: Element, Name: str, TypeName: str, c0: float, alpha: float)[source]

Create a MPID Force for OpenMM to compute electrostatics.

Parameters:
  • parent (etree.Element) – Parent ForceField xml tree

  • Name (str) – Atom name

  • TypeName (str) – Atom Type

  • c0 (float) – Permanent partial charge

  • alpha (float) – Polarizability

Return type:

Returns force field xml parent tree

factorpol.parameterization.parameterize_molecule(smile: str, ff_name: str, polarizability: Polarizability, BCCLibrary: BondChargeCorrections, output_path: str, off_forcefield: ForceField) Quantity[source]

Parameterize a molecule with OpenFF sage or gaff force field

Parameters:
  • smile (str) – The SMILES string of molecule to parameterize

  • ff_name (str) – gaff or sage

  • polarizability (Polarizability) – Polarizability Library to parameterize molecules

  • BCCLibrary (BondChargeCorrections) – BCC library to generate AM1-BCC-dPol charge

  • output_path (str) – The path to write output files

  • off_forcefield (ForceField) – The OpenFF Force Field to label molecule with SMIRNOFF patterns

Returns:

Returns a string for generated force fields and molecular dipole moments

Return type:

Dict

factorpol.alphas_training.fit_alphas.remote(worker: AlphaWorker, global_opt=False) ndarray

Fit the polarizability of a molecule to reference QM ESPs This is a remote function to be called by ray Atomic units

\[\sum_{j = 1}^{n}\sum_{i = 1}^{m}\frac{\alpha_j \mathrm{r}_{ij} \mathrm{E^2}}{r_{ij}^3r_{ik}} = \sum_{i = 1}^{m}\frac{V_i \mathrm{E} \mathrm{r}_{ij}}{r_{ik} r_{ij}^3}\]
Parameters:
  • worker (AlphaWorker) – The AlphaWorker that contains all ESP-fitting related data

  • global_opt (bool) – Whether to perform global optimization

Returns:

Returns the fitted polarizability alphas if global_opt is False Returns built matrix, vector, and polarizability types if global_opt is True

Return type:

ndarray