test / index.html
acwk's picture
Add 2 files
7b520d7 verified
Raw History Blame Contribute Delete
48.5 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MV Cable & Transformer Sizing Tool</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
electric: '#00B4D8',
powerblue: '#0077B6',
darkblue: '#03045E',
}
}
}
}
</script>
<style>
.gradient-bg {
background: linear-gradient(135deg, #03045E 0%, #0077B6 50%, #00B4D8 100%);
}
.result-card {
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
transition: all 0.3s ease;
}
.result-card:hover {
transform: translateY(-5px);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.tab-content {
display: none;
}
.tab-content.active {
display: block;
animation: fadeIn 0.5s ease;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.input-highlight {
border-left: 4px solid #00B4D8;
}
.chart-container {
position: relative;
height: 400px;
width: 100%;
}
</style>
</head>
<body class="bg-gray-50 font-sans">
<header class="gradient-bg text-white">
<div class="container mx-auto px-4 py-8">
<div class="flex flex-col md:flex-row justify-between items-center">
<div class="mb-6 md:mb-0">
<h1 class="text-3xl md:text-4xl font-bold mb-2">
<i class="fas fa-bolt mr-2"></i> MV Power Sizing Tool
</h1>
<p class="text-lg opacity-90">Medium Voltage Cable & Transformer Sizing Calculator</p>
</div>
<div class="flex space-x-4">
<button onclick="switchTab('cable')" class="tab-btn bg-white text-powerblue px-6 py-2 rounded-full font-semibold shadow-md hover:bg-gray-100 transition">
<i class="fas fa-cable-car mr-2"></i> Cable Sizing
</button>
<button onclick="switchTab('transformer')" class="tab-btn bg-transparent border-2 border-white text-white px-6 py-2 rounded-full font-semibold hover:bg-white hover:text-powerblue transition">
<i class="fas fa-transformer mr-2"></i> Transformers
</button>
</div>
</div>
</div>
</header>
<main class="container mx-auto px-4 py-8">
<!-- Cable Sizing Tab -->
<div id="cable-tab" class="tab-content active">
<div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
<div class="p-6">
<h2 class="text-2xl font-bold text-darkblue mb-4 flex items-center">
<i class="fas fa-cable-car text-electric mr-3"></i> Medium Voltage Cable Sizing
</h2>
<p class="text-gray-600 mb-6">Enter the system parameters to calculate the appropriate cable size for your medium voltage application.</p>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<div class="mb-6">
<label class="block text-gray-700 font-medium mb-2" for="system-voltage">
System Voltage (kV)
</label>
<select id="system-voltage" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-electric focus:border-transparent input-highlight">
<option value="3.3">3.3 kV</option>
<option value="6.6">6.6 kV</option>
<option value="11" selected>11 kV</option>
<option value="22">22 kV</option>
<option value="33">33 kV</option>
</select>
</div>
<div class="mb-6">
<label class="block text-gray-700 font-medium mb-2" for="load-current">
Load Current (A)
</label>
<input type="number" id="load-current" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-electric focus:border-transparent input-highlight" placeholder="e.g. 150">
</div>
<div class="mb-6">
<label class="block text-gray-700 font-medium mb-2" for="cable-length">
Cable Length (m)
</label>
<input type="number" id="cable-length" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-electric focus:border-transparent input-highlight" placeholder="e.g. 250">
</div>
</div>
<div>
<div class="mb-6">
<label class="block text-gray-700 font-medium mb-2" for="installation-method">
Installation Method
</label>
<select id="installation-method" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-electric focus:border-transparent input-highlight">
<option value="buried">Buried Direct in Ground</option>
<option value="duct">In Duct/Buried</option>
<option value="tray">Cable Tray</option>
<option value="ladder">Cable Ladder</option>
<option value="air">In Air</option>
</select>
</div>
<div class="mb-6">
<label class="block text-gray-700 font-medium mb-2" for="soil-resistivity">
Soil Thermal Resistivity (K.m/W)
</label>
<input type="number" id="soil-resistivity" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-electric focus:border-transparent input-highlight" value="1.2" step="0.1">
</div>
<div class="mb-6">
<label class="block text-gray-700 font-medium mb-2" for="ambient-temp">
Ambient Temperature (°C)
</label>
<input type="number" id="ambient-temp" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-electric focus:border-transparent input-highlight" value="30" step="1">
</div>
</div>
</div>
<div class="flex justify-center mt-6">
<button onclick="calculateCableSize()" class="gradient-bg text-white px-8 py-3 rounded-full font-semibold hover:opacity-90 transition flex items-center">
<i class="fas fa-calculator mr-2"></i> Calculate Cable Size
</button>
</div>
</div>
</div>
<div id="cable-results" class="hidden">
<div class="bg-white rounded-xl shadow-md overflow-hidden mb-8 result-card">
<div class="p-6">
<h3 class="text-xl font-bold text-darkblue mb-4 flex items-center">
<i class="fas fa-file-alt text-electric mr-3"></i> Cable Sizing Results
</h3>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
<div class="bg-gray-50 p-4 rounded-lg">
<p class="text-gray-600 font-medium">Recommended Size</p>
<p id="recommended-size" class="text-2xl font-bold text-electric">-- mm²</p>
</div>
<div class="bg-gray-50 p-4 rounded-lg">
<p class="text-gray-600 font-medium">Current Capacity</p>
<p id="current-capacity" class="text-2xl font-bold text-electric">-- A</p>
</div>
<div class="bg-gray-50 p-4 rounded-lg">
<p class="text-gray-600 font-medium">Voltage Drop</p>
<p id="voltage-drop" class="text-2xl font-bold text-electric">-- %</p>
</div>
</div>
<div class="mb-4">
<h4 class="font-semibold text-gray-700 mb-2">Cable Specifications:</h4>
<div class="bg-gray-50 p-4 rounded-lg">
<div class="grid grid-cols-2 gap-4">
<div>
<p class="text-gray-600">Type: <span id="cable-type" class="font-medium">--</span></p>
<p class="text-gray-600">Insulation: <span id="cable-insulation" class="font-medium">--</span></p>
</div>
<div>
<p class="text-gray-600">Sheath: <span id="cable-sheath" class="font-medium">--</span></p>
<p class="text-gray-600">Conductor: <span id="cable-conductor" class="font-medium">--</span></p>
</div>
</div>
</div>
</div>
<div class="mt-6">
<h4 class="font-semibold text-gray-700 mb-2">Notes:</h4>
<ul class="list-disc pl-5 text-gray-600 space-y-1">
<li>Results are based on IEC 60502 standards</li>
<li>Consider derating factors for grouping and depth of burial</li>
<li>Verify short circuit withstand capacity</li>
<li>Consult manufacturer data for exact specifications</li>
</ul>
</div>
</div>
</div>
<!-- Interactive Power Loss Diagram -->
<div class="bg-white rounded-xl shadow-md overflow-hidden mb-8 result-card">
<div class="p-6">
<h3 class="text-xl font-bold text-darkblue mb-4 flex items-center">
<i class="fas fa-chart-line text-electric mr-3"></i> Power Loss Analysis
</h3>
<div class="mb-6">
<div class="flex flex-col md:flex-row gap-4 mb-4">
<div class="w-full md:w-1/3">
<label class="block text-gray-700 font-medium mb-2" for="chart-type">
Chart Type
</label>
<select id="chart-type" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-electric focus:border-transparent input-highlight">
<option value="length">Power Loss vs Cable Length</option>
<option value="current">Power Loss vs Load Current</option>
<option value="voltage">Power Loss vs System Voltage</option>
</select>
</div>
<div class="w-full md:w-1/3">
<label class="block text-gray-700 font-medium mb-2" for="cable-size-chart">
Cable Size (mm²)
</label>
<select id="cable-size-chart" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-electric focus:border-transparent input-highlight">
<option value="35">35 mm²</option>
<option value="50">50 mm²</option>
<option value="70">70 mm²</option>
<option value="95">95 mm²</option>
<option value="120">120 mm²</option>
<option value="150">150 mm²</option>
<option value="185">185 mm²</option>
<option value="240">240 mm²</option>
</select>
</div>
<div class="w-full md:w-1/3">
<label class="block text-gray-700 font-medium mb-2" for="chart-method">
Installation Method
</label>
<select id="chart-method" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-electric focus:border-transparent input-highlight">
<option value="buried">Buried Direct</option>
<option value="duct">In Duct</option>
<option value="tray">Cable Tray</option>
<option value="air">In Air</option>
</select>
</div>
</div>
<button onclick="updatePowerLossChart()" class="gradient-bg text-white px-6 py-2 rounded-full font-semibold hover:opacity-90 transition flex items-center">
<i class="fas fa-sync-alt mr-2"></i> Update Chart
</button>
</div>
<div class="chart-container">
<canvas id="powerLossChart"></canvas>
</div>
<div class="mt-6 bg-gray-50 p-4 rounded-lg">
<h4 class="font-semibold text-gray-700 mb-2">Key Observations:</h4>
<ul class="list-disc pl-5 text-gray-600 space-y-1">
<li>Power losses increase <span class="font-semibold">quadratically</span> with current (P = I²R)</li>
<li>Higher voltage systems show <span class="font-semibold">lower percentage</span> power losses</li>
<li>Larger cable sizes reduce losses but increase <span class="font-semibold">initial cost</span></li>
<li>Buried cables typically have <span class="font-semibold">better cooling</span> than tray installations</li>
</ul>
</div>
</div>
</div>
</div>
<div class="bg-white rounded-xl shadow-md overflow-hidden">
<div class="p-6">
<h3 class="text-xl font-bold text-darkblue mb-4 flex items-center">
<i class="fas fa-info-circle text-electric mr-3"></i> Cable Sizing Guidelines
</h3>
<div class="space-y-4">
<div class="flex items-start">
<div class="bg-electric text-white rounded-full p-2 mr-4">
<i class="fas fa-1"></i>
</div>
<div>
<h4 class="font-semibold text-gray-800">Current Carrying Capacity</h4>
<p class="text-gray-600">The cable must be able to carry the maximum load current without exceeding temperature limits.</p>
</div>
</div>
<div class="flex items-start">
<div class="bg-electric text-white rounded-full p-2 mr-4">
<i class="fas fa-2"></i>
</div>
<div>
<h4 class="font-semibold text-gray-800">Voltage Drop</h4>
<p class="text-gray-600">Ensure voltage drop is within acceptable limits (typically 3-5% for distribution systems).</p>
</div>
</div>
<div class="flex items-start">
<div class="bg-electric text-white rounded-full p-2 mr-4">
<i class="fas fa-3"></i>
</div>
<div>
<h4 class="font-semibold text-gray-800">Short Circuit Withstand</h4>
<p class="text-gray-600">Cable must withstand short circuit currents for the duration of protection operation.</p>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Transformer Sizing Tab -->
<div id="transformer-tab" class="tab-content">
<div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
<div class="p-6">
<h2 class="text-2xl font-bold text-darkblue mb-4 flex items-center">
<i class="fas fa-transformer text-electric mr-3"></i> Measurement Transformer Sizing
</h2>
<p class="text-gray-600 mb-6">Calculate the appropriate current and voltage transformer specifications for your protection and metering needs.</p>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<div class="mb-6">
<label class="block text-gray-700 font-medium mb-2" for="transformer-type">
Transformer Type
</label>
<select id="transformer-type" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-electric focus:border-transparent input-highlight">
<option value="current">Current Transformer (CT)</option>
<option value="voltage">Voltage Transformer (VT)</option>
</select>
</div>
<div class="mb-6">
<label class="block text-gray-700 font-medium mb-2" for="primary-value">
Primary Value
</label>
<div class="flex">
<input type="number" id="primary-value" class="w-full px-4 py-3 rounded-l-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-electric focus:border-transparent input-highlight" placeholder="e.g. 100">
<span id="primary-unit" class="bg-gray-200 px-4 py-3 rounded-r-lg border border-l-0 border-gray-300">A</span>
</div>
</div>
<div class="mb-6">
<label class="block text-gray-700 font-medium mb-2" for="secondary-value">
Secondary Value
</label>
<div class="flex">
<input type="number" id="secondary-value" class="w-full px-4 py-3 rounded-l-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-electric focus:border-transparent input-highlight" placeholder="e.g. 1 or 5">
<span id="secondary-unit" class="bg-gray-200 px-4 py-3 rounded-r-lg border border-l-0 border-gray-300">A</span>
</div>
</div>
</div>
<div>
<div class="mb-6">
<label class="block text-gray-700 font-medium mb-2" for="accuracy-class">
Accuracy Class
</label>
<select id="accuracy-class" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-electric focus:border-transparent input-highlight">
<option value="0.1">0.1 (Metering)</option>
<option value="0.2">0.2 (Metering)</option>
<option value="0.5">0.5 (Metering)</option>
<option value="1">1 (General Purpose)</option>
<option value="3">3 (Protection)</option>
<option value="5">5 (Protection)</option>
<option value="10">10 (Protection)</option>
</select>
</div>
<div class="mb-6">
<label class="block text-gray-700 font-medium mb-2" for="burden">
Burden (VA)
</label>
<input type="number" id="burden" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-electric focus:border-transparent input-highlight" placeholder="e.g. 15">
</div>
<div class="mb-6">
<label class="block text-gray-700 font-medium mb-2" for="application">
Application
</label>
<select id="application" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-electric focus:border-transparent input-highlight">
<option value="metering">Metering</option>
<option value="protection">Protection</option>
<option value="both">Both (Metering & Protection)</option>
</select>
</div>
</div>
</div>
<div class="flex justify-center mt-6">
<button onclick="calculateTransformer()" class="gradient-bg text-white px-8 py-3 rounded-full font-semibold hover:opacity-90 transition flex items-center">
<i class="fas fa-calculator mr-2"></i> Calculate Transformer
</button>
</div>
</div>
</div>
<div id="transformer-results" class="hidden">
<div class="bg-white rounded-xl shadow-md overflow-hidden mb-8 result-card">
<div class="p-6">
<h3 class="text-xl font-bold text-darkblue mb-4 flex items-center">
<i class="fas fa-file-alt text-electric mr-3"></i> Transformer Sizing Results
</h3>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
<div class="bg-gray-50 p-4 rounded-lg">
<p class="text-gray-600 font-medium">Ratio</p>
<p id="transformer-ratio" class="text-2xl font-bold text-electric">--</p>
</div>
<div class="bg-gray-50 p-4 rounded-lg">
<p class="text-gray-600 font-medium">Accuracy Class</p>
<p id="result-accuracy" class="text-2xl font-bold text-electric">--</p>
</div>
<div class="bg-gray-50 p-4 rounded-lg">
<p class="text-gray-600 font-medium">Burden</p>
<p id="result-burden" class="text-2xl font-bold text-electric">-- VA</p>
</div>
</div>
<div class="mb-4">
<h4 class="font-semibold text-gray-700 mb-2">Specifications:</h4>
<div class="bg-gray-50 p-4 rounded-lg">
<div class="grid grid-cols-2 gap-4">
<div>
<p class="text-gray-600">Type: <span id="transformer-type-result" class="font-medium">--</span></p>
<p class="text-gray-600">Application: <span id="transformer-application" class="font-medium">--</span></p>
</div>
<div>
<p class="text-gray-600">Primary: <span id="transformer-primary" class="font-medium">--</span></p>
<p class="text-gray-600">Secondary: <span id="transformer-secondary" class="font-medium">--</span></p>
</div>
</div>
</div>
</div>
<div class="mt-6">
<h4 class="font-semibold text-gray-700 mb-2">Recommendations:</h4>
<ul class="list-disc pl-5 text-gray-600 space-y-1">
<li>Verify short-time current rating matches system fault levels</li>
<li>Consider using dual-core CTs for metering and protection</li>
<li>Ensure burden doesn't exceed transformer rating</li>
<li>Check compliance with IEC 60044 standards</li>
</ul>
</div>
</div>
</div>
</div>
<div class="bg-white rounded-xl shadow-md overflow-hidden">
<div class="p-6">
<h3 class="text-xl font-bold text-darkblue mb-4 flex items-center">
<i class="fas fa-info-circle text-electric mr-3"></i> Transformer Selection Guidelines
</h3>
<div class="space-y-4">
<div class="flex items-start">
<div class="bg-electric text-white rounded-full p-2 mr-4">
<i class="fas fa-bolt"></i>
</div>
<div>
<h4 class="font-semibold text-gray-800">Current Transformers (CTs)</h4>
<p class="text-gray-600">Select CTs based on primary current, accuracy class, burden, and application (metering or protection).</p>
</div>
</div>
<div class="flex items-start">
<div class="bg-electric text-white rounded-full p-2 mr-4">
<i class="fas fa-charging-station"></i>
</div>
<div>
<h4 class="font-semibold text-gray-800">Voltage Transformers (VTs)</h4>
<p class="text-gray-600">Choose VTs based on system voltage, accuracy requirements, and burden of connected instruments.</p>
</div>
</div>
<div class="flex items-start">
<div class="bg-electric text-white rounded-full p-2 mr-4">
<i class="fas fa-exclamation-triangle"></i>
</div>
<div>
<h4 class="font-semibold text-gray-800">Safety Considerations</h4>
<p class="text-gray-600">Never open-circuit a CT secondary circuit or short-circuit a VT secondary circuit.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<footer class="gradient-bg text-white py-8">
<div class="container mx-auto px-4">
<div class="flex flex-col md:flex-row justify-between items-center">
<div class="mb-4 md:mb-0">
<h3 class="text-xl font-bold mb-2">MV Power Sizing Tool</h3>
<p class="text-sm opacity-80">Professional tool for medium voltage electrical design</p>
</div>
<div class="flex space-x-4">
<a href="#" class="text-white hover:text-gray-200 transition">
<i class="fab fa-github text-xl"></i>
</a>
<a href="#" class="text-white hover:text-gray-200 transition">
<i class="fab fa-linkedin text-xl"></i>
</a>
<a href="#" class="text-white hover:text-gray-200 transition">
<i class="fas fa-envelope text-xl"></i>
</a>
</div>
</div>
<div class="border-t border-white border-opacity-20 mt-6 pt-6 text-sm text-center opacity-80">
<p>© 2023 MV Power Sizing Tool. All calculations are based on IEC standards.</p>
<p class="mt-1">For professional engineering verification only.</p>
</div>
</div>
</footer>
<script>
// Tab switching functionality
function switchTab(tabName) {
// Hide all tab contents
document.querySelectorAll('.tab-content').forEach(tab => {
tab.classList.remove('active');
});
// Show selected tab
document.getElementById(`${tabName}-tab`).classList.add('active');
// Update tab buttons
document.querySelectorAll('.tab-btn').forEach(btn => {
if (btn.textContent.includes(tabName.charAt(0).toUpperCase() + tabName.slice(1))) {
btn.classList.remove('bg-transparent', 'border-white', 'text-white');
btn.classList.add('bg-white', 'text-powerblue');
} else {
btn.classList.remove('bg-white', 'text-powerblue');
btn.classList.add('bg-transparent', 'border-white', 'text-white');
}
});
}
// Update transformer units based on type
document.getElementById('transformer-type').addEventListener('change', function() {
const type = this.value;
const primaryUnit = document.getElementById('primary-unit');
const secondaryUnit = document.getElementById('secondary-unit');
if (type === 'current') {
primaryUnit.textContent = 'A';
secondaryUnit.textContent = 'A';
} else {
primaryUnit.textContent = 'kV';
secondaryUnit.textContent = 'V';
}
});
// Cable sizing calculation
function calculateCableSize() {
// Get input values
const voltage = parseFloat(document.getElementById('system-voltage').value);
const current = parseFloat(document.getElementById('load-current').value);
const length = parseFloat(document.getElementById('cable-length').value);
const method = document.getElementById('installation-method').value;
const soilResistivity = parseFloat(document.getElementById('soil-resistivity').value);
const ambientTemp = parseFloat(document.getElementById('ambient-temp').value);
// Validate inputs
if (isNaN(current) || isNaN(length)) {
alert('Please enter valid numbers for load current and cable length');
return;
}
// Simplified calculation (real implementation would use detailed tables)
let recommendedSize;
let currentCapacity;
let voltageDrop;
if (current <= 100) {
recommendedSize = 35;
currentCapacity = 140;
voltageDrop = 1.2;
} else if (current <= 150) {
recommendedSize = 50;
currentCapacity = 170;
voltageDrop = 0.9;
} else if (current <= 200) {
recommendedSize = 70;
currentCapacity = 210;
voltageDrop = 0.7;
} else if (current <= 250) {
recommendedSize = 95;
currentCapacity = 250;
voltageDrop = 0.5;
} else {
recommendedSize = 120;
currentCapacity = 290;
voltageDrop = 0.4;
}
// Apply derating factors
let deratingFactor = 1.0;
// Installation method derating
if (method === 'buried') deratingFactor *= 0.9;
else if (method === 'duct') deratingFactor *= 0.85;
else if (method === 'tray') deratingFactor *= 0.8;
else if (method === 'ladder') deratingFactor *= 0.75;
// Soil resistivity derating
if (soilResistivity > 1.0) deratingFactor *= (1.0 / soilResistivity);
// Ambient temperature derating
if (ambientTemp > 20) deratingFactor *= (1.0 - (ambientTemp - 20) * 0.005);
// Apply derating
currentCapacity = Math.round(currentCapacity * deratingFactor);
// Adjust voltage drop for length
voltageDrop = (voltageDrop * length / 100).toFixed(2);
// Display results
document.getElementById('recommended-size').textContent = recommendedSize + ' mm²';
document.getElementById('current-capacity').textContent = currentCapacity + ' A';
document.getElementById('voltage-drop').textContent = voltageDrop + ' %';
// Set cable specifications based on voltage
document.getElementById('cable-type').textContent = voltage >= 22 ? 'XLPE/SWA/PVC' : 'XLPE/PVC';
document.getElementById('cable-insulation').textContent = 'XLPE';
document.getElementById('cable-sheath').textContent = voltage >= 22 ? 'PVC' : 'LSZH';
document.getElementById('cable-conductor').textContent = 'Copper';
// Show results
document.getElementById('cable-results').classList.remove('hidden');
// Initialize power loss chart
initializePowerLossChart();
// Scroll to results
document.getElementById('cable-results').scrollIntoView({ behavior: 'smooth' });
}
// Transformer calculation
function calculateTransformer() {
// Get input values
const type = document.getElementById('transformer-type').value;
const primary = parseFloat(document.getElementById('primary-value').value);
const secondary = parseFloat(document.getElementById('secondary-value').value);
const accuracy = document.getElementById('accuracy-class').value;
const burden = parseFloat(document.getElementById('burden').value);
const application = document.getElementById('application').value;
// Validate inputs
if (isNaN(primary) || isNaN(secondary) || isNaN(burden)) {
alert('Please enter valid numbers for primary, secondary and burden values');
return;
}
// Calculate ratio
const ratio = `${primary}${type === 'current' ? 'A' : 'kV'}/${secondary}${type === 'current' ? 'A' : 'V'}`;
// Display results
document.getElementById('transformer-ratio').textContent = ratio;
document.getElementById('result-accuracy').textContent = accuracy;
document.getElementById('result-burden').textContent = burden + ' VA';
// Set transformer specifications
document.getElementById('transformer-type-result').textContent =
type === 'current' ? 'Current Transformer (CT)' : 'Voltage Transformer (VT)';
document.getElementById('transformer-application').textContent =
application.charAt(0).toUpperCase() + application.slice(1);
document.getElementById('transformer-primary').textContent =
primary + (type === 'current' ? 'A' : 'kV');
document.getElementById('transformer-secondary').textContent =
secondary + (type === 'current' ? 'A' : 'V');
// Show results
document.getElementById('transformer-results').classList.remove('hidden');
// Scroll to results
document.getElementById('transformer-results').scrollIntoView({ behavior: 'smooth' });
}
// Power Loss Chart Variables
let powerLossChart;
// Initialize Power Loss Chart
function initializePowerLossChart() {
const ctx = document.getElementById('powerLossChart').getContext('2d');
// Destroy previous chart if it exists
if (powerLossChart) {
powerLossChart.destroy();
}
// Create new chart
powerLossChart = new Chart(ctx, {
type: 'line',
data: {
labels: generateChartLabels(),
datasets: [{
label: 'Power Loss (kW)',
data: generatePowerLossData(),
backgroundColor: 'rgba(0, 180, 216, 0.2)',
borderColor: 'rgba(0, 180, 216, 1)',
borderWidth: 2,
tension: 0.4,
fill: true
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
title: {
display: true,
text: getChartTitle(),
font: {
size: 16,
weight: 'bold'
}
},
tooltip: {
callbacks: {
label: function(context) {
return `Power Loss: ${context.parsed.y.toFixed(2)} kW`;
}
}
},
legend: {
display: false
}
},
scales: {
x: {
title: {
display: true,
text: getXAxisLabel(),
font: {
weight: 'bold'
}
}
},
y: {
title: {
display: true,
text: 'Power Loss (kW)',
font: {
weight: 'bold'
}
},
min: 0
}
}
}
});
}
// Update Power Loss Chart
function updatePowerLossChart() {
if (!powerLossChart) {
initializePowerLossChart();
return;
}
// Update chart data
powerLossChart.data.labels = generateChartLabels();
powerLossChart.data.datasets[0].data = generatePowerLossData();
powerLossChart.options.plugins.title.text = getChartTitle();
powerLossChart.options.scales.x.title.text = getXAxisLabel();
// Update chart
powerLossChart.update();
}
// Generate chart labels based on selected chart type
function generateChartLabels() {
const chartType = document.getElementById('chart-type').value;
if (chartType === 'length') {
return Array.from({length: 10}, (_, i) => (i + 1) * 100); // 100m to 1000m in 100m steps
} else if (chartType === 'current') {
return Array.from({length: 10}, (_, i) => (i + 1) * 25); // 25A to 250A in 25A steps
} else { // voltage
return [3.3, 6.6, 11, 22, 33]; // Common MV voltages
}
}
// Generate power loss data based on current inputs
function generatePowerLossData() {
const chartType = document.getElementById('chart-type').value;
const cableSize = parseFloat(document.getElementById('cable-size-chart').value);
const installationMethod = document.getElementById('chart-method').value;
const baseCurrent = parseFloat(document.getElementById('load-current').value) || 100;
const baseLength = parseFloat(document.getElementById('cable-length').value) || 100;
const baseVoltage = parseFloat(document.getElementById('system-voltage').value) || 11;
// Get resistance per km based on cable size (simplified)
const resistancePerKm = getResistanceForSize(cableSize);
// Get derating factor based on installation method
const deratingFactor = getDeratingFactor(installationMethod);
return generateChartLabels().map(value => {
let current, length, voltage;
if (chartType === 'length') {
current = baseCurrent;
length = value;
voltage = baseVoltage;
} else if (chartType === 'current') {
current = value;
length = baseLength;
voltage = baseVoltage;
} else { // voltage
current = baseCurrent;
length = baseLength;
voltage = value;
}
// Calculate power loss (P = I²R)
const resistance = (resistancePerKm * length / 1000) * deratingFactor;
const powerLoss = Math.pow(current, 2) * resistance / 1000; // in kW
return powerLoss;
});
}
// Get resistance for cable size (Ω/km)
function getResistanceForSize(size) {
// Simplified resistance values for copper conductors at 20°C
const resistances = {
35: 0.524,
50: 0.387,
70: 0.268,
95: 0.193,
120: 0.153,
150: 0.124,
185: 0.099,
240: 0.075
};
return resistances[size] || 0.524;
}
// Get derating factor for installation method
function getDeratingFactor(method) {
const factors = {
'buried': 1.0,
'duct': 1.1,
'tray': 1.2,
'air': 1.15
};
return factors[method] || 1.0;
}
// Get chart title based on selected type
function getChartTitle() {
const chartType = document.getElementById('chart-type').value;
const cableSize = document.getElementById('cable-size-chart').value;
if (chartType === 'length') {
return `Power Loss vs Cable Length (${cableSize}mm²)`;
} else if (chartType === 'current') {
return `Power Loss vs Load Current (${cableSize}mm²)`;
} else {
return `Power Loss vs System Voltage (${cableSize}mm²)`;
}
}
// Get X-axis label based on selected type
function getXAxisLabel() {
const chartType = document.getElementById('chart-type').value;
if (chartType === 'length') {
return 'Cable Length (m)';
} else if (chartType === 'current') {
return 'Load Current (A)';
} else {
return 'System Voltage (kV)';
}
}
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=acwk/test" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>