Skip to content

Commit

Permalink
Functionality for setting size of ghost atom
Browse files Browse the repository at this point in the history
Signed-off-by: peach280 <[email protected]>
  • Loading branch information
peach280 committed Jan 4, 2025
1 parent 3fe6f85 commit 35e92e5
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions avogadro/core/elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ static std::vector<std::string> CustomElementSymbols;
static std::vector<std::string> CustomElementNames;

// Match carbon's radii
static double CustomElementCovalentRadius = element_covalent[6];
static double CustomElementVDWRadius = element_VDW[6];
static std::vector<double> CustomElementCovalentRadii;
static std::vector<double> CustomElementVDWRadii;

inline std::string encodeCustomElement(unsigned char atomicNumber)
{
Expand Down Expand Up @@ -101,6 +101,8 @@ class InitializeCustomElementTables
{
CustomElementSymbols.resize(CustomElementCount);
CustomElementNames.resize(CustomElementCount);
CustomElementCovalentRadii.resize(CustomElementCount, element_covalent[6]);
CustomElementVDWRadii.resize(CustomElementCount, element_VDW[6]);
std::string suffix;
for (unsigned char i = CustomElementMin; i <= CustomElementMax; ++i) {
suffix = encodeCustomElement(i);
Expand All @@ -113,7 +115,19 @@ class InitializeCustomElementTables
} CustomElementTableInitializer;

} // end anon namespace
void Elements::setCustomElementCovalentRadius(unsigned char atomicNumber, double radius)
{
if (isCustomElement(atomicNumber)) {
CustomElementCovalentRadii[atomicNumber - CustomElementMin] = radius;
}
}

void Elements::setCustomElementVDWRadius(unsigned char atomicNumber, double radius)
{
if (isCustomElement(atomicNumber)) {
CustomElementVDWRadii[atomicNumber - CustomElementMin] = radius;
}
}
unsigned char Elements::elementCount()
{
return element_count;
Expand Down Expand Up @@ -235,7 +249,7 @@ double Elements::radiusVDW(unsigned char atomicNumber)
if (atomicNumber < element_count)
return element_VDW[atomicNumber];
else if (isCustomElement(atomicNumber))
return CustomElementVDWRadius;
return CustomElementVDWRadii[atomicNumber - CustomElementMin];
else
return element_VDW[0];
}
Expand All @@ -245,7 +259,7 @@ double Elements::radiusCovalent(unsigned char atomicNumber)
if (atomicNumber < element_count)
return element_covalent[atomicNumber];
else if (isCustomElement(atomicNumber))
return CustomElementCovalentRadius;
return CustomElementCovalentRadii[atomicNumber - CustomElementMin];
else
return element_covalent[0];
}
Expand Down

0 comments on commit 35e92e5

Please sign in to comment.