DEV Community

Cover image for [14/52] Fundamentals of Continuum Engineering
Brian Kirkpatrick
Brian Kirkpatrick

Posted on • Originally published at github.com

[14/52] Fundamentals of Continuum Engineering

Definitely something a bit different today! We're going to look at the game "Railway Empire", and I'll try to use it in explaining a key concept in continuum mechanics.

What are continuum mechanics, you wonder? I'm so glad you asked!

A continuum is an arbitrary volume (or boundary) of space characterized by a state space defined via continuous vector field. Continuum mechanics are the mathematical means by which we characterize real-world phenomenon by describing what happens within this space using that vector field. In particular, we want to anticipate how the vector field behaves over time.

This is a very generalized concept, of course! It comes down to two key concepts:

  1. What is the volume of space you are concerned about?

  2. What is the vector field? Or, in other words, what is the "stuff" you are interested in characterizing within this volume of space?

Depending on your answers to these questions, you can come up with insights into a wide variety of studies, from incompressible fluid mechanics to plasma fields to traffic & logistics problems. The underlying mathematical ideas are very powerful, but they can be tricky to wrap your head around.

Maths

Let's start with three interesting, but somewhat complicated, equations.

three equations

  • RTT is "Reynolds Transport Theorem". Basically, the change over time over the volume itself of a particular vector field can be expressed as the sum of two terms: The integral of the change of that field over the volume, and the integral of the change in the field over the flux through the boundary.

It looks crazy, but this is just an application of the product rule from calculus across the boundary as it changes. The big decisions here are, again, what is your vector field f and how does it relate to the changing boundary Omega?

  • CME is the Cauchy Momentum Equation, which captures conservation of momentum of a fluid within a particular volume boundary. Not that different, once you recognize the terms!~

  • NS(ic) is the incompressible, conservative form of the Navier-Stokes equation. And what do you know, there are similarities! The changing quantity (on the right) is some change over time plus the changes across the boundary as the field changes with respect to itself.

Rails

But these are just symbols. Let's take a very simple case here and go back to our game. We're looking at "Railway Empire", something of a successor to the classic tycoon games. This is a Germany map with specific geography and resources, but the mechanics of the game lend themselves to continuum characterizations.

countryside of Frankfurt

There, in this screenshot, is a rural station generating cloth. That cloth is shipped to the nearby city Frankfurt, where it is used to manufacture clothing.

This is a particularly difficult scenario in which you need to get ten cities to a population of 120,000. There's a lot of emphasis placed on understanding and optimizing the flow of goods to achieve this, and it's not easy to do. There are many different goods (a vector space, in fact!) that need to be considered to satisfy the demands of a city to the point where it can grow to be that big.

logistics of Frankfurt

In the case of cloth, the tailor in Frankfurt is also making goods that will be in demand by other cities, so trains may carry cars of that good to adjacent Wurms, Cassel, Cologne, etc. How do we characterize and balance all of these variables?

Logistics

Let's consider a boundary about the city. This defines a volume (if one in two dimensions). Let's focus on a single variable in our vector space at first, clothing. There is some rate at which clothing moves into this boundary (we'll use the variable c at first). Let's say c_in is the rate at which clothing is entering this boundary. There are also goods moving OUT of this boundary, which we will characterize by the rate c_out.

There will also be some rate of resources as generated by the city's factories--we'll call this c_gen. And there will be some rate of resources consumed by the city's residents to satisfy demand--we'll call this c_cons.

Because these resources must be conserved, the overall rate of change (which we want to be either positive or constant) can be described as:

c = c_in - c_out + c_gen - c_cons
Enter fullscreen mode Exit fullscreen mode

rates

We can look up specific details that let us define values for each of these numbers. If 1.2 units of cloth are needed for manufacturing, and 2.1 units are needed for consumption by the city, then (if we assume no cloth leaves the city directly) we know c_in must be about 3.3 units/week.

Fun With Units

We can also look up other variables that let us "solve" for the transportation required to satisfy this 3.3 units/week requirement.

rail goods

In this case, we see (from the four trains delivering cloth from the source to the city) that about 100 days (or about 14 weeks) are required for a round trip per train. With 8 units (or cars) per train, we compute the following "flux" into the city:

4 [trains] * 8 [units]/[train] / 14 [weeks] = 2.3 [units]/[week]
Enter fullscreen mode Exit fullscreen mode

Starting with a known constant, we can compute the rate and use the units in conversions effectively as variables themselves, cancelling them out to reach the appropriate measurement. More importantly, we can replace 4 [trains] with n [trains] because we may want to solve for how many trains are required to satisfy the demand for that city--that is, to increase the flux of this metric across that boundary.

Other Constraints

There is only so much flux the rail network can handle before a "shock" develops. You can start exceeding the capacity of the rail line, with implications for (if time at junctions becomes an issue) how trains can back up into each other. Number of tracks at the station also becomes a limiting factor (or "LIMFAC" as we call it in engineering).

In that case, you need to add other means to enter and exit the city. In this game, that means you need to add warehouses and similar structures. This effectively "expands" the boundary we were considering in our integrals! You can repeat this analysis by considering the resource exchange at the rural stations, where resources initialize, or by considering multiple resources (e.g., having a vector field with more than one dimension).

In Summary

To summarize Reynolds Transport Theorem: To consider the change of a vector field across a changing boundary, you add the change of the field over time with the change of the boundary over the field. This is just a conservation law, though, that we can also capture with the continuity equation:

continuity equation

We expressed these as discrete signed rates in our equation for c, but you'll notice:

c_in - c_out
Enter fullscreen mode Exit fullscreen mode

...doesn't need to be signed in our vector space calculations because we are integrating the flux across the boundary--they're the same thing captured within the integral. Similarly:

c_gen - c_cons
Enter fullscreen mode Exit fullscreen mode

...is simply the change in the integrated quantity over time. (This is particularly relevant in thermal problems where heat is generated and consumed by different reactions that may be taking place.)

You can also imagine how these concepts might reappear--not only in our upcoming "units" segment, but as we address problems in fluids, logistics, and other fields.

Simplified

We have four key concepts we can define to simplify all of the above:

  • There exists some CONTROL VOLUME, which we can think about as the area around a specific city or station

  • There exists some PROPERTY, like an in-game resource (cloth or clothing are two examples) or (in a fluid) momentum, mass, or other conserved quantities

  • There exists some INFLOW and OUTFLOW of this property across that volume. Trains are bringing resource into and out from the city. And moving fluids may be bringing momentum, mass, heat, or other quantities across the changing boundary of our volume.

Finally, REYNOLDS TRANSPORT THEOREM helps us describe (compute, predict) the behavior of this system by tracking how the amount of resources change over time based on what's coming in and going out.

Combine these concepts, and you can manage your resources better within challenging Railway Empire scenarios and make strategic decisions about how many trains you need, how many stations define the boundary of a city's volume, and how cities can efficiently and profitably grow within the game. Cool stuff!

Top comments (0)