Solve Differential Equations

Main.ModelFormulation History

Hide minor edits - Show changes to markup

February 05, 2023, at 05:21 AM by 10.35.117.248 -
Changed line 5 from:
One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. The ordinary differential equation `\frac{dx}{dt}+x=12` can be solved analytically with separate & integrate or LaPlace transforms. The ODE can also be solved numerically with Excel or Python.
to:
Differential equations can be solved with analytic or numerical methods. For numerical methods, one of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. The ordinary differential equation `\frac{dx}{dt}+x=12` can be solved analytically with separate & integrate or LaPlace transforms. The ODE can also be solved numerically with Excel or Python.
February 05, 2023, at 05:19 AM by 10.35.117.248 -
Changed line 8 from:

<iframe width="560" height="315" src="https://www.youtube.com/embed/CtUNKqynUak" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

to:

<iframe width="560" height="315" src="https://www.youtube.com/embed/7TbwDrZ3kAg" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

February 05, 2023, at 04:57 AM by 10.35.117.248 -
Changed line 1 from:

(:title Formulation Strategies:)

to:

(:title Solve Differential Equations:)

February 05, 2023, at 04:56 AM by 10.35.117.248 -
Changed line 5 from:
One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. The ordinary differential equation `\frac{dx}{dt}+x=12` can be solved analytically with separate & integrate or LaPlace transforms. The ODE can also be solved numerically with Excel or Python.
to:
One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. The ordinary differential equation `\frac{dx}{dt}+x=12` can be solved analytically with separate & integrate or LaPlace transforms. The ODE can also be solved numerically with Excel or Python.
February 05, 2023, at 04:56 AM by 10.35.117.248 -
Changed line 5 from:
One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. The ordinary differential equation `\frac{dx}{dt}+x=12` can be solved analytically with separate & integrate or LaPlace transforms. The ODE can also be solved numerically with Excel or Python.
to:
One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. The ordinary differential equation `\frac{dx}{dt}+x=12` can be solved analytically with separate & integrate or LaPlace transforms. The ODE can also be solved numerically with Excel or Python.
February 05, 2023, at 04:55 AM by 10.35.117.248 -
Changed line 5 from:
One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. The ordinary differential equation `\frac{dx}{dt}+x=12` can be solved analytically with separate & integrate or LaPlace transforms. The ODE can also be solved numerically with Excel or Python.
to:
One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. The ordinary differential equation `\frac{dx}{dt}+x=12` can be solved analytically with separate & integrate or LaPlace transforms. The ODE can also be solved numerically with Excel or Python.
February 05, 2023, at 04:54 AM by 10.35.117.248 -
Changed lines 5-6 from:

One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. The ordinary differential equation `\frac{dx}{dt}+x=12` can be solved analytically with separate & integrate or LaPlace transforms. The ODE can also be solved numerically with Excel or Python.

to:
One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. The ordinary differential equation `\frac{dx}{dt}+x=12` can be solved analytically with separate & integrate or LaPlace transforms. The ODE can also be solved numerically with Excel or Python.
Deleted lines 9-10:
February 05, 2023, at 04:54 AM by 10.35.117.248 -
Changed line 5 from:

One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. The ordinary differential equation `\frac{dx}{dt}+x=12` can be solved analytically with separate & integrate or LaPlace transforms. It can also be solved numerically.

to:

One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. The ordinary differential equation `\frac{dx}{dt}+x=12` can be solved analytically with separate & integrate or LaPlace transforms. The ODE can also be solved numerically with Excel or Python.

February 05, 2023, at 04:53 AM by 10.35.117.248 -
Added lines 6-9:

(:html:) <iframe width="560" height="315" src="https://www.youtube.com/embed/CtUNKqynUak" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> (:htmlend:)

February 05, 2023, at 03:53 AM by 10.35.117.248 -
Added lines 6-7:
February 05, 2023, at 03:52 AM by 10.35.117.248 -
Changed line 5 from:

One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. The ordinary differential equation `\frac{dx}{dt}+x=12` can be solved analytically with separate & integrate or LaPlace transforms. It can also be solved numerically with approximate methods.

to:

One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. The ordinary differential equation `\frac{dx}{dt}+x=12` can be solved analytically with separate & integrate or LaPlace transforms. It can also be solved numerically.

February 05, 2023, at 03:52 AM by 10.35.117.248 -
Changed lines 5-22 from:

One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. In each section below are some of the key strategies related to model creation and formulation. The discussion begins with a basic introduction to the APMonitor Modeling Language and Gekko Optimization Suite.

to:

One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. The ordinary differential equation `\frac{dx}{dt}+x=12` can be solved analytically with separate & integrate or LaPlace transforms. It can also be solved numerically with approximate methods.

(:source lang=python:) import numpy as np from gekko import GEKKO m = GEKKO(remote=False) m.time = np.linspace(0,5) x = m.Var(0) m.Equation(x.dt()+x==12) m.options.IMODE=4 m.solve(disp=False)

import matplotlib.pyplot as plt plt.plot(m.time,x) plt.show() (:sourceend:)

In each section below are some of the key strategies related to model creation and formulation. The discussion begins with a basic introduction to the APMonitor Modeling Language and Gekko Optimization Suite.

February 05, 2023, at 03:22 AM by 10.35.117.248 -
Added lines 171-172:

Added lines 272-273:

Added lines 277-278:

February 05, 2023, at 03:19 AM by 10.35.117.248 -
Changed lines 46-48 from:
  • Solve Differential Equations with Python Gekko

This course has examples in APM Matlab and Python Gekko. There are many other open-source simulation and optimization platforms that can also be used in this course.

to:

(:source lang=python:) import numpy as np from gekko import GEKKO m = GEKKO(remote=False)

  1. input (1) = u
  2. states (5) = x[1] to x[5]
  3. output (1) = y
  4. Constants

n = 5 K = m.Const(4)

  1. Parameter

u = m.Param(value=3,lb=0,ub=10)

  1. Variable array

x = m.Array(m.Var,5,lb=0)

  1. Intermediate

y = m.Intermediate(x[4])

  1. Equations

m.Equation( x[0].dt() + x[0] == K*u) m.Equations([x[i].dt() + x[i] == x[i-1]

             for i in range(1,n)])
  1. Objective

m.Minimize((y-5)**2)

  1. Define time

m.time = np.linspace(0,20)

  1. Solve dynamic simulation

m.options.IMODE = 4 m.solve()

  1. Show solution

import matplotlib.pyplot as plt for i in range(n):

    plt.plot(m.time,x[i],label=f'$x_{i}$')

plt.plot(m.time,y,'k--',label='y') plt.xlabel('Time'); plt.grid(); plt.legend() plt.show() (:sourceend:)

This course has examples in APM Matlab and Python Gekko. See additional examples of solving differential equations in Python Gekko. There are many other open-source simulation and optimization platforms that can also be used in this course.

February 05, 2023, at 03:05 AM by 10.35.117.248 -
Changed line 5 from:

One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. In each section below are some of the key strategies related to model creation and formulation. The discussion begins with a basic introduction to the APMonitor Modeling Language.

