Skip to content

dosstacy/cobweb-website

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

112 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Cobweb Website - Difference Equations & Economic Models

A modern web application for visualizing and understanding difference equations and economic models, with a focus on interactive demonstrations of dynamic systems.

๐ŸŽฏ Overview

This project is an educational web application designed to help students and economists understand complex dynamic systems through interactive visualizations. It covers fundamental concepts in difference equations and their applications to economic models like the Cobweb Model, supply-demand dynamics, and price-quantity relationships.

The application provides:

  • Interactive Calculator for solving difference equations
  • Visual Models with real-time parameter adjustments
  • Multi-language Support (English, Slovak)
  • Mathematical Rendering with LaTeX and Plotly charts

Main page

โœจ Features

1. Cobweb Model

Interactive visualization of how price and quantity reach equilibrium through cyclical adjustments.

Cobweb Parameters

Variations include:

  • Convergence to equilibrium
  • Divergence from equilibrium
  • Oscillatory behavior
  • Chaotic dynamics

2. Difference Equations Calculator

Solve difference equations with automatic LaTeX rendering of solutions.

Calculator Interface

3. Supply & Demand Analysis

Explore how market equilibrium is determined through supply and demand curves.

4. Normal Price Model

Analysis of long-run equilibrium in dynamic economic systems.

5. Adaptive Expectations

Study how expectations adapt over time in economic forecasting.

6. Chaos & Anomalies

Explore chaotic behavior and system anomalies in difference equations.

7. Multi-language Support

Full support for English and Slovak languages with dynamic language switching.


๐Ÿ“ Project Structure

cobweb-website/
โ”œโ”€โ”€ app.py                          # Flask application entry point
โ”œโ”€โ”€ Dockerfile                      # Docker configuration
โ”œโ”€โ”€ requirements.txt                # Python dependencies
โ”œโ”€โ”€ secret.env                      # Environment variables
โ”‚
โ”œโ”€โ”€ api/                            # API route handlers
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ home_api.py                 # Home page routing
โ”‚   โ”œโ”€โ”€ calculator_api.py           # Calculator endpoints
โ”‚   โ”œโ”€โ”€ models_api.py               # Model visualization endpoints
โ”‚   โ”œโ”€โ”€ intros_and_params_api.py   # Introduction & parameters
โ”‚   โ””โ”€โ”€ language_api.py             # Language switching
โ”‚
โ”œโ”€โ”€ dictionaries/                   # Content dictionaries
โ”‚   โ”œโ”€โ”€ intros_dictionary.py
โ”‚   โ”œโ”€โ”€ models_dictionary.py
โ”‚   โ””โ”€โ”€ params_dictionary.py
โ”‚
โ”œโ”€โ”€ tools/                          # Calculation & modeling tools
โ”‚   โ”œโ”€โ”€ diff_calculator.py          # Difference equation solver
โ”‚   โ””โ”€โ”€ models/
โ”‚       โ”œโ”€โ”€ cobweb_equations.py
โ”‚       โ”œโ”€โ”€ cobweb_functions.py
โ”‚       โ”œโ”€โ”€ demand_and_supply.py
โ”‚       โ”œโ”€โ”€ adaptive_expectations.py
โ”‚       โ”œโ”€โ”€ normal_price.py
โ”‚       โ””โ”€โ”€ prices_periods_dependency.py
โ”‚
โ”œโ”€โ”€ static/                         # Static assets
โ”‚   โ”œโ”€โ”€ css/                        # Stylesheets
โ”‚   โ”‚   โ”œโ”€โ”€ global.css
โ”‚   โ”‚   โ”œโ”€โ”€ index.css
โ”‚   โ”‚   โ”œโ”€โ”€ calculator.css
โ”‚   โ”‚   โ”œโ”€โ”€ data.css
โ”‚   โ”‚   โ”œโ”€โ”€ intros.css
โ”‚   โ”‚   โ””โ”€โ”€ params.css
โ”‚   โ”œโ”€โ”€ js/                         # JavaScript files
โ”‚   โ”‚   โ”œโ”€โ”€ data.js
โ”‚   โ”‚   โ””โ”€โ”€ intro.js
โ”‚   โ””โ”€โ”€ img/                        # Images & diagrams
โ”‚
โ”œโ”€โ”€ templates/                      # HTML templates
โ”‚   โ”œโ”€โ”€ base.html                   # Base template
โ”‚   โ”œโ”€โ”€ index.html                  # Home page
โ”‚   โ”œโ”€โ”€ calculator.html             # Calculator interface
โ”‚   โ”œโ”€โ”€ data.html                   # Data visualization
โ”‚   โ”œโ”€โ”€ intros_base.html
โ”‚   โ”œโ”€โ”€ params_base.html
โ”‚   โ””โ”€โ”€ partials/                   # Reusable template components
โ”‚       โ”œโ”€โ”€ math_table.html
โ”‚       โ””โ”€โ”€ math_table_calc.html
โ”‚
โ””โ”€โ”€ utils/                          # Utility functions
    โ”œโ”€โ”€ checking_utils.py
    โ””โ”€โ”€ solutions_utils.py

