3DFrame-py

My 3DFrame spreadsheet has now been converted to Python code and can be downloaded from:

3DFrame-py.zip

The frame analysis uses the Scipy linear algebra functions called from pyLinalgfuncs3, which must be available on the Python path:

pyLinAlgfuncs3.zip

The 3DFrame-py download file includes:

  • 3DFrame-py.xlsb: The basic spreadsheet, including data for a small example frame
  • 3DFrame-py Strand7 check.xlsb: Results for the small frame compared with Strand7 results.
  • 3DFrame-py-vvbig.xlsb: Spreadsheet with input and results for a much larger frame
  • Load3DFrame.py: Python code to load the 3DFrame-py code at startup of the associated spreadsheet
  • py_3DFrame0_1.py: The 3DFrame-py code, using the Numba just-in-time compiler.
  • py_3DFrame0_1-nojit.py: The same code but without any calls to Numba jit compilation.

In addition to the download files, the following modules are used:
Required:

  • pyxll
  • Numpy and Scipy
  • ctypes

Optional:

The spreadsheet has VBA code to automatically load the Python frame analysis code when the file is opened:

Public Sub Workbook_Open()
Dim iErr As Long

Application.EnableEvents = True
iErr = Run("Load3DFrame")
End Sub

The Load3DFrame module should either be added to the list of files opened at startup, in the pyxll.cfg file, or the code below should be added to an existing startup file:

import pyxll
from pyxll import xl_menu, xl_macro, xl_app, xlcAlert
import importlib as imp

@xl_macro
@xl_menu("Frame Analysis", menu="Load")
def Load3DFrame():
    xl = xl_app()
    usejit = xl.Range("Usejit").Value
    try:
        if usejit == 0:
            imp.import_module('py_3DFrame0_1-nojit')
        else:
            imp.import_module('py_3DFrame0_1')
        pyxll.rebind()
        xlcAlert('Frame Analysis module import completed')
    except:
        xlcAlert('Module not imported')
    return 0

The Python code is a work in progress, and the functionality of the spreadsheet is largely the same as the VBA version. The major differences are that the links to compiled solver routines have been replaced with links to the Scipy and pyPardiso solvers, and there is now an option to use code calling the Numba just-in-time compiler:

For large problems using the Numba module greatly reduces the time to complete an analysis, but the first time the solver is used the compiled code takes about 20 seconds to generate, so for small frames (or if the Numba module is not available), it is better to leave it disabled.

The spreadsheet has been saved with data for a small frame, and the results are compared with the Strand7 FEA results, showing near exact agreement:

The spreadsheet is able to handle much larger frames, and the download file has an example with nearly 10,000 nodes and over 27,000 beam members:

Note that for models of this size the Numba code should be enabled, and the solver should be set to one of the 2 iterative options, or to Scipy sparse, if the pyPardiso module is installed. The banded solver is very slow for models of this size, and may have memory overrun problems.

Background information on the methods used to generate and solve the frame model can be found by selecting “Frame Analysis” from the Categories drop down list at the top-right of the blog Home tab.

Posted in Arrays, Excel, Finite Element Analysis, Frame Analysis, Link to Python, Newton, NumPy and SciPy, PyXLL, Strand7, VBA | Tagged , , , , , , , | 3 Comments

More new old recordings

There have been quite a few old Pentangle and Bert Jansch recordings posted on YouTube in recent months.

BBC The Genius of Bert Jansch Folk Blues and Beyond, from 2014. Interviews and archive footage weave together performances from a concert at the Royal Festival Hall celebrating the songs and artistry of the folk-blues troubadour Bert Jansch.

Pentangle – ‘Newsnight’ 26/06/08:Robin Denselow investigates to third coming of the five and has coffee by the Thames with publishing personality Ian Anderson.

A Guardian article about the same concert:

Pentangle’s 2008 Royal Festival Hall reunion brought them back to the venue of the live half of their Sweet Child double album (1968). By many accounts, that performance was not without its rough edges. But the musicianship on display during tonight’s two-set engagement is awe-inspiring, virtuosic and – still – somewhat perverse: an endless knot of strings, disparate influences and textures.

And a Bert Jansch concert at the same venue in the early days: Bert Jansch – Royal Festival Hall 30/6/71

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

Calculating and plotting rotations

This post was prompted by a recent post at Eng-Tips.

The original problem seemed simple enough:

Im trying to wirte a formula where I imput vessel heading and datum bore heading and it tells me FWD, STBD, AFT or PORT

Now FWD and AFT are I can manage. If the difference between two headings is 45 or less then its FWD. if its greater than 135 its AFT

