Models#

PyTES models, by family.

Finned tube#

class pytes.SharpFrontModel(name='Sharp front model', options=None)[source]#

Bases: BaseFinnedTubeModel

Finned-tube model in which the PCM and the fins are homogenised into a single composite material (pytes.materials.CompositeMaterial), with heat conduction across the PCM (“storage depth”, radially from the tube) at each point along the tube. With a sharp melting point and no smoothing (“PCM melting range [K]” and “PCM smoothing width [K]” both 0) the melting front is sharp, hence the name.

Submodels:

Parameters:
  • name (str, optional) – The name of the model.

  • options (dict, optional) – The model’s options; see BaseFinnedTubeModel.

set_submodels()[source]#

Fill self.submodels

property default_var_pts#

Number of mesh points in each spatial variable, with about the same error from each (F-052). For the default discharge, against 160 points in either and 20 or 40 in the other, y gives 0.054 K on average in the outlet temperature and 0.11 % in the stored energy, and z 0.066 K and 0.12 %, in about 1 s; 40 by 40 gives about a quarter of these errors, in about 5 times as long.

class pytes.MushModel(name='Mush model', options=None)[source]#

Bases: BaseFinnedTubeModel

Finned-tube model that resolves the fins and the PCM separately. Heat flows from the tube wall along annular fins (“storage depth”) and from the fins into the PCM between them (“fin gap”), at each point along the tube.

The PCM only exchanges heat with the fins: it does not touch the tube wall, and heat flows through it only across the gap between two fins (in x), not radially or along the tube. By symmetry, only half the gap is modelled, from the fin surface (x = d_c / 2) to the midplane (x = d_m / 2). The PCM uses the properties of the PCM on its own (pytes.materials.PureMaterial).

Submodels:

Parameters:
  • name (str, optional) – The name of the model.

  • options (dict, optional) – The model’s options; see BaseFinnedTubeModel.

Variables:

x (pybamm.SpatialVariable) – Distance from the fin centreline [m], from half the fin thickness to half the fin pitch, in the “fin gap” domain.

set_spatial_variables()[source]#

Create the spatial variables, which may depend on the options

set_submodels()[source]#

Fill self.submodels

property default_geometry#

That of BaseFinnedTubeModel, plus the half-gap between two fins (x from half the fin thickness to half the fin pitch)

property default_var_pts#

Number of mesh points in each spatial variable. 10 points in x change the outlet temperature by about 0.02 K and are about 4 times faster. Along the tube, against 80 points, 20 give 0.061 K on average in the outlet temperature and 0.11 % in the stored energy for the default discharge (F-052)

The finned-tube family: PCM with metal fins around tubes carrying the fluid.

class pytes.models.finned_tube.BaseFinnedTubeModel(name, options=None)[source]#

Bases: BaseModel

Base model of the finned-tube family: heat transfer fluid flowing along a tube that exchanges heat with the surrounding PCM and fins. One tube is modelled; device totals are multiplied by the number of tubes. See pytes.models.finned_tube.parameters for the geometry and the assumptions.

