Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Energy electron volt #273

Merged
merged 5 commits into from
Jul 12, 2017
Merged

Conversation

cquiroz
Copy link
Collaborator

@cquiroz cquiroz commented Jun 23, 2017

I noted that we are missing the very important Electron-Volt unit for energy. This PR adds them

I'll probably add the other uses of eV for Mass, Momentum, Distance and Temperature

Do you think I should add a UnitGroup for these?

@derekmorr
Copy link
Collaborator

We can't add a unit group for them since they're different Dimensions.

@cquiroz
Copy link
Collaborator Author

cquiroz commented Jun 23, 2017

@derekmorr Wouldn't e.g. eV, keV, MeV belong to the same group?

@derekmorr
Copy link
Collaborator

Oh, sorry. I misunderstood. I thought you meant adding units for Mass, Momentum, etc into a unit group.

I agree that naming will be an issue.

lazy val TeV = TeraElectronVolt(1)
lazy val PeV = PetaElectronVolt(1)
lazy val EeV = ExaElectronVolt(1)
lazy val evMultiplier: Double = 1.60217656535e-19
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be moved into the ElectronVolt object so we don't leak a constant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's probably a good idea

@cquiroz cquiroz force-pushed the energy-electron-volt branch 2 times, most recently from 05628d4 to a48f924 Compare June 28, 2017 22:22
@derekmorr
Copy link
Collaborator

This LGTM. Did we decide on how to handle naming issues?

@cquiroz
Copy link
Collaborator Author

cquiroz commented Jul 8, 2017

No decision yet, but I think it will be a problem to have the same unit name. I'm leaning to use ElectronVolt only for Energy and add a prefix in the other cases like ElectronVoltMass, ElectronVoltTemperature, etc

WDYT?

@@ -187,6 +198,46 @@ object Ergs extends EnergyUnit {
val symbol = "erg"
}

object ElectronVolt extends EnergyUnit {
val conversionFactor = Joules.conversionFactor * 1.60217656535e-19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conversion factor is wrong. The factor is defined as 1.602176565(35)x10e-19. The digits in the parentheses do not represent additional precision, however. Instead, that notation - known as uncertainty notation - represents the standard deviation of the last two digits in the value. It means it is ~65% likely that the conversion factor is actually 1.602176565e-19 +/- 0.000000035e-19, or ~95% likely that it is 1.602176565e-19 +/- 2*0.000000035e-19

The best factor for our purposes is 1.602176565e-19.

Perhaps in a future enhancement, we can account for this uncertainty somehow.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for poiting this up, I'll update this and the constants PR that uses the same bad logic

Copy link
Contributor

@garyKeorkunian garyKeorkunian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my previous comment on the conversion factor.

Copy link
Contributor

@garyKeorkunian garyKeorkunian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cquiroz
Copy link
Collaborator Author

cquiroz commented Jul 11, 2017

Seems I could merge this. I'll wait a bit to let others chime in if needed

@derekmorr derekmorr merged commit 4c71dbf into typelevel:master Jul 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants