QM Common Data Model Design¶
This page defines the boundaries of MolOP’s common QM input and result containers. The goal is to let Gaussian, ORCA, and future program parsers project into one shared model without letting duplicated fields overwrite each other.
Layers¶
The common QM model has three layers:
- Compatibility fields:
method,functional,basis_set,keywords,request_num_cpu,request_memory, andresources_raw. They remain available for existing API users, but new parser logic should not treat them as authoritative. - Input request containers:
model_chemistry,task_requests,resource_request,excited_state_requests, andmultireference_requests. Parsers should write these structured fields first. - Result containers:
energies,molecular_orbitals,vibrations,single_point_properties,electronic_states, andmultireference_result. These describe calculation output and should not infer input requests in reverse.
Source Of Truth¶
Structured containers are authoritative. After parsing structured semantics, parsers should call project_common_qm_fields() to project structured containers onto compatibility fields:
model_chemistry.raw_keywords->keywordsmodel_chemistry.method_family/method->methodmodel_chemistry.functional->functionalmodel_chemistry.basis_set->basis_setresource_request.num_cpu/memory/raw->request_num_cpu/request_memory/resources_raw
The legacy refresh_common_qm_containers() method is kept for existing callers only. It backfills empty
structured fields from compatibility fields and then projects the structured values back to compatibility
fields. It never lets flat fields overwrite already parsed structured semantics. To change normalized
semantics, modify the structured container and call project_common_qm_fields().
Input Requests¶
QMModelChemistry describes model chemistry:
methodis the stable concrete electronic-structure method used for matching and protocol identity. GaussianR,U, andROprefixes are removed from this value and retained separately inspin_treatment; the original route token remains available in Gaussian’s semantic route evidence.- Functionals and dispersion belong to the same model-chemistry expression. Gaussian and ORCA both append the dispersion suffix to
functional, such asB3LYP-GD3BJ. dispersion_correctionalso stores the normalized dispersion label, such asGD3BJorD4.basis_setsstores mixed basis sets, auxiliary basis sets, ECPs, and atom-scoped overrides.basis_setstores only the primary global orbital basis.solvation_modelandsolventdescribe the input request and are separate from output-sideBaseCalcFrame.solvent.
QMTaskRequest describes only generic task types and generic task options, such as sp, opt, freq, excited_state, and multi_reference. Domain-specific excited-state and multi-reference parameters belong in their dedicated containers.
ExcitedStateRequest describes requested roots, number of states, spin channels, root following, and requested properties.
MultireferenceRequest describes requested multi-reference method, reference method, active space, state blocks, thresholds, and corrections.
Results¶
ElectronicStates stores state/root-resolved output data for excited-state, MRCI, CASSCF, and related calculations. It does not replace energies, which remains the overall or ground-state energy container.
MultireferenceResult stores multi-reference output data, including method, active space, state-resolved results, corrections, and diagnostics. It does not replace input-side MultireferenceRequest.
Result semantics across formats¶
These contracts apply to Gaussian logs, formatted checkpoints, ORCA logs and xTB
stdout. Tests live in tests/test_qm_result_semantics.py and the format-specific
numerical suites.
- State identity:
state_indexis an internal, unique non-negative index;rootis the program’s root number. Setis_ground_stateexplicitly:Trueidentifies the ground state,Falseidentifies an excited state, andNoneleaves identity unknown. List position and root zero do not identify a ground state. An excited-only collection exports every known transition. Its initial internal state isNoneunless a ground-state record exists; printed initial labels/root numbers remain in transition properties. - Missing observations: unknown orbital energies, bond orders and coupling
matrix entries remain numeric
np.naninternally. Unknown occupations and symmetry labels useNone. Only these explicitly nullable fields mask NaN for public JSON exports (null); binary ndarray exports preserve NaN. Infinities still fail JSON validation. A printed zero remains zero. EachBondOrderMatrixinBondOrdersretains its print threshold and missing-entry reason alongside the matrix; RDKit embedding skips unobserved pairs. - Spin channels: the common orbital validator aligns unequal or absent spin
channels with unknown entries, without assuming restriction. Parsers identify
shared restricted references explicitly.
orbital_basis,occupancy_originandtotal_occupanciesdistinguish printed spin occupations from derived shared-spatial occupations. Closed-shell totals split equally; evidenced integer high-spin totals can split into alpha/beta; other open-shell totals retain unknown spin occupations. xTB’s omitted orbital ranges never imply zero occupation. Printed HOMO/LUMO labels populatereported_homo_indexandreported_lumo_index; fractional occupations alone do not define frontiers or SOMOs. - Modes:
mode_indicesare stable internal indices starting at zero when parsed.source_mode_indicesseparately retain printed numbers, orNonewhere the source supplies only an array. Filtering retains both identities. SingleVibrationrecords and IR/Raman bands carry source program, orientation, normalization and mass-weighting metadata. Source-normalized Cartesian vectors are not rescaled to make different programs appear equivalent. - Thermochemistry: corrections and totals retain their existing definitions
(
U_T = Eel + TCE,H_T = Eel + TCH,G_T = Eel + TCG). The container also retains temperature, pressure,entropy_model, frequency scaling, excluded-mode cutoff, HO/rotor interpolation reference and imaginary-frequency cutoff when available. These are distinct conditions; a rotor interpolation reference is not a frequency-exclusion threshold. Property-bundle exports retain the conditions. Gaussian FCHK totals alone do not establish an entropy model.
Gaussian Raman data retain plane-polarized and unpolarized depolarization
ratios separately in raman_depolarization_ratios_polarized and
raman_depolarization_ratios_unpolarized. The unsuffixed ratio field is
reserved for source tables with unspecified polarization. xTB PTB calculations
retain distinct frequency_method and raman_activity_method labels.
FCHK thermal corrections carry their equations in derivations.
See data containers and cross-QM semantics for
the public container overview and user-facing comparison rules.
Migration: callers constructing electronic states must set is_ground_state
explicitly. Callers needing original vibration numbers must use
source_mode_indices (or Vibration.source_mode_index), not mode_indices.
Do not replace missing matrix entries with zero when comparing programs.
Extensible bond-order records¶
Like atomic populations, BondOrders.bond_orders maps stable identifiers to typed
BondOrderMatrix records. Each record stores its extensible scheme string,
values, optional spin channel, source label, print threshold, missing-entry reason
and program-specific metadata. No parallel dictionaries link provenance by name.
import numpy as np
from molop.io.base_models.DataClasses import BondOrderMatrix, BondOrders
orders = BondOrders(bond_orders={
"mayer_bond_order": BondOrderMatrix(
scheme="mayer",
values=np.array([[np.nan, 0.9], [0.9, np.nan]]),
source_label="Mayer bond orders larger than 0.1",
print_threshold=0.1,
missing_reason="unprinted atom pairs",
),
})
matrix = orders["mayer_bond_order"].values
New schemes need only another dictionary entry. Serialization, property bundles
and RDKit embedding do not enumerate supported scheme names. Matrices must be
non-empty square arrays of the same shape; a frame with geometry also checks them
against its source atom count. Access records through bond_order_items(),
bond_order_names, get_bond_order() or indexing. RDKit skips missing observations
and preserves observed zero values on existing bonds.
Migrate BondOrders(mayer_bond_order=matrix) to the dictionary constructor above,
and replace frame.bond_orders.mayer_bond_order with
frame.bond_orders["mayer_bond_order"].values. Old flat fields are rejected rather
than silently ignored. Serialized matrices live under bond_orders[name]["values"];
NaN entries still export as JSON null.
Parser Rules¶
New parser logic should follow this flow:
- Declare a canonical
format_id, implement_quick_check_file_format()and_locate_segments()on the file parser, and locate original source ranges directly. - Implement
_parse_artifact_metadata()or_parse_segment_metadata()only when that scope has metadata. - Parse program-specific syntax into semantic models and build common structured containers.
- If resource or keyword data was initially parsed into legacy fields, use
backfill_common_qm_containers_from_legacy()only to fill empty structured fields. - Call
project_common_qm_fields()and test structured fields and compatibility projections together.
Do not reintroduce _split_file() or _parse_metadata(). The locator is the
only source of truth for segment/frame boundaries and the source slices sent to
the frame parser.
Do not store new semantics only in keywords, resources_raw, or options. options is reserved for program-specific details that do not yet have a common field.