kicad2ems.core.study

A study: what can be asked of a board, and the programs that answer.

A *question* is something to find out with a known kind of answer: the ports'
S-parameters, an antenna's pattern, every trace's impedance, a rail's DC drop,
its impedance, a converter's near field, a circuit on the copper, the
capacitance between nets, the board's temperature. An *engine* is a program that
answers one or more of them: the S-parameter solvers (kicad2ems.core.solvers:
openEMS, gfdtd, mom25d, the line model ...) and the analyses
(kicad2ems.core.analyses: pcbqs's tools, kicad2ems.fem's Elmer and Palace
tools). Several engines may answer one question (the temperature by pcbqs or by
Elmer), and one engine several questions from one run (a rail's drop and its
impedance).

    from kicad2ems.core.study import study_tree, engines, questions
    for g in study_tree():      # what a front end lists: by group, each
                                # question with its engines
        for row in g['questions']:
            (row['question'].label, [e.label for e in row['engines']],
             row['missing'])
    engines()['pdn'].provides   # ('dc', 'pdn')

A front end shows the tree, lets each question asked name its engine (or
several, to compare them), and starts them: an analysis engine by the command
its Analysis gives (Analysis.command, its settings first passed through
Analysis.for_questions with the questions asked of it), the solver engines
together as one kicad2ems run. Whoever starts a run leaves a mark in its folder
(kicad2ems.core.runs.mark) saying which engine made it, what was asked and how
it ended, so a folder is known as that engine's result even when two engines
leave a file of the same name (runs.index, analyses.analysis_of).

A config holds a study as its [study] tables (Study, read_config, write_config),
plan() gives the runs it takes in order, and run() makes them, which is the
command `kicad2ems study board.toml`:

    study = read_config('board.toml')  # Study(asked={'dc': ['pdn',
                                       # 'elmer_dc']}, fields={}, said='study')
    [st.name for st in plan(study)]    # ['pdn', 'elmer_dc']: 'rf' is the
                                       # solvers' run
    run('board.toml')                  # 0: every run finished
