Following the previous post I have adapted the units code to use the Pint package, and added a function using the Sympy equation solver, with Pint units. I have applied the functions to finding the depth of neutral axis of a reinforced concrete beam, under combined bending and axial load. A similar example was previously presented using VBA code.
The spreadsheet and associated Python code can be downloaded from:
The screen-shot below shows the same examples as previously presented using the Unyt package:
As before, the Excel exponentiation symbol may be used both in functions to be evaluated and in unit names, and is converted automatically to the Python **.
The next example shows input for a rectangular reinforced concrete section with two layers of reinforcement. The input is a 3 column range with symbols, values, and units. Input values and units are shaded grey.:
The first example finds the depth of the neutral axis at the Ultimate Limit State, assuming a rectangular stress block for the concrete in compression, with a strain of 0.003 at the compression face. The tension steel is assumed to be at the yield stress, and the compression steel in the elastic range. With these assumptions, a quadratic equation is formed, relating the nett force on the section to the depth of the neutral axis, x. This equation is then solved using the user defined function (UDF) SolveU, that calls the Sympy Eq function. The UDF result is checked on the right using the standard formula for quadratic equations:
The SolveU function arguments are:
- Solveu(lhs, rhs, datrange, var_sym = ‘x’, rtnunit = ”, out = 0, adddat = ):
- lhs, rhs: Text strings for the equation Left and Right Hand Sides, to be equalised
- datrange: Three column range with equation constant symbols, values, and units
- var_sym: Optional variable symbol; default = ‘x’
- rtnunit: Optional units of the return value; default = base SI units
- out: Optional output index; default = 0, return all values as an array (complex numbers are returned as two values in adjacent columns)
- adddat: Optional additional data. Three column range. Default = none.
A second ULS example is shown below, with the axial load increased so that the compression steel is past the yield point, but the tension steel is in the elastic range:
The third example finds the neutral axis depth for linear elastic behaviour in both steel layers, and the concrete in compression, with a given axial force and applied bending moment.
In this case the strain of the concrete at the compression face is initially unknown. To enable a closed form solution:
- The strain at the compression face is assumed to be equal to the neutral axis depth, x
- A cubic equation for x is solved, such that the internal Force/Moment ratio is equal to Force/Moment of the applied loads, assuming linear behaviour of the steel and the compression concrete.
- The nett internal force is calculated assuming unit stress at the compression face.
- This stress is then factored so that the internal force is equal to the applied axial force, and the internal moment calculated, to check that it is equal to the applied moment.
In the example below the cubic equation for the neutral axis depth is solved using the SolveU function, and compared with the results using the VBA Cubic UDF:
Having found the depth of the neutral axis, the internal force and moment are calculated assuming a unit stress (Sigc) at the compression face:
Finally the compression stress is scaled to generate a reaction force equal to the applied load of 500 kN (25. 46 MPa), and the internal moment about the concrete centroid is checked against the applied moment. The calculated stress may then be copied to the Sigc value (cell D108), to find the actual forces and moments in the steel and concrete under the applied load:
Pingback: Pint, MPmath and implied units, working with Excel | Newton Excel Bach, not (just) an Excel Blog