CP_FLUID_PARAM
This function fetches fluid metadata text from CoolProp for a given fluid name and parameter key. It is useful for displaying identifiers and descriptive attributes in spreadsheet reports.
The lookup is:
s = g(\text{fluid}, \text{param})
where the output s is a string metadata value returned by the CoolProp database.
Excel Usage
=CP_FLUID_PARAM(fluid, param)
fluid(str, required): CoolProp fluid identifier (for example Water or R134a).param(str, required): Requested metadata key (for example formula or CAS).
Returns (str): Metadata string value for the requested fluid parameter.
Example 1: Water chemical formula string
Inputs:
| fluid | param |
|---|---|
| Water | formula |
Excel formula:
=CP_FLUID_PARAM("Water", "formula")
Expected output:
"H_{2}O_{1}"
Example 2: Water CAS metadata string
Inputs:
| fluid | param |
|---|---|
| Water | CAS |
Excel formula:
=CP_FLUID_PARAM("Water", "CAS")
Expected output:
"7732-18-5"
Example 3: R134a aliases metadata string
Inputs:
| fluid | param |
|---|---|
| R134a | aliases |
Excel formula:
=CP_FLUID_PARAM("R134a", "aliases")
Expected output:
"R134A"
Example 4: Carbon dioxide InChI string
Inputs:
| fluid | param |
|---|---|
| CO2 | INCHI_String |
Excel formula:
=CP_FLUID_PARAM("CO2", "INCHI_String")
Expected output:
"InChI=1S/CO2/c2-1-3"
Python Code
Show Code
import CoolProp.CoolProp as CP
def cp_fluid_param(fluid, param):
"""
Retrieve a CoolProp metadata string for a specified fluid and metadata field.
See: https://coolprop.org/apidoc/CoolProp.CoolProp.html#CoolProp.CoolProp.get_fluid_param_string
This example function is provided as-is without any representation of accuracy.
Args:
fluid (str): CoolProp fluid identifier (for example Water or R134a).
param (str): Requested metadata key (for example formula or CAS).
Returns:
str: Metadata string value for the requested fluid parameter.
"""
try:
# CoolProp uses case-sensitive metadata keys. Accept common variations from spreadsheet users.
def normalize_param(p):
if not isinstance(p, str):
return p
p = p.strip()
if not p:
return p
# Handle common InChI name variations (e.g. INCHI_String, inchi_string)
low = p.lower().replace("_", "").replace(" ", "")
if "inchi" in low:
return "InChIKey" if "key" in low else "InChI"
# Common metadata keys in CoolProp are typically case-sensitive.
# Try removing underscores/spaces and using the value as-is.
return p.replace("_", "").replace(" ", "")
try:
return str(CP.get_fluid_param_string(fluid, param))
except Exception:
normalized = normalize_param(param)
if normalized != param:
try:
return str(CP.get_fluid_param_string(fluid, normalized))
except Exception:
pass
# last effort: try lower-case key
try:
return str(CP.get_fluid_param_string(fluid, str(param).lower()))
except Exception as e:
return f"Error: {str(e)}"
except Exception as e:
return f"Error: {str(e)}"Online Calculator
CoolProp fluid identifier (for example Water or R134a).
Requested metadata key (for example formula or CAS).