jcaiuwyo / cantera

Automatically exported from code.google.com/p/cantera
0 stars 0 forks source link

Include a units package to clarify values (possibly Python only) #202

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
After just spending way too much time looking for an error caused by my wrong 
use of units, I suggest including a units package. Thus, you could e.g. 
determine much more easy what gas.viscosity is;)

Possibly, this would make sense for the Python interface only. There are 
several packages available (numericalunits, pint, units). I personally became a 
big fan of pint (https://pint.readthedocs.org).

However, I don't know if the wrapping of the C++ code makes things more 
difficult. It surely is low-priority. But it would still be a cool feature.

Original issue reported on code.google.com by thetruet...@googlemail.com on 29 Jan 2014 at 9:58

GoogleCodeExporter commented 9 years ago
I don't think that integration of a units package into cantera is necessary, as 
units are as far as I am aware consistent within cantera, and documentation of 
units (at least of r2710) is available through python's help function 
(generated from the original .pyx files in 
<cantera-src>/interfaces/cython/cantera).

Original comment by ischo...@gmail.com on 30 Jan 2014 at 4:03

GoogleCodeExporter commented 9 years ago
You're right, it is pretty nice that cantera is unit-consistent (and SI). The 
documentation of the units is also pretty good, although a little cumbersome 
(like gas.viscosity? does not give you any useful help, but you have to find 
your way to cantera.transport.viscosity? - or am I doing something cumbersome 
myself here?)

The advantage of using a units-package would be that the user is forced to 
enter the right units, and can easily convert it to other units.

This is surely not an essential feature and also possibly annoying for some 
people. It's just an idea.

Original comment by thetruet...@googlemail.com on 30 Jan 2014 at 5:27

GoogleCodeExporter commented 9 years ago
I wouldn't be opposed to providing a set of wrapped classes that worked with 
dimensioned values, but I think the main Cantera classes should remain as is. 
It would probably even be possible to generate the classes somewhat 
programatically.

As far accessing the documentation in IPython goes, this is unfortately what 
always happens when using properties. That is, you get the docstring for 
whatever "gas.viscosity" returns, in this case a float, rather than the 
docstring for the property. The other option besides using 
"Solution.viscosity?" is to do "gas.__class__.viscosity?" which is also 
somewhat cumbersome, but doesn't require you to know the type of the underlying 
object.

Original comment by yarmond on 31 Jan 2014 at 3:59