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

Unit simplification in results #45

Open
jwiegley opened this issue Jul 31, 2024 · 2 comments
Open

Unit simplification in results #45

jwiegley opened this issue Jul 31, 2024 · 2 comments

Comments

@jwiegley
Copy link

Hello! Great mode, it could replace all my uses of the Soulver app on macOS.

One question I have: I made the alias for using uconv to do unit conversions, but it's not working as I would expect. For example, let's say I do the following in calc:

'120 gal
'794 ft^2
/                 => 1:  0.151133501259 gal / ft^2
u c in            => 1:  0.242443324937 in

This is great. But in literate-calc-mode I have:

flow = 120 gal
surface_area = 794 ft^2
loss_by_flow = flow / surface_area => loss_by_flow: 0.151133501259 gal / ft^2
result = uconv(loss_by_flow, in) => result: 1.04953820319e-3 gal / in^2

This is not the answer I would have expected, although it's correct in some sense. Why is it only applying the unit conversion to the denominator here, and not to the whole result?

@jwiegley
Copy link
Author

Where uconv is defined using (defalias 'calcFunc-uconv 'math-convert-units).

@sulami
Copy link
Owner

sulami commented Aug 1, 2024

From playing around with it for a bit, I don't think it's a division thing, for example

flow = 120 L => flow: 120 L
surface_area = 794 m^2 => surface_area: 794 m^2
loss_by_flow = flow / surface_area => loss_by_flow: 0.151133501259 L / m^2
result = uconv(loss_by_flow, gal) => result: 0.0399252472077 gal / m^2

converts only the numerator instead. My suspicion is that in^2/m^2 aren't actually recognized as units of volume for some reason. Similarly, usimplify doesn't seem to reduce the fraction either.

As a counterexample, this works as intended:

f = 150 g * 3 m/s^2 => f: 450 g m / s^2
= uconv(f, N) => 0.45 N

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

2 participants