HW4: Chaos

Due Monday 3/20/2023

Overview

Informally, chaos is a natural phenomenon defined as a "sensitivity to initial conditions"; that is, if we change one little thing in our environment, we can get radically different dynamics over time. Colloquially, this is known as the butterfly effect, and it's the reason, for instance, that we have a difficult time predicting the weather.

In this assignment, you will numerically explore two manifestations of chaos using python: a planet orbiting a binary star system, and a simple predator/prey model known as the "logistic map."

Learning Goals

  • Explore numerical stability issues in simulations
  • Manipulate data files for python
  • Implement loops
  • Manipulate arrays in loops

What To Submit

When you're finished, submit the following to canvas:

  • The file BinaryStar.svg and the three screenshots for part 1
  • A .py file containing the method get_logistic for part 2, as well as the parameter combinations for x0 and r that you chose to find the different dynamics.

Part 1: Binary Star System (10 Points)

In this part, you're going to do a series of experiments using your code from the last assignment to create a binary star system with one planet. Setup the following system in a file called BinaryStar.csv:

  • One star at position (-1011meters, 0 meters, 0 meters) with an initial velocity of (0 meters/sec, 0 meters/sec, 10,000 meters/sec) and a mass of 1030 kilograms
  • A second star at position (1011meters, 0 meters, 0 meters) with an initial velocity of (0 meters/sec, 0 meters/sec, -10,000 meters/sec) and a mass of 1030 kilograms. This star is roughly as far away from the other star as the distance from the sun to mars.
  • A planet directly in between them at position (0 meters, 0 meters, 0 meters) moving perpendicularly to the stars' rotational plane at an initial velocity of (0 meters/sec, 20,000 meters/sec, 0 meters/sec), with a mass of 6 x 1024 kilograms.

Task 1: Run this simulation for 1000 days and take a screenshot of the orbits.

Task 2: Next, keep everything the same, except change the x component of the planet's initial velocity from 0 to 0.01 meters/sec. This is an incredibly minute change in the initial velocity which translates to about 0.02 miles/hour change. Take a screenshot of the orbits.

Task 3: Finally, keep everything the same, except change the x component of the planet's initial velocity from 0 to 1 meter/sec. This is still an incredibly minute change compared to the overall velocity. Take a screenshot of the orbits.

Reflection question: What's disconcerting/strange about what you see? What is a "year" on this planet?


Part 2: Logistic Map (10 Points)

There is a simple "discrete nonlinear differential equation" model for predator/prey dynamics that evolves the population of the prey based on its current size. The equation, known as the logistic map, is defined as follows

\[ x_{n+1} = r x_n (1-x_n) \]

Where xn is a number between 0 and 1 representing the predator population; 0 means none of the predator, and 1 means the maximum amount of the predator that its environment can accommodate. Intuitively, if the population is high, they will reproduce a lot more (the xn term), but there will also be less food distributed to each animal, so they will start to starve (the 1-xn term). Finally, r is some constant between 0 and 4.

Your Task

Create a method get_logistic(x0, r, N) That generates and returns an array with N samples of the logistic function with constant r, starting with a value of x0.

Once that's finished, find a set of parameters for x0 and for r that lead to the following dynamics:

  • A decaying oscillation
  • A non-decaying oscillation
  • Noise / chaos