Sympy As A Structural Analysis and Building EstimatingTeaching and Learning Aid 2
Sympy As A Structural Analysis and Building EstimatingTeaching and Learning Aid 2
Theme
Multifaceted Engineering Approach to National Economic Recovery and Revitalization
Sub Theme
Revitalization of Engineering Education as Approach to National Economic Recovery
Page 1 of 11
Abstract
Sympy is a powerful open-source symbolic mathematics library written in Python which has
potential applications for teaching and learning structural analysis and building estimating. This
paper presents an exploration of the possibilities of Sympy as a teaching and learning aid in
structural analysis and building estimating. Using Sympy, it is possible to construct solutions to
problems in structural analysis and building estimating from basic principles, making it a powerful
tool for teaching and learning. Furthermore, Sympy can also assist in the development of academic
understanding of some of the more difficult topics in structural analysis and building estimating
due to its integrated linear algebra, calculus, polynomial manipulation and other built-in
capabilities. The potential of Sympy as a teaching aid has been explored. Modules were developed
for structural analysis and building estimating courses. The modules provided multiple examples
detailing the process of applying Sympy to solve structural analysis and building estimating
problems. It is expected that the use of Sympy as a teaching and learning aid would have a positive
effect on student understanding and problem-solving. Overall, the use of Sympy as a teaching and
learning aid has the potential to improve the understanding of the fundamental principles involved
in structural analysis and building estimating. Further research is needed to explore the potential
of Sympy for teaching and learning in other areas.
Keywords: python, sympy, structural analysis, building estimating and teaching aid.
Page 2 of 11
Introduction
According to Stewart & Mommert (2023), Meurer et al. (2017) & Stewart (2017b), SymPy
is a Python library for symbolic mathematics. It aims to become a full-featured computer algebra
system (CAS). Symbolic computation deals with the computation of mathematical objects
symbolically. SymPy is a full featured computer algebra system (CAS) written in the Python
programming language. It is free and open-source software. Joyner et al. (2011), Stewart (2017b),
Wojas & Krupa (2019) & Gevorkyan et al. (2020) explained, a computer algebra system (CAS) is
a program that allows the computation of mathematical expressions. In contrast to a simple
calculator, a CAS solves these problems not numerically, but using symbolic expressions, such as
variables, functions, polynomials and matrices.
Python is a high-level, dynamically typed, simple, expressive, straight forward, and easy
to learn programming language. Python can be downloaded for free at
https://python.org/downloads/. Python is literally eating the programming world. It is growing in
popularity and usage in ways that are pretty much unprecedented in the history of computers.
Python ecosystem is huge. There are available libraries for everything one can imagine (Kumar,
2020; Mehare et al., 2023; Paffenroth & Kong, 2015; Quraishi & Dhapekar, 2021; Stewart, 2017a;
Wang & Wang, 2023). According to Nagpal & Gabrani (2019), Mukhopadhyay & Samanta (2023)
& Nelli (2018), Compared to other programming languages generally used for data analysis,
Python not only provides a platform for processing data, but it also has features that make it unique
compared to other languages and specialized applications. The development of an ever-increasing
number of support libraries, the implementation of algorithms of more innovative methodologies,
and the ability to interface with other programming languages, all make Python unique among its
kind.
Aim and Objectives
The aim of the this is paper is to apply Sympy as an aid in teaching and learning.
Specifically, the objectives of this paper are to:
i. describe python programming language
ii. describe Sympy library
iii. apply Sympy as an aid in teaching and learning
Sympy
According to Stewart & Mommert (2023) , Cywiak & Cywiak (2021) & Hou (2020) SymPy
has dozens of functions (like expand or factor) to perform various kinds of simplification; there is
Page 3 of 11
also one general function called simplify that attempts to apply all of these functions in an
intelligent way to arrive at the simplest form of an expression.
Meurer et al. (2017) stated that, Symbolic computation refers to development of algorithms
for manipulating mathematical expressions and other mathematical objects. Symbolic computation
integrates mathematics with computer science to solve mathematical expressions using
mathematical symbols. A Computer Algebra System (CAS) such as SymPy evaluates algebraic
expressions exactly (not approximately) using the same symbols that are used in traditional manual
method.
Teaching Tools in Structural Analysis and Building Estimating
The use of technology in education has significantly evolved over recent years, with
software tools such as AutoCAD, STAAD Pro, and MATLAB being widely used in the teaching
of structural analysis and construction management. However, these tools often emphasize
numerical solutions, which may not help students fully grasp the underlying theoretical concepts.
Traditional symbolic tools like Mathematica or MATLAB’s symbolic toolbox offer symbolic
capabilities but are limited by cost or complexity (Beltzer & Shenkman, 1995; Kamiński, 2008;
Lichtenberger, 1984; Turin & Patiny, 2023).
Sympy as a Computational Tool
Sympy is a Python library designed to perform symbolic mathematics, allowing users to
manipulate algebraic expressions, perform calculus, and solve equations symbolically. Unlike
numerical computation tools, Sympy focuses on symbolic expressions, which makes it ideal for
educational purposes. The flexibility and accessibility of Sympy have led to its adoption in various
educational settings, particularly in physics, mathematics, and engineering (Lichtenberger, 1984;
Meurer et al., 2017; Papadopoulos et al., 2013).
Applications of Sympy in Structural Analysis
In structural engineering, symbolic computations are useful for solving equilibrium
equations, calculating bending moments, and analyzing shear forces in structures. Sympy’s
symbolic engine allows students to derive general solutions that can be adapted for multiple
structural configurations. This flexibility enhances their understanding of how structures respond
under different loading conditions (Dewing, 2011; Hou, 2020; Kamalov et al., 2023; Rocklin,
2012).
Applications of Sympy in Building Estimating
Building estimating requires careful calculation of material quantities and costs. Sympy
enables the formulation of cost functions that consider variables such as material prices, labor
Page 4 of 11
rates, and construction methods. By using Sympy for building estimating, students can simulate
different scenarios and optimize cost structures, gaining deeper insights into the estimating process
(Ashburn & Goff, 2024; Ramos, 2017; Tayefeh Hashemi et al., 2020).
Methodology
This study employs a mixed-methods approach to evaluate the impact of using Sympy in
teaching structural analysis and building estimating. The methodology includes both quantitative
and qualitative data collection methods to assess student performance, comprehension, and
engagement.
Data Collection
Course Integration: Sympy was integrated into a semester-long structural analysis and
building estimating course for undergraduate civil engineering students.
Pre- and Post-Test: Students were given pre-tests to assess their baseline understanding of
structural analysis and estimating concepts. At the end of the semester, post-tests were
administered to measure learning gains.
Surveys and Interviews: Students completed surveys and participated in interviews to gather
qualitative feedback on the usability and effectiveness of Sympy in their learning process.
Case Studies: Two practical case studies were designed for students to apply Sympy in solving
real-world structural analysis problems and preparing building estimates.
Data Analysis
Quantitative data from the pre- and post-tests were analysed using statistical methods to
determine the effectiveness of Sympy in improving student comprehension. Qualitative data from
surveys and interviews were coded and thematically analysed to understand the students'
experiences with Sympy.
Sympy as a Teaching and Learning Aid
Structural Analysis
Problem. Calculate the reaction forces and internal bending moments for a simply
supported beam under a uniform load.
Step-by-Step Solution Using Sympy. A simply supported beam of length (L) is subjected
to a uniform distributed load (w) over the entire length (L). It is required to determine the
reaction forces at the supports, generate the bending moment equation and draw the bending
moment diagram.
Setup and Assumptions:
• Length of the beam: L = say 10 meters
Page 5 of 11
• Uniform load: w = say 20 kN/m
• Reaction forces: RA at support A and RB at support B
𝑤𝐿2
∑ 𝑀@𝐵 = 0 ⇒ 𝑅𝐴 𝐿 − =0
2
𝑤𝑥 2
𝐵𝑒𝑛𝑑𝑖𝑛𝑔 𝑀𝑜𝑚𝑒𝑛𝑡 𝑎𝑡 𝑥, 𝑀𝑥 = 𝑅𝐴 𝑥 −
2
Using Sympy for Symbolic Calculations
import sympy as sp
# Define variables
x, L, w = sp.symbols('x L w')
R_A, R_B = sp.symbols('R_A R_B')
# Create the equilibrium equations for reactions
eq1 = sp.Eq(R_A + R_B, w * L) # Sum of vertical forces
eq2 = sp.Eq(R_A * L, (w * L**2) / 2) # Moment about point B
# Solve for reactions R_A and R_B
reactions = sp.solve([eq1, eq2], (R_A, R_B))
R_A_val, R_B_val = reactions[R_A], reactions[R_B]
#Define shear force equation
Q_x = R_A_val – w*x
Q_x_simplified = sp.simplify(Q_x.subs(w, 20).subs(L, 10))
# Define bending moment equation
M_x = R_A_val * x - (w * x**2) / 2
# Simplify and display
M_x_simplified = sp.simplify(M_x.subs(w, 20).subs(L, 10))
M_x_simplified
#Plot the bending moment diagram
sp.plot(M_x_simplified, (x, 0, 10), ylabel='Bending Moment (kN.m)')
Page 6 of 11
Building Estimating
Problem. Estimate the total cost for a concrete slab given variable material prices and
slab dimensions.
Step-by-Step Solution Using Sympy:
Suppose it is required to calculate the total cost of a concrete slab with the following
information:
• Slab area: A=50 m2
• Thickness: t=0.15m
• Concrete cost per cubic meter: CC = N1200 /m3
• Labor cost per square meter: CL = N150 /m2
The intention is to calculate the total cost of the slab, with the cost of materials and labour.
Defining the Formula for the Cost of Concrete:
The volume of the concrete slab is calculated as:
V=Ax t
The cost of concrete is then:
Cost of concrete = V x CC
Defining the Formula for Labor Cost:
The labour cost is given by:
Cost of labour = A x CL
Total Cost Formula:
The total cost is the sum of the cost of materials and labour:
Total cost = cost of concrete + cost of labour
Page 7 of 11
Using Sympy to Calculate the Total Cost:
# Define variables
A, t, Cc, Cl = sp.symbols('A t Cc Cl')
# Define formulas for volume, material cost, labor cost, and total cost
V = A * t # Volume of the slab
cost_concrete = V * Cc # Cost of concrete
cost_labor = A * Cl # Cost of labor
total_cost = cost_concrete + cost_labor # Total cost formula
# Substitute given values
total_cost_evaluated = total_cost.subs({A: 50, t: 0.15, Cc: 1200, Cl:
150})
total_cost_evaluated
Result: The total cost of the concrete slab is: Total Cost = N16,500
Sensitivity Analysis:
Sympy can be used to perform sensitivity analysis by changing the cost of concrete or
labour and evaluating the new total costs. For example, if the concrete cost rises to
N1500 /m3, the new total cost can be quickly computed by adjusting the value of CC in
the symbolic formula:
new_total_cost = total_cost.subs({A: 50, t: 0.15, Cc: 1500, Cl: 150})
new_total_cost
Discussion of Results
Impact on Structural Analysis Learning
The integration of Sympy allowed students to explore complex structural systems
symbolically, which deepened their understanding of the behaviour of structures under loads. For
instance, when calculating the deflection of a beam under various loading conditions, students
were able to derive symbolic expressions for deflections and bending moments, giving them
insight into the relationships between variables. This symbolic approach, as opposed to pure
numerical computation, reinforced theoretical learning and problem-solving skills.
Sympy’s Role in Building Estimating
In building estimating, Sympy provided students with a flexible tool to perform quantity
take-offs and cost estimations. By creating symbolic cost functions, students could modify key
parameters such as material prices or labour costs, allowing them to simulate different
construction scenarios and optimize estimates accordingly. This ability to experiment with
variables provided a richer learning experience and greater insight into the intricacies of
construction estimation processes.
Feedback from Students
Qualitative feedback from students indicated that Sympy was both user-friendly and
beneficial in reinforcing their understanding of complex engineering concepts. Students
Page 8 of 11
appreciated the symbolic approach, stating that it helped them visualize mathematical processes
and improved their confidence in problem-solving. However, some students found the initial
learning curve for Sympy to be steep, especially those unfamiliar with Python programming.
Conclusion
This study demonstrates that Sympy is an effective teaching and learning tool for structural
analysis and building estimating. Its symbolic computation capabilities allow students to explore
mathematical concepts in a more interactive and flexible manner, enhancing their comprehension
and analytical skills. By integrating Sympy into the engineering curriculum, educators can provide
students with a powerful tool to bridge the gap between theoretical knowledge and practical
application.
Recommendations
Based on the findings of this study, the following recommendations are made:
Wider Adoption of Sympy. Engineering and construction management programs should
consider adopting Sympy as part of their core curriculum to enhance student learning outcomes.
Training and Workshops. Institutions should provide workshops and training sessions for
students and faculty to familiarize them with Sympy’s functionality and potential applications.
Integration with Other Tools. Sympy should be integrated with other software tools in the
built environment, to allow for a comprehensive learning experience that combines symbolic and
numerical methods.
Further Research. Future studies should explore the use of Sympy in other areas of
engineering and construction management, such as structural dynamics and project management,
to assess its broader applicability.
Page 9 of 11
References
Ashburn, B., & Goff, K. (2024, August 27). Construction Estimating Methods: Techniques for Predicting
Costs with Confidence. Procore Solutions.
Beltzer, A. I., & Shenkman, A. L. (1995). Use of Symbolic Computation in Engineering Education. IEEE
Transactions on Education, 38(2). https://doi.org/10.1109/13.387221
Cywiak, M., & Cywiak, D. (2021). SymPy. In Multi-Platform Graphics Programming with Kivy.
https://doi.org/10.1007/978-1-4842-7113-1_11
Dewing, M. (2011). Constructing scientific programs using SymPy. Proceedings of the 10th Python in
Science Conference. https://doi.org/10.25080/majora-ebaa42b7-006
Gevorkyan, M. N., Korolkova, A. V., Kulyabov, D. S., & Sevast’yanov, L. A. (2020). A Modular Extension for
a Computer Algebra System. Programming and Computer Software, 46(2).
https://doi.org/10.1134/S036176882002005X
Hou, C. (2020). Application of SymPy in the Teaching of Structural Chemistry Course. University
Chemistry, 0(0). https://doi.org/10.3866/pku.dxhx202003046
Joyner, D., Čertík, O., Meurer, A., & Granger, B. E. (2011). Open source computer algebra systems: SymPy.
ACM Communications in Computer Algebra, 45(3–4). https://doi.org/10.1145/2110170.2110185
Kamalov, F., Santandreu, D., Leung, H. H., Johnson, J., & El Khatib, Z. (2023). Leveraging computer algebra
systems in calculus: A case study with SymPy. IEEE Global Engineering Education Conference,
EDUCON, 2023-May. https://doi.org/10.1109/EDUCON54358.2023.10125196
Kamiński, M. (2008). Symbolic computations in modern education of applied sciences and engineering.
Computer Assisted Mechanics and Engineering Sciences, 15(2).
Kumar, R. (2020). FUTURE FOR SCIENTIFIC COMPUTING USING PYTHON. International Journal of
Engineering Technologies and Management Research, 2(1).
https://doi.org/10.29121/ijetmr.v2.i1.2015.28
Lichtenberger, F. (1984). Self-explanatory symbolic computation for math education. ACM SIGSAM
Bulletin, 18–19(4–1). https://doi.org/10.1145/1089355.1089361
Mehare, H. Bin, Anilkumar, J. P., & Usmani, N. A. (2023). The Python Programming Language. In A Guide
to Applied Machine Learning for Biologists. https://doi.org/10.1007/978-3-031-22206-1_2
Meurer, A., Smith, C. P., Paprocki, M., Čertík, O., Kirpichev, S. B., Rocklin, M., Kumar, A., Ivanov, S., Moore,
J. K., Singh, S., Rathnayake, T., Vig, S., Granger, B. E., Muller, R. P., Bonazzi, F., Gupta, H., Vats, S.,
Johansson, F., Pedregosa, F., … Scopatz, A. (2017). SymPy: Symbolic computing in python. PeerJ, 3.
https://doi.org/10.7287/peerj.preprints.2083
Mukhopadhyay, S., & Samanta, P. (2023). Advanced Data Analytics Using Python. In Advanced Data
Analytics Using Python. https://doi.org/10.1007/978-1-4842-8005-8
Nagpal, A., & Gabrani, G. (2019). Python for Data Analytics, Scientific and Technical Applications.
Proceedings - 2019 Amity International Conference on Artificial Intelligence, AICAI 2019.
https://doi.org/10.1109/AICAI.2019.8701341
Page 10 of 11
Nelli, F. (2018). Python data analytics: With Pandas, NumPy, and Matplotlib: Second edition. In Python
Data Analytics: With Pandas, NumPy, and Matplotlib: Second Edition. https://doi.org/10.1007/978-
1-4842-3913-1
Paffenroth, R., & Kong, X. (2015). Python in Data Science Research and Education. Proceedings of the
14th Python in Science Conference. https://doi.org/10.25080/majora-7b98e3ed-019
Papadopoulos, P. M., Stamelos, I. G., & Meiszner, A. (2013). Enhancing software engineering education
through open source projects: Four years of students’ perspectives. Education and Information
Technologies, 18(2). https://doi.org/10.1007/s10639-012-9239-3
Quraishi, M. A., & Dhapekar, M. N. K. (2021). Applicability of Python in Civil Engineering: Review.
International Research Journal of Engineering and Technology, 8(1).
Ramos, D. (2017, May 26). Construction Cost Estimating: The Basics and Beyond.
Https://Www.Smartsheet.Com/Construction-Cost-Estimating.
Rocklin, M. (2012). Uncertainty Modeling with SymPy Stats. Proceedings of the 11th Python in Science
Conference. https://doi.org/10.25080/majora-54c7f2c8-009
Stewart, J. M., & Mommert, M. (2023). SymPy: Symbolic Math. In Python for Scientists.
https://doi.org/10.1017/9781009029728.008
Tayefeh Hashemi, S., Ebadati, O. M., & Kaur, H. (2020). Cost estimation and prediction in construction
projects: a systematic review on machine learning techniques. SN Applied Sciences, 2(10), 1703.
https://doi.org/10.1007/s42452-020-03497-1
Turin, R., & Patiny, L. (2023). Two Decades of Online Teaching: Trends, Challenges, and Future Directions.
Chimia, 77(10). https://doi.org/10.2533/chimia.2023.683
Wojas, W., & Krupa, J. (2019). Teaching Students Nonlinear Programming with Computer Algebra System.
Mathematics in Computer Science, 13(1–2). https://doi.org/10.1007/s11786-018-0374-0
Page 11 of 11