When a Watt is not a Watt

The Watt is the unit of power. What most people don’t know is that there are two different kinds of Watt, the Watt-SI and the Watt-90. The units are very close to each other, but they are not the same. This post tells you the story of the two Watts.

In our system of units, the SI, seven base units are defined: the meter, the kilogram, the second, the Ampere, the Kelvin, the mole and the Candela. Mechanical power can easily be expressed in these base units:

.

In electrical units the Watt can be written as:

The above equation can, in fact, be used to define the SI Volt. But, there is one caveat. The SI-Ampere is notoriously difficult to realize. To see why, just read the definition:

The ampere is that constant current which, if maintained in two straight parallel conductors of infinite length, of negligible circular cross-section, and placed 1 meter apart in vacuum, would produce between these conductors a force equal to 2x 10 −7 newton per meter of length.

Obviously this definition calls for a mechanical device, like a balance, to realize the ampere. This is not a very desirable situation. To realize the ampere, one needs precise electrical measurement equipment and precision mechanics.

Fortunately two discoveries, made in the last century, provide a way out of this dilemma. The effects are the Josephson Effect and the integral quantum hall effect. In this short blog post, I can’t do justice to the intricacies of both effects (I may other posts on it), but I give the elevator pitch.

The Josephson effect appears in a three layer sandwich of an superconductor/insulator/superconductor. In the metrological application, a current is passed through this layer structure while it is irradiated with microwave frequencies. A quantum mechanical effect produces a potential difference between the two superconducting layers. The potential difference is exactly

, with

where f is the microwave frequency, h Planck’s constant and e the elementary charge. The ratio is called the Josephson constant.

The quantum Hall effect requires an electron gas that is constrained to one layer, i.e. two dimensions. In this paradigm the hall effect, i.e. the potential perpendicular to a current and a magnetic field is quantized. The ratio of potential difference to current, i.e. resistance
is a multiple of
.
The constant is called the von Klitzing constant.

With these two effects the Ohm and the Volt can be realized. However for the realization of the Ohm and the Volt in the SI the current values of the fundamental constants, h and e must be used. The current values can be found .

The values of the fundamental constant change every couple of years with the so-called adjustment, which is performed by the CODATA task group. For calibration purposes it is impractical to change the realization every four years. Hence in 1990 the conventional values of and , where established:

GHz/V
Ohm

With these constants the Ohm-90 and the V-90 can be realized. The ratio o the conventional (or 90) units to the SI units are given by

and

Using the above equations the ratio of conventional Watts to SI Watts can be calculated:

Using the current values of the fundamental constant we can express the SI units in conventional units:







This is, in short, the story of the two Watt. Presently both Watts differ by about 0.1 part per million (ppm).

Python line style generator for gnuplot

Python line style generator for gnuplot

Every once and a while, I need to plot data that depends on two variables. This task can be accomplished with a 3 dimensional plot. However, it is very hard to make a good three dimensional plot if the data set is not sampled regularly. Another option is to plot the data with respect to one dimension and to encode the values in the other dimension using the color of the data points.
I like to use intuitive color schemes, like heat maps, to indicate going from a small value to a large value. This is tedious to accomplish in gnuplot. The short python script below creates N
different lines styles in a heat map color scheme. Just run “rgb.py 13 7 > lines.gpl” to generate a file lines.gpl that can be imported into a gnuplot script. In this case 13 different line styles will be generated.

import sys

def red(x):
    if x<2.0/6.0:   return 0.0
    if x>=2.0/6.0 and x<= 4.0/6.0: return (x-2.0/6.0)*3.0
    if x>4.0/6.0:   return 1.0

def green(x):
    if x<=2.0/6.0: return x*3.0
    if x>2.0/6.0 and x<4.0/6.0: return 1.0
    if x>=4.0/6.0: return (1.0-x)*3.0

def blue(x):
    if x<2.0/6.0: return 1.0
    if x>=2.0/6.0 and x<=4.0/6.0: return (4.0/6.0-x)*3.0
    if x>4.0/6.0:  return 0.0

def myhex(i):
    h=hex(i)
    if len(h[2:])==1: h="0"+h[2:]
    else: h=h[2:]
    return h

N=0
ssymb=7
if (len(sys.argv)>1 ):
    N=int(sys.argv[1])
if (len(sys.argv)>2 ):
    ssymb=int(sys.argv[2])
if (len(sys.argv)==1 ):
    print "rgb NNN [SYMB]"
    print "NNN gives the number of different linestyles"
    print "nr of the gnuplot symbol, 0 = use different symbols"

symbols=(4,5,6,7,8,9,10,11,12,13,14,15,16)
x=range(N)
for i in x:
    f=i*1.0/(N-1)
    r=myhex(int(round(255*red(f))))
    g=myhex(int(round(255*green(f))))
    b=myhex(int(round(255*blue(f))))
    if ssymb==0:
        symb=symbols[i%len(symbols)]
    else:
        symb=ssymb
    a="set style lines {0} pt {1} lc rgb \"#{2}{3}{4}\"".format(i+1,symb,r,b,g)
    print a

The figure below shows the 13 different line styles.

The plot was generated with this short script.

load "lines.gpl"
set output "test.eps"
set term post color eps enhanced
set samples 60
unset key
dx=0.2
off=-1
set style function p
pi=atan2(0,-1)
pl [-pi:pi] sin(x)+off+ 1.0*dx ls  1,\
sin(x)+off+ 2.0*dx ls  2,\
sin(x)+off+ 3.0*dx ls  3,\
sin(x)+off+ 4.0*dx ls  4,\
sin(x)+off+ 5.0*dx ls  5,\
sin(x)+off+ 6.0*dx ls  6,\
sin(x)+off+ 7.0*dx ls  7,\
sin(x)+off+ 8.0*dx ls  8,\
sin(x)+off+ 9.0*dx ls  9,\
sin(x)+off+10.0*dx ls  10,\
sin(x)+off+11.0*dx ls  11,\
sin(x)+off+12.0*dx ls  12,\
sin(x)+off+13.0*dx ls  13

Python Analog Meter Project

Analog Meter in SVG File with python

The motivation for this fun little project was that I wanted to share the state of our experiment with my colleagues. The idea was to put a .svg file in a html file that everybody can see. The state of the experiment is best given by the uncertainty that we assign to its result. The absolute best number the experiment has ever produced has a relative uncertainty of 36×10-9. If the experiment is not running the uncertainty is 100%. Hence the analog display should go from 10-1 to 10-9.

I made the above template (rightclick to download) of the meter with Inkscape. I used a spreadsheet to calculate the positions of the divisions. The meter spans 140 degrees and 9 decades. One decade is a bit more than 15.5 degrees. In each decade thinner lines mark the positions 2,5, and 8. The purple indicator was added in Inkscape, too. By right clicking on the indicator, an ID can be assigned to this object, here appropriately “Indicator”.

The python script, shown below, parses the svg file using the minidom module (svg is a xml file). The program iterates over all attributes “id” until it finds “Indicator”. Once the indicator is found the program will replace the coordinates of the indicator to reflect the value that one wants to display. A new file w.svg will be written to disk. This file will be displayed in a html file.

Here is the source code of the python code that takes the new value as a command line argument:

import sys
import math
from xml.dom.minidom import parse, parseString

def generateW(newunc):
    dom1=parse("Wattmeter.svg")
    child=dom1.childNodes[1]
    for subelement in child.getElementsByTagName("path"):
        if subelement.hasAttribute("id"):
            if subelement.getAttribute("id")=="Indicator":
                myelem=subelement
    x0=215
    y0=-170
    ln=900      # length of the pointer
    bln=-120    # length of the backside (counterweight)
    ang0=62.22*math.pi/180
    dang=140.0/9*math.pi/180
    an=ang0+math.log10(unc/0.1)*dang
    newa="M {0} {1} {2} {3} ".format(x0+bln*math.cos(an),
        y0-bln*math.sin(an),x0+ln*math.cos(an),y0-ln*math.sin(an))
    myelem.setAttribute("d",newa)
    f=open("W.svg",'w')
    dom1.writexml(f)
    f.close()

	unc=1e-4
if (len(sys.argv)>1 ):
    unc=float(sys.argv[1])
if unc<5e-10: unc=5e-10
if unc>0.2: unc=0.2
generateW(unc)
print "Set uncertainty to {0}".format(unc)

Have fun with the script and the svg file.

Hello world!

I converted my home page to wordpress. I like the new layout better and it is easier to edit the content. WordPress is obviously software to host blogs. I am not sure how much blogging I will do. However, I will keep this feature open, for now.