Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

0.5 Computational Preparation and Readiness Project

CCD studies combine mathematical models with numerical simulation and optimization. You do not need advanced software-development experience to begin, but you should be comfortable reading and modifying short computational scripts.

Minimal MATLAB or Python preparation

Before continuing, you should be able to:

A simple computational workflow

A basic modeling study follows a repeatable sequence:

  1. Define parameters and initial conditions.

  2. Write the model equations.

  3. Simulate the model and plot the results.

  4. Evaluate one or more performance measures.

  5. Refine the model, parameters, or numerical settings.

Define parameters, write model equations, simulate and plot, evaluate performance, and refine.

A basic workflow for modeling and simulation. Later CCD workflows add optimization solvers, gradient computation, uncertainty studies, and validation.

Python example

The following script defines a mass–spring–damper model and integrates it numerically. It is a preparation exercise rather than a full CCD implementation.

import numpy as np
from scipy.integrate import solve_ivp
import matplotlib.pyplot as plt

m = 1.0
c = 0.4
k = 4.0


def model(t, x):
    u = 1.0
    x1, x2 = x
    dx1 = x2
    dx2 = -(k / m) * x1 - (c / m) * x2 + (1 / m) * u
    return [dx1, dx2]


sol = solve_ivp(model, [0, 10], [0, 0], max_step=0.02)

plt.plot(sol.t, sol.y[0, :])
plt.xlabel("time")
plt.ylabel("displacement")
plt.show()

The script performs four basic tasks:

MATLAB example

An analogous MATLAB script is

m = 1.0;
c = 0.4;
k = 4.0;

f = @(t,x) [x(2);
           -(k/m)*x(1) - (c/m)*x(2) + 1/m];

[t,x] = ode45(f,[0 10],[0;0]);

plot(t,x(:,1))
xlabel('time')
ylabel('displacement')

Both implementations express the same mathematical model. The syntax differs, but the modeling workflow is unchanged.

Computing a discrete performance measure

Suppose the continuous control-effort objective is

J=0Tu(t)2dt.J=\int_0^T u(t)^2\,dt.

After sampling u(t)u(t) on a time grid, a trapezoidal approximation can be computed in Python with

J = np.trapezoid(u**2, t)

or in MATLAB with

J = trapz(t, u.^2);

This simple pattern—simulate a trajectory, compute a performance measure, and compare alternatives—later becomes part of a numerical optimization loop.

Readiness mini-project

Before moving to Chapter 1, model and simulate a mass–spring–damper system and identify how its quantities would appear in a CCD formulation.

Suggested tasks

  1. Choose values for mm, cc, and kk.

  2. Write the second-order ODE and convert it to first-order state-space form.

  3. Select initial conditions and a force input u(t)u(t).

  4. Simulate displacement and velocity.

  5. Plot both state trajectories.

  6. Compute at least one performance measure, such as peak displacement, RMS displacement, or control effort.

  7. Explain which quantities could become decision variables and which conditions could become constraints.

Connection to a CCD formulation

CCD elementMass–spring–damper example
Plant variablesmm, cc, and kk
Control variablesForce-input history or controller gains
StatesDisplacement and velocity
Possible objectivesVibration suppression, control effort, or a weighted combination
Possible constraintsActuator-force limits, displacement bounds, or parameter bounds

Activity 0.6: State and Parameter Sensitivities for a Readiness Mini-Project