sunpeek.components.fluids#

Caveat: This docstring is outdated.

Summary#

This module implements fluids and fluid properties for HarvestIT.

Extended Summary#

A typical calculation involving fluid properties is getting thermal power when only volume flow and inlet & outlet temperatures are given; this requires knowledge about the fluid density and heat capacity at given temperatures. Pressure-dependence of these properties is negligible for practicale purposes and is thus neglected in HarvestIT.

The main superclass is Fluid which provides the two main methods for accessing fluid properties at given temperatures, namely Fluid.get_density() and Fluid.get_heat_capacity(). Both accept temperature as a scalar or vector pint Quantity.

Main classes: There are two options for using fluids:

1. Class CoolPropFluid: An interface to the well-known CoolProp database. This gives access to fluid properties of all CoolProp incompressible fluids listed under CoolProp Incompressibles. This includes some general fluids (such as “Propylene Glycol”) and some specific products (such as “Antifrogen L, Propylene Glycol”).

2. Class WPDFluid: An interface to fluids for which only graphical property information is given. This is a common case in solar thermal when the only piece of information given for a heat transfer fluid is a data sheet with some plots. The workflow in this case involves a tool called WebPlotDigitizer and is described in more detail below.

CoolProp fluids#

CoolProp fluids are implemented in the class CoolPropFluid which gives access to fluid properties of all CoolProp incompressible fluids listed under CoolProp Incompressibles. CoolPropFluid subclasses Fluid and thus gives high level access to properties via getDensity() and getHeatCapacity(). Since all fluids in this class are incompressibles, the exact pressure has a minor influence on CoolProps results. For simplicity, pressure is set to a constant, P_DEFAULT.

Fluids: The fluids include water, 60 pure fluids and 73 mixed fluids (as of 2022). Water properties follow the formulation in IAPWS-95, implemented in CoolProps HEOS::water backend. The mixed fluids are binary mixtures (water + some substance and require a concentration. Depending on the substance, the concentration is interpreted as mass concentration (mass-based binary mixtures) or volume concentration ( volume-based binary mixtures).

WPD fluids#

This module supports

  • reading & interpolating csv data created with WebPlotDigitizer.

  • training sklearn models for interpolation / fitting, and visual checks of fit quality.

# - exporting the trained models as ONNX files (to be stored in database). # - calculating fluid properties by using prediction based on ONNX model. - building WPDFluid instances from these ONNX files.

Here is a step-by-step guide on how to add a fluid to HarvestIT for which only graphical information about fluid properties is given (see #73). An example is the FHW plant. Example workflows can be found under tests/tests_fluids.

To enable property calculation for WPD fluids, follow this process:

  1. Use WebPlotDigitizer, an open source tool, to convert graphical information to numeric data.

    tutorial like [this one](https://www.youtube.com/watch?v=P7GbGdMvopU) or [this one](https://www.youtube.com/watch?v=Mv5nqAPCKA4). - If graphical information is for multiple concentrations (like in the example image in this issue), create multiple datasets in WebPlotDigitizer, with each dataset named like the concentration: e.g. dataset name 20 for the 20% concentration curve. - Repeat the plot digitization for both density and heat capacity. Export the data to csv, using the default settings. Generate files `density.csv` and `heat_capacity.csv`

2. In Python / HarvestIT, create models for density and heat capacity using this code (or see `tests/tests_fluids/test_wpd.py`).

  • Create a dictionary `unit` specifying the units used in the fluid property image: inputs (temperature

`te` and concentration `c`) and output (density or heat capacity):

` import fluids.wpd as wpd unit = {'density': {'te': 'degC', 'out': 'kg m**-3'}, 'heat_capacity': {'te': 'degC', 'out': 'J g**-1 K**-1'}} # Or if fluid has concentration as input: unit = {'density': {'te': 'degC', 'c': 'percent', 'out': 'kg m**-3'}, 'heat_capacity': {'te': 'degC', 'c': 'percent', 'out': 'J g**-1 K**-1'}} # Train the models: rho_model = wpd.ModelFactory(unit=unit['density']).train("density.csv") cp_model = wpd.ModelFactory(unit=unit['heat_capacity']).train("heat_capacity.csv") # Create fluid: fluid = wpd.FluidFactory(concentration=concentration, density_model=rho_model, heat_capacity_model=cp_model) `

3. Commit the trained fluid to the SunPeek database: ``` import common.utils as utils with utils.S() as session:

session.add(fluid) session.commit(fluid)

```

This implementation holds a ModelFactory used to generate a WPDModel. There are 2 subclasses of WPDModel: - WPDModelPure, for fluids that do _not_ have a concentration attached (e.g. measured at fixed concentration). Here, the interpolation / fit is temperature vs. target value (density or heat capacity). - WPDModelMixed, for fluids that have variable concentration (e.g. variable concentration properties available from data sheet). Here, the interpolation / fit is temperature and concentration vs. target value. This assumes that each concentration curve has been treated as a separate dataset in WebPlotDigitizer, with the concentration curve named after the concentration value, e.g. “50” for concentration 50%.

Sources#

Classes

CoolPropFluid([fluid, concentration])

High level class for interface with CoolProp incompressible fluids.

CoolPropFluidDefinition([fluid_string])

Fluid(**kwargs)

Stores basic information about fluids in SunPeek and a high level, and implements a high level abstract fluid interface for SunPeek.

FluidDefinition([fluid_string])

Fluid with all information to store in database.

FluidFactory(**kwargs)

UninitialisedFluid(fluid_def_name, stored_args)

WPDFluid(**kwargs)

Fluid with given trained sklearn models for density and heat capacity.

WPDFluidDefinition(name, density_model, ...)

Definitions of WPD fluids, for reuse by WPDFluid subclasses

WPDFluidMixed(concentration, **kwargs)

WPDFluid subclass for fluids that do have a variable concentration, either mass or volume concentration.

WPDFluidPure(**kwargs)

WPDFluid subclass for fluids that do not have a variable concentration, so they are either pure fluids or have a fixed concentration.