to:

One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. In each section below are some of the key strategies related to model creation and formulation. The discussion begins with a basic introduction to the APMonitor Modeling Language and Gekko Optimization Suite.

February 05, 2023, at 03:04 AM by 10.35.117.248 -
Changed lines 44-48 from:

GEKKO is an object-oriented Python library to facilitate local execution of APMonitor. It is a Python package for machine learning and optimization of mixed-integer and differential algebraic equations. It is coupled with large-scale solvers for linear, quadratic, nonlinear, and mixed integer programming (LP, QP, NLP, MILP, MINLP). Modes of operation include parameter regression, data reconciliation, real-time optimization, dynamic simulation, and nonlinear predictive control.

to:

GEKKO is an object-oriented Python library to facilitate local execution of APMonitor. It is a Python package for machine learning and optimization of mixed-integer and differential algebraic equations. It is coupled with large-scale solvers for linear, quadratic, nonlinear, and mixed integer programming (LP, QP, NLP, MILP, MINLP). Modes of operation include parameter regression, data reconciliation, real-time optimization, dynamic simulation, and nonlinear predictive control.

  • Solve Differential Equations with Python Gekko

This course has examples in APM Matlab and Python Gekko. There are many other open-source simulation and optimization platforms that can also be used in this course.

February 05, 2023, at 02:59 AM by 10.35.117.248 -
Deleted lines 121-124:

APM MATLAB

Reservoir Simulation in MATLAB with Video Solution
Added lines 220-223:

APM MATLAB

Reservoir Simulation in MATLAB with Video Solution
February 05, 2023, at 02:58 AM by 10.35.117.248 -
Changed lines 55-62 from:

Slack variables are defined to transform an inequality expression into an equality expression with an added slack variable. The general expression for inequality constraints in the DAE expression is g(dx/dt,x,p)>0. An equivalent mathematical expression of the general inequality is g(dx/dt,x,p)=s and s>0. This form is desirable with solvers such as interior point methods where the initial guess must satisfy all inequality constraints or be on the inside of the feasible region. In the slack variable form, an initial guess value greater than zero for the new slack variable s satisfies this requirement. The APMonitor Modeling Language automatically transforms all inequality constraints into equivalent equality constraints with added slack variables.

  • Click to Solve a Slack Variable Optimization Problem

(:html:) <iframe width="560" height="315" src="https://www.youtube.com/embed/jh6BK0BqqIs?rel=0" frameborder="0" allowfullscreen></iframe> (:htmlend:)

to:

Slack variables are defined to transform an inequality expression into an equality expression with an added slack variable. The general expression for inequality constraints in the DAE expression is g(dx/dt,x,p)>0. An equivalent mathematical expression of the general inequality is g(dx/dt,x,p)=s and s>0. This form is desirable with solvers such as interior point methods where the initial guess must satisfy all inequality constraints or be on the inside of the feasible region. In the slack variable form, an initial guess value greater than zero for the new slack variable s satisfies this requirement. The APMonitor Modeling Language and Gekko Optimization Suite automatically transform all inequality constraints into equivalent equality constraints with added slack variables. See additional information (video) on slack variables.

Changed lines 122-127 from:

(:html:) <iframe width="560" height="315" src="https://www.youtube.com/embed/ZzYURrtD4YI?rel=0" frameborder="0" allowfullscreen></iframe>(:htmlend:)


to:

APM MATLAB

Reservoir Simulation in MATLAB with Video Solution

Python Gekko

February 05, 2023, at 02:55 AM by 10.35.117.248 -
Added lines 7-8:

APMonitor Modeling Language

Added lines 41-44:

Gekko Optimization Suite

GEKKO is an object-oriented Python library to facilitate local execution of APMonitor. It is a Python package for machine learning and optimization of mixed-integer and differential algebraic equations. It is coupled with large-scale solvers for linear, quadratic, nonlinear, and mixed integer programming (LP, QP, NLP, MILP, MINLP). Modes of operation include parameter regression, data reconciliation, real-time optimization, dynamic simulation, and nonlinear predictive control.

June 20, 2020, at 04:59 PM by 136.36.211.159 -
Changed line 17 from:

There is an additional optional designation of parameters as either fixed values (FVs) or manipulated variables (MVs). Variables can be optionally designated as state variables (SVs) or controlled variables (CVs). The terminology of FV, MV, SV, and CV is from the process systems engineering community. In this community the MVs are designated as the inputs that are potentially changed by the controller and CVs are model outputs that are driven to target conditions. The terms FVs refer to either measured or unmeasured disturbances to the system and SVs are simply designated for viewing purposes as variables of importance. These parameter and variable classifications are specified in MATLAB or Python scripts (See additional details on FV, MV, SV, and CV classification).

to:

There is an additional optional designation of parameters as either fixed values (FVs) or manipulated variables (MVs). Variables can be optionally designated as state variables (SVs) or controlled variables (CVs). The terminology of FV, MV, SV, and CV is from the process systems engineering community. In this community the MVs are designated as the inputs that are potentially changed by the operator or controller as external decisions that are degrees of freedom to minimize an objective function. The CVs are model outputs that are defined by equations and driven to target conditions. The terms FVs refer to either measured or unmeasured disturbances to the system. SVs are simply designated for viewing purposes as variables of importance. These parameter and variable classifications are specified in MATLAB or Python scripts (See additional details on FV, MV, SV, and CV classification).

Changed line 95 from:
 Vflow_in1 = 0.13 (July-Mar), 0.21 (Apr-June)
to:
 Vflow_in1 = 0.13 (June-Feb), 0.21 (Mar-May)
Changed line 146 from:

