Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes#1714 => Functionality for setting size of ghost atom #1911

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 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> 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 @@
{
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 @@ -111,9 +113,33 @@
}
}
} CustomElementTableInitializer;
void setCustomElementCovalentRadius(unsigned char atomicNumber, double radius)

Check notice

Code scanning / CodeQL

Unused static function Note

Static function setCustomElementCovalentRadius is unreachable
{
if (isCustomElement(atomicNumber)) {
CustomElementCovalentRadii[atomicNumber - CustomElementMin] = radius;
}
}

void setCustomElementVDWRadius(unsigned char atomicNumber, double radius)

Check notice

Code scanning / CodeQL

Unused static function Note

Static function setCustomElementVDWRadius is unreachable
{
if (isCustomElement(atomicNumber)) {
CustomElementVDWRadii[atomicNumber - CustomElementMin] = radius;
}
}
} // end anon namespace
void setCustomElementCovalentRadius(unsigned char atomicNumber, double radius)
{
if (isCustomElement(atomicNumber)) {
CustomElementCovalentRadii[atomicNumber - CustomElementMin] = radius;
}
}

void 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 +261,7 @@
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 +271,7 @@
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
3 changes: 2 additions & 1 deletion avogadro/core/elements.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class AVOGADROCORE_EXPORT Elements

/** @return the mass of the element with the supplied @p atomicNumber. */
static double mass(unsigned char atomicNumber);

static void setCustomElementVDWRadius(unsigned char atomicNumber, double radius);
static void setCustomElementCovalentRadius(unsigned char atomicNumber, double radius);
/**
* @return the Van der Waals radius of the element with the supplied
* @p atomicNumber.
Expand Down
Loading