Year: 2011

  • The science of the general

    This is a draft of an upcoming comment hopefully to be published in Chemical Technology. Feel free to shoot with some comments, even if you’re not a chemical engineer.

    Chemical Engineering as a discipline by that name has been taught at universities since 1888. At this time it was seen as a small side-branch of Mechanical Engineering incorporating applied industrial chemistry, mainly serving the emerging chemical industries of the time. The curricula of these early courses would become more recognisable to modern Chemical Engineers when AD Little formalised the concept of unit operations in 1915, while the concept of material and energy balances had gained traction by 1935. Thermodynamics and process control had appeared by 1945, followed by chemical kinetics and process design by 1955 (see Origins of Chemical Engineering for a complete timeline). Henri Poincaré said “There is no science but the science of the general”, and one sees this instinct for generalisation at work as fundamental knowledge and general analysis supplanted a curriculum filled with specific examples from industry.

    During roughly the same time, computing devices were progressing from simple adding machines to fully programmable computers. Although computers had been used for process control on chemical plants since the late 1950s, the first personal computer was only released in 1974 and Chemical Engineering simulation software for the PC was released in 1981. In a recent Nature interview with Neil Turok from the African Institute for Mathematical Sciences, I was struck by his description of their curriculum design process. They had initially developed a “conventional syllabus involving math and physics”, but realised there wasn’t enough time to teach it. They then made a key observation: “… if you took a photograph of a scientist at work today, everyone looks the same … sitting at a computer and trying to make sense of what’s on the screen.” I think one could confidently replace scientist with engineer in that observation.

    The funny thing is that computers are often seen as a means to an end, something that can remain opaque to our understanding as long as the programs we use work. Although the same approach could arguably be applied to much of the equipment on our plants, we still teach Thermodynamics, Calculus and other subjects that are frequently described as not being used in the workplace. We do this because these subjects lead to a more fundamental, more general understanding of our plants. There is far greater likelihood of a particular Chemical Engineer using a computer in his day than any particular unit operation, but it is not common for us to teach the equivalent fundamentals behind computing as applied to the problems of Chemical Engineering. Instead, we focus on manual solution of sets of equations using methods that have very little in common with the computer techniques used by process simulators. A friend of mine summed it up well: “We’re teaching as though it were still the 70s, as though there is a reasonable chance of having to solve a problem on site without the benefit of a computer”.

    Perhaps a part of the problem lies in the demarcation of domains. The fact that computer science is a discipline in itself, or that there may be an electronic or computer engineering department in the same school as our Chemical Engineering departments may lead us to focus on the “real Chemical Engineering”, but the existence of an industrial chemistry course or a mechanical engineering course did not stop our predecessors from carving out the niche that would become Chemical Engineering. We would do well to remember that most of the simulators we use today were developed by Chemical Engineers rather than generic software houses.

    Another argument is that the principles don’t change much from manual calculation to computer implementation. However, the methods of solution and the fundamentals of computing have made such great strides in the last 100 years that understanding how to solve a set of mass balance equations by hand does not really enable one to reason about the algorithm being employed by a simulator. Not only that, but the algorithms and software that are available today enable the solution of whole different class of problems.

    We need to move beyond the simple treatment of computers as tools to solve our problems and appreciate that there is a general science underpinning their operation. As much as understanding Reaction Kinetics or Thermodynamics enables us to understand the design and
    failure modes of reactors, understanding the computational structure of our simulators, optimisation solvers and spreadsheets can help us to understand how to employ these new information unit operations more effectively. It may also enable us to develop the
    next set of tools for ourselves.

  • China childbirth stats analysed

    I read this infographic today about China’s one-child policy. One of the things that jumped out at me is that China has more men than women in their population, and the infographic (at the bottom right) mentions that some feel the policy makes this worse, along with infanticide and preferential abortion. So, I wanted to know how big the effect of the policy is and I did some stats.

    The infographic explains the process as follows:

    • As it is traditionally enforced, couples are encouraged to have only one child
    • If that child is a girl, parents would be allowed to have a second child to hopefully bear a son
    • After the second child, the would be discouraged from having a second child.

    Now, assuming that this is exactly enforced as written, there are only three outcomes of parents having children (let’s assume the chance of a birth resulting in a boy is x and ignore things like multiple births etc):

    Children Boys Girls Probability
    1 1 0 x
    2 1 1 (1-x)x
    2 0 2 (1-x)(1-x)

    Now, we can calculate the expected number of children, assuming everyone wants children and follows this process, this is simply 1 child with probability x and 2 with probability (1-x), so expected value is 1x + 2(1-x)=2-x. x is typically near 0.5, and they say that the fertility is near 1.5. Success! But what about the expected ratio of boys to girls?

    Using the table above, multiplying the “boys” column by the “probability” column and sum ming, we end up with 1x – (1-x)x=2xx2=x(2-x) boys expected. For girls, it’s 1(1-x)x + 2(1-x)(1-x)=(2-x)(1-x). If x is 0.5, this ends up with 0.75 boys and 0.75 girls. That doesn’t explain what we observe in China… In terms of the ratio of boys to girls, we see that the (2-x) term is common to both expected values, so the ratio ends up being x/(1-x). But this is exactly the same ratio that we would expect if no birthing policy is in place, as every birth would produce x boys and (1-x) girls on average. So, either these assumptions don’t hold, or we need to look elsewhere for the discrepancy.

  • MTU troubles with iBurst sorted

    When we moved into the new house, we went to Telkom to get our ADSL connected. They insisted it would take several weeks and they had to have physical access to the property, even though the previous owners had only cancelled their account two weeks before we moved in. This caused us to storm out of the Telkom offices, vowing never to darken their doorsteps again and get iBurst instead. The sign-up process was efficient and I left the store 20 minutes later with their desktop modem and an antenna in case our reception wasn’t so good.

    Installation was a breeze, and minutes later I was connected. However, the connection seemed erratic, with some sites loading faster than others and some strange freezing from time to time, even thought the iBurst speed tester reported really good speeds. I phoned support and they cleared it up for me: set the MTU to 1392 they said. No problem. Setting the MTU down made things work really well, but there was a slight snag. I had connected the iBurst device to our Time Capsule to access it wirelessly. Unfortunately, the Time Capsule is not capable of much in terms of routing. In router-speak, it is basically a bridge. The iBurst device is also a bridge, so the computer had to do the PPPoE dialing and the setting of the MTU. Things appeared fine until we tried to connect with our iPhones, which have no way of setting the MTU. So I fired up our little Netgear router and set it to do the PPPoE and the MTU, then chained the Time Capsule from that. Still no joy – turns out the Netgear WGR614 has a known issue with handling the MTU (we would later find out it wasn’t the Netgear’s fault as such, but read on).
    For a long time (probably too long), we used the iBurst on our laptops, but had to use the data connections on our phones in our own house. Not good. When my father gave me a good price on his old iPad, with no 3G, it became really clear we had to do something. A friend at work suggested the MikroTik 750g as a really capable unit with lots of customisability. Some research showed that MikroTik has a huge community and that RouterOS surely had what I needed to get the problem sorted out.
    Of course, with great power and flexibility comes great confusion to novice users, so it took me a couple of hours and several phone calls to friends to get the whole thing sorted out, but heres the lowdown:
    My top tip is to do all the configuration up to step 3 before unplugging your working internet connection. The configuration can all be done with the box directly connected to a laptop and you don’t need to have it connected to the iBurst device during config.
    Step 1: Update the firmware on the MikroTik – pretty simple, and allows much more to be done via the web interface. The web interface also has a copy of WinBox, which enables a vast array of configuration options.
    Step 2: Configure PPPoE dialout. Go to PPP on the left hand menu in WinBox or Webfig, then do “Add new”/”PPPoE client” and configure the username and password. Also check the “Add default route” and “Use Peer DNS” options. You can set the MTU to 1392 here, but this is not all you need to do – keep reading. I recommend using the first ethernet connection for this, this is what they assume you’ll do anyway.
    Step 3: Add a mangling rule to force lower MTU. Go to /IP/Firewall/Mangle – the PPPoE client setup should have added two rules to change the MSS. You’ll notice you can’t edit them, but copy the outgoing one and change the “New TCP MSS” to “clamp to pmtu”. Also make sure this new rule is above the old one in the rule table (you can drag them around to re-order them).
    Step 4: Plug it in and check that everything works. You can use WinBox to check that the PPPoE is working and that the mangling rule for clamping is getting the traffic before the other one. That’s it. Hopefully this will save other people the hassle I had to go through.
  • Advertising statistics

    I saw an ad on TV yesterday that made me think about statistics. It featured a shot of three women, with voice over saying “1 in three women develop disease X” (can’t remember what it was). The implication, of course, is that one of the three women shown in the picture will develop disease X. You’re supposed to be thinking “which one will it be”. This is vaguely reminiscent of my first class at university where a lecturer told us to look left and right – one out of three people pass the course, so work hard to make that person be you. As it happens, all three of us (myself and both of the people next to me) ended up passing.

    The stats work out as follows. Let’s say we have probability p of contracting the disease and that p=1/N. We are shown N people. The probability of no-one contracting the disease is (1-p)N. For the 3 person scenario, that means that there is about a 30% chance that they’re all fine. Of course, that means that there’s a 70% chance that at least one of them will contract the disease, but that’s not quite what they had in mind when they chose to show us three women. If they had chosen N=7 (I think that’s for breast-cancer), there would be a 34% chance that everyone was fine.

    Even more interesting is that the probability of everyone being fine converges to 1/e (about 37%) as N goes to infinity. Perhaps when I figure out a fast way to get nicely rendered equations and plots into this blog I’ll go into more detail.

  • Moving your personal info to Google from Mac

    In my previous post I ended off frustrated because I couldn’t see my calendars on my iPhone. This post is to serve as a nice step-by-step set of instructions to move your personal information from the Mac to Google’s servers.

    I assume when we start that you have a Gmail account, but have all your contacts and calendars on the Mac.
    1. Sync contacts from Mac to Google
    This part is easy. From Address Book Preferences, go to “Accounts” and check the “Sync with Google” checkbox. Click “Configure” to enter your Gmail username and password. Done.
    2. Get your calendars on to Google Calendars
    This part is easy but tedious. In iCal, select each of your calendars and go to “File|Export|Export” and save them somewhere. Now, go to Google calendar and create a corresponding calendar for each of your calendars. Then, import each of the files you created before into each of the calendars you have created. This is far more tedious than it should be, but when you’re done you’ve got all your calendars mirrored on the Google servers.
    3. Get the Google Calendars back on iCal
    From iCal Preferences, go to the Accounts tab and add an account. Select “Google” and enter all your info. Close the preferences box. You will notice a new calendar showing up on the left hand pane in iCal. Open the Preferences again and move to the “Delegation”, which should now reload to show all your calendars. Select them all and you should see a rather awkward nested structure appear and sync.
    4. Get all this on the iPhone
    To get the calendars and contacts synced on the iPhone, go to “Settings|Mail, Contacts, Calendar|Add Account” and select Microsoft Exchange. Enter the Google login details and when a new “Server” field appears, enter “m.google.com”. You will now only see your primary calendar on the iPhone. Now, go to “m.google.com” from your phone’s browser. Once you’ve logged in, select the “Sync” icon and then select all the calendars you want to have appear. Now, you should see all these calendars in the calendar app.
    I must say that I would have far preferred to have the Google calendars transparently synced with my iCal calendars in a similar fashion to the contacts, but at least this works. Also, the groups I had defined in my Address book, which used to sync well with the iPhone have now disappeared. The fight continues, but after many hours, I now have nicely synced contacts and calendars.