This notebook contains material from chemeng316_fluids; content is available on Github.

< 2.3 Properties of Pure Substances with CoolProp | Contents | 3.0 Drawings and Diagrams >

Open in Colab

2.4 Queary Wolfram Alpha for Information¶

Wolfram Alpha is a very useful tool for obtaining information and solving problems. This examples shows how to directly interface with Wolfram Alpha.

First, I will gather pint and CoolProp and setup numPy for use.

In [8]:
try:
    from pint import UnitRegistry
except:
    !pip install pint
    from pint import UnitRegistry
finally:
    ur = UnitRegistry()
    
try:
    from CoolProp.CoolProp import PhaseSI, PropsSI
except:
    !pip install CoolProp
    from CoolProp.CoolProp import PhaseSI, PropsSI
finally:
    import CoolProp as CP

import numpy as np

2.4.1 Situation¶

I need the properties of Chlorine at 1.55 atm and 200 deg. C.

In [9]:
CP.CoolProp.get_fluid_param_string("Chlorine","JSON")
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Input In [9], in <cell line: 1>()
----> 1 CP.CoolProp.get_fluid_param_string("Chlorine","JSON")

File CoolProp/CoolProp.pyx:315, in CoolProp.CoolProp.get_fluid_param_string()

File CoolProp/CoolProp.pyx:316, in CoolProp.CoolProp.get_fluid_param_string()

RuntimeError: key [Chlorine] was not found in string_to_index_map in JSONFluidLibrary

Oh no ... CoolProp doesn't have chlorine ... so, I asked chatGPT for a python script to use WolframAlpha to query fluid properties ...

First, to use the Wolfram Alpha API and make queries in your Python code, you need to have an App ID. Here's how to get one:

  • Go to the Wolfram Alpha developer portal.
  • Sign in or create an account if you don't have one already.
  • Click on the "Get an AppID" button.
  • Fill out the form with your app's details, such as the name and description.
  • Click on the "Create AppID" button.
  • Your new App ID will be displayed on the page.
  • Copy your App ID and use it in your Python code to make queries to the Wolfram Alpha API.
In [10]:
try:
    import wolframalpha
except:
    !pip install wolframalpha
    import wolframalpha

app_id = "32XYTH-8WAQ64Y9KH" # this is my app_id ... yours would be different
client = wolframalpha.Client(app_id)

query = "density of chlorine at 200 degC and 1.55 atm"
res = client.query(query)

answer = next(res.results).text
print(answer)  # output: "997.047 kg/m^3 (kilograms per cubic meter)"
2.845 kg/m^3 (kilograms per cubic meter)

Sometimes it still won't work. So, we have to always ben willing to find other sources ...

In [11]:
query = "viscosity of chlorine at 200 degC and 1.55 atm"
res = client.query(query)

answer = next(res.results).text
print(answer)  # output: "997.047 kg/m^3 (kilograms per cubic meter)"
(data not available)

That still didn't work, so I just went to Engineer's Toolbox and looked it up. You may need a CRC handbook or some other reference at times.

$ \mu = 2.10e^{-5} $ Pa$\cdot$s

In [12]:
query = "speed of sound for chlorine at 200 degC and 1.55 atm"
res = client.query(query)

answer = next(res.results).text
print(answer)  
964.6 km/h (kilometers per hour)

< 2.3 Properties of Pure Substances with CoolProp | Contents | 3.0 Drawings and Diagrams >

Open in Colab