Skip to content

A browser-based tool to explore and plot phase portraits for autonomous systems of ODEs. Includes built-in examples, vector fields, and export functionality.

License

Notifications You must be signed in to change notification settings

colingalbraith/differential-equation-visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Phase Portrait Plotter

A web-based tool for visualizing phase portraits of two-dimensional autonomous systems of differential equations. This application allows users to input custom differential equations and explore their phase portraits through interactive 2D and 3D visualizations. alt text alt text

Features

  • Interactive Visualizations: Supports 2D phase portraits, 3D trajectories, and 3D surface plots
  • Custom Equations: Input any differentiable functions for dx/dt and dy/dt
  • Built-in Examples: Pre-loaded systems including harmonic oscillator, predator-prey, and spiral dynamics
  • Vector Field Display: Shows direction field with customizable arrow density and scaling
  • Trajectory Integration: Computes and displays solution trajectories with adjustable time steps
  • Equilibrium Analysis: Automatically finds and highlights equilibrium points
  • Viewing Controls: Zoom, pan, and adjust window bounds interactively
  • Export Functionality: Save visualizations as PNG images
  • Dark Mode: Toggle between light and dark themes
  • Responsive Design: Works on desktop and mobile devices

Technical Details

The application uses:

  • p5.js for canvas rendering and interactive graphics
  • math.js for symbolic differentiation and numerical evaluation
  • Runge-Kutta 4th order integration for trajectory computation
  • HTML5 Canvas for high-performance 2D/3D rendering

Getting Started

Prerequisites

  • A modern web browser with JavaScript enabled
  • Internet connection for loading external libraries (math.js and p5.js)

Installation

  1. Clone or download this repository
  2. Navigate to the project directory
  3. Open index.html in your web browser

No additional installation or build steps are required.

Usage

Basic Operation

  1. Enter differential equations in the input fields:
    • dx/dt = f(x,y): Rate of change of x with respect to time
    • dy/dt = g(x,y): Rate of change of y with respect to time
  2. Adjust the viewing window bounds if needed
  3. Select visualization type (2D, 3D Trajectories, or 3D Surface)
  4. The plot will update automatically

Examples

  • Harmonic Oscillator: dx/dt = y, dy/dt = -x
  • Predator-Prey: dx/dt = x(1-y), dy/dt = y(x-1)
  • Spiral: dx/dt = x-y, dy/dt = x+y

Use the "Common Examples" dropdown to load these presets.

Advanced Features

  • Custom Trajectories: Click on the canvas to add trajectory starting points
  • Find Equilibria: Use the "Find Equilibria" button to locate and mark fixed points
  • Vector Field Settings: Adjust arrow density, length, and scaling
  • Zoom Controls: Use zoom in/out buttons or adjust bounds manually

Exporting

Click the "Save Image" button to export the current visualization as a PNG file.

Testing

The application is designed for interactive testing:

  1. Load the page in your browser
  2. Try the built-in examples to verify basic functionality
  3. Enter custom equations and observe the resulting phase portraits
  4. Test different visualization modes (2D, 3D)
  5. Verify export functionality by saving images
  6. Check responsiveness on different screen sizes

Browser Compatibility

  • Chrome/Chromium 80+
  • Firefox 75+
  • Safari 13+
  • Edge 80+

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

License

Copyright (c) 2013 Mark Otto.

Copyright (c) 2017 Andrew Fong.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A browser-based tool to explore and plot phase portraits for autonomous systems of ODEs. Includes built-in examples, vector fields, and export functionality.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published