The book The Man Who Knew Infinity by Robert Kanigel describes the life of the Indian mathematician Srinivasa Ramanujan, and also his Cambridge mentor G.H. Hardy. It mentions that Hardy was influenced by reading “A Treatise on the Mathematical Theory of Elasticity”, by Augustus Love.

Looking for a copy of this book, the first search results led to:

The Internet Archive, with a download available from Google Books. Unfortunately this was a poor quality non-searchable scanned document, with some pages that were totally unreadable.

The Strand7 API provides an interface between the Strand7 Finite Element Analysis program and external software. It works with many different languages, including Python, which uses ctypes to transfer data to and from the API functions. It is essential that data is transferred with the right data types, and that arrays are correctly sized. This post provides a summary of the different data types, with an example of Python code that can be called as a user defined function (UDF) from Excel, using pyxll.

Input of integer, double or Boolean data types may be passed to ctype functions unchanged. In Release 3 versions of Python, strings must be converted using string.encode(). For input Python lists or Numpy arrays an empty ctype array of the required length must first be created, then the values are copied to the array.

Variables passed to a ctype function to return output values must be created in Python as shown above. The returned values must then be converted back to a Python type, using .value or .value.decode(), before being passed back to the spreadsheet.

Typical Python code to call an API function is shown below:

@xl_func
@xl_arg('uID', 'int')
@xl_arg('ResultType', 'int')
@xl_arg('ResultSubType', 'int')
@xl_arg('BeamNum', 'int')
@xl_arg('MinStations', 'int')
@xl_arg('ResultCase', 'int')
@xl_return('numpy_array<var>')
def py_GetBeamResultArray(uID, ResultType, ResultSubType, BeamNum, MinStations, ResultCase):
"""
Returns the specified beam result quantity at several stations along the length of the beam. Additional stations
are inserted to ensure that the maximum/minimum results are captured.
:param uID: Strand7 model file ID number.
:param ResultType: Beam result quantity; see Beam Results for additional information.
:param ResultSubType: Beam result sub-type; see Beam Results for additional information.
:param BeamNum: Beam number.
:param MinStations: Minimum number of stations required.
:param ResultCase: Result case number.
"""
NumStations = c_int()
NumColumns = c_int()
BeamPos = (c_double * kMaxBeamResult)()
BeamResult = (c_double * kMaxBeamResult)()
iErr = St7GetBeamResultArray(uID, ResultType, ResultSubType, BeamNum, MinStations, ResultCase, NumStations, NumColumns, BeamPos, BeamResult)
if iErr:
return py_ErrStringA(iErr)
else:
n = NumStations.value * NumColumns.value
res = np.array(BeamResult[0:n]).reshape(-1, NumColumns.value)
pos = np.array(BeamPos[0:NumStations.value]).reshape(-1,1)
return np.concatenate((pos, res), axis = 1)

The API function, St7GetBeamResultArray, returns two integers and two arrays (the positions along the beam where results are returned, and the result values). The integers and arrays are created in Python, then passed to the API function. The returned ctypes 1D arrays are then converted to Numpy 2D arrays, using .reshape(), and combined into a single array for return to Excel, using np.concatenate.

The function in use is shown in the screenshots below:

The function may return results for the two beam ends:

The spreadsheet Vincenty.xlsb uses those resources to perform the following calculations, using both on-sheet calculations and VBA user-defined functions (UDF’s):

Calculation of distance and azimuth angles given latitude and longitude for two points.

Calculation of latitude and longitude and azimuth for a second point, given the position and azimuth for the first point.

Calculation of the area inside a closed polygon, using the excess angle method.

The spreadsheet contains full open source code, and documentation for the on-sheet calculations. Examples are shown in the screenshots below (click any image for full-size view):

Input and geometry constants required for the VincentyLen Function:

The on-sheet calculation follows the procedure given in the Wikipedia article. The VincentyLen function returns the same end results (in bold), and can also return the intermediate results:

The VincentyCoord function solves the “Direct Problem”, returning the latitude and longitude for a point at a specified distance and bearing from another point:

The VincentyArea Function finds the area inside a polygon specified by the latitude and longitude for a series of points, listed in clockwise order, using the “Excess angle method”. Note that as well as the returning the area, if the optional second argument is set to 2 the function returns additional data for each segment of the polygon, as shown in columns H to L below:

The VincentyArea function has been used to calculate the area of the Australian mainland, using a series of 2900 points:

The data for the points is listed with longitude first then latitude. All three functions have an optional third “XY” argument to deal with this convention with the values:

The myOnlineTraininghub blog recently had a post entitled Import Data from a Picture to Excel
which sounded promising, since I often need to extract data from Autocad files saved to a pdf.

From the link, it seems that if I had a Mac with Excel365 then I could do that, but:

The app is not available for Windows

The versions for iPhone and Android work by switching to camera mode when you select the “import data” icon, so that you can take a picture of printed images.

First results from the Android version were disappointing. This table from Roark’s Formulas for Stress and Strain:

was converted into this data: No doubt more care with taking the original photo would help, but the ability to work with existing image files (including pdf) or screen shots, preferably from a Windows computer, would make the whole process a lot easier and more reliable.

I’ll keep an eye on new developments, but at the moment it seems more trouble than it is worth.