Sie sind auf Seite 1von 51

Equivalent Stress Blocks

Posted on October 19, 2011 by dougaj4

Previous posts (e.g. Stress blocks in AS 3600) have presented Excel User Defined Functions
(UDFs) that determine the ultimate bending strength of a reinforced concrete section with the
use of a rectangular concrete stress block, with depth and stress factors adjusted so that the
results are identical to those using a parabolic-rectangular block, such as that defined in
Eurocode 2. This post provides details of this procedure, including VBA code for a UDF to
calculate the required factors for any specified concrete strength.

The figure below (from Eurocode 2) illustrates how a non-linear stress-strain curve may be
approximated by a rectangular stress block, applied over part of the area in compression.

Eurocode 2 Rectangular Stress Block

If the stress block is being used with a rectangular cross section it is possible to calculate
values for the depth and stress such that the area under the block, and the lever arm from the
neutral axis, are exactly equal to that for any specified curvilinear stress-strain relationship.
Parabolic and Equivalent Rectangular Blocks

The procedure for calculating the rectangular stress block equivalent to the Eurocode 2
parabolic/rectangular block is shown below :
Equivalent Rectangular Stress Block Procedure

This procedure can be simply coded in a VBA function (to use the function in your own
spreadsheet, copy and paste the code into any VBA module):

1 Function EquivSB(Fc As Double, Optional Out As Long = 0, Optional RFact As


2 Double = 0.9) As Variant
Dim Epscu As Double, Epscm As Double, n As Double, K As Double
3 Dim Ap As Double, Ar As Double, LAp As Double, LAr As Double, Qc As Double,
4 Ac As Double, LAc As Double
5 Dim SBFA(1 To 5, 1 To 1) As Variant
6
7 ' Find rectangular stress block factors for block equivalent to the
Eurocode parabolic/rectangular block
8
9 ' Find ultimate strain (Epscu), strain at maximum stress (Epscm) and
10parabolic exponent (n)
11' Based on Eurocode 2 Table 3.1
12If Fc Epscu = 0.0035
Epscm = 0.002
13 n = 2
14 Else
15If Fc < 90 Then Epscu = 0.0026 + 0.035 * ((90 - Fc) / 100) ^
164 n = 1.4 + 23.4 * ((90 - Fc) / 100) ^ 4
17Else Epscu = 0.0026 n = 1.4 End If
18 Epscm = 0.002 + 0.000085 * (Fc - 50) ^ 0.53 If Epscm > 0.0026
19 Then Epscm = 0.0026
End If
20
21' Find area and lever arm of parabolic, rectangular and composite curves
22K = Epscm / Epscu
23 Ap = K * (n / (n + 1))
24 LAp = K * ((n + 3) / (2 * (n + 2)))
25
Ar = 1 - K
26 LAr = 1 - (1 - K) / 2
27
28Qc = Ap * LAp + Ar * LAr
29 Ac = Ap + Ar
30LAc = Qc / Ac
31
32' If out = -1 generate description of each output array item
If Out = -1 Then
33SBFA(1, 1) = "Gamma"
34SBFA(2, 1) = "Alpha2"
35SBFA(3, 1) = "Epscu"
36SBFA(4, 1) = "Epscm"
37SBFA(5, 1) = "n"
' Else generate output array values
38 Else
39SBFA(1, 1) = (1 - LAc) * 2
40SBFA(2, 1) = Ac / SBFA(1, 1) * RFact
41SBFA(3, 1) = Epscu
42SBFA(4, 1) = Epscm
SBFA(5, 1) = n
43 End If
44
45' If out < 1 then return complete array, else return the specified array
46value
47 If Out < 1 Then
EquivSB = SBFA
48 Else
49EquivSB = SBFA(Out, 1)
50 End If
51
52End Function

And this is what the function looks like in use:


Equivsb() Function

The function arguments are:

 Fc: the concrete strength grade


 Out (optional): 0 or omit to return the full array of output values
-1 to return an array of descriptions of each output value
1 to 5 to return a specified value
 Rfact (optional): reduction factor on concrete stress (default = 0.9)

Enter as an array function to return the full array (see here for details of using array
functions).

Share this:

Reinforced Concrete Moment-Curvature – 4;


Development of curvature over time
Posted on February 12, 2010 by dougaj4

The previous post in this series looked at how specified shrinkage and creep strains affect the
curvature of a reinforced consrete section subject to a constant load. In this post I will
present a User Defined Function (UDF) that analyses the curvature due to loading, prestress,
creep and shrinkage over a series of time steps, allowing the interaction between these factors
to be taken into account, and also allowing for variation in loading and the concrete stiffness
over time.

The UDF has been added to RC design functions6.zip. As usual, the spreadsheet includes
full open sourec code.
The procedure used is:

 Read the section properties, creep and shrinkage parameters for each time step, and
optionally load, prestress and concrete E value for each time step.
 For each time step:
 Adjust the applied loads, prestress, and concrete E value, if required.
 Adjust the concrete E value for the increase in creep from the previous step.
 Calculate a virtual prestress force equivalent to the total shrinkage and creep strain up
the the previous step, plus the shrinkage strain for the current step.
 Calculate the section strains and curvature for the current step.
 Update the virtual prestress to include the creep increment from the current step.
 Go to next time step.

The screenshot below shows typical input data and results from the TimeCurve function
compared with a time-step analysis carried out in the finite element analysis program
Strand7.

Click to view full size

This screenshot shows typical time-step data and results. Note that the UDF must be entered
as an array function (press ctrl-shift-enter) to view all the results.:
Click to view full size

The spreadsheet also includes the following new functions:

 TimeSteps – generates a series of timesteps with logarithmic spacing


 EC2Props – generates concrete properties for a given age and strength grade, as
specified in Eurocode2.

Reinforced Concrete Moment-Curvature – 3; Restrained


Shrinkage and Creep
Posted on January 23, 2010 by dougaj4

The previous post in this series provided Excel User Defined Functions (UDFs) to find the
strain in a concrete section due to unrestrained creep and shrinkage. In this post the effect of
restraint of the creep and shrinkage strains by the section reinforcing steel will be discussed,
and in the following post a UDF will be presented that allows the stresses and strains in the
section to be calculated allowing for creep and shrinkage strains and variation in the applied
load and prestress over time.

Both shrinkage and creep result in a shrinkage strain in the concrete, with no change in stress
for an unrestrained section, but for a reinforced section the reinforcement partially restrains
the concrete strain, resulting in a transfer of compressive stress from the concrete to the
reinforcement for zones in compression, or an increase in the tensile stress in the concrete for
uncracked zones in tension.

A simple way to visualise the effect of shrinkage on the strains and stresses in a reinforced
section is to apply an imaginary external compressive axial force to the reinforcement, so that
it follows the unrestrained shrinkage strain of the concrete, with no change to the concrete
stress. If the external force is then removed the state of stress and strain in the section will be
the same as for a section that has undergone shrinkage with no change to the external loads
(except for the effects of creep, which will be discussed later). This analysis is illustrated
below:

Before Shrinkage

Concrete shrinkage + external load to reinforcement

Remove external load to reinforcement


Apply bending below cracking moment

Apply bending greater than cracking moment

Analysis with “negative” prestress; click to view full size

Note that:
 For an uncracked section with symmetrical reinforcement the shrinkage strain does
not affect the curvature of the section.
 For a cracked section there is a significant change in curvature due to shrinkage
strains, even for symmetrical reinforcement.
 The restraint of the shrinkage strain causes a significant increase in the tensile stress
in the concrete, which results in a reduction of the cracking moment.
 The effect of shrinkage may be analysed by applying a compressive prestress to the
reinforcement, equal to the free concrete strain multiplied by the reinforcement elastic
modulus.
 The change in stress in the concrete due to shrinkage is reduced by the effects of
creep. Analysis of this effect is discussed below.

Creep is the increase over time of strain due to applied load. Creep typically increases the
strain in the concrete by a factor of the order of 3, and must therefore be considered in
assessment of the long term behaviour of concrete structures. The reinforcing steel is also
subject to creep strains, but at typical reinforcement stresses the effects are negligible (except
for prestressed reinforcement, where the relaxation of prestress due to creep must be
considered). Since shrinkage results in a change of stress in the concrete, this interacts with
creep effects.

The effect of creep strains could in principle be analysed in the same way as shrinkage, by the
application of a virtual prestress to the reinforcement, but since the magnitude of the creep
strain is proportional to the stress in the concrete, the magnitude of the virtual prestress is
dependent on the stress in the concrete after completion of creep, so an iterative procedure
would be required to find the correct level of prestress. A simpler approach is to use an “age
adjusted modulus” for the concrete, so that the analysed strain in the concrete includes both
elastic and creep strains. For a creep coefficient of Ø the age adjusted modulus is given by Et
/ (1+ Ø), where Et is the elastic modulus of the concrete at the time of loading.

Having found the concrete stresses after creep using the age adjusted modulus method, it is
possible to find the equivalent virtual prestress that will result in the same stresses and
curvature in the section. The virtual prestress for creep is given by Es ec Ø / (1+ Ø), where Es
is the elastic modulus of the reinforcing steel, and ec is the total strain in the concrete at the
level of the reinforcement, as determined by the age adjusted modulus method. This prestress
is then applied in conjunction with the unreduced concrete modulus, giving exactly the same
end results for stresses in the concrete and reinforcement, and strains in the reinforcement.
Examples of these methods of calculating creep strains are shown below:
Age adjusted modulus method; click to view full size
Virtual Prestress Method; click to view full size

