ccp.State#

class ccp.State(*args, **kwargs)#

A thermodynamic state.

This class is inherited from CP.AbstractState. Some extra functionality has been added.

Creates a state from fluid composition and two properties. Properties can be floats (SI units are considered) or pint quantities.

Parameters:
pfloat, pint.Quantity

Pressure

Tfloat, pint.Quantity

Temperature

hfloat, pint.Quantity

Enthalpy

sfloat, pint.Quantity

Entropy

rhofloat, pint.Quantity

Specific mass

fluiddict

Dictionary with constituent and composition (mole fraction). (e.g.: fluid={‘Oxygen’: 0.2096, ‘Nitrogen’: 0.7812, ‘Argon’: 0.0092})

EOSstr, optional

String with REFPROP, HEOS, PR or SRK. Default is set in ccp.config.EOS

phasestr, None or False, optional

String with phase information. Options are: - “liquid” - “gas” - “two_phase” - “supercritical_liquid” - “supercritical_gas” - “supercritical” Default is None: the first flash lets REFPROP/CoolProp determine the phase (a stability analysis that dominates the flash cost) and, when ccp.config.DEFAULT_PHASE is set (default “gas”), that phase is imposed for the later (p, T), (rho, T) and (rho, s) flashes if imposing it reproduces the resolved density. States derived from this one by the point solvers (discharge, isentropic and dummy states) inherit the imposed phase and solve every flash single phase, which is where the speed-up comes from. A general update with (p, h), (p, s) or (h, s) inputs stays an equilibrium flash, so a state throttled into the phase envelope resolves to the two-phase state. Pass phase=False to never impose a phase on this state, or set ccp.config.DEFAULT_PHASE = None to restore the legacy behaviour globally.

Returns:
stateccp.State

Examples

>>> import ccp
>>> Q_ = ccp.Q_
>>> fluid = {'Oxygen': 0.2096, 'Nitrogen': 0.7812, 'Argon': 0.0092}
>>> s = ccp.State(p=101008, T=273, fluid=fluid)
>>> s.rho()
<Quantity(1.28939426, 'kilogram / meter ** 3')>
>>> # Using pint quantities
>>> s = ccp.State(fluid=fluid, p=Q_(1, 'atm'), T=Q_(0, 'degC'))
>>> s.h()
<Quantity(273291.7, 'joule / kilogram')>

Methods

T(units=None)#

Temperature in Kelvin.

Returns:
Tpint.Quantity

Temperature (Kelvin).

T_critical(units=None)#

Critical Temperature in K.

Returns:
T_criticalpint.Quantity

Critical temperature (degK).

__init__(self, arg0: str, arg1: str, /) → None#
conductivity(units=None)#

Thermal conductivity (W/m/K).

Returns:
conductivitypint.Quantity

Thermal conductivity (W/m/K).

cp(units=None)#

Specific heat at constant pressure joule/(kilogram kelvin).

Returns:
cppint.Quantity

Specific heat at constant pressure joule/(kilogram kelvin).

cv(units=None)#

Specific heat at constant volume joule/(kilogram kelvin).

Returns:
cvpint.Quantity

Specific heat at constant volume joule/(kilogram kelvin).

dTdp_s(units=None)#

(dT / dp)s

First partial derivative of temperature related to pressure with constant entropy.

classmethod define(p=None, T=None, h=None, s=None, rho=None, fluid=None, EOS=None, **kwargs)#

Constructor for state.

Creates a state from fluid composition and two properties. Properties can be floats (SI units are considered) or pint quantities.

Parameters:
pfloat, pint.Quantity

Pressure

Tfloat, pint.Quantity

Temperature

hfloat, pint.Quantity

Enthalpy

sfloat, pint.Quantity

Entropy

rhofloat, pint.Quantity

Specific mass

fluiddict

Dictionary with constituent and composition. (e.g.: fluid={‘Oxygen’: 0.2096, ‘Nitrogen’: 0.7812, ‘Argon’: 0.0092}) String with REFPROP, HEOS, PR or SRK. Default is set in ccp.config.EOS

Returns:
stateccp.State

Examples

