예제 #1
0
 def testReadSingleFile(self):
     """
     Test the correct interpretation of physical constants
     as definied in FMF version 1.1.
     """
     consts = FMFLoader.readSingleFile(
         self.FMFinput, "testReadSingleFile")[0].attributes[
         'Mathematical and Physical Constants'
         ]
     self.assertEqual(
         consts[u'Speed of light'][1], str2unit("1 c", FMFversion="1.1")
         )
     self.assertEqual(
         consts[u'Permeability of vacuum'][1],
         str2unit("1 mu0", FMFversion="1.1"),
         'The values differ by %s.' % (
             consts[u'Permeability of vacuum'][1] -\
             str2unit("1 mu0", FMFversion="1.1"),
             )
         )
     self.assertEqual(
         consts[u'Permittivity of vacuum'][1],
         str2unit("1 eps0", FMFversion="1.1")
         )
     self.assertEqual(
         consts[u'Gravitational constant'][1],
         str2unit("1 G", FMFversion="1.1")
         )
     self.assertEqual(
         consts[u'Planck constant'][1],
         str2unit("1 h", FMFversion="1.1")
         )
     self.assertEqual(
         consts[u'Planck constant / 2pi'][1],
         str2unit("1 hbar", FMFversion="1.1")
         )
     self.assertEqual(
         consts[u'Elementary charge'][1], str2unit("1 e",FMFversion="1.1"),
         'The elements %s and %s do not match.' % (
             consts[u'Elementary charge'][1],
             str2unit("1 e", FMFversion="1.1")
             )
         )
     self.assertEqual(
         consts[u'Electron mass'][1], str2unit("1 me", FMFversion="1.1")
         )
     self.assertEqual(
         consts[u'Proton mass'][1], str2unit("1 mp", FMFversion="1.1")
         )
     self.assertEqual(
         consts[u'Avogadro number'][1], str2unit("1 NA", FMFversion="1.1")
         )
     self.assertEqual(
         consts[u'Boltzmann constant'][1], str2unit("1 k",FMFversion="1.1")
         )
     self.assertEqual(
         consts[u'Rydberg constant'][1], str2unit("1 Ryd", FMFversion="1.1")
         )
     consts = FMFLoader.readSingleFile(
         self.FMFinput, "testReadSingleFile")[0].attributes[
         'Additional constants changed from FMF version 1.0 to 1.1'
         ]
     self.assertEqual(
         consts[u'Parsec'][1], str2unit("1 pc", FMFversion="1.1")
         )
     self.assertEqual(
         consts[u'US gallon'][1], str2unit("1 galUS", FMFversion="1.1")
         )
     self.assertEqual(
         consts[u'Atomic mass units'][1], str2unit("1 u", FMFversion="1.1")
         )
예제 #2
0
 def testReadSingleFile(self):
     """
     Test the correct interpretation of physical constants
     as definied in FMF version 1.0.
     """
     consts = FMFLoader.readSingleFile(
         self.FMFinput,
         "testReadSingleFile")[0].attributes[
         'Mathematical and Physical Constants'
         ]
     self.assertEqual(
         consts[u'Speed of light'][1], str2unit("1 c", FMFversion="1.0")
         )
     self.assertEqual(consts[u'Speed of light'][1], str2unit("1 c"))
     self.assertEqual(
         consts[u'Permeability of vacuum'][1],
         str2unit("1 mu0", FMFversion="1.0")
         )
     self.assertEqual(
         consts[u'Permittivity of vacuum'][1],
         str2unit("1 eps0", FMFversion="1.0")
         )
     self.assertEqual(
         consts[u'Gravitational constant'][1],
         str2unit("1 Grav", FMFversion="1.0")
         )
     self.assertTrue(
         consts[u'Planck constant'][1],
         str2unit("1 hplanck", FMFversion="1.0")
         )
     self.almostEqual(
         consts[u'Planck constant / 2pi'][1],
         str2unit("1 hbar", FMFversion="1.0")
         )
     self.almostEqual(
         consts[u'Elementary charge'][1],
         str2unit("1 e", FMFversion="1.0")
         )
     self.assertNotEqual(
         consts[u'Elementary charge'][1], str2unit("1 e"),
         "Elementary charge has been adapted to new CODATA recommendations."
         )
     self.assertEqual(
         consts[u'Electron mass'][1], str2unit("1 me", FMFversion="1.0")
         )
     self.assertNotEqual(
         consts[u'Electron mass'][1], str2unit("1 me"),
         "Electron mass has been adapted to new CODATA recommendations."
         )
     self.assertEqual(
         consts[u'Proton mass'][1], str2unit("1 mp", FMFversion="1.0")
         )
     self.assertNotEqual(
         consts[u'Proton mass'][1], str2unit("1 mp"),
         "Proton mass has been adapted to new CODATA recommendations."
         )
     self.assertEqual(
         consts[u'Avogadro number'][1], str2unit("1 Nav", FMFversion="1.0")
         )
     self.assertEqual(
         consts[u'Boltzmann constant'][1], str2unit("1 k", FMFversion="1.0")
         )
     consts = FMFLoader.readSingleFile(
         self.FMFinput,
         "testReadSingleFile")[0].attributes[
         'Additional constants changed from FMF version 1.0 to 1.1'
         ]
     self.almostEqual(
         consts[u'Parsec'][1], str2unit("1 pc", FMFversion="1.0")
         )
     self.almostEqual(
         consts[u'US gallon'][1], str2unit("1 galUS", FMFversion="1.0")
         )
     self.assertEqual(
         consts[u'Atomic mass units'][1],
         str2unit("1 amu", FMFversion="1.0")
         )