pyforfluids package

Subpackages

Submodules

pyforfluids.core module

Core module.

class pyforfluids.core.Fluid(model, composition, temperature, pressure=None, density=None)

Bases: object

Describes a fluid based on a given model and it’s thermo variables.

Density and pressure can’t be defined at the same time. If pressure is given, the density will be calculated with an iterative algorithm using the derivatives given by the model.

Parameters
model: pyforfluids model_like

Model to use in the properties calculation.

compositiondict

Dictionary with the compounds concentrations as: {'methane': 0.8, 'ethane': 0.1} In some cases, as in GERG2008, the values will be normalized for the calculations but won’t be modified in the Fluid attribute

temperature: float

Fluid temperature in degrees Kelvin [K]

pressure: float

Fluid pressure in Pascals [Pa]

density: float

Fluid density in mol per liter [mol/L]

Attributes
propertiesdict

Fluid properties calculated by it’s model.

Methods

copy:

Returns a copy of the Fluid.

set_composition:

Change the Fluid’s composition.

set_temperature:

Change the Fluid’s temperature.

set_density:

Change the Fluid’s density.

set_pressure:

Change the FLuid’s pressure.

calculate_properties:

Calculate the Fluids properties, returns as a dictionary.

isotherm:

Calculate the Fluid properties along a density range.

density_iterator:

Calculate the Fluid’s density based on a specified pressure.

calculate_properties()

Calculate the fluid’s properties.

copy()

Return a copy of the fluid, taking density as independant variable.

Returns
Fluid
density_iterator(objective_pressure, vapor_phase=True, liquid_phase=True)

With a given pressure and temperature value, get the fluid density.

Parameters
objective_pressure: float

Fluid pressure where to calculate density.

vapor_phase: bool

Find vapor phase root.

liquid_phase: bool

Find liquid phase root.

Returns
liquid_density: float

Calculated density in liquid phase.

vapor_density: float

Calculated density in vapor phase.

single_phase: bool

True if only one root was found.

isotherm(density_range)

Calculate isotherm along a density range.

Calculate the fluid’s properties that it’s model can give at constant temperature along a density range.

Parameters
density_range: array-like

Range of values of density where to calculate the properties.

Returns
dict

Dictionary with all the properties that the model can calculate along the density_range.

set_composition(composition)

Change the fluid’s composition.

Parameters
composition: dict

Dictionary with the fluid compounds as keys and their molar concentration as values

example: composition = {‘methane’: 0.1, ‘ethane’: 0.9}

set_density(density)

Change the fluid’s density.

Parameters
density: float

New density

set_pressure(pressure)

Change the fluid’s pressure.

Parameters
pressure: float

New pressure

set_temperature(temperature)

Change the fluid’s temperature.

Parameters
temperature: float

New temperature

Module contents

PyForFluids.

Fluid properties simulation based on Ecuations of State.