Friday, 31 July 2020

Building Cisco's Japan Development Center

Definitely the most interesting thing I did in my time at Cisco was to start an engineering team in Japan. How that came about is a story in itself.

My job at Cisco had nothing to do with Japan. I ran the router software group, IOS, which was a seriously full time job. It comprised about 500 people, mostly at the corporate HQ in San Jose, California, but plenty spread around the world including the UK, where I was initially hired, India, France, and several locations in the US. My move to the US coincided with a total, absolute hiring freeze after the crash of 2000. Senior management understood that we needed to grow the group, though, so every time some remote acquisition turned out to be surplus to requirements, we would acquire bits of the team. I had people in Colorado, North Carolina, up north in Sonoma County, and sundry individual contributors working from wherever they happened to have been hired.

Senior management was expected take on various odd tasks that had nothing to do with the day job. One such assignment that came my way was giving the opening keynote speech at the company's customer conference (Cisco Live) in Japan, in 2003.

Back in the 1980s, international standards work had taken me to Japan several times. During the 1990s my wife went there often for the same reason, and I would sometimes tag along. But this was my first visit since before I'd joined Cisco, in 1999. There were things I'd forgotten since my previous visit, like when the airport bus arrived at a hotel and the staff ran to meet it, then stood and bowed as it pulled away. You get used to this, but after a five year interval it surprised me again.

I was greeted very courteously by the head of marketing in Japan, who has since become a very good friend. It's assumed in Japan that foreigners will need their hands held at all times. It takes a lot to convince them that you can safely use the metro and railway system without getting lost. I think it would be a serious loss of face to mislay a visiting Vice President, so even if they believe you they are reluctant to let you try it. Consequently, I had been met at my hotel - the New Otani - and accompanied to the conference location.

I had a carefully prepared presentation - it had never occurred to me to ask for help or any kind of corporate guidance. But it was only in the hour before I gave it that I learned it was "the" keynote for the conference. I made a few hasty changes and it seemed to work OK. I spoke in English but there was simultaneous translation to Japanese. I asked the head translator, a very distinguished Japanese guy in his 50s, how fast I should speak. "About a quarter as fast as your CEO" was his answer. In fact it was very easy to pace myself. Every single person in the audience of hundreds was listening to the translation on headphones. There was enough sound leakage that I could tell when the translator had stopped, and start the next sentence.

That trip led to a couple more to meet Japanese customers, and that in turn led to a fairly surreal activity. We were trying to convince one of the big Japanese operators to switch to Cisco for their core network. Part of this was a technical collaboration around mobile networking for which I was the corporate sponsor. Every three months we would have a meeting, mostly in or around Tokyo though sometimes in the US, with half a dozen people from each side. Their technical team would present what they wanted to do, and how, and our technical team would respond. The two teams totally disagreed, but it didn't matter. At the end the customer's VP and I would both give little speeches saying how impressed we were with the spirit of cooperation and the progress that had been made. And then three months later we would have exactly the same meeting, with exactly the same presentations, and exactly the same speeches. We got some truly excellent Japanese meals out of it.

It was all worth it though. After several years of this, and long after I had left Cisco, we won the business, worth hundreds of millions of dollars.

You'll gather from this that I loved Japan - and still do - and was very happy to have good reasons to go there as often as possible. I got to know the country manager - now sadly no longer with us - quite well. Our only disagreement was over how I should address him. He wanted me to do it the American way, using his first name. In the Japanese culture first names are used only by childhood friends and immediate family, and even then not always. I just couldn't bring myself to do it, and always addressed him in the Japanese way as Kurosawa-san. If we had met in the US, it would have been different.

Over dinner on one trip he told me that it was his dream to have a corporate engineering activity in Japan. It was a constant ding against American suppliers that they did no R&D in the country, and he wanted to counter that. I thought it was a great idea, but when I presented it to my management back in California they practically laughed in my face. It would be expensive, we wouldn't be able to find or hire the right people, it made no sense, and so on. So that was that.

But Kurosawa-san was resourceful, and at some point, knowing that he had the practical support he needed from me, he managed to convince the CEO, John Chambers. That changed everything. Suddenly I was told to make it happen.

The biggest challenge was to find someone to run it. The key to any remote team like this is to find someone who understands the corporate thinking, and who also understands the local culture. Generally this is impossible, which is why so many remote teams fail miserably. I had a very lucky inspiration. One of the UK team which I'd inherited when I joined Cisco was bored and looking for something new. A Norwegian called Ole, he still had some Viking blood, one of life's adventurers looking for the next Big Thing. It helped a lot that he already knew some of the Cisco Japan team. He was signed up almost before I'd finished asking him.

The other big challenge was to assemble the nucleus of the team. But that turned out to be much easier than I'd expected. In 2004 Cisco's prestige was high and people were keen to be part of its product development team. There were people already working for Cisco Japan, who had taken jobs in support for want of anything better, who were happy to move into engineering. Through personal contacts we found engineers at Japanese companies who were happy to make the change. One of the new team was Japanese but working for Cisco in California. Quickly I had a nucleus who could be trusted to grow the team - although, in the end, it never did grow.

We had to put the team somewhere. Initially we borrowed some space from the country sales operation, in Shinjuku, but the hope was that eventually it would reach a hundred or more people. For that it made sense to think about a location outside Tokyo, which led to our "fact finding" trip to Kanazawa in Ishikawa prefecture, and our amazing lunch with the prefectural governor that I've written about before.

Everything came together in spring 2005. We had a team, we had an office, and we had someone to run it all. I went to Tokyo for three weeks to get it all started, and luckily my wife was able to come with me. Rather than stay in a hotel, we rented a very pleasant apartment in the Aoyama district of Tokyo. It's the closest I have ever come to living in Japan. We shopped for food in the local supermarkets, an interesting experience for my wife who neither speaks Japanese nor can read any of the characters. Most things can be identified from pictures on the labels, but she needed my help to distinguish salt from sugar and flour. We had a wonderful time there, one of the most memorable trips of my life.

For the next year or so, I visited Japan every three months. It led to some complicated itineraries, since I generally combined them with a visit to the team I still had in the UK. Cisco had rented an apartment in Tameike for Ole and his wife, absolutely vast by Japanese standards, a ten minute walk from the New Otani where I stayed on every trip. Each room was bigger than a typical Tokyo apartment. I spent many memorable evenings there, though the next mornings were sometimes a bit hazy. Apart from the team itself, he'd built a "support network" in Japan who helped him and all of us with every aspect of things.

Since I was in Japan so often, I got to know the country sales team well too. I visited several important Japanese customers as "the man from HQ". I would sit there in total incomprehension as the "fireside chat" meeting ran its course, but apparently just my presence made a big difference.

It was important for the team to know their colleagues in California, and we arranged for them all to visit at the same time. The trip happened to coincide with Halloween, and we arranged a fancy-dress party at home. One of the team's hobby was traditional Japanese kimono, and she had brought with her a complete outfit. She looked amazing, delicate and beautiful in the Japanese tradition, and definitely took first prize by popular acclaim.

I left Cisco about a year later, and Ole decided to return to Europe at the end of his two year contract. A local manager was hired. But by then Cisco had lurched into much more aggressive expense control, and the planned expansion never happened. The country manager retired, a victim of corporate politics - the destiny of all who reach the senior ranks of Cisco. With no sponsors left, the group lingered on for a surprisingly long time, but in the end a bean-counter somewhere spotted it and its destiny was sealed. Some of the engineers returned to non-engineering roles, some moved to the US, and some left the company.

The country manager, who I got to know well, once said to me "When you make a friend in Japan, you make a friend for life." And it's true. Even now, fifteen years later, I still have good friends there who I see whenever I get a chance to visit.

Saturday, 4 July 2020

The Garden Railway: Trouble with Turnouts

The design and construction quality of LGB equipment is astoundingly good. You can leave the trains outside in all weathers with no damage or deterioration, whether from rain, snow, intense heat, or UV radiation. The locomotives will pull heavy, friction infested trains all day long without complaint. If anything does break, even the tiniest moulding is available as a spare part, albeit at a high cost. The track too is tough as anything - you can step on it without damage, and electrically it works far better than you could reasonably expect.

But nothing is perfect. The one place where their attention to quality seems to have lapsed is the pointwork, those necessary but fiddly places where trains get a choice of direction. They're eye-wateringly expensive - roughly $100 for a new, electrically operated turnout. But with LGB you just have to get used to that. The problem is, they just aren't that well designed. There's a sort of pervasive optimism, a feeling of "it'll be alright on the night", that applies to every aspect of the design: electrical, mechanical and trackholding.

My garden railway currently has a total of 17 LGB turnouts, all electrically operated via my NCE DCC controller. All the ones on the main running lines are 16xxx medium radius. There is a yard with the small, 600mm radius 12xxx turnouts, mostly bought new 20 years ago. The others are a mix of new, at various times over the last 10 years, and some eBay bargains, of which the oldest was probably 40 years old.

Keeping them all in good working order, so the trains run over them smoothly without derailing, jerking, or just coming to a halt, requires constant attention.

Electrical Problems

All of the electrical side of LGB stock suffers from a degree of design optimism. There are simple rubbing contacts everywhere, for example between the pickups, motors and other electrical connections. The wires are made of brass, which slowly forms an insulating oxide layer on the surface, so intermittent electrical problems slowly arise as the trains gets older, especially when they live outdoors.

The slider pickups on the locomotives are a case in point. The idea is excellent, but the connection from the slider to the rest of the electrics depends on a fragile spring, wound with wire barely thicker than a human hair. If ever there is a short circuit in the engine, the spring heats up to the point where it loses its temper - which is to say it stops being a spring, so the pickup stops working. It's possible, but very fiddly, to replace the springs, and to make it more complicated a different part is needed depending on the particular locomotive.

This pervasive electrical optimism really strikes hard on the points. The outer running rails are solid brass, connected to the adjacent track by heavy, springy fishplates. No problem there. But the connection to the switch rails - the ones that move - is made by very primitive sliding contacts under the rail. This works way better than it deserves to when the track is new, but as it ages the contacts and the rail itself oxidize, and the force holding it all together weakens. The net result is that trains hesitate or flat-out stop as they are going over the points.

It doesn't help that there is a lot of dead track. The place where the two rails cross - the "crossing" or "frog" depending on your train-speak dialect - would ideally be connected to one rail or the other depending on the point setting. This is difficult to arrange, and LGB didn't try. These sections are made of insulating plastic, meaning that one wheel, at least, stands no chance of picking up power. Four wheel locomotives, like "Shiny", our Wismar railbus, are especially vulnerable - the more wheels the better.

The diverging rails are connected invisibly, under the sleepers, by metal strips that are spot-welded to the running rails. They also are a bit optimistic. On several of my older points these welds have failed, leaving a lengthy piece of rail with no connection.

Underside of turnout showing
soldered connecting wires
The solution to all these problems is to make soldered connections between the various pieces of rail. This is a bit daunting since large-section brass rails conduct heat away from the joint area very effectively, and there is an obvious risk of melting the plastic base. To deal with the second problem first - the plastic used for the bases is pretty resilient to soldering. It softens, but doesn't melt, when you heat the rails up. It will melt and burn instantly if you touch it with the hot iron, though.

