Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into custom-element
Browse files Browse the repository at this point in the history
Signed-off-by: Adarsh Balasubramanian <[email protected]>
  • Loading branch information
badarsh2 committed Sep 27, 2018
2 parents af5e051 + 86321ef commit 584d7d7
Show file tree
Hide file tree
Showing 107 changed files with 9,977 additions and 7,671 deletions.
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ language: cpp
sudo: true

matrix:
allow_failures:
- os: osx

include:
- language: python
sudo: false
python: 2.7
env: TASKS="clang-format"

os: linux
dist: trusty
addons:
apt:
Expand All @@ -23,6 +27,7 @@ matrix:
- clang-format-6.0

- compiler: gcc
os: linux
addons:
apt:
sources: ubuntu-toolchain-r-test
Expand All @@ -32,6 +37,7 @@ matrix:
- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"

- compiler: gcc
os: linux
addons:
apt:
sources: ubuntu-toolchain-r-test
Expand All @@ -41,8 +47,12 @@ matrix:
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"

- compiler: clang
os: linux
env: TASKS="ctest clang-3.9"

- os: osx
env: TASKS="Mac clang"

install:
- . ./scripts/travis/install.sh

Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ option(USE_VTK "Enable libraries that use VTK" OFF)
option(USE_LIBARCHIVE "Enable optional Libarchive features" ON)
option(USE_LIBMSYM "Enable optional features using libmsym" ON)
option(USE_SPGLIB "Enable optional features using spglib" ON)
option(USE_MMTF "Enable optional features using mmtf" ON)
option(USE_PROTOCALL "Enable libraries that use ProtoCall" OFF)
option(USE_MOLEQUEUE "Enable the MoleQueue dependent functionality" ON)
option(USE_PYTHON "Use Python to wrap some of our API" OFF)
Expand Down
8 changes: 6 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ init:
environment:
PATH: '%PATH%;%QTDIR%\bin'
matrix:
- CMAKE_GENERATOR: '"Visual Studio 15 2017 Win64"'
- CMAKE_GENERATOR: '"Ninja"'
QTDIR: C:\Qt\5.6\msvc2015_64
platform: x64
build_script:
Expand All @@ -29,6 +29,10 @@ build_script:
cd openchemistry-build
choco install ninja
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
cmake -G %CMAKE_GENERATOR% ../openchemistry
cmake --build . --target avogadrolibs --config Release -- /verbosity:detailed
cmake --build . --target avogadrolibs --config Release
32 changes: 26 additions & 6 deletions avogadro/core/atom.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ class AtomTemplate
bool selected() const;
/** @} */

/**
* The force on this atom.
* {@
*/
void setForceVector(const Vector3& force);
Vector3 forceVector() const;
/** @} */

private:
MoleculeType* m_molecule;
Index m_index;
Expand All @@ -171,14 +179,12 @@ class AtomTemplate
template <class Molecule_T>
AtomTemplate<Molecule_T>::AtomTemplate()
: m_molecule(nullptr), m_index(MaxIndex)
{
}
{}

template <class Molecule_T>
AtomTemplate<Molecule_T>::AtomTemplate(MoleculeType* m, Index i)
: m_molecule(m), m_index(i)
{
}
{}

template <class Molecule_T>
bool AtomTemplate<Molecule_T>::operator==(
Expand Down Expand Up @@ -317,7 +323,21 @@ bool AtomTemplate<Molecule_T>::selected() const
return m_molecule->atomSelected(m_index);
}

} // end Core namespace
} // end Avogadro namespace
template <class Molecule_T>
void AtomTemplate<Molecule_T>::setForceVector(const Vector3& force)
{
m_molecule->setForceVector(m_index, force);
}

template <class Molecule_T>
Vector3 AtomTemplate<Molecule_T>::forceVector() const
{
return m_molecule->forceVectors().size() > 0
? m_molecule->forceVectors()[m_index]
: Vector3::Zero();
}

} // namespace Core
} // namespace Avogadro

#endif // AVOGADRO_CORE_ATOM_H
70 changes: 48 additions & 22 deletions avogadro/core/elementdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,28 +151,54 @@ double element_covalent[] = {
};

