Closed defencedog closed 8 months ago
I'm not sure what the issue is here. Please explain what you need help with and what errors you are getting. And please post the actual code in the issue instead of linking to a file.
OK as per your latest syntax this is my code: A small calculator on termux
termimal
import chemics as cm
formula = input("Chemical Formula e.g CH4, H3N, ClH = ")
press = float(input("Process pressure kPaA = "))
temp = float(input("Process temperature degC = "))
p = press*1000 # Absolute pressure [Pa]
tk = temp+273.15 # temperature of gas [K]
gas = cm.Gas(formula, tk, p)
mw = gas.molecular_weight
rho = gas.density()
cp = gas.heat_capacity()
k = gas.thermal_conductivity()
mu = gas.viscosity() / 1000
print(f'\n{formula} gas properites')
print(f'molecular weight {mw:.2f} g/mol')
print(f'density {rho:.3f} kg/m³')
print(f'heat capacity {cp:.3f} J/(mol⋅K)')
print(f'thermal conductivity {k:.3f} W/(m⋅K)')
print(f'viscosity {mu:.3f} cP')
print('Note: in SI units 1 cP = 10⁻³ Pa⋅s = 1 mPa⋅s')
Now if input formula
as H2
....following error happens. This doesn't happen in case the str
is Cl2
(Chlorine)
Chemical Formula e.g CH4, H3N, ClH = H2
Process pressure kPaA = 130
Process temperature degC = 20
Traceback (most recent call last):
File "/storage/emulated/0/Download/jnotebooks/chemic_gasrho.py", line 13, in <module>
cp = gas.heat_capacity()
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/chemics/gas.py", line 176, in heat_capacity
row = _get_row("data/gas-cp-yaws.csv", self.formula, self.cas_number)
File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/chemics/gas.py", line 37, in _get_row
raise ValueError(m)
ValueError: Multiple substances available for H2. Include CAS number too.
It's working
Chemical Formula e.g CH4, H3N, ClH = Cl2
Process pressure kPaA = 130
Process temperature degC = 40
Cl2 gas properites
molecular weight 70.90 g/mol
density 3.540 kg/m³
heat capacity 34.178 J/(mol⋅K)
thermal conductivity 0.010 W/(m⋅K)
viscosity 0.141 cP
Note: in SI units 1 cP = 10⁻³ Pa⋅s = 1 mPa⋅s
Giving the CAS number for hydrogen will fix your problem.
import chemics as cm
gas = cm.Gas("H2", 313, cas_number="1333-74-0")
@wigging
Can we somehow query CAS
for the input str
? If the lib
can understand CAS
it must have a database for it.
Can we somehow query
CAS
for the inputstr
? If thelib
can understandCAS
it must have a database for it.
Submit this as an idea in the Discussions tab. I would like to discuss it more. Might be a good feature to add to the package.
Working great for me. Attaching
android
built forarmx32
remove.txt
chemics-24.1-py2.py3-none-any.whl.txtSyntax have changed, can author guide me in following script
chemic_gasrho.py.txt