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 CoolPropT (
pint.UnitRegistry.Quantity
) – Temperaturep (
pint.UnitRegistry.Quantity
) – Pressureu (
pint.UnitRegistry.Quantity
) – Mass-specific internal energys (
pint.UnitRegistry.Quantity
) – Mass-specific entropyv (
pint.UnitRegistry.Quantity
) – Mass-specific volumeh (
pint.UnitRegistry.Quantity
) – Mass-specific enthalpyx (
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.
- thermostate.thermostate.munge_coolprop_input_prop(prop: str) str ¶
Munge an input property pair from CoolProp into our format.
Example CoolProp input:
XY_INPUTS
, whereX
andY
are one ofT
,P
,Dmass
,Hmass
,Umass
,Q
, orSmass
. For use in ThermoState, we use lower case letters (except for T), replaceD
withv
, and replaceQ
withx
.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.
- class thermostate.abbreviations.SystemInternational¶
String representations of common units.
The attributes of this class are strings that represent the common units for thermodynamics calculations.
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.
- 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"
, orNone
. 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.
- 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.