ThermoState

thermostate.thermostate module

Base ThermoState module.

class thermostate.thermostate.CoolPropPhaseNames(value)

Map the phase names in CoolProp.

class thermostate.thermostate.State(substance: str, label=None, units=None, **kwargs: pint.Quantity)

Basic State manager for thermodyanmic states.

Parameters:
  • substance (str) – One of the substances supported by CoolProp

  • T (pint.UnitRegistry.Quantity) – Temperature

  • p (pint.UnitRegistry.Quantity) – Pressure

  • u (pint.UnitRegistry.Quantity) – Mass-specific internal energy

  • s (pint.UnitRegistry.Quantity) – Mass-specific entropy

  • v (pint.UnitRegistry.Quantity) – Mass-specific volume

  • h (pint.UnitRegistry.Quantity) – Mass-specific enthalpy

  • x (pint.UnitRegistry.Quantity) – Quality

property label

Get or set the string label for this state, used in plotting.

to_PropsSI(prop: str, value: pint.Quantity) float

CoolProp can’t handle Pint Quantites so return the magnitude only.

Convert to the appropriate SI units first.

to_SI(prop: str, value: pint.Quantity) pint.Quantity

Convert the input value to the appropriate SI base units.

property units

Get or set the string units for this state to set attribute units.

exception thermostate.thermostate.StateError

Errors associated with setting the State object.

thermostate.thermostate.munge_coolprop_input_prop(prop: str) str

Munge an input property pair from CoolProp into our format.

Example CoolProp input: XY_INPUTS, where X and Y are one of T, P, Dmass, Hmass, Umass, Q, or Smass. For use in ThermoState, we use lower case letters (except for T), replace D with v, and replace Q with x.

Examples

  • DmassHmass_INPUTS: vh

  • DmassT_INPUTS: vT

  • PUmass_INPUTS: pu

thermostate.thermostate.render_traceback(self: DimensionalityError)

Render a minimized version of the DimensionalityError traceback.

The default Jupyter/IPython traceback includes a lot of context from within pint that actually raises the DimensionalityError. This context isn’t really needed for this particular error, since the problem is almost certainly in the user code. This function removes the additional context.

thermostate.thermostate.set_default_units(units)

Set default units to be used in class initialization.

thermostate.abbreviations module

This module contains classes with attributes representing the common property units.

Example

These classes are shortcuts to the units for common properties:

>>> st = State("water", T=Q_(300.0, "K"), p=Q_(101325, "Pa"))
>>> h = st.h.to(SI.h)
>>> u = st.u.to(EE.u)
class thermostate.abbreviations.EnglishEngineering

String representations of common units.

The attributes of this class are strings that represent the common units for thermodynamics calculations.

h

BTU/lb

Type:

str

p

psi

Type:

str

s

BTU/(lb*degR)

Type:

str

T

degF

Type:

str

u

BTU/lb

Type:

str

v

ft**3/lb

Type:

str

cp

BTU/(lb*degR)

Type:

str

cv

BTU/(lb*degR)

Type:

str

class thermostate.abbreviations.SystemInternational

String representations of common units.

The attributes of this class are strings that represent the common units for thermodynamics calculations.

h

kJ/kg

Type:

str

p

bar

Type:

str

s

kJ/(kg*K)

Type:

str

T

degC

Type:

str

u

kJ/kg

Type:

str

v

m**3/lb

Type:

str

cv

kJ/(K*kg)

Type:

str

cp

kJ/(K*kg)

Type:

str

thermostate.plotting module

Base Plotting module.

class thermostate.plotting.IdealGas(substance, *args)

Class for plotting graphs modeled as an Ideal Gas.

plot(x_axis, y_axis)

Add a plot to this instance with given x and y axes.

Parameters:
  • x_axis (str) – The string representing the x axis for this plot. Allowed axes are “T”, “p”, “u”, “s”, “v”, and “h”.

  • y_axis (str) – The string representing the y axis for this plot. Allowed axes are “T”, “p”, “u”, “s”, “v”, and “h”.

class thermostate.plotting.PlottedState(key: str, state: ~thermostate.thermostate.State, markers: dict = <factory>)

Data class to efficiently store states in the self.states dictionary.

class thermostate.plotting.PlottingBase(substance: str)

Basic Plotting manager for thermodynamic states.

Parameters:

substance (str) – One of the substances supported by CoolProp

add_process(state_1: State, state_2: State, process_type: str | None = None, label_1: str | None = None, label_2: str | None = None)

Add a thermodynamic process to the self.process dictionary and plots it.

A property of the states is held constant and all intermediate states are traced out in a line between the two states on the graph. The property that is held constant is specified by the user with the process_type input. If no property is to be held constant then a straight line between the two points is drawn.

Parameters:
  • state_1 (State) – The starting state for this process.

  • state_2 (State) – The final state for this process.

  • process_type (optional, str) – If given, specifies the property that is held constant during the process. Must be one of "isochoric", "isovolumetric", "isobaric", "isothermal", "isoenergetic", "isoenthalpic", "isentropic", or None. If not specified, a straight line is drawn between the states.

  • label_1 (optional, str) – If given, will be used to label the first state.

  • label_2 (optional, str) – If given, will be used to label the second state.

add_state(state: State, key: str | None = None, label: str | None = None)

Add a state to the self.states dictionary and plot it.

abstract plot(x_axis: str, y_axis: str)

Hold the place of a plot function that a child class must establish.

remove_process(state_1: State, state_2: State, remove_states: bool = False)

Remove a process from the self.process dictionary.

The process to be removed is specified by the states that were used to initially create the process. It is optional to keep the points associated with the states while still removing the line object.

Parameters:
  • state_1 (State) – The starting state for this process.

  • state_2 (State) – The final state for this process.

  • remove_states (bool) – If True, the associated states are removed from the instance.

remove_state(state: State | None = None, key: str | None = None)

Remove a state from the self.states dictionary and plots.

set_xscale(x_axis, y_axis, scale='linear')

Access a plot in self.plots and change the scale of its x axis.

set_yscale(x_axis, y_axis, scale='linear')

Access a plot in self.plots and change the scale of its y axis.

class thermostate.plotting.VaporDome(substance, *args)

Class for plotting graphs with a vapor dome.

plot(x_axis, y_axis)

Add a plot with a vapor dome to this instance with given x and y axes.

Parameters:
  • x_axis (str) – The string representing the x axis for this plot. Allowed axes are “T”, “p”, “u”, “s”, “v”, and “h”.

  • y_axis (str) – The string representing the y axis for this plot. Allowed axes are “T”, “p”, “u”, “s”, “v”, and “h”.