unsigned char element_color[][3] = {
{ 17, 127, 178 }, { 255, 255, 255 }, { 216, 255, 255 }, { 204, 127, 255 },
{ 193, 255, 0 }, { 255, 181, 181 }, { 127, 127, 127 }, { 12, 12, 255 },
{ 255, 12, 12 }, { 178, 255, 255 }, { 178, 226, 244 }, { 170, 91, 242 },
{ 137, 255, 0 }, { 191, 165, 165 }, { 127, 153, 153 }, { 255, 127, 0 },
{ 255, 255, 48 }, { 30, 239, 30 }, { 127, 209, 226 }, { 142, 63, 211 },
{ 61, 255, 0 }, { 229, 229, 229 }, { 191, 193, 198 }, { 165, 165, 170 },
{ 137, 153, 198 }, { 155, 122, 198 }, { 127, 122, 198 }, { 112, 122, 198 },
{ 91, 122, 193 }, { 255, 122, 96 }, { 124, 127, 175 }, { 193, 142, 142 },
{ 102, 142, 142 }, { 188, 127, 226 }, { 255, 160, 0 }, { 165, 40, 40 },
{ 91, 183, 209 }, { 112, 45, 175 }, { 0, 255, 0 }, { 147, 255, 255 },
{ 147, 224, 224 }, { 114, 193, 201 }, { 84, 181, 181 }, { 58, 158, 158 },
{ 35, 142, 142 }, { 10, 124, 140 }, { 0, 104, 132 }, { 224, 224, 255 },
{ 255, 216, 142 }, { 165, 117, 114 }, { 102, 127, 127 }, { 158, 99, 181 },
{ 211, 122, 0 }, { 147, 0, 147 }, { 66, 158, 175 }, { 86, 22, 142 },
{ 0, 201, 0 }, { 112, 211, 255 }, { 255, 255, 198 }, { 216, 255, 198 },
{ 198, 255, 198 }, { 163, 255, 198 }, { 142, 255, 198 }, { 96, 255, 198 },
{ 68, 255, 198 }, { 48, 255, 198 }, { 30, 255, 198 }, { 0, 255, 155 },
{ 0, 229, 117 }, { 0, 211, 81 }, { 0, 191, 56 }, { 0, 170, 35 },
{ 76, 193, 255 }, { 76, 165, 255 }, { 33, 147, 214 }, { 38, 124, 170 },
{ 38, 102, 150 }, { 22, 84, 135 }, { 244, 237, 209 }, { 204, 209, 30 },
{ 181, 181, 193 }, { 165, 84, 76 }, { 86, 89, 96 }, { 158, 79, 181 },
{ 170, 91, 0 }, { 117, 79, 68 }, { 66, 130, 150 }, { 66, 0, 102 },
// See, for example http://jmol.sourceforge.net/jscolors/index.en.html
// Changes - H is not completely white to add contrast on light backgrounds
// - C is slightly darker (i.e. 50% gray - consistent with Avo1)
// - F is bluer to add contrast with Cl (e.g. CFC compounds)
// # Du # H # He
{ 17, 127, 178 }, { 240, 240, 240 }, { 217, 255, 255 }, { 204, 128, 255 },
// # Be, B, C, N
{ 194, 255, 0 }, { 255, 181, 181 }, { 127, 127, 127 }, { 48, 80, 255 },
// # O, F, Ne, Na
{ 255, 13, 13 }, { 178, 255, 255 }, { 178, 227, 245 }, { 171, 91, 242 },
// # Mg
{ 138, 255, 0 }, { 191, 166, 166 }, { 240, 200, 160 }, { 255, 128, 0 },
// # S
{ 255, 255, 48 }, { 31, 240, 31 }, { 128, 209, 227 }, { 143, 64, 212 },
// # Ca
{ 61, 255, 0 }, { 230, 230, 230 }, { 191, 194, 199 }, { 166, 166, 171 },
// # Cr
{ 138, 153, 199 }, { 156, 122, 199 }, { 224, 102, 51 }, { 240, 144, 160 },
// # Ni
{ 80, 208, 80 }, { 200, 128, 51 }, { 125, 128, 176 }, { 194, 143, 143 },
// # Ge
{ 102, 143, 143 }, { 189, 128, 227 }, { 255, 161, 0 }, { 166, 41, 41 },
// # Kr
{ 92, 184, 209 }, { 112, 46, 176 }, { 0, 255, 0 }, { 148, 255, 255 },
// # Zr
{ 148, 224, 224 }, { 115, 194, 201 }, { 84, 181, 181 }, { 59, 158, 158 },
// # Ru
{ 36, 143, 143 }, { 10, 125, 140 }, { 0, 105, 133 }, { 192, 192, 192 },
// # Cd
{ 255, 217, 143 }, { 166, 117, 115 }, { 102, 128, 128 }, { 158, 99, 181 },
// # Te
{ 211, 122, 0 }, { 148, 0, 148 }, { 66, 158, 176 }, { 87, 23, 143 },
// # Ba
{ 0, 201, 0 }, { 112, 212, 255 }, { 255, 255, 199 }, { 217, 255, 199 },
// # Nd
{ 199, 255, 199 }, { 163, 255, 199 }, { 143, 255, 199 }, { 97, 255, 199 },
// # Gd
{ 69, 255, 199 }, { 48, 255, 199 }, { 31, 255, 199 }, { 0, 255, 156 },
// # Er
{ 0, 230, 117 }, { 0, 212, 82 }, { 0, 191, 56 }, { 0, 171, 36 },
// # Hf
{ 77, 194, 255 }, { 77, 166, 255 }, { 33, 148, 214 }, { 38, 102, 150 },
// # Os
{ 38, 102, 150 }, { 23, 84, 135 }, { 208, 208, 224 }, { 255, 209, 35 },
// # Hg
{ 184, 194, 208 }, { 166, 84, 77 }, { 87, 89, 97 }, { 158, 79, 181 },
// # Po
{ 171, 92, 0 }, { 117, 79, 69 }, { 66, 130, 150 }, { 66, 0, 102 },
{ 0, 124, 0 }, { 112, 170, 249 }, { 0, 186, 255 }, { 0, 160, 255 },
{ 0, 142, 255 }, { 0, 127, 255 }, { 0, 107, 255 }, { 84, 91, 242 },
{ 119, 91, 226 }, { 137, 79, 226 }, { 160, 53, 211 }, { 178, 30, 211 },
Expand Down
41 changes: 41 additions & 0 deletions avogadro/core/gaussianset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,47 @@ void GaussianSet::setMolecularOrbitals(const vector<double>& MOs,
m_moMatrix[index].coeffRef(i, j) = MOs[i + j * m_numMOs];
}

void GaussianSet::setMolecularOrbitals(const vector<double>& MOs,
ElectronType type, Index idx)
{
if (!m_numMOs)
return;

size_t index = 0;
if (type == Beta)
index = 1;

unsigned int columns = static_cast<unsigned int>(MOs.size()) / m_numMOs;

MatrixX moMatrix;
moMatrix.resize(m_numMOs, columns);

for (unsigned int j = 0; j < columns; ++j)
for (unsigned int i = 0; i < m_numMOs; ++i)
moMatrix.coeffRef(i, j) = MOs[i + j * m_numMOs];

if (idx <= m_moMatrixSet[index].size())
m_moMatrixSet[index].resize(idx + 1);

m_moMatrixSet[index][idx] = moMatrix;
}

bool GaussianSet::setActiveSetStep(int index)
{
if (index >= static_cast<int>(m_moMatrixSet[0].size()) ||
index >= static_cast<int>(m_moMatrixSet[1].size())) {
return false;
}

if (index >= m_molecule->coordinate3dCount())
return false;

m_moMatrix[0] = m_moMatrixSet[0][index];
m_moMatrix[1] = m_moMatrixSet[1][index];
m_molecule->setCoordinate3d(index);
return true;
}

void GaussianSet::setMolecularOrbitalEnergy(const vector<double>& energies,
ElectronType type)
{
Expand Down
28 changes: 28 additions & 0 deletions avogadro/core/gaussianset.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,27 @@ class AVOGADROCORE_EXPORT GaussianSet : public BasisSet
void setMolecularOrbitals(const std::vector<double>& MOs,
ElectronType type = Paired);

/**
* Set the molecular orbital (MO) coefficients for a given index. Note
* that this must be used with coordinate sets to work correctly.
* @param MOs Vector containing the MO coefficients for the GaussianSet.
* @param type The type of the MOs (Paired, Alpha, Beta).
* @param index The index of the MO in the sequence.
*/
void setMolecularOrbitals(const std::vector<double>& MOs, ElectronType type,
Index index);

/**
* Get the number of elements in the set.
*/
int setCount() { return static_cast<int>(m_moMatrixSet[0].size()); }

/**
* Set the active element in the set, this expects a corresponding
* coordinate set element, and will change the active MO matrix.
*/
bool setActiveSetStep(int index);

/**
* @brief Set the molecular orbtial energies, expected in Hartrees.
* @param energies The vector containing energies for the MOs of type
Expand Down Expand Up @@ -314,6 +335,13 @@ class AVOGADROCORE_EXPORT GaussianSet : public BasisSet
*/
MatrixX m_moMatrix[2]; //! MO coefficient matrix

/**
* @brief If there are a sequence of related MOs, they are stored here, and
* set as the active MOs upon demand. Alpha will store Paired or the Alpha,
* Beta will store Beta coefficients for the appropriate calculation types.
*/
std::vector<MatrixX> m_moMatrixSet[2];

/**
* @brief This block stores energies for the molecular orbitals (same
* convention as the molecular orbital coefficients).
Expand Down
12 changes: 11 additions & 1 deletion avogadro/core/molecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,16 @@ void Molecule::updateGraph() const
}
}

Array<Vector3>& Molecule::forceVectors()
{
return m_forceVectors;
}

const Array<Vector3>& Molecule::forceVectors() const
{
return m_forceVectors;
}

Residue& Molecule::addResidue(std::string& name, Index& number, char& id)
{
Residue newResidue(name, number, id);
Expand All @@ -823,7 +833,7 @@ void Molecule::addResidue(Residue& residue)
m_residues.push_back(residue);
}

Residue Molecule::residue(int index)
Residue& Molecule::residue(int index)
{
return m_residues[index];
}
Expand Down
Loading

0 comments on commit 584d7d7

Please sign in to comment.