Main

Introduction to Dynamic Modeling

Main.DynamicModeling History

Hide minor edits - Show changes to output

Added lines 243-246:

(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/eKATopbW_rU" frameborder="0" gesture="media" allow="encrypted-media" allowfullscreen></iframe>
(:htmlend:)
Changed line 78 from:
'''Objective:''' Provide a basic introduction to dynamic system modeling and simulation with the equations of motion. Create a MATLAB (ode23, ode15s, etc) or Python (ODEINT) script to simulate and display the results. Simulate with [[http://apmonitor.com/wiki/index.php/Main/MATLAB|APM MATLAB]] or [[http://apmonitor.com/wiki/index.php/Main/PythonApp|APM Python]] as well. Compare the sequential (ODE integrators in MATLAB / Python) versus the simultaneous method (APMonitor). Observe how the number of time points in APMonitor affects the solution accuracy. ''Estimated Time: 1 hour''
to:
'''Objective:''' Provide a basic introduction to dynamic system modeling and simulation with the equations of motion. Create a MATLAB (ode23, ode15s, etc) or Python (ODEINT) script to simulate and display the results. Simulate with [[http://apmonitor.com/wiki/index.php/Main/MATLAB|APM MATLAB]], [[http://apmonitor.com/wiki/index.php/Main/PythonApp|APM Python]], or [[http://gekko.readthedocs.io/en/latest/|Python GEKKO]] as well. Compare the sequential (ODE integrators in MATLAB / Python) versus the simultaneous method (APMonitor). Observe how the number of time points in APMonitor affects the solution accuracy. ''Estimated Time: 1 hour''
Changed line 244 from:
(:toggle hide gekko button show="Show Gekko Code":)
to:
(:toggle hide gekko button show="Show GEKKO (Python) Code":)
Deleted line 241:
Deleted lines 246-247:

Changed lines 316-317 from:

(:divend:)
to:
(:divend:)
Changed lines 243-320 from:
(:divend:)
to:
(:divend:)

(:toggle hide gekko button show="Show Gekko Code":)
(:div id=gekko:)
(:source lang=python:)


from gekko import GEKKO
import numpy as np
import matplotlib.pyplot as plt

#number of points in time discretization
n = 91

#Initialize Model
m = GEKKO()

#define time discretization
m.time = np.linspace(0,90,n)

#make array of drag coefficients, changing at time 60
drag = [(0.2 if t<=60 else 10) for t in m.time]

#define constants
g = m.Const(value=9.81)
mass = m.Const(value=80)

#define drag parameter
d = m.Param(value=drag)

#initialize variables
x,y,vx,vy,v,Fx,Fy = [m.Var(value=0) for i in range(7)]

#initial conditions
y.value = 5000
vx.value = 50

#Equations
# force balance
m.Equation(Fx == -d * vx**2)
m.Equation(Fy == -mass*g + d*vy**2)
#F = ma
m.Equation(Fx/mass == vx.dt())
m.Equation(Fy/mass == vy.dt())
#vel = dxdt
m.Equation(vx == x.dt())
m.Equation(vy == y.dt())
#total velocity
m.Equation(v == (vx**2 + vy**2)**.5)

#Set global options
m.options.IMODE = 4 #dynamic simulation

#Solve simulation
m.solve(remote=True)

#%% Plot results
plt.figure()
plt.plot(x.value,y.value)
plt.xlabel('x')
plt.ylabel('y')

plt.figure()
plt.plot(m.time,x.value,label='x')
plt.plot(m.time,y.value,label='y')
plt.xlabel('time')
plt.legend()

plt.figure()
plt.plot(m.time,vx.value,label='vx')
plt.plot(m.time,vy.value,label='vy')
plt.xlabel('time')
plt.legend()

plt.show()
(:sourceend:)

(:divend:)
Changed lines 90-91 from:
This problem can also be solved with an ODE integrator such as Python's ODEINT function in SciPy.Integrate or MATLAB's ode23 function. The focus of this class is on solving dynamic optimization problems where ODE integrators are not suitable because of the inefficiencies of shooting methods. Regardless, it is valuable to know how to use ODE integrators for simulation. Below is the source code using ODEINT in Python.
to:
This problem can also be solved with an ODE integrator such as Python's ODEINT function in SciPy.Integrate or MATLAB's ode23 function. The focus of this class is on solving dynamic optimization problems where ODE integrators are not suitable because of the inefficiencies of shooting methods. Regardless, it is valuable to know how to use ODE integrators for simulation. Below is the source code in MATLAB and Python.

(:toggle hide matlab button show="Show MATLAB Code":)
(:div id=matlab:)
(:source lang=matlab:)
clear all; close all; clc

%% Method 1: MATLAB integration with ode15s
% initial conditions
z0 = [0,5000,50,0];
% time points
t = linspace(0,90,1);
% solve
[t,z1] = ode15s('skydiver',t,z0);

% parse results
ode_x = z1(:,1);
ode_y = z1(:,2);
ode_vx = z1(:,3);
ode_vy = z1(:,4);
ode_v = sqrt(ode_vx.^2+ode_vy.^2);


%% Method 2: APMonitor
addpath('apm') % load APMonitor.com files
y = apm_solve('skydiver',7); z = y.x; % solve numerically


%% Plot results
figure(1)
subplot(2,1,1)
plot(t,ode_x,'r-','LineWidth',2)
hold on
plot(t,ode_y,'b-','LineWidth',2)
plot(z.time,z.x,'r:','LineWidth',3)
plot(z.time,z.y,'b--','LineWidth',3)
ylabel('Position (m)')
legend('x','y')

subplot(2,1,2)
plot(t,ode_vx,'r-','LineWidth',2)
hold on
plot(t,ode_vy,'b-','LineWidth',2)
plot(t,ode_v,'k-','LineWidth',2)
plot(z.time,z.vx,'r:','LineWidth',3)
plot(z.time,z.vy,'b--','LineWidth',3)
plot(z.time,z.v,'k--','LineWidth',3)
xlabel('Time (sec)')
ylabel('Velocity (m/s)')
legend('V_x','V_y','V','APM V_x','APM V_y','APM V')

figure(2)
plot(z.x,z.y,'r-','LineWidth',2)
xlabel('Position (x)')
ylabel('Position (y)')
(:sourceend:)
(:divend:)

(:toggle hide python button show="Show Python Code":)
(:div id=python:)
Changed lines 241-243 from:
(:sourceend:)
to:
(:sourceend:)

(:divend
:)
February 08, 2017, at 08:52 PM by 173.115.111.58 -
Added lines 89-183:

This problem can also be solved with an ODE integrator such as Python's ODEINT function in SciPy.Integrate or MATLAB's ode23 function. The focus of this class is on solving dynamic optimization problems where ODE integrators are not suitable because of the inefficiencies of shooting methods. Regardless, it is valuable to know how to use ODE integrators for simulation. Below is the source code using ODEINT in Python.

(:source lang=python:)
### Sequential method with SciPy.integrate.odeint
import numpy as np
from scipy.integrate import odeint

def skydive(z,t):
    # constants
    g = 9.81 # m/s^2, gravitational constant
    m = 80  # kg, mass of skydiver and pack
    if t<61:
        c = 0.2  # N-s^2/m^2, drag coefficient, chute closed
    else:
        c = 10.0 # N-s^2/m^2, drag coefficient, chute open

    # states (z)
    x = z[0]  # meters, horizontal position
    y = z[1]  # meters, vertical position / elevation
    vx = z[2] # m/s, skydiver horizontal velocity = airplane velocity
    vy = z[3] # m/s, skydiver vertical velocity

    # derived values
    v = np.sqrt(vx**2+vy**2) # m/s, magnitude of velocity
    Fx = -c * vx**2
    Fy = -m*g + c*vy**2

    # calculate derivatives
    dxdt = vx
    dydt = vy
    dvxdt = Fx / m
    dvydt = Fy / m
    dzdt = [dxdt,dydt,dvxdt,dvydt]   

    return dzdt

# initial conditions
z0 = [0,5000,50,0]
# time points
t = np.linspace(0,90,91)
# solve
z1 = odeint(skydive,z0,t)

# parse results
x = z1[:,0]
y = z1[:,1]
vx = z1[:,2]
vy = z1[:,3]
v = np.sqrt(vx**2+vy**2)


### Simultaneous method with APMonitor
# install and load APMonitor
try:
    from APMonitor import *
except:
    import pip
    pip.main(['install','APMonitor'])   
    from APMonitor import *
   
# solve model
z2 = apm_solve('skydiver',7)


### Plot results
import matplotlib.pyplot as plt

plt.figure(1)
plt.subplot(2,1,1)
plt.plot(t,x,'r-',linewidth=2)
plt.plot(t,y,'b-',linewidth=2)
plt.plot(z2['time'],z2['x'],'r:',linewidth=3)
plt.plot(z2['time'],z2['y'],'b--',linewidth=3)
plt.ylabel('Position (m)')
plt.legend(['ODEINT x','ODEINT y','APM x','APM y'])

plt.subplot(2,1,2)
plt.plot(t,vx,'r-',linewidth=2)
plt.plot(t,vy,'b-',linewidth=2)
plt.plot(t,v,'k-',linewidth=2)
plt.plot(z2['time'],z2['vx'],'r--',linewidth=3)
plt.plot(z2['time'],z2['vy'],'b--',linewidth=3)
plt.plot(z2['time'],z2['v'],'k--',linewidth=3)
plt.xlabel('Time (sec)')
plt.ylabel('Velocity (m/s)')
plt.legend(['ODEINT V_x','ODEINT V_y','ODEINT V',\
            'APM V_x','APM V_y','APM V'])

plt.figure(2)
plt.plot(z2['x'],z2['y'],'r-')
plt.xlabel('Position (x)')
plt.ylabel('Position (y)')
plt.show()
(:sourceend:)
February 08, 2017, at 08:50 PM by 173.115.111.58 -
Deleted lines 88-180:

(:source lang=python:)
### Sequential method with SciPy.integrate.odeint
import numpy as np
from scipy.integrate import odeint

def skydive(z,t):
    # constants
    g = 9.81 # m/s^2, gravitational constant
    m = 80  # kg, mass of skydiver and pack
    if t<61:
        c = 0.2  # N-s^2/m^2, drag coefficient, chute closed
    else:
        c = 10.0 # N-s^2/m^2, drag coefficient, chute open

    # states (z)
    x = z[0]  # meters, horizontal position
    y = z[1]  # meters, vertical position / elevation
    vx = z[2] # m/s, skydiver horizontal velocity = airplane velocity
    vy = z[3] # m/s, skydiver vertical velocity

    # derived values
    v = np.sqrt(vx**2+vy**2) # m/s, magnitude of velocity
    Fx = -c * vx**2
    Fy = -m*g + c*vy**2

    # calculate derivatives
    dxdt = vx
    dydt = vy
    dvxdt = Fx / m
    dvydt = Fy / m
    dzdt = [dxdt,dydt,dvxdt,dvydt]   

    return dzdt

# initial conditions
z0 = [0,5000,50,0]
# time points
t = np.linspace(0,90,91)
# solve
z1 = odeint(skydive,z0,t)

# parse results
x = z1[:,0]
y = z1[:,1]
vx = z1[:,2]
vy = z1[:,3]
v = np.sqrt(vx**2+vy**2)


### Simultaneous method with APMonitor
# install and load APMonitor
try:
    from APMonitor import *
except:
    import pip
    pip.main(['install','APMonitor'])   
    from APMonitor import *
   
# solve model
z2 = apm_solve('skydiver',7)


### Plot results
import matplotlib.pyplot as plt

plt.figure(1)
plt.subplot(2,1,1)
plt.plot(t,x,'r-',linewidth=2)
plt.plot(t,y,'b-',linewidth=2)
plt.plot(z2['time'],z2['x'],'r:',linewidth=3)
plt.plot(z2['time'],z2['y'],'b--',linewidth=3)
plt.ylabel('Position (m)')
plt.legend(['ODEINT x','ODEINT y','APM x','APM y'])

plt.subplot(2,1,2)
plt.plot(t,vx,'r-',linewidth=2)
plt.plot(t,vy,'b-',linewidth=2)
plt.plot(t,v,'k-',linewidth=2)
plt.plot(z2['time'],z2['vx'],'r--',linewidth=3)
plt.plot(z2['time'],z2['vy'],'b--',linewidth=3)
plt.plot(z2['time'],z2['v'],'k--',linewidth=3)
plt.xlabel('Time (sec)')
plt.ylabel('Velocity (m/s)')
plt.legend(['ODEINT V_x','ODEINT V_y','ODEINT V',\
            'APM V_x','APM V_y','APM V'])

plt.figure(2)
plt.plot(z2['x'],z2['y'],'r-')
plt.xlabel('Position (x)')
plt.ylabel('Position (y)')
plt.show()
(:sourceend:)
January 11, 2017, at 02:04 PM by 198.233.146.2 -
Added lines 89-181:

(:source lang=python:)
### Sequential method with SciPy.integrate.odeint
import numpy as np
from scipy.integrate import odeint

def skydive(z,t):
    # constants
    g = 9.81 # m/s^2, gravitational constant
    m = 80  # kg, mass of skydiver and pack
    if t<61:
        c = 0.2  # N-s^2/m^2, drag coefficient, chute closed
    else:
        c = 10.0 # N-s^2/m^2, drag coefficient, chute open

    # states (z)
    x = z[0]  # meters, horizontal position
    y = z[1]  # meters, vertical position / elevation
    vx = z[2] # m/s, skydiver horizontal velocity = airplane velocity
    vy = z[3] # m/s, skydiver vertical velocity

    # derived values
    v = np.sqrt(vx**2+vy**2) # m/s, magnitude of velocity
    Fx = -c * vx**2
    Fy = -m*g + c*vy**2

    # calculate derivatives
    dxdt = vx
    dydt = vy
    dvxdt = Fx / m
    dvydt = Fy / m
    dzdt = [dxdt,dydt,dvxdt,dvydt]   

    return dzdt

# initial conditions
z0 = [0,5000,50,0]
# time points
t = np.linspace(0,90,91)
# solve
z1 = odeint(skydive,z0,t)

# parse results
x = z1[:,0]
y = z1[:,1]
vx = z1[:,2]
vy = z1[:,3]
v = np.sqrt(vx**2+vy**2)


### Simultaneous method with APMonitor
# install and load APMonitor
try:
    from APMonitor import *
except:
    import pip
    pip.main(['install','APMonitor'])   
    from APMonitor import *
   
# solve model
z2 = apm_solve('skydiver',7)


### Plot results
import matplotlib.pyplot as plt

plt.figure(1)
plt.subplot(2,1,1)
plt.plot(t,x,'r-',linewidth=2)
plt.plot(t,y,'b-',linewidth=2)
plt.plot(z2['time'],z2['x'],'r:',linewidth=3)
plt.plot(z2['time'],z2['y'],'b--',linewidth=3)
plt.ylabel('Position (m)')
plt.legend(['ODEINT x','ODEINT y','APM x','APM y'])

plt.subplot(2,1,2)
plt.plot(t,vx,'r-',linewidth=2)
plt.plot(t,vy,'b-',linewidth=2)
plt.plot(t,v,'k-',linewidth=2)
plt.plot(z2['time'],z2['vx'],'r--',linewidth=3)
plt.plot(z2['time'],z2['vy'],'b--',linewidth=3)
plt.plot(z2['time'],z2['v'],'k--',linewidth=3)
plt.xlabel('Time (sec)')
plt.ylabel('Velocity (m/s)')
plt.legend(['ODEINT V_x','ODEINT V_y','ODEINT V',\
            'APM V_x','APM V_y','APM V'])

plt.figure(2)
plt.plot(z2['x'],z2['y'],'r-')
plt.xlabel('Position (x)')
plt.ylabel('Position (y)')
plt.show()
(:sourceend:)
January 10, 2017, at 10:17 PM by 184.218.204.29 -
Changed line 78 from:
'''Objective:''' Provide a basic introduction to dynamic system modeling and simulation with the equations of motion. Create a MATLAB (ode23, ode15s, etc) or Python (ODEINT) script to simulate and display the results. Simulate with [[http://apmonitor.com/wiki/index.php/Main/MATLAB|APM MATLAB]] and [[http://apmonitor.com/wiki/index.php/Main/PythonApp|APM Python]] as well. Compare the sequential (ODE integrators in MATLAB / Python) versus the simultaneous method (APMonitor). Observe how the number of time points in APMonitor affects the solution accuracy. ''Estimated Time: 1 hour''
to:
'''Objective:''' Provide a basic introduction to dynamic system modeling and simulation with the equations of motion. Create a MATLAB (ode23, ode15s, etc) or Python (ODEINT) script to simulate and display the results. Simulate with [[http://apmonitor.com/wiki/index.php/Main/MATLAB|APM MATLAB]] or [[http://apmonitor.com/wiki/index.php/Main/PythonApp|APM Python]] as well. Compare the sequential (ODE integrators in MATLAB / Python) versus the simultaneous method (APMonitor). Observe how the number of time points in APMonitor affects the solution accuracy. ''Estimated Time: 1 hour''
January 10, 2017, at 10:17 PM by 184.218.204.29 -
Changed line 78 from:
'''Objective:''' Provide a basic introduction to dynamic system modeling and simulation with the equations of motion. Create a MATLAB or Python script to simulate and display the results. ''Estimated Time: 1 hour''
to:
'''Objective:''' Provide a basic introduction to dynamic system modeling and simulation with the equations of motion. Create a MATLAB (ode23, ode15s, etc) or Python (ODEINT) script to simulate and display the results. Simulate with [[http://apmonitor.com/wiki/index.php/Main/MATLAB|APM MATLAB]] and [[http://apmonitor.com/wiki/index.php/Main/PythonApp|APM Python]] as well. Compare the sequential (ODE integrators in MATLAB / Python) versus the simultaneous method (APMonitor). Observe how the number of time points in APMonitor affects the solution accuracy. ''Estimated Time: 1 hour''
April 21, 2015, at 03:13 PM by 10.10.33.68 -
Added lines 77-79:

'''Objective:''' Provide a basic introduction to dynamic system modeling and simulation with the equations of motion. Create a MATLAB or Python script to simulate and display the results. ''Estimated Time: 1 hour''

April 10, 2015, at 09:25 PM by 10.10.149.40 -
Changed line 84 from:
<iframe width="560" height="315" src="https://www.youtube.com/embed/y0ERNz5Kms8?rel=0" frameborder="0" allowfullscreen></iframe>
to:
<iframe width="560" height="315" src="https://www.youtube.com/embed/2FeOaGUQwKA?rel=0" frameborder="0" allowfullscreen></iframe>
April 10, 2015, at 08:29 PM by 10.5.113.179 -
Changed lines 81-85 from:
(video of solution)
to:
Attach:download.png [[Attach:simulate_skydiver.zip|Skydiver Simulation in MATLAB and Python]]

(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/y0ERNz5Kms8?rel=0" frameborder="0" allowfullscreen></iframe>
(:htmlend:
)
April 10, 2015, at 06:51 PM by 10.5.113.179 -
Changed lines 77-79 from:
Develop a mathematical description of the motion of a falling object (e.g. skydiver) in one dimension where there is a frictional resistance that is proportional to the square of the velocity. Solve the equations numerically.

Integrate
the system from zero initial time to terminal velocity and assume that the object is initially at rest. Assume a gravitational constant of 9.8 m/s'^2^', a mass of 80 kg, and a frictional loss coefficient of 0.2 N-s'^2^'/m'^2^'.
to:
Predict the position and velocity of a skydiver in two dimensions (horizontal and vertical) from the time of the initial jump through the first 90 seconds. At 60 seconds after the jump, the skydiver pulls the chute and the drag coefficient increases to slow the decent. The airplane is flying at a constant altitude of 5000 meters and 50 m/s when the skydiver jumps. The drag coefficient is 0.2 N-s'^2^'/m'^2^' while free-falling and 10 N-s'^2^'/m'^2^' with the parachute open. The gravitational constant is 9.8 m/s'^2^' and the mass is 80 kg for the skydiver and chute.
April 10, 2015, at 03:32 PM by 45.56.12.124 -
Changed lines 77-79 from:
Develop a mathematical description of the motion of an object in one dimension where there is a frictional resistance that is proportional to the velocity. Solve the equations numerically.

Integrate
the system from zero initial time to steady state conditions and assume that the object is initially at rest. Assume a force of 5 N, a mass of 10 kg, and a frictional loss coefficient of 0.2 N-s/m.
to:
Develop a mathematical description of the motion of a falling object (e.g. skydiver) in one dimension where there is a frictional resistance that is proportional to the square of the velocity. Solve the equations numerically.

Integrate the system from zero initial time to terminal velocity and assume that the object is initially at rest. Assume
a gravitational constant of 9.8 m/s'^2^', a mass of 80 kg, and a frictional loss coefficient of 0.2 N-s'^2^'/m'^2^'.
April 04, 2015, at 02:02 PM by 45.56.12.124 -
Changed line 61 from:
[[Attach:simulate_vehicle.zip|Attach:download.png Simulate with Excel, MATLAB, Python, and Simulink]]
to:
Attach:download.png [[Attach:simulate_vehicle.zip|Simulate with Excel, MATLAB, Python, and Simulink]]
April 04, 2015, at 02:00 PM by 45.56.12.124 -
Changed line 61 from:
* [[Attach:simulate_vehicle.zip|Simulate with Excel, MATLAB, Python, and Simulink]]
to:
[[Attach:simulate_vehicle.zip|Attach:download.png Simulate with Excel, MATLAB, Python, and Simulink]]
April 04, 2015, at 01:46 PM by 45.56.12.124 -
Changed line 61 from:
* [[Attach:simulate_vehicle.zip|Simulate vehicle velocity]]
to:
* [[Attach:simulate_vehicle.zip|Simulate with Excel, MATLAB, Python, and Simulink]]
April 03, 2015, at 01:38 AM by 10.24.17.95 -
Added lines 6-7:

* [[Attach:Intro_Dynamic_Modeling.pdf|Introduction to Dynamic Modeling (pdf)]]
April 02, 2015, at 05:46 AM by 45.56.12.124 -
Added lines 61-63:
(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/y0ERNz5Kms8?rel=0" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
April 02, 2015, at 05:25 AM by 45.56.12.124 -
Deleted lines 12-19:
!!!!Numerical Solution of Differential Equations

Excel, MATLAB, Python, and Simulink are used in the following example to solve the differential equation that describes the velocity of a vehicle.

* [[Attach:simulate_vehicle.zip|Simulate vehicle velocity]]


Added lines 56-60:

Excel, MATLAB, Python, and Simulink are used in the following example to solve the differential equation that describes the velocity of a vehicle.

* [[Attach:simulate_vehicle.zip|Simulate vehicle velocity]]

April 02, 2015, at 05:24 AM by 45.56.12.124 -
Changed line 15 from:
Excel, MATLAB, and Python are used in the following example to solve the differential equation that describes the velocity of a vehicle.
to:
Excel, MATLAB, Python, and Simulink are used in the following example to solve the differential equation that describes the velocity of a vehicle.
April 02, 2015, at 05:21 AM by 45.56.12.124 -
Added lines 6-9:

(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/VRs9gX6r1Ng?rel=0" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
April 02, 2015, at 05:01 AM by 45.56.12.124 -
Changed line 9 from:
!!!!Numerical Solution for Differential Equations
to:
!!!!Numerical Solution of Differential Equations
April 02, 2015, at 05:00 AM by 45.56.12.124 -
Added lines 9-16:
!!!!Numerical Solution for Differential Equations

Excel, MATLAB, and Python are used in the following example to solve the differential equation that describes the velocity of a vehicle.

* [[Attach:simulate_vehicle.zip|Simulate vehicle velocity]]


Changed line 71 from:
Develop a mathematical description of the motion of an object in one dimension where there is a frictional resistance that is proportional to the velocity. Solve the equations analytically and numerically.
to:
Develop a mathematical description of the motion of an object in one dimension where there is a frictional resistance that is proportional to the velocity. Solve the equations numerically.
Deleted lines 47-48:

(video of analytic solution)
Deleted lines 53-54:

(video of numerical solution, APM MATLAB, APM Python, APMonitor - show how error changes with refined discretization)
Changed lines 61-62 from:
 0 = f(dx/dt,x,p)
0 < g(dx/dt,x,p)
to:
 ''0 = f(dx/dt,x,p)''
 ''
0 < g(dx/dt,x,p)''
Changed line 45 from:
 ''y = a t'^2^'/2 + v'_0_' t + y_0''
to:
 ''y = a t'^2^'/2 + v'_0_' t + y'_0_'''
Changed lines 44-45 from:
 ''v = a t + v_0_''
 ''y = a t'^2^'/2 + v_0_ t + y_0''
to:
 ''v = a t + v'_0_'''
 ''y = a t'^2^'/2 + v'_0_' t + y_0''
Changed line 47 from:
Notice that the initial condition for acceleration (''a_0_'') does not appear in the solution but initial conditions for velocity (''v_0_'') and position (''y_0_'') do influence the solution. If the force (''F'') changes at any time in the future, the time horizon is divided into separate segments where the force is constant. The first segment is computed and the final values become the initial values for the next segment.
to:
Notice that the initial condition for acceleration (''a'_0_''') does not appear in the solution but initial conditions for velocity (''v'_0_''') and position (''y'_0_''') do influence the solution. If the force (''F'') changes at any time in the future, the time horizon is divided into separate segments where the force is constant. The first segment is computed and the final values become the initial values for the next segment.
Changed lines 18-23 from:
 ''f(dx/dt,x,p)=0'', Semi-Explicit ODE Form

 ''f(dx/dt,x,p)=0'', Open Equation ODE Form

In the case of the object motion, the acceleration that is applied to the object may be the parameter that can be manipulated by the user or optimizer. The relationship between acceleration (''a'') and force (''F'') includes another parameter, the mass of the object (''m''). There are now three equations that describe the motion of the system and relate force (''F'') to acceleration (''a''), velocity (''v''), and position (''y'').
to:
 ''dx/dt = f(x,p)'', Semi-Explicit Form

 ''f(dx/dt,x,p)=0'', Open Equation Form

In the case of the object motion, the acceleration is not typically manipulated directly but may be adjusted by a force that is acting on that object. The relationship between acceleration (''a'') and force (''F'') includes another parameter, the mass of the object (''m''). There are now three equations that describe the motion of the system and relate force (''F'') to acceleration (''a''), velocity (''v''), and position (''y'').
Added lines 49-50:
(video of analytic solution)
Changed lines 55-56 from:
(video - Analytic & Numerical Solutions)
to:
(video of numerical solution, APM MATLAB, APM Python, APMonitor - show how error changes with refined discretization)
Changed lines 67-69 from:
Develop a mathematical description of the motion of an object in one dimension where there is a frictional resistance that is proportional to the velocity. Solve the equations analytically and numerically and determine the numerical error with finer discretization.

Integrate the system from zero initial time to steady state and assume that the object is initially at rest
.
to:
Develop a mathematical description of the motion of an object in one dimension where there is a frictional resistance that is proportional to the velocity. Solve the equations analytically and numerically.

Integrate the system from zero initial time to steady state conditions and assume that the object is initially at rest. Assume a force of 5 N, a mass of 10 kg, and a frictional loss coefficient of 0
.2 N-s/m.

!!!!Solution

(video of solution)
Changed lines 5-6 from:
The focus of this course is on modeling, simulation, estimation, and optimization of dynamic systems. This section of the course starts with dynamic modeling or methods to mathematically describe time-evolving systems, particularly for the purpose of dynamic optimization in engineering disciplines.
to:
The focus of this course is on modeling, simulation, estimation, and optimization of dynamic systems. This section of the course starts with dynamic modeling or methods to mathematically describe time-evolving systems, particularly for the purpose of dynamic optimization in engineering disciplines. The examples are particularly focused on engineering applications although much of the theory and applications can also be applied to other fields as well.

The discussion starts with modeling because a reasonably accurate model of the system must first be created to approximate input to output relationships between values that can be adjusted (inputs) and those values that are used to judge the desirability of solution (outputs)
.
Changed lines 11-12 from:
Dynamic systems can often be described as differential equations. One example is the equations of motion for an object in a friction-less environment in one dimension. In this case velocity (''v'') is the equal to the time-derivative of position (''y'') and acceleration (''a'') is the time-derivative of velocity.
to:
Dynamic systems can often be described with differential equations. The equations can either be derived empirically from data or from fundamental relationships. One example of fundamental relationships are equations of motion for an object in a friction-less environment in one dimension. In this case velocity (''v'') is the equal to the time-derivative of position (''y'') and acceleration (''a'') is the time-derivative of velocity.
Changed lines 39-42 from:
!!!!Analytic Solutions

An exact solution ''x(t)'' may exist from an analytic approach to solving the differential equations. In the in example case, the solution is found by integrating both sides of the differential equations. With the object initially at rest, this translates to zero initial conditions. An initial condition must be specified for each differential variable (those variables that appear in differential terms). In this case, the acceleration ''a'' is determined by the first equation but does not appear in differential form such as ''da/dt''.  Values of the parameters must be specified over the selected integration time horizon. The time horizon spans from the initial time where the initial conditions are specified to a future time ''t'_f_'''. Suppose there is a constant force (''F=5'') applied to the body starting at ''t'_0_'=0''. The analytic solution is then
to:
!!!!Analytic Solution

An exact solution ''x(t)'' may exist from an analytic approach to solving the differential equations. In the in example case, the solution is found by integrating both sides of the differential equations. With the object initially at rest, this translates to zero initial conditions. An initial condition must be specified for each differential variable (those variables that appear in differential terms). In this case, the acceleration ''a'' is determined by the first equation but does not appear in differential form such as ''da/dt''.  Values of the parameters must be specified over the selected integration time horizon. The time horizon spans from the initial time where the initial conditions are specified to a future time ''t'_f_'''. Suppose there is a constant force (''F=5'') applied to the body starting at ''t'_0_'=0''. The analytic solution is then solved as a function of time.
Changed lines 44-54 from:
 ''v = a t = F t/m''
 ''y = v(t)'^2^'/2''

!!!!Numerical Solutions

Another method to solve dynamic system is with a numerical approach that approximates the exact solution
''x(t)'' at discrete time intervals, much like measuring a physical system at particular time points. The numerical approach is able to solve much larger and more complex systems of equations, especially when an analytic solution does not exist.



!!!!Mathematical
Description
to:
 ''v = a t + v_0_''
 ''y = a t'^2^'/2 + v_0_ t + y_0''

Notice that the initial condition for acceleration (
''a_0_'') does not appear in the solution but initial conditions for velocity (''v_0_'') and position (''y_0_'') do influence the solution. If the force (''F'') changes at any time in the future, the time horizon is divided into separate segments where the force is constant. The first segment is computed and the final values become the initial values for the next segment.

!!!!Numerical Solution

Another method to solve dynamic system is with a numerical approach that approximates the exact solution ''x(t)'' at discrete time intervals, much like measuring a physical system at particular time points. The numerical approach is able to solve much larger and more complex systems of equations, especially when the exact analytic solution does not exist. One drawback to numerical solutions is that the accuracy of the solution is not exact and depends on factors such as the discretization methods employed and the error tolerance of the solver before convergence is confirmed.

(video - Analytic & Numerical Solutions)

!!!!Mathematical
Description of Dynamic Systems
Changed lines 59-75 from:
 0 = f(dx/dt,x)
 0 < g(dx/dt,x)

In this case, the differential (''f'_1_''') and algebraic (''f'_2_''') are condensed into ''f(dx/dt,x)'' and any algebraic expressions simply omit the derivative terms. Expressions may either be equality (''f'') or inequality (''g'') constraints.


A standard form for describing a system is as a collection of differential and algebraic expressions. 

Dynamic models can be converted to steady state models by setting any

The focus of this course is on dynamic systems or those that change with time. It is particularly focused on engineering applications although much of the theory and applications could also be applied to other fields as well
.

''''Dynamic systems

The speed of computers doubles approximately every 18 months. From 2000-2015 the speed of computers increased by about 1000 times.

Dynamic optimization is simulation and
to:
 0 = f(dx/dt,x,p)
 0 < g(dx/dt,x,p)

In this case, the differential and algebraic equations are condensed into ''f(dx/dt,x)'' and any algebraic expressions simply omit the derivative terms. Expressions may either be equality (''f'') or inequality (''g'') constraints.

!!!!Exercise
Develop a mathematical description of the motion of an object in one dimension where there is a frictional resistance that is proportional to the velocity. Solve the equations analytically and numerically and determine the numerical error with finer discretization.

Integrate the system from zero initial time to steady state and assume that the object is initially at rest
.
Changed lines 39-43 from:
An exact solution ''x(t)'' may exist from an analytic approach to solving the differential equations. In the in example case, the solution is found by integrating both sides of the differential equations. With the object initially at rest, this translates to zero initial conditions. An initial condition must be specified for each differential variable (those variables that appear in differential terms). In this case, the acceleration ''a'' is determined by the first equation but does not appear in differential form such as ''da/dt''.  Values of the parameters must be specified over the selected integration time horizon. The time horizon spans from the initial time where the initial conditions are specified to a future time ''t'_f_'''.

 ''a(t) = F/m''
 ''v(t) = a
(t)'^2^'/2''
 ''y(t) = v(t)'^2^'/2''
to:
An exact solution ''x(t)'' may exist from an analytic approach to solving the differential equations. In the in example case, the solution is found by integrating both sides of the differential equations. With the object initially at rest, this translates to zero initial conditions. An initial condition must be specified for each differential variable (those variables that appear in differential terms). In this case, the acceleration ''a'' is determined by the first equation but does not appear in differential form such as ''da/dt''.  Values of the parameters must be specified over the selected integration time horizon. The time horizon spans from the initial time where the initial conditions are specified to a future time ''t'_f_'''. Suppose there is a constant force (''F=5'') applied to the body starting at ''t'_0_'=0''. The analytic solution is then

 ''a = F/m''
 ''v = a t = F t/m''
 ''y
= v(t)'^2^'/2''
Changed lines 9-10 from:
Dynamic systems can often be posed as differential equations. One example is the equations of motion for an object in a friction-less environment in one dimension. In this case velocity (''v'') is the equal to the time-derivative of position (''y'') and acceleration (''a'') is the time-derivative of velocity.
to:
Dynamic systems can often be described as differential equations. One example is the equations of motion for an object in a friction-less environment in one dimension. In this case velocity (''v'') is the equal to the time-derivative of position (''y'') and acceleration (''a'') is the time-derivative of velocity.
Changed lines 14-21 from:
The above differential equations are expressed in semi-explicit form where the derivative terms are isolated on the left side of the equation and all other variables are on the right side of the expression. A more general notation for the semi-explicit form is ''dx/dt = f(x,p)'' where ''f(x,p)'' is any combination of variables (''x'') or parameters (''p''). Variables (''x'') are those values that are determined by the solution of the equations while parameters (''p'') are those quantities that are either specified by a user or determined by an optimizer.

In the case of the object motion, the acceleration that is applied to the object may be the parameter that can be manipulated by
the user or optimizer. arbitrarilythat is object

A more general form for differential equations is
the open-equation format as (''f(dx/dt,x,p)=0'')

 and algebraic (''f'-2-'(x)=0'') equations with variables ''x''. These collections of equations are referred to as Differential Algebraic Equations (DAEs)
. When there are no algebraic expressions, the system of equations are simplified to Ordinary Differential Equations (ODEs). If the differential equations have spatial and temporal derivatives, they become Partial Differential Equations (PDEs). For the purpose of this modeling discussion, any PDEs are discretized in space to return to ODE or DAE form where only time derivatives are present.
to:
The above differential equations are expressed in semi-explicit form where the derivative terms are isolated on the left side of the equation and all other variables are on the right side of the expression. A more general notation for the semi-explicit form is ''dx/dt = f(x,p)'' where ''f(x,p)'' is any combination of variables (''x'') or parameters (''p''). Variables (''x'') are those values that are determined by the solution of the equations while parameters (''p'') are those quantities that are either specified by a user or determined by an optimizer. A more general form for differential equations is the open-equation format as ''f(dx/dt,x,p)=0'' where all terms are brought to one side of the equation.

 ''f(dx/dt,x,p)=0'', Semi-Explicit ODE Form

 ''f(dx/dt,x,p)=0'', Open Equation ODE Form

In the case of
the object motion, the acceleration that is applied to the object may be the parameter that can be manipulated by the user or optimizer. The relationship between acceleration (''a'') and force (''F'') includes another parameter, the mass of the object (''m''). There are now three equations that describe the motion of the system and relate force (''F'') to acceleration (''a''), velocity (''v''), and position (''y'').

 ''F = m a''
 ''dy/dt = v''
 ''dv/dt = a''

The equation ''F = m a'' is an algebraic equation with no differential terms. While it would be simple to eliminate ''a'' from the equation by substituting for ''F/m'', suppose that it is not possible or convenient to rearrange the equations to eliminate the algebraic expressions. This collection of equations is now referred to as Differential Algebraic Equations (DAEs). When there are no algebraic expressions, the system of equations are simplified to Ordinary Differential Equations (ODEs). If the differential equations have spatial and temporal derivatives, they become Partial Differential Equations (PDEs). For the purpose of this modeling discussion, any PDEs are discretized in space to return to ODE or DAE form where only time derivatives (not spatial derivatives)
are present.
Changed lines 30-31 from:
Dynamic systems are those where values that describe the system are expected to evolve over time and not necessarily remain at a steady state. When a dynamic system is at steady state, all time derivative values are zero (''dx/dt=0'').
to:
Dynamic systems are those where values that describe the system are expected to evolve over time and not necessarily remain at a steady state. When a dynamic system is at steady state, all time derivative values are either set to zero (''dx/dt=0'') or do not otherwise appear in the equations.
Changed lines 35-36 from:
For physical dynamic systems the values of ''x'' may be measured at specific times. For virtual or simulated dynamic systems there can either be analytic solutions or numerical solutions. An exact solution ''x(t)'' may exist from an analytic approach to solving the differential equations.
to:
For physical systems the values of ''x'' may be measured at specific times. For virtual or simulated dynamic systems there can either be analytic solutions or a numerical solution.

!!!!Analytic Solutions

An exact solution ''x(t)'' may exist from an analytic approach to solving the differential equations. In the in example case, the solution is found by integrating both sides of the differential equations. With the object initially at rest, this translates to zero initial conditions. An initial condition must be specified for each differential variable (those variables that appear in differential terms). In this case, the acceleration ''a'' is determined by the first equation but does not appear in differential form such as ''da/dt''.  Values of the parameters must be specified over the selected integration time horizon. The time horizon spans from the initial time where the initial conditions are specified to a future time ''t'_f_'''.

 ''a(t) = F/m''
 ''v(t) = a(t)'^2^'/2''
 ''y(t) = v(t)'^2^'/2''

!!!!Numerical Solutions

Added lines 48-49:

Changed lines 5-6 from:
The focus of this course is on modeling, simulation, estimation, and optimization for dynamic systems. This section of the course starts with dynamic modeling or methods to mathematically describe time-evolving systems, particularly for the purpose of dynamic optimization in engineering disciplines.
to:
The focus of this course is on modeling, simulation, estimation, and optimization of dynamic systems. This section of the course starts with dynamic modeling or methods to mathematically describe time-evolving systems, particularly for the purpose of dynamic optimization in engineering disciplines.
Changed lines 9-20 from:
Dynamic systems can often be posed as collections of differential (''f'-1-'(dx/dt,x)=0'' and algebraic (''f'-2-'(x)=0'') equations with variables ''x''. These collections of equations are referred to as Differential Algebraic Equations (DAEs). When there are no algebraic expressions, the system of equations are simplified to Ordinary Differential Equations (ODEs). If the differential equations have spatial and temporal derivatives, they become Partial Differential Equations (PDEs). For the purpose of this modeling discussion, any PDEs are discretized in space to return to ODE or DAE form where only time derivatives are present.
to:
Dynamic systems can often be posed as differential equations. One example is the equations of motion for an object in a friction-less environment in one dimension. In this case velocity (''v'') is the equal to the time-derivative of position (''y'') and acceleration (''a'') is the time-derivative of velocity.

 ''dy/dt = v''
 ''dv/dt = a''

The above differential equations are expressed in semi-explicit form where the derivative terms are isolated on the left side of the equation and all other variables are on the right side of the expression. A more general notation for the semi-explicit form is ''dx/dt = f(x,p)'' where ''f(x,p)'' is any combination of variables (''x'') or parameters (''p''). Variables (''x'') are those values that are determined by the solution of the equations while parameters (''p'') are those quantities that are either specified by a user or determined by an optimizer.

In the case of the object motion, the acceleration that is applied to the object may be the parameter that can be manipulated by the user or optimizer. arbitrarilythat is object

A more general form for differential equations is the open-equation format as (''f(dx/dt,x,p)=0'')

 and algebraic (''f'-2-'(x)=0'') equations with variables ''x''. These collections of equations are referred to as Differential Algebraic Equations (DAEs). When there are no algebraic expressions, the system of equations are simplified to Ordinary Differential Equations (ODEs). If the differential equations have spatial and temporal derivatives, they become Partial Differential Equations (PDEs). For the purpose of this modeling discussion, any PDEs are discretized in space to return to ODE or DAE form where only time derivatives are present.
Changed lines 7-10 from:
!!!!Differential Algebraic Equations

Dynamic
systems can often be posed as collections of differential (''f'-1-'(dx/dt,x)=0'' and algebraic (''f'-2-'(x)=0'') equations. These collections are referred to as Differential Algebraic Equations (DAEs). When there are no algebraic expressions, the system of equations are referred to as Ordinary Differential Equations (ODEs). If the differential equations have spatial and temporal derivatives, they become Partial Differential Equations (PDEs). For the purpose of this modeling discussion, any PDEs are discretized in space to return to ODE or DAE form where only time derivatives are present.
to:
!!!!Dynamic Systems

Dynamic
systems can often be posed as collections of differential (''f'-1-'(dx/dt,x)=0'' and algebraic (''f'-2-'(x)=0'') equations with variables ''x''. These collections of equations are referred to as Differential Algebraic Equations (DAEs). When there are no algebraic expressions, the system of equations are simplified to Ordinary Differential Equations (ODEs). If the differential equations have spatial and temporal derivatives, they become Partial Differential Equations (PDEs). For the purpose of this modeling discussion, any PDEs are discretized in space to return to ODE or DAE form where only time derivatives are present.
Changed lines 20-25 from:
Another method to solve DAEs is with a numerical approach that approximates the exact solution ''x(t)'' at discrete time intervals, much like measuring a physical system at particular time points. The numerical approach is able to solve much larger and more complex systems of equations, especially when an analytic solution does not exist.

!!!!Mathematical Description of DAEs

Models
are collections of assumptions, mathematical expressions, boundary conditions, initial conditions, and constraints. These mathematical expressions can range from a simple equation of motion for an object in a frictionless environment to complex systems that describe multi-body physics and interactions. A standard model form is shown below:
to:
Another method to solve dynamic system is with a numerical approach that approximates the exact solution ''x(t)'' at discrete time intervals, much like measuring a physical system at particular time points. The numerical approach is able to solve much larger and more complex systems of equations, especially when an analytic solution does not exist.

!!!!Mathematical Description

Models are not just equations but
are collections of assumptions, mathematical expressions, boundary conditions, initial conditions, and constraints. These mathematical expressions can range from a simple equation of motion for an object in a frictionless environment to complex systems that describe multi-body physics and interactions. A standard model form is shown below:
Changed lines 29-34 from:
In this case, the differential (''f'_1_''') and algebraic (''f'_2_''') are condensed into ''f(dx/dt,x)'' and any algebraic expressions simply omit the derivative terms.


Values that describe

A standard form for describing a system is as a collection of differential and algebraic expressions. These may either be equality (''f'') or inequality (''g'') constraints. The variables (''x'')
to:
In this case, the differential (''f'_1_''') and algebraic (''f'_2_''') are condensed into ''f(dx/dt,x)'' and any algebraic expressions simply omit the derivative terms. Expressions may either be equality (''f'') or inequality (''g'') constraints.


A standard form for describing a system is as a collection of differential and algebraic expressions.
Changed lines 5-17 from:
The focus of this course is on modeling, simulation, estimation, and optimization for dynamic systems. This section of the course starts with dynamic modeling or methods to mathematically describe time-evolving systems, particularly for the purpose of optimization in engineering disciplines.

!!!!Dynamic versus Steady State Numerical Solution

Dynamic systems are those where certain values that describe the system are expected to evolve over time and not necessarily remain at a steady state.

 Steady state: Values ('''x''') do not change with time
 Dynamic: At least one value
('''x''') changes with time

Values of '''x''' may be measured at specific times or an expression may exist from an analytic solution of the differential equations as '''x(t)'''. Differential equations are those in which a Another method to solve dynamic

!!!!Mathematical
Description
to:
The focus of this course is on modeling, simulation, estimation, and optimization for dynamic systems. This section of the course starts with dynamic modeling or methods to mathematically describe time-evolving systems, particularly for the purpose of dynamic optimization in engineering disciplines.

!!!!Differential Algebraic Equations

Dynamic systems can often be posed as collections of differential (''f'-1-'(dx/dt,x)=0'' and algebraic (''f'-2-'(x)=0'') equations. These collections are referred to as Differential Algebraic Equations (DAEs). When there are no algebraic expressions, the system of equations are referred to as Ordinary Differential Equations
(ODEs). If the differential equations have spatial and temporal derivatives, they become Partial Differential Equations (PDEs). For the purpose of this modeling discussion, any PDEs are discretized in space to return to ODE or DAE form where only time derivatives are present.

!!!!Dynamic versus Steady State

Dynamic systems are those where values that describe the system are expected to evolve over time and not necessarily remain at a steady state. When a dynamic system is at steady state, all time derivative values are zero (''dx/dt=0'').

 Steady state: Values (''x'') do not change with time
 Dynamic: At least one value (''x'') changes with time

For physical dynamic systems the values of ''x'' may be measured at specific times. For virtual or simulated dynamic systems there can either be analytic solutions or numerical solutions. An exact solution ''x(t)'' may exist from an analytic approach to solving the differential equations.

Another method to solve DAEs is with a numerical approach that approximates the exact solution ''x(t)'' at discrete time intervals, much like measuring a physical system at particular time points. The numerical approach is able to solve much larger and more complex systems of equations, especially when an analytic solution does not exist.

!!!!Mathematical
Description of DAEs
Changed lines 26-28 from:


to:
 0 = f(dx/dt,x)
 0 < g(dx/dt,x)

In this case, the differential (''f'_1_''') and algebraic (''f'_2_''') are condensed into ''f(dx/dt,x)'' and any algebraic expressions simply omit the derivative terms.


Changed lines 34-35 from:
A standard form for describing a system is as a collection of differential and algebraic expressions. These may either be equality ('''f''') or inequality ('''g''') constraints. The variables ('''x''')
to:
A standard form for describing a system is as a collection of differential and algebraic expressions. These may either be equality (''f'') or inequality (''g'') constraints. The variables (''x'')
Changed line 40 from:
''''Dynamic'''' systems
to:
''''Dynamic systems
Added lines 4-35:

The focus of this course is on modeling, simulation, estimation, and optimization for dynamic systems. This section of the course starts with dynamic modeling or methods to mathematically describe time-evolving systems, particularly for the purpose of optimization in engineering disciplines.

!!!!Dynamic versus Steady State Numerical Solution

Dynamic systems are those where certain values that describe the system are expected to evolve over time and not necessarily remain at a steady state.

 Steady state: Values ('''x''') do not change with time
 Dynamic: At least one value ('''x''') changes with time

Values of '''x''' may be measured at specific times or an expression may exist from an analytic solution of the differential equations as '''x(t)'''. Differential equations are those in which a Another method to solve dynamic

!!!!Mathematical Description

Models are collections of assumptions, mathematical expressions, boundary conditions, initial conditions, and constraints. These mathematical expressions can range from a simple equation of motion for an object in a frictionless environment to complex systems that describe multi-body physics and interactions. A standard model form is shown below:




Values that describe

A standard form for describing a system is as a collection of differential and algebraic expressions. These may either be equality ('''f''') or inequality ('''g''') constraints. The variables ('''x''')

Dynamic models can be converted to steady state models by setting any

The focus of this course is on dynamic systems or those that change with time. It is particularly focused on engineering applications although much of the theory and applications could also be applied to other fields as well.

''''Dynamic'''' systems

The speed of computers doubles approximately every 18 months. From 2000-2015 the speed of computers increased by about 1000 times.

Dynamic optimization is simulation and
Added lines 1-3:
(:title Introduction to Dynamic Modeling:)
(:keywords dynamic modeling, engineering, differential, algebraic, modeling language, tutorial:)
(:description Dynamic modeling with Differential Algebraic Equations (DAEs):)