Options:

  • “storage along flow path”: “resolved” (default), the storage at every point along the tube; or “averaged”, one storage cross-section standing for the average along the tube, exchanging heat with the fluid averaged along it (DESIGN D3, D4).

  • “heat transfer coefficient”: “constant” (default), “Heat transfer coefficient [W.m-2.K-1]” (pytes.submodels.NewtonCooling); or a Nusselt correlation for the flow in the tubes, by name: “Gnielinski” (pytes.submodels.Gnielinski, issue #6), or any correlation registered for the flow "tube" with pytes.submodels.register_correlation().

Parameters:
  • name (str) – The name of the model.

  • options (dict, optional) – The model’s options.

Variables:
  • y (pybamm.SpatialVariable) – Distance from the tube axis [m], from the tube radius to the storage outer radius R_f + D, in the “storage depth” domain (cylindrical coordinates), with the “flow path” as its secondary domain unless the storage is averaged.

  • z (pybamm.SpatialVariable) – Distance along the tube from the inlet [m], in the “flow path” domain.

allowed_options = {'heat transfer coefficient': HeatTransferCoefficientOptions('tube'): ['constant', 'Gnielinski'], 'storage along flow path': ('resolved', 'averaged')}#

Allowed values of each option, the first being the default

property averaged#

Whether the storage is averaged along the tube

storage_domains(*domains)[source]#

The given storage domains, then the flow path unless the storage is averaged

set_spatial_variables()[source]#

Create the spatial variables, which may depend on the options

get_parameters()[source]#

Return the model’s parameters

property flow_path#

The flow paths, one per tube

fluid_submodel()[source]#

The heat transfer fluid in the tubes

flux_law()[source]#

The surface flux law at the tube wall, from the “heat transfer coefficient” option

storage_flow_path()[source]#

The flow path a storage geometry is averaged along, or None if resolved

integrate_over_tube(symbol)[source]#

Integrate a symbol over one tube: for a “storage depth” symbol, its integral over the annulus around the tube, int int symbol 2 pi y dy dz; for a “flow path” symbol, int symbol dz. A storage averaged along the tube is the same at every z, so its integral along the tube is the tube length times its value.

property default_geometry#

The PCM annulus (y from the tube radius to the storage outer radius R_f + D) and the tube (z from 0 to the tube length)

property default_submesh_types#

Uniform 1D meshes in every domain

property default_spatial_methods#

Finite volumes in every domain; the tube uses the fluid’s spatial method

property default_quick_plot_variables#

Variables shown by pybamm.QuickPlot by default (DESIGN D15)

property default_solver#

IDAKLU with rtol=1e-5 and atol=1e-8

property default_parameter_values#

See pytes.models.finned_tube.get_parameter_values()

class pytes.models.finned_tube.FinnedTubeParameters[source]#

Bases: DeviceParameters

Parameters of the finned-tube family, as PyBaMM symbols. See pytes.parameters.DeviceParameters for the device-level ones.

Variables:
pytes.models.finned_tube.get_parameter_values(parameter_set=None)[source]#

Return parameter values for the finned-tube models.

The default set is the composition “Finned tube default” of pytes.parameter_layers: an illustrative heat battery of one tube with 0.02 kg/s of water, aluminium fins, and “PCM 60”, which melts over 59 °C to 61 °C. The battery starts uniform at 70 °C (liquid) and is discharged with water at 10 °C. Energies are zero at the uniform state at the reference temperature, 10 °C. See pytes.models.finned_tube.FinnedTubeParameters for the meaning of each parameter and the geometry, and pytes.parameter_layers.swap() to replace a part of the set, e.g. the PCM.

The corners of the melting range are smoothed over “PCM smoothing width [K]” = 0.01 K. A wider smoothing makes the models faster, at the cost of accuracy near the melting range; set it to 0 for exact corners.

Parameters:

parameter_set (str, optional) – The name of the parameter set. Only the default (None) is available.

Returns:

pybamm.ParameterValues

Packed bed#

class pytes.PackedBedModel(name='Packed bed model', options=None)[source]#

Bases: BaseModel

Packed bed of spherical PCM capsules, with the fluid flowing through the voids. At each point along the bed, one capsule stands for all those at that position: heat flows by conduction across it (“capsule”, radially from its centre) and into the fluid at its surface. See pytes.models.packed_bed.parameters for the geometry and the assumptions.

Submodels:

In this family the cross-section averages along the bed (e.g. “Storage cross-section average temperature [K]”) are the capsules’ volume averages: every capsule at a given height is the same.

Options:

  • “storage along flow path”: “resolved” (default), a capsule at every point along the bed; or “averaged”, one capsule standing for the average along the bed, exchanging heat with the fluid averaged along it (DESIGN D3, D4; the “reduced model” of the encapsulated-LTES repository).

  • “storage element”: “resolved” (default), the temperature resolved across each capsule; “lumped”, a uniform temperature in each capsule (issue #5), much cheaper, and accurate when the capsule’s Biot number is small; or “lumped with Jeffreson”, a lumped capsule whose heat transfer coefficient is corrected for the conduction inside it (pytes.submodels.Jeffreson), whichever coefficient the “heat transfer coefficient” option gives.

  • “heat transfer coefficient”: “constant” (default), “Heat transfer coefficient [W.m-2.K-1]” (pytes.submodels.NewtonCooling); or a Nusselt correlation for the flow through the bed, by name: “Wakao-Kaguei” (pytes.submodels.WakaoKaguei, issue #6), or any correlation registered for the flow "packed bed" with pytes.submodels.register_correlation().

Parameters:
  • name (str, optional) – The name of the model.

  • options (dict, optional) – The model’s options.

Variables:
  • r (pybamm.SpatialVariable) – Distance from the capsule centre [m], from 0 to the capsule radius, in the “capsule” domain (spherical), with the “flow path” as its secondary domain unless the storage is averaged. Not set for a lumped capsule.

  • z (pybamm.SpatialVariable) – Distance along the bed from the inlet [m], in the “flow path” domain.

allowed_options = {'heat transfer coefficient': HeatTransferCoefficientOptions('packed bed'): ['constant', 'Wakao-Kaguei'], 'storage along flow path': ('resolved', 'averaged'), 'storage element': ('resolved', 'lumped', 'lumped with Jeffreson')}#

Allowed values of each option, the first being the default

property averaged#

Whether the capsules are averaged along the bed

property lumped#

Whether each capsule has a uniform temperature

set_spatial_variables()[source]#

Create the spatial variables, which may depend on the options

get_parameters()[source]#

Return the model’s parameters

set_submodels()[source]#

Fill self.submodels

flux_law(storage)[source]#

The surface flux law at the capsules, from the “heat transfer coefficient” option, corrected for the conduction inside the capsule with “storage element”: “lumped with Jeffreson”

property default_geometry#

A capsule (r from 0 to the capsule radius), unless it is lumped, and the bed (z)

property default_submesh_types#

Uniform 1D meshes in every domain

property default_var_pts#

Number of mesh points in each spatial variable (F-052). The error comes mostly from r, and falls slowly with it because of the melting front inside the capsules. For the default charge, against 160 points in r (40 in z), 40 give 0.27 K on average in the outlet temperature and 1.8 % in the stored energy; against 640 points in z (40 in r), 40 give 0.063 K and 0.33 %, and 5.4 K at most, in a short spike as the front leaves the bed. It solves in about 1.5 s. A lumped capsule has no r.

property default_spatial_methods#

Finite volumes in every domain; the bed uses the fluid’s spatial method

property default_quick_plot_variables#

Variables shown by pybamm.QuickPlot by default (DESIGN D15)

property default_solver#

IDAKLU with rtol=1e-5 and atol=1e-8, as for the finned-tube family

property default_parameter_values#

See pytes.models.packed_bed.get_parameter_values()

The packed-bed family: a bed of PCM capsules with the fluid flowing through it.

class pytes.models.packed_bed.PackedBedParameters[source]#

Bases: DeviceParameters

Parameters of the packed-bed family, as PyBaMM symbols. See pytes.models.packed_bed.parameters for the geometry and the assumptions.

Variables:
pytes.models.packed_bed.get_parameter_values(parameter_set='Nallusamy2007')[source]#

Return parameter values for the packed-bed models.

Each set is the composition of the same name in pytes.parameter_layers, with the sources of its values in its "citations":

  • “Nallusamy2007” (default): the experiments of Nallusamy, Sampath and Velraj (2007), a stainless-steel tank (360 mm diameter, 460 mm high) of paraffin in spherical capsules (55 mm diameter), charged with water at 70 °C and 2 l/min from 32 °C. The measured temperatures are in examples/data.

  • “Raul2018”: the experiments of Raul et al. (2018), a bed (170 mm diameter, 360 mm long) of capsules (31 mm diameter) of A164, which melts at 168.7 °C, charged with Hytherm 600 oil at 180 °C and 8.2 l/min from 400 K.

The PCMs melt sharply, with corners smoothed over 0.01 K (DESIGN D7), and the heat transfer coefficient is an estimate. Energies are zero at the initial temperature.

Parameters:

parameter_set (str, optional) – The name of the parameter set (default “Nallusamy2007”).

Returns:

pybamm.ParameterValues

Base model and composition#

class pytes.BaseModel(name, options=None)[source]#

Bases: BaseModel

A heat battery model: a fixed composition of submodels (DESIGN D3).

Subclasses define get_parameters() and set_submodels(). Each submodel reads the variables of the others as pybamm.CoupledVariable (its requires). When the model is built it merges the submodels with pybamm.BaseModel.update(), checks the wiring and resolves every coupled variable, so the finished model contains none:

  • every required name is provided by exactly one submodel;

  • no variable depends on itself through coupled variables;

  • once resolved, each provided variable has the primary domain its coupled variable declares.

The equations are the same for charge and discharge, and the model has no events: cut-offs are the terminations of an experiment (DESIGN D11).

Variants are chosen through options (DESIGN D3): each model declares the values it allows in allowed_options, the first being the default. An unknown option or value raises, as does a combination check_options() rejects; a model never swaps a submodel the user did not ask for.

Parameters:
  • name (str) – The name of the model.

  • options (dict, optional) – The model’s options; missing ones take their defaults.

Variables:
  • param (object) – The parameters, from get_parameters().

  • options (dict) – The model’s options, defaults included.

  • submodels (dict) – The submodels, by name, in the order they were added.

  • controls (dict) – The model’s controls (DESIGN D9): the parameter symbols an experiment may turn into solver unknowns, keyed by the name of the matching variable.

temperature_scale = 200#

Scale of the temperature variables [K]

allowed_options = {}#

Allowed values of each option, the first being the default

process_options(options)[source]#

The options with their defaults filled in.

An option given under an old name (pytes.deprecation) is renamed, with a warning while its alias is active.

Raises:

pytes.OptionError – If an option or a value is not allowed (an old name whose alias is retired included), an option is given under both its old and new names, or the combination is rejected by check_options().

check_options(options)[source]#

Raise pytes.OptionError for an incompatible combination (none yet)

set_spatial_variables()[source]#

Create the spatial variables, which may depend on the options

get_parameters()[source]#

Return the model’s parameters

set_submodels()[source]#

Fill self.submodels

property controls#

The controls, inlet temperature and mass flow rate, as parameter symbols, keyed by the names of the matching variables

power(variables, controls=None)[source]#

Power [W] with some controls replaced by given symbols.

The experiment runner uses this to write a step’s power equation with the step’s target values, so that the equation depends on the control it adjusts.

Parameters:
  • variables (dict) – The model’s variables.

  • controls (dict, optional) – Symbols replacing the controls, keyed by control name.

property geometry_parameters#

Names of the parameters in the default geometry (the domain lengths), sorted

print_submodel_info()[source]#

Print the submodels: for each slot, the class, the variables it requires and provides, the parameters it uses and its modelling assumptions; then the parameters of the model’s geometry (DESIGN D3).

check_wiring()[source]#

Check that the submodels fit together (see the class docstring).

Returns:

dict – The submodel providing each variable name.

Raises:

WiringError –

build_model()[source]#

Merge the submodels, check the wiring, resolve the coupled variables and add the unit twins (DESIGN D12: the submodels define every quantity in SI units)

class pytes.ComposedModel(submodels, param, name='Composed model', defaults_from=None, **defaults)[source]#

Bases: BaseModel

A model built from given submodels, for developing and testing submodels (DESIGN D3).

The submodels are merged and checked exactly as in the built-in models (see pytes.BaseModel), so the result works with pybamm.Simulation, the experiment runner and the conformance checks. A composed model is not an admitted model (DESIGN D1).

Replacing one slot of an existing model:

base = pytes.SharpFrontModel()
storage = base.submodels["storage"]
coupling = pytes.submodels.WallCoupling(
    base.param, base.param.fluid, storage.label, storage.storage_geometry,
    flux_law=MyLaw(),
)
model = pytes.ComposedModel(
    {**base.submodels, "coupling": coupling}, base.param, name="My model",
    defaults_from=base,
)

The submodels are reused, not modified, so base is unchanged. The pytes.submodels.DeviceEnergy submodel refers to the storage and fluid submodels it was built with (for pytes.energy_between()); rebuild it when replacing them.

Parameters:
  • submodels (dict) – The submodels, by slot name, in order. They must have been built with param.

  • param (object) – The parameters the submodels were built with (a pytes.parameters.DeviceParameters, for the controls).

  • name (str, optional) – The name of the model (default “Composed model”).

  • defaults_from (pybamm.BaseModel, optional) – A model whose defaults (geometry, mesh, spatial methods, solver, parameter values and quick-plot variables) are used where no explicit value is given.

  • geometry (optional) – Explicit defaults, used by pybamm.Simulation as the default_* properties. Each overrides defaults_from; without either, PyBaMM’s default applies.

  • submesh_types (optional) – Explicit defaults, used by pybamm.Simulation as the default_* properties. Each overrides defaults_from; without either, PyBaMM’s default applies.

  • var_pts (optional) – Explicit defaults, used by pybamm.Simulation as the default_* properties. Each overrides defaults_from; without either, PyBaMM’s default applies.

  • spatial_methods (optional) – Explicit defaults, used by pybamm.Simulation as the default_* properties. Each overrides defaults_from; without either, PyBaMM’s default applies.

  • solver (optional) – Explicit defaults, used by pybamm.Simulation as the default_* properties. Each overrides defaults_from; without either, PyBaMM’s default applies.

  • parameter_values (optional) – Explicit defaults, used by pybamm.Simulation as the default_* properties. Each overrides defaults_from; without either, PyBaMM’s default applies.

  • quick_plot_variables (optional) – Explicit defaults, used by pybamm.Simulation as the default_* properties. Each overrides defaults_from; without either, PyBaMM’s default applies.

Raises:
  • pytes.WiringError – If the submodels do not fit together.

  • ValueError – If the geometry, submesh types or spatial methods miss a domain of the model’s states.

get_parameters()[source]#

Return the model’s parameters

set_submodels()[source]#

Fill self.submodels

property default_geometry#

Returns a dictionary of the default geometry for the model, which is empty by default.

property default_submesh_types#

Returns a dictionary of the default submesh types for the model, which is empty by default.

property default_var_pts#

Returns a dictionary of the default variable points for the model, which is empty by default.

property default_spatial_methods#

Returns a dictionary of the default spatial methods for the model, which is empty by default.

property default_solver#

Returns the default solver for the model, based on whether it is an ODE/DAE or algebraic model.

property default_parameter_values#

Returns the default parameter values for the model (an empty set of parameters by default).

property default_quick_plot_variables#

Returns the default variables for quick plotting (None by default).

exception pytes.OptionError[source]#

Bases: ValueError

An option, a value or a combination of options that the model does not allow

exception pytes.WiringError[source]#

Bases: ValueError

The submodels’ inputs and outputs do not fit together