Skip to content

ForeverDavid/pyCM

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License: GPL v3

Introduction

Contour method

The contour method for measuring residual stress is a cost effective, robust technique which has seen much interest both by academics and industry alike. First developed by Michael Prime at Los Alamos, it has seen a great deal of development both in the US and UK.

For more information on the contour method:

Analysis code

Recently it has been found that the visualization tools that are available in MATLAB are not the most robust for the purposes of the contour method. For example, large datasets developed with laser profilometers can often exceed the graphical capabilities of recent versions of MATLAB. The reasons for moving from MATLAB for contour method analysis are numerous:

  • Proprietary nature of the built-in libraries, cost and licensing issues with external ones.
  • Difficulties in dealing with path dependencies on managed desktops.
  • Although 'compiled' MATLAB code can be run on computers without MATLAB installed, this is reliant on the target machine having an identical MATLAB component runtime installation, which is proprietary and quite large (250 Mb+).
  • Diminished text file parsing built into MATLAB which makes working with FE codes difficult; this is particularly true for very large input files/meshes.

Each of these factors contribute to the overall portability of the code and present barriers to the residual stress characterisation community developing, validating and using analysis code.

Some of these have already been addressed via projects such as GNU Octave, a free and open source language similar to MATLAB in terms of development environment and syntax. However, this language has been shown to be quite slow in some cases, as inter-operability with MATLAB was favoured in place of speed. Inter-operability between GNU Octave and MATLAB is still relatively incomplete as MATLAB is developed independently of Octave.

Many researchers have moved from using MATLAB to Python entirely for numerical analysis. Python is an extremely flexible language, with many packages available to perform the same work as MATLAB. Due to the open source nature of Python, there have been many contributions that allow for wrapping compiled science and engineering code written in other languages (Fortran, C, Java) to be called directly by Python. When coupled with Numerical Python (NumPy) and SciPy, a significant amount of the same functionality is available as in MATLAB. Furthermore, there is a maintained library of Python bindings for VTK, the Visualization Toolkit, an extremely robust tool for visualising large datasets. For example, ParaView, an open source FEA post processor, makes extensive use of VTK.

Moving forward

It is for these reasons the overall aim is to future proof the analysis code by moving towards using Python as the language of choice. To this end, a Python package called pyCM (Python Contour Method) has been developed. The idea is to fully move over from using primarily MATLAB functions/scripts to Python equivalents in a step-by-step manner. The development strategy adopted is to build new tools where required, and allow for existing MATLAB tools to be used on the input and output from these Python tools. This will be accomplished using the SciPy packages which generate binary MATLAB files to store workspace variables, so processing can be partially performed in Python, and shifted back into MATLAB to use existing scripts.

Latest version

Alpha release 1.0.0 is currently the latest version which contains a complete toolchain for rectangular specimens with no self-restraint up to the FEA pre-processing step of an analysis. A post-processor is currently being developed, which has been made available in a beta form for testing purposes on quadrilateral meshes only.

Requirements

  1. Python 3.x (last tested on 3.6.0)
  2. Numpy
  3. Scipy
  4. VTK
  5. Matplotlib
  6. pyYaml
  7. PyQt5 (<5.10)

PyQt5 support mirrors that which is used by Spyder, a MATLAB-like Integrated Development Environment (IDE) for Python. Later versions of PyQt5 do not work, and installing later versions will break Spyder 3.3.0.

Once Python is installed, it is recommended on Windows machines to get numpy, scipy and VTK binaries from Christoph Gohlke's Unofficial Windows Binaries for Python Extension Packages for the best possible performance. Note that URLs on this site are blocked, you will have to manually select the distribution that you will need. Install them via:

pip install <pkg_prefix>.whl

However, the sources which arrive from PyPI are acceptable for most purposes and should automatically install - see next section.

Installation

These instructions cover the steps needed to install all dependencies and then add the pyCM components to your Python PATH. This permits calling the pyCM components anywhere on a host machine.

  1. Clone this repository to a location on the host machine.
  2. Change directory to this location and from the command line, run pip install pyCM-* where pyCM-* is the most recent tarball from the dist directory where you've cloned the repository. For example:
pip install pyCM-<version>.tar.gz

The remainder of the requisite packages will be installed from PyPI.

  1. Check if it installed properly by trying to import the pyCM library from any working directory at the Python prompt/IDLE:
from pyCM import *

or a check of installed packages via the pip freeze command.

Uninstalling can be accomplished via pip:

pip uninstall pyCM

Modules

  • main - a tabbed viewer which groups the following tools together to allow a more cohesive analysis route.
  • point_cloud - utility to read and work with raw contour data both with and without perimeter files.
  • align_average - utility to manipulate, align and average two contour surface datasets with perimeter files.
  • fit_surface - utility to fit averaged point clouds
  • preprocess - meshing/boundary condition building tool which works with Abaqus and OS FEA toolchains (Gmsh & Calculix).
  • postprocess - BETA currently only supports results from analyses with quadrilateral meshes.

Contributions and extensions

This project is intended to best serve the overall residual stress community, so feel free to adjust as needed and add functionality. Please contact me directly by email prior to submitting pull requests so that we can discuss overall structure further.

Currently, this project has only been tested on Windows 7 x64, but there is nothing to suggest that it will not work across all platforms.

Acknowledgements

A number of these tools have been developed based on MATLAB code written by Greg Johnson, Chris Gill, Matt Fox, Philip Frankel and Yuan-Sheng Xiong (and probably others) at the University of Manchester between 2004-2013.

I'd also like to acknowledge Richard Moat at the Open University for outlining the architecture of Python and MATLAB interchangeability and highlighting the performance improvements in visualization garnered by VTK.

About

A collection of visualization and data processing tools written in Python for performing the contour method for determining residual stress

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%