Simulating Systems and Box Models


Lecture 06

September 6, 2023

Review and Questions

Lake Eutrophication Example

  • Nonlinear system dynamics can result in unexpected behaviors
    • Bifurcations
    • Tipping Points
  • Be careful about planning against particular parameter values or focusing on one process.

Questions

Poll Everywhere QR Code

Text: VSRIKRISH to 22333

URL: https://pollev.com/vsrikrish

See Results

Simulating Systems

What is Simulation?

Simulation: evaluating a model to understand how a system might evolve under a particular set of conditions.

Think of simulation as data generation (or generative modeling).

The model represents a particular data-generating process.

Why Simulate Systems?

  1. System involves complex, nonlinear dynamics that may not be analytically tractable.
  2. Setting up and running a real-world experiment is not possible.
  3. State depends on prior states or states of nearby locations, so need to iterate over multiple spatial or temporal steps.
  4. Need to understand range of system performance across rarely-seen conditions.

Simulating the Shallow Lake Model

For the shallow lake model

\[X_{t+1} = X_t + a_t + y_t + \frac{X_t^q}{1 + X_t^q} - bX_t, \quad y_t \sim \text{LogNormal}(\mu, \sigma^2). \]

we need to simulate because:

  1. inflows \(a_t, y_t\) can change over time (non-steady state);
  2. state \(X_{t+1}\) depends on \(X_t\).

What Do We Need To Simulate The Lake Model?

Poll Everywhere QR Code

Text: VSRIKRISH to 22333

URL: https://pollev.com/vsrikrish

See Results

Lake Model Simulation: Parameters

Variable Value Units
\(X_0\) \(0\) dimensionless
\(\mu\) \(\log(0.03)\) dimensionless
\(\sigma^2\) \(0.1\) dimensionless
\(q\) \(2.5\) dimensionless
\(b\) \(0.4\) dimensionless

Lake Model Simulation: Results

Figure 1: Inflows \(y_t\) for this lake problem simulation.
Figure 2: State of the lake under two different constant release scenarios.

Simulating Multiple Objectives

Simulation also facilitates analyses of multiple outcomes of interest, which can involve tradeoffs.

For example:

  • Electric power system: CO\(_2\) emissions and cost;
  • Reservoir operations: hydropower potential, water supply, flood risk.

Box Models

What Is A Box Model?

Box models are a common building block of simulation models.

Box models are all about mass-balance (mass \(m\)), assume well-mixed within box.

Can be steady-state \((\dot{m} = 0)\) or not.

Steady-State Box Example

Box Models and Simulation

Many simulation models are built by:

  1. Dividing the domain into individual boxes (1-D, 2-D, or 3-D);
  2. Starting from initial box:
    1. Simulate change to stock within box;
    2. Obtain outflow as inflow into adjacent boxes;
    3. Move onto next box;
  3. If needed (e.g. non-steady-state), repeat for each time step.

Box Model Applications

Some applications of box models include:

  • Water balance/hydrologic flow models;
  • Climate models (ocean heat/CO\(_2\) uptake through “box” layers)
  • Airsheds

Box Model Example: Airsheds

Let’s look at a simple steady-state box model of an airshed.

Variable Meaning Units
\(m\) mass of some air pollutant g
\(C\) concentration in box g/m\(^3\)
\(S, D\) source, deposition rate within the box g/s
\(u\) wind speed m/s
\(L, W, H\) box dimensions m

Selecting Box Dimensions

What is relevant for the box dimensions \(L\), \(W\), and \(H\)? Primarily the assumption(s) about mixing.

  • Mixing height: is there an atmospheric inversion which limits mixing height?
  • Homogeneity of input/output flows and emissions.

Steady-State Airshed Box Model

Steady-state box ⇒ \(\dot{m} = 0\).

\[\begin{align} 0 &= m_\text{in} - m_\text{out} + S - D \\[0.5em] &\class{\fragment}{{} = (u WH) C_\text{in} - (u WH) C + S - D } \\[0.5em] \end{align}\]

Solving for \(C\): \[C = C_{in} + \frac{S-D}{uWH}\]

Non-Steady State Box Model

Now let’s assume some process affecting \(m\) depends on time.

For example: let’s say we care about an air pollutant which has a first-order decay rate \(k\), so \(L(t) = -km_\text{box}(t)\).

\[\Rightarrow \dot{m} = m_\text{in} - m_\text{out} + S - km_\text{box}(t)\]

Non-Steady State Solution

\[\begin{gather} &\dot{m} = \frac{d(CV)}{dt} = \overbrace{(u WH) C_\text{in}}^{\text{inflow}} - \overbrace{(u WH) C}^{\text{outflow}} + \overbrace{S - D}^{\text{net emissions}} - \overbrace{kCV}^{\text{mass decay}} \\[0.5em] &\class{fragment}{{} \frac{dC}{dt} = \underbrace{\frac{u WH}{V} C_\text{in} + \frac{S - D}{V}}_{\Large =P} - \underbrace{\left(\frac{u WH}{V} + k\right)}_{\Large =l} C} \\[0.5em] &\class{fragment}{{} \frac{dC}{dt} = P - l C} \end{gather}\]

Non-Steady State Solution

\[\begin{gather} &\frac{dC}{dt} = P - l C \\[0.5em] &\class{fragment}{{} \int \frac{dC}{P-lC} = \int dt} \\[0.5em] &\class{fragment}{{} -\frac{1}{l} \ln\left(P-lC\right) = t + A} \\[0.5em] &\class{fragment}{{} \underbrace{C(0) = C_0}_\text{initial condition} \Rightarrow A = -\frac{1}{l} \ln\left(P-lC_0\right)} \end{gather}\]

Non-Steady State Solution

\[\begin{gather} &-\frac{1}{l} \ln\left(P-lC\right) = t - \frac{1}{l} \ln\left(P-lC_0\right) \\[0.5em] &\class{fragment}{{} -\frac{1}{l} \ln\left(\frac{P-lC}{P-lC_0}\right) = t} \\[0.5em] &\class{fragment}{{} C = -\frac{1}{l} \left(P - e^{-lt}\left(P-lC_0\right)\right)} \\[0.5em] &\class{fragment}{{} C(t) = C_0 e^{-lt} + \frac{P}{l}\left(1 - e^{-lt}\right) } \end{gather}\]

Non-Steady State Solution

\[C(t) = \color{red}C_0 e^{-lt} \color{black}+ \color{blue}\frac{P}{l}\left(1 - e^{-lt}\right)\]

  • Initial condition is transient (decays to zero eventually);
  • Concentration converges to a steady-state solution.

Time-Varying Flows

Can also incorporate more complex in/outflow dynamics:

  • stochastic/dynamic in advection (wind speed);
  • Inflow/outflow concentrations varying over time

Multiple Boxes

To make this into a multi-box model, we can string together boxes to account for fluxes between them.

But this lets us account for spatially-heterogeneous flows.

Example: Two-box “simple” climate models which model the ocean and atmosphere as separate boxes.

Resolution/Complexity Tradeoff

More boxes (higher resolution) typically allows us to simulate more detailed dynamics.

But each box needs to be resolved in sequence to generate fluxes, so more boxes results in greater computational complexity.

Key Takeaways

Key Takeaways: Simulation

  • Simulation: Use model to evaluate system dynamics/outputs under different conditions.
  • Simulation ⇔ Descriptive Modeling
  • Simulation useful as a proxy for “real-world” experiments or future projections

Simulation Workflow

G Initial Box Initial Box Inflows Inflows Initial Box->Inflows Mixing/Bulk System Mixing/Bulk System Inflows->Mixing/Bulk System Fate & Transport Fate & Transport Mixing/Bulk System->Fate & Transport Outflows Outflows Fate & Transport->Outflows Outflows->Initial Box Repeat for Next Time Step Outflows->Inflows Repeat for Next Box
Figure 3

Key Takeaways: Box Models

  • Building block for many simulation models.
  • Boxes are \(n\)-d “chunks” of the system domain.
  • Box Models ⇔ Mass/Energy Balance.
  • Non-Steady State Box Models can often be decomposed into a transient portion and an equilibrium/steady-state portion.
  • Can combine multiple boxes together to create more complex models.

Upcoming Schedule

Next Classes

Friday: Building a Model for Dissolved Oxygen

Homework:

  • HW1 due Friday
  • HW2 assigned Monday (on simulation for dissolved oxygen and risk)