6 Year Report

As in previous years, I have downloaded the statistics for this blog for the previous year, and pasted them into a worksheet. The link to each post is preserved in the spreadsheet, so it makes a convenient index to what has been posted over the year. The spreadsheet has been uploaded to Skydrive (which now seems to have morphed into OneDrive), so you should be able to access the links in the window below, or open the file in your browser or Excel, or download it.

Of the 2013 posts, the most popular overall was Clearing excess formats .

The most popular in the Newton category was 3DFrame – 3D Frame analysis for Excel,

and the most popular in the Bach category (by a mile) was George Gently, Matty Groves, and Ebony Buckle

From the “deserving but sadly neglected category” I have chosen (so go and have a look/listen):
Newton: Unit aware continuous beam spreadsheet update

Excel: Selecting Ranges from a UDF:

Bach: The Incredible String Band

Most frequent referrers to this site came from:

Referrers to NewtonExcelBach

Referrers to NewtonExcelBach

Posted in Bach, Excel, Newton | Tagged | Leave a comment

Cubic splines with horizontal data

Following a request here I have modified my cubic spline functions to accept input arranged  in rows as well as columns.  By default the output arrays will have the same orientation as the range of interpolation X values, but I have also added an optional TransposeH input which if set to “False” will return the output arrays in columns, even if the interpolation X values are in a row.

The new spreadsheet (including full open source code) may be downloaded from: CSpline2.zip

For more details of the background to the functions, and how to use them see: Daily Download 22: Splines and Curves.

Typical output from CSplineA with X values in a row

Typical output from CSplineA with X values in a row

Posted in Excel, Maths, Newton, UDFs, VBA | Tagged , , , | 1 Comment

Beam actions and deflections, 3D or 2D

Two new functions have been added to the ConBeamU spreadsheet, last discussed here.

The new version can be downloaded from ConBeamU.zip, including full open-source code.

The new functions, BeamAct3D and BeamAct2D calculate forces, moments, deflections and rotations along a 3D or 2D beam under specified end conditions and loading.  The output is calculated based on the conditions specified at End1, and optionally the error in the calculated values at End 2, compared with the input values, may be returned.  If this option is not used the End2 data is ignored.

The examples below show input for a uniform beam, but the beam may be subdivided into any number of segments with differing section properties.  The current version of the functions performs linear analysis only, but the section properties can be easily adjusted on the spreadsheet, based on the output actions, to provide non-linear materials analysis.  Later versions will have this functionality built-in, and will also provide for geometric non-linear effects.

Details of the function input and output are shown in the screenshots below (taken from the Functions sheet of the spreadsheet).  For more details of how to use Excel User Defined Functions and Array Functions see: Using Array Functions and UDFs.

BeamAct1

BeamAct Functions Input 1

BeamAct2

BeamAct Functions Input 2

The output consists of 12 or 6 columns for the 3D or 2D version respectively:

BeamAct3

Examples of both functions are found on the BeamAct sheet:

BeamAct4

BeamAct3D Input

BeamAct5

BeamAct3D Input

BeamAct6

BeamAct3D Output; click for full size view

BeamAct7

BeamAct3D Deflection Results Compared with Strand7

BeamAct8

BeamAct2D Input 1

BeamAct9

BeamAct2D Input 2

BeamAct10

BeamAct2D results

BeamAct11

BeamAct2D Results compared with Strand7

Posted in Beam Bending, Excel, Finite Element Analysis, Frame Analysis, Newton, Strand7, UDFs, VBA | Tagged , , , , , , | 2 Comments

New Links: Scientific Python and Engineering Excel

The previous post had a link to Cyrille Rossant which is worth a closer look.  The blog has many detailed posts on scientific applications of Python, as well as links to Galry: a high performance interactive visualization package in Python and his IPython mini-book.

Spreadsheets 4 Simulation is a new blog focussing on engineering applications of Excel and Google Sheets, which has some impressive looking applications and animations, including:

Posted in Excel, Link to Python, Newton, NumPy and SciPy, VBA | Tagged , , , , | Leave a comment

The speed of loops in Python

This post is based on exercises published by Cyrille Rossant in his book “Learning IPython for Interactive Computing and Data Visualization”.  Cyril also has a blog well worth looking at: http://cyrille.rossant.net/blog/ (Thanks to Alfred Vachris and Boris Vishnevsky for the links).

As has been noted here before, pure Python can be very slow when looping through large blocks of data, but there are simple ways to speed things up dramatically.  This is illustrated by alternative techniques to search a list of 10 million 2D coordinates to find the point closest to a specified location.

The screenshot below shows Python code to loop through the coordinates in the list “positions” and return the index of the one closest to “position”.
closest1
The positions list is generated with the random function, and the closest function is then run with a position of (.5, .5), as shown below:

closest2
The Python routine takes 7.1 s to loop through the 10 million rows of the positions list.

To speed things up, using Numpy, the procedure is:

  • Import pylab with the command %pylab, which is the most convenient way of using NumPy in an IPython interactive session.
  • Generate the positions array with the rand function.
  • Extract single column arrays, x and y, from the positions array.
  • Create the distances array with the command:
    distances = (x – .5)**2 + (y-.5)**2
  • Extract the minimum distance from the distance array with:
    ibest = distances.argmin()

closest3

The total time to execute this procedure on the 10 million rows of the positions array was 218 ms, better than 30 times faster than the original code.

The message is, whenever working with large arrays, use Numpy functions that operate on the entire array with efficient C based code, rather than looping through the arrays with interpreted Python code.

Posted in Arrays, Link to Python, NumPy and SciPy | Tagged , , , , | Leave a comment