Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
538 changes: 538 additions & 0 deletions src/data/spaceGroups.cpp

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/data/spaceGroups.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#pragma once

#include "base/enumOptions.h"
#include "math/matrix4.h"
#include "sginfo/sginfo.h"
#include "templates/optionalRef.h"
Expand Down Expand Up @@ -551,6 +552,9 @@ enum SpaceGroupId
SpaceGroup_230,
nSpaceGroupIds
};
// Return enum option info for SpaceGroupID
EnumOptions<SpaceGroupId> spaceGroupID();
EnumOptions<SpaceGroupId> getEnumOptions(SpaceGroupId);

// Space Group Symbols
class SpaceGroupSymbol
Expand Down
3 changes: 3 additions & 0 deletions src/io/import/cif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,9 @@ bool CIFHandler::isValid() const
return !molecularSpecies_.empty() || supercellSpecies_.fragment(0).size() != supercellSpecies_.nAtoms();
}

// Return supercell species
const Species &CIFHandler::supercellSpecies() const { return supercellSpecies_; }

// Return cleaned unit cell species
const Species &CIFHandler::cleanedUnitCellSpecies() const { return cleanedUnitCellSpecies_; }

Expand Down
2 changes: 2 additions & 0 deletions src/io/import/cif.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ class CIFHandler
bool generate(CIFGenerationStage fromStage = CIFGenerationStage::CreateBasicUnitCell);
// Return whether the generated data is valid
bool isValid() const;
// Return supercell species
const Species &supercellSpecies() const;
// Return cleaned unit cell species
const Species &cleanedUnitCellSpecies() const;
// Return the detected molecular species
Expand Down
35 changes: 35 additions & 0 deletions src/nodes/cifBondingOptions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 Team Dissolve and contributors

#include "nodes/cifBondingOptions.h"

CIFBondingOptionsNode::CIFBondingOptionsNode(Graph *parentGraph) : Node(parentGraph)
{
// Inputs
addInput<CIFLoaderNode::CIFContext *>("CIFContext", "CIF handling context derived from parsing of CIF file", context_)
->setFlags({ParameterBase::Required});

// Outputs
addOutput<CIFLoaderNode::CIFContext *>("CIFContext", "CIF handling context derived from parsing of CIF file", context_);

// Options
addOption<Number>("BondingTolerance", "Bonding tolerance, if calculating bonding rather than using CIF definitions",
bondingTolerance_);
addOption<bool>("UseCIFBondingDefinitions", "Whether to use CIF bonding definitions", useCIFBondingDefinitions_);
addOption<bool>("PreventMetallicBonds", "Whether to prevent metallic bonding", preventMetallicBonds_);
}

std::string_view CIFBondingOptionsNode::type() const { return "CIFBondingOptions"; }

std::string_view CIFBondingOptionsNode::summary() const { return "Apply bonding options to a CIF context"; }

// Run main processing
NodeConstants::ProcessResult CIFBondingOptionsNode::process()
{

context_->setBondingTolerance(bondingTolerance_.asDouble());
context_->setUseCIFBondingDefinitions(useCIFBondingDefinitions_);
context_->setPreventMetallicBonds(preventMetallicBonds_);

return NodeConstants::ProcessResult::Success;
}
39 changes: 39 additions & 0 deletions src/nodes/cifBondingOptions.h
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 "nodes/cifLoader.h"
#include "nodes/node.h"

// CIFLoader Node
class CIFBondingOptionsNode : public Node
{
public:
CIFBondingOptionsNode(Graph *parentGraph);
~CIFBondingOptionsNode() override = default;

public:
std::string_view type() const override;
std::string_view summary() const override;

/*
* Definition
*/
private:
// CIF handler context
CIFLoaderNode::CIFContext *context_{nullptr};
// Bonding tolerance, if calculating bonding rather than using CIF definitions
Number bondingTolerance_{1.1};
// Whether to use CIF bonding definitions
bool useCIFBondingDefinitions_{false};
// Whether to prevent metallic bonding
bool preventMetallicBonds_{true};

/*
* Processing
*/
private:
// Run main processing
NodeConstants::ProcessResult process() override;
};
51 changes: 51 additions & 0 deletions src/nodes/cifConfiguration.cpp
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As briefly discussed, it is probably worth having a separate Configuration-maker node for each type of crystal cell we're generating (supercell, non-periodic, full species etc.).

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 Team Dissolve and contributors

#include "nodes/cifConfiguration.h"
#include <algorithm>
#include <iterator>

CIFConfigurationNode::CIFConfigurationNode(Graph *parentGraph) : Node(parentGraph)
{
// Inputs
addInput<CIFLoaderNode::CIFContext *>("CIFContext", "CIF handling context derived from parsing of CIF file", context_)
->setFlags({ParameterBase::Required});

// Outputs
addOutput<const Species *>("UnitCellSpecies", "Cleaned unit cell", unitCellSpecies_);
addOutput<const Species *>("SuperCellSpecies", "Supercell species", supercellSpecies_);
addOutput<std::vector<CIFMolecularSpecies>>("MolecularSpecies", "Detected molecular species", molecularSpecies_);
addOutput<Configuration *>("SuperCellConfiguration", "Supercell configuration pointer", supercellConfiguration_);

// Options
addOption<Vector3i>("SuperCellRepeat", "Supercell repeat", supercellRepeat_);
}

std::string_view CIFConfigurationNode::type() const { return "CIFConfiguration"; }

std::string_view CIFConfigurationNode::summary() const { return "Generate a supercell configuration from a CIF context"; }

// Run main processing
NodeConstants::ProcessResult CIFConfigurationNode::process()
{

// Generate from CIF context
context_->setSupercellRepeat(supercellRepeat_);
context_->generate();

// Get supercell configuration
supercellConfiguration_ = context_->generatedConfiguration();

// Get cleaned unit cell species
unitCellSpecies_ = &(context_->cleanedUnitCellSpecies());

// Get supercell species
supercellSpecies_ = &(context_->supercellSpecies());

// Get detected molecular species
auto &cifMols = context_->molecularSpecies();
molecularSpecies_.clear();
std::copy(cifMols.begin(), cifMols.end(), std::back_inserter(molecularSpecies_));

return NodeConstants::ProcessResult::Success;
}
43 changes: 43 additions & 0 deletions src/nodes/cifConfiguration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 Team Dissolve and contributors

#pragma once

#include "nodes/cifLoader.h"
#include "nodes/node.h"

// CIFLoader Node
class CIFConfigurationNode : public Node
{
public:
CIFConfigurationNode(Graph *parentGraph);
~CIFConfigurationNode() override = default;

public:
std::string_view type() const override;
std::string_view summary() const override;

/*
* Definition
*/
private:
// CIF handler context
CIFLoaderNode::CIFContext *context_{nullptr};
// Supercell configuration
Configuration *supercellConfiguration_{nullptr};
// Unit cell species
const Species *unitCellSpecies_{nullptr};
// Supercell species
const Species *supercellSpecies_{nullptr};
// Detected molecular species
std::vector<CIFMolecularSpecies> molecularSpecies_;
// Supercell repeat
Vector3i supercellRepeat_{1, 1, 1};

/*
* Processing
*/
private:
// Run main processing
NodeConstants::ProcessResult process() override;
};
41 changes: 41 additions & 0 deletions src/nodes/cifLoader.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 Team Dissolve and contributors

#include "nodes/cifLoader.h"
#include <sstream>
#include <string>
#include <vector>

CIFLoaderNode::CIFLoaderNode(Graph *parentGraph) : Node(parentGraph)
{
// Outputs
addPointerOutput<CIFContext>("CIFContext", "CIF handling context derived from parsing of CIF file", context_)
->setFlags({ParameterBase::Required});

// Option
addOption<std::string>("FilePath", "File path", filePath_);
addOption<SpaceGroups::SpaceGroupId>("SpaceGroupID", "Set space group from index", spaceGroup_);
}

std::string_view CIFLoaderNode::type() const { return "CIFLoader"; }

std::string_view CIFLoaderNode::summary() const
{
return "Load a CIF file and apply contained crystallographic data to a target configuration";
}

// Run main processing
NodeConstants::ProcessResult CIFLoaderNode::process()
{
// Read contents of CIF file
if (context_.read(filePath_))
{
if (spaceGroup_ != SpaceGroups::NoSpaceGroup)
context_.setSpaceGroup(spaceGroup_);
return NodeConstants::ProcessResult::Success;
}

error("Failed to read contents of CIF file");

return NodeConstants::ProcessResult::Failed;
}
40 changes: 40 additions & 0 deletions src/nodes/cifLoader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 Team Dissolve and contributors

#pragma once

#include "io/import/cif.h"
#include "nodes/node.h"

// CIFLoader Node
class CIFLoaderNode : public Node
{
public:
using CIFContext = CIFHandler;

public:
CIFLoaderNode(Graph *parentGraph);
~CIFLoaderNode() override = default;

public:
std::string_view type() const override;
std::string_view summary() const override;

/*
* Definition
*/
private:
// CIF handler context
CIFContext context_;
// Space group ID
SpaceGroups::SpaceGroupId spaceGroup_{SpaceGroups::SpaceGroupId::NoSpaceGroup};
// CIF filepath
std::string filePath_;

/*
* Processing
*/
private:
// Run main processing
NodeConstants::ProcessResult process() override;
};
49 changes: 49 additions & 0 deletions src/nodes/cifMolecularSpecies.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 Team Dissolve and contributors

#include "nodes/cifMolecularSpecies.h"
#include <algorithm>
#include <iterator>

CIFMolecularSpeciesNode::CIFMolecularSpeciesNode(Graph *parentGraph) : Node(parentGraph)
{
// Inputs
addInput<CIFLoaderNode::CIFContext *>("CIFContext", "CIF handling context derived from parsing of CIF file", context_)
->setFlags({ParameterBase::Required});

// Outputs
addOutput<std::vector<CIFMolecularSpecies>>("DetectedMolecularSpecies", "Detected molecular species", molecularSpecies_);
addOutput<Configuration *>("SuperCellConfiguration", "Supercell configuration pointer", supercellConfiguration_);

// Options
addOption<Vector3i>("SuperCellRepeat", "Supercell repeat", supercellRepeat_);
}

std::string_view CIFMolecularSpeciesNode::type() const { return "CIFMolecularSpecies"; }

std::string_view CIFMolecularSpeciesNode::summary() const
{
return "Output a configuration containing individual molecules based on detected species";
}

// Run main processing
NodeConstants::ProcessResult CIFMolecularSpeciesNode::process()
{
// Generate from CIF context
context_->setSupercellRepeat(supercellRepeat_);
context_->generate();

// Get supercell configuration
supercellConfiguration_ = context_->generatedConfiguration();
supercellConfiguration_->setName(context_->chemicalFormula());

// Get detected molecular species
auto &cifMols = context_->molecularSpecies();
molecularSpecies_.clear();
std::copy(cifMols.begin(), cifMols.end(), std::back_inserter(molecularSpecies_));

return NodeConstants::ProcessResult::Success;
}

// Get cleaned unit cell species
const Species &CIFMolecularSpeciesNode::cleanedUnitCellSpecies() const { return context_->cleanedUnitCellSpecies(); }
46 changes: 46 additions & 0 deletions src/nodes/cifMolecularSpecies.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2026 Team Dissolve and contributors

#pragma once

#include "nodes/cifLoader.h"
#include "nodes/node.h"

// CIFLoader Node
class CIFMolecularSpeciesNode : public Node
{
public:
CIFMolecularSpeciesNode(Graph *parentGraph);
~CIFMolecularSpeciesNode() override = default;

public:
std::string_view type() const override;
std::string_view summary() const override;

/*
* Definition
*/
private:
// CIF handler context
CIFLoaderNode::CIFContext *context_{nullptr};
// Supercell configuration
Configuration *supercellConfiguration_{nullptr};
// Detected molecular species
std::vector<CIFMolecularSpecies> molecularSpecies_;
// Supercell repeat
Vector3i supercellRepeat_{1, 1, 1};

/*
* Processing
*/
private:
// Run main processing
NodeConstants::ProcessResult process() override;

/*
* Getters
*/
public:
// Get cleaned unit cell species
const Species &cleanedUnitCellSpecies() const;
};
Loading
Loading