Archive

Posts Tagged ‘arrays’

Spatial Modeling in Two Dimensions

April 7th, 2009 10 comments

Editor’s Note:  This is part 2 of a 3-part series on spatial modeling in iThink and STELLA.  Part 1 is available here.  Part 3 is available here.



Last time, we explored spatial modeling using the one-dimensional diffusion problem as an example.  Many spatial applications, however, require two dimensional formulations.  As an extension, we will now explore the two-dimensional diffusion problem.  Instead of a one-meter metal bar with constant heat applied at its ends, the two-dimensional diffusion problem looks at the response of a one-meter by one-meter metal plate with constant heat applied to its center.  We then watch the heat diffuse across the plate.

At first blush, one might think the two-dimensional case is much more difficult than the one-dimensional case.  In particular, if a grid is superimposed over the plate, each finite element on the plate has eight neighbors, as shown below.  It is tempting, therefore, to consider radiating heat in each of these eight directions.

2d-radiation

However, without looking at the two-dimensional diffusion equations, if we consider just the physical layout of this system, the four corners of the finite element only touch the four corner neighbors (1, 3, 5, and 7) at one point.  In contrast, the four sides of the finite element are shared with each of its four immediate neighbors (2, 4, 6, and 8).  This suggests that heat only radiates to (and from) these four neighbors, not all eight.  In fact, if we examine the two-dimensional diffusion equation, we find that there are only component contributions in the x– and the y-directions.  There are no contributions on the diagonal (which would appear in the equation as ∂2u/∂xy and ∂2u/∂yx terms).

Intuitively, then, we have a finite element that is very similar to the one-dimensional case.  We only need to add corresponding flows in the y-direction.  This leads to the following model with the individual finite elements arrayed.

2d-element-model

The array T is now two-dimensional, in x and in y.  In addition, dx can differ from dy, so the diffusion constant C must be broken down into its constituent parts Cx = k/dx2 and Cy = k/dy2.  This leads to the following set of equations for the radiant flows through the plate:

in left = Cx*T[X – 1, Y]                               in top = Cy*T[X, Y – 1]
out left
= Cx*T[X, Y]                                  out top = Cy*T[X, Y]
out right
= Cx*T[X, Y]                              out bottom = Cy*T[X, Y]
in right
= Cx*T[X + 1, Y]                          in right = Cy*T[X, Y + 1]

X and Y are dimension names for the elements in the x– and ­y-directions, respectively.

Using isee Spatial Map, it is possible to view the results of this diffusion across two dimensions.  Spatial Map displays an array as a one-dimensional or two-dimensional grid (depending on the array).  Each cell in the grid is filled with a color corresponding to the value in the corresponding cell of the array.  Below are two spatial maps.  The one on the left shows the initial conditions of the metal plate.  Note that heat only appears in the center of the plate, where it is being externally applied.  The map on the right shows the distribution of heat across the plate at the end of a six-minute simulation.

2d-element-results

The model is available here:  2d-diffusion.  It is already configured to use isee Spatial Map.  In the final installment of this 3-part series, I will describe how to set up isee Spatial Map.

Spatial Modeling in iThink and STELLA

March 31st, 2009 No comments

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/∂tk2u/∂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(xdx, 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.

Read more…

New ARRAYRANK Builtin Sorts Array Values

February 17th, 2009 4 comments

Version 9.1.2 will introduce the ARRAYRANK feature.  Here is a preview of its capabilities.

The ARRAYRANK built-in can be very powerful for some applications.  It allows you to order the values in an array from smallest to largest or vice-versa.  In this sense, it expands upon what ARRAYMINIDX (find the index of the smallest value) and ARRAYMAXIDX (find the index of the largest value) already do.

To introduce ARRAYRANK, let’s look at a simple model that uses it.  In this model, we explore the efficacy of applying tiered commissions for salespeople in an effort to encourage them to sell more.  Each tier is designed as a reward so the top seller in any given week gets the highest percentage, while those who do not perform will get the lowest.  The tiers are:

Top seller:                    20%
2nd best seller:            15%
3rd best seller:             10%
Everyone else:               5%

Note that the non-tiered system gave everyone 10%.  The model is very simple:

arrayrank-model

Read more…

Tip: Setting up imports for 2D Graphical Functions

January 29th, 2009 8 comments

iThink and STELLA version 9.0 introduced a powerful new feature: data import and export with Excel.  Here at isee, we were excited to hear from our customers about how much they appreciated the feature and how easy it was to use.  In fact, many customers told us that it was the major reason they upgraded to version 9.0
simple import 1

Setting up a data import from Excel is pretty straight forward:  type the name of the model variable in one cell, type the value you want to import in the cell below it, (or beside it if you are using horizontal orientation):

If you are importing a time series or graphical function, you just keep listing the data points in the cells below the variable name:

simple import 2

This kind of data formatting works well since an Excel sheet is made up of columns and rows.  But how do you format data that is harder to visualize?  Things get a little tricky when you start dealing with arrayed variables.  The most complex import is a 2 dimensional array of graphical functions.  It’s actually 3 dimensions!

I’ve put together a simple example to illustrate how to do this.

Read more…