Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download

Scientific Computing Midterm

Views: 873
1
Sean Paradiso
2
CS 510
3
Midterm
4
5
6
Introduction
7
-------------
8
9
The python class Attractor has multiple methods to perform a variety of operations. Some of which include the utilization of Euler and Runge-Kutta to increment through a set of given differential equations, plotting of the results from the given set of differential equations, test cases, and more. A few of the useful built-in tools at use here were numpy, pandas, and matplotlib.
10
11
Requirements
12
-------------
13
14
This project required the following:
15
- Attractor class
16
- euler method
17
- rk2 method
18
-rk4 method
19
- evolve method
20
- save method
21
- plotx, ploty, and plotz methods
22
- plotxy, plotyz, and plotzx methods
23
- plot3d method
24
- test_attractor module
25
26
Detailed Descriptions
27
----------------------
28
29
The Attractor class takes three initialization parameters and stores them as a numpy array. It also takes an additional three initialization parameters used to compute a time increment to be used later.
30
31
The euler method takes a numpy array and returns the Euler increment for the set of three given differential equations.
32
33
rk2 proceeds very similarly to the euler method, however, returns the second order Runge-Kutta increment.
34
35
rk4 is the same as rk2 with the exception of returning the fourth order Runge-Kutta increment.
36
37
The method evolve takes a numpy array and an integer order to generate a pandas DataFrame.
38
39
A very straight forward method, save simply saves the self.solution variable to a CSV file on disk.
40
41
As to be expected from the names, plotx , ploty, and plotz take advantage of the matplotlib to generate two dimensional plots of the x(t), y(t), and z(t) curves vs. time accordingly.
42
43
The methods plotxy, plotyz, and plotzx plot the logical pairs of the solution curves in two dimension.
44
45
Taking it a step further, the plot3d method generates a three dimensional plot of the x-y-z solution curves
46
47
Our module test_attractor is where the tests are stored to experiment with the class and methods to ensure functionality.
48
49
Finally, the ExploreAttractor notebook loads the entire module and uses it to answer the following:
50
51
1. How does the plotted solution depend on your choice of time step size, and your choice of increment? Do you see an improvement in precision from using the higher-order integration methods?
52
2. How does the solution depend upon the initial conditions [x0, y0, z0]? How small a change can you make while still reproducing roughly the same dynamical curves?
53