Unit conversion
I'm not certain if the behaviour is correct in this example, or I am possibly misunderstanding something. Sorry about the lengthy example, but I had difficulties simplifying it into a simpler one.
# Setup units
lbf = units.force.pound_force;
inch = units.length.inch;
sec = units.time.second;
psi = lbf / inch^2;
gal = 231.0*inch^3;
min = 60.0*sec;
gpm = gal/min;
hole = gpm/sqrt(psi);
# Define the given constraints
FLext = 20000.0*lbf;
vext = 15.0*inch/sec;
FLret = -10000.0*lbf;
vret = -15.0*inch/sec;
# Assumed values
Ps = 3000.0*psi;
pv = 1.0;
pc = 1.4;
# System of 3 equations, 3 unknowns
ABE = var('A_BE');
ARE = var('A_RE');
kv = var('k_v');
eq1 = vext^2 == (Ps*ABE - FLext) * kv^2 / ABE^3 / (1 + pv^2 * pc^(-3));
eq2 = vret^2 == (FLret + Ps*ARE) * kv^2 / ARE^3 / (1 + pv^2 * pc^3);
eq3 = pc == ABE / ARE;
sol = solve([eq1, eq2, eq3], [ABE, ARE, kv], solution_dict=True);
sol = sol[1];
show(sol[ABE])
show(sol[ARE])
show(sol[kv])
# Showing the units of various variables
show(sol[kv].convert())
show(hole.convert())
show( (sol[kv]/hole).convert() ) # this should be dimensionless
# Showing the potential bug with unit conversion
show(sol[kv].convert(hole)) # ValueError: Incompatible units
Running the code, the section labelled # Showing the units of various variables
, you can see the various units of the relevant variables. The code for show( (sol[kv]/hole).convert() )
should return a dimensionless value, however it still shows units in the result. Looking at the non-numeric portions of it, everything appears to cancel. Running show(sol[kv].convert(hole))
results in ValueError: Incompatible units
. I expected a conversion into gpm/sqrt(psi) (i.e. holes).
What concerns me is my calculator (TI-92+) has conversion difficulties with this unit as well, being unable to convert. Is this the expected/normal/ideal behaviour for sage? If so, for what reason(s)? If not, what should I do?
Thank you,
menturi