exerpy.costing

Sizes of the components and their purchased equipment costs from the correlations of OpenPyTEA [8].

A cost function takes one or more sizes of a component. sizes() returns all that the model determines, in SI units: the power, mass flow, inlet volume flow and pressure ratio of a turbomachine, the power of a motor or a generator, and the heat flow, heat transfer capacity, logarithmic mean temperature difference and area of a heat exchanger, and the heat flow and live steam mass flow of a steam generator. A user-defined cost equation takes the ones it needs; estimate() takes the one a correlation of OpenPyTEA is based on and converts it into the units of the correlation.

The area of a heat exchanger follows from its sections: the exchanger is taken as counter-flow and cut at every phase change of either stream, and the area is the sum of \(\dot{Q}_i / (U_i \, \Delta T_{\mathrm{lm},i})\). Every section takes the overall heat transfer coefficient given as U or, without one, the default of its comparable cell in U_CELLS: the exchanger type and the fluid group and phase of each stream. A default is the median of the published values of its cell, read from data/heat_transfer_coefficients.json; a section without a cell asks for U.

The correlations of OpenPyTEA come from the process-industry literature. A size outside the range of a correlation is reported as such, and the cost is then extrapolated from the nearest bound with a scaling exponent, split into parallel units as OpenPyTEA does, or replaced by a value given by the user. OpenPyTEA is an optional dependency, pip install exerpy[costs] or pip install openpytea. Its costs are in US dollars.

exerpy.costing.available()[source]

Whether OpenPyTEA [8] is installed.

exerpy.costing.convert(value, what, units)[source]

Express a size given in SI units in the units of a correlation.

Parameters:
  • value (float) – The size in SI units, see UNITS.

  • what (str) – A key of UNITS.

  • units (str) – The units text of the correlation.

Returns:

float or None – The size in the units of the correlation, or None when the correlation is based on a kind of size other than the one the component provides.

exerpy.costing.correlation(key)[source]

The row of correlations() with the given key, as a dictionary.

exerpy.costing.correlations(component_class=None)[source]

Return the cost correlations of OpenPyTEA [8], or the ones that cost a class of component.

Parameters:

component_class (str, optional) – Name of a component class, e.g. "Compressor". Without it, every correlation is returned.

Returns:

pandas.DataFrame – Columns key, category, type, units, s_lower, s_upper, reference_year, material, source and remarks, one row per correlation. The correlations whose size cannot be derived from the units they state are included; they take a size given by hand.

exerpy.costing.cost_index()[source]

The plant cost index OpenPyTEA [8] ships, as {year: value}.

exerpy.costing.default_correlation(component)[source]

The correlation suggested for a component, or None when OpenPyTEA [8] has none that fits.

exerpy.costing.dimension(units)[source]

Read the dimension and the SI factor of the size units a correlation states.

Parameters:

units (str) – The units text of a correlation, e.g. "shaft power, kW" or "area, ft^2".

Returns:

tuple or None – (dimension, factor) with the dimension "rate", "area", "volume", "volume_flow" or "mass_flow" and the factor that turns the SI value (W, m², m³, m³/s, kg/s) into the units of the correlation. None for a size of another kind, a product of two sizes or a volume flow at standard conditions.

exerpy.costing.energy_flow(conn)[source]

The energy flow of a stream in W: the one the export states, or the heating value of a fuel stream.

Returns None when neither is available.

exerpy.costing.estimate(component, key, U=None, value=None, outside='scale', exponent=0.6, method='sections', exchanger_type=None)[source]

Estimate the purchased equipment cost of a component with a correlation of OpenPyTEA [8].

The size is the one of sizes() that has the dimension of the units of the correlation, a power or a heat flow, an area, a volume flow at the inlet or a mass flow, converted into those units.