To combine creep and shrinkage effects, a simple method that is satisfactory for many
purposes is to use the age adjusted modulus method for creep, and the virtual prestress
method for shrinkage. Whilst this method will usually give a result within the order of
accuracy of standard materials properties, it does introduce several avoidable inaccuracies:

 It does not take account of the variation of creep stresses over time.
 It does not take account of the interaction between shrinkage stresses and creep
strains.
 If shrinkage results in the section transitioning from an uncracked to a cracked state at
some time after initial loading, the initial stress and strain conditions will be very
different to those assumed, and this may introduce significant inaccuracies.
 If the loading and/or prestress applied to the section changes significantly over time it
is not possible to take account of these changes in the simple analysis.

All of these factors can be included in a time step analysis as described below:
1. Set up a table of logarithmic time steps, with shrinkage strain and creep factor for
each time step. Optionally add changes to applied loads, and changes to prestress
loads.
2. Analyse the strains and stresses in the section at the end of the first time step, using
the virtual prestress method for shrinkage and the age adjusted modulus method for
creep.
3. For each succeeding time step add creep strains from the previous stages to the
cumulative shrinkage strain for calculation of the virtual prestress. Find the creep
strain increment using the age adjusted modulus, using the increment in the Ø value,
and adjust applied loads and applied prestress where applicable.

A spreadsheet performing this analysis, with examples based on real projects, will be
included in the next post in this series.

Share this:

https://newtonexcelbach.com/tag/eurocode-2/

s Excel Tips About

Sunday, 15 October 2017


Application Settings is now Excel Settings

I decided to add more some more functionality to my Application Settings addin. In fact, I
also changed the name to Excel Settings. (It's actually a different file, so please be sure to
click "Check settings when opening/saving files" on the menu if you want these to fire).

What's new? As you can see, I added 2 new sections for Workbook Scope and Worksheet
Scope settings. The picture pretty well speaks for itself.
And, if your file is saved (has a path), you can see File Size, Last Saved (Date and Time) and
Last Edit (Author) details.

The download link is here.

Saturday, 2 September 2017


Application Settings Add-in Version 2

I made a new version of my Application Settings addin as per Sébastien's comments in my


last post (mirrored on the Daily Dose of Excel).
As you can see, there are new settings for the following.

Application.Iteration

Application.MaxIterations

Application.MaxChange

In the case of the last 2 settings, you'll notice that there are Set, Reset and Save buttons. This
is how they work,

Set: Set to the number that is entered in the text box.

Reset: Reset to the real default or “alias” default.


Save: Save an “alias” default instead of Excel’s real default. For example, if you prefer 120
instead of 100 for Max Iterations, you can set the “alias” default so that the form does not
appear when opening or saving the active workbook if Application.MaxIterations is set to
120. Also, clicking the Reset button thereafter will reset Application.MaxIterations to 120.
And using the Set button to set Application.MaxIterations to any other value than 120 will
show the value in red font to indicate it is not the “alias” default.

Hope this is useful. Download the new version here.

Posted by Andrew 0 comments Links to this post


Labels: Downloads , Utilities , VBA
Email This BlogThis! Share to Twitter Share to Facebook Share to Pinterest

Tuesday, 22 August 2017


Application Settings Add-in

Back in 2005, I noticed something that worried me.

You may know already that switching Application.Calculation to xlCalculationManual can


make various code run faster. It can be a big time saver.

The problem, as I see it, is not switching it back to xlCalculationAutomatic. Given that some
people for whatever reasons might use Manual Calculation all the time, most people don't,
especially the vast majority of average users who probably haven't heard of this setting. With
Calculation still set to Manual, they might be looking at values that haven't be updated. Even
experienced programmers might be temporarily confused until they figure out what's going
on. Imagine someone in a sales department quoting incorrect pricing to a customer or doing a
faulty presentation at an important meeting. Not good.

And now for what really worries me - saving files with this setting. Let's try something. Close
all Excel files, except one to use for testing. Now switch to Manual Calculation. If you don't
know how to do it in code, you can click Calculation Options on the Formulas tab, then select
Manual. Now save in that setting, close Excel, and reopen the file. If that file is the first one
to be opened, Excel Calculation will be set to Manual by default, and all other files opened
thereafter will be affected too. Save any of them with this setting, and the same thing will
happen if they happen to be the first file opened...

So, how do you know Calculation is set to Manual without specifically checking?

You can't.

Now, imagine sending one of these files to colleagues or customers, then realizing something
is amiss days later. Again, not good. In fact, downright scary.

So, also in 2005(?), I made an addin called Calculation Checker. It checks Calculation when
you save and prompts you to do so as Automatic if set as otherwise (including Automatic
Except for Data Tables).

I've found it useful, but since then I've thought there's room for improvement, so I made
something new.

As you can see there's 3 menu items. The bottom 2, when toggle to "On", check files when
opened/saved for the following settings.

Application.DisplayFormulaBar

Application.DisplayStatusBar

Application.Calculation

Application.ReferenceStyle

If any of those settings are not at their default, the Application Settings form will be
displayed. Non-default settings are displayed in red. (Yes, the first 3 should be obvious, but
easy enough to miss if you're busy, tired or both!)
Click the form's controls to reset them individually, or just click the Reset Everything button,
then the Save File and Exit button if you choose to. Alternatively, click the X button not to
save the file. Note that any other file that are open will also be saved with these settings
(unless you change them later), because they are Application settings, not Workbook settings.

And because the form can be opened directly from the Ribbon, you can easily change any of
the settings at any time for whatever reason. Click the Show Settings button and you can see
other settings that can also be reset when clicking the Reset Everything button, if the Include
other settings checkbox is ticked.
Note
Keep in mind that these additional settings aren't checked automatically. The form only resets
them if you click the Reset Everything button as mentioned above. Also, if
Application.EnableEvents is set to False by VBA code, my addin won't check files when
opening or saving as these are the events that trigger it. In fact, you should be setting this
False if any of your code does open or save workbooks to prevent my code from running,
then set it back to True before the code ends.

Hopefully this tool will be of use. You can download it here.

Posted by Andrew 0 comments Links to this post


Labels: Downloads , Utilities , VBA
Email This BlogThis! Share to Twitter Share to Facebook Share to Pinterest

Monday, 15 May 2017


Monthly Report Tutorial

At a former client, I was asked to submit monthly reports that show details of work
performed in 15 minute increments.

My line of thought went something like this,

"Let's see, a monthly calendar, something like the one on my fridge door comes to mind and
making one in Excel should be easy..."
One problem is space. If I do several tasks in one day, do I use tiny font to make the details
fit, or do I make the calendar larger to the point that I have to scroll copiously?

Also, just how practical is that style of calendar going to be when it comes to adding up total
time per task? Something along the lines of a regular timesheet would be better.

I can easily fit 32 rows on my laptop screen. That's a good start. So here's how to do the same
thing I did, if you are interested.

Leave the first row for your headers. In cells A1 and B1, enter "Date" and "Day", then change
the orientation. Right click the cells, select Format Cells, Alignment, and change Orientation
to 90 degrees.
(You might want to change the Alignment too. Choose from the options on the Alignment
Group on the Home Tab)

Enter the first day of the month in cell A2. Select range A2:A32, then change the format to
either "d/m" or "m/d" as you prefer. Right click the cells, select Format Cells, Number, and
enter the format in the Type text box in the Custom section.

Now enter =A2+1 into Range A3:A32 and click your Ctrl and Enter keys simultaneously to
enter the formula into all selected cells.

In the same way, enter


=CHOOSE(WEEKDAY(A2,1),"Su","Mo","Tu","We","Th","Fr","Sa") into Range B2:B32.

Adjust the width of both of these columns and set the alignment to suit.

You should have something like this.


And now for the details. Long descriptions take up space, so let's use numbers instead. Keep
in mind that longer tasks won't be completed in 15 minutes, and recurring tasks will be
duplicated so that's going to cut down the number of tasks in total. With any luck, we can
keep things within double digits.

Start times allotted for the 15 minute intervals go in Row 1. Adjust the Orientation to 90
degrees. "h:mm" is a suitable format.
The task descriptions that match the numbers can go on the right. But note the numbers to
their left to perform a lookup.
Important: adjust the following ranges to suit your requirements. Use Named Ranges if you
prefer.

Enter formulas to add up the time. Type the following formula into Cell AI2, and drag down
to the end of your list.

=IF(COUNTIF($C$2:$AE$32,AG2)=0,"",COUNTIF($C$2:$AE$32,AG2)/4)
You should have something like this.
You can freeze the first row if the number of tasks exceed the number of visible rows on your
screen. (View Tab, Windows Group, Freeze Panes, Freeze Top Row)

Now for some extra features to enhance visibility. Why not add some Conditional Formatting
to highlight the weekends? With Range A2:AE32 selected, click the Home Tab, Styles,
Conditional Formatting, New Rule, then "Use a formula to determine which cells to format"
and enter this formula. (Click the Format button to choose a suitable format)

Here's the result.


An ActiveX Combo Box and a bit more Conditional Formatting makes it easy to see when
the work was done. If you can't see the Developer Tab on the Ribbon, select the File Tab,
Options, Customize Ribbon, then tick "Developer" on the list to the right and click the OK
button.
On the Developer Tab, select Insert from the Control Group to add an Active X Combo Box.
(I've already added one to Cell AH1)

Right click the Combo Box and select Properties. Set the LinkedCell and ListFillRange
properties. I've hard-coded my ListFillRange range reference but you can use Named Ranges
too, as in "=Tasks" without the quotation marks.
When finished, toggle off Design Mode on the Developer Tab.

Note the linked cell. That gives me the selected item of the list. Now I use another formula to
get the reference number which I have put in the cell below the linked cell (In this case, Cell
AJ3).

=MATCH(AJ2,AH:AH,0)-1
If I select the first item on the Combo Box, Cell AJ3 will show 1.
Here's the Conditional Formatting for the details part of the report. (Range C2:AI32)
And here's the Conditional Formatting for the list. (Range AG2:AH32)
I also added some Data Bars to the hours.
And we're done.
No VBA was used so you can send the file without explaining the need to enable macros.

Here's a download link if you want to skip making one yourself.

Posted by Andrew 0 comments Links to this post


Labels: Downloads , Formatting , Formulas , Tutorial
Email This BlogThis! Share to Twitter Share to Facebook Share to Pinterest

Wednesday, 26 April 2017


AET VBE Tools v1.7.3

Yet another tool has been added!

You can now run a report that shows project statistics. It's a good way to get a general feel of
how much work you have done, and where it is located.

Details include:
 Module Names
 Procedure Names
 Count of Children (Project and Modules)
 Procedure Scope
 Count of Lines (Project, Modules and Procedures)
 Count of Comments (Project, Modules and Procedures)
 Count of Declaration Lines (Project and Modules)
 Count of Declaration Comments (Project and Modules)
Download the new version here.

P.S. If you have purchased an earlier version, contact me by email and I'll send a new set of
tools - free of charge!

Posted by Andrew 2 comments Links to this post


Minimum Requirements: Excel 2007 and above, Windows (works with both 32 and
64 bit)

Here is a list of the things you can do.

1. Indent code within the active VB project, module, procedure or selected text.

2. Add line numbers to code within the active VB project, module, procedure.

3. Delete line numbers from code within the active VB project, module, procedure.

4. Add or delete line continuation to/from code within the active VB project, module,
procedure.
5. Export code from the active VB project, module, procedure to text files.

6. Compare code between different procedures.

7. Copy code between projects.


8. Add generic comments to all macros in the active project or module.

9. Insert Code Snippets.


10. Run Favourite Macros.

11. Find and replace code with several fields at once.

12. Run a report to see every location that code exists.


13. Rename userform controls and their code.

14. Cleanup project code.

Options include:
 Delete all instances of Debug.Print
 Delete all instances of Debug.Assert
 Delete all instances of Stop
 Delete all orphan code
 Delete blank lines (excess or all)
 Delete comments
 Delete indenting

15. Make a list of project variables and constants.

Details include:
 Module Name (Where the variable or constant is)
 Scope (Public, Private, Type or Procedure)
 Location (Declaration or procedure name)
 Name (Variable or constant name)
 Type (Variable or constant type, eg String, Long, etc)
 Const (True or null, to discern between variables and constants)
 Const Value (Value if constant)
 Found in Project (Count within project)
 Found in Report (Count within report)
 Modules Count
 Procedures Count
 Unique Values
 Duplicate Values
16. Show Project Statistics

Details include:
 Module Names
 Procedure Names
 Count of Children (Project and Modules)
 Procedure Scope
 Count of Lines (Project, Modules and Procedures)
 Count of Comments (Project, Modules and Procedures)
 Count of Declaration Lines (Project and Modules)
 Count of Declaration Comments (Project and Modules)

17. Automatically highlight code in Excel.

This is useful because the VBE does not indicate structured code.
18. Copy code for web. (Add html tags to your code to show it as indented and copy
it to the clipboard)

19. Select the current procedure (Select the procedure where the mouse cursor is
within)

You can also change the following settings.

And a detailed Help file is also included that you can open directly from the tools.

Impressed?

I believe my VBE tools to be the best value for money you can buy, less than a third
of the cost of it's nearest competition.
Not only that, even more tools are planned for the future and will be available to you
at no extra cost!
- Andrew Engwirda, creator of AET VBE Tools.

Feedback from users


It's very useful and now It's impossible work with VBA without the help of AET VBE
Tools. Andrew, thank you very much!
(Kellsens Willamos)

Great time-saving toolkit for VBA developers!


(Petros Chatzipantazis, Esoteric Consulting Ltd)
Keep up the awesome work!!
(Zack Barresse, exceltables.com)

Download AET VBE Tools and watch your productivity soar!

https://digital.com/blog/excel-tutorials/

http://www.engineerexcel.com/blog/

Importing text data into Excel for analysis is pretty straightforward, but what if you want to
use data from a chart in a book or some other reference? There’s a free tool that will let you
convert graphical charts into text data: Engauge Digitizer.

Go to http://markummitchell.github.io/engauge-digitizer/, and click “Latest Releases.”


Choose the appropriate installer for your operating system.

The file stress_concentration_hole.jpg is an image of a stress concentration curve for an


axially loaded rectangular bar with a hole through the middle. The stress concentration factor
is given as a function of the radius of the hole divided by the width of the bar.

[Note: Want to learn even more about advanced Excel techniques? Watch my free training
just for engineers. In the three-part video series I'll show you how to easily solve engineering
challenges in Excel. Click here to get started.]

To be able to use the data in a spreadsheet, you’ll need to convert the chart to pairs of XY
data using Engauge Digitizer.

Once you have the software installed and open, select File > Import, then open
stress_concentration_hole.jpg. In the wizard that opens, click Next twice, then Finish.

Any image that’s color or grayscale will look terrible at first, but we can correct it by going to
Settings > Color Filter. Adjust the filters by clicking and dragging the green arrows until a
recognizable curve appears, then click OK:

Next, you’ll need to tell the software where the axis points are. Select the button with the
three red crosses ( ). Place the crosshair over the intersection of the x- and y-axes. Left-
click, then enter the coordinates for this axis point (x=0, y=2).

Repeat for the highest marked point on the y-axis (x=0, y=3.2) and on the x-axis (x=0.5,
y=2).

Next, add points by selecting the Point Match tool ( ) and clicking various points on the
curve. These are the points that will be exported later as XY coordinates.
With enough data points selected, the coordinates can be exported to a .csv (comma separated
values) file by choosing File and Export. Accept the default name and click Save.

Now Excel can import the data into a worksheet using a text data import. Go to Data > From
Text, then double-click on the .csv file that was just created. Make sure the delimited option
is selected and click Next. Select the comma delimited option, then click Finish. Choose a
location for the data.

To verify that the data was imported properly, select the X and Y column, then create a
scatter chart. You can use the Quick Access Toolbar button or go to the Insert tab and find
the Scatter Chart button.

Right-click the y-axis and choose Format Axis. Change the minimum and maximum to
match the chart in the image (minimum = 2.0, maximum = 3.2). Now the Excel chart is the
same as the original:

These data can be used in calculations going forward by using lookups or linear interpolation.

If the function you want to integrate is known in terms of a variable, you can perform the
integration using VBA instead of the tabular method in the last section.

Let’s say we have a velocity function:

[Note: Want to learn even more about advanced Excel techniques? Watch my free training
just for engineers. In the three-part video series I'll show you how to easily solve engineering
challenges in Excel. Click here to get started.]
Although you could integrate this equation using a table in the worksheet, VBA will allow
you to obtain a more accurate estimate by using a smaller time step (smaller slices).

Open up the VBA editor (Alt-F11) and insert a new module in the worksheet by right-
clicking in the Project window and choosing Insert > Module.

This module will contain two functions. The first will be a function for the velocity from the
equation above. Create a function named vel with one argument, t. Then enter in the equation
above:

Function vel(t)

vel = 24 * t – 1.2 * t ^ 2

End Function

The second function will calculate position by integrating velocity. This function is going to
have three arguments: an initial position (x0), a starting time (t1), and an ending time (t2).
For complex functions like this, it’s helpful to create a skeleton of what the function will do
using comments. Create the position function and the skeleton:

Function Position(x0, t1, t2)

‘define the range of the integral

‘discretize the integral into “n” slices, “dt” wide

‘initialize variables

‘calculate areas using the trapezoidal rule

‘sum the area under the curve for each slice

End Function

The last two steps, calculating the areas and summing them, will be done simultaneously
using a FOR loop.

With the skeleton complete, you can code each step. For the first step, defining the range of
the integral, we’ll create a variable int_range which is the difference between time t2 and
time t1:

‘define the range of the integral

int_range = t2 – t1

In the second step, you’ll slice this range up into a certain number of slices. The number of
slices will be defined as n. An n of 1000 should give good accuracy. The time step, dt, is the
width of one of those slices, so it will equal the integral range divided by the number of
slices.
‘discretize the integral into “n” slices, “dt” wide

n = 1000

dt = int_range / n

Before estimating the area of a slice using the trapezoidal rule, you’ll need to set some initial
conditions.

If you recall, the trapezoidal equation is evaluated from a to b. Since this example has time on
the x axis, we’ll call the time at the beginning of the slice “ta” and set it equal to our initial
start time (t1). We’ll call the time at the end of the slice tb, and set it equal to ta + dt.

‘initialize variables

ta = t1

tb = ta + dt

While t1 is a fixed point in time, ta and tb will change as the function moves from one slice to
the next.

There’s one more variable to initialize – the position. Initialize the position by setting it to the
argument x0 that is passed into the function:

Position = x0

With the initialization done, you can set up a FOR loop that will go through the slices and
calculate the area of each one. It will also sum up the total area of all the slices as it goes.

The FOR loop is going to run once for each slice, and there are n slices, so we’ll set this up
For j = 1 to n. Then the position will be calculated from the trapezoidal rule using the vel
function we defined above to calculate the height at the start and end of the slice:

‘calculate areas using the trapezoidal rule

‘sum the area under the curve for each slice

For j = 1 To n

Position = Position + (tb – ta) * (vel(ta) + vel(tb)) / 2

In order to move to the next slice, we’ll change the values of ta and tb. The new ta will be
equal to the old tb, and tb will increment by dt:

ta = tb

tb = ta + dt

Next
The Next statement closes out the loop.

When you’re all done, your code should look like this:

Function vel(t)

vel = 24 * t – 1.2 * t ^ 2

End Function

__________________________________________________________________________

Function Position(x0, t1, t2)

‘define the range of the integral

int_range = t2 – t1

‘discretize the integral into “n” slices, “dt” wide

n = 1000

dt = int_range / n

‘initialize variables

ta = t1

tb = ta + dt

Position = x0

‘calculate areas using the trapezoidal rule

‘sum the area under the curve for each slice

For j = 1 To n

Position = Position + (tb – ta)* (vel(ta) + vel(tb)) / 2

ta = tb

tb = ta + dt

Next

End Function

Now that the Position function is complete, you can use it in the spreadsheet to do
calculations. First, use it to calculate the position at 20 seconds. Remember this function
needs three arguments passed to it: x0, t1 and t2. Type in the function name, then use Ctrl-
Shift-A to automatically populate the names of the arguments. The first argument, x0, is the
initial position in cell C5; t1 is the lower bound in cell C6, and t2 is the upper bound in cell
C7.

=Position(C5,C6,C7)

The Position function will give the result 1600 feet after 20 seconds.

Of course, the function can also be used to calculate the position at many different times. The
worksheet already contains time and velocity data. For the position column, the arguments
will be entered in a slightly different way. The initial position and the initial time are the
same as above. You can begin the function:

=Position(C5,C6,

Both of these arguments need to be made absolute references using F4 because they’ll be the
same for every time point in the table. However, the t2 argument will change as you go down
the table, so you can simply click within cell B17 and leave that as a relative reference.

=Position($C$5,$C$6,B17)

Select this cell and double-click the fill handle to fill the formula down the column. This will
give you the same end position of 1600 feet, but it also gives all the position and velocity data
points in between. You can plot these together. Select all three columns and insert a scatter
chart. The velocity data are much smaller numbers than the position, so plot those on a
secondary axis. Right-click the velocity data and choose Format Data Series. Select Plot
Series On Secondary Axis.

You can see that when the velocity is near zero, the slope of the position curve is flat. The
position increases more rapidly as velocity increases, and eventually gains more slowly as the
velocity begins to drop again. Finally, when the velocity is zero again, the position stops
increasing.

0Share
0Share
Tweet
Share
0Share
0Pin

There are two basic functions that allow you to pull data from tables you’ve created so that
you can use them in a calculation: VLOOKUP and HLOOKUP.

VLOOKUP, or vertical lookup, finds a value in a row of a vertical table by matching a value
in the first column. Its syntax is as follows:

VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])

[Note: Want to learn even more about advanced Excel techniques? Watch my free training
just for engineers. In the three-part video series I'll show you how to easily solve engineering
challenges in Excel. Click here to get started.]

lookup_value: the value in the first column that is being searched for

table_array: the table of data that is being searched

col_index_num: the column containing the values to return

range_lookup: (optional) TRUE returns an approximate match, FALSE returns an


exact match

Although the range_lookup argument is optional, it’s often preferable to specify this as false,
as you’ll see later in this section.

The HLOOKUP, or horizontal lookup, function is basically the same function for a horizontal
table. It allows you to find a value in a column of a table by matching a value in the first row.
Its syntax is nearly identical:

HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])

lookup_value: the value in the first row that is being searched for

table_array: the table of data that is being searched

row_index_num: the row containing the values to return

range_lookup: (optional) TRUE returns an approximate match, FALSE returns an


exact match
We’ll do an example using the VLOOKUP function, but the same concepts can be applied to
use HLOOKUP.

Worksheet 04g is set up to calculate the mass of a gas stored in a tank. In this example, there
is a 10 m3 tank filled with propane at 25°C, pressurized to 5 x 105 Pa. The ideal gas equation
can be used to calculate the mass of propane in the tank, but first you must look up the gas
constant based on the name of the gas. VLOOKUP can be used to get this value and return it
to cell C12. Begin the function:

=VLOOKUP(C5,

The name of the gas is entered in C5, so we can use this cell reference. For the second
argument, select the full table (not including headers).

=VLOOKUP(C5,F7:K22,

The column index number is the number of the column containing the data we want to return.
Since the gas constant data is in the third column on the table, enter the number 3 as the third
argument.

=VLOOKUP(C5,F7:K22,3

Finally, to make sure that a value is returned only when the name of the gas matches a value
in the first column exactly, type FALSE.

=VLOOKUP(C5,F7:K22,3,FALSE)

The data in the table is in kJ/kg*K, but the data needs to be in units of j/kg*K for the next
step, so multiply the lookup value by 1000.

=VLOOKUP(C5,F7:K22,3,FALSE)*1000

Verify that the function is returning the correct result by finding the gas constant for propane
in the table. Remember, it will be multiplied by 1000 in cell C12.

This worksheet already has named cells, so you can calculate the mass of gas in the tank by
entering

=P*V/(Rgas*T)

Now this spreadsheet is able to calculate the mass of any gas, in any tank, under any
conditions, as long as that gas is in the table. If you change the gas name in cell C5 to Argon,
the result updates automatically:

What happens if the range_lookup argument is set to TRUE instead of FALSE? TRUE allows
an approximate match to be returned, whereas FALSE forces an exact match. If this argument
is TRUE, and the gas name in cell C5 is misspelled “Argom,” an incorrect result is returned:
This happens because Excel is trying to match the misspelled word to a value in the table.
When it can’t find an exact match, it uses the first value that approximately matches. With
text data, it does this alphabetically, so it returns the gas constant for “Air” in this case.

If the range lookup is FALSE and the name is misspelled, it returns an error. In this case, it’s
preferable to return an error than to get an erroneous result.

Array formulas allow you to use multiple cell inputs rather than a single cell input. There are
two types of array formulas. One type of array formula returns a single value from multiple
inputs. A common example is the SUM function:

The other type of array formula is one that returns multiple outputs. A simple addition can be
used as an array formula:

[Note: Want to learn even more about advanced Excel techniques? Watch my free training
just for engineers. In the three-part video series I'll show you how to easily solve engineering
challenges in Excel. Click here to get started.]

[Note: Want to learn even more about advanced Excel techniques? Watch my free training
just for engineers. In the three-part video series I'll show you how to easily solve engineering
challenges in Excel. Click here to get started.]

EXCEL TRAINING FOR ENGINEERS

Learn advanced engineering techniques in Excel.

LEARN MORE
Creating the second type of array formula is a little different from what you’ve done so far.
The biggest difference is that you’ll use Ctrl-Shift-Enter to finish the formula.

What’s the point of array formulas? We’ve already seen how to fill formulas into other cells
using the fill handle. There are three benefits to using array formulas:

1. They can reduce errors in spreadsheets. Because you are forced to edit the entire array at
once, you or someone else cannot mistakenly modify a formula in the middle of a range of
cells.
2. They simplify spreadsheets by allowing you to combine calculations that would take multiple
cells into a single cell.
3. They allow us to use named ranges on a selection of cells. This significantly improves formula
readability in Excel. Named ranges will be discussed later in this chapter.

The worksheet contains an example where we can use an array formula. It’s set up to
calculate airfoil lift as a function of varying velocity (v) and constant lift coefficient (C L),
area (A), and air density (ρ). The formula to calculate airfoil lift (L) is:

First, we’ll calculate the lift without using an array formula. Enter the formula in as

=C5*C6*C7*F7^2/2

The constant values in column C need to be absolute references, so click within each one and
type F4. Leave F7 as a relative reference.

Double-click the fill handle in the lower right corner to fill the rest of the column with this
formula.

One problem with performing the calculation this way is that it’s possible to mistakenly edit a
single cell. For example, if you were to delete the denominator from a single cell’s formula,
that cell’s value would be incorrect:

Excel flags the altered cell with a small green triangle to indicate that it doesn’t match the
surrounding cells, but those flags can be hidden or even ignored altogether.

Using an array formula will minimize the potential for errors. There are a few differences in
how array formulas are entered compared to standard formulas.
First, select all the cells that you want to return results to. Rather than enter the formula into
the cell itself, click within the formula bar and enter it there.

Enter =C5*C6*C7* in the formula bar, then select the entire range of velocities. You should
have:

=C5*C6*C7*F7:F16

Square the velocities by adding ^2, then divide by 2.

=C5*C6*C7*F7:F16^2/2

To finish the array formula, type Ctrl-Shift-Enter. This is an important step to remember
when using array formulas.

In this case, it’s unnecessary to make the constants absolute references. The formula won’t be
copied into any other cells, so the reference won’t change.

When you complete the array formula with Ctrl-Shift-Enter, Excel will automatically add
curly brackets on either side of the formula to indicate it’s an array formula:

If you try to edit any single cell in the array, Excel will give an error message. To edit the
formula, select all of the output cells in the array, make your edit, then again type Ctrl-Shift-
Enter.

http://www.engineerexcel.com/blog/

Das könnte Ihnen auch gefallen