c3 icon indicating copy to clipboard operation
c3 copied to clipboard

Misleading Quantity units with pi

Open GlaserN opened this issue 4 years ago • 3 comments

Is your feature request related to a problem? Please describe. Inputing a number in radian values needs the unit specifier "Hz" But inputing a unit in Hz values needs the unit specifier "Hz 2pi" This is rather counter intuitive and should be changed.

However if you currently use the unit Hz 2pi the input value will be multiplied by 2pi converting from Hz to rad. But it would be more intuitive the other way around to insert a value in Hz with the unit Hz and then transform this value to a radian value, if necessary, e.g. creating the Hamiltonian.

Describe the solution you'd like Do not transform input value of quantity if 2pi is in the quantity name. Objects which need a value in radians (e.g. creation of the hamiltonian) should be able to request a value that is in radians and includes a scaling factor dependend on the given unit

Describe alternatives you've considered Transform an initalized Hz unit to a Hz 2Pi while changing the unit specifier, as well as the value.

Additional context

GlaserN avatar Jan 28 '21 16:01 GlaserN

An additional problem with the current implementation is that a modification by get_value and set_value is not straightvorward:

v = Qty(3, unit="Hz 2pi")
v.set_value(v.get_value())

leads to an out of bounds error

GlaserN avatar Jan 28 '21 16:01 GlaserN

Maybe "Hz" and "rad/s" ? Cumbersome, but clear.

On Thu, 28 Jan 2021, 18:37 Niklas Glaser, [email protected] wrote:

An additional problem with the current implementation is that a modification by get_value and set_value is not straightvorward:

v = Qty(3, unit="Hz 2pi") v.set_value(v.get_value())

leads to an out of bounds error

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/q-optimize/c3/issues/26#issuecomment-769211454, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH3Q4K3KXUJQ7IDCDFJLY3S4GHD3ANCNFSM4WXLG4QQ .

shaimach avatar Jan 28 '21 16:01 shaimach

The main point is what should be the unit that invokes the following transformation:

https://github.com/q-optimize/c3/blob/ef9533008dccbcb23810e1e7396f85b5f200da15/c3/c3objs.py#L74-L79

GlaserN avatar Jan 29 '21 10:01 GlaserN