Boost C++ Libraries: Ticket #4418: units::electron_charge units::current incorrect https://svn.boost.org/trac10/ticket/4418 <p> I was trying to implement <a class="ext-link" href="http://hyperphysics.phy-astr.gsu.edu"><span class="icon">​</span>http://hyperphysics.phy-astr.gsu.edu</a> (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. </p> <ol><li>An "electron charge" is the base unit, you have "current" as a base unit. </li><li>"current" is charge per time which is a derived unit which is measured in amps. </li><li>"electron charge" is measured in number of electrons. A coulomb is the measure of the number of electrons and is 1/e. </li><li>"electric_charge" is an okay term to use. </li><li>If you swapped electric_charge &lt;-&gt; current you would still be wrong because current would then have charge*time instead of charge/time. </li></ol><p> Running Ubuntu 10.04 LTS with Boost 1.40.0 </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4418 Trac 1.4.3 Steven Watanabe Sat, 10 Jul 2010 03:25:15 GMT component changed; owner set https://svn.boost.org/trac10/ticket/4418#comment:1 https://svn.boost.org/trac10/ticket/4418#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Matthias Schabel</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">units</span> </li> </ul> <p> According to <a class="ext-link" href="http://www.bipm.org/en/si/base_units/"><span class="icon">​</span>http://www.bipm.org/en/si/base_units/</a>, 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. </p> Ticket mejames7760.atatatat.att.net Sat, 10 Jul 2010 20:25:39 GMT <link>https://svn.boost.org/trac10/ticket/4418#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4418#comment:2</guid> <description> <p> 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 "<a class="ext-link" href="http://www.mj3.biz/church/unitsTestCase.tgz"><span class="icon">​</span>http://www.mj3.biz/church/unitsTestCase.tgz</a>" </p> <p> I have to admit that this is confusing. And multiple places have conflicting information. However I think that having base units as defined at <a class="ext-link" href="http://en.wikipedia.org/wiki/SI_base_unit"><span class="icon">​</span>http://en.wikipedia.org/wiki/SI_base_unit</a> (which has ampere as a base unit) and doing dimensional analysis as defined at <a class="ext-link" href="http://en.wikipedia.org/wiki/Dimensional_analysis"><span class="icon">​</span>http://en.wikipedia.org/wiki/Dimensional_analysis</a> (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. </p> <p> Your reference above is to base units not base dimensions. </p> <p> 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. </p> <p> Thanks. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>mejames7760.atatatat.att.net</dc:creator> <pubDate>Sat, 10 Jul 2010 20:53:53 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4418#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4418#comment:3</guid> <description> <p> Just noticed that the program still has a problem which I need to work out the compensating time units are still required. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sat, 10 Jul 2010 21:03:13 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4418#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4418#comment:4</guid> <description> <p> Program is okay. The definition of Coulomb's Constant is (Newton *Meters<sup>2)/Coulombs</sup>2. Which comes out to length<sup>3,mass</sup>1,time<sup>-2,charge</sup>-2. I had forgotten that Newton has a Time<sup>-2. </sup></p> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Sun, 11 Jul 2010 00:00:27 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4418#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4418#comment:5</guid> <description> <p> 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. </p> <p> The commented out code is wrong because it treats current as though it were electric charge. The correct definition is </p> <pre class="wiki">typedef make_dimension_list&lt; boost::mpl::list&lt; dim&lt; length_base_dimension,static_rational&lt;3&gt; &gt;, dim&lt; mass_base_dimension,static_rational&lt;1&gt; &gt;, dim&lt; time_base_dimension,static_rational&lt;-4&gt; &gt;, dim&lt; current_base_dimension,static_rational&lt;-2&gt; &gt; &gt; &gt;::type coulomb_constant_dimension; </pre><p> an alternate definition which is somewhat easier to understand is </p> <pre class="wiki">typedef mpl::times&lt; force_dimension, static_power&lt;length_dimension, static_rational&lt;2&gt; &gt;::type, static_power&lt;electric_charge_dimension, static_rational&lt;-2&gt; &gt;::type &gt;::type coulomb_constant_dimension; </pre><p> P.S. all I needed to see was main.cpp, which easily fits within trac's limits. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Sun, 11 Jul 2010 00:14:21 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4418#comment:6 https://svn.boost.org/trac10/ticket/4418#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> Ticket mejames7760.atatatat.att.net Sun, 11 Jul 2010 04:04:17 GMT <link>https://svn.boost.org/trac10/ticket/4418#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4418#comment:7</guid> <description> <p> 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. </p> <p> Yes, I agree that your changes above functionally work but only by masking that there are time<sup>2</sup> dimensions that shouldn't be. </p> <p> You got the extra so you would have all the changes to make charge the base dimension. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Sun, 11 Jul 2010 14:20:01 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4418#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4418#comment:8</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/4418#comment:7" title="Comment 7">mejames7760.atatatat.att.net</a>: </p> <blockquote class="citation"> <p> 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. </p> </blockquote> <p> 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). </p> <p> 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. </p> </description> <category>Ticket</category> </item> </channel> </rss>