connorferster / forallpeople

Python SI units library: your 'daily driver' for calculations.
Apache License 2.0
299 stars 40 forks source link

Issue with my own defined units #20

Closed AloisPrimes closed 3 years ago

AloisPrimes commented 3 years ago

Hi, I really like handcalcs + forallpeople so far and I want to use it for master thesis calculations. Unfortunately, there is no support for thermodynamic calculations so I'm working on JSON file that have these units defined. The issue is when I try to specify output units, it doesn't work. I use my own environment (link here: https://textbin.cc/QfQSGFtRnb). It doesn't matter what I do, the result is still in mW/m/K and I can't force it make a result in W/m/K. Can you help me with this issue, please? xx2

PS: conductivity('CO2', 293.15, 1.01325) is my function that takes result from CoolProp module and make the syntax a little bit easier. xx

Imported modules and settings xx3

connorferster commented 3 years ago

Hi @razor1995,

Thank you for posting this issue. Dealing with thermal energy units like you have described is something that I am motivated to have work properly. Thank you also for supplying your JSON file.

I will play with this over the next day or so and come up with a solution.

AloisPrimes commented 3 years ago

Hi @razor1995,

Thank you for posting this issue. Dealing with thermal energy units like you have described is something that I am motivated to have work properly. Thank you also for supplying your JSON file.

I will play with this over the next day or so and come up with a solution.

Amazing, thank you!

connorferster commented 3 years ago

Hi @razor1995,

Apologies for the delay. I have found the problem. I am working on posting the patch right now but found that the change caused an unexpected behaviour in some of my tests. I will post again when I have the patched version uploaded to PyPI.

connorferster commented 3 years ago

Hi @razor1995,

Thank you for your patience. It is now patched. You should be able to update your installation via pip to v2.0.2.

To fix your issue, on the variable described above, use the .prefix() method with "unity" as the prefix argument: lambda_C02_1.prefix('unity'). This will force the representation to not use the auto-prefixing that is causing it to show as mW*m-1*K.

Regarding your defined units:

They should work great now! Let me know on this thread if you find any other issues.