I referenced this discussion in https://github.com/sympy/sympy/issues/23022
/c On Monday, November 28, 2022 at 4:51:07 PM UTC-6 [email protected] wrote: > Teo, > > My solution is to treat units as positive valued symbols and skip the > units tool in sympy. Then you just define things in the set of units you > wish to use and force your students to think about converting among them. > For some examples see the documentation for Algebra_with_Sympy > <https://gutow.github.io/Algebra_with_Sympy/algebra_with_sympy.html>. I > then use the .subs() to substitute in conversion factors. > > Jonathan > > On Monday, November 28, 2022 at 2:44:35 PM UTC-6 [email protected] wrote: > >> Thanks Oscar, that works. I can see why the current output is preferred >> by many, but the SI base units output is still useful for learners of >> Physics. My learners are young, so I hope there could be an easier way to >> achieve this. >> >> On Tuesday, 29 November 2022 at 01:55:20 UTC+11 Oscar wrote: >> >>> On Sat, 26 Nov 2022 at 07:13, Teo <[email protected]> wrote: >>> > >>> > Hi all. I just started using Sympy this week. According to this video, >>> when the following code was run, the units of ohm would be returned in SI >>> base units. >>> > >>> > import sympy.physics.units as u >>> > u.ohm >>> > >>> > However, when I tried, I got the symbol omega instead. Is there a >>> method to obtain the same SI base units (kgm^2)/(A^2s^3)? >>> >>> You can do it like this: >>> >>> In [1]: import sympy.physics.units as u >>> >>> In [3]: u.convert_to(u.ohm, [u.kg,u.m,u.ampere,u.s]) >>> Out[3]: >>> 2 >>> kilogram⋅meter >>> ─────────────── >>> 2 3 >>> ampere ⋅second >>> >>> Probably there should be an easier way. It's also possible like this: >>> >>> In [4]: u.convert_to(u.ohm, u.si.SI._base_units) >>> Out[4]: >>> 2 >>> kilogram⋅meter >>> ─────────────── >>> 2 3 >>> ampere ⋅second >>> >>> In [5]: u.si.SI._base_units >>> Out[5]: (meter, kilogram, second, ampere, mole, candela, kelvin) >>> >>> That's using _base_units which has a leading underscore indicating >>> that it should be considered "private". I don't see why it should be >>> considered private though... >>> >>> Oscar >>> >> -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/d2bdc061-15ab-4718-b8a4-26dd1355e451n%40googlegroups.com.
