Skip to content
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

Defining units help #1469

Closed
aldo-o opened this issue Feb 19, 2022 · 0 comments
Closed

Defining units help #1469

aldo-o opened this issue Feb 19, 2022 · 0 comments

Comments

@aldo-o
Copy link

aldo-o commented Feb 19, 2022

Greetings,

I am reading the docs in regards to defining new units but I don't get the results I want. This is the case scenario;

I want to implement Heat of Combustion (per Mass). When I make the conversion online 1 Joule per Kilogram [J/KG] = 1000 Kilogram per Kilojoule [Kg/KJ].

This is the configuration of the text file:

# Defitions
# j_kg 	-> Joule per Kilogram [J/kg]
# kg_j 	-> Kilogram per Joule [kg/J]
# kg_kj	-> Kilogram per Kilojoule [kg/KJ]

j_kg = [heat_of_combustion_per_mass] = kg_j
kg_kj = 1000 * j_kg

But when I execute this code;

ureg = UnitRegistry()
ureg.load_definitions("./my_def.txt")

test = 2 * ureg["j_kg"]
print(test.to(ureg["kg_kj"]))

and it returns 0.002 kg_kj. It should return 2000 kg_kj.

Thank You in advance!

UPDADE #1: Never mind. It 1:00 AM and my brain in not functioning well. My apologies.

@aldo-o aldo-o closed this as completed Feb 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant