Skip to content

Commit

Permalink
Merge branch 'master' of github.com:openchemistry/avogadrolibs into a…
Browse files Browse the repository at this point in the history
…dd-bond-labels

Signed-off-by: Geoff Hutchison <[email protected]>
  • Loading branch information
ghutchis committed Dec 23, 2023
2 parents 8c55381 + b45dcfd commit e3f4078
Show file tree
Hide file tree
Showing 110 changed files with 51,095 additions and 21,602 deletions.
31 changes: 16 additions & 15 deletions .github/workflows/build_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt-get -qq update
sudo apt-get -qq install ninja-build libeigen3-dev libboost-all-dev libglew-dev libxml2-dev
sudo apt-get -qq install ninja-build libeigen3-dev libboost-all-dev libglew-dev libxml2-dev
sudo apt-get -qq install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5x11extras5-dev libqt5svg5-dev
sudo apt-get -qq install libgcc-10-dev libgcc-9-dev
- name: Install Dependencies (macOS)
Expand Down Expand Up @@ -178,34 +178,36 @@ jobs:

- name: Fix Mac plugins
if: runner.os == 'macOS'
working-directory: ${{ runner.workspace }}/build/prefix/lib/openbabel
working-directory: ${{ runner.workspace }}/build/prefix/lib/openbabel
run: |
for plugin in *.so; do
for libpath in `otool -L ${plugin} | grep '/Users/runner/work' | awk '{print $1}'`; do
for libpath in `otool -L ${plugin} | grep '/Users/runner/work' | awk '{print $1}'`; do
export lib=`echo $libpath | cut -d '/' -f 9`;
echo "Fixing $plugin $lib $libpath"
install_name_tool -change $libpath @executable_path/../Frameworks/$lib $plugin
done
done
cd .. # build/prefix/lib
for plugin in libinchi.?.?.?.dylib; do
for libpath in `otool -L ${plugin} | grep '/Users/runner/work' | awk '{print $1}'`; do
for plugin in libinchi.?.?.?.dylib libopenbabel.?.?.?.dylib; do
for libpath in `otool -L ${plugin} | grep '/Users/runner/work' | awk '{print $1}'`; do
export lib=`echo $libpath | cut -d '/' -f 9`;
echo "Fixing $plugin $lib $libpath"
install_name_tool -change $libpath @executable_path/../Frameworks/$lib $plugin
done
done
otool -L libinchi.?.?.?.dylib
otool -L libopenbabel.?.?.?.dylib
cp -p libinchi* ../Avogadro2.app/Contents/Frameworks/
cp -p libopenbabel* ../Avogadro2.app/Contents/Frameworks/
# finally, fixup the binaries
#cd ../bin
#for exe in obabel obmm eht_bind genXrdPattern; do
# for libpath in `otool -L ${exe} | grep '/Users/runner/work' | awk '{print $1}'`; do
# export lib=`echo $libpath | cut -d '/' -f 9`;
# echo "Fixing $exe $lib $libpath"
# install_name_tool -change $libpath @executable_path/../Frameworks/$lib $exe
# done
#done
cd ../bin
for exe in obabel obmm eht_bind genXrdPattern; do
for libpath in `otool -L ${exe} | grep '/Users/runner/work' | awk '{print $1}'`; do
export lib=`echo $libpath | cut -d '/' -f 9`;
echo "Fixing $exe $lib $libpath"
install_name_tool -change $libpath @executable_path/../Frameworks/$lib $exe
done
done
- name: Run tests
if: matrix.config.os == 'ubuntu-20.04'
Expand Down Expand Up @@ -314,7 +316,7 @@ jobs:

- name: Upload
if: matrix.config.artifact != 0
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
path: ${{ runner.workspace }}/build/avogadroapp/Avogadro2*.*
name: ${{ matrix.config.artifact }}
Expand All @@ -327,4 +329,3 @@ jobs:
rm -rf ./* || true
rm -rf ./.??* || true
ls -la ./
2 changes: 1 addition & 1 deletion .github/workflows/build_m1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ jobs:

- name: Upload
if: matrix.config.artifact != 0
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
path: ${{ runner.workspace }}/build/avogadroapp/Avogadro2*.*
name: ${{ matrix.config.artifact }}
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
CIBW_BEFORE_ALL_LINUX: yum install -y git eigen3-devel

# Specify eigen location for windows
CIBW_ENVIRONMENT_WINDOWS: "EXTRA_CMAKE_ARGS=-DEigen3_INCLUDE_DIR:PATH=/c/eigen"
CIBW_ENVIRONMENT_WINDOWS: "EXTRA_CMAKE_ARGS=-DEIGEN3_INCLUDE_DIR:PATH=/c/eigen"

# On Mac build both x64 and arm64
CIBW_ARCHS_MACOS: "x86_64 arm64"
Expand Down Expand Up @@ -52,22 +52,24 @@ jobs:
# give it a correct version even on non-tag push.
fetch-depth: 0

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.7'
python-version: '3.8'
cache: 'pip' # caching pip dependencies

- name: Install cibuildwheel
run: pip install cibuildwheel==2.12.3
run: pip install cibuildwheel==2.16.2

- name: Install dependencies
run: . ./scripts/github-actions/install.sh

- name: Build wheels
run: cibuildwheel --output-dir wheelhouse

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

upload_pypi:
Expand All @@ -77,7 +79,7 @@ jobs:
# upload to PyPI on every tag push
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Upload patch
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
path: ${{ runner.workspace }}/clang-format.diff
name: clang-format.diff
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
echo ${{ github.event.pull_request.head.repo.full_name }} > ${{ runner.workspace }}/clang-tidy-result/pr-head-repo.txt
echo ${{ github.event.pull_request.head.ref }} > ${{ runner.workspace }}/clang-tidy-result/pr-head-ref.txt
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: clang-tidy-result
path: ${{ runner.workspace }}/clang-tidy-result/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ jobs:
# Upload the SARIF file generated in the previous step
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: filtered.sarif
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
source-root: ${{ github.workspace }}/avogadrolibs
Expand All @@ -105,7 +105,7 @@ jobs:
shell: bash

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
checkout_path: ${{ github.workspace }}/avogadrolibs
2 changes: 1 addition & 1 deletion avogadro/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ target_sources(Headers PUBLIC
utilities.h
vector.h
)
target_link_libraries(Headers INTERFACE Eigen3::Eigen3)
target_link_libraries(Headers INTERFACE Eigen3::Eigen)
install(TARGETS Headers
EXPORT "AvogadroLibsTargets"
FILE_SET HEADERS DESTINATION "${INSTALL_INCLUDE_DIR}")
Expand Down
44 changes: 38 additions & 6 deletions avogadro/core/molecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ Molecule::Molecule()

Molecule::Molecule(const Molecule& other)
: m_data(other.m_data), m_partialCharges(other.m_partialCharges),
m_customElementMap(other.m_customElementMap), m_elements(other.m_elements),
m_positions2d(other.m_positions2d), m_positions3d(other.m_positions3d),
m_atomLabels(other.m_atomLabels), m_bondLabels(other.m_bondLabels),
m_coordinates3d(other.m_coordinates3d), m_timesteps(other.m_timesteps),
m_hybridizations(other.m_hybridizations),
m_spectra(other.m_spectra), m_customElementMap(other.m_customElementMap),
m_elements(other.m_elements), m_positions2d(other.m_positions2d),
m_positions3d(other.m_positions3d), m_atomLabels(other.m_atomLabels),
m_bondLabels(other.m_bondLabels), m_coordinates3d(other.m_coordinates3d),
m_timesteps(other.m_timesteps), m_hybridizations(other.m_hybridizations),
m_formalCharges(other.m_formalCharges), m_colors(other.m_colors),
m_vibrationFrequencies(other.m_vibrationFrequencies),
m_vibrationIRIntensities(other.m_vibrationIRIntensities),
Expand Down Expand Up @@ -79,7 +79,8 @@ Molecule::Molecule(const Molecule& other)

void Molecule::readProperties(const Molecule& other)
{
m_label = other.m_label;
m_atomLabels = other.m_atomLabels;
m_bondLabels = other.m_bondLabels;
m_colors = other.m_colors;
// merge data maps by iterating through other's map
for (auto it = other.m_data.constBegin(); it != other.m_data.constEnd();
Expand All @@ -93,6 +94,9 @@ void Molecule::readProperties(const Molecule& other)
m_partialCharges[it->first] = it->second;
}

// copy spectra
m_spectra = other.m_spectra;

// copy orbital information
SlaterSet* slaterSet = dynamic_cast<SlaterSet*>(other.m_basisSet);
if (slaterSet != nullptr) {
Expand Down Expand Up @@ -128,6 +132,7 @@ void Molecule::readProperties(const Molecule& other)

Molecule::Molecule(Molecule&& other) noexcept
: m_data(other.m_data), m_partialCharges(std::move(other.m_partialCharges)),
m_spectra(other.m_spectra),
m_customElementMap(std::move(other.m_customElementMap)),
m_elements(other.m_elements), m_positions2d(other.m_positions2d),
m_positions3d(other.m_positions3d), m_atomLabels(other.m_atomLabels),
Expand Down Expand Up @@ -167,6 +172,7 @@ Molecule& Molecule::operator=(const Molecule& other)
if (this != &other) {
m_data = other.m_data;
m_partialCharges = other.m_partialCharges;
m_spectra = other.m_spectra;
m_customElementMap = other.m_customElementMap;
m_elements = other.m_elements;
m_positions2d = other.m_positions2d;
Expand Down Expand Up @@ -229,6 +235,7 @@ Molecule& Molecule::operator=(Molecule&& other) noexcept
if (this != &other) {
m_data = other.m_data;
m_partialCharges = std::move(other.m_partialCharges);
m_spectra = other.m_spectra;
m_customElementMap = std::move(other.m_customElementMap);
m_elements = other.m_elements;
m_positions2d = other.m_positions2d;
Expand Down Expand Up @@ -325,6 +332,31 @@ std::set<std::string> Molecule::partialChargeTypes() const
return types;
}

std::set<std::string> Molecule::spectraTypes() const
{
std::set<std::string> types;
for (auto& it : m_spectra)
types.insert(it.first);
return types;
}

void Molecule::setSpectra(const std::string& type, const MatrixX& value)
{
m_spectra[type] = value;
}

MatrixX Molecule::spectra(const std::string& type) const
{
MatrixX value;

auto search = m_spectra.find(type);
if (search != m_spectra.end()) {
value = search->second; // value from the map
}

return value;
}

void Molecule::setFrozenAtom(Index atomId, bool frozen)
{
if (atomId >= m_atomicNumbers.size())
Expand Down
11 changes: 11 additions & 0 deletions avogadro/core/molecule.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ class AVOGADROCORE_EXPORT Molecule
/** \overload */
VariantMap& dataMap();

/** @return a specific spectra entry */
MatrixX spectra(const std::string& name) const;

/** Sets the spectra value with @p name to @p value. */
void setSpectra(const std::string& name, const MatrixX& value);

/** @return the list of available spectra */
std::set<std::string> spectraTypes() const;

/** Sets atomic partial charges with @p type to @p value. */
void setPartialCharges(const std::string& type, const MatrixX& value);

Expand Down Expand Up @@ -804,6 +813,8 @@ class AVOGADROCORE_EXPORT Molecule
VariantMap m_data;
std::map<std::string, MatrixX>
m_partialCharges; //!< Sets of atomic partial charges

std::map<std::string, MatrixX> m_spectra; //!< Sets of spectra
CustomElementMap m_customElementMap;
ElementMask m_elements; //!< Which elements this molecule contains (e.g., for
//!< force fields)
Expand Down
Loading

0 comments on commit e3f4078

Please sign in to comment.