Parameters#
Parameter layers#
Parameter sets composed from independent layers (DESIGN D1, issue #3).
A parameter set is the union of layers of different kinds: the operation (energy reference,
initial state, controls), the coupling (surface flux law), the heat transfer fluid, the PCM,
the metal of the fins, and the family geometry in two parts: the flow path (the tubes or the
bed, which set the size of the device) and the storage element (the fins or the capsules,
the repeating unit). Each kind holds its own names
(pytes.parameter_layers.kinds), so layers merge without clashes and one can be
swapped, e.g. a PCM, without touching the rest. A layer is a plain dict of PyBaMM parameter
names and values, with the sources of its values in "citations", and a composed set is a
plain pybamm.ParameterValues.
>>> import pytes
>>> parameter_values = pytes.parameter_layers.compose(
... operation="Finned tube discharge",
... coupling="Finned tube default",
... heat_transfer_fluid="Water",
... pcm="PCM 60",
... metal="Aluminium",
... finned_tube_flow_path="Finned tube default",
... finned_tube_storage_element="Finned tube default",
... )
>>> pytes.parameter_layers.swap(parameter_values, pcm=my_pcm)
- pytes.parameter_layers.LAYERS = {'coupling': {'Finned tube default': <function finned_tube_default>, 'Packed bed default': <function packed_bed_default>}, 'finned_tube_flow_path': {'Finned tube default': <function finned_tube_default>}, 'finned_tube_storage_element': {'Finned tube default': <function finned_tube_default>}, 'heat_transfer_fluid': {'Hytherm 600': <function hytherm_600>, 'Water': <function water>}, 'metal': {'Aluminium': <function aluminium>, 'Copper': <function copper>, 'Steel': <function steel>}, 'operation': {'Finned tube discharge': <function finned_tube_discharge>, 'Nallusamy2007': <function nallusamy2007>, 'Raul2018': <function raul2018>}, 'packed_bed_flow_path': {'Nallusamy2007': <function nallusamy2007>, 'Raul2018': <function raul2018>}, 'packed_bed_storage_element': {'Default capsule': <function default_capsule>, 'Nallusamy2007': <function nallusamy2007>, 'Raul2018': <function raul2018>}, 'pcm': {'A164 (Raul 2018)': <function raul2018_pcm>, 'PCM 10N': <function pcm_10n>, 'PCM 30': <function pcm_30>, 'PCM 60': <function pcm_60>, 'Paraffin (Nallusamy 2007)': <function nallusamy2007_paraffin>}}#
The registered layers, for each kind the functions returning them, by name
- pytes.parameter_layers.SETS = {'Finned tube default': {'coupling': 'Finned tube default', 'finned_tube_flow_path': 'Finned tube default', 'finned_tube_storage_element': 'Finned tube default', 'heat_transfer_fluid': 'Water', 'metal': 'Aluminium', 'operation': 'Finned tube discharge', 'pcm': 'PCM 60'}, 'Nallusamy2007': {'coupling': 'Packed bed default', 'heat_transfer_fluid': 'Water', 'operation': 'Nallusamy2007', 'packed_bed_flow_path': 'Nallusamy2007', 'packed_bed_storage_element': 'Nallusamy2007', 'pcm': 'Paraffin (Nallusamy 2007)'}, 'Raul2018': {'coupling': 'Packed bed default', 'heat_transfer_fluid': 'Hytherm 600', 'operation': 'Raul2018', 'packed_bed_flow_path': 'Raul2018', 'packed_bed_storage_element': 'Raul2018', 'pcm': 'A164 (Raul 2018)'}}#
Named compositions, for each set the name of the layer of each kind. Each family’s default parameter values are one of these sets
- class pytes.parameter_layers.LayerKind(key: str, description: str, required: tuple[str, ...], optional: tuple[str, ...] = ())[source]#
Bases:
objectA kind of parameter layer.
- Variables:
key (
str) – Identifier of the kind, e.g. “pcm”, used as a keyword ofpytes.parameter_layers.compose().description (
str) – What a layer of this kind describes.required (
tupleofstr) – Parameter names every layer of this kind holds.optional (
tupleofstr) – Parameter names a layer of this kind may hold, used by no model yet (hooks). No kind has any today.
- property names#
Every parameter name a layer of this kind may hold
- pytes.parameter_layers.check(kind, layer, populated=True)[source]#
Check that a layer holds the names of its kind, and only those.
- Parameters:
- Raises:
ValueError – If a required name is missing, a name does not belong to the kind, or (with
populated) a value is None.
- pytes.parameter_layers.compose(**layers)[source]#
Compose a parameter set from layers.
- Parameters:
**layers (
strordict) – One layer per kind, keyed by kind (e.g.pcm="PCM 60"): the name of a registered layer, or a layer as a dict.- Returns:
pybamm.ParameterValues– The union of the layers, with their citations.- Raises:
ValueError – If a layer fails
check().
- pytes.parameter_layers.compose_set(name)[source]#
Compose a named set (see
SETS).- Parameters:
name (
str) – The name of the set.- Returns:
- pytes.parameter_layers.get(kind, name)[source]#
A registered layer.
- Parameters:
kind (
str) – The kind, e.g. “pcm”.name (
str) – The name of the layer (seeavailable()).
- Returns:
dict– A fresh copy of the layer, with its"citations".
- pytes.parameter_layers.swap(parameter_values, **layers)[source]#
Replace layers in a parameter set, in place.
The set must already hold every name of each new layer’s kind it holds, so that a swap replaces a layer and cannot add stray names. (This is the check that
ParameterValues.update(check_already_exists=True)made before PyBaMM deprecated it.) The set’s"citations"gain the sources of the new layers. Those of the replaced layers stay, as another layer of the set may cite them too.- Parameters:
parameter_values (
pybamm.ParameterValues) – The set to update.**layers (
strordict) – The new layers, keyed by kind, as forcompose().
- Raises:
ValueError – If a layer fails
check(), or the set does not hold the required names of its kind.
- pytes.parameter_layers.template(kind)[source]#
An empty layer of a kind, to fill in: every name the kind holds, required and optional, with the value None, and no citations.
The kinds of parameter layer and the names each one holds (DESIGN D1).
A layer holds every name its kind requires, may hold the kind’s optional names, and holds no other names, so layers of different kinds never share a name and merge without clashes.
Device parameters#
Parameters shared by every family: the device-level description (DESIGN D4, D14).
Family parameter classes inherit from DeviceParameters and add their geometry and
materials.
- class pytes.parameters.DeviceParameters[source]#
Bases:
objectDevice-level parameters, as PyBaMM symbols.
- Variables:
T_ref (
pybamm.Parameter) – “Reference temperature [K]”: every energy is zero at the uniform state at this temperature (DESIGN D14). Energy differences do not depend on it.T_init (
pybamm.Parameter) – “Initial temperature [K]”: the initial state is the uniform equilibrium state at this temperature (DESIGN D14); for a sharp melting point, solid at the melting temperature.T_in (
pybamm.FunctionParameter) – “Inlet temperature [K]”, a function of time (“Time [s]”). A control.mdot (
pybamm.Parameter) – “Mass flow rate [kg.s-1]”, through the whole device. A control.temperature_scale (
float) – Scale of the temperature variables [K].
- pytes.parameters.validate_parameter_values(parameter_values, non_negative=())[source]#
Check that parameter values are physical (DESIGN D14).
- Parameters:
parameter_values (
pybamm.ParameterValuesordict) – The parameter values.non_negative (
iterableofstr, optional) – Names of parameters that must not be negative, e.g. “PCM melting range [K]” and “PCM smoothing width [K]”.
- Raises:
ValueError – If a temperature is not positive or a parameter in
non_negativeis negative.