Ignore:
Timestamp:
Apr 28, 2021, 10:02:49 PM (4 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Candidate_v1.7.0, stable
Children:
e0e77e
Parents:
87c1cc
git-author:
Frederik Heber <frederik.heber@…> (04/17/21 09:41:33)
git-committer:
Frederik Heber <frederik.heber@…> (04/28/21 22:02:49)
Message:

SaturateAction may use outer shell information.

  • when considering the outer shell, then we look at both occupied and unoccupied orbitals. The ideal polygon will be created for the number of all orbitals, but only the unoccupied will be allowed to be taken by either present bonds or saturation hydrogens.
  • SphericalPointDistribution allows to occupy less than present points.
  • I have tested this manually by adding oxygen, saturation, adding carbon, saturating again, then turning oxygen into nitrogen and saturating. Results were always exactly as hoped for.
  • DOCU: Added note to action in userguide.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Exporters/unittests/SphericalPointDistributionUnitTest.cpp

    r87c1cc r2390e6  
    748748    expected += Vector(-1.,0.,0.);
    749749    SphericalPointDistribution::Polygon_t remaining =
    750         SPD.getRemainingPoints(polygon, 2);
     750        SPD.getRemainingPoints(polygon, 2, 2);
    751751//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    752752    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    760760    expected += Vector(0.,-1.,0.);
    761761    SphericalPointDistribution::Polygon_t remaining =
    762         SPD.getRemainingPoints(polygon, 2);
     762        SPD.getRemainingPoints(polygon, 2, 2);
    763763//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    764764    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    772772    expected += Vector(0.,0.,1.);
    773773    SphericalPointDistribution::Polygon_t remaining =
    774         SPD.getRemainingPoints(polygon, 2);
     774        SPD.getRemainingPoints(polygon, 2, 2);
    775775//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    776776    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    785785    expected += RotationAxis.rotateVector(Vector(-1.,0.,0.), 47.6/180*M_PI);
    786786    SphericalPointDistribution::Polygon_t remaining =
    787         SPD.getRemainingPoints(polygon, 2);
     787        SPD.getRemainingPoints(polygon, 2, 2);
    788788//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    789789    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    805805    expected.pop_front(); // remove first point
    806806    SphericalPointDistribution::Polygon_t remaining =
    807         SPD.getRemainingPoints(polygon, 3);
     807        SPD.getRemainingPoints(polygon, 3, 3);
    808808//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    809809    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    823823    }
    824824    SphericalPointDistribution::Polygon_t remaining =
    825         SPD.getRemainingPoints(polygon, 3);
     825        SPD.getRemainingPoints(polygon, 3, 3);
    826826//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    827827    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    838838    expected.pop_front(); // remove second point
    839839    SphericalPointDistribution::Polygon_t remaining =
    840         SPD.getRemainingPoints(polygon, 3);
     840        SPD.getRemainingPoints(polygon, 3, 3);
    841841//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    842842    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    861861      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    862862    SphericalPointDistribution::Polygon_t remaining =
    863         SPD.getRemainingPoints(polygon, 3);
     863        SPD.getRemainingPoints(polygon, 3, 3);
    864864//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    865865    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    880880    SphericalPointDistribution::Polygon_t expected; // empty cause none are vacant
    881881    SphericalPointDistribution::Polygon_t remaining =
    882         SPD.getRemainingPoints(polygon, 3);
     882        SPD.getRemainingPoints(polygon, 3, 3);
    883883//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    884884    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    901901    SphericalPointDistribution::Polygon_t expected; // empty cause none are vacant
    902902    SphericalPointDistribution::Polygon_t remaining =
    903         SPD.getRemainingPoints(polygon, 3);
     903        SPD.getRemainingPoints(polygon, 3, 3);
    904904//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    905905    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    925925    expected.pop_front(); // remove first point
    926926    SphericalPointDistribution::Polygon_t remaining =
    927         SPD.getRemainingPoints(polygon, 4);
     927        SPD.getRemainingPoints(polygon, 4, 4);
    928928    //    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    929929        CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    943943    }
    944944    SphericalPointDistribution::Polygon_t remaining =
    945         SPD.getRemainingPoints(polygon, 4);
     945        SPD.getRemainingPoints(polygon, 4, 4);
    946946//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    947947    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    958958    expected.pop_front(); // remove second point
    959959    SphericalPointDistribution::Polygon_t remaining =
    960         SPD.getRemainingPoints(polygon, 4);
     960        SPD.getRemainingPoints(polygon, 4, 4);
    961961//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    962962    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    977977    expected.pop_front(); // remove second point
    978978    SphericalPointDistribution::Polygon_t remaining =
    979         SPD.getRemainingPoints(polygon, 4);
     979        SPD.getRemainingPoints(polygon, 4, 4);
    980980//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    981981    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    10001000      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    10011001    SphericalPointDistribution::Polygon_t remaining =
    1002         SPD.getRemainingPoints(polygon, 4);
     1002        SPD.getRemainingPoints(polygon, 4, 4);
    10031003//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    10041004    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    10211021    expected.pop_front(); // remove third point
    10221022    SphericalPointDistribution::Polygon_t remaining =
    1023         SPD.getRemainingPoints(polygon, 4);
     1023        SPD.getRemainingPoints(polygon, 4, 4);
    10241024//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    10251025    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    10461046      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    10471047    SphericalPointDistribution::Polygon_t remaining =
    1048         SPD.getRemainingPoints(polygon, 4);
     1048        SPD.getRemainingPoints(polygon, 4, 4);
    10491049//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    10501050    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    10731073    expected += Vector(-0.5773502691896,-5.551115123126e-17,-0.8164965809277);
    10741074    SphericalPointDistribution::Polygon_t remaining =
    1075         SPD.getRemainingPoints(polygon, 4);
     1075        SPD.getRemainingPoints(polygon, 4, 4);
    10761076//    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
    10771077//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     
    10901090    expected += Vector(-0.3535533905933,-0.3535533905933,-0.8660254037844);
    10911091    SphericalPointDistribution::Polygon_t remaining =
    1092         SPD.getRemainingPoints(polygon, 5);
     1092        SPD.getRemainingPoints(polygon, 5, 5);
    10931093    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
    10941094//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     
    11081108    expected += Vector(0.3535534025157,-0.3535533856548,0.8660254009332);
    11091109    SphericalPointDistribution::Polygon_t remaining =
    1110         SPD.getRemainingPoints(polygon, 5);
     1110        SPD.getRemainingPoints(polygon, 5, 5);
    11111111//    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
    11121112//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     
    11251125    expected += Vector(0.,0.,-1.);
    11261126    SphericalPointDistribution::Polygon_t remaining =
    1127         SPD.getRemainingPoints(polygon, 6);
     1127        SPD.getRemainingPoints(polygon, 6, 6);
    11281128//    std::cout << std::setprecision(13) << "Matched polygon is " << remaining << std::endl;
    11291129//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     
    11461146    expected.pop_front(); // remove first point
    11471147    SphericalPointDistribution::Polygon_t remaining =
    1148         SPD.getRemainingPoints(polygon, 5);
     1148        SPD.getRemainingPoints(polygon, 5, 5);
    11491149//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    11501150    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    11641164    }
    11651165    SphericalPointDistribution::Polygon_t remaining =
    1166         SPD.getRemainingPoints(polygon, 5);
     1166        SPD.getRemainingPoints(polygon, 5, 5);
    11671167//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    11681168    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    11791179    expected.pop_front(); // remove second point
    11801180    SphericalPointDistribution::Polygon_t remaining =
    1181         SPD.getRemainingPoints(polygon, 5);
     1181        SPD.getRemainingPoints(polygon, 5, 5);
    11821182//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    11831183    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    12021202      *iter = RotationAxis.rotateVector(*iter, 47.6/180.*M_PI);
    12031203    SphericalPointDistribution::Polygon_t remaining =
    1204         SPD.getRemainingPoints(polygon, 5);
     1204        SPD.getRemainingPoints(polygon, 5, 5);
    12051205    // the three remaining points sit on a plane that may be rotated arbitrarily
    12061206    // so we cannot simply check for equality between expected and remaining
     
    12281228    expected.pop_front(); // remove third point
    12291229    SphericalPointDistribution::Polygon_t remaining =
    1230         SPD.getRemainingPoints(polygon, 5);
     1230        SPD.getRemainingPoints(polygon, 5, 5);
    12311231//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    12321232    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    12531253      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    12541254    SphericalPointDistribution::Polygon_t remaining =
    1255         SPD.getRemainingPoints(polygon, 5);
     1255        SPD.getRemainingPoints(polygon, 5, 5);
    12561256//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    12571257    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    12771277    expected.pop_front(); // remove first point
    12781278    SphericalPointDistribution::Polygon_t remaining =
    1279         SPD.getRemainingPoints(polygon, 6);
     1279        SPD.getRemainingPoints(polygon, 6, 6);
    12801280//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    12811281    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    12951295    }
    12961296    SphericalPointDistribution::Polygon_t remaining =
    1297         SPD.getRemainingPoints(polygon, 6);
     1297        SPD.getRemainingPoints(polygon, 6, 6);
    12981298//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    12991299    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    13101310    expected.pop_front(); // remove second spoint
    13111311    SphericalPointDistribution::Polygon_t remaining =
    1312         SPD.getRemainingPoints(polygon, 6);
     1312        SPD.getRemainingPoints(polygon, 6, 6);
    13131313//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    13141314    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    13331333      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    13341334    SphericalPointDistribution::Polygon_t remaining =
    1335         SPD.getRemainingPoints(polygon, 6);
     1335        SPD.getRemainingPoints(polygon, 6, 6);
    13361336    // the four remaining points sit on a plane that may have been rotated arbitrarily
    13371337    // so we cannot simply check for equality between expected and remaining
     
    13591359    expected.pop_front(); // remove third point
    13601360    SphericalPointDistribution::Polygon_t remaining =
    1361         SPD.getRemainingPoints(polygon, 6);
     1361        SPD.getRemainingPoints(polygon, 6, 6);
    13621362//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    13631363    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    13841384      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    13851385    SphericalPointDistribution::Polygon_t remaining =
    1386         SPD.getRemainingPoints(polygon, 6);
     1386        SPD.getRemainingPoints(polygon, 6, 6);
    13871387//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    13881388    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    14081408    expected.pop_front(); // remove first point
    14091409    SphericalPointDistribution::Polygon_t remaining =
    1410         SPD.getRemainingPoints(polygon, 7);
     1410        SPD.getRemainingPoints(polygon, 7, 7);
    14111411//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    14121412    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    14261426    }
    14271427    SphericalPointDistribution::Polygon_t remaining =
    1428         SPD.getRemainingPoints(polygon, 7);
     1428        SPD.getRemainingPoints(polygon, 7, 7);
    14291429//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    14301430    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    14411441    expected.pop_front(); // remove second point
    14421442    SphericalPointDistribution::Polygon_t remaining =
    1443         SPD.getRemainingPoints(polygon, 7);
     1443        SPD.getRemainingPoints(polygon, 7, 7);
    14441444//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    14451445    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    14641464      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    14651465    SphericalPointDistribution::Polygon_t remaining =
    1466         SPD.getRemainingPoints(polygon, 7);
     1466        SPD.getRemainingPoints(polygon, 7, 7);
    14671467    // the five remaining points sit on a plane that may have been rotated arbitrarily
    14681468    // so we cannot simply check for equality between expected and remaining
     
    14901490    expected.pop_front(); // remove third point
    14911491    SphericalPointDistribution::Polygon_t remaining =
    1492         SPD.getRemainingPoints(polygon, 7);
     1492        SPD.getRemainingPoints(polygon, 7, 7);
    14931493//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    14941494    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    15151515      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    15161516    SphericalPointDistribution::Polygon_t remaining =
    1517         SPD.getRemainingPoints(polygon, 7);
     1517        SPD.getRemainingPoints(polygon, 7, 7);
    15181518//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    15191519    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    15391539    expected.pop_front(); // remove first point
    15401540    SphericalPointDistribution::Polygon_t remaining =
    1541         SPD.getRemainingPoints(polygon, 8);
     1541        SPD.getRemainingPoints(polygon, 8, 8);
    15421542//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    15431543    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    15571557    }
    15581558    SphericalPointDistribution::Polygon_t remaining =
    1559         SPD.getRemainingPoints(polygon, 8);
     1559        SPD.getRemainingPoints(polygon, 8, 8);
    15601560//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    15611561    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    15721572    expected.pop_front(); // remove second point
    15731573    SphericalPointDistribution::Polygon_t remaining =
    1574         SPD.getRemainingPoints(polygon, 8);
     1574        SPD.getRemainingPoints(polygon, 8, 8);
    15751575//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    15761576    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    15951595      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    15961596    SphericalPointDistribution::Polygon_t remaining =
    1597         SPD.getRemainingPoints(polygon, 8);
     1597        SPD.getRemainingPoints(polygon, 8, 8);
    15981598    // the six remaining points sit on two planes that may have been rotated arbitrarily
    15991599    // so we cannot simply check for equality between expected and remaining
     
    16251625    expected.pop_front(); // remove third point
    16261626    SphericalPointDistribution::Polygon_t remaining =
    1627         SPD.getRemainingPoints(polygon, 8);
     1627        SPD.getRemainingPoints(polygon, 8, 8);
    16281628//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    16291629    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     
    16501650      *iter = RotationAxis.rotateVector(*iter, 47.6/180*M_PI);
    16511651    SphericalPointDistribution::Polygon_t remaining =
    1652         SPD.getRemainingPoints(polygon, 8);
    1653 //    CPPUNIT_ASSERT_EQUAL( expected, remaining );
    1654     CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
    1655     // also slightly perturbed
    1656     const double amplitude = 0.05;
    1657     perturbPolygon(polygon, amplitude);
    1658     CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
    1659   }
    1660 }
     1652        SPD.getRemainingPoints(polygon, 8, 8);
     1653//    CPPUNIT_ASSERT_EQUAL( expected, remaining );
     1654    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, CenterAccuracy) );
     1655    // also slightly perturbed
     1656    const double amplitude = 0.05;
     1657    perturbPolygon(polygon, amplitude);
     1658    CPPUNIT_ASSERT( areEqualToWithinBounds(expected, remaining, amplitude) );
     1659  }
     1660}
Note: See TracChangeset for help on using the changeset viewer.