Variables#

Standard variable names (DESIGN D12) and the helper that generates unit twins.

Models define every quantity in SI units (K, W, J, …). For reading convenience, every model also provides twins in common units, generated by add_unit_twins() when the model is built and never written by hand (see UNIT_TWINS): a temperature in [K] gets a [degC] twin, a power in [W] a [kW] twin, an energy in [J] a [kWh] twin, a time in [s] [min] and [h] twins, a volume flow rate in [m3.s-1] a [l.min-1] twin and a volume in [m3] a [l] twin. Temperature differences have no twin (a difference of 5 K is not 5 degC): their names contain “temperature difference” (e.g. “Inlet-outlet temperature difference [K]”).

pytes.variables.REQUIRED_VARIABLES = ('Time [s]', 'Mass flow rate [kg.s-1]', 'Inlet temperature [K]', 'Outlet temperature [K]', 'Inlet specific enthalpy [J.kg-1]', 'Outlet specific enthalpy [J.kg-1]', 'Power [W]', 'Discharged energy [J]', 'Charged energy [J]', 'Discharged throughput [J]', 'Charged throughput [J]', 'Storage thermal energy [J]', 'Storage average temperature [K]', 'Storage cross-section average temperature [K]', 'Heat transfer fluid thermal energy [J]', 'Total thermal energy [J]', 'Heat loss power [W]', 'Heat transfer fluid specific enthalpy [J.kg-1]', 'Heat transfer fluid temperature [K]', 'Heat transfer fluid velocity [m.s-1]', 'Inlet-outlet temperature difference [K]', 'Volume flow rate [m3.s-1]', 'Pumped volume [m3]')#

Variables every model must provide

pytes.variables.OPTIONAL_VARIABLES = ('Average liquid fraction',)#

Variables a model may provide, under these names when it does

pytes.variables.RESERVED_VARIABLES = ('Pressure drop [Pa]',)#

Names reserved for quantities no model computes yet, so that the first ones agree

pytes.variables.FLOW_COORDINATE = 'z'#

Name of the flow-path coordinate in every family

pytes.variables.FLOW_DOMAIN = 'flow path'#

Name of the flow-path domain in every family

pytes.variables.UNIT_TWINS = {'[J]': (('[kWh]', <function <lambda>>),), '[K]': (('[degC]', <function <lambda>>),), '[W]': (('[kW]', <function <lambda>>),), '[m3.s-1]': (('[l.min-1]', <function <lambda>>),), '[m3]': (('[l]', <function <lambda>>),), '[s]': (('[min]', <function <lambda>>), ('[h]', <function <lambda>>))}#

The unit twins of a variable in an SI unit (key), each with its unit and conversion

pytes.variables.is_temperature_difference(name)[source]#

Whether a variable name denotes a temperature difference (K only, no twin)

pytes.variables.unit_twins(name)[source]#

A variable’s unit twins, as {twin name: conversion}; empty if it has none (its unit is not in UNIT_TWINS, or it is a temperature difference)

pytes.variables.add_unit_twins(variables)[source]#

Add the unit twin of every variable that has one (see UNIT_TWINS).

Parameters:

variables (dict) – The variables, in SI units (modified in place).

Returns:

dict – variables, for chaining.

Raises:

ValueError – If a twin is already defined: twins are generated, never written by hand.