Converts a quantity to the given target units using sympy.physics.units.convert_to.
Args:
expr_key: The key of the expression (previously introduced) to convert.
target_units: List of unit names as strings (e.g., ["meter", "1/second"]).
unit_system: Optional unit system (from UnitSystem enum). Defaults to SI.
The following units are available by default:
SI base units: meter, second, kilogram, ampere, kelvin, mole, candela
Length: kilometer, millimeter
Mass: gram
Energy: joule
Force: newton
Pressure: pascal
Power: watt
Electric: coulomb, volt, ohm, farad, henry
Constants: speed_of_light, gravitational_constant, planck
IMPORTANT: For compound units like meter/second, you must separate the numerator and
denominator into separate units in the list. For example:
- For meter/second: use ["meter", "1/second"]
- For newton*meter: use ["newton", "meter"]
- For kilogram*meter²/second²: use ["kilogram", "meter**2", "1/second**2"]
Example:
# Convert speed of light to kilometers per hour
expr_key = introduce_expression("speed_of_light")
result = convert_to_units(expr_key, ["kilometer", "1/hour"])
# Returns approximately 1.08e9 kilometer/hour
# Convert gravitational constant to CGS units
expr_key = introduce_expression("gravitational_constant")
result = convert_to_units(expr_key, ["centimeter**3", "1/gram", "1/second**2"], UnitSystem.CGS)
SI prefixes (femto, pico, nano, micro, milli, centi, deci, deca, hecto, kilo, mega, giga, tera)
can be used directly with base units.
Returns:
A key for the converted expression, or an error message.