本文整理汇总了C++中OBMol::SetPartialChargesPerceived方法的典型用法代码示例。如果您正苦于以下问题:C++ OBMol::SetPartialChargesPerceived方法的具体用法?C++ OBMol::SetPartialChargesPerceived怎么用?C++ OBMol::SetPartialChargesPerceived使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBMol
的用法示例。
在下文中一共展示了OBMol::SetPartialChargesPerceived方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ComputeCharges
bool QEqCharges::ComputeCharges(OBMol &mol)
{
///////////////////////////////////////////////////////////////////////////////
//Some OpenBabel bookkeeping that I copied from the Gasteiger scheme
mol.SetPartialChargesPerceived();
OBPairData *dp = new OBPairData;
dp->SetAttribute("PartialCharges");
dp->SetValue("QEq");
dp->SetOrigin(perceived);
mol.SetData(dp);
///////////////////////////////////////////////////////////////////////////////
//Read in atomic information from OpenBabel molecule and parameterize
//Read in total number of atoms
int i, N = mol.NumAtoms();
Hardness = MatrixXd::Zero(N+1, N+1);
Voltage = VectorXd::Zero(N+1);
Electronegativity = VectorXd::Zero(N);
VectorXd BasisSet = VectorXd::Zero(N);
Vector3d Parameters;
FOR_ATOMS_OF_MOL(atom, mol)
{
Parameters = GetParameters(atom->GetAtomicNum(), atom->GetFormalCharge());
i = atom->GetIdx() - 1;
if (Parameters[0] == 0.)
{
stringstream msg;
msg << "Some QEq Parameters not found!" << endl
<< "Parameters not found for atom no. " << i+1 << endl
<< "Atom will be ignored in the charge computation.";
obErrorLog.ThrowError(__FUNCTION__, msg.str(), obError);
}
Electronegativity[i] = Parameters[0];
Hardness(i,i) = Parameters[1];
BasisSet[i] = Parameters[2];
}
示例2: AssignSeedPartialCharge
void OBPhModel::AssignSeedPartialCharge(OBMol &mol)
{
if (!_init)
Init();
mol.SetPartialChargesPerceived();
if (!mol.AutomaticPartialCharge())
return;
vector<pair<OBSmartsPattern*,vector<double> > >::iterator i;
for (i = _vschrg.begin();i != _vschrg.end();++i)
if (i->first->Match(mol))
{
_mlist = i->first->GetUMapList();
unsigned int k;
vector<vector<int> >::iterator j;
for (j = _mlist.begin();j != _mlist.end();++j)
for (k = 0;k < j->size();++k)
mol.GetAtom((*j)[k])->SetPartialCharge(i->second[k]);
}
}
示例3: ComputeCharges
//! \return whether partial charges were successfully assigned to this molecule
bool EQEqCharges::ComputeCharges(OBMol &mol)
{
int i, j, a, c, N = mol.NumAtoms();
double cellVolume;
VectorXf chi(N), J(N), b(N), x(N);
MatrixXf J_ij(N, N), A(N, N);
OBUnitCell *obuc;
matrix3x3 unitcell, fourier;
vector3 dx;
int numNeighbors[3];
OBAtom *atom;
// If parameters have not yet been loaded, do that
if (!_paramFileLoaded)
{
if (ParseParamFile())
{
_paramFileLoaded = true;
} else
{
return false;
}
}
// Calculate atomic properties based around their ionic charge
for (i = 0; i < N; i++)
{
atom = mol.GetAtom(i + 1);
a = atom->GetAtomicNum();
c = _chargeCenter[a];
// Fail if ionization data is missing for any atom in the molecule
if (_ionizations[a][c + 1] == -1 || _ionizations[a][c] == -1 || a > TABLE_OF_ELEMENTS_SIZE)
{
obErrorLog.ThrowError(__FUNCTION__, "Insufficient ionization data for atoms in the given molecule. Update `data/eqeqIonizations.txt` with missing information and re-run this function.", obError);
return false;
}
J(i) = _ionizations[a][c + 1] - _ionizations[a][c];
chi(i) = 0.5 * (_ionizations[a][c + 1] + _ionizations[a][c]) - (a == 1? 0 : c * J(i));
}
// If a unit cell is defined, use the periodic Ewald calculation
if (mol.HasData(OBGenericDataType::UnitCell))
{
// Get unit cell and calculate its Fourier transform + volume
obuc = (OBUnitCell *) mol.GetData(OBGenericDataType::UnitCell);
unitcell = obuc->GetCellMatrix();
fourier = (2 * PI * unitcell.inverse()).transpose();
cellVolume = obuc->GetCellVolume();
// Get the number of radial unit cells to use in x, y, and z
numNeighbors[0] = int(ceil(minCellLength / (2.0 * (obuc->GetA())))) - 1;
numNeighbors[1] = int(ceil(minCellLength / (2.0 * (obuc->GetB())))) - 1;
numNeighbors[2] = int(ceil(minCellLength / (2.0 * (obuc->GetC())))) - 1;
for (i = 0; i < N; i++)
{
atom = mol.GetAtom(i + 1);
for (j = 0; j < N; j++)
{
dx = atom->GetVector() - (mol.GetAtom(j + 1))->GetVector();
J_ij(i, j) = GetPeriodicEwaldJij(J(i), J(j), dx, (i == j), unitcell, fourier, cellVolume, numNeighbors);
}
}
// If no unit cell, use the simplified nonperiodic calculation
} else
{
for (i = 0; i < N; i++)
{
atom = mol.GetAtom(i + 1);
for (j = 0; j < N; j++)
{
J_ij(i, j) = GetNonperiodicJij(J(i), J(j), atom->GetDistance(j + 1), (i == j));
}
return false;
}
}
// Formulate problem as A x = b, where x is the calculated partial charges
// First equation is a simple overall balance: sum(Q) = 0
A.row(0) = VectorXf::Ones(N);
b(0) = 0;
// Remaining equations are based off of the fact that, at equilibrium, the
// energy of the system changes equally for a change in any charge:
// dE/dQ_1 = dE/dQ_2 = ... = dE/dQ_N
A.block(1, 0, N - 1, N) = J_ij.block(0, 0, N - 1, N) - J_ij.block(1, 0, N - 1, N);
b.tail(N - 1) = chi.tail(N - 1) - chi.head(N - 1);
// The solution is a list of charges in the system
x = A.colPivHouseholderQr().solve(b);
// Now we are done calculating, pass all this back to OpenBabel molecule
mol.SetPartialChargesPerceived();
OBPairData *dp = new OBPairData;
dp->SetAttribute("PartialCharges");
dp->SetValue("EQEq");
dp->SetOrigin(perceived);
//.........这里部分代码省略.........
示例4: ComputeCharges
bool EEMCharges::ComputeCharges(OBMol &mol)
{
mol.SetPartialChargesPerceived();
if(_parameters.empty())
_loadParameters();
// Copied from spectrophore.cpp
// CHI and ETA
unsigned int _nAtoms = mol.NumAtoms();
unsigned int dim(_nAtoms + 1);
std::vector<double> CHI(dim);
double** ETA = new double*[dim];
for (unsigned int i = 0; i < dim; ++i)
{
ETA[i] = new double[dim];
}
double totalCharge(0.0);
unsigned int i(0);
double hardness;
double electronegativity;
for (OpenBabel::OBMolAtomIter atom(mol); atom; atom++, i++) {
int n = atom->GetAtomicNum();
int b = atom->HighestBondOrder();
// Search for parameters for a particular atom type
bool found = false;
for(unsigned int j = 0; j < _parameters.size(); j++) {
if((_parameters[j].Z == n && _parameters[j].bond_order == b) ||
(_parameters[j].Z == n && _parameters[j].bond_order == - 1) ||
(_parameters[j].Z == -1 && _parameters[j].bond_order == -1)) {
electronegativity = _parameters[j].A;
hardness = _parameters[j].B;
found = true;
break;
}
}
if(!found) {
std::stringstream ss;
ss << "No parameters found for: " << etab.GetSymbol(n) << " " << b
<< ". EEM charges were not calculated for the molecule." << std::endl;
obErrorLog.ThrowError(__FUNCTION__, ss.str(), obError);
return false;
}
CHI[i] = -electronegativity;
ETA[i][i] = hardness;
// Adjust the total molecular charge
totalCharge += atom->GetFormalCharge();
}
// Complete CHI
CHI[_nAtoms] = totalCharge;
// Complete ETA
OBAtom *rAtom, *cAtom;
for (unsigned int r = 0; r < _nAtoms; ++r)
{
rAtom = mol.GetAtom(r+1); // Atom index
for (unsigned int c = r + 1; c < _nAtoms; ++c)
{
cAtom = mol.GetAtom(c+1); // Atom index
ETA[r][c] = _kappa / cAtom->GetDistance(rAtom);
ETA[c][r] = ETA[r][c];
}
}
for (unsigned int i = 0; i < dim; ++i)
{
ETA[i][_nAtoms] = -1.0;
ETA[_nAtoms][i] = +1.0;
}
ETA[_nAtoms][_nAtoms] = 0.0;
// Solve the matrix equation
_solveMatrix(ETA, &(CHI[0]), dim); // CHI will contain the values
OBAtom *atom;
for (unsigned int i = 0; i < _nAtoms; ++i)
{
atom = mol.GetAtom(i+1); // atom index issue
atom->SetPartialCharge(CHI[i]);
}
OBChargeModel::FillChargeVectors(mol);
// Cleanup
for(unsigned int i = 0; i < dim; i++)
delete [] ETA[i];
delete [] ETA;
return true;
}