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: Vaishnavi Bhandari <[email protected]>
  • Loading branch information
peach280 committed Jan 26, 2025
1 parent 05d2dd0 commit e22ba14
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
23 changes: 18 additions & 5 deletions avogadro/core/elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +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)
{
std::string result;
Expand Down Expand Up @@ -101,6 +100,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 @@ -111,7 +112,19 @@ class InitializeCustomElementTables
}
}
} 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

unsigned char Elements::elementCount()
Expand Down Expand Up @@ -235,7 +248,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 +258,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
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
1 change: 1 addition & 0 deletions tests/qtgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ if(PYTHON_EXECUTABLE AND AVOGADRO_DATA)
# InputGeneratorWidget
)
endif()
# link_directories(/usr/lib)

# Build up the source file names.
set(testSrcs "")
Expand Down

0 comments on commit e22ba14

Please sign in to comment.