File size: 4,169 Bytes
9ad4750
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5f25c87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
---
title: Eng Calc
emoji: 🏒
colorFrom: indigo
colorTo: green
sdk: gradio
sdk_version: 5.36.2
app_file: app.py
pinned: false
license: agpl-3.0
short_description: engineering calculator
---

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

# Engineering Calculator

A comprehensive Gradio-based web application providing multiple calculator modes for engineering, scientific, and programming calculations.

## Features

### Calculator Modes
- **Standard Calculator**: Basic arithmetic with infinite precision
- **Scientific Calculator**: Trigonometric functions, logarithms, and advanced mathematical operations
- **Programming Calculator**: Base conversions and bitwise operations
- **Engineering Calculator**: Specialized engineering calculations including 3-phase impedance analysis

### Key Capabilities
- **Infinite Precision Arithmetic**: No precision loss for basic operations (addition, subtraction, multiplication, division)
- **Calculation History**: Track and review previous calculations
- **Memory Functions**: Store and recall values
- **AI Assistant**: Interactive chat interface for calculation help (placeholder)
- **Complex Number Support**: Full support for complex numbers with j notation for electrical engineering

## Installation

1. Clone the repository:
```bash
git clone <repository-url>
cd calculator
```

2. Install dependencies:
```bash
pip install -r requirements.txt
```

3. Run the application:
```bash
python app.py
```

The application will start on `http://localhost:7860`

## Engineering Functions

### 3-Phase Impedance Calculator
Calculate equivalent impedance matrices for 5-wire power systems (A, B, C, N, PE) using:
- Modified Carson's equations for earth return effects
- Kron reduction technique for system simplification
- IEEE standard electrical engineering practices

**Input Parameters:**
- Conductor coordinates (feet)
- Conductor electrical parameters (resistance in Ξ©/mile, GMR in feet)

**Output:**
- 5Γ—5 primitive impedance matrix
- 3Γ—3 reduced phase impedance matrix
- Distance calculations between conductors
- Matrix analysis and properties

## Project Structure

```
calculator/
β”œβ”€β”€ app.py                 # Main Gradio application
β”œβ”€β”€ requirements.txt       # Python dependencies
β”œβ”€β”€ README.md             # This file
β”œβ”€β”€ CLAUDE.md             # Development guidance
β”œβ”€β”€ calculator/           # Core calculator modules
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── core.py          # Calculator classes
β”œβ”€β”€ engineering/          # Engineering calculations
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── impedance.py     # 3-phase impedance calculator
β”œβ”€β”€ tests/               # Test files (to be implemented)
└── static/              # CSS and JavaScript assets
```

## Usage Examples

### Standard Calculator
- Basic arithmetic operations with button interface
- Memory functions (MS, MR, MC)
- Calculation history tracking

### Scientific Calculator
- Trigonometric functions (sin, cos, tan, etc.)
- Inverse trigonometric functions (asin, acos, atan)
- Logarithmic functions (log, ln)
- Angle mode selection (degrees/radians)

### Programming Calculator
- Base conversions between decimal, binary, hexadecimal, and octal
- Support for various input formats

### Engineering Calculator
- Load test data for quick verification
- Input conductor coordinates and electrical parameters
- Calculate comprehensive impedance analysis

## Development

### Running Tests
```bash
python -m pytest tests/  # When test suite is implemented
```

### Adding New Engineering Functions
1. Implement the calculation logic in the `engineering/` module
2. Add the function to the dropdown in `app.py`
3. Create the corresponding input interface
4. Update this README with usage instructions

## Dependencies

- **Gradio**: Web interface framework
- **NumPy**: Numerical computations and matrix operations
- **Pandas**: Data analysis and manipulation
- **Matplotlib**: Plotting and visualization
- **Seaborn**: Statistical visualization

## License

[Add license information here]

## Contributing

[Add contributing guidelines here]