Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#4418 closed Bugs (invalid)

units::electron_charge units::current incorrect

Reported by: mejames7760.atatatat.att.net Owned by: Matthias Schabel
Milestone: Boost 1.44.0 Component: units
Version: Boost 1.40.0 Severity: Problem
Keywords: units charge current Cc:

Description

I was trying to implement http://hyperphysics.phy-astr.gsu.edu (Coulomb's Law example) and then determine the acceleration on a single charge "e" as a way of learning to use Boost::units. I was having lots of errors with wrong units which I have finally traced to incorrect dimensions of electric_charge and current. Please refer to the above link or any physics text book to verify the following.

  1. An "electron charge" is the base unit, you have "current" as a base unit.
  2. "current" is charge per time which is a derived unit which is measured in amps.
  3. "electron charge" is measured in number of electrons. A coulomb is the measure of the number of electrons and is 1/e.
  4. "electric_charge" is an okay term to use.
  5. If you swapped electric_charge <-> current you would still be wrong because current would then have charge*time instead of charge/time.

Running Ubuntu 10.04 LTS with Boost 1.40.0

Change History (8)

comment:1 by Steven Watanabe, 12 years ago

Component: Noneunits
Owner: set to Matthias Schabel

According to http://www.bipm.org/en/si/base_units/, the correct base unit is Amperes (current). Anyway, the exact base units should not make a difference. Can you provide the failing code? Also, the link you posted doesn't work. It shows a default Apache page with no useful content.

comment:2 by mejames7760.atatatat.att.net, 12 years ago

I have a tar file to send you but it exceeds the 256k limits. I spent the day changing units to work the way that I think that it should work. The tgz file as the modified units.tgz plus the test project. Please send me an email based my "reported by name" or download from "http://www.mj3.biz/church/unitsTestCase.tgz"

I have to admit that this is confusing. And multiple places have conflicting information. However I think that having base units as defined at http://en.wikipedia.org/wiki/SI_base_unit (which has ampere as a base unit) and doing dimensional analysis as defined at http://en.wikipedia.org/wiki/Dimensional_analysis (which has charge as the base dimension)are two different but related things. And what boost:units tries to do is connect them in a way that a computer can understand.

Your reference above is to base units not base dimensions.

The problem is the way that dimensions were defined. Current and charge are not the same thing. I was trying to work a charge problem with no reference to time. So I couldn't create Coulomb's Constant with the right dimensions. With the modified boost::units it works perfectly.

Thanks.

comment:3 by mejames7760.atatatat.att.net, 12 years ago

Just noticed that the program still has a problem which I need to work out the compensating time units are still required.

comment:4 by anonymous, 12 years ago

Program is okay. The definition of Coulomb's Constant is (Newton *Meters2)/Coulombs2. Which comes out to length3,mass1,time-2,charge-2. I had forgotten that Newton has a Time-2.

comment:5 by Steven Watanabe, 12 years ago

First of all, the dimensions chosen as base dimensions don't matter except when you want to use make_dimension_list directly. The only thing that matters is the relationships between dimensions.

The commented out code is wrong because it treats current as though it were electric charge. The correct definition is

typedef make_dimension_list<
    boost::mpl::list< dim< length_base_dimension,static_rational<3> >,
                      dim< mass_base_dimension,static_rational<1> >,
                      dim< time_base_dimension,static_rational<-4> >,
                      dim< current_base_dimension,static_rational<-2> > >
                      >::type    coulomb_constant_dimension;

an alternate definition which is somewhat easier to understand is

typedef mpl::times<
    force_dimension,
    static_power<length_dimension, static_rational<2> >::type,
    static_power<electric_charge_dimension, static_rational<-2> >::type
>::type coulomb_constant_dimension;

P.S. all I needed to see was main.cpp, which easily fits within trac's limits.

comment:6 by Steven Watanabe, 12 years ago

Resolution: invalid
Status: newclosed

comment:7 by mejames7760.atatatat.att.net, 12 years ago

We are having some sort of cross communication. Current IS electric charge per time which makes it a derived unit! Please go talk to someone.

Yes, I agree that your changes above functionally work but only by masking that there are time2 dimensions that shouldn't be.

You got the extra so you would have all the changes to make charge the base dimension.

in reply to:  7 comment:8 by Steven Watanabe, 12 years ago

Replying to mejames7760.atatatat.att.net:

We are having some sort of cross communication. Current IS electric charge per time which makes it a derived unit! Please go talk to someone.

Alternately, electric charge IS current times time, which makes it a derived unit. The base dimensions are totally arbitrary as long as they form a basis. energy, force, potential difference, and acceleration would work just as well as mass, length, time, and charge (although they would be awkward to use).

This isn't going to change, sorry. We've chosen to match the SI base units. If you don't like dealing with current, create your new dimensions by combining existing derived dimensions, as I showed.

Note: See TracTickets for help on using tickets.