KingsburyLab/pyEQL

pint dimension error using pyEQL

Closed this issue · 2 comments

Hi,

I am brand new to pyEQL, and try to follow the pyEQL tutorials. However, I got errors in the first few steps.

`

import pyEQL
import pint
s1 = pyEQL.Solution([['Na+','1 mol/L'],['Cl-','1 mol/L']],temperature='20 degC',volume='500 mL')
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\123\AppData\Local\Programs\Python\Python37\lib\site-packages\pyEQL\solution.py", line 145, in init
self.add_solute(item)
File "C:\Users\123\AppData\Local\Programs\Python\Python37\lib\site-packages\pyEQL\solution.py", line 176, in add_solute
solute_vol = self._get_solute_volume()
File "C:\Users\123\AppData\Local\Programs\Python\Python37\lib\site-packages\pyEQL\solution.py", line 2213, in _get_solute_volume
param.get_value()[4],Salt.z_cation,Salt.z_anion,Salt.nu_cation,Salt.nu_anion,temperature)
File "C:\Users\123\AppData\Local\Programs\Python\Python37\lib\site-packages\pyEQL\activity_correction.py", line 550, in get_apparent_volume_pitzer
second_term = (nu_cation + nu_anion) * abs(z_cation * z_anion) * (_debye_parameter_volume(temperature) / 2 / b) * math.log((1+b
ionic_strength ** 0.5))
File "C:\Users\123\AppData\Local\Programs\Python\Python37\lib\site-packages\pyEQL\activity_correction.py", line 208, in _debye_parameter_volume
result = -2 * _debye_parameter_osmotic(temperature) * unit.R * unit(temperature) *
File "C:\Users\123\AppData\Local\Programs\Python\Python37\lib\site-packages\pyEQL\activity_correction.py", line 154, in _debye_parameter_osmotic
output = 1/3 * _debye_parameter_activity(temperature)
File "C:\Users\123\AppData\Local\Programs\Python\Python37\lib\site-packages\pyEQL\activity_correction.py", line 116, in _debye_parameter_activity
return debyeparam.to('kg ** 0.5 / mol ** 0.5')
File "C:\Users\123\AppData\Local\Programs\Python\Python37\lib\site-packages\pint\quantity.py", line 591, in to
magnitude = self._convert_magnitude_not_inplace(other, *contexts, **ctx_kwargs)
File "C:\Users\123\AppData\Local\Programs\Python\Python37\lib\site-packages\pint\quantity.py", line 540, in _convert_magnitude_not_inplace
return self._REGISTRY.convert(self._magnitude, self._units, other)
File "C:\Users\123\AppData\Local\Programs\Python\Python37\lib\site-packages\pint\registry.py", line 925, in convert
return self._convert(value, src, dst, inplace)
File "C:\Users\123\AppData\Local\Programs\Python\Python37\lib\site-packages\pint\registry.py", line 1762, in _convert
return super()._convert(value, src, dst, inplace)
File "C:\Users\123\AppData\Local\Programs\Python\Python37\lib\site-packages\pint\registry.py", line 1376, in _convert
return super()._convert(value, src, dst, inplace)
File "C:\Users\123\AppData\Local\Programs\Python\Python37\lib\site-packages\pint\registry.py", line 958, in _convert
raise DimensionalityError(src, dst, src_dim, dst_dim)
pint.errors.DimensionalityError: Cannot convert from 'avogadro_number ** 0.5 * elementary_charge ** 3 * kilogram ** 0.5 / boltzmann_constant ** 1.5 / kelvin ** 1.5 / meter ** 1.5 / vacuum_permittivity ** 1.5' ([mass] ** 0.5) to 'kilogram ** 0.5 / mole ** 0.5' ([mass] ** 0.5 / [substance] ** 0.5)`

Does anyone know how to solve the problem?

Hi @duliuying . This error was caused by a change made to the pint library back in May, and it should be fixed as of pyEQL version 0.5.2. Please make sure you've upgraded pyEQL, and report back if you're still having trouble.

Hi @duliuying . This error was caused by a change made to the pint library back in May, and it should be fixed as of pyEQL version 0.5.2. Please make sure you've upgraded pyEQL, and report back if you're still having trouble.

Hi @rkingsbury Thanks for your help. After I upgraded pyEQL to version 0.5.2, this problem was fixed. Thanks again!