*Details of nomenclature and setup*I built a function that calculates the signed moment due to a linearly varying load applied to an arbitrary polygon.

As might be guessed, I used Green’s theorem and Python and Sympy to develop the function.

Imagine (follow along on the PDF below):

- A triangular base in the XY plane (pink)
- The triangular base represents a flat surface subjected to a pressure
- A tetrahedron drawn above that base (blue)
- The tetrahedon has a normalized height of 1.0
- The upper surface of the tetrahedron represents a linear varying load on its triangular base below
- The triangle CG is located at the well-known 'one-third points'
- The tetrahedron CG is located at the well-known 'one-fourth points'
- Several lines are shown (gold), labeled 1 through 6. Using both the function and routine hand methods, I calculate the moment for each of these lines.
- Given the obove: the moment may be easily calculated by hand, as shown in the PDF (of course, I specially chose the geometry)
- In this post, however, the hand calculations are only provided to verify the Python function
- Using the function we can calculate much more difficult loading situations
- The algebra in the function, as presented below, might be simplified algebraically, sometime in the future

*Note*

In some of the presentations in this post, I provide calculations to several decimal places. This is done here to ascertain/assert/prove that all calculations are as expected; not to imply a level of proper engineering accuracy.

Example unlabeled

Example labeled

Example problem — all input

Example problem — miscellaneous data —

*of this is required by the function, just FYI*

**none**Spreadsheet screenshot — simple as this !

**Excel formula for the moment shown in the example:**######################################### # note that W=1 in this example # W is the slope of the oblique plane ######################################### =W*get_line_fxy(my_points,A,B,m,xq,yq) # W = 1 # my_points = [[3, 0], # [7, 0] # [7, 3] # [4, 3] # [4, 8] # [2.25, 8] # [2.25, 1.75]] # A = 3 # B = 7 # m = 5/6 = 0.833333 # xq = 4 # yq = 0

**Excel calculated answer for the moment shown in the example:**= -109.745

**PyXLL function**################################ # this is the PyXLL function ################################ @xl_func("float[][] l_pts_input, float A, float B, float m, float xq, float yq: float") def get_line_fxy(l_pts_input, A, B, m, xq, yq): """ Compute moment about a line due to varying pressure :param l_pts_input: 2D points :param A: x-intercept of neutral axis :param B: y-intercept of neutral axis :param m: defines line basis, slope of line :param xq: defines line basis, x-coord of point on line :param yq: defines line basis, y-coord of point on line :return: moment """ l_pts = fs.Points(l_pts_input) moment = fs.Section.line_fxy(l_pts, A, B, m, xq, yq) return moment

