New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PhysicalField mishandles compound units #534
Comments
Is it an option to simply define your >>> from fipy import PhysicalField
>>> v = PhysicalField('1 mol/l')
>>> k = PhysicalField('1 l**2/mol**2/h')
>>> print(k)
1.0 l**2/h/mol**2
>>> print(k.inBaseUnits())
2.77777777778e-10 m**6/s/mol**2
>>> t = v**3 * k
>>> print(t)
1.0 mol/h/l
>>> print(t.unit)
<PhysicalUnit mol/h/l>
>>> print(t.inBaseUnits().unit)
<PhysicalUnit mol/s/m**3> edited for inline returns |
There's definitely something wrong in the unit handling for |
While waiting for pull request #535 to be merged, you should be able to work around this issue with >>> t = v * v * v * k as the bug only affects the |
@guyer Great, thanks for the quick fix. Sorry for the lapse, I was away for a break over the new years! I have another issue which I've seen mentioned in the mailing list, but have not seen a resolution for yet. Should I open another issue for it? The creation of meshes (1D in my case) does not seem to take distance units as its input in dx. That is In further progress, a simple |
@achennu Please file a new ticket. Dimensional meshes are supposed to work, but are evidently never tested, which means they don't work. |
@guyer Any ETA on when a next release of fipy (i guess 3.1.4) will be done? I'd like to include fipy as a dependency that is pip installable. |
|
Thanks for the info @guyer Yes, I realize that it is pip installable. The pypi version doesn't include the fixes made in this issue, and requires a special case to do a pip git+git_url install for fipy. Installing it that way includes the fixes for the units. I've noticed an issue with pip installing it. Will report it separately. |
I am looking to use the units of the PhysicalFields (and thereby Variables)
Here is an example that shows the problem:
I thought this may be due to the numeric factor in the units (which I've seen being handled in other cases well), so I factored that out to make the units
l**2/mol**2/h
. This also leads to a problem, suggesting the issue is more in the parsing of compound units, rather than the numeric factor.I also tried to make v into a PhysicalField instead of a Variable, but the problem persists.
This seems like a bug to me, though I can't quite see from the source code where the error occurs yet.
Any help would be appreciated!
The text was updated successfully, but these errors were encountered: