Models#
PyTES models, by family.
Finned tube#
- class pytes.SharpFrontModel(name='Sharp front model', options=None)[source]#
Bases:
BaseFinnedTubeModelFinned-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:
“fluid”:
pytes.submodels.AdvectedFluid;“storage”:
pytes.submodels.EnthalpyStorageof the composite, in cylindrical coordinates;“coupling”:
pytes.submodels.WallCoupling, the composite touching the tube wall;“device energy”:
pytes.submodels.DeviceEnergy.
- Parameters:
- 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,
ygives 0.054 K on average in the outlet temperature and 0.11 % in the stored energy, andz0.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:
BaseFinnedTubeModelFinned-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:
“fluid”:
pytes.submodels.AdvectedFluid;“storage”:
pytes.submodels.EnthalpyStorageof the PCM across the half-gap (cartesian);“fins”:
pytes.submodels.EnthalpyStorageof the fin metal, radially along the fins (cylindrical);“coupling”:
pytes.submodels.FinRootCoupling, the fluid and the fin roots;“fin-PCM coupling”:
pytes.submodels.FinStorageCoupling;“device energy”:
pytes.submodels.DeviceEnergy.
- Parameters:
- 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.
- property default_geometry#
That of
BaseFinnedTubeModel, plus the half-gap between two fins (xfrom half the fin thickness to half the fin pitch)
- property default_var_pts#
Number of mesh points in each spatial variable. 10 points in
xchange 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:
BaseModelBase 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.parametersfor 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"withpytes.submodels.register_correlation().
- Parameters:
- Variables:
y (
pybamm.SpatialVariable) – Distance from the tube axis [m], from the tube radius to the storage outer radiusR_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
- property flow_path#
The flow paths, one per tube
- 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 everyz, so its integral along the tube is the tube length times its value.
- property default_geometry#
The PCM annulus (
yfrom the tube radius to the storage outer radiusR_f + D) and the tube (zfrom 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.QuickPlotby default (DESIGN D15)
- property default_solver#
IDAKLU with
rtol=1e-5andatol=1e-8
- property default_parameter_values#
- class pytes.models.finned_tube.FinnedTubeParameters[source]#
Bases:
DeviceParametersParameters of the finned-tube family, as PyBaMM symbols. See
pytes.parameters.DeviceParametersfor the device-level ones.- Variables:
R_f (
pybamm.Parameter) – “Tube radius [m]”.Z (
pybamm.Parameter) – “Tube length [m]”.H (
pybamm.Symbol) – The outer radius of the storage around a tube [m],R_f + D.D (
pybamm.Parameter) – “Storage depth [m]”: the extent of the storage from the tube wall (the length of the “storage depth” domain), so that the storage outer radius is about half the distance between neighbouring tubes.d_c (
pybamm.Parameter) – “Fin thickness [m]”.d_m (
pybamm.Parameter) – “Fin pitch [m]”: the centre-to-centre distance between consecutive fins.delta (
pybamm.Symbol) – Volume fraction of the fins,d_c / d_m.N_tubes (
pybamm.Parameter) – “Number of tubes”.perimeter (area,) – Flow area
pi R_f**2[m2] and wall perimeter2 pi R_f[m] of one tube.fluid (
pytes.fluids.ConstantPropertyLiquid) – The fluid-property object, with zero enthalpy at the reference temperature.pcm (
pytes.materials.PureMaterial) – The PCM on its own (parameters “PCM …”).metal (
pytes.materials.SensibleMaterial) – The fin metal (parameters “Metal …”).composite (
pytes.materials.CompositeMaterial) – The PCM and the fins homogenised into one material.T_m (
pybamm.Parameter) – The PCM melting temperature [K].temperature_reference (
pybamm.Symbol) – Reference of the temperature variables: the melting temperature.
- 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. Seepytes.models.finned_tube.FinnedTubeParametersfor the meaning of each parameter and the geometry, andpytes.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:
Packed bed#
- class pytes.PackedBedModel(name='Packed bed model', options=None)[source]#
Bases:
BaseModelPacked 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.parametersfor the geometry and the assumptions.Submodels:
“fluid”:
pytes.submodels.AdvectedFluid, through the voids (flow areaeps A, a single flow path);“storage”:
pytes.submodels.EnthalpyStorageof the PCM in a capsule (spherical), exchanging heat at its surface; or, for a lumped capsule,pytes.submodels.LumpedStorage;“coupling”:
pytes.submodels.WallCoupling, the fluid and the capsule surfaces (3 (1 - eps) / Rof surface per unit bed volume);“device energy”:
pytes.submodels.DeviceEnergy;“per-area totals”:
pytes.submodels.PerAreaTotals, the device totals per unit bed cross-sectional area (e.g. “Power per unit area [W.m-2]”).
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"withpytes.submodels.register_correlation().
- Parameters:
- 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
- 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 (
rfrom 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 inr(40 inz), 40 give 0.27 K on average in the outlet temperature and 1.8 % in the stored energy; against 640 points inz(40 inr), 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 nor.
- 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.QuickPlotby default (DESIGN D15)
- property default_solver#
IDAKLU with
rtol=1e-5andatol=1e-8, as for the finned-tube family
- property default_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:
DeviceParametersParameters of the packed-bed family, as PyBaMM symbols. See
pytes.models.packed_bed.parametersfor the geometry and the assumptions.- Variables:
Z (
pybamm.Parameter) – “Bed length [m]”.A (
pybamm.Parameter) – “Bed cross-sectional area [m2]”.eps (
pybamm.Parameter) – “Bed porosity”: the volume fraction of the bed taken by the fluid.R (
pybamm.Parameter) – “Capsule radius [m]”: the outer radius of a capsule.flow_area (
pybamm.Symbol) – Area of the bed cross-section open to the flow,eps A[m2].capsule_density (
pybamm.Symbol) – Number of capsules per unit bed volume [m-3].fluid (
pytes.fluids.ConstantPropertyLiquid) – The fluid-property object, with zero enthalpy at the reference temperature.pcm (
pytes.materials.PureMaterial) – The PCM (parameters “PCM …”).T_m (
pybamm.Parameter) – The PCM melting temperature [K].temperature_reference (
pybamm.Symbol) – Reference of the temperature variables: the melting temperature.
- 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:
Base model and composition#
- class pytes.BaseModel(name, options=None)[source]#
Bases:
BaseModelA heat battery model: a fixed composition of submodels (DESIGN D3).
Subclasses define
get_parameters()andset_submodels(). Each submodel reads the variables of the others aspybamm.CoupledVariable(itsrequires). When the model is built it merges the submodels withpybamm.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 inallowed_options, the first being the default. An unknown option or value raises, as does a combinationcheck_options()rejects; a model never swaps a submodel the user did not ask for.- Parameters:
- Variables:
param (
object) – The parameters, fromget_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.OptionErrorfor an incompatible combination (none yet)
- 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.
- 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).
- class pytes.ComposedModel(submodels, param, name='Composed model', defaults_from=None, **defaults)[source]#
Bases:
BaseModelA 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 withpybamm.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
baseis unchanged. Thepytes.submodels.DeviceEnergysubmodel refers to the storage and fluid submodels it was built with (forpytes.energy_between()); rebuild it when replacing them.- Parameters:
submodels (
dict) – The submodels, by slot name, in order. They must have been built withparam.param (
object) – The parameters the submodels were built with (apytes.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.Simulationas thedefault_*properties. Each overridesdefaults_from; without either, PyBaMM’s default applies.submesh_types (optional) – Explicit defaults, used by
pybamm.Simulationas thedefault_*properties. Each overridesdefaults_from; without either, PyBaMM’s default applies.var_pts (optional) – Explicit defaults, used by
pybamm.Simulationas thedefault_*properties. Each overridesdefaults_from; without either, PyBaMM’s default applies.spatial_methods (optional) – Explicit defaults, used by
pybamm.Simulationas thedefault_*properties. Each overridesdefaults_from; without either, PyBaMM’s default applies.solver (optional) – Explicit defaults, used by
pybamm.Simulationas thedefault_*properties. Each overridesdefaults_from; without either, PyBaMM’s default applies.parameter_values (optional) – Explicit defaults, used by
pybamm.Simulationas thedefault_*properties. Each overridesdefaults_from; without either, PyBaMM’s default applies.quick_plot_variables (optional) – Explicit defaults, used by
pybamm.Simulationas thedefault_*properties. Each overridesdefaults_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.
- 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:
ValueErrorAn option, a value or a combination of options that the model does not allow
- exception pytes.WiringError[source]#
Bases:
ValueErrorThe submodels’ inputs and outputs do not fit together