Skip to content

Commit e22ba14

Browse files
committed
Functionality for setting size of ghost atom
Signed-off-by: Vaishnavi Bhandari <[email protected]>
1 parent 05d2dd0 commit e22ba14

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

avogadro/core/elements.cpp

+18-5
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ static std::vector<std::string> CustomElementSymbols;
2626
static std::vector<std::string> CustomElementNames;
2727

2828
// Match carbon's radii
29-
static double CustomElementCovalentRadius = element_covalent[6];
30-
static double CustomElementVDWRadius = element_VDW[6];
31-
29+
static std::vector<double> CustomElementCovalentRadii;
30+
static std::vector<double> CustomElementVDWRadii;
3231
inline std::string encodeCustomElement(unsigned char atomicNumber)
3332
{
3433
std::string result;
@@ -101,6 +100,8 @@ class InitializeCustomElementTables
101100
{
102101
CustomElementSymbols.resize(CustomElementCount);
103102
CustomElementNames.resize(CustomElementCount);
103+
CustomElementCovalentRadii.resize(CustomElementCount, element_covalent[6]);
104+
CustomElementVDWRadii.resize(CustomElementCount, element_VDW[6]);
104105
std::string suffix;
105106
for (unsigned char i = CustomElementMin; i <= CustomElementMax; ++i) {
106107
suffix = encodeCustomElement(i);
@@ -111,7 +112,19 @@ class InitializeCustomElementTables
111112
}
112113
}
113114
} CustomElementTableInitializer;
115+
void setCustomElementCovalentRadius(unsigned char atomicNumber, double radius)
116+
{
117+
if (isCustomElement(atomicNumber)) {
118+
CustomElementCovalentRadii[atomicNumber - CustomElementMin] = radius;
119+
}
120+
}
114121

122+
void setCustomElementVDWRadius(unsigned char atomicNumber, double radius)
123+
{
124+
if (isCustomElement(atomicNumber)) {
125+
CustomElementVDWRadii[atomicNumber - CustomElementMin] = radius;
126+
}
127+
}
115128
} // end anon namespace
116129

117130
unsigned char Elements::elementCount()
@@ -235,7 +248,7 @@ double Elements::radiusVDW(unsigned char atomicNumber)
235248
if (atomicNumber < element_count)
236249
return element_VDW[atomicNumber];
237250
else if (isCustomElement(atomicNumber))
238-
return CustomElementVDWRadius;
251+
return CustomElementVDWRadii[atomicNumber - CustomElementMin];
239252
else
240253
return element_VDW[0];
241254
}
@@ -245,7 +258,7 @@ double Elements::radiusCovalent(unsigned char atomicNumber)
245258
if (atomicNumber < element_count)
246259
return element_covalent[atomicNumber];
247260
else if (isCustomElement(atomicNumber))
248-
return CustomElementCovalentRadius;
261+
return CustomElementCovalentRadii[atomicNumber - CustomElementMin];
249262
else
250263
return element_covalent[0];
251264
}

avogadro/core/elements.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ class AVOGADROCORE_EXPORT Elements
7676

7777
/** @return the mass of the element with the supplied @p atomicNumber. */
7878
static double mass(unsigned char atomicNumber);
79-
79+
static void setCustomElementVDWRadius(unsigned char atomicNumber, double radius);
80+
static void setCustomElementCovalentRadius(unsigned char atomicNumber, double radius);
8081
/**
8182
* @return the Van der Waals radius of the element with the supplied
8283
* @p atomicNumber.

tests/qtgui/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ if(PYTHON_EXECUTABLE AND AVOGADRO_DATA)
4343
# InputGeneratorWidget
4444
)
4545
endif()
46+
# link_directories(/usr/lib)
4647

4748
# Build up the source file names.
4849
set(testSrcs "")

0 commit comments

Comments
 (0)