CoolProp.Plots.Common module#

class CoolProp.Plots.Common.Base2DObject(x_type, y_type, state=None, small=None)#

Bases: object

A container for shared settings and constants for the isolines and the property plots.

HS = 463#
PD = 251#
PH = 252#
PLOTS = {'HS': 463, 'PD': 251, 'PH': 252, 'PS': 253, 'PT': 230, 'TD': 241, 'TS': 243}#
PLOTS_INV = {230: 'PT', 241: 'TD', 243: 'TS', 251: 'PD', 252: 'PH', 253: 'PS', 463: 'HS'}#
PS = 253#
PT = 230#
PU = 257#
TD = 241#
TS = 243#
property critical_state#
property state#
property x_index#
property y_index#
class CoolProp.Plots.Common.BaseDimension(add_SI=0.0, mul_SI=1.0, off_SI=0.0, label='', symbol='', unit='')#

Bases: BaseQuantity

A dimension is a class that extends the BaseQuantity and adds a label, a symbol and a unit label

property label#
property symbol#
property unit#
class CoolProp.Plots.Common.BasePlot(fluid_ref, graph_type, unit_system='KSI', tp_limits='DEF', **kwargs)#

Bases: Base2DObject

The base class for all plots. It can be instantiated itself, but provides many general facilities to be used in the different plots.

HI_FACTOR = 2.25#
ID_FACTOR = 10.0#
LINE_PROPS = {20: {'color': 'Darkred', 'lw': 0.25}, 21: {'color': 'DarkCyan', 'lw': 0.25}, 22: {'color': 'black', 'lw': 0.25}, 41: {'color': 'DarkBlue', 'lw': 0.25}, 42: {'color': 'DarkGreen', 'lw': 0.25}, 43: {'color': 'DarkOrange', 'lw': 0.25}}#
LO_FACTOR = 1.01#
PROPERTIES = {20: 'temperature', 21: 'pressure', 41: 'density', 42: 'specific enthalpy', 43: 'specific entropy', 47: 'specific internal energy'}#
TP_LIMITS = {'ACHP': [173.15, 493.15, 25000.0, 2.25], 'DEF': [1.01, 2.25, 1.01, 2.25], 'NONE': [None, None, None, None], 'ORC': [273.15, 673.15, 25000.0, 2.25]}#
UNIT_SYSTEMS = {'EUR': <CoolProp.Plots.Common.EURunits object>, 'KSI': <CoolProp.Plots.Common.KSIunits object>, 'SI': <CoolProp.Plots.Common.SIunits object>}#
property axis#
property figure#
static generate_ranges(itype, imin, imax, num)#

Generate a range for a certain property

get_Tp_limits()#

Get the limits for the graphs in temperature and pressure, based on the active units: [Tmin, Tmax, pmin, pmax]

get_axis_limits(x_index=None, y_index=None)#

Returns the previously set limits or generates them and converts the default values to the selected unit system. Returns a list containing [xmin, xmax, ymin, ymax]

static get_x_y_dydx(xv, yv, x)#

Get x and y coordinates and the linear interpolation derivative

grid(b=None, **kwargs)#
inline_label(xv, yv, x=None, y=None)#

This will give the coordinates and rotation required to align a label with a line on a plot in axis units.

property limits#

Returns [Tmin,Tmax,pmin,pmax] as value or factors

property props#
savefig(*args, **kwargs)#
set_Tp_limits(limits)#

Set the limits for the graphs in temperature and pressure, based on the active units: [Tmin, Tmax, pmin, pmax]

set_axis_limits(limits)#

Set the limits of the internal axis object based on the active units, takes [xmin, xmax, ymin, ymax]

show()#
property system#
title(title)#
xlabel(xlabel)#
ylabel(ylabel)#
class CoolProp.Plots.Common.BaseQuantity(add_SI=0.0, mul_SI=1.0, off_SI=0.0)#

Bases: object

A very basic property that can convert an input to and from a given unit system, note that the conversion from SI units starts with a multiplication. If you need to remove an offset, use the off_SI property. Examples with temperature: celsius = BaseQuantity(add_SI=-273.15) fahrenheit = BaseQuantity(add_SI=32.0, mul_SI=1.8, off_SI=-273.15) Examples with pressure: bar = BaseQuantity(mul_SI=1e-5) psi = BaseQuantity(mul_SI=0.000145037738)

property add_SI#
from_SI(value)#
property mul_SI#
property off_SI#
to_SI(value)#
class CoolProp.Plots.Common.EURunits#

Bases: KSIunits

class CoolProp.Plots.Common.IsoLine(i_index, x_index, y_index, value=0.0, state=None, tracing=True)#

Bases: Base2DObject

An object that holds the functions to calculate a line of a constant property in the dimensions of a property plot. This class only uses SI units.

VALID_REQ = 0.05#
XY_SWITCH = {20: {230: None, 241: None, 243: None, 251: False, 252: True, 253: False, 463: False}, 21: {230: None, 241: False, 243: False, 251: None, 252: None, 253: None, 463: False}, 22: {230: False, 241: True, 243: True, 251: True, 252: True, 253: True, 463: True}, 41: {230: False, 241: None, 243: True, 251: None, 252: True, 253: True, 463: False}, 42: {230: False, 241: False, 243: False, 251: True, 252: None, 253: True, 463: None}, 43: {230: True, 241: False, 243: None, 251: True, 252: True, 253: None, 463: None}}#
calc_range(xvals=None, yvals=None)#
calc_sat_range(Trange=None, Prange=None, num=200)#
get_update_pair()#

Processes the values for the isoproperty and the graph dimensions to figure which should be used as inputs to the state update. Returns a tuple with the indices for the update call and the property constant. For an isobar in a Ts-diagram it returns the default order and the correct constant for the update pair: get_update_pair(CoolProp.iP,CoolProp.iSmass,CoolProp.iT) -> (0,1,2,CoolProp.PSmass_INPUTS) other values require switching and swapping.

property i_index#
sanitize_data()#

Fill the series via interpolation

property tracing#

Whether IsoLineTracer is used to walk along the isoline

Set this to False to calculate every point with an independent flash, which is much slower but does not depend on the neighbouring points.

property value#
property x#
property y#
class CoolProp.Plots.Common.IsoLineTracer(state, index1, index2, iso_index)#

Bases: object

Walk along an isoline, warm-starting every point from the previous one.

IsoLine.calc_range() evaluates an isoline at consecutive points, so the solution at one point is an excellent initial guess for the next one. That turns each point into a much cheaper problem than the cold two-dimensional flash it replaces:

  • A single-phase point is solved as a two-by-two Newton iteration in (T, rhomolar). Every property is an explicit function of (T, rhomolar) for a Helmholtz-energy EOS, so the iteration needs no flash at all, only DmolarT_INPUTS updates on a state whose phase has been imposed. Imposing the phase skips the saturation call that dominates a mixture update and, just as importantly, keeps the iterates on the single-phase root instead of snapping to a two-phase solution.

  • A two-phase point is bracketed by the two saturation states at the constant temperature or pressure of the input pair, and the vapour quality between them is found by a bracketed one-dimensional solve.

The tracer needs temperature or pressure among the two inputs – see supports() – because that is what lets it bracket the saturation curve. Every point it cannot bracket, on either side, raises so that the caller falls back to a plain AbstractState.update() call: a phase-imposed Newton iteration will happily return the metastable extension of the EOS inside the dome, and only the bracket rules that out.

Parameters:
  • state (CoolProp.AbstractState) – The state the isoline belongs to; it is cloned, never modified.

  • index1 (int) – Parameter indices of the two inputs, in the order the input pair expects them.

  • index2 (int) – Parameter indices of the two inputs, in the order the input pair expects them.

  • iso_index (int) – Parameter index the isoline holds constant.

