Skip to content

Commit

Permalink
Merge branch 'master' into 'release'
Browse files Browse the repository at this point in the history
Zeta normalization was applied twice in tests.

See merge request luechow-group/inPsights!8
  • Loading branch information
heueristik committed Apr 26, 2021
2 parents 69aa76b + 01c275d commit 3000fa9
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 4 deletions.
18 changes: 18 additions & 0 deletions .gitlab/issue_templates/Bug Report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Problem Definition

<!-- Provide a description of what is the current problem and why you are raising this issue.
If it's a bug please describe what was the unexpected thing that occured and what was the
expected behaviour. -->

## Files and Logs

<!-- Provide files and logs of an (minimal) example
together with an instruction on how to reproduce the error. -->


### System Description


Operating system:

inPsights version:
14 changes: 14 additions & 0 deletions .gitlab/issue_templates/Feature Request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Abstract

<!-- Please describe by example what problem you see in the current Amolqc implementation
that you would like addressed.-->

## Motivation

<!-- Why do you think this feature should be addressed.
What is the value added to the users of Amolqc and why would they want to have it implemented? -->

## Specification

<!-- If the feature is technical in nature
please write as detailed as possible a specification of what needs to be built. -->
7 changes: 5 additions & 2 deletions src/BaseLib/resources/TestMolecules.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,13 @@ namespace TestMolecules {
}

namespace HeH {
const MolecularGeometry nuclei = {
AtomsVector({
{Element::He, {0, 0, 0.37}},
{Element::H, {0, 0, -0.37}}}),{}};
namespace ElectronsInCores {
const MolecularGeometry normal = {
AtomsVector({{Element::He,{0, 0, 0.37}},
{Element::H, {0, 0,-0.37}}}),
nuclei.atoms(),
ElectronsVector({{Spin::alpha,{0, 0, 0.37}},
{Spin::alpha,{0, 0, 0.37}},
{Spin::beta, {0, 0,-0.37}}})};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ namespace SOAP {
const TypeSpecificNeighborhoodsAtOneCenter &expansions2,
double zeta = General::settings.zeta());

double kernelDistance(const Environment &e1,
const Environment &e2,
double zeta = General::settings.zeta());

double kernelDistance(const TypeSpecificNeighborhoodsAtOneCenter &expansions1,
const TypeSpecificNeighborhoodsAtOneCenter &expansions2,
double zeta = General::settings.zeta());
Expand Down
14 changes: 12 additions & 2 deletions src/Methods/StructuralSimilarity/SOAP/source/LocalSimilarity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace SOAP {
auto expansion1 = expander.computeParticularExpansions(e1);
auto expansion2 = expander.computeParticularExpansions(e2);

return pow(kernel(expansion1, expansion2), zeta);
return kernel(expansion1, expansion2, zeta);
}

double unnormalizedKernel(const Environment &e1, const Environment &e2) {
Expand Down Expand Up @@ -110,9 +110,19 @@ namespace SOAP {
double kernelDistance(const TypeSpecificNeighborhoodsAtOneCenter &expansions1,
const TypeSpecificNeighborhoodsAtOneCenter &expansions2, double zeta) {

return sqrt(2.0 - 2.0 * kernel(expansions1, expansions1, zeta));
return sqrt(2.0 - 2.0 * kernel(expansions1, expansions2, zeta));
}

double kernelDistance(const Environment &e1, const Environment &e2, double zeta) {
assert(zeta > 0 && "Zeta must be positive.");
NeighborhoodExpander expander;
auto expansion1 = expander.computeParticularExpansions(e1);
auto expansion2 = expander.computeParticularExpansions(e2);

return kernelDistance(expansion1, expansion2, zeta);
}



double internal::typeAgnostic(const TypeSpecificNeighborhoodsAtOneCenter &expansions) {
int noneType = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,32 @@ class ALocalSimilarityTest : public ::testing::Test {
};
};

TEST_F(ALocalSimilarityTest, LocalSimilarityMaxSimilarityBound) {
General::settings.mode = General::Mode::chemical;
ParticleKit::create(TestMolecules::H2::nuclei);

auto H2 = TestMolecules::H2::nuclei;

Environment h0(H2, EnumeratedType<int>(int(Element::H), 0));
Environment h1(H2, EnumeratedType<int>(int(Element::H), 1));

ASSERT_NEAR(LocalSimilarity::kernel(h0, h1), 1.0, eps);
ASSERT_NEAR(LocalSimilarity::kernelDistance(h0, h1), 0.0, eps);
}

TEST_F(ALocalSimilarityTest, LocalSimilarityMinSimilarityBound) {
General::settings.mode = General::Mode::chemical;
ParticleKit::create(TestMolecules::HeH::nuclei);

auto HeH = TestMolecules::HeH::nuclei;

Environment he0(HeH, EnumeratedType<int>(int(Element::He), 0));
Environment h0(HeH, EnumeratedType<int>(int(Element::H), 0));

ASSERT_NEAR(LocalSimilarity::kernel(he0, h0), 0.0, eps);
ASSERT_NEAR(LocalSimilarity::kernelDistance(he0, h0), std::sqrt(2.0), eps);
}

TEST_F(ALocalSimilarityTest, GenericNormalization) {
ParticleKit::create(molecule);
General::settings.mode = General::Mode::typeAgnostic;
Expand Down

0 comments on commit 3000fa9

Please sign in to comment.