vin = [0.13,0.13,0.13,0.13,0.21,0.21,0.21,\

to:

vin = [0.13,0.13,0.13,0.21,0.21,0.21,0.13,\

Changed line 146 from:

vin = [0.13,0.13,0.13,0.21,0.21,0.21,0.13,\

to:

vin = [0.13,0.13,0.13,0.13,0.21,0.21,0.21,\

Changed line 84 from:
 Outflow River Rates (km3/yr)
to:
 Outflow River Rates (km3/yr) with height in meters
Changed line 120 from:

Solution

to:

Solutions

Added lines 126-131:

(:html:) <iframe width="560" height="315" src="https://www.youtube.com/embed/BHxNe86_TXc" frameborder="0" gesture="media" allow="encrypted-media" allowfullscreen></iframe> (:htmlend:)

Added lines 126-218:

(:toggle hide gekko button show="Show GEKKO (Python) Code":) (:div id=gekko:) (:source lang=python:) from __future__ import division from gekko import GEKKO import numpy as np

  1. Initial conditions

c = np.array([0.03,0.015,0.06,0]) areas = np.array([13.4, 12, 384.5, 4400]) V0 = np.array([0.26, 0.18, 0.68, 22]) h0 = 1000 * V0 / areas Vout0 = c * np.sqrt(h0) vin = [0.13,0.13,0.13,0.21,0.21,0.21,0.13, 0.13,0.13,0.13,0.13,0.13,0.13] Vin = [0,0,0,0]

  1. Initialize model

m = GEKKO()

  1. time array

m.time = np.linspace(0,1,13)

  1. define constants

c = m.Array(m.Const,4,value=0) c[0].value = 0.03 c[1].value = c[0] / 2 c[2].value = c[0] * 2 c[3].value = 0 Vuse = [0.03,0.05,0.02,0.00]

  1. Parameters

evap_c = m.Array(m.Param,4,value=1e-5) evap_c[-1].value = 0.5e-5

A = [m.Param(value=i) for i in areas]

Vin[0] = m.Param(value=vin)

  1. Variables

V = [m.Var(value=i) for i in V0] h = [m.Var(value=i) for i in h0] Vout = [m.Var(value=i) for i in Vout0]

  1. Intermediates

Vin[1:4] = [m.Intermediate(Vout[i]) for i in range(3)] Vevap = [m.Intermediate(evap_c[i] * A[i]) for i in range(4)]

  1. Equations

m.Equations([V[i].dt() == Vin[i] - Vout[i] - Vevap[i] - Vuse[i] for i in range(4)]) m.Equations([1000*V[i] == h[i]*A[i] for i in range(4)]) m.Equations([Vout[i]**2 == c[i]**2 * h[i] for i in range(4)])

  1. Set to simulation mode

m.options.imode = 4

  1. Solve

m.solve()

  1. Plot results

time = [x * 12 for x in m.time]

  1. plot results

import matplotlib.pyplot as plt plt.figure(1)

plt.subplot(311) plt.plot(time,h[0].value,'r-') plt.plot(time,h[1].value,'b--') plt.ylabel('Level (m)') plt.legend(['Jordanelle Reservoir','Deer Creek Reservoir'])

plt.subplot(312) plt.plot(time,h[3].value,'g-') plt.plot(time,h[2].value,'k:') plt.ylabel('Level (m)') plt.legend(['Great Salt Lake','Utah Lake'])

plt.subplot(313) plt.plot(time,Vin[0].value,'k-') plt.plot(time,Vout[0].value,'r-') plt.plot(time,Vout[1].value,'b--') plt.plot(time,Vout[2].value,'g-') plt.xlabel('Time (month)') plt.ylabel('Flow (km3/yr)') plt.legend(['Supply Flow','Upper Provo River', 'Lower Provo River','Jordan River']) plt.show() (:sourceend:) (:divend:)

May 01, 2015, at 11:05 PM by 45.56.3.184 -
Changed lines 101-105 from:
 Vevap1 = 0.03
 Vevap2 = 0.05
 Vevap3 = 0.02
 Vevap4 = 0.00
to:
 Vuse1 = 0.03
 Vuse2 = 0.05
 Vuse3 = 0.02
 Vuse4 = 0.00
Changed line 118 from:

Simulate the height of the reservoirs over the course of a year, starting in January, with higher inlet flowrates in the spring due to melting snow. Use a mass balance to describe the change in volume and height of each body of water. This is a simple simulation model that assumes no active control. In actual practice, water outlet flows are actively managed to maintain reservoir levels for recreation, provide sufficient river flow rates, limit river flow rates to avoid flooding, and serve agricultural and community needs. Utah Lake and the Great Salt Lake also have additional inlet sources such as the Payson River (Utah Lake) and the Weber River and Bear River (Great Salt Lake) that are not considered in this simulation.

to:

Simulate the height of the reservoirs (in meters) over the course of a year, starting in January, with higher inlet flowrates in the spring due to melting snow. Use a mass balance to describe the change in volume and height of each body of water. This is a simple simulation model that assumes no active control. In actual practice, water outlet flows are actively managed to maintain reservoir levels for recreation, provide sufficient river flow rates, limit river flow rates to avoid flooding, and serve agricultural and community needs. Utah Lake and the Great Salt Lake also have additional inlet sources such as the Payson River (Utah Lake) and the Weber River and Bear River (Great Salt Lake) that are not considered in this simulation.

April 23, 2015, at 01:40 PM by 45.56.12.124 -
Changed line 118 from:

Simulate the height of the reservoirs over the course of a year, starting in January, with higher inlet flowrates in the spring due to melting snow. This is a simple simulation model that assumes no active control. In actual practice, water outlet flows are actively managed to maintain reservoir levels for recreation, provide sufficient river flow rates, limit river flow rates to avoid flooding, and serve agricultural and community needs. Utah Lake and the Great Salt Lake also have additional inlet sources such as the Payson River (Utah Lake) and the Weber River and Bear River (Great Salt Lake) that are not considered in this simulation.

to:

Simulate the height of the reservoirs over the course of a year, starting in January, with higher inlet flowrates in the spring due to melting snow. Use a mass balance to describe the change in volume and height of each body of water. This is a simple simulation model that assumes no active control. In actual practice, water outlet flows are actively managed to maintain reservoir levels for recreation, provide sufficient river flow rates, limit river flow rates to avoid flooding, and serve agricultural and community needs. Utah Lake and the Great Salt Lake also have additional inlet sources such as the Payson River (Utah Lake) and the Weber River and Bear River (Great Salt Lake) that are not considered in this simulation.

April 22, 2015, at 05:16 PM by 10.10.144.236 -
Changed lines 125-126 from:

<iframe width="560" height="315" src="https://www.youtube.com/embed/WCTTY4baYLk?rel=0" frameborder="0" allowfullscreen></iframe> (:htmlend:)

to:

<iframe width="560" height="315" src="https://www.youtube.com/embed/ZzYURrtD4YI?rel=0" frameborder="0" allowfullscreen></iframe>(:htmlend:)

April 21, 2015, at 03:14 PM by 10.10.33.68 -
Changed line 71 from:

Objective: Formulate a dynamic model with model quantities such as constants, parameters, and variables and model expressions such as intermediates and equations. Use time-varying inputs, initial conditions, and mass balance equations to specify the problem inputs and dynamics. Create a MATLAB or Python script to simulate and display the results.

to:

Objective: Formulate a dynamic model with model quantities such as constants, parameters, and variables and model expressions such as intermediates and equations. Use time-varying inputs, initial conditions, and mass balance equations to specify the problem inputs and dynamics. Create a MATLAB or Python script to simulate and display the results. Estimated Time: 2 hours

April 21, 2015, at 03:07 PM by 10.10.33.68 -
Added lines 70-71:

Objective: Formulate a dynamic model with model quantities such as constants, parameters, and variables and model expressions such as intermediates and equations. Use time-varying inputs, initial conditions, and mass balance equations to specify the problem inputs and dynamics. Create a MATLAB or Python script to simulate and display the results.

April 21, 2015, at 03:01 PM by 10.10.33.68 -
Changed line 116 from:

Simulate the height of the reservoirs over the course of a year, starting in January, with higher inlet flowrates in the spring due to melting snow. This is a simple simulation model that assumes no active control. In actual practice, water outlet flows are actively managed to maintain reservoir levels for recreation, provide sufficient river flow rates, limit river flow rates to avoid flooding, and serve agricultural and community needs.

to:

Simulate the height of the reservoirs over the course of a year, starting in January, with higher inlet flowrates in the spring due to melting snow. This is a simple simulation model that assumes no active control. In actual practice, water outlet flows are actively managed to maintain reservoir levels for recreation, provide sufficient river flow rates, limit river flow rates to avoid flooding, and serve agricultural and community needs. Utah Lake and the Great Salt Lake also have additional inlet sources such as the Payson River (Utah Lake) and the Weber River and Bear River (Great Salt Lake) that are not considered in this simulation.

April 21, 2015, at 02:57 PM by 10.10.33.68 -
Deleted lines 102-107:
 Area of Reservoir / Lake (km2)
 A1 = 13.4
 A2 = 12.0
 A3 = 384.5
 A4 = 4400
April 21, 2015, at 02:53 PM by 10.10.33.68 -
Changed line 80 from:

Suppose that there is a spillway from each upstream body of water to the lower body of water with a flow that is proportional to the square root of the reservoir height. There is no outflow from the Great Salt Lake except due to evaporation. Develop a simplified dynamic model of the height change in each reservoir from water mass balances. Below are relevant constants to use for outflow correlations and initial holdups. Below are constants such as area (km2) and usage requirements (km3/yr), inlet and outlet flow correlations (km3/yr), and initial conditions for the volumes (km3).

to:

Suppose that there is a spillway from each upstream body of water to the lower body of water with a flow that is proportional to the square root of the reservoir height. There is no outflow from the Great Salt Lake except due to evaporation. Develop a simplified dynamic model of the height change in each reservoir from water mass balances. Below are constants such as area (km2) and usage requirements (km3/yr), inlet and outlet flow correlations (km3/yr), evaporation correlations, and initial conditions for the volumes (km3).

April 21, 2015, at 02:52 PM by 10.10.33.68 -
Added lines 73-76:

(:table border=0 width=100%:) (:cell width=20%:)

(:cell width=80%:)

Changed lines 78-79 from:
to:

(:tableend:)

Deleted lines 120-121:
April 21, 2015, at 02:49 PM by 10.10.33.68 -
Added lines 123-127:

(:html:) <iframe width="560" height="315" src="https://www.youtube.com/embed/WCTTY4baYLk?rel=0" frameborder="0" allowfullscreen></iframe> (:htmlend:)

April 21, 2015, at 02:05 PM by 10.10.33.68 -
Changed lines 84-85 from:
 V'_evap' = 1e-5 * Area, for fresh water
 V'_evap' = 0.5e-5 * Area, for salt water
to:
 Vevap = 0.5e-5 * Area, for salt water (Great Salt Lake)
 Vevap = 1e-5 * Area, for fresh water (all others)
April 21, 2015, at 02:01 PM by 10.10.33.68 -
Changed lines 71-76 from:

In Utah, water flows into the (1) Jordanelle reservoir, to the (2) Deer Creek reservoir, to (3) Utah Lake, and finally to the (4) Great Salt Lake. Suppose that there is a spillway from each upstream body of water to the lower body of water with a flow that is proportional to the square root of the reservoir height. There is no outflow from the Great Salt Lake except due to evaporation. Develop a simplified dynamic model of the height change in each reservoir from water mass balances. Below are relevant constants to use for outflow correlations and initial holdups. Below are constants such as area (km2) and usage requirements (km3/yr), inlet and outlet flow correlations (km3/yr), and initial conditions for the volumes (km3).

 Outflow Rates (km3/yr)
 Vflow_out1 = 0.1 sqrt(h1) 
 Vflow_out2 = 0.05 sqrt(h2) 
 Vflow_out3 = 0.2 sqrt(h3)
to:

In Utah, water flows into the (1) Jordanelle reservoir, to the (2) Deer Creek reservoir, to (3) Utah Lake, and finally to the (4) Great Salt Lake.

Suppose that there is a spillway from each upstream body of water to the lower body of water with a flow that is proportional to the square root of the reservoir height. There is no outflow from the Great Salt Lake except due to evaporation. Develop a simplified dynamic model of the height change in each reservoir from water mass balances. Below are relevant constants to use for outflow correlations and initial holdups. Below are constants such as area (km2) and usage requirements (km3/yr), inlet and outlet flow correlations (km3/yr), and initial conditions for the volumes (km3).

 Outflow River Rates (km3/yr)
 Vflow_out1 = 0.030 sqrt(h1) 
 Vflow_out2 = 0.015 sqrt(h2) 
 Vflow_out3 = 0.060 sqrt(h3)
Added lines 83-86:
 Evaporation Rates (km3/yr)
 V'_evap' = 1e-5 * Area, for fresh water
 V'_evap' = 0.5e-5 * Area, for salt water
Deleted lines 92-97:
 Evaporation Rates (km3/yr)
 Vevap1 = 0.01 A1
 Vevap2 = 0.01 A2
 Vevap3 = 0.01 A3
 Vevap4 = 0.005 A4
Changed lines 94-98 from:
 Vevap1 = 20
 Vevap2 = 100
 Vevap3 = 30
 Vevap4 = 0
to:
 Vevap1 = 0.03
 Vevap2 = 0.05
 Vevap3 = 0.02
 Vevap4 = 0.00

 Area of Reservoir / Lake (km2)
 A1 = 13.4
 A2 = 12.0
 A3 = 384.5
 A4 = 4400

 Area of Reservoir / Lake (km2)
 A1 = 13.4
 A2 = 12.0
 A3 = 384.5
 A4 = 4400

 Initial Volume of Reservoir / Lake (km3)
 V1 = 0.26
 V2 = 0.18
 V3 = 0.68
 V4 = 22.0
Deleted lines 119-120:
April 21, 2015, at 01:20 PM by 10.10.33.68 -
Changed lines 71-77 from:

In Utah, water flows into the (1) Jordanelle reservoir, to the (2) Deer Creek reservoir, to (3) Utah Lake, and finally to the (4) Great Salt Lake. Suppose that there is a spillway from each upstream body of water to the lower body of water with a flow that is proportional to the square root of the reservoir height. There is no outflow from the Great Salt Lake except due to evaporation. Develop a simplified dynamic model of the height change in each reservoir from water mass balances. Below are relevant constants to use for outflow correlations and initial holdups. Lookup estimates for the height (km), area (km2), and initial volumes (km3). Simulate the height of the reservoirs over the course of a year with higher inlet flowrates in the spring due to melting snow.

 Vflow_in1 = variable 
 Vflow_in2 = Vflow_out1
 Vflow_in3 = Vflow_out2
 Vflow_in4 = Vflow_out3
to:

In Utah, water flows into the (1) Jordanelle reservoir, to the (2) Deer Creek reservoir, to (3) Utah Lake, and finally to the (4) Great Salt Lake. Suppose that there is a spillway from each upstream body of water to the lower body of water with a flow that is proportional to the square root of the reservoir height. There is no outflow from the Great Salt Lake except due to evaporation. Develop a simplified dynamic model of the height change in each reservoir from water mass balances. Below are relevant constants to use for outflow correlations and initial holdups. Below are constants such as area (km2) and usage requirements (km3/yr), inlet and outlet flow correlations (km3/yr), and initial conditions for the volumes (km3).

 Outflow Rates (km3/yr)
Added lines 79-85:
 Inflow Rates (km3/yr)
 Vflow_in1 = 0.13 (July-Mar), 0.21 (Apr-June)
 Vflow_in2 = Vflow_out1
 Vflow_in3 = Vflow_out2
 Vflow_in4 = Vflow_out3

 Evaporation Rates (km3/yr)
Added lines 91-96:
 Usage Requirements (km3/yr)
 Vevap1 = 20
 Vevap2 = 100
 Vevap3 = 30
 Vevap4 = 0
Changed line 99 from:

This is a simple simulation model that assumes no active control. In actual practice, water outlet flows are actively managed to maintain reservoir levels for recreation, provide sufficient river flow rates, limit river flow rates to avoid flooding, and serve agricultural and community needs.

to:

Simulate the height of the reservoirs over the course of a year, starting in January, with higher inlet flowrates in the spring due to melting snow. This is a simple simulation model that assumes no active control. In actual practice, water outlet flows are actively managed to maintain reservoir levels for recreation, provide sufficient river flow rates, limit river flow rates to avoid flooding, and serve agricultural and community needs.

April 20, 2015, at 09:32 PM by 10.5.113.179 -
Changed line 71 from:

In Utah, water flows into the (1) Jordanelle reservoir, to the (2) Deer Creek reservoir, to (3) Utah Lake, and finally to the (4) Great Salt Lake. Suppose that there is a spillway from each upstream body of water to the lower body of water with a flow that is proportional to the square root of the reservoir height. There is no outflow from the Great Salt Lake except due to evaporation. Develop a simplified dynamic model of the height change in each reservoir from water mass balances. Below are relevant constants to use for outflow correlations and initial holdups. Lookup estimates for the height (m), area (m2), and initial volumes (m3). Simulate the height of the reservoirs over the course of a year with higher inlet flowrates in the spring due to melting snow.

to:

In Utah, water flows into the (1) Jordanelle reservoir, to the (2) Deer Creek reservoir, to (3) Utah Lake, and finally to the (4) Great Salt Lake. Suppose that there is a spillway from each upstream body of water to the lower body of water with a flow that is proportional to the square root of the reservoir height. There is no outflow from the Great Salt Lake except due to evaporation. Develop a simplified dynamic model of the height change in each reservoir from water mass balances. Below are relevant constants to use for outflow correlations and initial holdups. Lookup estimates for the height (km), area (km2), and initial volumes (km3). Simulate the height of the reservoirs over the course of a year with higher inlet flowrates in the spring due to melting snow.

April 20, 2015, at 08:27 PM by 10.5.113.179 -
Added lines 88-89:
Added lines 91-92:
April 20, 2015, at 08:25 PM by 10.5.113.179 -
Added line 77:
Added line 82:
April 20, 2015, at 08:25 PM by 10.5.113.179 -
Changed line 84 from:
 Vevap3 = 0.005 A4
to:
 Vevap4 = 0.005 A4
April 20, 2015, at 08:24 PM by 10.5.113.179 -
Changed lines 74-84 from:
 Vflow_in2 = mout1
 V'flow_in3' = mout2
 V'flow_in4' = mout3
 Vflow_out1 = 0.1 sqrt(h1) 
 Vflow_out2 = 0.05 sqrt(h2) 
 Vflow_out3 = 0.2 sqrt(h3)
 Vflow_out4 = 0
 Vevap1 = 0.01 A1
 Vevap2 = 0.01 A2
 Vevap3 = 0.01 A3
 Vevap3 = 0.005 A4
to:
 Vflow_in2 = Vflow_out1
 Vflow_in3 = Vflow_out2
 Vflow_in4 = Vflow_out3
 Vflow_out1 = 0.1 sqrt(h1) 
 Vflow_out2 = 0.05 sqrt(h2) 
 Vflow_out3 = 0.2 sqrt(h3)
 Vflow_out4 = 0
 Vevap1 = 0.01 A1
 Vevap2 = 0.01 A2
 Vevap3 = 0.01 A3
 Vevap3 = 0.005 A4
April 20, 2015, at 08:23 PM by 10.5.113.179 -
Changed lines 73-76 from:
 V'flow_in1' = variable 
 V'flow_in2' = m'_out1'
 V'flow_in3' = m'_out2'
 V'flow_in4' = m'_out3'
to:
 Vflow_in1 = variable 
 Vflow_in2 = mout1
 V'flow_in3' = mout2
 V'flow_in4' = mout3
April 20, 2015, at 08:22 PM by 10.5.113.179 -
Changed lines 71-80 from:

In Utah, water flows into the (1) Jordanelle reservoir, to the (2) Deer Creek reservoir, to (3) Utah Lake, and finally to the (4) Great Salt Lake. Suppose that there is a spillway from each upstream body of water to the lower body of water with a flow that is proportional to the square root of the reservoir height. There is no outflow from the Great Salt Lake except due to evaporation. Develop a simplified dynamic model of the height change in each reservoir from water mass balances. Below are relevant constants to use for outflow correlations and initial holdups. Lookup estimates for the height (m) and area (m^_2_^).

 m^_out1^ = 0.1 h^_1_^ 
 m^_out2^ = 0.05 h^_2_^ 
 m^_out3^ = 0.2 h^_3_^ 
 m^_out4^ = 0
 m^_evap1^ = 0.01 A^_1_^
 m^_evap2^ = 0.01 A^_2_^
 m^_evap3^ = 0.01 A^_3_^
 m^_evap3^ = 0.005 A^_4_^
to:

In Utah, water flows into the (1) Jordanelle reservoir, to the (2) Deer Creek reservoir, to (3) Utah Lake, and finally to the (4) Great Salt Lake. Suppose that there is a spillway from each upstream body of water to the lower body of water with a flow that is proportional to the square root of the reservoir height. There is no outflow from the Great Salt Lake except due to evaporation. Develop a simplified dynamic model of the height change in each reservoir from water mass balances. Below are relevant constants to use for outflow correlations and initial holdups. Lookup estimates for the height (m), area (m2), and initial volumes (m3). Simulate the height of the reservoirs over the course of a year with higher inlet flowrates in the spring due to melting snow.

 V'flow_in1' = variable 
 V'flow_in2' = m'_out1'
 V'flow_in3' = m'_out2'
 V'flow_in4' = m'_out3'
 Vflow_out1 = 0.1 sqrt(h1) 
 Vflow_out2 = 0.05 sqrt(h2) 
 Vflow_out3 = 0.2 sqrt(h3)
 Vflow_out4 = 0
 Vevap1 = 0.01 A1
 Vevap2 = 0.01 A2
 Vevap3 = 0.01 A3
 Vevap3 = 0.005 A4
April 20, 2015, at 08:16 PM by 10.5.113.179 -
Changed lines 71-73 from:

Solution

to:

In Utah, water flows into the (1) Jordanelle reservoir, to the (2) Deer Creek reservoir, to (3) Utah Lake, and finally to the (4) Great Salt Lake. Suppose that there is a spillway from each upstream body of water to the lower body of water with a flow that is proportional to the square root of the reservoir height. There is no outflow from the Great Salt Lake except due to evaporation. Develop a simplified dynamic model of the height change in each reservoir from water mass balances. Below are relevant constants to use for outflow correlations and initial holdups. Lookup estimates for the height (m) and area (m^_2_^).

 m^_out1^ = 0.1 h^_1_^ 
 m^_out2^ = 0.05 h^_2_^ 
 m^_out3^ = 0.2 h^_3_^ 
 m^_out4^ = 0
 m^_evap1^ = 0.01 A^_1_^
 m^_evap2^ = 0.01 A^_2_^
 m^_evap3^ = 0.01 A^_3_^
 m^_evap3^ = 0.005 A^_4_^

This is a simple simulation model that assumes no active control. In actual practice, water outlet flows are actively managed to maintain reservoir levels for recreation, provide sufficient river flow rates, limit river flow rates to avoid flooding, and serve agricultural and community needs.

Solution

Changed line 49 from:

Slack variables are defined to transform an inequality expression into an equality expression with an added slack variable. The general expression for inequality constraints in the DAE expression is g(dx/dt,x,p)>0. An equivalent mathematical expression of the general inequality is g(dx/dt,x,p)=s and s>0. This form is desirable with solvers such as interior point methods where the initial guess must satisfy all inequality constraints or be on the inside of the feasible region. In the slack variable form, an initial guess value greater than zero for the new slack variable s satisfies this requirement. The APMonitor Modeling Language automatically transforms all inequality constraints into equivalent equality constraints with added slack variables.

to:

Slack variables are defined to transform an inequality expression into an equality expression with an added slack variable. The general expression for inequality constraints in the DAE expression is g(dx/dt,x,p)>0. An equivalent mathematical expression of the general inequality is g(dx/dt,x,p)=s and s>0. This form is desirable with solvers such as interior point methods where the initial guess must satisfy all inequality constraints or be on the inside of the feasible region. In the slack variable form, an initial guess value greater than zero for the new slack variable s satisfies this requirement. The APMonitor Modeling Language automatically transforms all inequality constraints into equivalent equality constraints with added slack variables.

Added lines 64-67:

(:html:) <iframe width="560" height="315" src="https://www.youtube.com/embed/ELEUFKzwUj0" frameborder="0" allowfullscreen></iframe> (:htmlend:)

Changed line 55 from:

(:html:)

to:

(:htmlend:)

Added lines 50-55:
  • Click to Solve a Slack Variable Optimization Problem

(:html:) <iframe width="560" height="315" src="https://www.youtube.com/embed/jh6BK0BqqIs?rel=0" frameborder="0" allowfullscreen></iframe> (:html:)

Changed lines 17-19 from:

There is an additional optional designation of parameters as either fixed values (FVs) or manipulated variables (MVs). Variables can be optionally designated as state variables (SVs) or controlled variables (CVs). The terminology of FV, MV, SV, and CV is from the process systems engineering community. In this community the MVs are designated as the inputs that are potentially changed by the controller and CVs are model outputs that are driven to target conditions. The terms FVs refer to either measured or unmeasured disturbances to the system and SVs are simply designated for viewing purposes as variables of importance. These parameter and variable classifications are specified in MATLAB or Python scripts (See additional details on FV, MV, SV, and CV classification).

Collections of constants, parameters, variables, intermediates, equations, objects, and connections constitute a model. The model file is created and stored in a text file with extension apm. Several text editors are available that support syntax highlighting such as Notepad++ and gEdit (---see installation instructions). Below is an example model that demonstrates the use of many of these sections to create a 5th order differential equation model.

to:

There is an additional optional designation of parameters as either fixed values (FVs) or manipulated variables (MVs). Variables can be optionally designated as state variables (SVs) or controlled variables (CVs). The terminology of FV, MV, SV, and CV is from the process systems engineering community. In this community the MVs are designated as the inputs that are potentially changed by the controller and CVs are model outputs that are driven to target conditions. The terms FVs refer to either measured or unmeasured disturbances to the system and SVs are simply designated for viewing purposes as variables of importance. These parameter and variable classifications are specified in MATLAB or Python scripts (See additional details on FV, MV, SV, and CV classification).

Collections of constants, parameters, variables, intermediates, equations, objects, and connections constitute a model. The model file is created and stored in a text file with extension apm. Several text editors are available that support syntax highlighting such as Notepad++ and gEdit (see installation instructions). Below is an example model that demonstrates the use of many of these sections to create a 5th order differential equation model.

Changed line 53 from:

Certain functions such as abs, if..then, min, max, signum, and discontinuous functions can be included in models but need to be posed in a way to allow efficient solution by solvers that perform better with continuous first and second derivatives. There are alternative methods to reformulate the problems. Two popular approaches are as MPECs (Mathematical Programs with Equilibrium Constraints) or with binary variables that switch on or off certain elements of the equations.

to:

Certain functions such as abs, if..then, min, max, signum, and discontinuous functions can be included in models but need to be posed in a way to allow efficient solution by solvers that perform better with continuous first and second derivatives. There are alternative methods to reformulate the problems. Two popular approaches are as MPECs (Mathematical Programs with Equilibrium Constraints) or with binary variables that switch on or off certain elements of the equations.

Changed lines 17-18 from:

There is an additional optional designation of parameters as either fixed values (FVs) or manipulated variables (MVs). Variables can be optionally designated as state variables (SVs) or controlled variables (CVs). The terminology of FV, MV, SV, and CV is from the process systems engineering community. In this community the MVs are designated as the inputs that are potentially changed by the controller and CVs are model outputs that are driven to target conditions. The terms FVs refer to either measured or unmeasured disturbances to the system and SVs are simply designated for viewing purposes as variables of importance. These parameter and variable classifications are specified in MATLAB or Python scripts.

to:

There is an additional optional designation of parameters as either fixed values (FVs) or manipulated variables (MVs). Variables can be optionally designated as state variables (SVs) or controlled variables (CVs). The terminology of FV, MV, SV, and CV is from the process systems engineering community. In this community the MVs are designated as the inputs that are potentially changed by the controller and CVs are model outputs that are driven to target conditions. The terms FVs refer to either measured or unmeasured disturbances to the system and SVs are simply designated for viewing purposes as variables of importance. These parameter and variable classifications are specified in MATLAB or Python scripts (See additional details on FV, MV, SV, and CV classification).

Deleted lines 39-40:

(--include link to additional symbols--)

Changed lines 53-55 from:

MPECs - max, min, abs, if statements, etc

to:

Certain functions such as abs, if..then, min, max, signum, and discontinuous functions can be included in models but need to be posed in a way to allow efficient solution by solvers that perform better with continuous first and second derivatives. There are alternative methods to reformulate the problems. Two popular approaches are as MPECs (Mathematical Programs with Equilibrium Constraints) or with binary variables that switch on or off certain elements of the equations.

Changed line 13 from:
  • Equations are either equality constraints as f(dx/dt,x,p)=0, inequality constraints as g(dx/dt,x,p)>0, or expression of the objective with statements that begin with keywords maximize or minimize.
to:
  • Equations are either equality constraints as f(dx/dt,x,p)=0, inequality constraints as g(dx/dt,x,p)>0, or expression of the objective with statements that begin with keywords maximize or minimize (See additional details on equations).
Changed line 9 from:
  • Constants are values that never change. Integer values may be defined to give sizes to arrays (See additional details on constants)..
to:
  • Constants are values that never change. Integer values may be defined to give sizes to arrays (See additional details on constants).
Changed lines 9-12 from:
  • Constants are values that never change. Integer values may be defined to give sizes to arrays.
  • Parameters are values that are nominally fixed at initial values but can be changed with input data, by the user, or can become calculated by the optimizer to minimize an objective function if they are indicated as decision variables.
  • Variables are always calculated values as determined by the set of equations. Some variables are either measured and/or controlled to a desired target value.
  • Intermediates are explicit equations where the variable is set equal to an expression that may include constants, parameters, variables, or other intermediate values that are defined previously. Intermediates are not implicit equations but are explicitly calculated with each model function evaluation.
to:
  • Constants are values that never change. Integer values may be defined to give sizes to arrays (See additional details on constants)..
  • Parameters are values that are nominally fixed at initial values but can be changed with input data, by the user, or can become calculated by the optimizer to minimize an objective function if they are indicated as decision variables (See additional details on parameters).
  • Variables are always calculated values as determined by the set of equations. Some variables are either measured and/or controlled to a desired target value (See additional details on variables).
  • Intermediates are explicit equations where the variable is set equal to an expression that may include constants, parameters, variables, or other intermediate values that are defined previously. Intermediates are not implicit equations but are explicitly calculated with each model function evaluation (See additional details on intermediates).
Changed lines 14-21 from:
  • Objects are object-oriented extensions of APMonitor that may include parameters, variables, equations, and objective terms.
  • Connections are simple equality constraints that relate object variables to model parameter or variables.

There is an additional optional designation of parameters as either fixed values (FVs) or manipulated variables (MVs). Variables can be optionally designated as state variables (SVs) or controlled variables (CVs). The terminology of FV, MV, SV, and CV is from the process systems engineering community. In this community the MVs are designated as the inputs that are potentially changed by the controller and CVs are model outputs that are driven to target conditions. The terms FVs refer to either measured or unmeasured disturbances to the system and SVs are simply designated for viewing purposes as variables of importance.

Collections of constants, parameters, variables, intermediates, equations, objects, and connections constitute a model. The model file is created and stored in a text file with extension apm. Several text editors are available that support syntax highlighting such as Notepad++ and gEdit (see installation instructions).

 ! 5th order differential equation model with:
to:
  • Objects are object-oriented extensions of APMonitor that are stand-alone models that are instantiated from parent objects. The children objects may include parameters, variables, equations, and objective terms (See additional details on objects).
  • Connections are equality constraints that relate object variables to model parameter or variables from other models (See additional details on connections).

There is an additional optional designation of parameters as either fixed values (FVs) or manipulated variables (MVs). Variables can be optionally designated as state variables (SVs) or controlled variables (CVs). The terminology of FV, MV, SV, and CV is from the process systems engineering community. In this community the MVs are designated as the inputs that are potentially changed by the controller and CVs are model outputs that are driven to target conditions. The terms FVs refer to either measured or unmeasured disturbances to the system and SVs are simply designated for viewing purposes as variables of importance. These parameter and variable classifications are specified in MATLAB or Python scripts.

Collections of constants, parameters, variables, intermediates, equations, objects, and connections constitute a model. The model file is created and stored in a text file with extension apm. Several text editors are available that support syntax highlighting such as Notepad++ and gEdit (---see installation instructions). Below is an example model that demonstrates the use of many of these sections to create a 5th order differential equation model.

Changed lines 49-52 from:

Slack variables

include slack variable sections from optimization course

to:

Slack Variables

Slack variables are defined to transform an inequality expression into an equality expression with an added slack variable. The general expression for inequality constraints in the DAE expression is g(dx/dt,x,p)>0. An equivalent mathematical expression of the general inequality is g(dx/dt,x,p)=s and s>0. This form is desirable with solvers such as interior point methods where the initial guess must satisfy all inequality constraints or be on the inside of the feasible region. In the slack variable form, an initial guess value greater than zero for the new slack variable s satisfies this requirement. The APMonitor Modeling Language automatically transforms all inequality constraints into equivalent equality constraints with added slack variables.

Added lines 54-55:
Changed lines 7-8 from:

Models consist of sections including constants, parameters, variables, intermediates, and equations. All expressions used in the equations section must be created in one of the prior sections. The initialization of individual parameters or variables is sequential in the order that they are listed in the model file. Equations, however, can be listed in any order because equations are solved simultaneously.

to:

Models consist of sections including constants, parameters, variables, intermediates, equations, objects, and connections. All expressions used in the equations section must be created in one of the prior sections. The initialization of individual parameters or variables is sequential in the order that they are listed in the model file. Equations, however, can be listed in any order because equations are solved simultaneously.

Changed line 10 from:
  • Parameters are values that are nominally fixed at initial values but can be changed with input data, by the user, or can become calculated by the optimizer to minimize an objective function if they are indicated as degrees of freedom.
to:
  • Parameters are values that are nominally fixed at initial values but can be changed with input data, by the user, or can become calculated by the optimizer to minimize an objective function if they are indicated as decision variables.
Changed lines 17-19 from:

Collections of the above elements constitute a model and are stored in a text file with extension apm. Several text editors are available that support syntax highlighting such as Notepad++ and gEdit (see installation instructions).

to:

There is an additional optional designation of parameters as either fixed values (FVs) or manipulated variables (MVs). Variables can be optionally designated as state variables (SVs) or controlled variables (CVs). The terminology of FV, MV, SV, and CV is from the process systems engineering community. In this community the MVs are designated as the inputs that are potentially changed by the controller and CVs are model outputs that are driven to target conditions. The terms FVs refer to either measured or unmeasured disturbances to the system and SVs are simply designated for viewing purposes as variables of importance.

Collections of constants, parameters, variables, intermediates, equations, objects, and connections constitute a model. The model file is created and stored in a text file with extension apm. Several text editors are available that support syntax highlighting such as Notepad++ and gEdit (see installation instructions).

Changed lines 37-38 from:

In the above model comments are designated with !, %, or #. Another symbol is the dollar sign $ that indicates a differential variable or dxi/dt. The square brackets with the range of [1:n] creates 5 separate variables or x[1], x[2], x[3], x[4], and x[5]. Each variable is initialized with a lower bound of 0 and an initial condition of u=3. The variable y is defined in the intermediates section. This variable is a renaming of x[5] and is used in the objective function. The quantity x[n] could also be used in the objective function instead with the same result. There are no degrees of freedom for this problem.

to:

In the above model comments are designated with !, %, or #. Another symbol is the dollar sign $ that indicates a differential variable or dxi/dt. The definition of x[1:5] in the variables section creates 5 separate variables or x[1], x[2], x[3], x[4], and x[5]. Each variable is initialized with a lower bound of 0 and an initial condition of u=3. The variable y is defined in the intermediates section. This variable is a copy of x[5] and is used in the objective function as an output with a desired target value of 5. The quantity x[n] could also be used in the objective function instead with the same result. However, there are no degrees of freedom for this problem so the objective function has no effect on the solution.

Added lines 55-58:

Model Complexity

Model complexity can range from detailed finite element analysis to simple reduced order models. An important aspect of modeling is the overall goal of capturing the input to output relationships for a particular target application. In the case of real-time embedded systems, the complexity of the model may need to be limited to meet simulation or optimization speed requirements. Other times there is no computational time target for a solution and more sophisticated models can be solved. In each case, the correct level of sophistication should be carefully considered. One strategy for finding the appropriate level of complexity is to start with simple models and add complexity only as needed.

Changed line 19 from:
 ! state space model with:
to:
 ! 5th order differential equation model with:
Added line 25:
   K = 4
Changed line 29 from:
   x[1:n] = 0, >=0
to:
   x[1:n] = u, >=0
Changed line 31 from:
   y = K * u
to:
   y = x[n]
Deleted line 34:
   y = x[5]
Changed lines 37-40 from:

In the above model comments are designated with !, %, or #. The other symbol that is the $ that indicates a differential variable.

(--include additional symbols--)

to:

In the above model comments are designated with !, %, or #. Another symbol is the dollar sign $ that indicates a differential variable or dxi/dt. The square brackets with the range of [1:n] creates 5 separate variables or x[1], x[2], x[3], x[4], and x[5]. Each variable is initialized with a lower bound of 0 and an initial condition of u=3. The variable y is defined in the intermediates section. This variable is a renaming of x[5] and is used in the objective function. The quantity x[n] could also be used in the objective function instead with the same result. There are no degrees of freedom for this problem.

(--include link to additional symbols--)

Changed lines 50-51 from:
to:

include slack variable sections from optimization course

Added lines 55-60:

Exercise

Solution

Changed lines 5-6 from:

One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. In each section below are some of the key strategies related to model creation and formulation. The discussion begins with a basic introduction to

to:

One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. In each section below are some of the key strategies related to model creation and formulation. The discussion begins with a basic introduction to the APMonitor Modeling Language.

Changed lines 17-26 from:

Collections of the above elements constitute a model and are stored in a text file with extension apm. Several text editors are available that support syntax highlighting such as Notepad++ and gEdit (see installation instructions).

Discretization

Divide by zero

Scaling

Slack variables

to:

Collections of the above elements constitute a model and are stored in a text file with extension apm. Several text editors are available that support syntax highlighting such as Notepad++ and gEdit (see installation instructions).

 ! state space model with:
 ! input  (1) = u
 ! states (5) = x[1] to x[5]
 ! output (1) = y
 Constants
   n = 5
 Parameters
   u = 3, >=0, <=10
 Variables
   x[1:n] = 0, >=0
 Intermediates
   y = K * u
 Equations
   $x[1]   + x[1]   = K * u
   $x[2:n] + x[2:n] = x[1:n-1]
   y = x[5]
   minimize (y-5)^2

In the above model comments are designated with !, %, or #. The other symbol that is the $ that indicates a differential variable.

(--include additional symbols--)

Time Discretization

There is an inherent trade-off between accuracy and computational speed for numerical solution. Additional time discretization points generally improve the accuracy of a solution but also create additional computational burden. Fewer discretization points are needed when the dynamics are slow or the system is near a steady state solution. As a compromise finer discretization points are often used in regions of fast dynamics and more coarse discretization is used in regions of slow dynamics. Often the fast dynamics are present after a step change in an input or near the beginning of a horizon. Fast dynamics naturally decay as the system exceeds two dominant time constants after a change. The dominant time constant is generally dictated by the slowest process in the system to reach steady state. A dominant time constant is often empirically obtained by introducing a step input and simulating the system until it reaches steady state. The dominant time constant is approximately the amount of time necessary to reach (1-e-1) or 63% of the total response change from initial value to steady state.

There are also cases where dynamic data has been collected from a prior event. In these cases the model predictions are desired for comparison with the dynamic data. To compare model and data at each time point, the simulation step size of the simulation is adjusted to match the data frequency. These replay simulations can take excessive computational effort when large amounts of data are available. For these cases of dynamic data reconciliation, downsampling or less frequent time steps of the data may be used by collecting moving averages, infrequent points, or simply predicting at less frequent intervals than the data set.

Slack variables

Conditional Statements

Deleted line 54:
Added lines 4-28:

One of the most important factors in efficient and reliable solution of dynamic systems is the model formulation. Changes in model formulation are not intended to change the equations, only to put them into a form that allows solvers to more easily find an accurate solution. In each section below are some of the key strategies related to model creation and formulation. The discussion begins with a basic introduction to

Models consist of sections including constants, parameters, variables, intermediates, and equations. All expressions used in the equations section must be created in one of the prior sections. The initialization of individual parameters or variables is sequential in the order that they are listed in the model file. Equations, however, can be listed in any order because equations are solved simultaneously.

  • Constants are values that never change. Integer values may be defined to give sizes to arrays.
  • Parameters are values that are nominally fixed at initial values but can be changed with input data, by the user, or can become calculated by the optimizer to minimize an objective function if they are indicated as degrees of freedom.
  • Variables are always calculated values as determined by the set of equations. Some variables are either measured and/or controlled to a desired target value.
  • Intermediates are explicit equations where the variable is set equal to an expression that may include constants, parameters, variables, or other intermediate values that are defined previously. Intermediates are not implicit equations but are explicitly calculated with each model function evaluation.
  • Equations are either equality constraints as f(dx/dt,x,p)=0, inequality constraints as g(dx/dt,x,p)>0, or expression of the objective with statements that begin with keywords maximize or minimize.
  • Objects are object-oriented extensions of APMonitor that may include parameters, variables, equations, and objective terms.
  • Connections are simple equality constraints that relate object variables to model parameter or variables.

Collections of the above elements constitute a model and are stored in a text file with extension apm. Several text editors are available that support syntax highlighting such as Notepad++ and gEdit (see installation instructions).

Discretization

Divide by zero

Scaling

Slack variables

MPECs - max, min, abs, if statements, etc

Changed line 1 from:

(:title Formulation Strategies for Simulation of Dynamic Systems:)

to:

(:title Formulation Strategies:)

Added lines 1-3:

(:title Formulation Strategies for Simulation of Dynamic Systems:) (:keywords formulation, strategy, well-posed, modeling language, differential, algebraic, tutorial:) (:description Model formulation strategies for Differential Algebraic Equations (DAEs) with use in dynamic simulation, estimation, and control:)