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

dimensional test of derived dimensions #16754

Open
schymans opened this issue Apr 29, 2019 · 2 comments
Open

dimensional test of derived dimensions #16754

schymans opened this issue Apr 29, 2019 · 2 comments
Labels
physics.units Units and dimensions

Comments

@schymans
Copy link
Contributor

The below should not give an error, as the dimensions of energy are compatible with mass * length ** 2 / second ** 2:

from sympy import S, exp
from sympy.physics.units import energy, length, mass, time, Quantity
u = Quantity("u")
v = Quantity("v")
u.set_dimension(energy)
v.set_dimension(mass*length**2/time**2)
Quantity._collect_factor_and_dimension(1 - (u/v))

returns
ValueError: Dimension of "-u/v" is energy*time**2/(length**2*mass), but it should be 1

@oscarbenjamin oscarbenjamin added the physics.units Units and dimensions label Apr 29, 2019
@schymans
Copy link
Contributor Author

Same problem also occurs with check_dimensions:

from sympy import S, exp
from sympy.physics.units import energy, length, mass, time, Quantity
from sympy.physics.units.systems.si import dimsys_SI, SI
from sympy.physics.units.util import convert_to, check_dimensions
u = Quantity("u")
v = Quantity("v")
SI.set_quantity_dimension(u, energy)
SI.set_quantity_dimension(v, mass*length**2/time**2)
check_dimensions(1 - (u/v))

returns
ValueError: addends have incompatible dimensions

@schymans
Copy link
Contributor Author

And maybe a more straightforward example:

from sympy.physics.units import joule, kilogram, meter, second
from sympy.physics.units.util import check_dimensions
check_dimensions(1 - (kilogram*meter**2/second**2) / joule)

returns
ValueError: addends have incompatible dimensions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
physics.units Units and dimensions
Projects
None yet
Development

No branches or pull requests

2 participants