**Python function**################################ # this is the Python function ################################ def line_fxy(pts_input: Points, a, b, m, xq, yq): """Input: polygon as list of points points are type Point Output: """ # polygon must be a 'closed' set of coordinates # therefore, last point must equal first point length_factor = a*b/(a**2+b**2)**0.5 pts = Points(pts_input) pts.close_polygon() x = [e.x for e in pts] y = [e.y for e in pts] mx = 0 for i in range(len(pts) - 1): x0 = x[i] x1 = x[i + 1] y0 = y[i] y1 = y[i + 1] mx_temp = ( 4 * a * b * ( 2 * m * x1**2 * y1 + x0**2 * (-2 * m * y0 - m * y1) + x0 * ( m * x1 * y0 - m * x1 * y1 + 3 * m * xq * y0 + 3 * m * xq * y1 + y0**2 + y0 * y1 - 3 * y0 * yq + y1**2 - 3 * y1 * yq ) - x1 * y0**2 + x1 * (-3 * m * xq * y1 - y1**2 + 3 * y1 * yq) + y0 * (m * x1**2 - 3 * m * x1 * xq - x1 * y1 + 3 * x1 * yq) ) + a * ( -3 * m * x1**2 * y1**2 + x0**2 * (3 * m * y0**2 + 2 * m * y0 * y1 + m * y1**2) + x0 * ( -2 * m * x1 * y0**2 + 2 * m * x1 * y1**2 - 4 * m * xq * y0**2 - 4 * m * xq * y0 * y1 - 4 * m * xq * y1**2 - 2 * y0**3 - 2 * y0**2 * y1 + 4 * y0**2 * yq - 2 * y0 * y1**2 + 4 * y0 * y1 * yq - 2 * y1**3 + 4 * y1**2 * yq ) + 2 * x1 * y0**3 + x1 * (4 * m * xq * y1**2 + 2 * y1**3 - 4 * y1**2 * yq) + y0**2 * (-m * x1**2 + 4 * m * x1 * xq + 2 * x1 * y1 - 4 * x1 * yq) + y0 * ( -2 * m * x1**2 * y1 + 4 * m * x1 * xq * y1 + 2 * x1 * y1**2 - 4 * x1 * y1 * yq ) ) + b * ( -6 * m * x1**3 * y1 + x0**3 * (6 * m * y0 + 2 * m * y1) + x0**2 * ( -2 * m * x1 * y0 + 2 * m * x1 * y1 - 8 * m * xq * y0 - 4 * m * xq * y1 - 3 * y0**2 - 2 * y0 * y1 + 8 * y0 * yq - y1**2 + 4 * y1 * yq ) + x0 * ( -2 * m * x1**2 * y0 + 2 * m * x1**2 * y1 + 4 * m * x1 * xq * y0 - 4 * m * x1 * xq * y1 + 2 * x1 * y0**2 - 4 * x1 * y0 * yq - 2 * x1 * y1**2 + 4 * x1 * y1 * yq ) + x1**2 * y0**2 + x1**2 * (8 * m * xq * y1 + 3 * y1**2 - 8 * y1 * yq) + y0 * ( -2 * m * x1**3 + 4 * m * x1**2 * xq + 2 * x1**2 * y1 - 4 * x1**2 * yq ) ) ) / (24 * a * b * (m**2 + 1) ** 0.5) mx += mx_temp return mx*length_factor

https://en.wikipedia.org/wiki/George_Green_(mathematician)#Cambridge

**Excerpt**

In 1832, aged nearly forty, Green was admitted as an undergraduate at Cambridge and graduated with a BA in 1838.

Green’s work on the motion of waves in a canal (resulting in what is known as Green’s law) anticipates the WKB approximation of quantum mechanics, while his research on light-waves and the properties of the Aether produced what is now known as the Cauchy-Green tensor. Green’s theorem and functions were important tools in classical mechanics, and were revised by Schwinger’s 1948 work on electrodynamics that led to his 1965 Nobel prize (shared with Feynman and Tomonaga). Green’s functions later also proved useful in analysing superconductivity.

It is unclear to historians exactly where Green obtained information on current developments in mathematics, as Nottingham had little in the way of intellectual resources. What is even more mysterious is that Green had used “the Mathematical Analysis”, a form of calculus derived from Leibniz that was virtually unheard of, or even actively discouraged, in England at the time (due to Leibniz being a contemporary of Newton, who had his own methods that were championed in England). This form of calculus, and the developments of mathematicians such as the French mathematicians Laplace, Lacroix and Poisson, were not taught even at Cambridge, let alone Nottingham, and yet Green not only had heard of these developments, but improved upon them.

The theoretical physicist Julian Schwinger, who used Green’s functions in his ground-breaking works, published a tribute entitled “The Greening of Quantum Field Theory: George and I” in 1993.

The young theoretical physicists of a generation or two earlier subscribed to the belief that: If you havenâ€™t done something important by age 30, you never will. Obviously, they were unfamiliar with the history of George Green, the miller of Nottingham.

Born, as we all know, exactly two centuries ago, he received, from the age 8, only a few terms of formal education. Thus, he was self-educated in mathematics and physics, when in 1828, at age 35, he published, by subscription, his first and most important work: An Essay on the Applications of Mathematical Analysis to the Theory of Electricity and Magnetism. The Essay was dedicated to a noble patron of the â€śSciences and Literatureâ€ť, the Duke of Newcastle. Green sent his own copy to the Duke. I do not know if it was acknowledged. Indeed, as Albert Einstein is cited as effectively saying, during his 1930 visit to Nottingham, Green, in writing the Essay, was years ahead of his time.

There are those who cannot accept that someone, of modest social status and limited formal education, could produce formidable feats of intellect.

Green’s Mill in Sneinton, the mill owned by Green’s father.

The mill was renovated in 1986 and is now a science centre.