Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Working with units

Hi,

I am just getting started with sage. I'm an electrical engineer. One thing that was really nice about Mathcad was letting me know if my units were messed up. I see there are electrical units types, like "units.electrical_potential.volt" but I'm struggling to see how to use it in a real application.

For example, a resistor, do I do something like this for 220 ohm resistor?

R = 220 * units.resistance.ohms

And what I'd really like to do is then define a voltage:

V = 1*units.electrical_potential.volt

And then be able to just go like this to get the current through the resistor:

V/R

Which would output something like this:

0.00455 * units.current.amp

Or better yet, just:

4.55mA

I don't mind building my own class to achieve this functionality. I also need to create my own units, for example noise spectral density such as V*sqrt(Hz).

Anyways, I really like what I see with Sage so far, I tried to use PTC Mathcad a while back and was pulling my hair out... Sage seems super intuitive and flexible, just being able to type things out in the notebook is great.

Thank you!

Erik