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.
- Host: GitHub
- URL: https://github.com/nelman25/capacicalc
- Owner: Nelman25
- Created: 2025-05-25T19:23:06.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2025-05-26T11:31:38.000Z (12 months ago)
- Last Synced: 2025-06-26T03:02:24.248Z (11 months ago)
- Topics: chartjs, gemini-api, react, tailwindcss, typscript, zustand
- Language: TypeScript
- Homepage: https://capaci-calc.vercel.app
- Size: 139 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
---