An open API service indexing awesome lists of open source software.

https://github.com/nelman25/capacicalc

Where physics meets code ⚔ Watch capacitors charge/discharge in real-time and chat with an AI about the math behind the curves.
https://github.com/nelman25/capacicalc

chartjs gemini-api react tailwindcss typscript zustand

Last synced: 8 days ago
JSON representation

Where physics meets code ⚔ Watch capacitors charge/discharge in real-time and chat with an AI about the math behind the curves.

Awesome Lists containing this project

README

          

# CapaciCalc: Capacitor Charge-Discharge Calculator

## šŸ“ Overview
CapaciCalc is an interactive capacitor charge-discharge calculator I developed as my Physics 2 final project. This tool provides:

- **Real-time calculations** of capacitor voltage during charge/discharge cycles
- **Visualization** of the exponential charge/discharge curve
- **AI-powered explanations** for understanding the physics behind the results

## ✨ Features

### ⚔ Core Calculator
- Calculate instantaneous voltage at any time point
- Supports both charging and discharging scenarios
- Automatic time constant (Ļ„ = RC) calculation
- Unit conversions for capacitance (F, μF, nF, pF) and resistance (Ω, kΩ, MΩ)

### šŸ“Š Visualization
- Interactive graph showing the complete charge/discharge curve
- Highlighted time constant (Ļ„) markers
- Real-time updates as parameters change

### šŸ¤– AI Physics Assistant
- Built-in chatbot powered by Gemini API
- Ask follow-up questions about:
- Calculation results
- Physics concepts
- Circuit behavior explanations
- Provides formatted responses with Markdown support

## šŸ› ļø Technical Implementation

### Frontend
- **React** with TypeScript
- **Zustand** for state management
- **Chart.js** + **react-chartjs-2** for visualization
- **ShadCN** UI components for clean interface

### AI Integration
- Google's **Gemini API** for physics explanations
- Dynamic prompt engineering for technical responses
- Response formatting with Markdown support

## šŸš€ Getting Started

### Prerequisites
- Node.js (v18+ recommended)
- Google Gemini API key (for AI features)

### Installation
```bash
git clone https://github.com/yourusername/capacicalc.git
cd capacicalc
npm install
```

### Configuration
Create a `.env` file:
```env
VITE_GEMINI_API_KEY=your_api_key_here
```

### Running
```bash
npm run dev
```

## šŸ“š Physics Concepts Implemented

### Key Formulas
- Time constant: Ļ„ = RC
- Charging: V(t) = Vā‚€(1 - e^(-t/Ļ„))
- Discharging: V(t) = Vā‚€e^(-t/Ļ„)

### Graph Features
- Shows 0 → 5Ļ„ range (99.3% complete charge/discharge)
- Exponential curve visualization
- Dynamic scaling based on circuit parameters

---