This notebook contains material from chemeng316_fluids; content is available on Github.
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.
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
I need the properties of Chlorine at 1.55 atm and 200 deg. C.
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:
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 ...
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
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)