Skip to content

refactor: Test species as TOML#2424

Open
trisyoungs wants to merge 10 commits intodissolve2/tidy-up-species-intra-serialisationfrom
dissolve2/test-species-as-toml
Open

refactor: Test species as TOML#2424
trisyoungs wants to merge 10 commits intodissolve2/tidy-up-species-intra-serialisationfrom
dissolve2/test-species-as-toml

Conversation

@trisyoungs
Copy link
Copy Markdown
Member

@trisyoungs trisyoungs commented Apr 30, 2026

Follows #2422

This PR removes the code-based generation of test species in speciesData.h and replaces it with loading of TOML species now that AtomType and CommonTerm data is local to the Species class.

@trisyoungs trisyoungs requested review from RobBuchananCompPhys and rprospero and removed request for rprospero April 30, 2026 09:10
Comment thread tests/nodes/angle.cpp
// Set up the test graph
TestGraph testGraph;
testGraph.createConfiguration("Box", {{createWater, 267}}, 0.1);
testGraph.createConfiguration("Box", {{[]() { return TestGraph::loadTOMLSpecies("species/water-dlpoly.toml"); }, 267}},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this goes back to a question I asked in a PR some time ago - do we need to revisit the use of a lambda here (which in this case takes up code space with curly braces and empty lambda/arg capture)? If we still need the option to operate further on the created species, then this might be useful, otherwise, perhaps we could look at setting this argument to a simple std::pair<std::unique_ptr<SpeciesNode>, int>, or even just have an extra optional argument const std::optional<std::function<SpeciesNode *>()>> &speciesInitialiser = {} which is there as a back-up in case we want to call it further down the line like

if (speciesInitialiser)
    *speciesInitialiser(sp.get());

Comment on lines +447 to +451
if (box_->type() != Box::BoxType::NonPeriodic)
{
attachedAtomListsGenerated_ = false;
return;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be a more simple bouncer pattern?

Suggested change
if (box_->type() != Box::BoxType::NonPeriodic)
{
attachedAtomListsGenerated_ = false;
return;
}
attachedAtomListsGenerated_ = box_->type() != Box::BoxType::NonPeriodic;
if (attachedAtomListsGenerated_)
{
... // everything from line 455 to 561
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants