Some Words About Physics, Python And The World In General

Engineering, Politics And How To Save The World

When you ask yourself or others to make a list containing the big problems that mankind is facing, you will probably find these among them:

Note that this is an unordered list, so the position has no specific meaning. Many of these problems are tied very closely together for example: hunger and lack of clean water are often due to poverty which is often caused by the lack of education, terrorism/war and or disasters. However the point of this post is to convince you that most of these problems are technically already solved we only lack the political willpower or solution to implement the solution.

Technically Solved

Lets have a look at the overpopulation and hunger complex. Both seem to be closely linked in peoples minds. We are to many, the world can not feed so many people. At the same time we waste almost as much food in the world as is consumed in Africa (222 million tonnes wasted vs. 230 million tonnes consumed). We do not have a food production issue we have a food distribution issue combined with a quality of production issue in some developing countries. Considering that most of the food is produced and wasted in the developed countries however, mainly a distribution issue. This however means we have technically solved food production. The problem then must be poverty, if the people would have enough money they could buy the food.

So what about poverty?

Poverty is so apparent because of the distribution of wealth, the richest 1% of the people now own about 50% of the world. And the rest of the distribution is similarly unjust. As demonstrated by the hunger problem, it is not really the case that we do not have enough for everybody, we just do not know how to give it to everybody. Our attempts to do so have so far failed and ended in totalitarianism instead of communism. Please note, this is no attempt to make any claims that capitalism is inherently bad. I believe quite the opposite, that is, that capitalism has brought as very far – to where we are now – but we still need to evolve it. Nevertheless, we have plenty of ideas of how to fix the problems we have currently in capitalism. There are proposals to change the current money and banking regime and change taxation in ways to keep the rich from owning 50% of the world. Tackling these fundamentals of capitalism, money and property seems impossible (at least without pitchforks). Yet there are numerous example where it has been done before, our money regime changed last in 1971 due to decisions made by the U.S. government. After it was only introduced in the 1940. An example for seemingly impossible taxation can be found in post war Germany where the actual wealth of a people was taxed. It was officially planed as means of to redistribute wealth. And we are not speaking about small amounts: up to 50% of a persons wealth could be redistributed spread over 30 years. Imagine that. One might think that this was only possible due to Germany‘s isolated position after the war. However the law was based on a Finnish law and Finland was not at all isolated after the war. So again the conclusion could be that we technically know how to solve the problems of capitalism but we just can not implement them politically. Anyhow, wealth distribution is certainly not the only cause of poverty.

What about war and terrorism?

This is one of the things I really struggle with. Is there a technical solution to war? For many cases there actual might be one, however other conflicts seem impossible to resolve. Will the Palestinians stop to hate the Israelis once their economic situation is better? Would the Israelis allow the situation to become better? Will this end the terror? Impossible to answer. We know that there are basically no wars in modern day and age that lead to an economically better situation, so one might assume that there are no wars in capitalism but this is obviously not true. Never the less, the number of people involved in wars is on an historic low (video), so maybe capitalism is also winning on this front. Terrorism however seems to be another shoe. It seems to be the case the the western world constantly looses its battle against terrorism and the more wars we fight the more terrorists we create. And since the modern terrorism is basically founded as an answer against the wars the US and its allies are fighting in the middle east this should not surprise anyone. In other words, terrorism is the evolutionary answer to war. We can not win against it with war. However there are plenty of ideas of how to fight against it, which again we do not implement because we can not bring it on politically. So lets look at some other fields. (Note: I should link to something about this, however I don‘t feel like I have proper sources. A lot of my thinking however is based on ideas from this awesome podcast)


