As an economic naif this looks to me like one of the many, many ideas in economics that start with 'If all other things are equal...' - assuring a certain disconnection from reality right from the beginning.
So rather than textbook simulations, wouldn't it be more useful to try find examples from the real world?
Any theory that's so fragile it can't survive real world trading conditions doesn't deserve to be taken seriously. Alternatively if it really does work, being able to point to some reality-based evidence for it would help define the boundary conditions of any simulation.
Assumptions in Example 3 ... Full employment - if one or other of the economies has less than full employment of factors of production, then this excess capacity must usually be used up before the comparative advantage reasoning can be applied. ... Perfect mobility of factors of production within countries - this is necessary to allow production to be switched without cost. In real economies this cost will be incurred: capital will be tied up in plant (sewing machines are not sowing machines) and labour will need to be retrained and relocated. This is why it is sometimes argued that 'nascent industries' should be protected from fully liberalised international trade during the period in which a high cost of entry into the market (capital equipment, training) is being paid for. Immobility of factors of production between countries - why are there different rates of productivity? Capital includes production technology and know-how. If it can be moved between countries then the production capabilities of the countries will change. Similarly the movement of labour will change that factor cost and productivity. Perfect transnational mobility of factors of production would invalidate comparative advantage. Imperfect transnational mobility reduces the mutual benefit of trade. Perfect competition - this is a standard assumption that allows perfectly efficient allocation of productive resources in an idealized free market.
This is terribly important as I think it clarifies my main problem with the issue (and which prompted my comment.)
The success of teaching Comparative Advantage rests on a beautifully simple model, a little bit of game theory, nothing more. From that (if you read the mises link I put in my other comment) they are happy to build a whole assertion of "good things."
The problem with free mobility of capital is that it doesn't disrupt the generic assumption that free trade makes for a larger "total sum of wealth" but that it has the potential to massively destabilize the utilisation of that wealth, leaving whole countries effectively unemployed.
This doesn't bother the rich, but it should bother the rest of us.
Seeing the power of a simple model, badly applied in all these economics classes and textbooks, I wondered, what if we can build a simple little model that demonstrates (or not) my fears about what the movement of capital means for the stability of the system. It could be a powerful tool for helping people think carefully about trade.
In this way we might raise the well being of all individuals despite differences in relative productivities. In this description, we do not predict that a result will carry over to the complex real world. Instead we carry the logic of comparative advantage to the real world and ask how things would have to look to achieve a certain result (maximum output and benefits). In the end we should not say that the model of comparative advantage tells us anything about what will happen when two countries begin to trade, instead we should say that the theory tells us some things that can happen.
Comparative advantage is important as a rebuttal to naive zero-sum thinking, not as a predictor of performance in a free-trade scenario which does not conform to the assumptions.