I've been pretty successful soldering fine wires to the underside of the rails. My technique is:
  • start by cleaning the metal very thoroughly, with a fibreglass "scratch brush", until it is gleaming
  • then cover the joint area in non-corrosive resin flux
  • I use a 50W temperature controlled iron, set to its highest temperature of 425°C, with a substantial chisel-shaped bit about 7mm across - providing plenty of reserve heat
  • hold the iron flat against the rail, holding it as far as possible from the plastic, and hold the solder against the iron - when melted it acts as a heat transfer fluid
  • now hold the iron in place until the rail is hot enough to form a proper joint with the solder. It's easy to see this because the blob of liquid solder suddenly spreads out on the metal
  • now add the wire, then hold it in place with a screwdriver or similar until the solder solidifies again. This will take a while - up to 30 seconds - because of the heat retained by the rail
  • Don't touch anything! - the rail stays painfully burning hot for a long time afterwards.

Mechanical Problems

In real life, track is held on the sleepers by some kind of spike driven into the wood, which either directly holds the rail, in US practice, or holds a metal plate which in turn presses on the base of the rail, in Europe. (It's different for serious railways, with high speeds and heavy trains, but light and narrow gauge railways work like this). The LGB track provides a good visual impression of this, but it really isn't very strong. The rails are held in place by tiny flaps of soft plastic, less than a millimetre thick. It takes very little to twist and break them.

On normal track this isn't really a problem. The sleepers all support each other, so they aren't subject to high stresses. And even if one does break, the rail is still supported by those around it. Points are a different story though. For example, the very first sleeper, closest to the moving switch rails, is the only one supporting the point motor and the first few inches of rail. It can easily get broken, and when it does, the vertical relation between the fixed rail and the moving one is lost. Trains fall off the track as a result.

It's impossible to repair the track base. What I have found effective is to glue the rail in place on the damaged sleepers, using the remains of the simulated spike. The plastic is something soft and difficult to stick to, but I have found a two-part epoxy that works well, Loctite EA9340. I originally bought it to make some repairs in the kitchen, where prolonged exposure to steam softened regular hardware-store epoxy, but it seems perfect for this too. Another advantage is that it dries to a murky dark green, making it pretty much invisible on the track.

The technique is simple. First get everything as clean as possible. Clean the rail with a fibreglass brush, and swab everything with alcohol. Then mix up some epoxy and make it into a blob around the base of the rail, so it looks like part of the sleeper. If several sleepers are damaged on the same point, do it for all of them.

Sometimes you can't blame LGB. One of my points was hit by a heavy steel ball, from playing French bowls (petanque) in the garden. The rail was badly twisted both horizontally and vertically, and many rail fastenings were broken. After I dismantled it and straightened the rail out, the epoxy worked perfectly to hold the rails in place. The repaired point is back on the layout, and trains pass it without problems.

Trackholding Problems

In Victorian times facing points - ones where the train has a choice of which way it goes - were regarded with horror. Railway designers went to great lengths to avoid them on main lines wherever possible. Where they were unavoidable, they always had facing point locks, which held the switch rails firmly in place while a train passed over them. They were interlocked with the signals, so it was impossible to clear a train to pass over the points unless the locks were in place.

Sadly our LGB points don't have these devices. They are held in place rather feebly by the magnets in the point motors. It's quite common to have a tiny gap between the fixed and moving rails - a fraction of a millimetre, but enough to cause problems. If a flange rides over the sharp end of the rail it can move the rail under it, opening the point and dropping into the gap on the wrong side. The rest of the train inevitably derails when this happens.

I haven't found a really good solution to this. Some point motors work better than others. I had one point that would consistently cause derailments. It was an old one, from eBay, with an older design of point motor. Replacing the latter with a newer motor held the rail in place much more firmly, and solved the problem.

The ideal, in the absence of an actual lock, would be a really firm over-centre spring mechanism, but I can't see an easy way to do this. In any case the force produced by the point motor probably wouldn't be enough to overcome it.

LGB four-wheel carriages and trucks have pivoting axles, to simplify going round the tight 600mm radius curves. Normally these are held at the correct angle by the traction on the coupling, but that doesn't work if the train is being pushed. And sometimes they get stiff. So they will occasionally end up trying to go through a point when the wheels aren't aligned correctly with the track. This makes the above problem a lot worse. It causes another problem, too.

In real life, points have check rails, or guard rails, which ensure the wheels go the right way through the "crossing" or "frog", where the two rails cross. The check rail presses against the back of the wheel and stops it slipping into the wrong, diverging flangeway.

Unfortunately the check rails on LGB points are mostly decorative. They are way too far from the rails to be really effective. Mostly this doesn't seem to matter, but on the three-way point they are not only too far away, but not in the places they need to be. There are so many problems with this item that it deserves an article to itself.

Saturday, 13 June 2020

The Garden Railway: Fabian the Krokodil

You know how it is with eBay when you bid on something. You have the winning bid for days, then in the last ten minutes a bunch of robo-bidders go to work and the item sells for twice what you thought you'd get it for. So I was very pleasantly surprised to get a message telling me that my bid for our latest LGB locomotive had succeeded. I'd been thinking about getting a new train for the garden railway for a little while. I was very tempted by LGB's DR Class 99 2-10-2 steam engine, a huge monster of a thing which I once saw in real life on the Hartzquerbahn in the former DDR. But the new production is selling for nearly $2000, and isn't available yet anyway. That seems like a lot for a toy train.

So when I spotted a Rhätische Bahn Krokodil at a very good price, I just couldn't resist. My winning bid was less than a quarter the price of the steam engine. And a few days later he showed up, and the fun started.

The original Rhätische Bahn Krokodil, class Ge 6/6, in a suitably Swiss setting
The real-life Krokodils appeared in 1921. The Rhätische Bahn, which operates (still) an extensive metre-gauge network in the Swiss Alps, was a pioneer of system-wide electrification. Starting in 1919, and completed by the mid-1920s, the overhead line covered the whole network providing electricity at 11,000 volts and 16⅔ hertz.

They acquired some extra-powerful locomotives, officially called Class Ge 6/6, to pull the heaviest trains. The design, with a snout at each end holding a giant electric motor, was needed because of the sharp curves on the line. Similar, but larger engines had already been built for the Swiss main line. They had even longer, flatter snouts, and the name Krokodil (meaning, of course, Crocodile) was an obvious choice, applied subsequently to all similar engines. The driver sat in one of the cabs at either end of the central section, enjoying excellent protection in the event of a crash yet also excellent visibility. The centre section held a huge, heavy transformer, to convert the high voltage scraped off the wires by the pantographs into something like 600 volts for the motors.

All of our engines have names - Marcel the diminutive French 0-6-0 who was the subject of my intelligent locomotive experiments, Helmut the beefy Hanomag 0-6-6-0 Mallet, and so on. A few years back we visited Cancun, in Mexico. We had dinner one evening on the terrace of a restaurant overlooking the lagoon. When the kitchen was closing the cook came out and threw a whole chicken into the lagoon, as he softly called "Fabian, Fabian". There was a splash and a scurry in the water. The chicken was gone. Fabian was their semi-tame crocodile who lived in the lagoon and showed up for dinner every evening. Later we could see him gently rocking to the dance music that was playing downstairs. And so Fabian was the obvious name for our Crocodile.

The big challenge with these old LGB locomotives is converting them to run with the DCC control system on my railway. This puts a permanent 18V AC on the rails, superimposed with a control signal that tells each engine what to do. The advantage is that you can have as many trains as you want, some moving and some standing still, without any complicated wiring. A little decoder in each engine understands the control signal and turns the 18V AC into something suitable to drive a DC motor. It's hard to imagine operating a serious-sized railway without it, nowadays. Modern locomotives are designed to connect easily to a decoder, with the electrical pickups from the track wired separately from the motors.

But the old LGB ones, like Fabian, date from the time when the rails were connected directly to the motor, which was operated by a variable DC voltage on the track. The connection is typically buried deep inside the workings, and so it is with Fabian. I approached the open-gearbox surgery with trepidation, after reading web articles about the number of tiny parts that were just waiting for a chance to leap across the room and get lost in the carpet. In the event it wasn't too difficult. The internal connections are made by complex shaped brass strips that rub against all the right places, and it just took a couple of cuts to separate them. It was also necessary to run an extra wire from each bogie into the main body, so there could be three completely separate circuits: track power, motor, and lighting.

Like all older LGB locos, Fabian has a fearsomely retro-looking circuit board full of randomly placed through-hole components and massive hand-soldered tracks, that operates the lights from the track power. Rather than attempting to reproduce what it does, I prefer just to give it a fake track power feed and leave all the existing light circuits untouched. A little bridge rectifier produces 18V DC, which is then fed via a reversing relay to the circuit board. I have a stock of bistable relays, that remember their last setting mechanically, left over from another project (30 years ago!). All it takes is a couple of diodes feeding the actual motor supply from the decoder into the two relay coils, so the lights reflect the last way the train ran.

At least, that's the theory, and the way it works on my other engines. But for some reason the relay didn't want to cooperate. I think it must be defective, but anyway I ended up building something a lot more complicated, packed into board space that wasn't really available. It was a nightmare to get it to work, and I still don't understand why.

Finally everything worked. Reassembling Fabian's body was an interesting challenge. The mechanical design is ingenious, as always with LGB. To remove the circuit board required removing the back of the driver's cab. That is held in place by the hinge of the opening driver's door. Reassembling that, with the tiny spring that holds it shut, requires about six hands. With only two hands, it can eventually be done with patience and lots of not-in-front-of-the-children language.

Fabian, with his mentor Helmut looking on
Fabian looking very purposeful
Finally Fabian was ready. While he was on the bench, his train had shown up. LGB has a strange policy of constantly changing what is available new. They have made RhB wagons on and off, over the years, so finding a complete train requires a search of eBay, new production, and dealers' old stock. For now I have managed to accumulate three, with another on its way from England. Helmut generously agreed to lend Fabian his bright yellow banana wagon, but with a condition - he also had to take the track cleaner, a rather nondescript affair loaded with logs to held it scrape the oxide layer off the rails. It's surprisingly effective, but hard to pull and inclined to fall off the track. I'm sure Helmut believes he got the better part of the deal.

So now I can watch Fabian touring our garden at his stately speed - in real life he is limited to 55 km/h, even when pulling the optimistically named Glacier Express. Thanks to the wonders of JMRI and the Raspberry Pi Zero W, I can sit and sip my pastis and control him from my iPhone - but that is another story.

Fabian with his Rhätische Bahn train along with the borrowed banana wagon and track cleaner

Friday, 22 May 2020

Modelling a Pandemic


Inspired by the observed differences between actual Covid-19 data and the predictions of the classic "SIR" model, I built a detailed pandemic model. It's a person-by-person simulation, for up to 50 million people, rather than a mathematical model. It uses the tricks I've accumulated writing high-performance network software to do this at reasonable speed. The results closely match actual data, and allow control over variables like vaccination, social distancing and self isolation. Skip to the last section to see the results. The source code is available on Github.


Soon after the Covid 19 pandemic started, Mark Handley at UCL in London started a website showing the development in the number of cases and deaths in various countries and places around the world, which I followed with great interest.

Out of curiosity, I put together a simple simulation based on the SIR model of infectious transmission. This is the basis of much of epidemiology, and yet it quickly struck me that the curves it generates didn't correspond at all with Mark's. Using a log/linear scale (i.e. the Y-axis is logarithmic), SIR gives a straight line up until very close to saturation, where nearly all of the population have been infected. This corresponds to the now much-discussed "R0" number, i.e. the number of next-generation victims who will be infected by a single sick person.

Yet Mark's graphs weren't like that. No matter which country or area, nor which policies were being followed there, they all showed a gradual reduction in the slope. This was true for Lombardy and for much less afflicted places. It was true for Spain, which quickly enforced a very strict lockdown, and for Belarus, which never edicted anything at all. Even knowing exactly when lockdowns were put in place, it was difficult or impossible to see an inflection in the curve.

It was easy enough to come up with a mathematical model which closely described these curves. It is sufficient for the "R0" number to decrease slowly over time, to get a close match. The resulting curves perfectly matched the actual data from Lombardy.

So, why is reality different from the this nearly one century old model? It doesn't take long to see an obvious weakness. The math behind the model is simple:

    infected on day n+1 = constant * infected on day n * susceptible on day n

where the constant is closely related to our old friend R0. It's a simple differential equation, which indeed predicts the exponential growth everyone talks about.

But wait a moment. This supposes that every infected person is equally likely to infect every susceptible person. Is this realistic? Suppose Bob, living in New York, get sick. Alice lives in Los Angeles with her vulnerable elderly mother. She gets sick too. Which of them is more likely to infect Alice's mother? Or Bob's drinking buddy? In fact, the SIR equation only makes sense when applied to relatively intimate groups of people - families or close friends, for example. For larger communities, it needs to take into account also the probability of contact between individuals.

Herd Immunity

Everyone is now familiar with the concept of "herd immunity". If enough people are immune, a single infected person can no longer infect enough for the outbreak to grow. R (not R0 any more) has fallen below 1. It's widely stated that herd immunity needs to be somewhere around 60% to be effective, depending on the value of R0.

But again, this assumes that everyone is equally likely to infect everyone else - that herd immunity will not protect New Yorkers from each other if it has not yet reached the necessary level in Idaho. This obviously makes no sense. That situation may be bad news when an infected New Yorker visits Idaho, but New Yorkers will be protected from each other.

People tend to operate in clusters: families, groups of friends, close colleagues. Within such a cluster, transmission is high: if one person in a nuclear family, or one person in a small office, gets sick, the others will all be heavily exposed and most likely will either get sick or develop an immune response. Hence the admonition, common even before Covid, for sick people to stay home from work.

Once all the people in such a cluster have been exposed, the cluster has a localised form of herd immunity, regardless of what is going on in the wider world. An infected stranger visiting an exposed family, for example, poses no risk.

Thinking along these lines led me to the idea of "fractal herd immunity" - that there can be herd immunity at a local level, or in a larger community, without it applying globally. There is leakage between clusters - the nuclear family goes to visit the parents and cousins, close colleagues are part of  a larger company. Friendships especially are "leaky", it's common enough that my friends have friends who I don't know, or barely.

Building a Model

I wanted to develop a model to test this idea and see if the results look like reality. I didn't see any mathematical way to do this, so I built a simulation. Each person in the population is simulated, with day-by-day exposure to the infected people around them.

The model creates cities, and populates them according to a realistic distribution - a few big cities, and lots of small ones. Each person is allocated to each of four different clusters: family, friends, work and the local community. The latter corresponds to things like shopping. Clusters are randomly sized; for example, the family cluster can be anything from 1 (people living alone) to 8, with a bias towards smaller sizes.

Influence is a parameter for each cluster. In a family, people are in close proximity. This is taken as an influence of 1. The community cluster has a much smaller influence, but the clusters are a lot bigger. Cluster size is extremely important, because transmission increases as the square of cluster size: more people are exposed to more infected people. This is why large gatherings have been such an effective way to spread Covid, like the religious groups in north-east France and Korea.

Infection has to get between clusters. Partly this is done by grouping them into larger clusters, with reduced influence between the members. So a sick person in one family cluster has a small chance of infecting someone in an adjacent cluster, just as if they visited another part of the family.

Most cluster memberships and relationships are within the same city, but there are also ways for infection to travel between cities. This can be via cluster membership, for example when a family's relations are in another city, or when an office is part of a larger company based elsewhere. It can also be through explicit travel. Each person is randomly assigned a mobility, which is the probability that they will visit another city on any given day.

The model has a few higher-level parameters that control it, and a lot of detailed ones that are manipulated by the higher level ones. For example:
  • population: the total number of people - the model can handle 50 million, and gives rapid results for 3 million
  • infectiousness:  the R0 value for the infection
  • auto-immunity: the number of people who, when exposed, will develop immunity without becoming sick or infectious
  • distancing: the extent to which people's behavior is modified by social distancing
  • vaccination: the number of people who are immune at the start due to prior vaccination 


The results can be presented either as a simple graph, showing the number infected and total infected as some parameter is changed, or as a rather fetching animation where each city is shown as a "bubble" gradually changing color as people are infected and either become immune or recover (or die). Here are some examples.

Social Distance

This chart shows the effect of varying "social distance", i.e. reducing interaction with friends, work and the local environment, and reducing travel between cities. Zero means business as usual. 1 is Wuhan style - everyone at home except truly essential workers, no travel. It is modelled by varying the level of interaction between people and the groups they belong to. At distance equal to 1, the family group is unchanged, friends drops to zero, work to 20% (allowing for some essential workers), and travel to 10%. Intermediate values of distance set intermediate values of interaction.

Somewhere around 0.8 or 0.9 is what was achieved in the UK or California, with less travel and contact, but still some, and some people trying to disregard the restrictions altogether. This level very substantially "flattens the peak", as well as reducing the total number infected. The chart also shows that anything less than 0.5 has no impact.

R0 - the Infection Ratio

This chart shows the effect of different values of R0, the number of people infected by each infectious person (using a log scale for the Y-axis). At 1.0, the infection dies out slowly. In some simulations, depending on the randomness, it lingers for a long while without growing much. At 1.2, the infection grows very, very slowly. This is a consequence of the local immunity effect - with the traditional SIR model, it would grow very quickly. Covid-19 supposedly has R0 in the range 2.5-3.


This chart shows the effect of vaccination. Just 20% vaccination halves the total number of people infected, and the size of the peak. At 50%, the infection is wiped out. This percentage is a product of the number of people vaccinated, and the effectiveness of the vaccine. So if 50% of people get vaccinated, and the vaccine is 80% effective, that corresponds to 0.4 on this chart.

Watching the Pandemic

The simulation can also show graphically how the pandemic spreads. The picture above is at day 100 with some typical parameters. Each blob is a city (some large cities are drawn on top of their smaller neighbors). The red ring corresponds to current infections, the blue outer circle to those who are still susceptible. The inner green circle is those who are no longer susceptible - recovered, asymptomatically immune, or vaccinated. The small black dot in the middle corresponds to deaths. Clicking here will show the complete evolution of the pandemic (select 1080p for best results).

Tuesday, 12 May 2020

Life on the Ocean Wave - Riding the Hovercraft

One day I will write a guidebook to nostalgia, called "101 Things You Can't Do Any More". In pride of place, along with crossing into East Berlin and flying on Concorde, will be the hovercraft journey across the English Channel (La Manche pour mes lecteurs français).

Since 1994 crossing the channel has been a dull business. You drive straight off the M20 from London into a vast car park, from which you are shepherded into a tunnel. You stop behind the car in front, like any other traffic jam, turn the engine off, and sit there for half an hour or so. You are vaguely aware of movement, but only just, as you listen to the car stereo or read a book. Then the car in front moves, you follow it, and you are on the A1 headed for Paris. It's efficient, relatively inexpensive, and of absolutely no interest at all.

The story behind this dull half hour is a fascinating one, of over a century of political and financial wrangling which led, finally, to the construction of the Channel Tunnel. While you are sitting there, bored, you are on a train travelling at 100 miles per hour through one of man's most extraordinary civil engineering achievements. But the whole point of it is that you don't need to be aware of any of this.

Until 1994, there was no way to travel with a car between England and France without being firmly aware of the 22 miles of open water that have protected England and Continental Europe from each other since 1066 AD. In Victorian times it was a serious adventure, tossed about on the waves in a sailing boat or later a steamship. Turner, the English artist, was inspired by it to produce some extraordinary paintings, even strapping himself to the mast of a channel boat during a violent storm for the experience.

It could be hazardous in many ways. It certainly was for Rudolf Diesel, inventor of the eponymous and omnipresent engine. After the German Navy had expressed no interest in his invention he took the steamer to Harwich to try and sell it to the British. One has to suppose that the Germans suddenly woke up to their mistake, because he disappeared en route, his body never to be found.

My own first Channel crossing by car was in about 1979. It was long and boring. The shortest crossing, the 22 miles between Dover and Calais, took a couple of hours, with another hour or so at each end of waiting, embarkation and disembarkation. The crossing itself was spent staring at the sea, resisting the limited attractions of the greasy fast food and fizzy beer available on board.

There were other, longer routes. For one summer holiday we took our car on the ferry between Southampton and Le Havre. That was an overnight trip, tucked up in a narrow berth in a tiny cabin. While waiting for the return ferry we got chatting to the driver of the car in front, who was struggling with a stuck-open window in his Lancia. He told us he was a fashion designer. A year later his name, David Emanuel, became famous as the creator of Princess Diana's wedding dress, but at the time he was just a thoroughly nice bloke.

From 1989, after I met Isabelle and started our long-distance relationship between England and France, I needed to cross back and forth more often. By then the hovercraft was an option. (You were wondering when I'd get to it, weren't you?) It offered a crossing in just 40 minutes and since it was smaller, a lot less time was spent messing about at either end. This more than made up for the extra cost.

My first trip was unforgettable. The sea was choppy, and with every wave we ploughed up high in the air then crashed down into the void between the peaks. Unlike the ferries you had to remain seated the whole time, in airliner-like seats stretched across the width of the cabin. I spent the whole journey staring fixedly but unfocussed at the horizon, trying to keep my breakfast inside me.

Afterwards I made a visit to the men's room. Next to me were two colleagues, one regaling the other with how much worse it could have been. "Remember that bit where it felt like we were just hanging in space?" His buddy groaned in response. "Well, last time, those were the good bits."

It was a fantastic way to travel though. You stood on the edge of the beach at Ramsgate or Calais watching the giant, roaring monster slither gently up the sand then sink gradually onto its giant rubber skirt as the engines stopped. Compared to a ferry it was tiny, with room for maybe 40 cars, all firmly tied down en route.

The hovercraft did not deal well with rough seas. At least, I think the machine itself did, but there was a limit to what you could ask passengers to put up with. This was brought home to me on my most memorable trip, in April 1990, taking my children on a spring break to Paris, Toulouse and Hossegor.

It was memorable for many reasons. My car's wheels had been stolen a couple of weeks earlier, and the replacements were on long back-order. In place of my beloved Golf GTi, the insurance was paying for that pinnacle of British luxury motoring, the Rover 827. The adventure started long before we got near water. We had stopped off for tea at my parents' house in Romford, more or less on the way to Ramsgate. When it was time to leave, somebody - we will be discreet here - revealed that they had locked the car keys in the trunk. It has been a source of family amusement ever since, but at the time it was not funny at all. Eventually the RAC showed up.

"Have it open in no time, guv. What car is it?" said the smiling mechanic.

"A Rover 827."

His faced dropped. "Blimey, they're nearly impossible. I'll 'ave a go anyway." That was just the kind of reassurance I was looking for. After half an hour of fiddling about with long thin bits of metal, he finally got the door open, and we set off for Ramsgate.

As it turned out, none of this mattered. We arrived to see a big handwritten sign, "Hovercraft cancelled due to bad weather, please go to ferry terminal at Folkestone". We drove the 20 miles or so down the coast in what was indeed terrible weather, the gale-swept rain swirling around the car. Upon arrival we learned that the ferry too was running hours late. We filled in the time with a visit to McDonalds, and finally boarded the ferry around 10pm - when we should already have been well on our way down the A1 to Paris. We climbed up from the car deck, and waited to set sail. And waited, and waited, and waited.

Finally I went back to the car deck, and found a loader who explained the delay to me. The waves were huge even inside the harbour, and the ferry had sunk into the trough of one just as a bus was crossing onto the ramp. The ramp crashed into the bottom of the bus, severing the brake lines and locking the brakes firmly on.

"Normally if that happens someone crawls underneath and releases them by hand. But not tonight," said my interlocutor, gesturing at the bus which was tossing around crazily as the boat did the same. Instead they had to tow it off, wheels locked, with the giant tractors used for container trucks. The first effort snapped a rope the size of a man's arm. Eventually they got it off with an even thicker one.

I whiled away the time by wandering around the open deck in the gale and blowing rain. I read the notice explaining how to launch a lifeboat. I have to suppose that the sailors were trained and knew the procedure, so this was just in case the passengers had to do it themselves. It made the instructions for Chinese consumer electronics look positively lucid. I didn't understand a single substantive word. It read something like the following.
  1. Unsprurl the flangling ropes.
  2. Diswangle the grotling clips.
  3. Under no circumstances allow the wribbits to contact the ortlers.
  4. Bringle the yarling cords.
And so on and so on. Eventually we set sail, and after a rough crossing during which we all slept soundly and several hours driving, we arrived in Paris at about 5am.

Our trip was wonderful. We explored Paris together, had an Easter Egg hunt at Isabelle's mother's house outside Toulouse, and paid the first of many, many visits to Hossegor on France's Atlantic coast. On the way back we spent another night in Paris, creating another family memory. We had to be up very early for the return trip to Calais. I went out to buy croissants. My daughter, about 7 at the time and very grumpy at her early awakening, simply stared at hers.

"What's wrong?" I asked.

"My croissant is too bumpy!" she complained.

Despite bumpy croissants, we made it uneventfully to Calais and could watch the monster machine arrive on the beach, where the photo at the top was taken. The sea was perfectly calm, one of the best hovercraft trips I ever did.

I missed them when the tunnel opened, a few years later. The hovercraft is a brilliant invention, even without its famous contribution to the Hungarian-English phrasebook ("My hovercraft is full of eels"). But somehow it is never quite the right tool for the job, and there is hardly anywhere in the world where you can still ride them. Still, it was fun while it lasted.

Saturday, 9 May 2020

My Dad's War

My Dad, December 1940 - 29 years old
In 1940, soon after the declaration of war against Germany, my Dad was conscripted into the British Army. In that he was just like every able-bodied male, of suitable age and not in an essential job like the railways.

War is hell, as has been said before. For so many, even if they escaped with their lives, it was a traumatic, life-changing experience - and not in a good way. But for some it was the greatest experience of their lives, working together in a common purpose. I'm quite jealous of the people at Bletchley Park, constantly struggling with new ways to break the German codes, knowing that an hour shaved off the time could save hundreds of lives.

One of my favourite books is Most Secret War, by Reg Jones. He led the efforts to develop hi-tech (for the time) aids to beating the Germans, and to understand and defeat their technology. Just one example was their use of intersecting radio beams to bomb British cities accurately. Once understood, it was a simple matter to broadcast a stronger signal on a slightly different alignment, resulting in thousands of tons of German bombs falling on open countryside instead of devastating a town and killing hundreds of people.

Yet there was a human side too. Jones had to live through the blitz just like everyone else. He mentions an occasion when they expected a big raid on their neighbourhood. Prudently he filled the bath beforehand, ensuring a water supply even if, as happened, the pipes were destroyed by the bombs. Imagine his shock when he discovered his wife, wondering why on earth he had left the bath full, had emptied it shortly before the bombs fell.

My Dad was selected for the Artillery. He was sent off to a remote training camp in North Wales to learn to be a wireless (radio) operator. He was taught Morse Code, and the basics of radio operation. No doubt he expected to be sent to a battlefield somewhere, sending reports and receiving instructions under bombardment as his squad-mates in turn bombarded the Germans.

He never talked about exactly what happened. He was a very social, personable chap, who made friends very easily with a straightforward, natural charm. Maybe it was that, or maybe he really was talented. But whatever the reason, the camp commander decided that he could best serve his country by teaching other people how to communicate under bombardment, instead of doing it himself.

And so for the next five years my Dad was stationed just outside Llandudno, teaching other men Morse Code. It's hard to imagine anywhere more remote or distant from the industrial heartland, except maybe the Scottish Highlands. He admitted to having seen just one enemy plane, a German bomber which had got lost and subsequently crashed into the Irish Sea. The contrast with my mother, too young to serve and living at home in South London with her family, couldn't be greater. Bombs were part of her daily life, met with typical British stoicism: "If it's got my number on it, it's for me". She was more concerned about being home before her mother's imposed deadline than she was about being hit by a bomb.

He may have been far from the action, but he was still a soldier in uniform, admired by the people who remained on the farms and in the villages. Even with strict rationing, the local country people weren't short of eggs, chickens, milk or butter. So, "Here Reg, take a couple of eggs for your breakfast" happened often enough.

Without a shadow of a doubt, World War II was the highlight of my Dad's life. He had good friends, an easy enough life, the respect of everyone for a serving soldier - and what he was doing was genuinely valuable for the war effort. That it involved absolutely no risk at all certainly made it more pleasant.

He made friends easily, but they were mostly superficial - good mates, but no more. There was one exception, Bert. They served together in North Wales for the entire duration of the war. He often spoke of him, and in the tradition of the times they exchanged Christmas cards, but no more. Bert lived a long way off for the times, somewhere near Birmingham in the Midlands.

And yet... one day with my mother he visited a park quite a way off, in Barking. Why they went there I have no idea. And strolling through the park, over a hundred miles from home, was Bert, with his family. It's an extraordinary coincidence, worthy of a Thomas Hardy novel. They shook hands, chatted for a while about the old times... and never saw each other again.

Even for my Dad, the war wasn't without unfortunate consequences. He had married in the late 1930s, setting up home in a flat in Kilburn in grimy north-western inner London where my half-sister was born. When he went off to the Army his wife moved to the Suffolk countryside to live with her mother. It was an area that was crammed full of airbases, as close as possible for launching nightly raids on Germany. The airbases were in turn crammed full of airmen, British and American, and all the supporting staff they needed.

As the locals said, "The problem with the Americans is that they're overpaid, over-sexed, and over here." That was very unfair, considering that they were dying by hundreds every day in poorly conceived daylight bombing raids. And anyway it wasn't an American who stole my Dad's wife, it was a fellow Brit. From my point of view, this was an excellent thing - otherwise I would not have come into existence. In fact things worked out well all round - her second marriage was long-lasting, and my father made a happy second marriage too, as these things go.

It was a common enough problem after the war, and the Army set up special divorce courts to deal with it. My Dad told the story of leaving the court, after his divorce had been approved, along with a fellow serviceman who said, "Best day of my life, I'm finally rid of her. Let me buy you a drink."

My Dad's post-war life was uneventful, and successful enough in a very modest way. He became a salesman to the clothing industry, which lasted until he retired at 67. But I don't think anything after 1945 came close to his wartime experience.

Thursday, 7 May 2020

Lighting up Shiny, the Wismar Railbus

In the 1920s, road competition was really beginning to hurt rural railways everywhere in the world. The economics of running a steam engine, trailing a handful of elderly carriages behind it for three or four journeys per day, had never been good. Now they were terrible. The railway companies looked to modern technology for a solution. A diesel powered railbus could be operated by one man, requiring almost no routine maintenance - unlike a steam locomotive which took several hours of preparation every day. And as a bonus, it offered the same level of comfort as the road competition, rather than the hard seats and general decay of carriages that were often 50 years old. More frequent (well, less infrequent) services could be run, as well.

All over the world various different railbus designs appeared. Another of their advantages was that they run readily in either direction. Nowadays, we take it for granted that there will be a driving cab at either end. But that wasn't obvious in the beginning. For one thing it takes up space that could otherwise be used for passengers or freight. For another, operating the engine and transmission from a distance requires some kind of linkage. An electric or pneumatic system sounds ideal, but it had to be maintained in the field by steam locomotive engineers whose most subtle tool was a coal hammer. And mechanical linkages were hard to keep working. (When I was a teenager, I travelled all across France on a bus with a rear-engine, unknown in England at that time. Every gearchange was an adventure, as the driver struggled with the worn-out mechanical linkage to try and persuade the gearbox, 12 metres away at the back of the bus, to engage the right gear, or at least some gear).

So other solutions to the problem were developed. The French were especially creative. Some early railcars had a cab at one end only, next to the engine, and a kind of mini-turntable under the bus. At the terminus the crew would crank a handle until the bus was resting on the turntable, push the bus around 180 degrees, then retract the turntable. A much more widely-used idea was to put the driver in a turret on the roof. He sat sideways with the controls in front of him. The most common railbuses in the 1950s had the turret in the middle and offset to the side. They were called Picassos, after the painting with the girl's nose to one side of her face. The poor drivers must have suffered terribly from stiff necks, having to look sideways the whole time.

In Germany another ingenious, if improbable, solution emerged. In 1932 the Wismar company produced a railbus which had a completely independent engine and gearbox at each end. Whichever end the driver was sitting, he simply started the corresponding engine and drove from there. At the terminus he stopped that engine and put the gearbox in neutral, walked to the other end, and used the opposite engine. This made it possible to use readily-available Ford engines and transmissions, rather than developing something specific for railway use - making their product a lot cheaper. The resulting vehicle looked very odd, like a pig with a snout at each end. For all that, they were the salvation of many little rural lines. There are several still running today on preserved railways in Germany.

LGB made a model of this odd vehicle, and when I built the garden railway I really had to have one. We called him "Shiny", from the German name "schienenbus" (meaning railbus). At the time I added a DCC decoder in the simplest way possible. And Shiny trundled reliably around the railway, just as happy in either direction just like its prototype.

There are two ways to go about installing a DCC decoder. The simplest is just to put it as a "bump in the wire" between the track power and the motor. Sometimes with older locos, this means separating the track power from the motor, but otherwise it's easy. The disadvantage, though, is that nothing works if the train isn't moving - in particular, the lights. That's what I did for Shiny.

The more complicated alternative is to wire the lights, and any other accessories, to the corresponding outputs of the decoder. This works perfectly, but it's complicated. All LGB locos have a fairly elaborate circuit board to operate lights and the rest from the track power, using strange proprietary connectors. I have replaced them in some engines, but it's a lot of work. The little railbus would be especially difficult, because of its headlights and taillights that change according to the direction of travel.

But I really did want the lights to work when the train is stationary. It just looks so much better at night or in the twilight. And I really wasn't ready to build a replacement for the internal wiring. So I thought of a third approach.

The idea is very simple: separate the motor from the lighting circuit. Connect the decoder output to the motor as usual, but create a fake always-on motor feed for the lighting circuit. This is powered from the lighting power on the decoder, which is always on, via a polarity-switching relay, whose output is taken to the lighting circuit. The relay is bistable, i.e. it remembers its position even without power. It is controlled by the polarity of the actual motor feed, via a couple of diodes. So when the motor runs in the forward direction, the relay switches to the same polarity, and provides full-power  forward voltage to the lighting circuit - which continues even when the motor is turned off and the train is no longer moving. When the train direction is changed, the relay switches to follow it.

Using a relay makes this very easy. It could be done using an H-bridge chip, but that would also require some electronics to remember the last setting - much harder than just soldering a relay onto the board.

I chose to feed the fake power from the always-on auxiliary supply on the decoder, rather than from the lighting output. This means the lights cannot be switched off. I prefer this - in daylight they are invisible anyway, and at night I always want them on.

While I was buying the parts for this, I also noticed on eBay some seated LGB figures, some of whom are now installed in Shiny. I'm sure they're much happier now they can read while the train is stopped at a station or in the sidings.