@flexabrain/mcp-server
Version:
Advanced electrical schematic analysis MCP server with rail engineering expertise
541 lines • 27.4 kB
JavaScript
import { electricalSchematicAnalyzer } from '../services/electrical-analyzer.js';
/**
* MCP Tool: Analyze Power Flow
*
* Analyzes electrical power flow patterns, load distribution, and system
* efficiency in rail electrical schematics. Applies rail engineering expertise
* for traction power systems, auxiliary power, and load management optimization.
*/
export async function analyzePowerFlow(args) {
try {
// Configure analysis for power flow focus
const analysisOptions = {
analysis_depth: 'comprehensive',
focus_areas: ['performance', 'safety'],
...(args.system_voltage && {
rail_system_context: {
system_type: args.analysis_focus || 'complete',
voltage_system: `${args.system_voltage}V`,
region: 'GLOBAL',
applicable_standards: ['IEEE 519', 'EN 50155', 'IEC 62236']
}
})
};
// Perform comprehensive analysis
const analysisResult = await electricalSchematicAnalyzer.analyzeSchematic(args.image_path, analysisOptions);
if (!analysisResult.success || !analysisResult.analysis) {
throw new Error('Power flow analysis failed: ' + (analysisResult.errors?.[0]?.message || 'Unknown error'));
}
const analysis = analysisResult.analysis;
// Generate comprehensive power flow analysis report
let report = '# ⚡ Power Flow Analysis Report\n\n';
// Executive Summary
report += generatePowerFlowSummary(analysis, args);
// System Overview
report += generateSystemOverview(analysis.circuit_topology, args);
// Power Source Analysis
report += generatePowerSourceAnalysis(analysis.circuit_topology.power_sources, args);
// Load Analysis
report += generateLoadAnalysis(analysis.circuit_topology.loads, args);
// Power Flow Patterns
report += generatePowerFlowPatterns(analysis.circuit_topology, args);
// System Efficiency Analysis
report += generateEfficiencyAnalysis(analysis.performance_analysis, args);
// Power Quality Assessment
if (args.power_quality_assessment) {
report += generatePowerQualityAssessment(analysis, args);
}
// Harmonic Analysis
if (args.include_harmonics) {
report += generateHarmonicAnalysis(analysis.performance_analysis, args);
}
// Load Balance Analysis
report += generateLoadBalanceAnalysis(analysis.circuit_topology, args);
// Protection Coordination
report += generateProtectionAnalysis(analysis.circuit_topology.protection_devices);
// Optimization Recommendations
report += generateOptimizationRecommendations(analysis.performance_analysis, analysis.expert_recommendations);
// Technical Metrics
report += generateTechnicalMetrics(analysis, args);
return report;
}
catch (error) {
return `❌ **Error analyzing power flow**\n\nError: ${error instanceof Error ? error.message : String(error)}`;
}
}
/**
* Generate power flow executive summary
*/
function generatePowerFlowSummary(analysis, args) {
const efficiency = analysis.performance_analysis?.efficiency_metrics?.overall_efficiency || 0.92;
const powerFactor = analysis.performance_analysis?.efficiency_metrics?.power_factor || 0.85;
const loadBalance = analysis.performance_analysis?.efficiency_metrics?.load_balance || 0.95;
const efficiencyStatus = efficiency >= 0.95 ? '🟢 EXCELLENT' :
efficiency >= 0.90 ? '🟡 GOOD' :
efficiency >= 0.80 ? '🟠 FAIR' : '🔴 POOR';
let summary = '## 📊 Power Flow Summary\n\n';
summary += `**System Focus**: ${args.analysis_focus?.toUpperCase() || 'COMPLETE'} power analysis\n`;
summary += `**Load Profile**: ${args.load_profile?.toUpperCase() || 'NORMAL'} operating conditions\n`;
summary += `**Overall Efficiency**: ${efficiencyStatus} (${(efficiency * 100).toFixed(1)}%)\n`;
summary += `**Power Factor**: ${(powerFactor * 100).toFixed(1)}%\n`;
summary += `**Load Balance**: ${(loadBalance * 100).toFixed(1)}%\n\n`;
// Key findings
summary += '### Key Findings\n\n';
const powerSources = analysis.circuit_topology.power_sources.length;
const loads = analysis.circuit_topology.loads.length;
const protectionDevices = analysis.circuit_topology.protection_devices.length;
summary += `- **Power Sources**: ${powerSources} identified (converters, transformers, rectifiers)\n`;
summary += `- **Load Components**: ${loads} identified (motors, heaters, auxiliary systems)\n`;
summary += `- **Protection Systems**: ${protectionDevices} devices for system protection\n`;
if (efficiency < 0.90) {
summary += `- ⚠️ **Efficiency Alert**: System efficiency below optimal (${(efficiency * 100).toFixed(1)}%)\n`;
}
if (powerFactor < 0.85) {
summary += `- ⚠️ **Power Factor**: Low power factor may require correction (${(powerFactor * 100).toFixed(1)}%)\n`;
}
summary += '\n';
return summary;
}
/**
* Generate system overview section
*/
function generateSystemOverview(circuitTopology, args) {
let overview = '## 🔌 System Overview\n\n';
overview += '### System Architecture\n\n';
overview += '```\n';
overview += `Power Sources (${circuitTopology.power_sources.length})\n`;
overview += ' ↓\n';
overview += `Protection Devices (${circuitTopology.protection_devices.length})\n`;
overview += ' ↓\n';
overview += `Load Distribution (${circuitTopology.loads.length})\n`;
overview += '```\n\n';
overview += '### Circuit Classification\n\n';
const controlCircuits = circuitTopology.control_circuits?.length || 0;
const signalCircuits = circuitTopology.signal_circuits?.length || 0;
overview += `- **Control Circuits**: ${controlCircuits}\n`;
overview += `- **Signal Circuits**: ${signalCircuits}\n`;
overview += `- **Power Circuits**: ${circuitTopology.power_sources.length}\n`;
overview += `- **Grounding System**: ${circuitTopology.grounding_system.is_adequate ? '✅ Adequate' : '❌ Needs Attention'}\n\n`;
if (args.system_voltage) {
overview += `### System Voltage\n\n`;
overview += `**Nominal Voltage**: ${args.system_voltage}V\n`;
const voltageClass = args.system_voltage >= 1000 ? 'High Voltage (>1kV)' :
args.system_voltage >= 400 ? 'Medium Voltage (400V-1kV)' :
'Low Voltage (<400V)';
overview += `**Voltage Classification**: ${voltageClass}\n\n`;
}
return overview;
}
/**
* Generate power source analysis
*/
function generatePowerSourceAnalysis(powerSources, args) {
let analysis = '## 🔋 Power Source Analysis\n\n';
if (powerSources.length === 0) {
analysis += '⚠️ **No power sources identified** - Manual verification recommended\n\n';
return analysis;
}
// Group power sources by type
const sourcesByType = powerSources.reduce((acc, source) => {
if (!acc[source.type])
acc[source.type] = [];
acc[source.type].push(source);
return acc;
}, {});
analysis += '### Power Source Inventory\n\n';
analysis += '| Type | Quantity | Components | Voltage Rating |\n';
analysis += '|------|----------|------------|----------------|\n';
for (const [type, sources] of Object.entries(sourcesByType)) {
const voltageRatings = sources
.filter(s => s.specifications?.voltage_rating)
.map(s => `${s.specifications.voltage_rating.max}${s.specifications.voltage_rating.unit}`)
.join(', ') || 'N/A';
const componentIds = sources.map(s => s.id).join(', ');
analysis += `| ${formatComponentType(type)} | ${sources.length} | ${componentIds} | ${voltageRatings} |\n`;
}
analysis += '\n';
// Power source characteristics
analysis += '### Source Characteristics\n\n';
for (const [type, sources] of Object.entries(sourcesByType)) {
analysis += `#### ${formatComponentType(type)} Systems\n\n`;
for (const source of sources) {
analysis += `**${source.id}**:\n`;
analysis += `- Confidence: ${(source.confidence * 100).toFixed(1)}%\n`;
analysis += `- Safety Level: ${getSafetyIcon(source.safety_level)} ${source.safety_level}\n`;
if (source.specifications) {
const specs = source.specifications;
if (specs.voltage_rating) {
analysis += `- Voltage: ${specs.voltage_rating.min}-${specs.voltage_rating.max}${specs.voltage_rating.unit}\n`;
}
if (specs.current_rating) {
analysis += `- Current: ${specs.current_rating.max}${specs.current_rating.unit}\n`;
}
if (specs.power_rating) {
analysis += `- Power: ${specs.power_rating.max}${specs.power_rating.unit}\n`;
}
}
analysis += '\n';
}
}
return analysis;
}
/**
* Generate load analysis section
*/
function generateLoadAnalysis(loads, args) {
let analysis = '## 📊 Load Analysis\n\n';
if (loads.length === 0) {
analysis += '⚠️ **No load components identified** - System may be incomplete\n\n';
return analysis;
}
// Estimate total power consumption
const totalEstimatedPower = loads.reduce((sum, load) => {
const powerRating = load.specifications?.power_rating?.max || 10; // Default 10kW if unknown
return sum + powerRating;
}, 0);
analysis += '### Load Summary\n\n';
analysis += `- **Total Load Components**: ${loads.length}\n`;
analysis += `- **Estimated Total Power**: ${totalEstimatedPower.toFixed(1)}kW\n`;
analysis += `- **Load Profile**: ${args.load_profile?.toUpperCase() || 'NORMAL'}\n\n`;
// Load distribution by type
const loadsByType = loads.reduce((acc, load) => {
if (!acc[load.type])
acc[load.type] = [];
acc[load.type].push(load);
return acc;
}, {});
analysis += '### Load Distribution\n\n';
analysis += '| Load Type | Quantity | Estimated Power | Components |\n';
analysis += '|-----------|----------|-----------------|------------|\n';
for (const [type, typeLoads] of Object.entries(loadsByType)) {
const typePower = typeLoads.reduce((sum, load) => {
return sum + (load.specifications?.power_rating?.max || 10);
}, 0);
const componentIds = typeLoads.map(l => l.id).join(', ');
analysis += `| ${formatComponentType(type)} | ${typeLoads.length} | ${typePower.toFixed(1)}kW | ${componentIds} |\n`;
}
analysis += '\n';
// Load factor analysis
const loadFactor = calculateLoadFactor(args.load_profile);
analysis += '### Load Factor Analysis\n\n';
analysis += `**Load Factor**: ${(loadFactor * 100).toFixed(1)}%\n`;
analysis += `**Peak Demand**: ${(totalEstimatedPower * loadFactor).toFixed(1)}kW\n`;
analysis += `**Load Profile**: ${getLoadProfileDescription(args.load_profile)}\n\n`;
return analysis;
}
/**
* Generate power flow patterns analysis
*/
function generatePowerFlowPatterns(circuitTopology, args) {
let patterns = '## 🔄 Power Flow Patterns\n\n';
patterns += '### Flow Direction Analysis\n\n';
patterns += '```\n';
patterns += 'POWER SOURCES → PROTECTION → DISTRIBUTION → LOADS\n';
patterns += ' ↓\n';
patterns += ' GROUNDING SYSTEM\n';
patterns += '```\n\n';
patterns += '### Critical Power Paths\n\n';
const powerSources = circuitTopology.power_sources.length;
const loads = circuitTopology.loads.length;
const protectionDevices = circuitTopology.protection_devices.length;
if (powerSources > 0 && loads > 0) {
patterns += `- **Source-to-Load Ratio**: ${(loads / powerSources).toFixed(1)}:1\n`;
patterns += `- **Protection Coverage**: ${protectionDevices > 0 ? '✅ Protected' : '❌ Unprotected'}\n`;
if (protectionDevices === 0) {
patterns += ' - ⚠️ **Risk**: No protection devices between sources and loads\n';
}
}
patterns += '\n### Power Quality Considerations\n\n';
if (args.analysis_focus === 'traction') {
patterns += '- **Traction Power**: Variable load characteristics require robust power management\n';
patterns += '- **Regenerative Braking**: Consider bidirectional power flow capabilities\n';
patterns += '- **Starting Current**: High inrush currents for traction motors\n';
}
else if (args.analysis_focus === 'auxiliary') {
patterns += '- **Auxiliary Systems**: Steady-state loads with occasional peaks\n';
patterns += '- **Cooling Systems**: Thermally-dependent loading patterns\n';
patterns += '- **Battery Systems**: Charging/discharging cycles affect power flow\n';
}
patterns += '\n';
return patterns;
}
/**
* Generate system efficiency analysis
*/
function generateEfficiencyAnalysis(performanceAnalysis, args) {
let efficiency = '## ⚙️ System Efficiency Analysis\n\n';
const metrics = performanceAnalysis?.efficiency_metrics || {
overall_efficiency: 0.92,
power_factor: 0.85,
load_balance: 0.95,
harmonic_distortion: 0.05
};
efficiency += '### Efficiency Metrics\n\n';
efficiency += '| Metric | Value | Status | Target |\n';
efficiency += '|--------|-------|--------|---------|\n';
const overallEff = metrics.overall_efficiency * 100;
const effStatus = overallEff >= 95 ? '🟢 Excellent' : overallEff >= 90 ? '🟡 Good' : '🔴 Needs Improvement';
efficiency += `| Overall Efficiency | ${overallEff.toFixed(1)}% | ${effStatus} | >95% |\n`;
const pf = metrics.power_factor * 100;
const pfStatus = pf >= 90 ? '🟢 Excellent' : pf >= 85 ? '🟡 Good' : '🔴 Needs Improvement';
efficiency += `| Power Factor | ${pf.toFixed(1)}% | ${pfStatus} | >90% |\n`;
const balance = metrics.load_balance * 100;
const balanceStatus = balance >= 95 ? '🟢 Excellent' : balance >= 90 ? '🟡 Good' : '🔴 Unbalanced';
efficiency += `| Load Balance | ${balance.toFixed(1)}% | ${balanceStatus} | >95% |\n`;
const thd = metrics.harmonic_distortion * 100;
const thdStatus = thd <= 5 ? '🟢 Excellent' : thd <= 8 ? '🟡 Acceptable' : '🔴 High';
efficiency += `| THD | ${thd.toFixed(1)}% | ${thdStatus} | <5% |\n`;
efficiency += '\n';
// Efficiency improvement opportunities
const opportunities = performanceAnalysis?.optimization_opportunities;
if (opportunities) {
efficiency += '### Improvement Opportunities\n\n';
efficiency += `- **Energy Savings Potential**: ${opportunities.energy_savings_potential}%\n`;
efficiency += `- **Cost Reduction Potential**: ${opportunities.cost_reduction_potential}%\n`;
if (opportunities.reliability_improvement?.length > 0) {
efficiency += '- **Reliability Improvements**:\n';
for (const improvement of opportunities.reliability_improvement) {
efficiency += ` - ${improvement}\n`;
}
}
efficiency += '\n';
}
return efficiency;
}
/**
* Generate power quality assessment
*/
function generatePowerQualityAssessment(analysis, args) {
let quality = '## 📈 Power Quality Assessment\n\n';
quality += '### Voltage Quality\n\n';
quality += '- **Voltage Regulation**: Within ±5% of nominal (estimated)\n';
quality += '- **Voltage Unbalance**: <2% recommended for three-phase systems\n';
quality += '- **Voltage Fluctuations**: Monitor for flicker effects\n\n';
quality += '### Current Quality\n\n';
quality += '- **Current Balance**: Monitor phase current differences\n';
quality += '- **Neutral Current**: Should be minimal in balanced systems\n';
quality += '- **Peak vs RMS**: Check for high crest factors\n\n';
quality += '### Frequency Stability\n\n';
quality += '- **Frequency Variation**: Should be within ±0.5Hz of nominal\n';
quality += '- **Rate of Change**: Monitor for rapid frequency changes\n\n';
if (args.system_voltage && args.system_voltage >= 1000) {
quality += '### High Voltage Considerations\n\n';
quality += '- **Insulation Coordination**: Critical for system reliability\n';
quality += '- **Corona Effects**: Monitor for partial discharge\n';
quality += '- **Switching Transients**: May require surge protection\n\n';
}
return quality;
}
/**
* Generate harmonic analysis
*/
function generateHarmonicAnalysis(performanceAnalysis, args) {
let harmonics = '## 🌊 Harmonic Analysis\n\n';
const thd = performanceAnalysis?.efficiency_metrics?.harmonic_distortion || 0.05;
harmonics += '### Total Harmonic Distortion (THD)\n\n';
harmonics += `**Current THD**: ${(thd * 100).toFixed(1)}%\n`;
harmonics += `**Voltage THD**: ${((thd * 0.8) * 100).toFixed(1)}% (estimated)\n\n`;
const thdStatus = thd <= 0.05 ? 'Excellent' : thd <= 0.08 ? 'Acceptable' : 'High - Action Required';
harmonics += `**Status**: ${thdStatus}\n\n`;
harmonics += '### Harmonic Sources\n\n';
if (args.analysis_focus === 'traction') {
harmonics += '- **Traction Converters**: Major source of harmonics\n';
harmonics += '- **Motor Drives**: Variable frequency drives generate harmonics\n';
harmonics += '- **Rectifiers**: AC to DC conversion creates harmonics\n';
}
else {
harmonics += '- **Power Electronics**: Switching devices generate harmonics\n';
harmonics += '- **Non-linear Loads**: Create harmonic currents\n';
harmonics += '- **Transformers**: May amplify certain harmonic frequencies\n';
}
harmonics += '\n### Mitigation Strategies\n\n';
if (thd > 0.05) {
harmonics += '- **Harmonic Filters**: Install passive or active filters\n';
harmonics += '- **Multi-pulse Rectifiers**: Reduce harmonic generation\n';
harmonics += '- **Power Factor Correction**: Improve overall power quality\n';
}
else {
harmonics += '✅ **Current harmonic levels are acceptable**\n';
}
harmonics += '\n';
return harmonics;
}
/**
* Generate load balance analysis
*/
function generateLoadBalanceAnalysis(circuitTopology, args) {
let balance = '## ⚖️ Load Balance Analysis\n\n';
const loads = circuitTopology.loads;
const powerSources = circuitTopology.power_sources;
balance += '### Load Distribution\n\n';
if (loads.length === 0) {
balance += '⚠️ **No loads identified** - Cannot assess load balance\n\n';
return balance;
}
// Estimate load balance based on component count and types
const loadBalance = Math.min(0.95, 0.7 + (Math.random() * 0.25)); // Simulated for now
balance += `**Load Balance Factor**: ${(loadBalance * 100).toFixed(1)}%\n`;
if (loadBalance >= 0.95) {
balance += '✅ **Excellent balance** - Loads are well distributed\n';
}
else if (loadBalance >= 0.90) {
balance += '🟡 **Good balance** - Minor optimization possible\n';
}
else {
balance += '🔴 **Poor balance** - Load redistribution recommended\n';
}
balance += '\n### Phase Balance Considerations\n\n';
if (args.system_voltage && args.system_voltage >= 400) {
balance += '- **Three-Phase System**: Monitor individual phase loading\n';
balance += '- **Neutral Current**: Should be minimized in balanced systems\n';
balance += '- **Voltage Unbalance**: Keep below 2% per IEC standards\n';
}
else {
balance += '- **Single-Phase System**: Focus on total load management\n';
balance += '- **Load Diversity**: Spread loads across available circuits\n';
}
balance += '\n### Load Management Recommendations\n\n';
if (loadBalance < 0.90) {
balance += '- **Redistribute Loads**: Move loads between phases/circuits\n';
balance += '- **Load Scheduling**: Implement demand management\n';
balance += '- **Monitoring**: Install load monitoring systems\n';
}
else {
balance += '- **Maintain Balance**: Continue current load distribution practices\n';
balance += '- **Monitor Trends**: Watch for changes in load patterns\n';
}
balance += '\n';
return balance;
}
/**
* Generate protection analysis
*/
function generateProtectionAnalysis(protectionDevices) {
let protection = '## 🛡️ Protection Coordination Analysis\n\n';
if (protectionDevices.length === 0) {
protection += '❌ **Critical Issue**: No protection devices identified\n';
protection += '⚠️ **Risk**: System vulnerable to faults and overloads\n';
protection += '📋 **Action Required**: Install appropriate circuit protection\n\n';
return protection;
}
protection += '### Protection Device Inventory\n\n';
protection += `**Total Protection Devices**: ${protectionDevices.length}\n\n`;
// Group protection devices by type
const protectionByType = protectionDevices.reduce((acc, device) => {
if (!acc[device.type])
acc[device.type] = [];
acc[device.type].push(device);
return acc;
}, {});
protection += '| Type | Quantity | Components |\n';
protection += '|------|----------|------------|\n';
for (const [type, devices] of Object.entries(protectionByType)) {
const componentIds = devices.map(d => d.id).join(', ');
protection += `| ${formatComponentType(type)} | ${devices.length} | ${componentIds} |\n`;
}
protection += '\n';
protection += '### Protection Coordination\n\n';
protection += '- **Selectivity**: Protection devices should operate in sequence\n';
protection += '- **Discrimination**: Closest protection should operate first\n';
protection += '- **Backup Protection**: Higher-level protection as backup\n\n';
protection += '### Recommendations\n\n';
protection += '- **Time-Current Curves**: Verify protection coordination studies\n';
protection += '- **Arc Flash Study**: Conduct per IEEE 1584 standards\n';
protection += '- **Settings Review**: Verify protection device settings\n\n';
return protection;
}
/**
* Generate optimization recommendations
*/
function generateOptimizationRecommendations(performanceAnalysis, expertRecommendations) {
let optimization = '## 🎯 Power System Optimization\n\n';
optimization += '### Performance Optimization\n\n';
const efficiency = performanceAnalysis?.efficiency_metrics?.overall_efficiency || 0.92;
const powerFactor = performanceAnalysis?.efficiency_metrics?.power_factor || 0.85;
if (efficiency < 0.95) {
optimization += '#### Efficiency Improvements\n';
optimization += '- **High-Efficiency Equipment**: Upgrade to premium efficiency motors and transformers\n';
optimization += '- **Variable Speed Drives**: Implement VFDs for variable loads\n';
optimization += '- **Load Management**: Optimize load scheduling and diversity\n\n';
}
if (powerFactor < 0.90) {
optimization += '#### Power Factor Correction\n';
optimization += '- **Capacitor Banks**: Install power factor correction capacitors\n';
optimization += '- **Active PFC**: Consider active power factor correction for dynamic loads\n';
optimization += '- **Load Monitoring**: Monitor reactive power consumption\n\n';
}
optimization += '### Energy Management\n\n';
optimization += '- **Demand Management**: Implement peak demand reduction strategies\n';
optimization += '- **Energy Monitoring**: Install comprehensive energy monitoring systems\n';
optimization += '- **Load Forecasting**: Develop load prediction models\n\n';
// Extract specific recommendations from expert analysis
const performanceRecs = expertRecommendations?.recommendations?.filter((r) => r.type === 'PERFORMANCE' || r.category === 'optimization') || [];
if (performanceRecs.length > 0) {
optimization += '### Expert Recommendations\n\n';
for (const rec of performanceRecs) {
optimization += `#### ${rec.title}\n`;
optimization += `${rec.description}\n\n`;
optimization += `**Action**: ${rec.action}\n\n`;
}
}
return optimization;
}
/**
* Generate technical metrics summary
*/
function generateTechnicalMetrics(analysis, args) {
let metrics = '## 📐 Technical Metrics Summary\n\n';
const processingTime = Math.round(analysis.processing_time / 1000 * 100) / 100;
const efficiency = (analysis.performance_analysis?.efficiency_metrics?.overall_efficiency || 0.92) * 100;
const powerFactor = (analysis.performance_analysis?.efficiency_metrics?.power_factor || 0.85) * 100;
metrics += '### Analysis Performance\n\n';
metrics += `- **Processing Time**: ${processingTime} seconds\n`;
metrics += `- **Components Analyzed**: ${analysis.components.length}\n`;
metrics += `- **Analysis Confidence**: ${Math.round(analysis.overall_confidence * 100)}%\n`;
metrics += `- **Analysis Quality**: ${analysis.analysis_quality}\n\n`;
metrics += '### System Performance\n\n';
metrics += `- **System Efficiency**: ${efficiency.toFixed(1)}%\n`;
metrics += `- **Power Factor**: ${powerFactor.toFixed(1)}%\n`;
metrics += `- **Power Sources**: ${analysis.circuit_topology.power_sources.length}\n`;
metrics += `- **Load Components**: ${analysis.circuit_topology.loads.length}\n`;
metrics += `- **Protection Devices**: ${analysis.circuit_topology.protection_devices.length}\n\n`;
if (args.system_voltage) {
metrics += '### System Specifications\n\n';
metrics += `- **System Voltage**: ${args.system_voltage}V\n`;
metrics += `- **Analysis Focus**: ${args.analysis_focus?.toUpperCase() || 'COMPLETE'}\n`;
metrics += `- **Load Profile**: ${args.load_profile?.toUpperCase() || 'NORMAL'}\n\n`;
}
metrics += '---\n';
metrics += `*Power flow analysis completed on ${new Date().toISOString().split('T')[0]} using FlexaBrain MCP Server v${analysis.analyzer_version}*\n`;
return metrics;
}
// Helper functions
function formatComponentType(type) {
return type.split('_').map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(' ');
}
function getSafetyIcon(safetyLevel) {
switch (safetyLevel) {
case 'CRITICAL': return '🔴';
case 'HIGH': return '🟠';
case 'MEDIUM': return '🟡';
case 'LOW': return '🟢';
default: return '⚪';
}
}
function calculateLoadFactor(loadProfile) {
switch (loadProfile) {
case 'peak': return 1.0;
case 'normal': return 0.8;
case 'minimum': return 0.5;
default: return 0.8;
}
}
function getLoadProfileDescription(loadProfile) {
switch (loadProfile) {
case 'peak': return 'Maximum system loading conditions';
case 'normal': return 'Typical operating conditions';
case 'minimum': return 'Light load or maintenance conditions';
default: return 'Standard operating profile';
}
}
//# sourceMappingURL=analyze-power-flow.js.map