Skip to content

Commit

Permalink
Merge pull request #134 from NWChemEx/pt_bindings
Browse files Browse the repository at this point in the history
Python bindings for property types
  • Loading branch information
keceli authored Dec 13, 2023
2 parents 2a52691 + ae0cfdf commit d3c6743
Show file tree
Hide file tree
Showing 18 changed files with 440 additions and 29 deletions.
39 changes: 39 additions & 0 deletions src/python/atoms/export_atoms.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2023 NWChemEx-Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once
#include "../export_simde.hpp"
#include <pluginplay/pluginplay.hpp>
#include <simde/atoms/atoms.hpp>

namespace simde {

inline void export_atoms(python_module_reference m) {
EXPORT_PROPERTY_TYPE(AtomFromZ, m);
EXPORT_PROPERTY_TYPE(AtomFromSym, m);
EXPORT_PROPERTY_TYPE(AtomDenFromZ, m);
EXPORT_PROPERTY_TYPE(AtomDenFromSym, m);
EXPORT_PROPERTY_TYPE(ElecConfigFromZ, m);
EXPORT_PROPERTY_TYPE(ElecConfigFromSym, m);
EXPORT_PROPERTY_TYPE(FracConfigFromZ, m);
EXPORT_PROPERTY_TYPE(FracConfigFromSym, m);
EXPORT_PROPERTY_TYPE(FullConfigFromZ, m);
EXPORT_PROPERTY_TYPE(FullConfigFromSym, m);
EXPORT_PROPERTY_TYPE(SymbolFromZ, m);
EXPORT_PROPERTY_TYPE(ZFromSymbol, m);
}

} // namespace simde
5 changes: 4 additions & 1 deletion src/python/basis_set/export_basis_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
#pragma once
#include "../export_simde.hpp"
#include <pluginplay/pluginplay.hpp>
#include <simde/basis_sets/atomic_basis_set.hpp>
#include <simde/basis_sets/molecular_basis_set.hpp>