class kicad2ems.core.study.Engine(name: str, label: str, kind: str, provides: tuple, impl: object, fields: str = '', previewed: bool = False, order: int = 50, run: str = '', sets: dict = <factory>)[source]
A program that answers questions, as a front end lists it: a solver or
an analysis.
check()[source]
(usable, one line): the Solver's or the Analysis's own check (a
variant's: Analysis.check_with its settings).
class kicad2ems.core.study.Question(name: str, label: str, group: str, about: str, shares: str = '', answer: str = 'report', order: int = 50, figures: str = '')[source]
Something to find out about a board.
class kicad2ems.core.study.Step(kind: str, engines: tuple, questions: tuple, mode: str = '', fields: object = None)[source]
One run of a study: the solvers together (a kicad2ems run), or one
analysis.
class kicad2ems.core.study.Study(asked: dict, fields: dict = <factory>, said: str = '')[source]
What a study asks, as a config holds it:

    [study]
    run = ["sparams", "dc", "thermal"]  # the questions, by name (kicad2ems
                                        # --check lists them)
    [study.sparams]
    engine = ["mom25d", "pcbqs"]        # who answers: one, or several to
                                        # compare; none: the default
    [study.thermal]
    engine = "Elmer"                    # an engine's name ('elmer_thermal')
                                        # or how a list shows it
    fields = true                       # its field dumps too, where it can
                                        # write them

An engine's own settings stay where they were: a solver's under
[solver.<name>] (and the top level), an analysis's under
[analysis.<name>].
kicad2ems.core.study.check_lines()[source]
--check's lines about the questions: each one with the engines that
answer it.
kicad2ems.core.study.compare(results)[source]
Engines' answers side by side: dict(engines=[names], labels=[as a list
shows them], rows=[dict(name, unit, values=[a number or None per engine],
spread)]) from {engine: its result's folder}. A figure is a row when at
least one engine gives it, in the first engine's order and then the others'
own; spread: the largest difference between engines that give it (None with
fewer than two).
kicad2ems.core.study.default_fields(engine, fmin, fmax, layer='F.Cu', sweep='linear')[source]
What an engine is asked for when its field dumps are wanted and none is
set: {option key: value}. A solver's dump: the E field on `layer` (the first
port's, a front end knows) at the band's centre; a list of frequencies
(mom25d's current maps): that centre; an analysis: its `fields` switch.
fmin, fmax in GHz.
kicad2ems.core.study.describe(steps, sets=None)[source]
A plan as lines to print: each run, what it is asked, by whom. sets: the
analyses' tables of the config (analyses.read_sets): an analysis given
several is as many runs, named by their tags.
kicad2ems.core.study.dump_options(sv)[source]
The options that ask a solver for field dumps: its `dump` (the FDTD
solvers': FIELD@REGION@GHz specs) or one named <its own>_dump (mom25d's
mom_dump: the frequencies of its current maps).
kicad2ems.core.study.engine_named(question, text, es=None)[source]
The registry name of the engine `text` means among those that answer a
question: its name ('elmer_thermal', 'mom25d', 'crosstalk_gfdtd'), a
solver's alias ('mom', 'lines'), the name a list shows it by ('pcbqs',
'Elmer', 'line model + gfdtd') or a variant's last word ('gfdtd'), in any
case; None for 'auto' (the default engine). ValueError when nothing
matches, or more than one does.
kicad2ems.core.study.engines()[source]
{name: Engine}: the solvers (each answers 'sparams'; 'antenna' where it
models one; the line model's also 'lines') and the analyses, in the order
lists show them.
kicad2ems.core.study.engines_of(question)[source]
The engines that answer a question, in their order.
kicad2ems.core.study.load_config(path)[source]
A config's tables in the one form the study and the analyses read, its
older forms turned into it:

    [analysis.<name>]       a list of one ([[analysis.<name>]]: several);
                            names in lower case, keys with underscores
    [analysis] run = [...]  (before the questions, and no [study]): the
                            [study] it means: run = the questions (rf:
                            S-parameters; an analysis: those it answers,
                            by it), said = "analysis"
    an analysis's check     (the crosstalk's, before its variants were
                            engines), for a question [study] names no
                            engine for: that variant (crosstalk_gfdtd)

[study] then holds run (the questions, in lower case) and said ("study";
"analysis": the older form), [study.<q>] as written; none: None.
kicad2ems.core.study.main(argv=None, prog='kicad2ems study')[source]
`kicad2ems study board.toml`: run the study a config asks (run); --list
shows its runs without making them.
kicad2ems.core.study.plan(study)[source]
The runs a Study takes, in the order to make them: [Step]. First the
solvers, as one kicad2ems run (two when an antenna is asked of some and only
S-parameters of others: the antenna's run answers S-parameters for its own
solvers); then each analysis engine, in the registry's order (the
temperature after the circuit whose losses it takes). ValueError: a question
nobody answers, or an engine that does not answer what it is asked.
kicad2ems.core.study.provided(a)[source]
The questions an analysis answers: what it declares, else the one of its
own name.
kicad2ems.core.study.questions()[source]
{name: Question}: kicad2ems's, then those the analyses bring for what it
has none for (an analysis's `questions`; one that declares nothing is a
question of its own name, in the group Other).
kicad2ems.core.study.read_config(path, strict=True)[source]
The study a TOML config asks (Study): its [study] tables (load_config:
or what an older form means); with none, S-parameters. strict False (a
front end, which shows what it cannot run greyed): a question nobody knows
and an engine nobody lists are kept as written instead of a
ValueError.
kicad2ems.core.study.rf_needs(values)[source]
What an S-parameter run of these settings still needs before it can
start: [dict(text, key)], key the setting it is set by. Cheap (the board
file's footprints are read, no model is made): a front end asks on every
change, lists the answers and does not start the run.
kicad2ems.core.study.run(config, only=None, preview=False, out=None, echo=<built-in function print>, extra=None)[source]
Run the study a config asks, one run after the other (plan), each into a
folder of its own under the output folder and each a command of its own:
the solvers' kicad2ems's run of the config's settings, an analysis the
command its Analysis gives, with its settings from [analysis.<name>] (given
several tables, [[analysis.<name>]]: a run for each, a board's rails).
only: the questions (or engines) to run of those it asks; preview: the runs
that have one, without solving; extra: settings typed on the command line,
for the solvers' run. A run that cannot start or fails says why and the
rest go on, except an analysis that needs its result. Returns 0 when every
run finished, 1 when one did not, 2 when the study cannot be read.
kicad2ems.core.study.runs_for(asked)[source]
The runs a set of questions takes: {engine name: the questions asked of
it}, from {question: [engine names]} (a question with no engine named: its
first). Solver engines are separate entries here; a front end runs them as
one kicad2ems run. ValueError names a question nobody answers, or an engine
that does not answer it.
kicad2ems.core.study.study_tree()[source]
What a front end lists: [dict(group, questions=[dict(question, engines,
missing)])], every question kicad2ems or an analysis knows, by group and
order. engines: those that answer it (their own check says whether each can
run here); missing: why there is none ('' otherwise).
kicad2ems.core.study.unmet(name, failed)[source]
The analyses an engine's run needs (Analysis.needs) of `failed`, the
runs that did not finish: it is not made then.
kicad2ems.core.study.write_config(path, study)[source]
The [study] tables of the config at `path` written anew from a Study
(None: taken out); the rest of the file is kept. An engine is written by its
registry name.