Scipy functions with Excel and pyxll

Over the years, I have posted a large number of user defined functions (UDF’s) allowing Python Scipy functions (and related libraries) to be accessed from Excel. These have now been consolidated in a uniform format, using the pyxll add-in and can be downloaded from:

py_SciPy.zip

The download contains full open-source Python code and example spreadsheets that will be reviewed in this and following posts. To use the code the following software is required:

  • Excel for Windows
  • Python
  • Numpy, Scipy, and additional packages for specific applications (see later posts for details)
  • A licenced copy of pyxll (or an active demonstration version)

Details of the pyxll package (including download, free trial, and full documentation) can be found at:

pyxll

For those installing a new copy of pyxll, a 10% discount on the first year’s fees is available using the coupon code “NEWTONEXCELBACH10”.

Having installed Python, Numpy, Scipy and pyxll:

  • Copy the contents of the download file to a folder on the pyxll pythonpath (as defined in the pyxll.cfg file).
  • Add “StartSciPy” to the pyxll modules list in pyxll.cfg

The spreadsheets included in the download file will activate the associated functions automatically, but they will also be available from any other file through the add-ins tab:

The py_Numpy.xlsb spreadsheet has many examples calling Numpy functions, including:

A list of all available functions, with documentation:

Polynomial functions:

Working with arrays:

Numpy math functions:

Numpy trigonometry functions:

High precision functions for integers:

Floating point functions:

Numerical range functions:

Sorting functions:

Posted in Arrays, Excel, Link to Python, Maths, Newton, Numerical integration, NumPy and SciPy, PyXLL, UDFs | Tagged , , , , , | 7 Comments

Early Analog Computers

We tend to think of computers as having been developed starting in the years after the second world war, but in the late 19th and early 20th centuries the focus was on analog computers, which were seen as being the way of the future.

Wikipedia gives examples of machines capable of integrating differential equations starting in 1836, and leading to:

The first description of a device which could integrate differential equations of any order was published in 1876 by James Thomson, who was born in Belfast in 1822, but lived in Scotland from the age of 10.[5] Though Thomson called his device an “integrating machine”, it is his description of the device, together with the additional publication in 1876 of two further descriptions by his younger brother, Lord Kelvin, which represents the invention of the differential analyser.[6]

One of the earliest practical uses of Thomson’s concepts was a tide-predicting machine built by Kelvin starting in 1872–3. On Lord Kelvin’s advice, Thomson’s integrating machine was later incorporated into a fire-control system for naval gunnery being developed by Arthur Pollen, resulting in an electrically driven, mechanical analogue computer, which was completed by about 1912

https://en.wikipedia.org/wiki/Differential_analyser

The Water Integrator was an early analog computer built in the Soviet Union 1936 by Vladimir Sergeevich Lukyanov. This was of particular interest to me, because of an early application:

Lukyanov was one of the engineers working on the construction of the Troitsk-Orsk and Kartaly-Magnitnaya railways in the late 1920s. To ensure the quality and durability of reinforced concrete structures, the engineers poured concrete only in the summer. Despite this, cracks still appeared in the concrete when temperatures dropped below zero in winter. Lukyanov suggested that this can be avoided if a careful analysis of the temperature changes in the concrete mass is made, depending on the composition of the concrete, the cement used, the technology of the work, and the external conditions. Lukyanov began studying temperature conditions in concrete masonry, but the existing calculation methods could not give a quick and accurate solution to the complex differential equations that described the temperature regime.

n search of a new approach to solving the problem, Lukyanov discovered that water flow is in many respects similar in its laws to the distribution of heat. He concluded that by building a computer where the main component was water, Lukyanov could visualize the invisible thermal process. In 1936, Lukyanov built the first model of his “water integrator” at the Institute of Way and Construction (now Central Research Institute of Transport Construction, or TsNIIS). At that time it was the only computer that could solve partial differential equations.

https://www.amusingplanet.com/2019/12/vladimir-lukyanovs-water-computer.html

For more details and photographs see: Vladimir Lukyanov’s Water Computer.

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

Python Code Updates – py_UMom

Further to the previous post the py_UMom spreadsheet has now been updated for the latest Python and Numpy versions. The latest version can be downloaded from:

py_UMom.zip

In addition to the Python code changes, the example of the OptShearCap3600 function has been updated to use the option to limit the force in the vertical shear steel when checking longitudinal forces due to shear to the current AS 5100.5 code (see Longitudinal force due to shear for details).

Examples of this function are shown below, comparing AS 3600 (with and without adjustment of the compression strut angle) with AS 5100.5 (with and without a limit applied to the value of Vus). In the first examples the reduction factors for bending and shear have been adjusted in the AS 3600 results so that the only difference between the two codes is in the treatment of longitudinal loads due to shear.

With 12 mm shear steel at 200 spacing all results are equal where shear controls the section design but for higher moments the first AS 3600 results are more conservative. If the strut angle is adjusted AS 3600 has a slightly higher capacity than the AS 5100.5 results, where the two options are almost equal up to a moment of about 375 kNm. For higher moments the AS 5100.5 results give a higher capacity, but these values are un-conservative because they use a force in the shear steel greater than the applied shear force. Applying a limit to this force, the AS 5100.5 results are very close to the AS 3600 results with adjustment of the strut angle:

Increasing the shear steel diameter to 20 mm the trend of the results is similar except that in this case the AS 5100.5 results with a limit on Vus are significantly less than the AS 3600 results with adjustment of the strut angle. Note that if the strut angle was adjusted in the AS 5100.5 results (as allowed by the code) the results would be very close to the AS 3600 results. The AS 5100.5 results without a limit on Vus become unconservative for bending moments over 350 kNm in this case, with the applied shear force having no effect on the section capacity for a force of 350 kN or less:

Applying the code reduction factors for the AS 3600 calculations, with the same shear steel as above, the AS 3600 results without adjustment of the strut angle are very close to the AS 5100.5 results with the limit on Vus. AS 5100.5 results without the limit on Vus become lower than the AS 3600 results with adjustment of the strut angle, but again become unconservative for bending moments above about 380 kNm:

Posted in Beam Bending, Concrete, Excel, Link to Python, Newton, NumPy and SciPy, PyXLL, UDFs | Tagged , , , , , , , , | 1 Comment

Python code updates – 3DFrame-py

Recent changes to how Python treats comparing a Numpy array to an empty list have resulted in some of my functions returning errors and I am in the process of updating them. Specifically, when an optional argument to a function might return a NumPy array or an empty list, I have used the line:
if optarg == [] :
but if the argument is a non-empty array, this now returns an error, so has been replaced with:
if len(optarg) == 0:

Updated code for the 3DFrame-py program, and associated spreadsheets can be downloaded from:

3DFrame-py.zip

Details of file installation, and required software are at:

3DFrame-py

and use of the program for analyses including warping effects can be found at:

3DFrame-py update

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

SectionProperties Release 3

Robbie van Leeuwen’s SectionProperties program, (last featured here) has recently been updated to Release 3 with some major changes to the code, including:

  • New, unambiguous section property retrieval with get() methods, see an example here.
  • Improved stress plotting options (new colorbar features, mesh opacity, plot selected materials), see an example here.
  • Improved documentation style and automation.
  • sectionproperties API now has full typing coverage.
  • Significantly expanded examples in the documentation.
  • Add support for Python 3.11.
  • Improved workflow, CI and contributor experience by introducing poetry and nox.

Full documentation can be found at:

SectionProperties docs

Changes to the code have required updates to my Excel front-end spreadsheet. The new version can be downloaded from:

pySectProp3.zip

Note that the new spreadsheet is not backwards compatible with previous versions of SectionProperties. The spreadsheet requires pyxll to be installed, to connect from Excel to the Python code.

Note that the current version of the spreadsheet is a work in progress, and has had minimal testing. Please let me know of any problems, or suggestions for new features.

Typical output, section properties and stress results for a composite pre-stressed bridge girder:

Posted in Beam Bending, Concrete, Excel, Finite Element Analysis, Link to Python, Newton, PyXLL, UDFs | Tagged , , , | Leave a comment