Skip to content

Making Connections

isee systems blog

Making Connections

  • About
  • More Connections
Search

Spatial Modeling in iThink and STELLA

Updated: April 7, 2009March 31, 2009Filed under: Modeling Tips1 Comment

STELLA and iThink provide capabilities to model spatial problems.  Version 9.1.2 expands these capabilities to allow more intuitive equation formulations.

Spatial modeling is concerned with modeling behavior over space as well as time.  Common applications include modeling flows in lakes and streams or modeling development in an urban landscape.  To demonstrate the new capabilities in version 9.1.2, the one-dimensional diffusion problem will be modeled in STELLA.

Consider the diffusion of heat through a one meter metal bar when a constant temperature is applied to both ends.  This problem is typically introduced as the following partial differential equation for temperature function u(x, t) with the given boundary conditions:

∂u/∂t – k ∂2u/∂x2 = 0
u(x, 0) = 0, 0 < x < 1
u(0, t) = u0, t ≥ 0
u
(1, t) = u0, t ≥ 0

Here, k is the diffusion coefficient (based on thermal conductivity, density, and heat capacity) and u0 is the constant temperature applied to both ends of the bar.  The finite difference solution to this problem (with the above initial conditions) is:

u(x, t + dt) = u(x, t) + ∂u/∂t
∂u/∂t = k (u(x + dx, t) – 2u(x, t) + u(x – dx, t))/dx2

It is also possible to derive a closed-form solution.  Unless you are an astrophysicist, this solution probably does little to help you understand what is happening.  It is far more intuitive to develop a physical model of the underlying mechanics than to wrestle with the mathematics.

If you consider the metal bar as a single object that is being acted on by its environment, it is possible to consider some of the changes to that bar over time.  If the environment is warmer than the bar, there will be an inflow of heat to the bar.  If the bar is warmer than its surrounding environment, there will be an outflow of heat from the bar.  We probably all know from experience that a hot bar will radiate heat outward in all directions, so in a three-dimensional problem, heat would flow outward in all directions.

If you divide the bar into a set of consecutive finite elements (a finite element is just a fancy word for a small fixed-size section of a larger object – finite because its size is bounded), it becomes possible to imagine a model of what happens to each of these elements individually.  Connecting them in tandem should then yield the behavior of the entire bar.  This is the essence of spatial modeling.

Using the ideas above, we must have some amount of heat entering each element and some amount leaving each element.  For this problem, however, which way does the heat radiate?  The problem is intentionally limited to one dimension, x, so the only choice for the direction of radiation (from an element’s point of view) is left or right.  Thus, we can have heat radiating into the element from either the left or right side, and heat radiating out of the element from either the left or right side.  This is shown in the diagram below and is our model for a finite element of the metal bar.  Note that for clarity u has been renamed T for temperature.

element

If we chain a number of these elements together horizontally, we will have a model of the entire metal bar.  Using three elements leads to the following model of the metal bar.

elements-in-tandem

This model is obviously greatly simplified.  Note that heat applied left is the heat arriving from the left side of T1.  The heat leaving from the left side is zero, so is not even shown.  An analogous simplification has been made to T3.  This simplified model allows us to consider the nature of each of the four flows in our modeled element, as all of them relate to the neighbors of that element.  In this example, T2 has one neighbor to the left, T1, and one neighbor to the right, T3.  Thus, any heat gained from the left must come from T1 and any heat gained from right must come from T3.  In addition, any excess heat T2 has will radiate out to T1 on the left and T3 on the right.  This simple structure allows us to arrive at the equations for the four flows in our finite element model, shown in terms of both this example and the general finite element model:

in left = C·T1 = C·T(x – dx, t)
out left
= C·T2 = C·T(x, t)
out right
= C·T2 = C·T(x, t)
in right
= C·T3 = C·T(x + dx, t)

C is a diffusion constant describing the rate of temperature loss from a warm body, i.e., the fraction radiated by a finite element.  In the one-dimensional case, C = k/dx2.  Note that summing these four flows together properly (i.e., adding the inflows and subtracting the outflows) yields the exact same ∂u/∂t equation derived mathematically and shown above.

But are three elements, two of which are held at the applied temperature, sufficient to properly model a one meter metal bar?  Not really.  The number of elements used defines dx.  Specifically, dx = bar length/number of elements, in this case 1 m/3 = 1/3 m.  Like dt, dx must be small enough to properly catch the dynamics of the system.  We need far more elements to properly model this problem.  Since we have broken the metal bar down into identical finite elements, it becomes natural to build the metal bar up using an array of finite elements rather than showing each individual element.  This model looks like this:

element-model

Version 9.1.2 allows the equations above to be naturally expressed as Apply to All equations as follows:

in left = C*T[X – 1]
out left
= C*T[X]
out right
= C*T[X]
in right
= C*T[X + 1]

where X is name of the array dimension.  Note the value one is used instead of dx.  This is because each array element represents a finite element of width dx.  The subscript for the array counts elements rather than distance.  To get the position of the element along the bar it is necessary to multiply the index of the element by dx.  Also note that t is not represented by a subscript in the array.  This is because all models already simulate across time.  Therefore, all entities in a model are functions of time.  Running this model gives the expected behavior:

element-results

A final note:  Version 9.1.2 allows any constant, not just one, to be added to, or subtracted from, a dimension name in an equation.  The software evaluates T[X + c] to zero when X + c results in a subscript beyond the bounds of the array.  Thus, when X = 1, the first element, T[X – 1] will be forced to zero.  Likewise, when X = DIMSIZE(), the last element, T[X + 1] will be forced to zero.  As you will discover when you explore it, this particular model (1d-diffusion) forces these end conditions to the constant temperature being applied (100 in this case).

Editor’s Note:  This is part 1 of a 3-part series on spatial modeling in iThink and STELLA.  Part 2 is available here.  Part 3 will be posted the week of April 12th, 2009.

Modeling Tips
  • arrays
  • diffusion
  • iThink/STELLA
  • spatial
  • Version 9.1.2

Post navigation

Previous Post:

A Minor Release with Major Features

Next Post:

Video Demonstrates Modeling with Modules

About the Author

Karim Chichakly

Co-President

All posts byKarim ChichaklyWebsite

Hide

Categories

  • Education (4)
  • isee NetSim (3)
  • isee.NET Framework (1)
  • Modeling Tips (32)
  • News & Announcements (15)
  • STELLA & iThink (14)
  • Stories from the Field (5)
  • Systems Thinking (8)
  • Training (6)

Archives

Browse by keyword

2D array archetypes arrays Barry Richmond Bass diffusion builtins calibration Causal Loop CLD command line conferences crisis data diffusion Education environment export game graphical function h1n1 healthcare housing import iThink/STELLA market dynamics MODSIM modules mortgage netsim optimization Physics policy price releases scholarship software spatial Stella storytelling System Dynamics Society Systems Thinking Version 9.1.2 video webinar workshop

Recent Posts

  • COVID-19: Modeling Distributions of Incubation and Recovery Times April 1, 2020
  • Multiobjective Optimization January 9, 2018
  • Optimizing Model Performance December 22, 2017
  • Calibration in Stella® December 15, 2017
  • Drifting Goals March 9, 2016

RSS System Dynamics Forum

Recent Comments

  • best apps review on About
  • digital software on Modeling the Economic Crisis
  • Mishawaka Indiana on What are “Mental Models”?
  • La Paz Indiana on XMILE – An open standard for system dynamics models
  • Bristol Indiana on Modeling the Economic Crisis

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Products
Software (v1.3)
  • Stella Architect
  • Stella Professional
  • Stella Designer
  • Stella Simulator
  • iThink
  • Feature Updates
  • Policies
  • Publishing Options
  • License Agreement
Free Software
  • Stella Online
  • isee Player
  • Stella Architect Trial
Solutions
Consulting
  • Systems Innovation Practice
Common Applications
  • Business
  • Education
  • Research
  • Government
  • Energy
  • Health
  • Agriculture
  • Manufacturing
  • Conservation
Quick Links
About
  • isee systems
  • Systems Thinking
  • Barry Richmond Scholarship
Resources
  • Frequently Asked Questions
  • Product Help
  • Examples
  • Request Support
  • Request Quote
  • Systems in Focus
  • Quick Tips
  • Legacy Tutorials
News and Events
Upcoming Workshops
  • Introduction to Dynamic Modeling
  • Whole Systems Partnership
Newsletter
  • The Connector
Recent Webinars
  • Model Mysteries
Recent Training
  • Systems Thinking Practice
Press Release
  • Stella Architect Release

  Phone: (603) 448-4990   Email: info@iseesystems.com

   Monday - Friday: 9:00 am - 5:00 pm EDT | Saturday - Sunday: Closed
Wheelock Office Park | 31 Old Etna Rd, Suite 7N | Lebanon, NH 03766 | US

isee systems inc. holds registered trademark rights over the following: iThink®, STELLA®, Stella®, isee systems® and claims the following trademarks; isee NetSim™, Stella Live™, Causal Lens™ and Stella Online™.

Terms of Use

© 2017. isee systems inc . All rights reserved.