Any suggestions for implementing parametric unit conversions?

I have the following table of unit conversions for wave attenuation rates.

For example,

image

The unitless quantity (units of “1”) is known as the loss tangent.

In the spirit of Unitful.jl and/or DynamicQuantities.jl or other unit-handling implementations, what are your guys’ thoughts on how to best implement the above conversion equations?

Some implementation pointers:

  • I wasn’t sure how to implement a “new” unit named “wavelength” by symbol λ, not being “equal” to anything currently existing (re Unitful.@unit).

  • The conversion from e.g. dB/λ to Np/m involves the two components of conversion from dB to Np and from /λ to /m. My above “in the spirit of” refers to leveraging the fact that we can implement those two components individually, and hopefully the general implementation gets the conversion from dB/λ to Np/m for “free” by internally automatically knowing to call the two component implementations. (That was poorly worded, sorry.)

  • I assume handling the dimensionless attenuation rate (unit “1”) would be tricky.

Am I unable to extend on Unitful.jl and/or DynamicQuantities.jl?

1 Like