Welcome to this presentation of the draft for the opening chapter of my upcoming book, titled "Structural Engineering: Dynamics, Seismic Solution, and AI Integration." This chapter delves into the intricate realm of undergraduate structural dynamics. This endeavor is not meant to mirror the exhaustive details laid out in some of the field's seminal literature. If you're familiar with works from esteemed authors such as Chopra, Mario Paz, Cloth & Penzien, among others, you'll be aware of the profound depth and rigor they bring to the underlying concepts and mathematical foundations of structural dynamics. Rather than merely echoing their profound insights, this book and the initial chapter provided here chart a distinctive course.
The chief aim is to distill intricate theoretical mathematics into more accessible discrete mathematical frameworks, offering clear outlines of pivotal concepts in dynamic structures. This proves indispensable for students traversing the expansive realm of structural dynamics. By intertwining essential theories with illustrative Python code samples, readers will unlock understanding of the fundamental mechanics underpinning both single-degree-of-freedom SDOF and multi-degree-of-freedom MDOF dynamic systems. The focus remains unwaveringly on applications within structural engineering, positioning this as a prized asset for those immersing themselves in the field. It's vital to understand that this draft of the initial chapter isn't designed to serve as an isolated guide. Instead, it acts in tandem with conventional educational tools, reinforcing the bedrock knowledge students garner in academic settings. For a nuanced and comprehensive grasp of the domain, turning to the venerable tomes of dedicated structural dynamics literature is imperative. When combined with in-depth classroom learning, the revelations from such extensive studies will unquestionably refine a scholar's proficiency. I invite you to join me on this illuminating expedition, and I hope it lays the foundation for your scholastic and professional achievements in structural dynamics.
Acknowledging the significance for the readers to practically apply the mathematical concepts taught in classes, this book aims to bridge the gap with an introduction to basic Python programming. To facilitate this, essential instructions for navigating the VSCode environment and Python engine are thoughtfully included. While readers are encouraged to execute the various codes provided throughout the book and those hosted in the GitHub repository in their preferred environment, it is important to note that these instructions are reflective of the technological standards and installation processes as of late 2023. Thus, due to the pace of technological advancement, these guidelines may evolve over time
Installing Visual Studio Code and Python for Civil Engineering Students
This guide will help you install Visual Studio Code (VSCode) and set up Python for your coding needs in civil engineering.
Step 1: Install Visual Studio Code
Download and Install
.exe
file to start the installation process.Step 2: Install Python
Download and Install
Step 3: Set Up Python in VSCode
Install Python Extension
Ctrl+Shift+X
).Verify Python Installation
.py
extension, e.g., test.py
.print("Hello, World!")
.Step 4: Install and Use Jupyter Notebooks (Optional)
Install Jupyter Extension
Ctrl+Shift+X
).Using Jupyter Notebooks
Ctrl+Shift+P
to open the command palette.Shift+Enter
.Select Python Kernel for Jupyter Notebooks
Step 5: Start Coding
You're all set! You can now begin writing Python code in Visual Studio Code. Create new .py
or ipynb
files and explore Python's capabilities.
The study of vibration phenomena in mechanical systems dates back to ancient times, but it wasn't until the 17th century that the mathematical foundations for analyzing these phenomena were developed by mathematicians such as Galileo Galilei and Isaac Newton. In the following centuries, the study of vibration became increasingly important as it was applied to practical engineering problems such as the design of machines, buildings, and bridges. One of the key developments in the analysis of vibrating systems was the discovery of the principle of superposition, which states that the response of a system to multiple excitations can be obtained by summing the responses to each excitation individually. Another important development was the realization that many practical vibrating systems can be modeled as discrete, 1-degree-of-freedom (SDOF) systems. In the 19th century, the French mathematician Joseph Louis Lagrange developed a powerful tool for analyzing the dynamics of mechanical systems, which became known as Lagrangian mechanics. This approach allows the equations of motion for a system to be derived from a single function, the Lagrangian, which describes the system's kinetic and potential energy.
Using Lagrangian mechanics, it is possible to derive the equation of motion for a discrete SDOF vibrating system. This equation relates the displacement of the system to the external forces acting on it and the system's characteristics such as its mass, stiffness, and damping. The equation can then be solved to obtain the system's displacement response to a given excitation. Today, the equation for solving the displacement response of a discrete SDOF conservative vibrating system is a fundamental tool in structural engineering and is used in many applications such as the design of buildings, vehicles, and machines. Its development represents a significant milestone in the history of vibration analysis and has paved the way for further advances in the field.
In the 18th century, Daniel Bernoulli introduced the theory of string vibrations, which led to a deeper understanding of harmonic vibrations and their relevance in musical systems. It was an epiphanic moment when engineers and mathematicians realized that the principles behind the vibration of a string on a musical instrument could also be applied to structures like bridges and buildings. This connection between music and mechanics resulted in the development of structural acoustics, a discipline that examines how vibrations travel through structures and how they can be controlled or manipulated.
In the 20th century, with the advent of more advanced technologies, the need to understand and control vibrations became even more crucial. The Tacoma Narrows Bridge disaster in 1940 is a stark reminder of the importance of considering vibrations in engineering. Due to its design and wind conditions, the bridge entered a destructive dynamic magnification, leading to its collapse. This event reshaped the way engineers approached the study of structural dynamics, emphasizing the need to consider all possible forms of excitation and response. Besides theoretical advances, there were a slew of tools and techniques that evolved to measure and analyze vibrations. For instance, Spectral Analysis allowed engineers to break down complex vibrations into their fundamental components, facilitating a better understanding and control of dynamic systems. Tools like the spectroscope and modal analysis techniques became indispensable in labs and industrial applications, enabling safer and more efficient designs.
As technology progressed into the latter half of the 20th century, computational tools became indispensable. Finite Element Analysis (FEA), a computational technique originating from the Ritz method and the Galerkin method, empowered engineers to model and simulate complex structures under dynamic loads. This method transformed how industries approached design, especially in aerospace and automotive sectors, ensuring structural integrity against vibrational loads without exhaustive physical testing. The onset of the space age brought about new challenges. The launch of satellites and spacecrafts necessitated an understanding of vibrations in a vacuum, with the absence of damping from atmospheric air. Engineers turned to historical texts and combined them with modern computational techniques. Remarkably, the works of luminaries like Leonhard Euler and Sophie Germain found renewed relevance in this era, proving that foundational principles, once established, can find utility across centuries.
In more recent times, with the rise of sustainable architecture and the pressing challenges of climate change, understanding the dynamic response of structures has taken on a new dimension. Modern buildings, such as the Taipei 101 in Taiwan, employ massive tuned mass dampers to counteract vibrations induced by earthquakes and high winds. This integration of engineering dynamics into architecture exemplifies the multidisciplinary approach of the 21st century, bridging historical knowledge with cutting-edge innovation.
In the mid-20th century, a groundbreaking discovery in the field of structural dynamics was made. Engineers developed the concept of "modal analysis," a technique that allows them to determine the natural frequencies and mode shapes of a structure. This breakthrough not only revolutionized the way we design buildings and bridges. The intersection of art and science has also been profoundly impacted by vibration analysis. In the realm of music, the study of harmonic vibrations led to the creation of musical instruments with exceptional tonal quality. Stradivarius violins, for example, are celebrated for their unique resonance properties, which remain a subject of fascination and study among both musicians and engineers. Moreover, another fascinating historical fact is the role of vibrations in the world of paleontology. By analyzing the vibrations produced by fossils, researchers can gain insights into the structure and behavior of prehistoric creatures. This interdisciplinary approach has shed light on the movements of dinosaurs and ancient marine life, adding a new dimension to our understanding of Earth's history.
In recent decades, the development of "smart materials" has brought about a paradigm shift in vibration control. Materials with the ability to adapt their stiffness and damping properties in real-time have enabled structures to actively mitigate vibrations. This innovation has found applications in skyscrapers, where sensors and actuators work together to counteract the swaying caused by high winds, ensuring occupant comfort and safety.
Understanding dynamic systems plays a pivotal role in seismic engineering. Just as a physician must understand human anatomy to diagnose ailments, a seismic engineer needs to grasp the interplay between a structure and the ground it's built upon. This intricate relationship, often termed soil-structure interaction (SSI), is paramount. When seismic waves traverse the Earth's layers, they don't merely dissipate upon reaching built structures. Instead, they transfer energy, leading to vibrations or, in extreme cases, severe structural damage. Owing to the Earth's layered composition, seismic events generate multiple types of seismic waves. Among the most crucial are P-waves (Primary waves) and S-waves (Secondary waves). P-waves, being compressional, can travel through both solids and liquids, making them faster and the first to be detected by seismographs. In contrast, S-waves, being shear waves, only traverse solids, rendering them slower but also more destructive due to their larger amplitudes. To assess the potential seismic impact on structures, engineers often turn to response spectrum analysis. This methodology doesn't directly consider actual earthquake time histories but instead focuses on the maximum responses of oscillators (or idealized structures) to those earthquakes. By understanding how different oscillators (representing various structural periods) respond to seismic waves, engineers can anticipate potential structural behaviors during real-life seismic events. In the modern era, with the aid of computational tools, Finite Element Methods (FEM) allow engineers to simulate complex scenarios of soil-structure interaction. These simulations take into account various soil properties, foundation depths, and structural attributes. Through iterative testing in a virtual environment, optimal designs that can withstand anticipated seismic activities in specific regions are achieved. However, while our tools and methodologies have advanced, the foundational principles remain rooted in understanding the dynamics of systems and the seismic waves generated by the Earth. Recognizing the unique characteristics of P-waves, S-waves, and even surface waves ensures that structures are not just built to stand tall but also to sway and oscillate in harmony with the Earth's rhythms, thus ensuring safety and longevity.'
Animation Source: NOA
In order to establish a solid foundation for understanding the terminology related to structural dynamics used throughout this document, it's essential to be acquainted with the foundational concepts. These help in grasping the vibrations of systems and, by understanding them, we can make predictions regarding their behavior. It's crucial to understand that while seismic phenomena fall within the realm of dynamics, the concept of "prediction" isn't directly applicable due to their non-harmonic and non-periodic nature. However, grasping the dynamic behavior of seismic events from a probabilistic perspective is indispensable in structural design. As previously mentioned, the response of structural systems to such external excitations can currently be represented both mathematically and computationally with reasonable accuracy.
Note: Additional concepts will be elaborated upon as needed or when context expansion is required throughout the document.
Note: Faults can manifest in different ways.
Animation Source: J.Ziony, ed. “Earthquakes in the Los Angeles Region.” USGS.
Animation Source: Seismological Facility for the Advancement of Geoscience
Animation Source: Seismological Facility for the Advancement of Geoscience
Animation Source: Seismological Facility for the Advancement of Geoscience
Animation Source: California Intitude of Technology
Seismic Accelerogram: A record that depicts the variation of ground acceleration with respect to time during an earthquake. It provides valuable data about the intensity and characteristics of seismic waves as they pass through a specific location.
Note: Seismic events propagate in the form of waves, and, like waves in any elastic medium, they undergo phenomena such as reflection, refraction, polarization, diffraction, dissipation and attenuation. Because these waves traverse the layers of the Earth and its discontinuities, they generate new waves that complicate the interpretation of seismic records. Due to this, seismic waves can be highly variable; however, they can be classified into families, which will be described below.
System: Is a set of components with specific properties that respond to external excitation by vibrating.
Discrete System: A system where the physical properties of its components are distinctly localized or concentrated at clearly identified points or positions. Contrary to continuous systems where properties are distributed over a spatial extent, discrete systems, often represented by a finite number of degrees of freedom, are typically described using algebraic equations or ordinary differential equations (ODEs).
Consider, for instance, a mass-spring system with a finite number of masses and springs, which serves as a classical example of a discrete system. In such systems, the dynamics of each component can typically be defined using a set of differential equations based on Newton’s second law.
Continuous System: A system wherein the physical properties are distributed throughout its extent, rather than concentrated at discrete points. Unlike discrete systems, continuous systems are described using field variables which vary over space, typically represented using partial differential equations (PDEs).
A foundational example of a continuous system is a stretched string or beam. The vibration of such a system is described by the wave equation:
$$ \frac{\partial^2 u(x,t)}{\partial t^2} = c^2 \frac{\partial^2 u(x,t)}{\partial x^2} $$Where:
Video Source: Jason Bramburger
External Excitation: External action that induces vibration in a system.
Impulsive Dynamic Excitation: An external action that varies with time and is completely independent of the system's motion.
Dynamic Impact Excitation: An external action that varies with time and depends on the motion of the system.
Response: Displacement, speed, or acceleration outcomes in a system's vibration, resulting from external excitation or free vibration.
Animation Source: Extreme Loading for Structures
Animation Source: FREEform
Animation Source: Flipping Physics
Dynamic Analysis: A study centered on understanding the forces and motions of systems over time, particularly those in free vibration or subjected to external excitation. (Structural Dynamics).
Deterministic Dynamic Analysis: A dynamic analysis that assumes complete knowledge of the external excitation in the time domain.
Probabilistic Dynamic Analysis: This refers to a method used in engineering, especially in the realm of structural engineering, to assess the response of a system under dynamic loads by considering the uncertainties inherent in the system properties, external loads, and initial conditions. Instead of analyzing a single deterministic scenario, probabilistic dynamic analysis evaluates multiple scenarios considering the probabilistic distribution of various input parameters.
Key points:
Stochastic Modeling: The inherent randomness of certain parameters (like material properties, loads, and boundary conditions) is represented using probabilistic distributions.
System Response: The analysis yields probabilistic descriptions of the system response instead of deterministic single values.
Risk Assessment: By understanding the probabilistic nature of the system's response, one can make more informed decisions regarding safety, reliability, and performance.
Animation Source: Extreme Loading for Structures
Vibration: Refers to the oscillatory motion of a system about an Static Equilibrium Position.
Free Vibration: The natural oscillation of a system in the absence of external forces.
Forced Vibration: Oscillation that occurs when an external force is applied to a system, driving it to vibrate at the frequency of the applied force, potentially leading to dynamic magnification if the forcing frequency is close to the system's natural frequency.
Vibration Cycle: One complete motion or oscillation of a vibrating system from its initial position, through its maximum displacement, and back to its initial position.
Periodic Motion: A motion that repeats itself in regular intervals of time, characterized by a definitive period or frequency.
Animation Source: Wikipedia
Vibration Period [T]: The time taken for a vibrating system to complete one full cycle of its motion, from a specific point back to the same point. It's essential to understand that for a vibration cycle, and consequently a vibration period, to exist, the system must be considered conservative, implying no energy is lost over time. is typically measured in Seconds (s)
Vibration Frequency [f]: The number of cycles of vibration that occur in one second. It is the reciprocal of the vibration period "$ f = \frac{1}{T} $" and is typically measured in Hertz (Hz).
Animation Source: Wikipedia
Simple Harmonic Motion (SHM): A type of periodic motion where an object moves back and forth about a central position due to a restoring force proportional to its displacement from the equilibrium. The trajectory of this motion follows a sinusoidal path, making it describable by sine and cosine functions.
Dynamic Degree of Freedom: Refers to the number of independent ways a dynamic system can move without violating any constraint imposed upon it. In essence, it determines the minimum number of independent coordinates required to describe the motion or configuration of the system at any given time.
Inertial Reference Frame: A frame of reference in which Newton's first law of motion (the law of inertia) holds true. In such a frame, an object not subject to external forces will remain at rest or move at a constant velocity. Non-inertial reference frames, on the other hand, are accelerating and therefore, experience fictitious forces.
Animation Source: Wikipedia
Stiffness: In structural engineering and mechanics, stiffness refers to the extent to which an object or material resists deformation in response to an applied force. It's quantified as the ratio of the force applied to the deformation produced (Hooke's law). In terms of structures, stiffness often determines how much a structure will deform or deflect under specific loads. Mathematically, for linear elastic materials, stiffness $ K $ is described by the equation:
$$ P = K \cdot \delta $$Where:
Animation Source: Wikipedia
Stiffness Coefficients: These are constants that quantify the resistance of structural elements to deformation when subjected to forces. They often represent the linear relationship between force and displacement for a specific degree of freedom in a structural system.
Stiffness Matrix: A square matrix used in structural element analysis that relates nodal displacements to nodal forces within a structure or a structural element. Each entry in the matrix represents the reaction force induced at a node for a unit displacement imposed at another node, while keeping all other nodes restrained. This matrix encapsulates the structural behavior of the element or the entire system under study. For a linear elastic system, the relationship between forces $ P $ and displacements $ \delta $ can be represented as:
$$ \lbrace P_{\scriptstyle \text{GDLg}} \rbrace = [K]_{\scriptstyle \text{GDLg}} \cdot \lbrace \delta \rbrace_{\scriptstyle \text{GDLg}} \rightarrow \lbrace \delta \rbrace_{\scriptstyle \text{GDLg}} = [K]_{\scriptstyle \text{GDLg}}^{-1} \cdot \lbrace P_{\scriptstyle \text{GDLg}} \rbrace $$
Where:
Animation Source: Author's own.
Damping: A phenomenon in which the energy of an oscillating system decreases over time, usually due to the conversion of mechanical energy into heat or other forms of energy. Damping tends to reduce the amplitude of oscillations and can bring an oscillating system to rest if there is enough of it.
Equivalent Viscous Damping ($ c $): A conceptual form of damping used to describe the energy dissipation characteristics of a system in terms equivalent to those of a viscous damper. It's often used in structural engineering and earthquake engineering to relate actual complex damping mechanisms to a simpler linear damping model, enabling the use of standard analysis techniques.
Damping Factor ($\xi$): A dimensionless quantity used to describe the amount of damping in a system relative to critical damping. It provides a measure of the energy dissipated in an oscillatory system. A system with $\xi$ = 0 is undamped, while $\xi$ = 1 represents a critically damped system. Values between 0 and 1 indicate underdamping, and values greater than 1 indicate overdamping.
Animation Source: Wikipedia
Animation Source: Author's own.
Weight: The gravitational force exerted on an object due to the mass of the object and the acceleration due to gravity. It is a vector quantity, meaning it has both magnitude and direction, and it always acts downward towards the center of the Earth (or any other massive body).
Elastic Force: A restoring force that acts to bring a system back to its equilibrium position. It is directly proportional to the displacement of the system from its equilibrium position, especially as described by Hooke's law in many materials.
Video Source: Veritasium
Newton's Laws of Motion: These fundamental principles, articulated by Sir Isaac Newton in his work "Philosophiæ Naturalis Principia Mathematica" in the 17th century, provide the foundation for classical mechanics, describing the relationship between the forces acting on a body and its motion. The laws are as follows:
First Law (Law of Inertia): A body will preserve its state of rest or of uniform motion in a straight line unless it is compelled to change that state by forces acting upon it. This is a manifestation of the inertial property of matter. It introduces the concept of inertia and serves as a statement of what happens in the absence of net external forces.
Second Law (Law of Acceleration): The net force acting on an object is directly proportional to the rate of change of its momentum. For objects with constant mass, this relationship simplifies to:
Where:
$ F $: represents the net external force acting on the object.
$ m $: is the system mass.
$ a $: is its acceleration. The direction of the acceleration is the same as the direction of the net force.
Note: It's essential to underscore that the equation previously mentioned embodies the essence of Newton's second law. This law is characterized by a second-order ordinary differential equation.
Animation Source: Wikipedia
$$ F_{external} - m \cdot a = 0 $$
Where:
$ F_{external} $ : is the external force acting on the system, "$ m $" is the mass of the system, and "$ a $" is its acceleration. The term "$ -m \cdot a $" is often referred to as the "D'Alembert force" or "inertial force".
Animation Source: Wikipedia
Differential Equation of Dynamic Equilibrium: The core principle behind this equation is the conservation of energy in dynamic systems, specifically addressing how energy is distributed among various forms: potential, kinetic, and dissipative due to damping. Rooted deeply in the laws of motion and energy conservation, it's the mathematical formulation that captures the dynamic behavior of systems subjected to time-varying external forces or initial conditions.
At any given instant of time, the sum of the inertial forces (proportional to acceleration), damping forces (proportional to velocity), and elastic (or restoring) forces (proportional to displacement) in the system must equal the externally applied forces. Mathematically, this relationship can be captured by the equation:
$$ m \ddot{x}(t) + c \dot{x}(t) + k x(t) = f(t) $$Where:
The equation encapsulates a balance where the sum of inertial, damping, and restoring forces within the system equals the external forces acting upon it. This balance, inherently a manifestation of Newton's second law in dynamic contexts, provides foundational understanding and predictive capability in various engineering, physical, and scientific applications.
Beyond the foundational definitions provided earlier, it's imperative to delve deeper into the mathematical framework underlying the behavior of structural systems in both free and forced vibrations systems. A foundational approach to comprehending this intricate behavior begins with the most elementary mathematical representation: The Simple Harmonic System. Is fundamentally anchored in an un-damped Single Degree of Freedom SDOF system, characterized by a consistent angular velocity $(\omega_n)$.
The mathematical derivation of this system is firmly rooted in two primary principles. First, the principle of energy conservation, which dictates that the total energy in an isolated system remains unchanged over time. And second, the foundational concept of constant velocity, which, in its simplest form, is expressed as the ratio of distance traveled to the time taken.
While many educational settings have likely introduced and dissected the mechanics of this topic, a comprehensive understanding requires a deeper dive into its intricate nuances. In the ensuing discussion, we will elucidate the pivotal equations borne from the study of simple harmonic motion. Furthermore, we will explore the applications of these equations, demonstrating how they can be adeptly used to predict a system's position, velocity, and acceleration when its initial conditions are known. It's paramount to emphasize that these mathematical formulations, although insightful, are based on the simplified analogy of a conservative discrete SDOF system. Consequently, while they offer significant insights, they also come with inherent constraints and limitations that one must be cognizant of.
Delving deeper into the realms of the Simple Harmonic System, it becomes evident that its mathematical elegance and simplicity have profound implications for the real-world understanding of dynamic systems. The SDOF model, albeit an idealization, paves the way for understanding more complex systems by isolating the essential physics of vibrations. The inherent beauty of the Simple Harmonic System lies in its cyclical nature, represented by sinusoidal functions. These functions not only describe the system's position over time but also elegantly encapsulate the fundamental attributes of periodic motion, including amplitude, frequency, and phase. The angular frequency $(\omega_n)$ is particularly noteworthy, as it signifies the natural frequency of the system — a unique attribute dependent solely on the system's stiffness and mass. This frequency underscores the system's propensity to oscillate at a characteristic rate in the absence of external influences, a concept that resonates deeply with the intrinsic rhythmic patterns observed in nature and engineered structures alike.
Building upon these principles, the mathematical representation of the system evolves into a second-order differential equation, typically known as the equation of motion. This equation, derived from Newton's second law, correlates the net force acting on the system with its acceleration, factoring in both the restoring force due to the system's stiffness and the inertial force due to its mass. Herein lies the crux of understanding dynamic behavior (the interplay between force and response, cause and effect, that governs oscillatory motion). However, the real world rarely adheres to the simplifications of an idealized SDOF system. Real systems exhibit damping, a phenomenon where energy is dissipated over time, typically in the form of heat, altering the pristine sinusoidal responses predicted by the simple harmonic model. Damping brings forth the concept of the damped natural frequency, a slightly altered version of the natural frequency, accounting for the energy dissipated with each cycle of motion. The consideration of damping is not merely an academic exercise; it is a critical component in the design and analysis of systems, especially when assessing their responses to dynamic loading, such as in seismic or wind engineering.
Furthermore, one must consider the influence of external excitations. These are forces that are not accounted for within the conservative system model but are crucial for understanding the behavior of structures under operational or environmental loads. In engineering practice, these excitations often manifest as harmonic, periodic, or even random forces or non periodic non armonic exitations, each with its own set of analytical challenges. In essence, while the Simple Harmonic, Undamped SDOF System provides a valuable foundation, it is the springboard from which we dive into the rich, intricate world of vibrations in real systems. From the exploration of these concepts emerges a more comprehensive, nuanced understanding of dynamic systems, illuminating both their predictable simplicity and captivating complexity. However, as we venture into these complexities, we must remain anchored in the fundamental principles, appreciating the insights they offer while navigating the vast ocean of nuances that define real-world dynamic behavior.
Note: You can find more information in the recommended bibliography. Additionally, further digital resources on the topic are available here.
In classroom settings, it's often encouraged to meticulously unpack the mathematical underpinnings of Simple Harmonic Motion (SHM). While we won't traverse the entire deductive journey here, we'll highlight key equations and insights. A core tenet to grasp is that for a conservative SDOF discrete system (as described in Section 1.2), the angular velocity or angular frecuency, denoted $\omega_n$, remains unchanging. This constancy implies that any shift in the circular trajectory of motion can be derived from its spatial rate of change over time.
A full cycle of this movement, termed "vibration", depicted in the associated figure, accounts for a $2\pi$ displacement. Given this, the time it demands to complete one full cycle becomes $\frac{2\pi}{\omega_n}$. In simpler terms, the system's vibrational period is expressed as $T = \frac{2\pi}{\omega_n}$. To further comprehend this, consider the foundational principles of trigonometry and geometry. When applied to the figure provided, they allow us to dissect the angular movement's projection onto its Cartesian counterparts. This application is pivotal both when assessing the system's outset position $x_0$, and when pinpointing its location at any subsequent time, represented as $x(t)$.
$$ \omega_n $$ $$ \theta = \omega_n t $$ $$ x_0 = R \cdot \cos(\phi) $$ $$ x(t) = R \cdot \cos(\omega_n t + \phi) $$ $$ \dot{x}(t) = -R \cdot \omega_n \cdot \sin(\omega_n t + \phi) $$ $$ \ddot{x}(t) = -R \cdot \omega_n^2 \cdot \cos(\omega_n t + \phi) $$ $$ T = \frac{2\pi}{\omega_n} $$ $$ f = \frac{1}{T} = \frac{\omega_n}{2\pi} $$ $$ \omega_n = \frac{2\pi}{T} $$ $$ R = \sqrt{x^2 + \frac{\dot{x_0}^2}{\omega_n^2}} $$ $$ \phi = \arctan\left(-\frac{\dot{x_0}}{\omega_n x_0}\right) $$ $$ x(t) = R \cdot \cos(\omega_n t + \phi) \ \ \boldsymbol{\color{blue}{\xRightarrow{\hspace*{0.7cm}{}}}} \ \ \boxed{x(t) = x_0 \cos(\omega_n t) + \frac{\dot{x_0}}{\omega_n} \sin(\omega_n t)} $$
Where:
$ \omega_n $: Angular Velocity or Angular Frequency
$ \theta $: Angular displacement
$ x_0 $: Initial position
$ x(t) $: Position as a function of time
$ \dot{x}(t) $: First derivative of position with respect to time (velocity)
$ \ddot{x}(t) $: Second derivative of position with respect to time (acceleration)
$ T $: Period
$ f $: Frequency
$ R $: Amplitude
$ \phi $: Phase angle
In this first example, each line of code is meticulously dissected, with detailed explanations clarifying its purpose and mechanics. This thorough breakdown is unique to the first example; subsequent code snippets throughout this book won't receive the same line-by-line dissection. Instead, they will be accompanied by succinct commentaries summarizing the overarching functionality of significant code segments. This streamlined approach is informed by the nature of coding itself, which often involves the strategic deployment of straightforward logical constructs like for
, while
, and if
.
For the reader, the primary objective extends beyond mere code comprehension. It's about nurturing a methodical and logical problem-solving mindset, anchored in the mathematical concepts that the code is designed to operationalize. To this end, every snippet of code within these pages comes with clarifying comments. It's worth noting that some lines, especially those utilizing plot
for visualizing data, might appear repetitively across different contexts.
The codes featured in this book are intentionally simplified and functional, tailored to demystify specific structural engineering challenges in a pedagogical manner. However, it's pertinent to recognize that these streamlined solutions represent a starting point; they can be refined and executed more efficiently with advanced coding techniques. To foster this progression, we extend an invitation to the reader to explore a curated collection of intermediate and advanced codes, addressing analogous or identical challenges, housed in our GitHub repository. We urge you to engage with these codes critically—analyze, comprehend, implement, and, most crucially, innovate upon them, crafting bespoke, high-performance solutions.
Solution 1: $$ x(t) = R \cdot \cos(\omega_n t + \phi) $$
Solution 2: $$ x(t) = x_0 \cos(\omega_n t) + \frac{\dot{x_0}}{\omega_n} \sin(\omega_n t)$$
Given the problem's parameters, it's logical to deduce that if the initial phase conditions, meaning the phase angle "$\phi$", is set to 0, this implies an orthogonal projection of $x_0$ = 1, where 1 represents the maximum amplitude of the motion. Understanding that this is the peak amplitude of movement. We can deduce, based on the concept of the rate of change in space over time (velocity), that the slope at this maximal displacement point is 0. In other words, the rate of change of position over time, or the velocity $\dot{x}(t)$, is equal to 0 at this point.
After pinpointing the solution equations and logically determining the necessary input data, we proceed to employ straightforward code to assign the corresponding values to the both equations, within the time range and interval specified by the problem. It's imperative, firstly, to ensure that the necessary libraries are installed in the VSCode development environment. Here's a brief overview of the essential libraries and their roles in the coding process:
Numpy
: This is a fundamental library for numerical computation in Python, offering optimized data structures for large matrices and vectors, along with high-level mathematical functions.
Pandas
: This library is crucial for manipulating and analyzing structured data, simplifying the management of data tables and time series with its DataFrame and Series data structures.
Matplotlib
: A key library for creating static, animated, and interactive visualizations, it's essential for graphically representing data, allowing for the visual interpretation of results and trends from the analyses conducted.
To install these libraries, one approach is to open the "terminal" in VSCode and utilize the pip
command. Below is a recommended set of commands to install the libraries required for solving the current problem.
It's advisable to execute the following lines in the "terminal":
pip install numpy
pip install Pandas
pip install Matplotlib
For more detailed information, readers are encouraged to visit the following link: Beginner's Guide to Python.
Below, we outline the procedural steps for solving the proposed exercise, leveraging both the mathematical methodology discussed in class and the additional insights from this book, all while utilizing Python as the computational tool.
numpy
as np
, pandas
as pd
, and matplotlib.pyplot
as plt
.import numpy as np # Importing "numpy" Library
import pandas as pd # Importing "pandas" Library
import matplotlib.pyplot as plt # Importing "matplotlib" Library
%matplotlib widget
wn = 2 # Angular Velocity or Angular Frequency
phi = 0 # Phase angle
R = 1 # Amplitud
xo = 1 # Initial position (orthogonal projection)
xvo = 0 # First derivative of position with respect to time (velocity) (orthogonal projection)
to = 0 # Inital time
tf = 10 # Final time
dt = 0.05 # Step time
to
(start time) to tf
(end time) in increments of dt
(time step), the for
loop is an ideal choice. This loop structure allows for the execution of a set of instructions repeatedly, covering the desired range of time values.For setting up the loop, it's essential to clearly define the sequence's start point, end point, and the interval (step) between the points. The arange
function from the numpy
library comes in handy for this purpose. It's adept at generating sequences of numbers with the specified start, end, and step values. In other words, using arange
, you can efficiently set up your time range for the loop as follows:
for i in np.arange(to, ((tf-to)/dt) + 1, dt):
The code line described sets up a loop that operates ((tf-to)/dt) + 1 = 201 times, capturing a sequential value for the variable i
with each iteration. As i
progresses from to
to tf
in increments of dt
, it acts as a decimal value, effectively tracking the time at each step of the computation. For instance, i
starts at 0
in the first computation cycle, advances to 0.05
in the second, then to 0.10
in the third, continuing this pattern of incrementing by dt
in subsequent cycles.
However, to efficiently store the result of each solution for every computational cycle, Python's append
function is utilized. This function appends the outcome of each loop cycle to a list. It's crucial, though, to first establish a list-type variable before commencing the loop. This list can start off empty or with predefined initial values. For the code being discussed, the variables are set up as follows:
time = [] # Variable where each value of the time step in the calculation will be stored
x1 = [] # Variable where each value of the response displacement will be stored. [solution 1]
x2 = [] # Variable where each value of the response displacement will be stored. [solution 2]
In this code, the equations we'll use are time-dependent, meaning they adjust based on the time at each computation cycle. Therefore, you can incorporate the variable i
directly into the relevant equations or alternatively use a variable named time
. Since i
represents the time elapsed at each computation cycle, it's practical to store this value in a variable named time
for clarity and ease of understanding. The assignment would look like this:
time.append(i)
To enhance the instructional clarity for the code, we'll use the variable time
. As time
is a list holding the time values for each computation cycle, it's essential to introduce an integer variable that can access each specific value within the list. It's crucial to remember that Python indexing starts at zero. Bearing this in mind, we define the following variable:
j = 0 # Managing an Integer Counter for a List or Data Array.
By adopting this approach, we'll be able to accurately compute and store the amplitude value for the corresponding computation cycle.
x1.append(R*np.cos(wn*time[j]+phi)) # Calculating the amplitude based on the equation from Solution 1.
x2.append(xo*np.cos(wn*time[j]) + xvo/wn*np.sin(wn*time[j])) # Calculating the amplitude based on the equation from Solution 2.
Each time the loop initiates a new cycle, it's necessary to increment the counter variable j
by one. This increment allows us to retrieve the specific time value from the time
variable that corresponds to the current computation cycle. To achieve this increment efficiently, we can use a straightforward line of code that adds 1 to the current value of j
, thereby ensuring accurate synchronization with the time
variable for each cycle:
j = j+1 # Incrementing the Counter by One Unit.
Building upon the previously outlined steps and principles, we now present the specific code designed to address and solve the problem in question:
time = [] # Variable where each value of the time step in the calculation will be stored
x1 = [] # Variable where each value of the response displacement will be stored. [solution 1]
x2 = [] # Variable where each value of the response displacement will be stored. [solution 2]
j = 0
for i in np.arange(to, tf+dt, dt): # uso de bucle "for"
time.append(i) # almacenamiento de cada dato de tiempo por ciclo
x1.append(R*np.cos(wn*time[j]+phi)) # almacenamiento de cada dato de calculo de respuesta con base en la solución 1
x2.append(xo*np.cos(wn*time[j]) + xvo/wn*np.sin(wn*time[j])) # almacenamiento de cada dato de calculo de respuesta con base en la solución 2
j = j+1
pandas
library and its pd.DataFrame
functionality. This conversion not only organizes the data neatly but also requires specifying column names through columns =
, adding a clear, descriptive header to the new DataFrame.In addition, to maintain a clear and organized structure, new variables like time_vs_x1
, time_vs_x2
, and Results
have been introduced. Merging these variables into a cohesive data set is smoothly accomplished with pandas
's pd.concat
function. This function joins two or more DataFrames along a specified axis, which, for horizontal concatenation, requires setting axis = 1
. It's also crucial to specify ignore_index=False
to preserve the original indexing of each DataFrame.
While the print()
function can serve to display results, utilizing the organized structure of a DataFrame offers a more refined approach. The head()
function, for instance, conveniently displays the first five rows of the DataFrame. However, this can be further tailored. By integrating the len()
function, you can dynamically control the amount of data displayed, making the output both comprehensive and relevant to your specific analysis needs.
time = pd.DataFrame(time, columns= ['Time [s]']) # Converting the Variable to a DataFrame
x1 = pd.DataFrame(x1, columns = ['x1 [amplitude]']) # Converting the Variable to a DataFramee
x2 = pd.DataFrame(x2, columns = ['x2 [amplitude]']) # Converting the Variable to a DataFrame
time_vs_x1 = pd.concat([time, x1], axis=1, ignore_index=False) # Concatenating DataFrames
time_vs_x2 = pd.concat([time, x2], axis=1, ignore_index=False) # Concatenating DataFrames
Results = pd.concat([time_vs_x1, time_vs_x2], axis=1, ignore_index=False) # Concatenating DataFrames
Results.head(len(Results)) # Displaying Results
Time [s] | x1 [amplitude] | Time [s] | x2 [amplitude] | |
---|---|---|---|---|
0 | 0.00 | 1.000000 | 0.00 | 1.000000 |
1 | 0.05 | 0.995004 | 0.05 | 0.995004 |
2 | 0.10 | 0.980067 | 0.10 | 0.980067 |
3 | 0.15 | 0.955336 | 0.15 | 0.955336 |
4 | 0.20 | 0.921061 | 0.20 | 0.921061 |
... | ... | ... | ... | ... |
196 | 9.80 | 0.731386 | 9.80 | 0.731386 |
197 | 9.85 | 0.659649 | 9.85 | 0.659649 |
198 | 9.90 | 0.581322 | 9.90 | 0.581322 |
199 | 9.95 | 0.497186 | 9.95 | 0.497186 |
200 | 10.00 | 0.408082 | 10.00 | 0.408082 |
201 rows × 4 columns
matplotlib.pyplot
library. Initially, it's necessary to define variables for both the figure and the axes. While these variable names can vary based on user preference, it's common to name them fig
and ax
, respectively.Creating a plot involves using the axes variable with the plot
function, which offers a variety of plotting options. For a deeper understanding of these options, it's recommended to consult the official documentation, available here. However, to facilitate immediate use, the code provided below includes comments explaining the functionality of each line.
fig, ax = plt.subplots(figsize=(16/1.5, 9/1.5)) # Creating a Figure and Axes of a Specific Size
ax.plot(time.iloc[:,:], x1.iloc[:,:], marker='+', color=(0, 0, 1), markersize=0, # Plotting the First Dataset on the Axes: Solution 1
markerfacecolor='w', markeredgewidth=0, linewidth=0.5, alpha=1, label='Solution 1')
ax.plot(time.iloc[:,:], x2.iloc[:,:], linestyle='--', dashes=[5, 5], linewidth=2, marker='+', color=(1, 0, 0), # Plotting the Second Dataset with a Different Line Style: Solution 2
markerfacecolor='w', markeredgewidth=0, alpha=1, label='Solution 2')
ax.set_title('Displacement Response', fontsize=10, color=(0, 0, 1)) # Setting the Graph Title, Font Size, and Color
ax.set_xlabel('Time [s]', fontsize=10, color=(0, 0, 0)) # Setting the X-Axis Label, Font Size, and Color
ax.set_ylabel('Amplitude', fontsize=10, color=(0, 0, 0), rotation=90) # Setting the Y-Axis Label, Font Size, Color, and Rotation
ax.grid(which='both', axis='x', alpha=0.5) # Adding a Grid to the Graph on the X-Axis with Transparency
ax.set_xlim(0, time['Time [s]'].max()) # Setting the X-Axis Limit from 0 to the Maximum Value of 'Time [s]'
legend = ax.legend(fontsize=10) # Displaying the Legend with a Specific Font Size
legend.get_frame().set_edgecolor('none') # Setting the Legend's Box Border Color to 'None'
In the GitHub repository (fun_SHM_animation), the open-source code for a simple function is presented, which calculates the time-domain response of a conservative discrete system SDOF. It also generates the animation of the response in the SHM context and its Cartesian projection on a two-dimensional graph, utilizing the previously described mathematics and code developed in Python.
import numpy as np
from IPython.display import HTML
from IPython.display import display
# Parámetros
from fun_SHM_animation import SHM_animation
R = 0.5
phi = 0
wn = 1.0 * np.pi
T = (2*np.pi)/wn
# Function
ani = SHM_animation(R, phi, wn, T)
display(HTML(ani.to_jshtml()))