Skip to content
Tutorials Center
My learning

Topics

Lesson 42 of 46 ยท Projects and Practice

Project: a repeated-dose drug model

Model drug concentration with a one-compartment ODE, repeated doses and an oral absorption curve, then design a dosing schedule that stays inside a target window.

When you take a medicine, its concentration in the blood rises, falls and builds up again with the next dose. Doctors and pharmacists want the concentration to stay high enough to work and low enough to be safe. This project builds that model from the decay equation of Chapter 5, adds repeated doses, and then asks an optimization question: which dosing schedules keep the concentration inside a target window?

A sawtooth curve of drug concentration over 48 hours with a shaded target window and dashed lines marking the steady-state peak and trough.
Each dose lifts the concentration; elimination pulls it down. After a few doses the curve settles into a repeating cycle between a trough and a peak.

This is a teaching model with made-up drug numbers. It is not medical advice, and real dosing depends on the drug, the patient and a professional's judgement.

What you will learn

  • How to model elimination and repeated doses with dC/dt = โˆ’kยทC and jumps.
  • How to derive the steady-state peak and trough.
  • How an oral dose differs from an injected one (absorption).
  • How to turn a target window into a feasible region of dosing schedules.

Key terms

One-compartment model: the body is treated as one well-mixed volume in which the drug decays at a rate proportional to its concentration.

Half-life (tยฝ): the time for the concentration to fall by half; k = ln(2)/tยฝ.

Steady state: the repeating cycle reached after many equal doses at equal intervals.

Therapeutic window: the concentration range between "too low to work" and "too high to be safe".

Step 1: the model

Let C(t) be the concentration (mg/L). The body removes the drug at a rate proportional to what is there: dC/dt = โˆ’kยทC, so between doses C decays as e^(โˆ’kยทt). A drug with a half-life of 4 hours has k = ln(2)/4 = 0.173 per hour.

An injected dose D (measured as the jump it causes in concentration, in mg/L) adds instantly. If a dose is given every ฯ„ hours, the concentration just after dose n obeys C_n = C_{nโˆ’1}ยทr + D, with r = e^(โˆ’kยทฯ„). Add up the geometric series:

C_n = Dยท(1 โˆ’ rโฟ)/(1 โˆ’ r).

As n grows, rโฟ โ†’ 0 and the steady-state peak (just after a dose) is

C_peak = D/(1 โˆ’ r), with trough C_trough = C_peakยทr.

With D = 11 mg/L, ฯ„ = 6 h and k = 0.173 per hour, r = e^(โˆ’1.04) = 0.354. Then C_peak = 11/0.646 = 17.0 mg/L and C_trough = 6.0 mg/L. The ratio peak/trough is 1/r = e^(kยทฯ„): it depends only on the half-life and the interval, not on the dose.

Python Repeated injections: formula against simulation

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Step 2: pills are not injections

A tablet must dissolve and be absorbed, so the concentration climbs gradually. The standard model adds a second compartment, the gut: dA/dt = โˆ’kโ‚ยทA for the amount A still waiting to be absorbed, and dC/dt = (Fยทkโ‚/V)ยทA โˆ’ kยทC, where F is the fraction absorbed, V the volume of distribution and kโ‚ the absorption rate. The solution for a single dose D is

C(t) = (FยทDยทkโ‚) / (Vยท(kโ‚ โˆ’ k)) ยท (e^(โˆ’kยทt) โˆ’ e^(โˆ’kโ‚ยทt)),

which rises, peaks at t_max = ln(kโ‚/k)/(kโ‚ โˆ’ k), and then falls with the elimination rate. In the next experiment we use made-up values: D = 500 mg, V = 45 L, F = 1, kโ‚ = 1.5 per hour and k = 0.173 per hour, and check the formula against a numerical solution of the two equations.

Python Oral absorption: formula against ODE solver

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Common misconceptions

"Doubling the dose doubles the time it works." In this model doubling D doubles the concentration at every moment, but time above a threshold increases only by about one half-life, because decay is exponential.

"Taking a missed dose twice makes up for it." It overshoots the peak. The model shows that peak size depends on the dose given at once, which is why real advice for each medicine varies.

"The half-life is how long the drug works." It is how long the concentration takes to halve. Whether it is still effective depends on the threshold.

Step 3: design a schedule

Now an optimization question. We want the concentration to stay inside the window 5 โ‰ค C โ‰ค 18 mg/L once the pattern has settled. In steady state that means

  • trough Dยทr/(1 โˆ’ r) โ‰ฅ 5 and
  • peak D/(1 โˆ’ r) โ‰ค 18.

Both depend on the pair (interval ฯ„, dose D); the set of pairs satisfying both is a feasible region, exactly as in the linear-programming lesson (although here the boundaries are curves). Dividing the two conditions shows a hard limit: the peak/trough ratio is e^(kยทฯ„), which must not exceed 18/5 = 3.6. So ฯ„ โ‰ค ln(3.6)/k = 7.4 hours, whatever the dose. With a 4-hour half-life, a dose every 8 hours can never stay inside this window; every 6 hours can.

Python The feasible region of dosing schedules

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Step 4: report

A short summary for a colleague: "With a half-life of 4 hours and a target of 5 to 18 mg/L, doses must be at most 7.4 hours apart. Every 6 hours with a dose raising the concentration by about 11 mg/L keeps the steady cycle between 6.0 and 17.0 mg/L. Assumptions: one compartment, instant injection, no variation between patients. Limits: real patients differ widely in k; a 20 percent change in k moves the cycle noticeably (a sensitivity analysis would quantify this)."

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. A drug has a half-life of 4 hours. What is k?

    k = ln(2) / 4 = 0.693 / 4 = 0.173 per hour.
  2. 2. In steady state with dose D every tau hours and r = exp(-k tau), the peak concentration is:

    Summing the geometric series of decayed doses gives D/(1 - r).
  3. 3. What does the ratio peak/trough depend on?

    peak/trough = 1/r = exp(k tau), independent of the dose.
  4. 4. The window is 5 to 18 mg/L and the half-life is 4 h. Which interval can never work?

    The maximum interval is ln(3.6)/k, about 7.4 hours, so 8 hours exceeds it.
  5. 5. How does oral absorption change the concentration curve compared with an injection?

    Absorption spreads the entry of the drug over time, so the concentration climbs gradually.

Summary

  • Elimination is dC/dt = โˆ’kยทC; repeated doses add a geometric series.
  • Steady state: peak D/(1 โˆ’ r), trough Dยทr/(1 โˆ’ r), ratio e^(kยทฯ„).
  • Oral dosing adds an absorption compartment with a delayed, lower peak.
  • A target window defines a feasible region of schedules, with a hard limit on the interval.

Next: Practice set: six modelling problems