AER E 1600 - Lecture 6 Study Notes

Iowa State University Aerospace Engineering AER E 1600 - Lecture 6

Overview of the Lecture

  • Introduction to Programming with Python focusing on Numerical Integration of Ordinary Differential Equations (ODE) using Euler's Method.
  • Instructor: Carolyn Riedel

Key Topics Covered

  • Vector Math with Numpy and Lists
  • Graphing using Matplotlib
  • Installation of the units toolbox Pint
  • Understanding numerical integration
  • Importance of numerical integration in programming
  • Overview of numerical integration of ODE by Euler’s Method

Vectors: Fundamental Concepts

Definition of Vectors

  • Vectors are mathematical symbols used for quantities that possess both magnitude and direction.
  • Example: A force has both a magnitude (how much force) and a direction (in which direction it is applied).
  • In structural design, it's crucial to consider both magnitude and direction to ensure adequate support and stability.

Scalars vs. Vectors

  • Scalar quantities only have magnitude (e.g., temperature, mass).
  • Importance of Vectors:
    • Understanding vectors is essential in fields like physics and engineering where direction plays a crucial role in analysis and design.

Notation for Vectors

Different Representations

  • A vector F can be denoted in various ways including:
    • F
    • 𝐹
    • 𝐹
    • 𝐹⃑
  • The notation can vary depending on the field being discussed.

Magnitude and Components of Vectors

Magnitude Calculation

  • The magnitude of the vector F can be calculated using the formula:
    F=extsqrt(F<em>x2+F</em>y2+Fz2)F = ext{sqrt}(F<em>x^2 + F</em>y^2 + F_z^2)
  • Alternatively, if the magnitude and angle at which the force is applied are known, the components can be derived:
    • Fx=Fimesextcos(heta)F_x = F imes ext{cos}( heta)
    • Fy=Fimesextsin(heta)F_y = F imes ext{sin}( heta)

Practical Applications in Class

Hands-On Exercises

  1. Calculate the vector between the points (3,5,7) and (2,6,3).
  2. To find the magnitude of this vector, use:
    extmagnitudeofvector(a,b,c)=extsqrt(a2+b2+c2)ext{magnitude of vector}(a,b,c) = ext{sqrt}(a^2 + b^2 + c^2)
  3. Find the direction of this vector (i.e., unit vector).

Using Numpy for Vector Calculations

Linspace Function

  • Function:
    • np.linspace(start, stop, num_points) - generates evenly spaced values between the start and stop.
  • Exercise: Create an array from -1 to 3 with 1000 points and check the length of the generated array.

Arange Function

  • Function:
    • np.arange(start, stop, step) - generates values starting at a point, stopping before another, with a specified step.
  • Exercise: Create an array from 0 to 4 with a step size of 0.01, and determine the length of the array.

Plotting with Matplotlib

Introduction to Matplotlib

  • Library Use: Matplotlib is a library for creating static, animated, and interactive visualizations in Python.
  • Pyplot:
    • The pyplot module is used for plotting commands.

Basic Plotting Commands

Standard Plot Structure
  • Import libraries:
  from matplotlib import pyplot as plt
  import numpy as np
  • Create an array and corresponding y-values to plot, for example:
  x = np.arange(0, 50.5, 0.5)
  y = 5 * x + 10
  plt.plot(x, y)
  plt.title("PyPlot Example X vs Y")
  plt.xlabel('X')
  plt.ylabel('Y')
Review of Plotting Commands
  • Steps to Plot:
    • Start the code with importing libraries.
    • Plot the data using plt.plot(x, y).
    • Add a title with plt.title().
    • Label the axes with plt.xlabel() and plt.ylabel().

Projectile Motion and Plotting

  • Projectile Path Equation:
    • The path of a projectile is determined by:
      x=V<em>0imesextcos(heta)imestx = V<em>0 imes ext{cos}( heta) imes ty=V</em>0imesextsin(heta)imest12gt2y = V</em>0 imes ext{sin}( heta) imes t - \frac{1}{2}gt^2
  • Variables defined:
    • V0V_0 - initial velocity
    • hetaheta - launch angle
    • gg - acceleration due to gravity (9.8 m/s²)
    • tt - time
  • Exercise: Graph the trajectory of a cannonball shot at a 30° angle with an initial velocity of 125 m/s, over 10 seconds.