BRACKET_RTOL = 1e-08#

A saturation bracket narrower than this (relative) cannot resolve a quality: a pure fluid at fixed T brackets p by psat on both sides, and an azeotropic mixture is barely better. Such a point is single-phase as far as the tracer is concerned.

BRANCH_RTOL = 1e-06#

How far outside the saturation densities a converged single-phase root may sit before it is rejected as the wrong branch.

DOME_MARGIN = 1.05#

The reported extent of the two-phase region is a traced curve, so its end is not exactly the cricondenbar (or cricondentherm). A point is only called supercritical this far beyond it.

ENVELOPE_CLOSED_RTOL = 0.35#

A phase envelope that ends with its two densities still this far apart did not run to the critical point, so where its dome ends is unknown and has to be found the expensive way.

LIQUID = -1#
NEWTON_ITMAX = 30#
NEWTON_RTOL = 1e-10#

The Newton iteration has settled once the relative step in both T and rhomolar is this small. That alone is not convergence – see RESIDUAL_RTOL – but it is what stops the iteration.

NEWTON_TRUST = 0.25#

A single Newton step may not move T or rhomolar by more than this fraction of their current value.

QUALITY_ITMAX = 60#
QUALITY_RTOL = 1e-08#
QUALITY_XTOL = 1e-12#

Bracketed solve for the vapour quality of a two-phase point.

RANGE_FACTOR = 2.0#

How far past the equation of state’s stated temperature range a root may sit. Deliberately loose: this is not a validity check. CoolProp answers a PT flash well outside the fitted range and so would the fallback this hands back to, so a tighter bound would only make traced and flashed points on the same isoline obey different rules. What it catches is an iteration that has run away entirely – an R504 isochore reaching four hundred times the maximum temperature.

RESIDUAL_RTOL = 1e-09#

Residual accepted at that point, relative to how much the property varies over the iteration variables.

VAPOUR = 1#
keyed_output(key)#

Read a property of the most recently traced point

set_guess(state)#

Adopt a state the caller solved itself as the warm start

A two-phase state says nothing about the single-phase root the Newton iteration follows, so it is ignored. Both phase() and Q() are consulted: the caller’s state is shared and may have had a phase imposed on it, in which case phase() reports that rather than what was found.

property state#

The state holding the most recently traced point

Note that its phase() reports the phase the tracer imposed on it, not one it determined; Q() is meaningful, phase() is not.

classmethod supports(index1, index2)#

Whether an isoline with these two inputs can be traced

The tracer needs temperature or pressure among the inputs, because that is what lets it put a saturation bracket around a point and so tell a two-phase state from a single-phase one. Without it the Newton iteration would run on a phase-imposed state with nothing to stop it returning the metastable extension of the EOS inside the dome – a plausible-looking answer that is simply wrong. HmassSmass_INPUTS and DmassSmass_INPUTS are the pairs this rules out.

update(value1, value2)#

Trace the state with index1 == value1 and index2 == value2

Raises if the point could not be traced. The warm start survives, because it holds the last point that did converge and that is still the best guess available for the next one – dropping it on every failure lets a single awkward point strand the whole rest of the line in a region where there is no saturation state to restart from.

class CoolProp.Plots.Common.KSIunits#

Bases: SIunits

class CoolProp.Plots.Common.PropertyDict#

Bases: object

A collection of dimensions for all the required quantities

property D#
property H#
property P#
property Q#
property S#
property T#
property U#
property dimensions#
class CoolProp.Plots.Common.SIunits#

Bases: PropertyDict

CoolProp.Plots.Common.get_critical_point(state)#
CoolProp.Plots.Common.interpolate_values_1d(x, y, x_points=None, kind='linear')#
CoolProp.Plots.Common.is_string(in_obj)#
CoolProp.Plots.Common.process_fluid_state(fluid_ref, fractions='mole')#

Check input for state object or fluid string

Parameters:
Return type:

CoolProp.AbstractState