>>> import ccp
>>> Q_ = ccp.Q_
>>> fluid = {'Oxygen': 0.2096, 'Nitrogen': 0.7812, 'Argon': 0.0092}
>>> s = ccp.State.define(p=101008, T=273, fluid=fluid)
>>> s.rho()
<Quantity(1.28939426, 'kilogram / meter ** 3')>
>>> # Using pint quantities
>>> s = ccp.State.define(fluid=fluid, p=Q_(1, 'atm'), T=Q_(0, 'degC'))
>>> s.h()
<Quantity(273291.7, 'joule / kilogram')>
dpdv_s(units=None)#

Partial derivative of pressure to spec. volume with const. entropy.

gas_constant(units=None)#

Gas constant in joule / (mol kelvin).

Returns:
gas_constantpint.Quantity

Gas constant (joule / (mol kelvin).

get_coolprop_state()#

Return a CoolProp state object.

h(units=None)#

Specific Enthalpy (joule/kilogram).

Returns:
hpint.Quantity

Enthalpy (joule/kilogram).

kT()#

Isentropic temperature exponent (dimensionless).

Returns:
kTpint.Quantity

Isentropic temperature exponent (dimensionless).

kinematic_viscosity(units=None)#

Kinematic viscosity in m²/s.

Returns:
kinematic_viscositypint.Quantity

Kinematic viscosity (m²/s)

kv()#

Isentropic volume exponent (dimensionless).

Returns:
kvpint.Quantity

Isentropic volume exponent (dimensionless).

molar_mass(units=None)#

Molar mass in kg/mol.

Returns:
molar_masspint.Quantity

Molar mass (kg/mol).

p(units=None)#

Pressure in Pascal.

Returns:
ppint.Quantity

Pressure (pascal).

p_critical(units=None)#

Critical Pressure in Pa.

Returns:
p_criticalpint.Quantity

Critical pressure (Pa).

phase_is_stable()#

Check the imposed phase against an unconstrained flash.

Re-flashes the state at its current (p, T) without the imposed phase and compares densities. Returns True when no phase is imposed, when the unconstrained flash reproduces the density, or when the unconstrained flash fails (the check is then inconclusive). Returns False when the imposed root is metastable, i.e. the (p, T) point lies inside the phase envelope or on the other phase. The state is left unchanged (the imposed phase is restored).

plot_envelope(T_units='degK', p_units='Pa', dew_point_margin=20, fig=None, **kwargs)#

Plot phase envelope.

Plots the phase envelope and dew point limit.

Parameters:
T_unitsstr

Temperature units. Default is ‘degK’.

p_unitsstr

Pressure units. Default is ‘Pa’.

dew_point_marginfloat

Dew point margin. Default is 20 degK (from API). Unit is the same as T_units.

figplotly.graph_objects.Figure, optional

The figure object with the rotor representation.

Returns:
figplotly.graph_objects.Figure

The figure object with the rotor representation.

plot_point(T_units='degK', p_units='Pa', fig=None, **kwargs)#

Plot point.

Plot point in the given figure. Function will check for axis units and plot the point accordingly.

Parameters:
T_unitsstr

Temperature units. Default is ‘degK’.

p_unitsstr

Pressure units. Default is ‘Pa’.

figplotly.graph_objects.Figure, optional

The figure object with the rotor representation.

kwargsdict

Dictionary that will be passed to go.Scatter method.

Returns:
figplotly.graph_objects.Figure

The figure object with the rotor representation.

rho(units=None)#

Specific mass (kilogram/m**3).

Returns:
rhopint.Quantity

Specific mass (kilogram/m**3).

s(units=None)#

Specific entropy (per unit of mass).

Returns:
spint.Quantity

Entropy (joule/(kelvin kilogram)).

classmethod single_phase_solver()#

Let the imposed phase drive every flash while the block runs.

Used by the discharge closures of ccp.Point: a compression from a single-phase suction moves away from the dew line, so the single-phase root is the physical one and the (p, h), (p, s) and (h, s) flashes can skip the phase-stability analysis (see _solve_T_at_p()). Not used for general state updates, where a target inside the phase envelope must resolve to the equilibrium two-phase state.

speed_sound(units=None)#

Speed of sound - Eq. 8.1 from P. Nederstigt - Real Gas Thermodynamics.

Returns:
speed_soundpint.Quantity

Speed of sound (m/s).

update(p=None, T=None, rho=None, h=None, s=None, phase=None, **kwargs)#

Update the state.

This method simplifies the state update. Only keyword arguments are required to update.

Parameters:
pfloat, pint.Quantity

Pressure (Pa).

Tfloat, pint.Quantity

Temperature (degK).

rhofloat, pint.Quantity

Specific mass (kg/m**3).

hfloat, pint.Quantity

Enthalpy (J/kg).

sfloat, pint.Quantity

Entropy (J/(kg*degK)).

phasestr, optional

String with phase information. Options are: - “liquid” - “gas” - “two_phase” - “supercritical_liquid” - “supercritical_gas” - “supercritical” Default is the phase defined in the state initialization.

v(units=None)#

Specific volume (m**3/kilogram).

Returns:
vpint.Quantity

Specific volume (m**3/kilogram).

viscosity(units=None)#

Viscosity in pascal second.

Returns:
viscositypint.Quantity

Viscosity (pascal second)

z(units=None)#

Compressibility (dimensionless).

Returns:
zpint.Quantity

Compressibility (dimensionless).

Attributes

Bvirial

Cvirial

PIP

Prandtl

Q

Qmass

T_reducing

Tmax

Tmin

Ttriple

acentric_factor

all_critical_points

alpha0

alphar

apply_simple_mixing_rule

available_in_high_level

backend_name

build_options_json

build_phase_envelope

build_spinodal

change_EOS

chemical_potential

clear

compressibility_factor

conductivity_contributions

conformal_state

cp0mass

cp0molar

cpmass

cpmolar

criticality_contour_values

cvmass

cvmolar

d2alpha0_dDelta2

d2alpha0_dDelta_dTau

d2alpha0_dTau2

d2alphar_dDelta2

d2alphar_dDelta_dTau

d2alphar_dTau2

d3alpha0_dDelta2_dTau

d3alpha0_dDelta3

d3alpha0_dDelta_dTau2

d3alpha0_dTau3

d3alphar_dDelta2_dTau

d3alphar_dDelta3

d3alphar_dDelta_dTau2

d3alphar_dTau3

d4alphar_dDelta2_dTau2

d4alphar_dDelta3_dTau

d4alphar_dDelta4

d4alphar_dDelta_dTau3

d4alphar_dTau4

dBvirial_dT

dCvirial_dT

dalpha0_dDelta

dalpha0_dTau

dalphar_dDelta

dalphar_dTau

delta

dipole_moment

fast_evaluate

first_partial_deriv

first_saturation_deriv

first_two_phase_deriv

first_two_phase_deriv_splined

fluid_names

fluid_param_string

fugacity

fugacity_coefficient

fundamental_derivative_of_gas_dynamics

get_binary_interaction_double

get_binary_interaction_string

get_fluid_constant

get_fluid_parameter_double

get_mass_fractions

get_mole_fractions

get_phase_envelope_data

get_reducing_state

get_spinodal_data

get_state

gibbsmass

gibbsmass_excess

gibbsmolar

gibbsmolar_excess

gibbsmolar_residual

has_melting_line

helmholtzmass

helmholtzmass_excess

helmholtzmolar

helmholtzmolar_excess

hmass

hmass_excess

hmass_idealgas

hmolar

hmolar_excess

hmolar_idealgas

hmolar_residual

ideal_curve

isobaric_expansion_coefficient

isothermal_compressibility

keyed_output

melting_line

mole_fractions_liquid

mole_fractions_liquid_double

mole_fractions_vapor

mole_fractions_vapor_double

name

neff

p_triple

phase

pmax

rhomass

rhomass_critical

rhomass_reducing

rhomolar

rhomolar_critical

rhomolar_reducing

saturated_liquid_keyed_output

saturated_vapor_keyed_output

saturation_ancillary

second_partial_deriv

second_saturation_deriv

second_two_phase_deriv

set_T

set_binary_interaction_double

set_binary_interaction_string

set_cubic_alpha_C

set_fluid_parameter_double

set_mass_fractions

set_mole_fractions

set_volu_fractions

smass

smass_excess

smass_idealgas

smolar

smolar_excess

smolar_idealgas

smolar_residual

specify_phase

surface_tension

tangent_plane_distance

tau

trivial_keyed_output

true_critical_point

umass

umass_excess

umass_idealgas

umolar

umolar_excess

umolar_idealgas

unspecify_phase

update_QT_pure_superanc

update_with_guesses

using_mass_fractions

using_mole_fractions

using_volu_fractions

viscosity_contributions

volumemass_excess

volumemolar_excess