Dear all,
I am not sure if I am using the units package correctly, but I have
the following problem:
I want to assign different units to variables, then get the units of
derived variables that are functions of others and check for
consistency at the end. Here is a simple example. I know the units of
H_l, T_a and T_l and want to know the units of h_c in H_l == h_c*(T_a
- T_l). For this, I create a dictionary udict with the units of the
variables I know, then I solve the equation for the unknown variable
and substitute the units for the known variables. However, subtraction
of two variables with the same units makes the units cancel out!!!
This is not very useful. Am I doing something wrong, or is this
desired behaviour? I hope there is an easy way around it. Thanks for
your help already!
sage: udict = {}
sage: udict[H_l] = units.energy.calorie/units.length.centimeter^2/
units.time.minute
sage: udict[T_a] = units.temperature.kelvin
sage: udict[T_l] = units.temperature.kelvin
sage: soln = solve(H_l == h_c*(T_a - T_l), h_c)[0]; soln
h_c == H_l/(T_a - T_l)
sage: soln.subs(udict)
Traceback (most recent call last):
...
RuntimeError: power::eval(): division by zero
---
This works:
sage: (H_l/T_a).subs(udict)
calorie/(centimeter^2*kelvin*minute)
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org