Between 45 or 135 is PORT or STBD depending on which way vessel turns. If vessel turns clockwise on compass then bore heading on PORT and and if anticlockwise its STBD

Anyone know how to write such a thing on excel?

For consistency the terminology used in the rest of this post will be:

  • Angles are measured clockwise from North, so will always be between 0 and 360 degrees.
  • The angle from the boat to the datum bore is referred to as the Reference Bearing.
  • The ship’s direction of travel is referred to as the Heading
  • The angle required is the angle from the Heading to the Reference Bearing, which will be divided into FWD, STBD, AFT, PORT, and back to FWD, with transitions at 45, 135, 225, and 315 degrees.

The problem is that if the angle is calculated as Ref. Bearing – Heading, it may lie between -360 degrees and 360 degrees, which makes any single formula using nested if statements very long. The simplest solution is to use a VLookup formula with a table, as in the screenshot below:

The table can be shortened by using the formula =MOD(Ref-Head, 360), which returns an angle between 0 and 360. The shortened lookup table is in my opinion the simplest solution, and the easiest to check, but two working alternatives were given in the discussion, which used a single cell formula:

  • The formula in cell A16 uses =INDEX() with a list of the four direction names, and a formula using MOD() that returns a value between 1 and 4.
  • The formula in cell A11 uses the sum of the Sin and Cos of Ref-Head, together with nested Ifs and ANDs.

A simpler solution using the ABS function was suggested, but this does not work when the Ref-Head angle is negative.

Finally Eng-Tips regular MintJulep provided some VBA code to plot the Reference Bearing and Heading instantly whenever one of the angles was changed:

Both spreadsheets shown above, including full open-source VBA code can be downloaded from:

Bearings.ZIP

Posted in Coordinate Geometry, Drawing, Excel, Maths, Newton, VBA | Tagged , , , , , , | Leave a comment

Speed of Scipy Linear Algebra Solvers

The files presented in the recent post on Scipy Linear Algebra Solvers include a wide range of different solver types, with in some cases numerous sub-options, allowing the functions to be called from Excel, and greatly extending and speeding up Excel’s limited solver functions.

In this post the speed of all the available functions is compared for solving sparse matrices for structural frame analysis with matrix sizes of 14742×14742 and 29485×29485.

The python code and spreadsheet for the solvers can be downloaded from:

pyLinAlgfuncs3.zip

and the timer spreadsheets (including complete matrices) from:

TimeLinAlg.zip

Note that the spreadsheets require pyxll to link the Python code to Excel.

The file Time Lin-Alg2.xlsx has the larger matrix and time results for both:

The solver times show the time for complete solution in the first column, or where applicable the time for factorisation in the first column, and extraction of the results from a factorised matrix in the second:

The functions solveit (iterative solver) and spsolve (sparse solver) have alternative solver types, with widely varying performance:

Times shown are for the larger matrix.

Two of the iterative solvers (4 and 10) failed to converge.

For the py_Spsolve functions Option 0 calls the pyPardiso library, which must be installed separately to Scipy. This is very much faster than the built-in Scipy options, and is the default solver called by py_Spsolve.

Posted in Arrays, Excel, Finite Element Analysis, Frame Analysis, Link to dll, Link to Python, Newton, NumPy and SciPy, PyXLL, UDFs | Tagged , , , , , | 2 Comments

EngineeringPaper.xyz

EngineeringPaper.xyz is a web app for engineering applications with free open-source code:

EngineeringPaper.xyz is a web app for engineering calculations that handles unit conversion/checking automatically and also supports plotting, solving systems of equations, and documenting your calculations (see the official blog for many examples). It’s easy to share your calculations by creating a shareable link that anyone can open and build off of. Additionaly, you can save and open your files locally if you prefer not to save to the cloud. EngineeringPaper.xzy runs on Mac, Windows, Linux, and ChromeOS and works on all of the major browsers. Additionally, EngineeringPaper.xyz is designed to run well on Android and iOS devices. Launch EngineeringPaper.xyz in your browser to try it out.

From the tutorial:

EngineeringPaper.xyz is a free and open source Mathcad® alternative for engineering calculations that automatically handles unit checking and unit conversions, can solve systems of equations, and supports plotting. You can also easily save and share your work by creating a shareable link. EngineeringPaper.xyz is a web app that doesn’t require you to create an account. The tutorial video below will get you started using this powerful tool that runs on any operating system including macOS, Windows, Chrome OS, and Linux. The table at the bottom of this page lists several example sheets that walk you through some of the more advanced capabilities of EngineeringPaper.xyz. If your interested getting involved with the development of EngineeringPaper.xyz, visit the EngineeringPaper.xyz GitHub project site

Posted in Computing - general, Newton | Tagged , | Leave a comment