A component library#
A component library is several files that
merge composes into one spec. Each
file is a whole spec that states one part of a larger one (a
fragment). mathspec loads each
fragment on its own, and the typesetter prints
it. One fragment declares the names every component shares (the
surface), and each component file
declares its own math against the surface.
- The coupling surface declares the flow, the balance and the objective that every component file uses.
- Generators is a component file with a variable of its
own and a cost that adds to
total_cost. - Loads is a component file with no variable of its own.
- The composed spec contains what
mergereturns, and the math of the merged spec with and without the patch.
The components couple through one flow variable per port, Port_p.
The names are those of an open-source power system framework
(PyPSA), spelled Component_attribute as on
PyPSA in one file. The typesetter prints the math in the
symbols of that page.
The layout#
examples/library/
surface.yaml one flow per port, one balance per bus, the objective
generator.yaml PyPSA's Generator
load.yaml PyPSA's Load
variants/
commitment.yaml a patch over the composed spec
Each component file sits beside the surface, and the patch sits in its own folder.
How the files divide the spec#
mergetakes the whole of a fragment or none of it.- A component file states one class of PyPSA component, such as
Generator(a component class).mergejoins a second component class as another fragment. A patch changes one component class, andoverridelays the patch over the composed spec. - Every entry a component file declares, apart from its dimensions, has the
prefix of its component class. The prefixes
Generator_andLoad_separate the names of the two component files, and the surface declares the names withPort_andBus_. Every file declaressnapshotandportalike.
See also
- Composing specs, for what
mergeandoverrideaccept and what mathspec refuses - Compose a spec from several files, for a library whose components add a term to one sum instead of sharing a flow variable
- The composed spec, for the patch and the math it adds
- The glossary, for fragment, surface, term and patch