0% found this document useful (0 votes)
13 views61 pages

CST-3021 - Ch2

Uploaded by

Kaunghtet Sween
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views61 pages

CST-3021 - Ch2

Uploaded by

Kaunghtet Sween
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 61

Third Year ( First Semester)

Introduction to Modeling and Simulation and Theory of Computation

CST - 3021
Faculty of Computing

CST - 3021 Faculty of Computing


Introduction to Computational
Science
Second Edition

CST - 3021 Faculty of Computing


CHAPTER 2

System Dynamics Problems with Rate Proportional to Amount

CST - 3021 Faculty of Computing


Contents

 2.1 System Dynamics Tool – Tutorial I


 2.2 Unconstrained Growth and Decay
 2.3 Constrained Growth
 2.4 System Dynamics Tool – Tutorial I
 2.5 Drug Dosage

CST - 3021 Faculty of Computing


Module 2.1 System Dynamics Tool—Tutorial 1

Introduction

Dynamic systems, which change with time, are usually very


complex, having many components, with involved relationships. Two
examples are systems involving competition among different species for
limited resources and the kinetics of enzymatic reactions.
-to perform basic modeling with such a tool, including the following:
• Diagramming a model
• Entering equations and values
• Running a simulation
• Constructing graphs
• Producing tables

CST - 3021 Faculty of Computing


Module 2.2 Unconstrained Growth and Decay

• Many situations exist where the rate at which an amount is changing is


proportional to the amount present.

• For example: When money is compounded continuously, the rate of


change of the amount is also proportional to the amount present.

• For a radioactive element, the amount of radioactivity decays at a rate


proportional to the amount present.

• Similarly, the concentration of a chemical pollutant decays at a rate


proportional to the concentration of pollutant present.

CST - 3021 Faculty of Computing


Rate of Change
Definition:

Suppose s(t) is the position of an object at time t, where a ≤ t ≤ b. Then the


change in time, Δt, is Δt = b – a; and the change in position, Δs, is Δs = s(b) – s(a).
Moreover, the average velocity, or the average rate of change of s with respect to t,
of the object from time a = b – Δt to time b is

CST - 3021 Faculty of Computing


Quick Review Question 1

Suppose on a windless day someone standing on a bridge holds a ball over the side
and tosses the ball straight up into the air. After reaching its highest point, the ball falls,
eventually landing in the water. The ball’s height in meters (m) above the water (y) is a
function (s) of time (t) in seconds (s), or y = s(t).

a. Determine the average velocity with units of the ball from t = 1 s to t = 2 s if s(1) =21.1 m

and s(2) = 21.4 m.

b. Determine the average velocity with units of the ball from t = 1 s to t = 3 s if s(1) = 21.1 m

and s(3) = 11.9 m.

c. Using the notation of the definition of average velocity, for Part b determine the following,
including units: b, s(b), Δt, b – Δt, s(b – Δt), Δs.

CST - 3021 Faculty of Computing


Solution
the ball’s height in meters (m) above the water
in time From part b,
time

average velocity = ?
average velocity

average velocity = ?
average velocity

CST - 3021 Faculty of Computing


Definition
The instantaneous velocity, or the instantaneous rate of change of s with respect to t, at t =
b is the number the average velocity, approaches as comes closer and closer to O (provide the ratio
approaches a number). In this case, the derivative of with respect to t at t = b, written is the
instantaneous velocity at . In general, the derivative of with respect to t is written as , or

can represent many things other than position.

For Eg,
a quantity ( mass ) of radioactive carbon – 14 at time t

the instantaneous rat of change of with respect to t ( instantaneous rate of decay)

CST - 3021 Faculty of Computing


a population at time t

(rate of change of population)

Differential Equation

Malthusian model for unconstrained population growth, where the rate of change of the
population is directly proportional (∝) to the number of individuals in the population.

Where the growth rate (or) instantaneous growth rate (or) continuous growth rate

the rate of change of the population

CST - 3021 Faculty of Computing


For Eg, a bacterial population of size 100, an instantaneous growth rate of 10%=0.10,
and time measured in hours. Thus , we had

with

The equation with the initial condition is a differential equation because it


contains a derivative. A solution to this differential equation is a function, , whose
derivative is with

CST - 3021 Faculty of Computing


