563 lines
19 KiB
HTML
563 lines
19 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Manual Simulation - Transformer</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
padding: 20px;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
.container {
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
background: white;
|
|
border-radius: 15px;
|
|
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
|
|
padding: 30px;
|
|
}
|
|
|
|
.header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
h1 {
|
|
color: #333;
|
|
}
|
|
|
|
.nav-link {
|
|
color: #667eea;
|
|
text-decoration: none;
|
|
padding: 10px 20px;
|
|
border: 2px solid #667eea;
|
|
border-radius: 20px;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.nav-link:hover {
|
|
background: #667eea;
|
|
color: white;
|
|
}
|
|
|
|
.subtitle {
|
|
text-align: center;
|
|
color: #666;
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.controls {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
|
gap: 20px;
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.control-group {
|
|
background: #f8f9fa;
|
|
padding: 15px;
|
|
border-radius: 8px;
|
|
border: 1px solid #e0e0e0;
|
|
}
|
|
|
|
.control-group h3 {
|
|
color: #555;
|
|
font-size: 14px;
|
|
margin-bottom: 15px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 1px;
|
|
}
|
|
|
|
.slider-container, .select-container {
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
.slider-container:last-child, .select-container:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
label {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
font-weight: 500;
|
|
color: #333;
|
|
margin-bottom: 8px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.value-display {
|
|
color: #667eea;
|
|
font-weight: bold;
|
|
}
|
|
|
|
input[type="range"] {
|
|
width: 100%;
|
|
height: 8px;
|
|
border-radius: 5px;
|
|
background: #d3d3d3;
|
|
outline: none;
|
|
-webkit-appearance: none;
|
|
}
|
|
|
|
input[type="range"]::-webkit-slider-thumb {
|
|
-webkit-appearance: none;
|
|
appearance: none;
|
|
width: 20px;
|
|
height: 20px;
|
|
border-radius: 50%;
|
|
background: #667eea;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
input[type="range"]::-webkit-slider-thumb:hover {
|
|
background: #764ba2;
|
|
transform: scale(1.1);
|
|
}
|
|
|
|
select {
|
|
width: 100%;
|
|
padding: 10px;
|
|
border: 2px solid #e0e0e0;
|
|
border-radius: 5px;
|
|
font-size: 14px;
|
|
background: white;
|
|
cursor: pointer;
|
|
transition: border-color 0.3s;
|
|
}
|
|
|
|
select:focus {
|
|
outline: none;
|
|
border-color: #667eea;
|
|
}
|
|
|
|
.button-container {
|
|
text-align: center;
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
button {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
border: none;
|
|
padding: 15px 40px;
|
|
font-size: 16px;
|
|
font-weight: bold;
|
|
border-radius: 25px;
|
|
cursor: pointer;
|
|
transition: all 0.3s;
|
|
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
|
|
}
|
|
|
|
button:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
|
|
}
|
|
|
|
button:active {
|
|
transform: translateY(0);
|
|
}
|
|
|
|
button:disabled {
|
|
background: #ccc;
|
|
cursor: not-allowed;
|
|
box-shadow: none;
|
|
}
|
|
|
|
.results {
|
|
background: #f8f9fa;
|
|
border-radius: 10px;
|
|
padding: 25px;
|
|
border: 2px solid #667eea;
|
|
}
|
|
|
|
.results h2 {
|
|
color: #333;
|
|
margin-bottom: 20px;
|
|
text-align: center;
|
|
}
|
|
|
|
.results-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
gap: 15px;
|
|
}
|
|
|
|
.result-card {
|
|
background: white;
|
|
padding: 15px;
|
|
border-radius: 8px;
|
|
border-left: 4px solid #667eea;
|
|
}
|
|
|
|
.result-card h4 {
|
|
color: #555;
|
|
font-size: 12px;
|
|
text-transform: uppercase;
|
|
margin-bottom: 8px;
|
|
letter-spacing: 1px;
|
|
}
|
|
|
|
.result-value {
|
|
font-size: 24px;
|
|
font-weight: bold;
|
|
color: #333;
|
|
}
|
|
|
|
.result-unit {
|
|
font-size: 14px;
|
|
color: #666;
|
|
margin-left: 5px;
|
|
}
|
|
|
|
.error {
|
|
background: #fee;
|
|
border: 2px solid #f66;
|
|
color: #c33;
|
|
padding: 15px;
|
|
border-radius: 8px;
|
|
text-align: center;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.loading {
|
|
text-align: center;
|
|
padding: 20px;
|
|
color: #667eea;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.hidden {
|
|
display: none;
|
|
}
|
|
|
|
.efficiency-high {
|
|
border-left-color: #22c55e;
|
|
}
|
|
|
|
.efficiency-medium {
|
|
border-left-color: #f59e0b;
|
|
}
|
|
|
|
.efficiency-low {
|
|
border-left-color: #ef4444;
|
|
}
|
|
|
|
.tap-info {
|
|
font-size: 12px;
|
|
color: #666;
|
|
margin-top: 5px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="header">
|
|
<h1>🔧 Manual Simulation</h1>
|
|
<a href="/" class="nav-link">⚡ Go to Optimizer</a>
|
|
</div>
|
|
<p class="subtitle">Directly specify tap settings and input voltage to simulate transformer performance</p>
|
|
|
|
<div class="controls">
|
|
<div class="control-group">
|
|
<h3>Tap Selection</h3>
|
|
<div class="select-container">
|
|
<label>
|
|
<span>Primary Tap</span>
|
|
</label>
|
|
<select id="primary-tap">
|
|
<option value="1">Tap 1 (50 turns)</option>
|
|
<option value="2">Tap 2 (100 turns)</option>
|
|
</select>
|
|
</div>
|
|
<div class="select-container">
|
|
<label>
|
|
<span>Secondary Tap</span>
|
|
</label>
|
|
<select id="secondary-tap">
|
|
<option value="1">Tap 1 (100 turns)</option>
|
|
<option value="2">Tap 2 (150 turns)</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="control-group">
|
|
<h3>Input Parameters</h3>
|
|
<div class="slider-container">
|
|
<label>
|
|
<span>Input Voltage</span>
|
|
<span class="value-display"><span id="vp-value">12</span> V</span>
|
|
</label>
|
|
<input type="range" id="vp" min="1" max="100" value="12" step="0.5">
|
|
</div>
|
|
<div class="slider-container">
|
|
<label>
|
|
<span>Frequency</span>
|
|
<span class="value-display"><span id="freq-value">2000</span> Hz</span>
|
|
</label>
|
|
<input type="range" id="freq" min="100" max="50000" value="2000" step="100">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="control-group">
|
|
<h3>Load Conditions</h3>
|
|
<div class="slider-container">
|
|
<label>
|
|
<span>Load Resistance</span>
|
|
<span class="value-display"><span id="load-value">100</span> Ω</span>
|
|
</label>
|
|
<input type="range" id="load" min="5" max="10000" value="100" step="5">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="button-container">
|
|
<button id="simulate-btn" onclick="runSimulation()">▶️ Run Simulation</button>
|
|
</div>
|
|
|
|
<div id="loading" class="loading hidden">
|
|
Running simulation...
|
|
</div>
|
|
|
|
<div id="error" class="error hidden"></div>
|
|
|
|
<div id="results" class="results hidden">
|
|
<h2>Simulation Results</h2>
|
|
<div class="results-grid">
|
|
<div class="result-card" id="efficiency-card">
|
|
<h4>Efficiency</h4>
|
|
<div class="result-value">
|
|
<span id="efficiency">-</span><span class="result-unit">%</span>
|
|
</div>
|
|
</div>
|
|
<div class="result-card">
|
|
<h4>Output Power</h4>
|
|
<div class="result-value">
|
|
<span id="p-out">-</span><span class="result-unit">W</span>
|
|
</div>
|
|
</div>
|
|
<div class="result-card">
|
|
<h4>Input Power</h4>
|
|
<div class="result-value">
|
|
<span id="p-in">-</span><span class="result-unit">W</span>
|
|
</div>
|
|
</div>
|
|
<div class="result-card">
|
|
<h4>Primary Turns</h4>
|
|
<div class="result-value">
|
|
<span id="np-eff">-</span><span class="result-unit">turns</span>
|
|
</div>
|
|
</div>
|
|
<div class="result-card">
|
|
<h4>Secondary Turns</h4>
|
|
<div class="result-value">
|
|
<span id="ns-eff">-</span><span class="result-unit">turns</span>
|
|
</div>
|
|
</div>
|
|
<div class="result-card">
|
|
<h4>Turns Ratio</h4>
|
|
<div class="result-value">
|
|
<span id="turns-ratio">-</span>
|
|
</div>
|
|
</div>
|
|
<div class="result-card">
|
|
<h4>Input Voltage</h4>
|
|
<div class="result-value">
|
|
<span id="vp-rms">-</span><span class="result-unit">V</span>
|
|
</div>
|
|
</div>
|
|
<div class="result-card">
|
|
<h4>Output Voltage</h4>
|
|
<div class="result-value">
|
|
<span id="vs-rms">-</span><span class="result-unit">V</span>
|
|
</div>
|
|
</div>
|
|
<div class="result-card">
|
|
<h4>Input Current</h4>
|
|
<div class="result-value">
|
|
<span id="ip-rms">-</span><span class="result-unit">A</span>
|
|
</div>
|
|
</div>
|
|
<div class="result-card">
|
|
<h4>Output Current</h4>
|
|
<div class="result-value">
|
|
<span id="is-rms">-</span><span class="result-unit">A</span>
|
|
</div>
|
|
</div>
|
|
<div class="result-card">
|
|
<h4>Flux Density</h4>
|
|
<div class="result-value">
|
|
<span id="b-peak">-</span><span class="result-unit">T</span>
|
|
</div>
|
|
</div>
|
|
<div class="result-card">
|
|
<h4>Copper Loss (Primary)</h4>
|
|
<div class="result-value">
|
|
<span id="p-cu-primary">-</span><span class="result-unit">W</span>
|
|
</div>
|
|
</div>
|
|
<div class="result-card">
|
|
<h4>Copper Loss (Secondary)</h4>
|
|
<div class="result-value">
|
|
<span id="p-cu-secondary">-</span><span class="result-unit">W</span>
|
|
</div>
|
|
</div>
|
|
<div class="result-card">
|
|
<h4>Core Loss</h4>
|
|
<div class="result-value">
|
|
<span id="p-core">-</span><span class="result-unit">W</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Update slider value displays
|
|
const sliders = {
|
|
'vp': { element: 'vp-value', format: (v) => parseFloat(v).toFixed(1) },
|
|
'freq': { element: 'freq-value', format: (v) => Math.round(v) },
|
|
'load': { element: 'load-value', format: (v) => Math.round(v) },
|
|
};
|
|
|
|
for (const [id, config] of Object.entries(sliders)) {
|
|
const slider = document.getElementById(id);
|
|
const display = document.getElementById(config.element);
|
|
slider.addEventListener('input', (e) => {
|
|
display.textContent = config.format(e.target.value);
|
|
});
|
|
}
|
|
|
|
async function runSimulation() {
|
|
const btn = document.getElementById('simulate-btn');
|
|
const loading = document.getElementById('loading');
|
|
const results = document.getElementById('results');
|
|
const error = document.getElementById('error');
|
|
|
|
// Hide previous results/errors
|
|
results.classList.add('hidden');
|
|
error.classList.add('hidden');
|
|
|
|
// Show loading
|
|
btn.disabled = true;
|
|
loading.classList.remove('hidden');
|
|
|
|
try {
|
|
const response = await fetch('/api/simulate', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({
|
|
primary_tap: parseInt(document.getElementById('primary-tap').value),
|
|
secondary_tap: parseInt(document.getElementById('secondary-tap').value),
|
|
Vp_rms: parseFloat(document.getElementById('vp').value),
|
|
freq_hz: parseFloat(document.getElementById('freq').value),
|
|
load_ohms: parseFloat(document.getElementById('load').value),
|
|
}),
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (data.success) {
|
|
displayResults(data.result);
|
|
} else {
|
|
showError(data.error);
|
|
}
|
|
} catch (err) {
|
|
showError('Network error: ' + err.message);
|
|
} finally {
|
|
btn.disabled = false;
|
|
loading.classList.add('hidden');
|
|
}
|
|
}
|
|
|
|
function displayResults(result) {
|
|
document.getElementById('efficiency').textContent = result.efficiency;
|
|
document.getElementById('p-out').textContent = result.P_out_W;
|
|
document.getElementById('p-in').textContent = result.P_in_W;
|
|
document.getElementById('np-eff').textContent = result.Np_eff;
|
|
document.getElementById('ns-eff').textContent = result.Ns_eff;
|
|
document.getElementById('turns-ratio').textContent = result.turns_ratio;
|
|
document.getElementById('vp-rms').textContent = result.Vp_rms;
|
|
document.getElementById('vs-rms').textContent = result.Vs_rms;
|
|
document.getElementById('ip-rms').textContent = result.Ip_rms;
|
|
document.getElementById('is-rms').textContent = result.Is_rms;
|
|
document.getElementById('b-peak').textContent = result.B_peak_T;
|
|
document.getElementById('p-cu-primary').textContent = result.P_cu_primary_W;
|
|
document.getElementById('p-cu-secondary').textContent = result.P_cu_secondary_W;
|
|
document.getElementById('p-core').textContent = result.P_core_W;
|
|
|
|
// Color code efficiency
|
|
const effCard = document.getElementById('efficiency-card');
|
|
effCard.classList.remove('efficiency-high', 'efficiency-medium', 'efficiency-low');
|
|
if (result.efficiency >= 90) {
|
|
effCard.classList.add('efficiency-high');
|
|
} else if (result.efficiency >= 80) {
|
|
effCard.classList.add('efficiency-medium');
|
|
} else {
|
|
effCard.classList.add('efficiency-low');
|
|
}
|
|
|
|
document.getElementById('results').classList.remove('hidden');
|
|
}
|
|
|
|
function showError(message) {
|
|
const errorDiv = document.getElementById('error');
|
|
errorDiv.textContent = message;
|
|
errorDiv.classList.remove('hidden');
|
|
}
|
|
|
|
// Load transformer info on page load
|
|
async function loadTransformerInfo() {
|
|
try {
|
|
const response = await fetch('/api/transformer_info');
|
|
const data = await response.json();
|
|
|
|
// Update tap options based on actual transformer
|
|
const primarySelect = document.getElementById('primary-tap');
|
|
const secondarySelect = document.getElementById('secondary-tap');
|
|
|
|
primarySelect.innerHTML = '';
|
|
secondarySelect.innerHTML = '';
|
|
|
|
// Primary taps (skip first element which is 0)
|
|
for (let i = 1; i < data.primary_taps.length; i++) {
|
|
const turns = data.primary_taps.slice(1, i + 1).reduce((a, b) => a + b, 0);
|
|
const option = document.createElement('option');
|
|
option.value = i;
|
|
option.textContent = `Tap ${i} (${turns} turns)`;
|
|
primarySelect.appendChild(option);
|
|
}
|
|
|
|
// Secondary taps
|
|
for (let i = 1; i < data.secondary_taps.length; i++) {
|
|
const turns = data.secondary_taps.slice(1, i + 1).reduce((a, b) => a + b, 0);
|
|
const option = document.createElement('option');
|
|
option.value = i;
|
|
option.textContent = `Tap ${i} (${turns} turns)`;
|
|
secondarySelect.appendChild(option);
|
|
}
|
|
} catch (err) {
|
|
console.error('Failed to load transformer info:', err);
|
|
}
|
|
}
|
|
|
|
// Load on page load
|
|
loadTransformerInfo();
|
|
</script>
|
|
</body>
|
|
</html>
|