The last two lessons gave you tools: separation of variables (3.3 Separable Equations) and the integrating factor (3.4 Linear First-Order Equations & Integrating Factors). Both start from an equation that someone has already written down. This lesson is about the step before that, which is where most of the real difficulty lives: getting the equation. A tank, a coffee cup, a skydiver and a circuit look unrelated, but one short recipe produces all four equations, and three of them turn out to be the same equation under different names.
That matters for simulation. A fluid solver is a bookkeeping device: for every cell, the change in what the cell holds equals what flowed in minus what flowed out. If you can do that for one tank, you can read a finite-volume code. We do it for five systems, then check our work by looking at units.
Transcript
- Until now someone handed you the equation. This lesson is about writing it. One recipe: the rate of change is what comes in minus what goes out, with units written first.
- A tank holds 100 litres of brine at 20 grams per litre. Brine at 50 grams per litre pours in at 6 litres a minute, and the stirred mixture leaves at 4. So 300 grams of salt arrive each minute, and the volume grows by 2 litres a minute: V equals 100 plus 2t.
- Take the salt mass m, because mass is what is conserved. In: 300 grams per minute, from the inlet. Out: the leaving mixture has the tank's concentration, m over V, so salt leaves at 4 m over V. Every term is grams per minute.
- This is linear, so the integrating factor works: mu is 50 plus t, squared. Divide the mass by the volume and the concentration climbs from 20 toward 50: 41.11 at 25 minutes, 46.25 at 50, 48.89 when the tank is full at 100. It crosses 45 at 40.86 minutes.
- The trap is writing the concentration equation directly. With m equal to c V, the product rule gives m prime equals c prime V plus c V prime. That second term is dilution: a filling tank spreads its salt thinner. Combine it with the outflow: c prime is 6 over V times 50 minus c.
- A mug loses heat in proportion to its gap from the room. Coffee at 85 degrees, then 65 ten minutes later in a 21 degree room: the gaps 64 and 44 give k equals 0.03747 per minute, a time constant of 26.7 minutes. It reads 51.25 at 20 minutes, hits 55 at 16.9, and levels off at 21, where out equals in.
- A falling body: m v prime is weight minus drag. Linear drag is b v; quadratic is half rho C d A v squared. At steady speed v prime is zero, so drag equals weight. Below it weight wins; above it drag wins. An 80 kilogram skydiver: 56.6 metres per second, 204 kilometres an hour. Give linear drag that same terminal speed and b over m is 0.173.
- Both laws on one set of axes. Without drag the diver would reach 49.1 metres per second at five seconds and 98.1 at ten. Quadratic drag gives 39.6 and 53.2, reaching 95 percent of terminal speed at 10.6 seconds. Linear drag with the same terminal speed arrives more slowly: 32.8 at five seconds, 46.6 at ten.
- A resistor and capacitor in series with a battery. Kirchhoff: V in equals R i plus v. The capacitor: i equals C v prime. Together, R C v prime plus v equals V in, and ohms times farads is seconds.
- With 4.7 kilohms and 220 microfarads, R C is 1.034 seconds. A 12 volt step reaches 7.59 volts after one R C, 10 volts at 1.853 seconds, and 90 percent at 2.381 seconds.
- Now line them up. The tank, the mug, the tracer room, linear drag and the capacitor are one equation: y prime is one over tau times the target minus y.
- The target is set by what pushes. The rate, one over tau, falls as there is more stuff to move: a bigger tank, mug, ball or capacitor has a longer tau and is more sluggish. Solve one and you have solved all five. Quadratic drag stays out.
- Units catch mistakes. Someone writes v prime equals g minus b v. Acceleration is metres per second squared, but b v is kilograms metres per second squared, a force. The equation adds an acceleration to a force. Divide by m and every term agrees. A unit check cannot see a missing half or a wrong sign.
- Quadratic drag, half rho C d A v squared, is what limits a skydiver or a plane. A finite-volume fluid solver is this lesson at scale: every cell's mass, momentum and energy change by flux in minus flux out. Rate of change equals in minus out. Units first.
The balance law
Take a quantity that is conserved apart from what crosses a boundary: salt in a tank, heat in a mug, momentum of a falling body, charge on a capacitor. Over a short time ,
Dividing by gives a balance law:
The art is in writing each rate. A rate in is usually given: a pump delivers so many litres per minute. A rate out usually depends on the state , because what leaves is whatever is currently inside; that dependence is what makes it an ODE.
A mixing tank whose volume changes
A tank holds L of brine at g/L, so it starts with g of salt. Brine at g/L is pumped in at L/min, and the well-stirred mixture is pumped out at L/min. The tank can hold 300 L.
Last lesson’s tracer room had a fixed volume. Here the tank gains L/min, so
and the tank is full at min. The unknown with the cleanest balance is the mass of salt, because mass is what is conserved. Build it term by term, with units.
- In: g/min.
- Out: the stirred mixture leaving has the tank’s concentration , so salt leaves at g/min.
So
Every term is grams per minute. This is linear first-order, , with and , so it is the integrating factor’s job (last lesson’s tool, because the unknown appears to the first power). The coefficient depends on , which is the new feature. The integrating factor is
so , hence . The start gives , so , and
At , and min the salt mass is , and g, and the concentration is , and g/L. The concentration reaches 45 g/L at min, when the volume is L.
The trap is writing the concentration equation directly. With you must differentiate the product, and the growing volume contributes a term:
The outflow and the dilution combine to : filling a tank dilutes it as surely as draining removes salt. The concentration relaxes toward at a rate that falls as the tank fills, so the gap decays algebraically, as , not exponentially. At both sides of equal g/L per min.
Newton’s law of cooling
A mug of coffee loses heat to the room. Let be its temperature and the room’s. The heat stored is (mass times specific heat times temperature), and the only way it leaves is across the surface, at a rate we model as proportional to the temperature difference, in watts, where is a heat-transfer coefficient in W/(mK) and is the surface area. The balance is
Units: is W/K, is J/K, and their ratio is . This has the shape of last lesson’s tracer equation , with solution . As a balance, “in” is the constant and “out” is , which grows with until the two are equal.
Fitting . Suppose a 0.25 kg mug of coffee, treated as water, reads C in a C room, and C ten minutes later. The gaps from the room are and , so and , a time constant min. Predictions: C, C, and the coffee reaches C at min. With J/(kg K) (rounded), implies W/K, or W/(mK) for an assumed area of : plausible for air. These readings are illustrative, not measurements.
Falling bodies: linear and quadratic drag
A body of mass falls. Newton’s second law is a balance law for momentum: is the sum of forces, gravity down and a drag force up that depends on the speed.
Linear drag. For slow motion through a thick fluid, drag is proportional to speed, , with in kg/s. Then
Each term is a force: is (kg/s)(m/s) = kg m/s, like . Dividing by gives , linear, so the integrating factor gives from rest.
Terminal velocity without solving. At a steady speed , so :
The balance also shows why the speed settles: below drag is smaller than gravity, so ; above it drag is larger, so . The correction always points back toward and is proportional to the distance from it, so the approach is exponential with time constant .
A real case: a steel ball in glycerin. Stokes’ law gives when the Reynolds number is below about one. Take mm, steel , glycerin and Pa s (all rounded; glycerin’s viscosity is very temperature-sensitive). Then kg and kg/s. The driving force is weight minus buoyancy, so m/s; forgetting buoyancy gives m/s, 19% too high. A balance law must list every force. The time constant is ms, and , so the linear-drag assumption was consistent.
Quadratic drag. At high Reynolds number drag comes from pushing fluid aside and scales with : with (explained below). The balance is
Terminal velocity is again : . The equation is not linear in , so the integrating factor does not apply. It is autonomous, the right side depends on only, so it is separable, and that is lesson 3.3 Separable Equations‘s tool. In fact it is exactly the equation solved there. Divide by and define :
Choosing the tool is a decision. If the unknown appears to the first power, , use the integrating factor ( may depend on , as the tank’s did). If the right side is a nonlinear function of alone, as with , separate.
The RC circuit, and the sameness
A resistor and capacitor are in series with a source . Two laws build the equation.
- Kirchhoff’s voltage law: the voltages around the loop sum to zero, so , where is the current and the capacitor voltage.
- The capacitor law: charge on the plate is , and current is the rate charge arrives, so .
Substituting:
Units: ohms times farads is seconds. From , .
With kΩ, µF, s. For a V source the capacitor reaches V at , V at s, and 90% of the way at s.
Now line up what we have built:
| System | Unknown | Target (where it settles) | Rate |
|---|---|---|---|
| Constant-volume tank | concentration | ||
| Cooling mug | temperature | ||
| Tracer in a room (last lesson) | concentration | ||
| Linear-drag fall | speed | ||
| RC circuit | capacitor voltage |
Quadratic drag is not in the table: its out term is nonlinear.
At the defaults the tank has g/L and min; cooling has min; linear drag settles at m/s with s; quadratic drag at m/s with local time scale s; the RC circuit has s. The equilibrium moves only when a parameter in its formula moves; sets the speed. The dot marks 63% of the way, reached at by the linear models. With the quadratic model, click the left edge of the plot and slide the starting value to m/s: the out term is against an in term of , so the speed falls at m/s (a parachute opening) onto m/s.
Compound interest: discrete and continuous
A bank balance with annual rate is a balance law too: it grows at a rate proportional to what is already there, , in dollars per year, and is per year. The bank, though, updates in steps. If it compounds times a year, each step multiplies by :
That is exactly an explicit Euler step of size on , and continuous compounding is the exact solution . For a starting balance of 1000 at over 10 years:
| Compounding | Balance after 10 years (from 1000) |
|---|---|
| annual () | 1628.89 |
| monthly () | 1647.01 |
| daily () | 1648.66 |
| continuous | 1648.72 |
The playground below reproduces the annual, monthly and continuous rows. Steady deposits make , the linear equation again, with solution ; for per year the balance after 10 years is . Unlike cooling, the state flees its “equilibrium” .
Units and dimensional checks
Every term in an equation must have the same dimensions, and the argument of , or must be dimensionless. Suppose a learner, copying the linear-drag force law, writes
Check the units: and are m/s, but is (kg/s)(m/s) = kg m/s, a force. The equation adds an acceleration to a force; the leftover factor is a kilogram, so it needs . The correct has every term in m/s.
A numerical test with kg would not catch this error, since dividing by one changes nothing; the units catch it at any mass.
Units also constrain the answer before any fluid mechanics. Built from , and , the only combination with units of speed squared is , so ; experiment supplies the dimensionless number, .
Quadratic drag in a real fluid
Playing with the numbers
This cell checks the tank solution against RK4 and runs the compounding-as-Euler loop. Edit the flow rates and watch the approach to change.
RK4 and the formula differ by , and g at , , ; the concentrations are , , g/L. The Euler loop prints and against .
Exercise: build the models
The exact tank answer g comes from the integrating factor ; verify it by hand.
Problems
A tank holds L of pure water. Brine at g/L flows in at L/min, and the stirred mixture leaves at L/min, so the tank is draining. (a) Write the volume and the salt equation for , with units. (b) Solve it. (c) Find the salt mass and concentration when the volume has dropped to L, and say what happens to the concentration as the tank empties.
Show worked solution
(a) L, empty at min. The balance is , in g/min.
(b) , so . Then . Since , we get , hence
(c) At ( min): g, so g/L. Check with RK4: g. As , g/L: the last of the tank is nearly all newly arrived brine.
An RC circuit has in ohms (volts per ampere) and in farads (coulombs per volt, i.e. ampere-seconds per volt). (a) Using only these units, decide which of , and can be a time constant. (b) For and , how long does a charging step take to come within of its final value? (c) A student types C = 47 instead of C = 47e-6. What does the code now report, and why did a unit check on the formula not warn them?
Show worked solution
(a) has units . The other two do not reduce to seconds: has units and is its reciprocal. Only is a time.
(b) The charging step is , so within of final means , i.e. . Here s, so s.
(c) With the code computes s, about days, not s: a factor of . The formula is dimensionally fine for any numbers, so the equation passes; the error is in the values (microfarads entered as farads). Store quantities in SI base units, and sanity-check the order of magnitude of every answer.
A temperature probe obeys with . Starting at C, it is put into an oven whose temperature rises as (in C, in minutes). (a) Solve for . (b) Once the transient fades, how many degrees and how many minutes does the probe lag the oven? (c) What are and the lag at min?
Show worked solution
(a) Write . With : . Integrating by parts, , so . With and : , and
(b) The gap tends to C, a delay of min: .
(c) C (RK4 gives ) against an oven at C: a lag of C, still short of C.
Where this goes
3.8 Autonomous Equations, Equilibria & Stability explains why is stable (the out term rises faster than the in term), and 3.6 Exact Equations & Substitutions extends the equations you can solve exactly.
Key Takeaways
- A balance law is . Write the units of each term first: all must be [units of ] per time.
- In a mixing tank with changing volume, use mass as the unknown; converting to concentration adds a dilution term, giving with a rate that falls as the tank fills.
- Newton’s cooling fails for non-uniform objects, changing convection, radiation and evaporation; a straight line of against is the test.
- Terminal velocity comes from : for linear drag, for quadratic. It is stable: above it the out term wins, below it the in term wins.
- Tool choice: linear in the unknown means integrating factor; a nonlinear function of the unknown alone means separation.
- The tank, mug, tracer room, linear drag and RC circuit are all : target from what pushes, from how much there is to move.
- Compound interest is explicit Euler with on .
- A dimensional check catches at any mass, but not missing dimensionless factors; follow it with limits and a numerical run.