Definitions:

A differential equation is an equation that contains one or more


derivatives. An initial condition is the value of the dependent variable when
the independent variable is zero. A solution to a differential equation is a
function that satisfies the equation and initial condition(s).

CST - 3021 Faculty of Computing


Difference Equation

population(t) = population(t – Δt) + (growth) * Δt

Where, growth = growth_rate * population,


population(t) = the population at time t
population(t – Δt) = the population at time t – Δt (previous time)
This equation, called a finite difference equation, indicates that the population at one
time step is the population at the previous time step plus the change in population
over that time interval:

(new population) = (old population) + (change in population)

CST - 3021 Faculty of Computing


OR
population(t) = population(t – Δt) + Δpopulation
Δ population = the change in population
Δpopulation = (growth) * Δt

growth =

Computer programs and system dynamics tools employ such finite difference
equations to solve differential equations.

CST - 3021 Faculty of Computing


CST - 3021 Faculty of Computing
Definition:

A finite difference equation is of the following form:


(new value) = (old value) + (change in value)
Such an equation is a discrete approximation to a differential equation.

Quick Review Question 2

Consider the differential equation dQ/dt = – 0.0004Q, with Q0= 200.

a. Using delta notation, give a finite difference equation corresponding to the differential
equation.
b. At time t = 9.0 s, give the time at the previous time step, where
Δt = 0.5 s.
c. If Q(t – Δt) = 199.32 and Q(t) = 199.28, give ΔQ.

CST - 3021 Faculty of Computing


Solution

finite differential equation is


new value = old value + change in value

(b) t = 9.0 s, Δt = 0.5 s


the time at the previous time step = ?

(c)

CST - 3021 Faculty of Computing


Example

We can show that:


the population at time t = 0-025 h is approximately
population (0.025) = 100.250250 bacteria, growth rate = 10% = 0.1
growth = growth_rate * population (0.025) = 0.1*100.250250 = 10.025025 bacteria per hour
For Δt = 0.005 h,
the next time step = 0.025 + 0.005 = 0.030 h
change in population of bacteria to the next time step (0.030 h) = growth * Δt
= 10.025025*0.005
= 0.050125 bacteria
the population at time 0.030 h = 100.250250 + 0.050125 = 100.300375

CST - 3021 Faculty of Computing


Quick Review Question 3

Evaluate population(0.045), the population at the next time interval after the end of
Table 2.2.1, to six decimal places.

Table 2.2.1

Table of Estimated Populations, Where the Initial Population is 100, the Continuous
Growth Rate is 10% per Hour, and the Time Step is 0.005 h

CST - 3021 Faculty of Computing


growth = growth_rate population (0) = 0.1 100 = 10