Installing and Using Pint for Unit Conversion

Introduction to Pint

  • Pint: A Python package for unit conversion.
  • Installation Steps:
    1. Open Anaconda Prompt.
    2. Type conda install -c conda-forge pint.
    3. Confirm installation by typing 'y'.

Unit Registry in Pint

  • Pull out the unit registry and assign it to ur.
  • You can add units and convert them easily.
  • Example of unit conversion:
    • To extract the number without the units, use the .magnitude method.

In-Class Unit Conversion Exercise

  1. Determine the force of an object with a mass of 40 lbs under acceleration due to gravity, which is 32.2 ft/s².
    1. Print the results in both pounds and Newtons.

Additional In-Class Exercise

  1. Find the force of an object with a mass of 1.24 slugs under the same gravitational conditions.
    1. Print the results as previously.

Understanding Numerical Methods

Definition and Applications

  • Numerical methods provide approximations for complex mathematical procedures, facilitating calculations in cases where closed-form solutions are unattainable.
  • Applied in programming environments to solve ordinary differential equations (ODEs).

Calculating Savings Over Time

  • The change in money over time in a savings account can be modeled by the differential equation: dMdt=rimesM+s\frac{dM}{dt} = r imes M + s where:
    • $M$ = dollar amount in the account (in units of dollars)
    • $r$ = interest rate (in units of per year)
    • $s$ = savings rate (in units of dollars per year)

Euler's Method

Overview

  • Definition: A numerical procedure for approximating the solutions to ODEs by breaking them down into small, finite intervals.
  • In the equation representation, use extd\boldsymbol{ ext{d}} symbolically replaced with extδ\boldsymbol{ ext{δ}} to indicate usage in the finite space.
  • Modified equation:
    δM=(rimesM+s)imesδt\boldsymbol{δM} = (r imes M + s) imes \boldsymbol{δt}

Example Calculation Using Euler's Method

Given Values
  • Interest rate (r) = 0.02
  • Initial savings amount ($) = $10,000
  • Savings rate (s) = $5000/year
  • Time step (δt=0.1\boldsymbol{δt} = 0.1)
Stepwise Calculation
t$ (M)$Calculation
010000($0.02 imes 10000 + 5000) imes 0 = 0
0.110520($0.02 imes 10000 + 5000) imes 0.1 = 520
0.211041.04
0.311563.12

Coding Euler's Method

Steps to Implement
  1. Initialize starting values.
  2. Create an array for time (start at 0, to 1, step size = 0.01).
  3. Create an empty array to store generated values.
  4. Loop through calculations to determine δM\boldsymbol{δM}.
  5. Store results and plot against time.

Thrust Specific Fuel Consumption (TSFC)

Definition and Importance

  • TSFC measures the rate of fuel consumption relative to thrust and is crucial for evaluating rocket performance.
  • Unit: extlb/extlbfimesextsext{lb} / ext{lbf} imes ext{s}

Change in Rocket Mass Over Time

Fundamental Equation
  • The rate of change in the rocket mass can be expressed as: dmdt=extTSFCimesT\frac{dm}{dt} = - ext{TSFC} imes T where:
    • extTSFCext{TSFC} = Thrust Specific Fuel Consumption
    • TT = Thrust of the rocket (N or lbf)
Euler’s Method Application
  • This can be expressed as: (oldsymbol{δm} = (− ext{TSFC} imes T) imes oldsymbol{δt}

Example Calculation - Fuel Burnout

Initial Input Variables
  • Thrust = 175,700N
  • Mass of Propellant = 133,971 kg
  • Mass of Structure = 6,676 kg
  • Mass of Payload = 1,900 kg
  • TSFC = 0.0003 lb/lbf/s
  • Time step = 0.001 s$$
Steps to Calculate Time Until Fuel Runs Out
  • Use Euler's Method to iterate through time steps until the fuel is exhausted.

References

  • Resource links include documentation of Euler's Method and additional Python learning resources such as LinkedIn Learning, w3schools.com, and PyNative.