There is no doubt that diseases are a problem – admittedly one I do not know much about. I know we have a problem with a shrinking number of effective antibiotics. I have seen how quickly a virus can get out of control (Ebola) and how infectious mutations (SARS/MERS) can be. However we have also seen how quickly we actually can develop a vaccination and discover even new classes of antibiotics or mechanisms of defeating harmful bacteria. So the real question might be why did we not manage to develop these things before a serious crisis was around the corner. The answer is most of the time given in the form of capitalism: it is usually not effective for a company to develop a treatment that heals quickly. If you develop a new antibiotic drug it will be given to the patient for 1-2 weeks an that is it. A vaccine is even worse, a one time shot. If you develop a new pain medication, a new cancer or depression treatment you will likely make profit from the same patient for years. You can just not sell an antibiotic so expansive that it has the same return of investment. So where do you invest your money? This makes the pharmacy industry look like bad people when in fact they are only doing the same as every other business. However we have plenty of ways to influence what the big industries are doing, it all comes down to the right incentives – as it always does in capitalism. You want to keep your patents for your most grossing drug for two years longer? No problem develop something that helps against on of the things on this list we update yearly and you can! Who can implement such a thing? Right, politicians. So what about the other big problem...

Climate Change / Availability Of Energy

This is a problem where we definitely do not have the technical solution yet right? Why in the world would everybody be working on a solutions otherwise? Wrong. I wrote at this at length in a previous post. In review: you could harvest all the energy the world needs in a 500 km square in Africa. One would need to build thermo solar power plants, which would feed the power to methane production plants. The methane production needs CO2 and Water as input. The CO2 can be taken from the air and the water might be gathered through desalinization of ocean water. The compressed methane can then be shipped or pipelined in the world to be used like conventional natural gas. Most of the infrastructure is already there, as are natural gas powered cars, buses, heating systems and power plants. The solar plants, desalination plants and even the methane plants already exist. Just to make this clear, this is not a partial solution. If implemented this will be a CO2 neutral way of supplying the world with easy to store and transport energy until the sun burns out. This could put an end to climate change. At least to further damage. Anyway, it is obviously not about to happen. Instead we have climate conference after climate conference no end insight. We also develop all kinds of fancy plans and complex infrastructure to solve it. So again, the problem is technically solved we just can not implement it politically.

But The Most Important Problem Is … !

I am more or less doing research in the energy sector. Therefore I usually argue like this: Availability of (cheap) energy is the most important problem we need to solve because it will solve all other problems. All we do is consuming energy, all things that make our life easier are consuming energy. We want everyone to have clean drinking water, no problem if we have cheap and "clean" energy we can just build a wastewater treatment plant or a desalination plant. We need more food? No problem we just build a greenhouse, temperature and light controlled and we are good. War? Mostly due to oil nowadays, once we need no oil anymore: gone. Disease? Once people do not need to care about oil and war they have more time to work on disease prevention … and so on. And you will find a lot of other very clever people arguing the same way for energy. Or for war, or poverty, or hunger …  In fact all of these problems are somehow connected, you can not solve one without the other. This does not mean that there is one root problem connecting them, they are all real problems on their own. However the connection between most of them is politics …

So Should We All Become Politicians Then?

Definitely not. While there are some former scientist in politics, some even from natural sciences, I believe not all of us are suited for a job in politics. However most researchers should radically change the view on how to do research. There is one part of science which is tasked with finding out new things about nature, sometimes very fundamental things like the particles that make up the universe, sometimes more about tiny details like how two very specific molecules interact. The another part of science however is tasked with finding solutions, often to the problems discussed here or related ones, or even completely unrelated ones. There might not always be a clear distinction between these roles and the same researcher or group may switch between both of them rapidly. However most of the time it is very clear if the outcome is a solution to a problem or a new fact about "how things work". Now every time you develop a solution to something you have to consider the politics that might be needed to implement your technical solution – because if your solution is political not possible to implement it is just not a solution. For other fields this kind of thinking has become very common, every time a new engineering solution is developed someone will check if it is cost-efficient. From the engineering standpoint this is not necessary if it technically works, the problem is solved right? Except it isn‘t because if it is not a profitable solution for a company it will not be adopted. The same is true if the solution is not feasible in a socio-political sense. Therefore in the same way engineering and many other disciplines have adopted economic theory we need to adopt socio-political thinking to test if our solutions are actual solutions to a problem not just technical ones. In many ways this means to just adopt more from economic theory than just cost calculations, because at the core economics deals with the incentives people have for making their decisions, it just happens to be the case that incentives often come in the form of money. Nevertheless incentives and rules are what politicians can use to make a difference, however very few technical solutions we have come with a bundle of incentives and rules that need to be in place in order for the solution to work right.


