Signed in as:
filler@godaddy.com
Signed in as:
filler@godaddy.com
As mentioned before, here is my brainchild. It is a package with functions I have found helpful when using Python, including array plotting, derivatives, and integration functions. I will try and consistently update this if I am adding new functions. I'm not sure if this makes an enormous difference, but I enjoy using the Spyder interface (from Anaconda), and can confirm that all the plotting is beautiful with my functions.
Below every function name, I have put a brief description that will hopefully make all very easy to use. :)
Code: https://github.com/jessica55wu/Spyder-Projects/blob/master/Jessica%20Math%20Package
Did I say last three-body code? Oops. I couldn't help but share another interesting version. :)
This is the circular restricted three body problem. The original problem is composed of 18 differential equations (3 planets, 3 position vectors, 3 velocity vectors). But by assuming that one of the bodies is so small that its mass is negligible and that it is in the plane of the orbits of the larger two bodies, we can largely simplify the system and convert it to 12 differential equations (3 planets, 2 position vectors, 2 velocity vectors).
In the code above, the red and blue lines map the trajectories of the two larger bodies, while the green line maps the trajectory of the smaller body. The image on the left is a standard view (imagine you are viewing the plane from above), while the image on the right is center-of-mass view, which makes the orbits of the two larger bodies very obvious.
In this version, there is no rotating view yet, but that will be the next project. By transforming to a rotating reference frame, we can remove the time dependence from the motion equations.
Code: https://github.com/jessica55wu/Spyder-Projects/blob/master/CR%20Three%20Body%20Problem%20V1
Here is a collection of interesting plots.
Apparently Lorenz plotted consecutive peaks in the z variable (in the Lorenz system) against each other and it resulted in these odd-looking spikes. These are the spikes along with diagonal lines for different parameters of roe.
There are problems with point density at the peaks, and I had to integrate with 0.001 temporal step size for 250000 steps to have the plots looking the way they currently do.
Code: https://github.com/jessica55wu/Spyder-Projects/blob/master/Lorenz%20Spikes
The final three-body project: an integrating function of my own! :)
Here I'm using an adaptive step size with the second order method, which will calculate error and increase/decrease the timestep accordingly to get a path that is both accurate and faster than simply using tiny timesteps.
I learned to format my code a little bit better so that it is more readable, and I also learned to vectorize all my functions so that they can be applied to any system. In fact, I used the same functions on the Lorenz System on the right as I did on the Three Body System on the left.
Stay tuned! I'm currently working on a package with all these useful functions that I'll publish on Github. The functions will be helpful for math modeling and experimentation in the fields of chaos theory and dynamics.
Code: https://github.com/jessica55wu/Spyder-Projects/blob/master/odeint_wu
Another three body system comparison with different initial conditions! This time, we're comparing the first order Euler method with a second order method in which we take a step using the average of derivatives between consecutive points. Again, the brighter colors point out the more accurate trajectory, and this time, there is an enormous difference in paths for each body.
It is also possible to compare the second order integrating with the odeint function, in which the latter is far more accurate. One can do this by combining parts of this code link and the code link from the project below.
For the next few projects, we explore differential equation solvers of our own, including the Euler Method as in this diagram. We have the three-body diagram, a classic chaotic example, integrated with timestep sizes of 4*10^-5 and 1*10^-5. The darker-colored trajectories correspond to larger timestep size, while the brighter-colored trajectories correspond to the smaller timestep size. As the Euler Method is only a first-order integration, for it to be very accurate, we must decrease the timestep size drastically.
The circles on the trajectories are the ending points.
Code: https://github.com/jessica55wu/Spyder-Projects/blob/master/Three%20Body%20Euler%20Comparison
Something else that might be interesting is this diagram as an animation. Since I was having trouble with the standard animating package and functions, I wrote my own, and it works decently well. Here is a link to this code: https://github.com/jessica55wu/Spyder-Projects/blob/master/Three%20Body%20Animation
Copyright © 2023 Jessica Wu - All Rights Reserved.