morphogen.results¶
Database of the configurations tested and of their results, and Ashby charts.
A ResultsDatabase is one SQLite file (Python’s standard library). Every run
directory added (ResultsDatabase.add_run(): the outputs of morphogen run, or of
a run with outputs.database) contributes one record per realization: its
configuration flattened into dotted keys (model.type, model.radius,
domain.size, homogenization.materials.1.young…) and its row of results
(measures, apparent properties, solid fraction, relative, normalized and specific values:
morphogen.homogenization.postprocess). Records are selected by conditions on any
key (parse_condition()): model.type == gyroid, solid_fraction < 0.3,
model.type in gyroid,octet, run_name ~ lattice*.
Ashby charts (ashby_chart()) place records in a space of two properties, by default
normalized: a relative property (E / E_s) against the relative density (the solid
fraction), on logarithmic axes, one family per value of a key (the model by default),
with the scaling laws of cellular solids P / P_s = phi^n (Gibson & Ashby 1997:
n = 1 for stretching-dominated architectures, the rule of mixtures; n = 2 for
bending-dominated open-cell foams).
- morphogen.results.SCHEMA = '\nCREATE TABLE IF NOT EXISTS runs (\n id INTEGER PRIMARY KEY,\n path TEXT UNIQUE,\n name TEXT,\n added TEXT,\n config TEXT,\n version TEXT\n);\nCREATE TABLE IF NOT EXISTS samples (\n run INTEGER REFERENCES runs(id) ON DELETE CASCADE,\n realization INTEGER,\n data TEXT,\n PRIMARY KEY (run, realization)\n);\n'¶
Runs and their realizations; a record is the JSON of the flattened configuration merged with the row of results of one realization.
- morphogen.results.flatten(data: dict, prefix: str = '') dict[source]¶
Nested mappings as one level of dotted keys; lists become JSON text.
- morphogen.results.parse_condition(text: str) tuple[str, str, object][source]¶
"key OP value"with OP one of== != < <= > >= in, not in(comma-separated values) or~(shell pattern, e.g.lattice*).
- morphogen.results.matches(record: dict, conditions) bool[source]¶
Whether a record satisfies every condition (strings or parsed tuples); a missing key fails every condition but
!=andnot in.
- class morphogen.results.ResultsDatabase(path)[source]¶
Bases:
objectSQLite database of runs and of the results of their realizations.
- add_run(directory, *, name: str | None = None) int[source]¶
Add (or replace) the realizations of a run directory: its configuration (
run.json) and results (results.csv, or the files of split runs). Returns the number of records.
- morphogen.results.record_run(directory, database, *, name: str | None = None) int[source]¶
Add a run directory to a database file (created if needed).
- morphogen.results.write_records(records: list[dict], path, keys=None) Path[source]¶
CSV of records (all their keys, or
keys): the table view of a chart.
- morphogen.results.SERIES = {'dark': ('#3987e5', '#d95926', '#199e70'), 'light': ('#2a78d6', '#eb6834', '#1baf7a')}¶
three hues pass the colour-vision checks together; more families fold into “Other”), light and dark.
- Type:
Categorical slots of scatter charts (any two families can be neighbours
- morphogen.results.default_axes(records: list[dict]) tuple[str, str][source]¶
The relative density and the first relative property found (Young’s modulus first, then the bulk and shear moduli, then any).
- morphogen.results.ashby_points(records: list[dict], x: str | None = None, y: str | None = None, by: str | None = 'model.type', *, log: bool = True, groups: list | None = None, max_groups: int = 3) dict[source]¶
Points of an Ashby chart: the families (values of
by) with their points, the firstmax_groupsin their own colour (by size, or the order ofgroups), the others folded into “Other”. Records without finite values (positive ones on logarithmic axes) are left out.
- morphogen.results.axis_label(key: str) str[source]¶
Readable name of a key: the relative density, a relative property…
- morphogen.results.ashby_chart(records: list[dict], path, x: str | None = None, y: str | None = None, by: str | None = 'model.type', *, log: bool = True, guides=None, groups: list | None = None, theme: str = 'light', title: str | None = None) Path[source]¶
Ashby chart of records as a PNG, SVG or PDF file (needs matplotlib): one family per value of
by(three in colour, with their markers, envelopes and direct labels; others in “Other”), on logarithmic axes by default, with the linesy = x^nforguides(default: n = 1 and 2 when the axes are relative).