To give a more concrete example, we just saw the introduction of distributed energy storage for the mass market. However the battery technology is not yet cheap enough or good enough to go off grid. But since we have a lot of solar and wind energy in certain countries, resulting in high price fluctuations for power, these batteries start to make economic sense in a way that they can be cost effective. Which is why we will most probably see them adopted in many places. Once we have enough batteries they will however begin to influence the price of electricity, because they dampen the price fluctuation we currently see, by buying power when it is cheap and selling it when it is expensive. Which means once we have enough batteries the fluctuations will reduce considerably if not vanish, which is very beneficial for society because it means energy is always available in enough magnitude. We have to remember however that these very fluctuations are what made the batteries worth buying in the first place. Economic theory now suggest that people will stop buying batteries because it is no longer profitable. The problem however is that the cost effectiveness of the batteries was calculated over many years, so once at the point that the price fluctuations begin to shrink, it is already to late for all the buyers of batteries. Economic theory again suggest that we all try to optimize our profit, how could you do that if you have bought a battery? Fairly easy, you just try to sell as late as possible when the price starts to rise, because as long as no one is selling the price will continue to rise. So there is now an incentive and a possibility in place for all the battery owners to increase the fluctuations instead of decreasing them. There are several reasons why you can not play this waiting game indefinitely, first of all at some point the grid will have a blackout. Second, the regulated power plants will kick in and supply the power needed. Third, if enough of the other players sell before you, you will not make your needed profit. While the third reason might keep the whole situation in check, by keeping everyone on its toes while waiting, it does by no means guarantee stability. Because now everyone is looking for a change in the speed of the rising price, because a slower rising price suggest the others have begun to sell. So now a slowdown might trigger an avalanche of sales, flooding the market. So instead what we need is a regulations that makes it very unlikely or downright impossible for the owners of batteries to engage in this kind of speculation, while still giving them an incentive to buy a battery helping to stabilize the power grid. It is exactly this kind of political solution that is needed for the technologies to succeed and be of value for all of society. We engineers are problem solvers, however we leave some of the toughest problems to figure out for the politicians – even though we know they fail to solve them a lot of the times. This has to change.

mpi4py Allgatherv Example

My current work involves some agent based simulation written in Python. I now wanted teach it some new tricks including running on multiple cores. While my normal approch for multithreading in Python is to just run several simulations in parallel to get some average, I decided it would now make sense to also have single simulations run on multiple cores. One reason for that was to make it scale more easily on the computing cluster, the other was that I assumed it would be quite easy with the agent based stucture.

For the same reasons I decided to use MPI (mpi4py): it seamed like a good fit for an agent based model (agents sending messages around) and it was available on the computing cluster. It turned out that in the end I did not use any mpi code in the agents to keep them more flexible.

Anyway, the simulations is structured in the following way: on each core/process a controller is initalized which handels not only the communication but is also in charge of the agents. This is a good fit because the simulations involves global state as base of the agents decisions.

I decide in the beginning which controller controlls which agents. This might lead to some unused processing time during the sync between the controllers because they might have to wait to get the globals state. But since each agent has a lot of data attatched, I assumed it would not make sense to depatch the agents to a different process every timestep. This would mean to shuffle around big python objects and therefore presumeably slow.

Instead only the global state is shared between the controllers. I am not sure if this is the best solutions since I did not try any other but it turned out to have a nice structure and work quite well.

One problem I sumbled upon was the that I could not gurante that each group of agents would be the same size, because when you want to simulate 100 agents on 16 cores it does not add up. This meant I could not use the normal allgather methods of MPI to collect the state but had to use allgatherv which can deal with the different sizes. Sadly there is no documentation about allgatherv in MPI4PY. With some googling I worked out an example of how it works I wanted to share so here it is:

from mpi4py import MPI
import numpy as np

rank = comm.Get_rank()
mpi_size = comm.Get_size()

# work_size = 127  # arbitrary prime number
work_size = 100  
work = np.zeros(work_size)

