
Dear users, I just started to use boost::units for some simulations. However, I have some problems with unit conversions and I hope someone can help me. Let's say I have a quantity given in terms of energy in "electron volts" (eV) with the unit "energy". I defined the unit the following: BOOST_UNITS_DEFINE_BASE_UNIT_WITH_CONVERSIONS(si, electron_volts, "electron volts", "eV", PHYSICAL_CONSTANT_DVALUE(e), si::energy, 5000); namespace si { typedef make_system<electron_volts_base_unit>::type electron_volt_system; typedef unit<energy_dimension,si::electron_volt_system> electron_volt_type; BOOST_UNITS_STATIC_CONSTANT(eV,electron_volt_type); } where PHYSICAL_CONSTANT_DVALUE(e) gives me the double representation of si::constants::codata::e.value(). This works fine, for conversions like eV=>Joule etc. (By the way, is there a more straight forward way, to define non-rational scaled units, than defining a new unit sytem?) Now I want to convert eV to nanometers (wavelength) This is defined as: wavelength = c/frequency = h*c/energy (c=speed of light, h = Planck's constant) I would again define a system with the base unit of wavelength and the unit wavelength_type initialized e.g. with wavelength_nanometer. First Problem: What would be the derived dimension/unit: energy, length or a new dimension like wavelength_dimenson? If I would define it as something else than energy, I will have problems when using quantity<si::electron_volt_type>(x*si::wavelength_nanometer) or quantity<si::nanometer_type>(x*si::eV) Second problem: The relationship is reciprocal: wavelength ~ 1/energy. How do I define a proper conversion? Thanks for your help! Cheers, Matthias