Populating Simulation and Program¶
This page gives implementation-oriented guidance for populating the top-level Simulation entry and its Program subsection in parser code.
For the conceptual meaning of these sections in archive data, see Simulation Entry.
Purpose¶
In parser implementations, Program is typically one of the first subsections populated under Simulation. It identifies the software that produced the data and provides a stable software context for the rest of the archive.
Minimal Parser Pattern¶
A simple parser-side pattern is:
- Extract program metadata from the source files.
- Instantiate
Simulation. - Populate
simulation.programwith the parsed software metadata. - Append the populated
Simulationsection toarchive.data.
For example, imagine a file containing:
The parser can extract the program name and version and store them in the archive:
from nomad.parsing.file_parser import TextParser, Quantity
from nomad_simulations.schema_packages.general import Simulation, Program
class SUPERCODEParser:
"""
Class responsible to populate the NOMAD `archive` from the files given by a
SUPERCODE simulation.
"""
def parse(self, filepath, archive, logger):
output_parser = TextParser(
quantities=[
Quantity('program_version', r'version *([\d\.]+) *', repeats=False)
]
)
output_parser.mainfile = filepath
simulation = Simulation()
simulation.program = Program(
name='SUPERCODE',
version=output_parser.get('program_version'),
)
# append `Simulation` as an `archive.data` section
archive.data.append(simulation)
Notes¶
- Keep the conceptual meaning of
SimulationandProgramin the explanation docs. - Keep parser-specific extraction patterns and archive-population examples in
Schema Development. - Follow the broader development workflow and contribution rules in Contribution Guides Overview.