base = work_size / mpi_size
leftover = work_size%mpi_size

sizes = np.ones(mpi_size)*base
offsets = np.zeros(mpi_size)

start = offsets[rank]
local_size = sizes[rank]
work_local = np.arange(start,start+local_size,dtype=np.float64)

print "local work: {} in rank {}".format(work_local,rank)

summe = np.empty(1,dtype=np.float64)


print "work {} vs {} in rank {}".format(np.sum(work),summe,rank)    

Power to Gas in Africa

You may know this famous image illustrating that we would only need a "tiny" fraction of the desert in Africa to be fitted with solar thermal power plants to meet the electricity demand of the world (diploma thesis). Problem is how to get the energy from there to the world. If only there would be a high energy density storage medium that is easy utilize and transport.

Well, you see there is. Gas. Methane gas for example. While some try to get methane gas from the bottom of the ocean, there is technology to produce it from water. In essence you first split water in hydrogen and oxygen and then combine the hydrogen with CO2 to get methane. More or less the only other thing you need to do that, is electricity, which is why this technique is called power to gas.

The problem with power to gas is, that it has a very bad energy efficiency when you compare what you put in to what you get out. For high compression (200 bar), which you need in order for easy transport, you only get about 49% efficiency. In other words less then half of the electricity put in to the process would not end up in the produced gas. To put that in perspective a coal plant reaches about 33%, a gas plant about 60% and a diesel engine up to 50% (1,2). That in turn means that for the whole process of harvesting energy in Africa and using it for transportation and electricity we might and up with only 30% efficiency. Terrible isn‘t it?

No it isn‘t. Because the solar energy which radiates on Africa at the moment is not used at all. But we should compare it to other measures of energy production, and efficency wise they are probably ahead. But keep in mind that once installed you would get solar energy allmost for free with no environmental demage done while harvesting it. No nuclear waste, no added CO2 – you only have the investment cost and the maintainance costs of the plants.

Ok, back to the idea. Imagine we would build a lot of solar-thermal power plants in Africa and produce methane gas with them. We could provide the world with energy and the world would not even have to change! Well it would shake up the political landscape. Maybe. A little bit. We can use the gas for heating, for mobility and for producing electricity. All CO2 neutral with an allmost infinite supply for the future. And all the technology to do it allready exists.

The worlds energy demand should be about 20,000 TWh/y. To produce that in methane gas we would need about three times of that in electricity, assuming that allmost all is needed as electricity (which it isn‘t but it is the worst case). That makes 60,000 TWh/y. Assuming the same things as in the image above that would mean a square with an edge length of 500km. Or four times the size of the biggest square in the image.

So what would it cost? Let‘s do a very rough estimation here: The Ivanpah Solar Power Facility is the biggest solar thermal power plant today. It it cost $ 2.2 billion and produces about 1 TWh/y. This would mean the total cost for building the power plants would be about $132 trillion. Let‘s work with that, even though the true cost of building 60,000 power plants would for sure be different because of scaling effects and infrastructure that would be needed besides the plants.

How much are $132 trillion? That is about 2 times the global GDP. A lot. But if you consider that this would solve the energy problem of the world – it might be cheap. In a rough estimate the US energy consumption amounts to allmost 1 trillion dollar per year alone. Solving the worlds energy problem with the all the worlds money in 2 years. Seams worth it.

Would‘t this be Desertec all over again? Somehow. The biggest problems Desertec had were political. You can not simply force Africa to be a stable part of your electricity grid. The problem with power grids is that they are much more unstable then they look like, so extending them geographically and making their stability dependent on a far away region is not a good idea.

The difference with gas would be that it is easy to integrate, as we would not need new powerlines. And while we would still be dependent on Africa to sell us gas (as we are now from Russia for gas and Saudi Arabia for oil) we can much more easily store gas for emergencies (as we do now). If we would couple our grid instead the shutdown would be immediate. Back to the bright side…

Isn‘t that amazing: we could meet the worlds energy demand with easy to utilize gas. For the rest of the lifetime of the sun. By only using a fraction of the land available in Africa.

The depressing thing is what we do instead…

 page 1 / 8  older