๐Ÿš€ Installation

Prerequisites

  • Python 3.8+
  • pip or conda

Local Setup

  1. Clone the repository

    git clone <repository-url>
    cd cobweb-website
  2. Create a virtual environment

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Set environment variables

    # Create a .env file or use secret.env
    export SECRET_KEY="your-secret-key-here"
  5. Run the application

    python app.py

The application will be available at http://localhost:5000


๐Ÿ“– Usage

Home Page

Navigate to / to access the main menu with all available models and tools.

Cobweb Model

Access the interactive cobweb model at /model/cobweb to adjust parameters and visualize model behavior.

Calculator

Use the difference equations calculator at /calculator to solve equations and see LaTeX-formatted solutions.

Data Visualization

View interactive charts and data analysis at /data.

Language Switching

Switch between English and Slovak from the language menu in the navigation bar.


๐Ÿ› ๏ธ Technologies

Technology Purpose
Flask Web framework for routing and templating
SymPy Symbolic mathematics & equation solving
Plotly Interactive data visualization
NumPy Numerical computations
HTML5/CSS3 Frontend structure and styling
JavaScript Client-side interactivity

Dependencies

  • flask ~3.0.3
  • sympy ~1.13.2
  • plotly ~5.24.1
  • numpy ~1.26.4

๐Ÿงฎ Models & Tools

Difference Equations Calculator

Solves linear and non-linear difference equations, providing:

  • General solutions
  • Particular solutions
  • LaTeX mathematical notation rendering

Cobweb Model

Demonstrates supply-demand dynamics with:

  • Convergent equilibrium
  • Divergent patterns
  • Oscillatory cycles
  • Chaotic behavior

Key Equations:

  • Demand: $P_d = a - b \cdot Q_d$
  • Supply (lagged): $Q_s = c + d \cdot P_{t-1}$
  • Equilibrium condition: $Q_d = Q_s$

Normal Price Model

Analyzes long-run equilibrium behavior and convergence properties.

Adaptive Expectations

Models how agents form expectations adaptively based on past errors.

Supply & Demand Analysis

Comprehensive visualization of:

  • Market equilibrium
  • Consumer and producer surplus
  • Elasticity effects

๐Ÿ”Œ API Endpoints

Endpoint Method Description
/ GET Home page
/calculator GET Calculator interface
/calculator POST Calculate difference equations
/model/<model_name> GET Display specific model
/data GET Data visualization page
/intros/<section> GET Introduction pages
/params/<model> GET Model parameters page
/language POST Switch language

๐Ÿณ Docker Deployment

Build Docker Image

docker build -t cobweb-website .

Run Container

docker run -p 5000:5000 \
  -e SECRET_KEY="your-secret-key" \
  cobweb-website

The application will be accessible at http://localhost:5000


๐Ÿ‘จโ€๐Ÿ’ผ About

This educational application was developed as a Bachelor's thesis project in Computer Modeling. It demonstrates the practical application of computational techniques, symbolic mathematics, and interactive visualization to make complex economic and mathematical concepts accessible through hands-on experimentation.


About

Bachelor's thesis project in Computer Modeling

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors