Skip to content

C++ API

Shared conventions (units, frames, indices) are on the home page.

#include "molsymm/molsymm.hpp"

Umbrella header re-exports analysis, displacement, fragment, molecule, types, zmatrix, masses, and error.

Core types

Type Role
Molecule Atoms with atomic number, position, mass; ctors from flat xyz or 3×N Eigen matrix
Tolerances primary (Å, default 1e-3), angle, inertia, max_axis_order, max_group_order
Analysis Result of analyze: point_group, order, symmetry_number, frame/original molecules, operations, character_table, subgroups, rmsd; select_subgroup, symmetrize, frame_to_input
ZMatrixAtom One Z-matrix row (1-based indices; Å / radians)

Workflow functions

Function Description
analyze(mol, tol={}) Detect point group → Analysis
molecule_from_zmatrix(rows) / zmatrix_positions(rows) Z-matrix → Molecule / positions
symmetrize(mol, point_group, forces*, hessian*, tol={}) One-shot project → Symmetrized
unique_displacements(analysis, step=1e-3) → DisplacementSet with plus / minus
fragmentation(analysis) / reconstruct(frag, reps) Asymmetric unit ↔ full molecule
subgroup_assembly(analysis, name) / assemble(asm, pieces) Lower-symmetry assembly
wyckoff_positions / wyckoff_plans / wyckoff_plan / assemble_from_au Group + site plan → Analysis

Finite groups only (Cotton frame). WyckoffPlan::assemble returns an Analysis usable with fragmentation / subgroup_assembly.

DisplacementSet provides gradient_from_energies and hessian_from_gradients. Symmetrized holds rmsd, positions (input frame), optional forces / hessian.

C++-only helpers (not wrapped in other bindings): symmetrize_gradient, symmetrize_hessian, project_external, center_of_mass, inertia_tensor, atomic_mass.

molsymm::Analysis a = molsymm::analyze(molsymm::Molecule(/*Z*/, /*xyz flat*/));
a.select_subgroup("C2v");
a.symmetrize();
auto frag = molsymm::fragmentation(a);
molsymm::Molecule full = molsymm::reconstruct(frag, reps);

auto built = molsymm::assemble_from_au(
    "Oh", {16, 9}, {molsymm::Vec3::Zero(), molsymm::Vec3(0, 0, 1.56)}, {"1a", "6a"});