-
Notifications
You must be signed in to change notification settings - Fork 19
refactor: Structure manipulation and SupercellConfigurationNode
#2530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
RobBuchananCompPhys
merged 7 commits into
develop2
from
dissolve2/supercell-config-node-and-structure-manipulation
Jun 24, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a4d2de8
structure manipulations and supercellconfigurationnode
RobBuchananCompPhys 53236a7
corrections
RobBuchananCompPhys 9e99da0
some pr comments - cosmetic/comments etc
RobBuchananCompPhys b0e7299
pr comments and test
RobBuchananCompPhys e3cfaf5
clang format
RobBuchananCompPhys 3dcbc5d
test passing
RobBuchananCompPhys d46deed
refactor loop
RobBuchananCompPhys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,69 @@ | ||
| // SPDX-License-Identifier: GPL-3.0-or-later | ||
| // Copyright (c) 2026 Team Dissolve and contributors | ||
|
|
||
| #include "nodes/supercellConfiguration.h" | ||
| #include "math/vector3.h" | ||
|
|
||
| SupercellConfigurationNode::SupercellConfigurationNode(Graph *parentGraph) : Node(parentGraph) | ||
| { | ||
| // Inputs | ||
| addInput("Configuration", "Target configuration", targetConfiguration_); | ||
|
|
||
| // Outputs | ||
| addPointerOutput("SupercellConfiguration", "Supercell configuration", supercellConfiguration_); | ||
|
|
||
| // Options | ||
| addOption("SupercellRepeat", "Integer coefficients by which unit cell will be repeated along its axes", supercellRepeat_); | ||
| } | ||
|
|
||
| /* | ||
| * Definition | ||
| */ | ||
|
|
||
| std::string_view SupercellConfigurationNode::type() const { return "SupercellConfiguration"; } | ||
|
|
||
| std::string_view SupercellConfigurationNode::summary() const | ||
| { | ||
| return "Create a repeated instance (supercell) of a configuration"; | ||
| } | ||
|
|
||
| /* | ||
| * Processing | ||
| */ | ||
|
|
||
| // Perform processing | ||
| NodeConstants::ProcessResult SupercellConfigurationNode::process() | ||
| { | ||
| supercellConfiguration_.empty(); | ||
|
|
||
| const auto &box = targetConfiguration_->box(); | ||
|
|
||
| // Set up configuration | ||
| auto supercellLengths = box.axisLengths(); | ||
| supercellLengths.multiply(supercellRepeat_.x, supercellRepeat_.y, supercellRepeat_.z); | ||
| supercellConfiguration_.createBoxAndCells(supercellLengths, box.axisAngles(), false); | ||
|
|
||
| // Create images of all molecular unit cell species | ||
| for (auto &mol : targetConfiguration_->molecules()) | ||
| { | ||
| const auto *sp = mol->species(); | ||
|
|
||
| // Loop over cell images | ||
| for (auto ix = 0; ix < supercellRepeat_.x; ++ix) | ||
| { | ||
| for (auto iy = 0; iy < supercellRepeat_.y; ++iy) | ||
| { | ||
| // Create and translate molecule | ||
| for (auto iz = 0; iz < supercellRepeat_.z; ++iz) | ||
| supercellConfiguration_.addMolecule(sp)->translate(box.axes() * Vector3(ix, iy, iz)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| supercellConfiguration_.updateObjectRelationships(); | ||
|
|
||
| message("Created ({}, {}, {}) supercell - {} atoms total.\n", supercellRepeat_.x, supercellRepeat_.y, supercellRepeat_.z, | ||
| supercellConfiguration_.nAtoms()); | ||
|
|
||
| return NodeConstants::ProcessResult::Success; | ||
| } |
This file contains hidden or 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,39 @@ | ||
| // SPDX-License-Identifier: GPL-3.0-or-later | ||
| // Copyright (c) 2026 Team Dissolve and contributors | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "classes/configuration.h" | ||
| #include "nodes/node.h" | ||
|
|
||
| class SupercellConfigurationNode : public Node | ||
| { | ||
| public: | ||
| SupercellConfigurationNode(Graph *parentGraph); | ||
| ~SupercellConfigurationNode() override = default; | ||
|
|
||
| /* | ||
| * Definition | ||
| */ | ||
| public: | ||
| std::string_view type() const override; | ||
| std::string_view summary() const override; | ||
|
|
||
| /* | ||
| * Data | ||
| */ | ||
| private: | ||
| // Input configuration | ||
| Configuration *targetConfiguration_{nullptr}; | ||
| // Supercell repeat | ||
| Vector3i supercellRepeat_; | ||
| // Supercell configuration | ||
| Configuration supercellConfiguration_; | ||
|
|
||
| /* | ||
| * Processing | ||
| */ | ||
| protected: | ||
| // Perform processing | ||
| NodeConstants::ProcessResult process() override; | ||
| }; |
This file contains hidden or 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 hidden or 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,17 @@ | ||
| 15 | ||
| Unnamed001 | ||
| C 5.000000 0.100000 5.000000 0.000000 | ||
| H 5.000000 1.100000 5.000000 0.000000 | ||
| H 5.000000 9.766193 4.057359 0.000000 | ||
| H 5.816351 9.766193 5.471321 0.000000 | ||
| H 4.183649 9.766193 5.471321 0.000000 | ||
| C 0.100000 5.000000 5.000000 0.000000 | ||
| H 1.100000 5.000000 5.000000 0.000000 | ||
| H 9.766193 5.000000 5.942641 0.000000 | ||
| H 9.766193 5.816351 4.528679 0.000000 | ||
| H 9.766193 4.183649 4.528679 0.000000 | ||
| C 5.000000 5.000000 0.100000 0.000000 | ||
| H 5.000000 5.000000 1.100000 0.000000 | ||
| H 5.000000 5.942641 9.766193 0.000000 | ||
| H 5.816351 4.528679 9.766193 0.000000 | ||
| H 4.183649 4.528679 9.766193 0.000000 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.