namespace simde {

inline void export_molecular_basis_set(python_module_reference m) {
inline void export_basis_set(python_module_reference m) {
EXPORT_PROPERTY_TYPE(AtomicBasisSetFromZ, m);
EXPORT_PROPERTY_TYPE(AtomicBasisSetFromSym, m);
EXPORT_PROPERTY_TYPE(MolecularBasisSet, m);
}

Expand Down
31 changes: 31 additions & 0 deletions src/python/density/export_density.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2023 NWChemEx-Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once
#include "../export_simde.hpp"
#include <pluginplay/pluginplay.hpp>
#include <simde/density/density.hpp>

namespace simde {

inline void export_density(python_module_reference m) {
EXPORT_PROPERTY_TYPE(SCFDensity, m);
EXPORT_PROPERTY_TYPE(InitialDensity, m);
EXPORT_PROPERTY_TYPE(SCFGuessDensity, m);
EXPORT_PROPERTY_TYPE(SCFDensityStep, m);
}

} // namespace simde
29 changes: 29 additions & 0 deletions src/python/derivative/export_derivative.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2023 NWChemEx-Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once
#include "../export_simde.hpp"
#include <pluginplay/pluginplay.hpp>
#include <simde/derivative/derivative.hpp>

namespace simde {

inline void export_derivative(python_module_reference m) {
EXPORT_PROPERTY_TYPE(AOEnergyNuclearGradient, m);
EXPORT_PROPERTY_TYPE(AOEnergyNuclearHessian, m);
}

} // namespace simde
3 changes: 0 additions & 3 deletions src/python/energy/export_energy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ namespace simde {

inline void export_energy(python_module_reference m) {
EXPORT_PROPERTY_TYPE(Energy, m);
}

inline void export_aoenergy(python_module_reference m) {
EXPORT_PROPERTY_TYPE(AOEnergy, m);
}

Expand Down
12 changes: 9 additions & 3 deletions src/python/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,25 @@
* limitations under the License.
*/

#include "atoms/export_atoms.hpp"
#include "basis_set/export_basis_set.hpp"
#include "density/export_density.hpp"
#include "derivative/export_derivative.hpp"
#include "energy/export_energy.hpp"
#include "export_simde.hpp"
#include "operators/export_operators.hpp"

namespace simde {

PYBIND11_MODULE(simde, m) {
m.doc() =
"PySimDE: Python bindings for the Simulation development environment";

export_atoms(m);
export_basis_set(m);
export_density(m);
export_derivative(m);
export_energy(m);
export_aoenergy(m);
export_molecular_basis_set(m);
export_operators(m);
}

} // namespace simde
29 changes: 29 additions & 0 deletions src/python/operators/export_operators.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2023 NWChemEx-Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once
#include "../export_simde.hpp"
#include <pluginplay/pluginplay.hpp>
#include <simde/operators/operators.hpp>

namespace simde {

inline void export_operators(python_module_reference m) {
EXPORT_PROPERTY_TYPE(FockOp, m);
EXPORT_PROPERTY_TYPE(SystemHamiltonian, m);
}

} // namespace simde
13 changes: 13 additions & 0 deletions tests/python/unit_tests/atoms/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2023 NWChemEx-Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
88 changes: 88 additions & 0 deletions tests/python/unit_tests/atoms/test_atoms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Copyright 2023 NWChemEx-Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import simde
from test_property_type import BaseTestPropertyType

class TestAtomFromZ(BaseTestPropertyType):
def setUp(self):
self.pt = simde.AtomFromZ()
self.input_labels = ['Atom ID']
self.result_labels = ['Atom']

class TestAtomFromSym(BaseTestPropertyType):
def setUp(self):
self.pt = simde.AtomFromSym()
self.input_labels = ['Atom ID']
self.result_labels = ['Atom']

class TestAtomDenFromZ(BaseTestPropertyType):
def setUp(self):
self.pt = simde.AtomDenFromZ()
self.input_labels = ['Atom ID']
self.result_labels = ['Atomic Density']

class TestAtomDenFromSym(BaseTestPropertyType):
def setUp(self):
self.pt = simde.AtomDenFromSym()
self.input_labels = ['Atom ID']
self.result_labels = ['Atomic Density']

class TestElecConfigFromZ(BaseTestPropertyType):
def setUp(self):
self.pt = simde.ElecConfigFromZ()
self.input_labels = ['Atom ID']
self.result_labels = ['Electronic Configuration']

class TestElecConfigFromSym(BaseTestPropertyType):
def setUp(self):
self.pt = simde.ElecConfigFromSym()
self.input_labels = ['Atom ID']
self.result_labels = ['Electronic Configuration']

class TestFracConfigFromZ(BaseTestPropertyType):
def setUp(self):
self.pt = simde.FracConfigFromZ()
self.input_labels = ['Atom ID']
self.result_labels = ['Electronic Configuration']

class TestFracConfigFromSym(BaseTestPropertyType):
def setUp(self):
self.pt = simde.FracConfigFromSym()
self.input_labels = ['Atom ID']
self.result_labels = ['Electronic Configuration']

class TestFullConfigFromZ(BaseTestPropertyType):
def setUp(self):
self.pt = simde.FullConfigFromZ()
self.input_labels = ['Atom ID']
self.result_labels = ['Electronic Configuration']

class TestFullConfigFromSym(BaseTestPropertyType):
def setUp(self):
self.pt = simde.FullConfigFromSym()
self.input_labels = ['Atom ID']
self.result_labels = ['Electronic Configuration']

class testSymbolFromZ(BaseTestPropertyType):
def setUp(self):
self.pt = simde.SymbolFromZ()
self.input_labels = ['Z']
self.result_labels = ['Symbol']

class testZFromSymbol(BaseTestPropertyType):
def setUp(self):
self.pt = simde.ZFromSymbol()
self.input_labels = ['Symbol']
self.result_labels = ['Z']
26 changes: 18 additions & 8 deletions tests/python/unit_tests/basis_set/test_basis_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,22 @@
# limitations under the License.

import simde
import unittest
from test_property_type import BaseTestPropertyType

class TestBasisSet(unittest.TestCase):
def test_molecular_basis_set_pt(self):
pt = simde.MolecularBasisSet()
self.assertIn('Molecule', pt.inputs())
self.assertEqual(len(pt.inputs()), 1)
self.assertIn('Molecular Basis Set', pt.results())
self.assertEqual(len(pt.results()), 1)
class TestAtomicBasisSetFromZ(BaseTestPropertyType):
def setUp(self):
self.pt = simde.AtomicBasisSetFromZ()
self.input_labels= ['Atom ID']
self.result_labels = ['Atomic Basis Set']

class TestAtomicBasisSetFromSym(BaseTestPropertyType):
def setUp(self):
self.pt = simde.AtomicBasisSetFromSym()
self.input_labels= ['Atom ID']
self.result_labels = ['Atomic Basis Set']

class TestMolecularBasisSet(BaseTestPropertyType):
def setUp(self):
self.pt = simde.MolecularBasisSet()
self.input_labels= ['Molecule']
self.result_labels = ['Molecular Basis Set']
13 changes: 13 additions & 0 deletions tests/python/unit_tests/density/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2023 NWChemEx-Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
40 changes: 40 additions & 0 deletions tests/python/unit_tests/density/test_atoms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2023 NWChemEx-Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import simde
from test_property_type import BaseTestPropertyType

class TestSCFDensity(BaseTestPropertyType):
def setUp(self):
self.pt = simde.SCFDensity()
self.input_labels = ['Phi0']
self.result_labels = ['Density']

class TestInitialDensity(BaseTestPropertyType):
def setUp(self):
self.pt = simde.InitialDensity()
self.input_labels = ['Hamiltonian']
self.result_labels = ['Density']

class TestSCFGuessDensity(BaseTestPropertyType):
def setUp(self):
self.pt = simde.SCFGuessDensity()
self.input_labels = ['Hamiltonian', 'Input Space']
self.result_labels = ['Output Density']

class TestSCFDensityStep(BaseTestPropertyType):
def setUp(self):
self.pt = simde.SCFDensityStep()
self.input_labels = ['Hamiltonian', 'Input Space']
self.result_labels = ['Output Density']
13 changes: 13 additions & 0 deletions tests/python/unit_tests/derivative/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2023 NWChemEx-Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Loading

0 comments on commit d3c6743

Please sign in to comment.