Friday, October 28, 2016

Plotting Beam Diagrams with Python

     Today I'm sharing how to plot Beam Diagrams using python. More specifically the code is about a cantilever beam subjected to gravity load, a special case of uniformly distributed load. There's a bunch of cool python features in this post, like the very convenient use of "x>" to evaluate a function, or part of it, only after a specified value in the array.

For example, the code: (my blog font shows this symbol =, as equals, this is a minus -)

import numpy as np
x=np.linspace(1,10,10)
y=2*x*(x>5)
print x
print y

returns these two arrays.

[  1.   2.   3.   4.   5.   6.   7.     8.   9.    10.]
[  0.   0.   0.   0.   0.  12.  14.  16.  18.    20.]

     Values with "false" boolean condition returned 0, and the values with "true" condition were evaluated. This is very useful when computing singularities functions, also known as Macaulay method, due to the British mathematician William Herrick Macaulay.  Oddly this method was first proposed by the German mathematician Alfred Clebsch. 

    Other features that worth take a look is how to make very neat plots using matplotlib subplots method.

The code:



The plot:


See ya!

No comments:

Post a Comment