Input Validation#

Overview#

pychum validates input at dataclass construction time using __post_init__ methods. Validation is inline – the _validators.py file exists as an empty placeholder for future extraction.

Validation Approach#

All validation happens when a dataclass is instantiated. Invalid values raise ValueError immediately, before any rendering occurs. This catches configuration errors at load time rather than producing malformed input files.

Validated Fields#

Atom#

Condition

Error

point_charge is None and symbol is None

“Atom symbol is required unless it’s a point charge.”

When point_charge is set, symbol is forced to "Q" (no error).

OptimSettings#

Field

Allowed values

method

LBFGS, VPO, FIRE

Comparison is case-insensitive (.upper()).

ReparamSettings#

Field

Allowed values

interp

linear, cubic

Comparison is case-insensitive (.lower()).

FreeEndSettings#

Field

Allowed values

opt_type

PERP, CONTOUR, FULL

Comparison is case-insensitive (.upper()).

ZoomSettings#

Field

Allowed values

interpolation

linear, cubic

Comparison is case-insensitive (.lower()).

SpringSettings#

Field

Allowed values

spring_kind

image, dof, ideal

perpspring

no, cos, tan, cosTan, DNEB

Both comparisons are case-insensitive (.lower()).

NebBlock#

Field

Allowed values

convtype

all, cionly

quatern

no, startonly, always

tangent

improved, original

interpolation

IDPP, LINEAR, XTB1TS, XTB1, XTB2TS, XTB2

convtype, quatern, and tangent use .lower(). interpolation uses .upper().

RestartSettings#

Condition

Error

Both gbw_basename and allxyz are set

“Only one of gbwbasenameor allxyz should be provided.”

TSGuessSettings#

Condition

Error

Both xyz_struct and pdb_struct are set

“Only one of xyzstructor pdbstructshould be provided.”

Unvalidated Fields#

Most numeric fields (tolerances, step sizes, spring constants) accept any value without range checking. Boolean fields are not validated. The ConfigLoader relies on TOML parsing to enforce basic type correctness.

Template-level Validation#

The geom_scan.jinja template has an additional guard: if the total number of scan coordinates (bonds + angles + dihedrals) exceeds 3, it emits an error message instead of rendering the scan block. This is a template-level check, not a dataclass validator.

Future Work#

The empty _validators.py and _orcablocks.py placeholders suggest planned extraction of validation logic into dedicated modules. Currently all validation is co-located with the dataclass definitions.