Parameters:
  • component (Component)

  • key (str) – The correlation to use, see correlations().

  • U (float or dict, optional) – Overall heat transfer coefficient of a heat exchanger in W/m²K, see heat_exchanger_area().

  • value (float, optional) – The size in the units of the correlation, given by hand when the model does not determine it.

  • outside, exponent – See purchase_cost().

  • method (str, optional) – See heat_exchanger_area().

  • exchanger_type (str, optional) – A key of EXCHANGER_TYPES; by default the one the correlation describes, see exchanger_type_of().

Returns:

dict – The result of purchase_cost() together with size, size_units, quantity (the size read from the model, None for one given by hand), key, fit (see fit()) and sizing, the result of heat_exchanger_area() for an area.

Raises:

ValueError – If the size is neither given nor derivable, or lies below the range of the correlation and parallel units were asked for.

exerpy.costing.exchanger_type_of(key)[source]

The type in U_DEFAULTS that a heat exchanger correlation of OpenPyTEA [8] describes.

exerpy.costing.fit(row, value)[source]

Say how a size relates to the range a correlation was fitted over.

Parameters:
  • row (dict) – A correlation, as correlation() returns it.

  • value (float or None) – The size in the units of the correlation.

Returns:

dict – status is "in range", "below", "above", "unbounded" (the correlation states no range) or "unknown" (no size); lower and upper are the bounds, and ratio the size over the bound it exceeds.

exerpy.costing.fluid_group(conn)[source]

The fluid group of U_CELLS a stream belongs to, from its mass composition.

A stream of one species is placed by its name: water/steam, ammonia, CO2, hydrogen, natural gas (methane), hydrocarbon refrigerants, siloxanes, toluene/aromatics, HFC/HFO (the other refrigerants named R…), thermal oil, molten salt or glycol/brine. A mixture of ammonia and water is an absorption mixture, one of nitrogen and oxygen is air, one that also carries carbon dioxide from combustion is flue gas, and one of mostly methane is natural gas.

Returns:

str or None – The group, or None for a stream no group describes.

exerpy.costing.heat_exchanger(component)[source]

Duty, temperature difference and heat transfer capacity of a heat exchanger with two streams.

Returns:

dict or None – Q is the heat flow in W; dT_lm the logarithmic mean temperature difference of the counter-flow arrangement in K, None on a temperature cross; kA the heat transfer capacity in W/K, taken from the simulation where the model carries it and from \(\dot{Q} / \Delta T_\mathrm{lm}\) otherwise, with kA_source saying which; phase_change lists the sides, "hot" and "cold", on which a stream changes phase. None when the component does not have two streams in and out.

exerpy.costing.heat_exchanger_area(component, U=None, exchanger_type='shell_and_tube', method='sections')[source]

Area of a heat exchanger, by its sections or by its heat transfer capacity.

Parameters:
  • component (Component) – A heat exchanger with two streams in and two out.

  • U (float or dict, optional) – Overall heat transfer coefficient in W/m²K. The sections take one value or one per pair of phases, see heat_exchanger_sections(); the "kA" method needs one value, \(A = kA / U\).

  • exchanger_type (str, optional) – A key of EXCHANGER_TYPES, for the defaults of the sections.

  • method (str, optional) – "sections" (default), falling back to "kA" where the sections cannot be formed, or "kA".

Returns:

dict or None – area in m² (None when "kA" has no single U), method, exchanger_type, sections (the result of heat_exchanger_sections(), or None) and U. None when the component does not have two streams in and out.

exerpy.costing.heat_exchanger_sections(component, U=None, exchanger_type='shell_and_tube')[source]

Area of a heat exchanger from its sections, each with the heat transfer coefficient of its phases and fluids.

The exchanger is taken as counter-flow and cut at every point where one of the streams crosses a saturation line, so every section has one phase on each side. A stream of one fluid CoolProp knows is followed through its saturation enthalpies, from the temperatures, pressures, qualities and enthalpy differences of the export, so the enthalpy reference of the simulator does not matter; a mixture or an unknown fluid is taken as single-phase with a temperature linear in the heat transferred, as a gas when its specific volume is above 0.01 m³/kg and as a liquid otherwise, or by its fluid group where the export has no volume flow.