t Population (t) = population(


0.000 100.000 000
0.005 100.050 000 = 100.000 000 + 10.000 000 0.005
0.010 100.100 025 = 100.050 000 + 10.005 000 0.005
0.015 100.150 075 = 100.100 025 + 10.010 003 0.005
0.020 100.200 150 = 100.150 075+ 10.015 008 0.005
0.025 100.250 250 = 100.200 150 + 10.020 015 0.005
0.030 100.300 375 = 100.250 250 + 10.025 025 0.005
0.035 100.350 525 = 100.300 375 + 10.030 038 0.005
0.040 100.400 701 = 100.350 525 + 10.035 053 0.005
0.045 100.400 701 = 100.350 525 + 10.035 053 0.005

Population (0.045) = 100.400 701


CST - 3021 Faculty of Computing
CST - 3021 Faculty of Computing
Rule of Thumb :

Although the simulation takes longer because of more computation, it is


usually more accurate to use a small step size (Δt), say, 0.01 or less.

CST - 3021 Faculty of Computing


Simulation Program

CST - 3021 Faculty of Computing


Revised Program

CST - 3021 Faculty of Computing


Analytical Solution: Introduction
We can solve the preceding model analytically for unconstrained growth, which is the
differential equation with initial condition as follows:

CST - 3021 Faculty of Computing


For example, if

Completion of the Analytical Solution

The general solution is , with


A particular solution of the form is

CST - 3021 Faculty of Computing


Quick Review Question 4
Give the solution of the differential equation w.
Find

Solution

CST - 3021 Faculty of Computing


Q

CST - 3021 Faculty of Computing


Further Refinement
growth_rate = birth_rate - death _ rate

Unconstrained Decay
The rate of change of the mass of a radioactive substance is proportional to the
mass of the substance, and the constant of proportionally is negative.

Example, the constant = r = -0.000 120 968 = -0.012 0968%


Q = the quantity (mass) of carbon-14

CST - 3021 Faculty of Computing


Example 1
Suppose the proportion of carbon-14 in a mummy is only about 20% of that in a
living human. Estimate the age of the mummy.

Solution
the age of the mummy=?
Let Q = the amount of carbon-14 in a mummy
= the amount of carbon-14 in living human
Q =20%=0.20

CST - 3021 Faculty of Computing


Q

Q =
0.20

CST - 3021 Faculty of Computing


Definition
The half-life is the period of time that it takes for a radioactive to decay to half of its
original amount.

Quick Review Question 5

Radium-226 has a continuous decay rate of about 0.0427869% per year. Determine its
half-life in whole years.

Solution

CST - 3021 Faculty of Computing


Q

for Q =
0.5

CST - 3021 Faculty of Computing


MODULE 2.3
Constrained Growth
Carrying Capacity

Unconstrained Growth and Decay

Definition
The carrying capacity (M) for an organism in an area is the maximum number of
organisms that the area can support.

CST - 3021 Faculty of Computing


Revised Model

 For an initial population much lower than the carrying capacity, we want the population to
increase in approximately the same exponential fashion as in the earlier unconstrained model.

 The population size gets closer and closer to the carrying capacity, the number of deaths should
be almost equal to the number of birth, so that the population remains roughly constant.

 To accomplish this dampening of growth, compute the number of deaths as a changing fraction of
the number of birth, as .

 When the population is very small, we want the fraction to be almost zero, indicating that few
individuals are dying.

 When the population is close to the carrying capacity, the fraction should be almost .

CST - 3021 Faculty of Computing


Revised Model

For population larger than the carrying capacity, the fraction should be even larger so that the
population decreases in size through deaths. Such a fraction is P/M.

For example,
If the population P is 10 and the carrying capacity M is 1000,
then = 10/1000 = 0.01 = 1%.
For a population P = 995 close to the carrying capacity, P/M = 995/1000 = 0.995
= 99.5 %;
for the excessive P = 1400, P/M = 1400/1000 = 1.400 = 140%

CST - 3021 Faculty of Computing


Revised Model
We can model the instantaneous rate of change of the umber of deaths (D) as the fraction P/M
times the instantaneous rate of change of the number births (r), as the following differential
equation indicates:

The differential equation for the instantaneous rate of change of the population subtracts this
value from the instantaneous rate of change of the number of births, as follows:

(OR) birth death

CST - 3021 Faculty of Computing


Revised Model

births deaths

CST - 3021 Faculty of Computing


Quick Review Question 4
a. Complete the difference equation to model constrained growth of a population P with respect to time t
over a time step of 0.1 units, given that the population at time is the carrying capacity is 1000, the
instantaneous rate of change of births is 105%, and the initial population is 20.

b. What is the maximum population?


c. Suppose the population at time is 600 individuals. What is the population, rounded to the nearest
integer, at time

Solution

the population at time

the instantaneous rate of change of births 105%1.05

CST - 3021 Faculty of Computing


b. individuals

c. individuals,

individuals(nearest integer)
Equilibrium and Stability

Definitions
An equilibrium solution for a different equation is a solution where the derivative is
always zero. An equilibrium solution for a different equation is a solution where the change is
always zero.

Definitions
Suppose that q is an equilibrium solution for a differential equation or a difference
equation . The solution q is stable if there is an interval containing q, such that if the initial
population is in that interval, then

1. is finite for all


2. As time, t, becomes larger and larger, approaches q

The solution q is unstable if no such interval exists.

CST - 3021 Faculty of Computing


MODULE 2.4
System Dynamics Tool: Tutorial 2

This tutorial introduces the following functions and concepts, subsequent modules
employ for model formulation and solution using your system dynamics tool:

 Built-in functions and constants, such as the if-then-else construct, absolute value, initial
value, exponential function, sine, pulse function, time step, and
 Relational and logical operators
 Comparative graphs
 Graphical input
 Conveyors, an optional topic useful for some of the later projects

CST - 3021 Faculty of Computing


MODULE 2.5
Drug Dosage
Introduction
 Errors in the dispensing and administration of medications occur frequently.
How do these errors occur? According to the Institute of Medicine, medication
errors can be classified as error in
orderingincorrect drug or dosage;
transcribingincorrect frequency of a administration or missed dosages;
dispensingincorrect drug, dosage, or timing;
administeringwrong dosage, technique;
monitoringnot observing effects of medication.

There are prescribed dosages for various drug, but how do we determine what
the correct/ effective dosage is? There are quite a number of factors that are considered,
including drug absorption, distribution, metabolism, and elimination. These factors are
components of the quantitative science of pharmacokinetics.

CST - 3021 Faculty of Computing


One-Compartment Model of Single Dose

CST - 3021 Faculty of Computing


One-Compartment Model of Single Dose

CST - 3021 Faculty of Computing


One-Compartment Model of Single Dose

• The flow from aspirin_in_plasma (elimination) is proportional to the amount present in the
system, aspirin_in_plasma.
• Thus, the rate of change of the drug leaving the system is proportional to the quantity of drug in
the system (aspirin_in_plasma, or Q in the following equation):

The constant of proportionality K earlier and elimination constant in the system dynamics
software model have the following relationship to the drug’s half-life
Q

Pharmaceutical sources widely report a drug’s half-life.

CST - 3021 Faculty of Computing


Quick Review Question 1

Determine the elimination constant with units for aspirin, assuming a half-life of 3.2 h.

Solution

CST - 3021 Faculty of Computing


One-compartment model of a aspirin

CST - 3021 Faculty of Computing


CST - 3021 Faculty of Computing
Quick Review Question 2

In terms of the variables in the model of Figure 2.5.1, give the equation for plasma_
concentration.

CST - 3021 Faculty of Computing


One-Compartment Model of Repeated Doses

CST - 3021 Faculty of Computing


One-Compartment Model of Repeated Doses

• Because of the periodic nature of the dosage, we employ a pulse function with
converters/variables for the dose (dosage), time of the initial dose (start), and time interval
between doses (interval).
• Only a fraction (absorption_fraction) actually enters the system, we multiply this constant
(0.12) and the pulse value together for the equation of entering.

CST - 3021 Faculty of Computing


Quick Review Question 3
Give the equation of entering.

Solution
entering = absorption_fraction * (pulse of amount dosage beginning at start every interval
hours)

CST - 3021 Faculty of Computing


One-Compartment Model of Repeated Doses

Equation Set 2.5.2

CST - 3021 Faculty of Computing


Mathematics of Repeated Doses

• Suppose that the patient takes a 100-mg tablet every 8 h.


• In the model, we assumed an absorption level of 0.12, the effective dosage is elimination rate
• The amount of drug in the system after 8 h is

• At the end of 8-h about 77.72% of the drug remains in the system.
Suppose
Thus, assuming 77.72% of the drug remains in the system at the end of an 8-h interval
immediately before a dose, we have the following:

After 8-h,

After 16-h,

CST - 3021 Faculty of Computing


Mathematics of Repeated Doses

After 24-h,

Similarly, the quantity of the drug immediately after the , follows;


)
Quick Review Question 4

Suppose a patient takes a 200-mg tablet once a day, and within 24 h, 75% of the drug is
eliminated from the body. With being the quantity of the drug in the body after the dose,
determine the following:

a. expressed as a sum
b. expressed as a sum
c. expressed as a sum
d. expressed as a sum

Solution
= the quantity of the drug in the body after the dose
The drug eliminated from the body = 75%
The drug remained in the body = 25% = 0.25

CST - 3021 Faculty of Computing


CST - 3021 Faculty of Computing
Definition

for and positive integer n is a finite geometric series with base a.

Quick Review Question 5

Using the drug of QRQ 4 and the formula for the sum of a finite geometric
series, evaluate the following:

Solution

CST - 3021 Faculty of Computing


Quick Review Question 6

Using the drug of QRQ 4 and 5, determine the quantity of drug after the
when the patient has been taking the drug for a long time

Solution

CST - 3021 Faculty of Computing

You might also like