-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Voronoi analysis using Voronota-LT (#444)
* Add voronotalt headers * Add voronoi analysis * Add test * Make voronotalt header a system header * Update documentation * DOI to voronota-lt * Detect and log PBC information * Support PBC
- Loading branch information
Showing
20 changed files
with
3,400 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,8 @@ analysis: | |
molecule: mymolecule | ||
radius: 2.0 | ||
nstep: 1 | ||
- voronoi: | ||
file: voronoi_sasa.dat | ||
radius: 2.0 | ||
nstep: 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#include "analysis.h" | ||
#include "mpicontroller.h" | ||
#include <voronotalt/voronotalt.h> | ||
#include <numeric> | ||
|
||
namespace Faunus::analysis { | ||
|
||
Voronota::Voronota(double probe_radius, const Faunus::Space& spc) | ||
: Analysis(spc, "voronota") | ||
, probe_radius(probe_radius) { | ||
cite = "doi:10/mq8k"; | ||
auto n_pbc = spc.geometry.asSimpleGeometry()->boundary_conditions.isPeriodic().count(); | ||
switch (n_pbc) { | ||
case 0: | ||
faunus_logger->debug("{}: No PBC detected", name); | ||
use_pbc = false; | ||
break; | ||
case 3: | ||
faunus_logger->debug("{}: 3D PBC detected", name); | ||
use_pbc = true; | ||
break; | ||
default: | ||
faunus_logger->warn("{}: Non-uniform PBC is currently ignored - be careful!", name); | ||
use_pbc = false; | ||
} | ||
} | ||
|
||
Voronota::Voronota(const Faunus::json& input, const Faunus::Space& spc) | ||
: Voronota(input.value("radius", 1.4_angstrom), spc) { | ||
from_json(input); | ||
} | ||
|
||
void Voronota::_from_json(const Faunus::json& input) { | ||
if (filename = input.value("file", ""s); !filename.empty()) { | ||
output_stream = IO::openCompressedOutputStream(MPI::prefix + filename); | ||
*output_stream << "# step SASA\n"; | ||
} | ||
} | ||
|
||
void Voronota::_to_json(json& json_ouput) const { | ||
if (!average_data.area.empty()) { | ||
json_ouput = {{"⟨SASA⟩", average_data.area.avg()}, | ||
{"⟨SASA²⟩-⟨SASA⟩²", average_data.area_squared.avg() - std::pow(average_data.area.avg(), 2)}}; | ||
} | ||
json_ouput["radius"] = probe_radius; | ||
} | ||
|
||
void Voronota::_to_disk() { | ||
if (output_stream) { | ||
output_stream->flush(); | ||
} | ||
} | ||
|
||
void Voronota::_sample() { | ||
using voronotalt::SimplePoint; | ||
using namespace ranges::cpp20::views; | ||
|
||
// Convert single `Particle` to Voronota's `SimpleSphere` | ||
auto to_sphere = [&](const Particle& p) -> voronotalt::SimpleSphere { | ||
return {{p.pos.x(), p.pos.y(), p.pos.z()}, 0.5 * p.traits().sigma + probe_radius}; | ||
}; | ||
const auto spheres = spc.activeParticles() | transform(to_sphere) | ranges::to_vector; | ||
|
||
voronotalt::RadicalTessellation::Result result; | ||
|
||
if (use_pbc) { | ||
auto to_point = [](const Point& p) -> SimplePoint { return {p.x(), p.y(), p.z()}; }; | ||
const auto corner = 0.5 * spc.geometry.getLength(); | ||
const std::vector<SimplePoint> box_corners = {to_point(-corner), to_point(corner)}; | ||
voronotalt::RadicalTessellation::construct_full_tessellation(spheres, box_corners, result); | ||
} else { | ||
voronotalt::RadicalTessellation::construct_full_tessellation(spheres, result); | ||
} | ||
|
||
auto areas = result.cells_summaries | transform([](auto& s) { return s.sas_area; }); | ||
const auto total_area = std::accumulate(areas.begin(), areas.end(), 0.0); | ||
average_data.area.add(total_area); | ||
average_data.area_squared.add(total_area * total_area); | ||
|
||
if (output_stream) { | ||
*output_stream << this->getNumberOfSteps() << " " << total_area << "\n"; | ||
} | ||
} | ||
|
||
} // namespace Faunus::analysis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2023 Kliment Olechnovic | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Voronota-LT version 0.9.2 |
Oops, something went wrong.