Parameters:
  • component (Component) – A heat exchanger with two streams in and two out.

  • U (float or dict, optional) – Overall heat transfer coefficient in W/m²K of every section, or per section by its pair of phases, the phase of the hot stream first, as {("gas", "liquid"): 450.0, ("two-phase", "liquid"): 2500.0}. A section not given takes the default of its cell in U_CELLS.

  • exchanger_type (str, optional) – A key of EXCHANGER_TYPES. Default is "shell_and_tube".

Returns:

dict or None – area in m², Q in W and sections, one entry per section with Q, dT_lm, hot and cold (the phases as words), U, U_scope ("user" or "default"), U_cell (the cell, None for a value given by the user), U_sources (keys of U_SOURCES), U_n_sources and area; fluids holds the groups of the hot and the cold stream, see fluid_group(); profile lists (Q, T_hot, T_cold) points along the exchanger in W and K. None when the streams do not allow it: a temperature cross, a saturated end whose quality is unknown, or a stream state CoolProp does not accept.

Raises:

ValueError – If the exchanger type is unknown, or if a section has no comparable cell and U gives none.

exerpy.costing.heating_value(conn)[source]

The lower heating value of a stream in J/kg from its mass composition, None for a stream without fuel.

Species the table does not name count as inert.

exerpy.costing.per_dollar(currency, year)[source]

How much of a currency one US dollar bought in a year, for the currencies the module knows.

Parameters:
  • currency (str) – "USD" or "EUR"; anything else is unknown.

  • year (int) – The year of the cost. A year outside the table takes the nearest year in it.

Returns:

float or None – Units of the currency per US dollar, None for a currency the module does not know.

exerpy.costing.purchase_cost(key, value, outside='scale', exponent=0.6)[source]

Evaluate a correlation of OpenPyTEA [8], inside or outside its range.

Parameters:
  • key (str) – The key of the correlation.

  • value (float) – The size in the units of the correlation.

  • outside (str, optional) – What to do with a size outside the range of the correlation. "scale" (default) extrapolates from the nearest bound with the scaling exponent, \(C = C(S_\mathrm{b}) \, (S / S_\mathrm{b})^{n}\), so the component stays one unit. "parallel" lets OpenPyTEA split a size above the range into identical units; a size below the range is then an error.

  • exponent (float, optional) – The scaling exponent \(n\). Default 0.6.

Returns:

dict – PEC is the cost in USD of reference_year, the year of the correlation; units the number of parallel units; method is "correlation", "scaled" or "parallel"; bound the bound the cost was scaled from, if any.

Raises:
  • KeyError – If the key is unknown.

  • ValueError – If the size lies below the range and outside is "parallel".

exerpy.costing.quantities(component)[source]

The sizes the model determines for a component, see QUANTITIES; empty for any other class.

exerpy.costing.size(component, quantity, U=None, exchanger_type='shell_and_tube', method='sections')[source]

Read one size of a component from the model, in SI units.

Parameters:
  • component (Component) – A component of an analysed plant.

  • quantity (str) – One of quantities() of the component, see QUANTITIES; the unit is in UNITS.

  • U, exchanger_type, method – For the area of a heat exchanger, see heat_exchanger_area().

Returns:

float or None – The size, or None when the model does not determine it.

Raises:

ValueError – If the component has no such size, or if a section of a heat exchanger has no coefficient.

exerpy.costing.sizes(component, U=None, exchanger_type='shell_and_tube', method='sections')[source]

Read all sizes the model determines for a component, in SI units.

A cost function takes the ones it needs, for example sizes(compressor)["volume_flow"]. The parameters are those of size().

Returns:

dict – {quantity: value} for every one of quantities(), None where the model does not determine it; empty for a component the model gives no size for.