ODE Solver - A Flask Website and Project Reflection

After working on a project all quarter long, it’s time to reflect on the progress that’s been made and what has been learned.

What Was Achieved

In this project, I was able to create a webapp using Python and Flask. On the webapp, I implemented two main pages that graphically solve a large class of ordinary differential equations. On the first page, the solver takes in any differential equation of the form d^ny/dt^n = f(t,y,y’,y’‘,…,y^{n-1}) with n initial conditions y(0), y’(0), … y^{n-1}(0). All inputs can handle typical math words like “sin” and “pi”, converting the user’s inputted text to something Python can mathematically understand. After submitting a form, a Plotly Express graph will display the solution.

The second main page of the webapp allows for a similar input, but only ODEs of the form dy/dt = f(t,y). However, the user can also select from multiple different numerical methods to see how each method compares to the actual solution as well as to compare how well they perform against other methods. All of this was achieved by using Flask for Python, as well as scipy.integrate to solve the differential equations. I was also able to learn more of plotly and plotly express and found ways to further manipulate plots to have them displayed exactly as I desire.

One of the things I was proud to accomplish was making the math work exactly as I had imagined. I thought that it would be very difficult to create a function that can solve such a large class of problems. It took a while to figure out how to use scipy.integrate the way I intended. After managing to learn how to solve a first order ODE with odeint(), it took a lot of time to figure out how to accurately implement higher order differential equations. However, I was able to accomplish this and create a function that can solve an ODE of any order. Another huge obstacle I feared was turning user input into something Python can correctly handle. Of course, taking basic numbers isn’t too difficult, but converting derivatives and trigonometric functions, for example, were the problem. Validating the inputted data also took a while to get down as it was difficult to check whether an input, which was interpreted as a string, was a valid number. Managing to implement this was by far one of the most difficult tasks, and I am more than proud to have done it well.

Future Prospects

One thing that can definitely be worked on in the future for this project is to implement a better user interface. Due to a lack of web designing skills, the webapp turned out to be slightly plain-looking and not the most attractive. Another issue I would work on is changing the method in which the plotly express graphs are displayed. For some unknown reason, submitting a form with valid inputs wouldn’t produce a graph sometimes. After lots of experimenting, I was never able to pin point the reason for the strange error. Because of this, it would be best to use a different method instead of JSON encoding that can reliably produce a graph every single time a user submits the form.

Compared to everything that was stated in the project proposal, the final outcome came pretty close to achieving all that was expected to be done. All methods and pages were implemented as I had hoped. However, I didn’t design the webapp as well as I had planned, and the method of outputting the graph didn’t meet my full expectations; the fact that it sometimes wouldn’t produce a plot despite everything working pefectly, with this behavior occurring what seemed to be randomly, was not as I had planned in the beginning.

One of the biggest things I learned from doing this project was learning how to work with scipy. Though there are many different functionalities of scipy, I was able to learn one strong function that can solve ordinary differential equations. I was also able to learn a bit more about plotly and plotly express as well as fine-tuning graphs to look the way I like. A second thing I learned was how to create webpages using HTML and CSS. I had very minimal background working with web development, so it took a long time to adjust to the syntax and rules of each language. I was also able to learn how to use Jinja more efficiently to do exactly what I want. Lastly, I learned how to better use GitHub. Even after using it for blog posts, I was still unsure of how to properly use it in its full capacity. However, working with this project and making it so that it’s accessible to anyone who views the repository has taught me exactly what the different methods are used for, ie what the difference is between cloning and forking as well as simply downloading all the files.

Future Endeavours

As I plan on going into software engineering after graduating, this class and project has prepared me on how to work with GitHub and utilize version control tools. This is an important part for every project, especially larger ones, as it allows for the maintanence of older versions of projects in case the current program goes south. This project has also taught me just how much work must go into every project. Even for something as basic as this webapp, it took lots of time and energy to create it. This has thus given me a decent idea of how huge projects that companies work on must function and the typical workflow for them.

Written on December 9, 2021