diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 75ecdc8..9168bb3 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -56,18 +56,6 @@ namespace CtrEditor
_objectManager = new ObjectManipulationManager(this, ImagenEnTrabajoCanvas);
-#if DEBUG
- // Ejecutar prueba NPSH al iniciar en modo debug
- try
- {
- TestNPSHOnStartup();
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine($"Error al inicializar prueba NPSH: {ex.Message}");
- }
-#endif
-
_panningArea = new Rectangle
{
Fill = Brushes.Transparent,
@@ -1264,97 +1252,5 @@ namespace CtrEditor
return new ValidationResult(false, "Ingrese un número válido.");
}
-#if DEBUG
- private void TestNPSHOnStartup()
- {
- System.Threading.Tasks.Task.Run(() =>
- {
- try
- {
- System.Threading.Thread.Sleep(2000); // Esperar a que se cargue la aplicación
-
- // Crear una bomba con curva característica
- var pumpModel = new HydraulicSimulator.PumpHQ(
- h0: 50.0, // 50 metros de cabeza a caudal cero
- q0: 100.0, // 100 L/min caudal máximo teórico
- speed: 1750 // 1750 RPM nominal
- );
-
- // Configurar NPSH requerido de 3 metros (típico para bombas centrífugas)
- pumpModel.NPSHRequerido = 3.0;
-
- string resultado = "=== PRUEBA NPSH INICIADA ===\n";
- resultado += $"Bomba configurada:\n";
- resultado += $" H0: {pumpModel.H0} m\n";
- resultado += $" Q0: {pumpModel.Q0} L/min\n";
- resultado += $" NPSH Requerido: {pumpModel.NPSHRequerido} m\n\n";
-
- // CASO 1: Condición problemática del usuario
- resultado += "=== CASO 1: Condición problemática ===\n";
- double presionOrigen = 1.01; // bar
- double presionDestino = 34.0; // bar
-
- // Calcular NPSH disponible
- double npshDisponible = pumpModel.CalculateNPSHAvailable(presionOrigen);
- resultado += $"Presión origen: {presionOrigen} bar\n";
- resultado += $"Presión destino: {presionDestino} bar\n";
- resultado += $"NPSH Disponible: {npshDisponible:F2} m\n";
- resultado += $"NPSH Requerido: {pumpModel.NPSHRequerido} m\n";
-
- bool puedeOperar = pumpModel.CanOperateWithoutCavitation(presionOrigen);
- resultado += $"¿Puede operar sin cavitación?: {(puedeOperar ? "SÍ" : "NO")}\n";
-
- if (!puedeOperar)
- {
- double factorCavitacion = pumpModel.GetCavitationFactor(presionOrigen);
- resultado += $"Factor de cavitación: {factorCavitacion:F3}\n";
- resultado += "RESULTADO: La bomba NO debería operar en estas condiciones\n";
- }
-
- // CASO 2: Condición normal
- resultado += "\n=== CASO 2: Condición normal ===\n";
- presionOrigen = 2.5; // bar (presión adecuada)
- presionDestino = 5.0; // bar (presión razonable)
-
- npshDisponible = pumpModel.CalculateNPSHAvailable(presionOrigen);
- resultado += $"Presión origen: {presionOrigen} bar\n";
- resultado += $"Presión destino: {presionDestino} bar\n";
- resultado += $"NPSH Disponible: {npshDisponible:F2} m\n";
-
- puedeOperar = pumpModel.CanOperateWithoutCavitation(presionOrigen);
- resultado += $"¿Puede operar sin cavitación?: {(puedeOperar ? "SÍ" : "NO")}\n";
-
- if (puedeOperar)
- {
- double deltaP = pumpModel.Dp(50.0); // 50 L/min
- resultado += $"Presión diferencial a 50 L/min: {deltaP:F2} bar\n";
- resultado += "RESULTADO: La bomba puede operar normalmente\n";
- }
-
- resultado += "\n=== RESUMEN ===\n";
- resultado += "La implementación NPSH previene que la bomba opere\n";
- resultado += "cuando la presión de succión es insuficiente,\n";
- resultado += "solucionando el problema físicamente imposible\n";
- resultado += "reportado por el usuario.\n";
-
- // Mostrar resultado en UI thread
- Dispatcher.Invoke(() =>
- {
- System.Windows.MessageBox.Show(resultado, "Prueba NPSH Completada",
- System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Information);
- });
- }
- catch (Exception ex)
- {
- // Mostrar error en UI thread
- Dispatcher.Invoke(() =>
- {
- System.Windows.MessageBox.Show($"Error en prueba NPSH: {ex.Message}\n\n{ex.StackTrace}",
- "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
- });
- }
- });
- }
-#endif
}
}
\ No newline at end of file
diff --git a/NPSHTestConsole.cs b/NPSHTestConsole.cs
deleted file mode 100644
index 66ce4bc..0000000
--- a/NPSHTestConsole.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-using System;
-using CtrEditor.HydraulicSimulator;
-
-// Programa simple para probar las funcionalidades NPSH
-class Program
-{
- static void Main()
- {
- Console.WriteLine("=== TEST NPSH VERIFICATION SYSTEM ===");
- Console.WriteLine();
-
- // Test 1: Condiciones problemáticas del usuario original
- Console.WriteLine("1. TEST: Condiciones problemáticas originales");
- Console.WriteLine(" Tanque origen: VACÍO (1.01 bar)");
- Console.WriteLine(" Tanque destino: 34 bar presión");
-
- var pump = new PumpHQWithSuctionCheck();
- double suctionPressure = 101325.0; // 1.01 bar
- double dischargePressure = 3400000.0; // 34 bar
- double flowRate = 10.0; // L/min
-
- pump.UpdatePressures(suctionPressure, dischargePressure);
-
- double npshAvailable = pump.CalculateNPSHAvailable(
- suctionPressure, 0.5, 2337.0, 0.5);
- bool canOperate = pump.CanOperateWithoutCavitation(flowRate);
- double cavitationFactor = pump.GetCavitationFactor(flowRate);
-
- Console.WriteLine($" NPSH Disponible: {npshAvailable:F2} m");
- Console.WriteLine($" Puede operar sin cavitación: {canOperate}");
- Console.WriteLine($" Factor cavitación: {cavitationFactor:F2}");
- Console.WriteLine();
-
- // Test 2: Condiciones normales de operación
- Console.WriteLine("2. TEST: Condiciones normales de operación");
- Console.WriteLine(" Tanque origen: 5 bar presión");
- Console.WriteLine(" Tanque destino: 2 bar presión");
-
- suctionPressure = 500000.0; // 5 bar
- dischargePressure = 200000.0; // 2 bar
-
- pump.UpdatePressures(suctionPressure, dischargePressure);
-
- npshAvailable = pump.CalculateNPSHAvailable(
- suctionPressure, 2.0, 2337.0, 0.3);
- canOperate = pump.CanOperateWithoutCavitation(flowRate);
- cavitationFactor = pump.GetCavitationFactor(flowRate);
-
- Console.WriteLine($" NPSH Disponible: {npshAvailable:F2} m");
- Console.WriteLine($" Puede operar sin cavitación: {canOperate}");
- Console.WriteLine($" Factor cavitación: {cavitationFactor:F2}");
- Console.WriteLine();
-
- // Test 3: Configuración dinámica
- Console.WriteLine("3. TEST: Configuración dinámica NPSH");
- var manager = new HydraulicSimulationManager();
-
- Console.WriteLine($" Estado inicial - NPSH: {manager.EnableNPSHVerification}");
-
- manager.ConfigureNPSHSettings(true, 2.5, 2500.0, 0.8);
- Console.WriteLine($" Después configuración - NPSH: {manager.EnableNPSHVerification}");
- Console.WriteLine();
-
- // Resumen
- Console.WriteLine("=== RESUMEN DE RESULTADOS ===");
- Console.WriteLine("✅ Sistema NPSH implementado exitosamente");
- Console.WriteLine("✅ Verificación de cavitación funcionando");
- Console.WriteLine("✅ Configuración dinámica operativa");
- Console.WriteLine("✅ Problema original resuelto");
- Console.WriteLine();
- Console.WriteLine("PRESIONA CUALQUIER TECLA PARA SALIR...");
- Console.ReadKey();
- }
-}
diff --git a/NPSHTestExample.cs b/NPSHTestExample.cs
deleted file mode 100644
index 72918ca..0000000
--- a/NPSHTestExample.cs
+++ /dev/null
@@ -1,206 +0,0 @@
-using System;
-using CtrEditor.HydraulicSimulator;
-
-namespace CtrEditor
-{
- ///
- /// Ejemplo para probar las nuevas funcionalidades de NPSH
- /// Reproduce el problema original del usuario donde una bomba
- /// seguía funcionando con tanque vacío y alta presión de descarga
- ///
- public class NPSHTestExample
- {
- public static void TestNPSHConfiguration()
- {
- Console.WriteLine("=== TESTING NPSH VERIFICATION SYSTEM ===");
- Console.WriteLine();
-
- // Configuración original problemática del usuario
- Console.WriteLine("1. TESTING ORIGINAL PROBLEM SCENARIO:");
- Console.WriteLine(" - Tanque origen: VACÍO (1.01 bar)");
- Console.WriteLine(" - Tanque destino: 34 bar presión");
- Console.WriteLine(" - Sin verificación NPSH");
-
- var problematicTest = TestProblematicScenario();
- Console.WriteLine($" Resultado SIN NPSH: Bomba funciona = {problematicTest.canOperate}");
- Console.WriteLine($" Presión diferencial: {problematicTest.pressureDiff:F2} bar");
- Console.WriteLine();
-
- // Test con verificación NPSH habilitada
- Console.WriteLine("2. TESTING WITH NPSH VERIFICATION ENABLED:");
- Console.WriteLine(" - Misma configuración pero con NPSH verificado");
-
- var npshTest = TestWithNPSHVerification();
- Console.WriteLine($" Resultado CON NPSH: Bomba puede operar = {npshTest.canOperate}");
- Console.WriteLine($" NPSH Disponible: {npshTest.npshAvailable:F2} m");
- Console.WriteLine($" NPSH Requerido: {npshTest.npshRequired:F2} m");
- Console.WriteLine($" Factor cavitación: {npshTest.cavitationFactor:F2}");
- Console.WriteLine();
-
- // Test con condiciones normales de operación
- Console.WriteLine("3. TESTING NORMAL OPERATING CONDITIONS:");
- Console.WriteLine(" - Tanque origen: 5 bar presión");
- Console.WriteLine(" - Tanque destino: 2 bar presión");
-
- var normalTest = TestNormalConditions();
- Console.WriteLine($" Resultado NORMAL: Bomba puede operar = {normalTest.canOperate}");
- Console.WriteLine($" NPSH Disponible: {normalTest.npshAvailable:F2} m");
- Console.WriteLine($" Factor cavitación: {normalTest.cavitationFactor:F2}");
- Console.WriteLine();
-
- // Test de configuración dinámica
- Console.WriteLine("4. TESTING DYNAMIC NPSH CONFIGURATION:");
- TestDynamicConfiguration();
- Console.WriteLine();
-
- Console.WriteLine("=== TEST COMPLETED ===");
- }
-
- private static (bool canOperate, double pressureDiff) TestProblematicScenario()
- {
- // Crear bomba con modelo original (sin NPSH)
- var pump = new PumpHQ();
-
- // Configurar presiones problemáticas
- double suctionPressure = 101325.0; // 1.01 bar (atmosférica)
- double dischargePressure = 3400000.0; // 34 bar
- double flowRate = 10.0; // L/min
-
- // Calcular con modelo original
- double pressureDiff = pump.Dp(flowRate, suctionPressure, dischargePressure);
-
- // Sin NPSH, la bomba siempre "funciona"
- bool canOperate = pressureDiff > 0;
-
- return (canOperate, pressureDiff / 100000.0); // convertir a bar
- }
-
- private static (bool canOperate, double npshAvailable, double npshRequired, double cavitationFactor) TestWithNPSHVerification()
- {
- // Crear bomba con verificación NPSH
- var pump = new PumpHQWithSuctionCheck();
-
- // Configurar presiones problemáticas
- double suctionPressure = 101325.0; // 1.01 bar (atmosférica)
- double dischargePressure = 3400000.0; // 34 bar
- double flowRate = 10.0; // L/min
- double tankLevel = 0.5; // 50 cm de altura
- double vaporPressure = 2337.0; // Presión vapor agua a 20°C
- double suctionLosses = 0.5; // Pérdidas de succión estimadas
-
- // Actualizar presiones en la bomba
- pump.UpdatePressures(suctionPressure, dischargePressure);
-
- // Calcular NPSH disponible
- double npshAvailable = pump.CalculateNPSHAvailable(
- suctionPressure, tankLevel, vaporPressure, suctionLosses);
-
- // Verificar si puede operar sin cavitación
- bool canOperate = pump.CanOperateWithoutCavitation(flowRate);
-
- // Obtener factor de cavitación
- double cavitationFactor = pump.GetCavitationFactor(flowRate);
-
- return (canOperate, npshAvailable, 3.0, cavitationFactor);
- }
-
- private static (bool canOperate, double npshAvailable, double cavitationFactor) TestNormalConditions()
- {
- var pump = new PumpHQWithSuctionCheck();
-
- // Condiciones normales de operación
- double suctionPressure = 500000.0; // 5 bar
- double dischargePressure = 200000.0; // 2 bar
- double flowRate = 15.0; // L/min
- double tankLevel = 2.0; // 2 metros de altura
- double vaporPressure = 2337.0;
- double suctionLosses = 0.3;
-
- pump.UpdatePressures(suctionPressure, dischargePressure);
-
- double npshAvailable = pump.CalculateNPSHAvailable(
- suctionPressure, tankLevel, vaporPressure, suctionLosses);
-
- bool canOperate = pump.CanOperateWithoutCavitation(flowRate);
- double cavitationFactor = pump.GetCavitationFactor(flowRate);
-
- return (canOperate, npshAvailable, cavitationFactor);
- }
-
- private static void TestDynamicConfiguration()
- {
- // Crear manager de simulación hidráulica
- var manager = new HydraulicSimulationManager();
-
- Console.WriteLine(" Configuración inicial - NPSH deshabilitado:");
- manager.EnableNPSHVerification = false;
- Console.WriteLine($" NPSH habilitado: {manager.EnableNPSHVerification}");
-
- Console.WriteLine(" Habilitando NPSH con parámetros personalizados:");
- manager.ConfigureNPSHSettings(
- enableNPSH: true,
- npshRequired: 2.5, // metros
- vaporPressure: 2500.0, // Pa
- suctionLosses: 0.8 // metros
- );
-
- Console.WriteLine($" NPSH habilitado: {manager.EnableNPSHVerification}");
- Console.WriteLine(" Configuración aplicada correctamente");
- }
-
- ///
- /// Método para integrar en el UI y probar con bombas reales
- ///
- public static void TestWithRealPumpComponent()
- {
- Console.WriteLine("=== TESTING REAL PUMP COMPONENT ===");
- Console.WriteLine("Para integrar con componentes UI reales, usar el método:");
- Console.WriteLine("NPSHTestExample.TestWithRealPumpComponent() desde el UI");
- }
-
- ///
- /// Método para verificar el problema original específico del usuario
- ///
- public static void VerifyOriginalProblemFixed()
- {
- Console.WriteLine("=== VERIFICANDO SOLUCIÓN AL PROBLEMA ORIGINAL ===");
- Console.WriteLine("Problema: 'con el tanque de origen vacío y el de destino");
- Console.WriteLine("con una presión de 34 bar la bomba continúa a llenar el tanque de destino'");
- Console.WriteLine();
-
- var pump = new PumpHQWithSuctionCheck();
-
- // Exactamente las condiciones del problema
- double suctionPressure = 101325.0; // Tanque vacío (presión atmosférica)
- double dischargePressure = 3400000.0; // 34 bar como reportó el usuario
- double flowRate = 5.0; // Flujo típico
-
- pump.UpdatePressures(suctionPressure, dischargePressure);
-
- // Verificar NPSH
- double npshAvailable = pump.CalculateNPSHAvailable(
- suctionPressure, 0.1, 2337.0, 0.5); // Tanque casi vacío
-
- bool canOperate = pump.CanOperateWithoutCavitation(flowRate);
- double cavitationFactor = pump.GetCavitationFactor(flowRate);
-
- Console.WriteLine($"Presión succión: {suctionPressure/100000:F2} bar");
- Console.WriteLine($"Presión descarga: {dischargePressure/100000:F2} bar");
- Console.WriteLine($"NPSH disponible: {npshAvailable:F2} m");
- Console.WriteLine($"Factor cavitación: {cavitationFactor:F2}");
- Console.WriteLine($"Bomba puede operar: {canOperate}");
- Console.WriteLine();
-
- if (!canOperate)
- {
- Console.WriteLine("✅ PROBLEMA SOLUCIONADO: La bomba ya no puede operar");
- Console.WriteLine(" en condiciones físicamente imposibles!");
- }
- else
- {
- Console.WriteLine("❌ PROBLEMA PERSISTE: La bomba aún puede operar");
- Console.WriteLine(" en condiciones incorrectas.");
- }
- }
- }
-}
diff --git a/NPSHTestProgram.cs b/NPSHTestProgram.cs
deleted file mode 100644
index e45c8a4..0000000
--- a/NPSHTestProgram.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System;
-using System.Windows;
-using CtrEditor;
-
-namespace CtrEditor
-{
- ///
- /// Programa de consola simple para probar NPSH sin necesidad del UI completo
- ///
- public class NPSHTestProgram
- {
- [STAThread]
- public static void Main(string[] args)
- {
- try
- {
- Console.WriteLine("NPSH VERIFICATION SYSTEM - TEST PROGRAM");
- Console.WriteLine("========================================");
- Console.WriteLine();
-
- // Ejecutar todas las pruebas
- NPSHTestExample.TestNPSHConfiguration();
- Console.WriteLine();
-
- // Verificar específicamente el problema original
- NPSHTestExample.VerifyOriginalProblemFixed();
- Console.WriteLine();
-
- Console.WriteLine("Presiona cualquier tecla para continuar...");
- Console.ReadKey();
- }
- catch (Exception ex)
- {
- Console.WriteLine($"ERROR durante las pruebas: {ex.Message}");
- Console.WriteLine($"Stack trace: {ex.StackTrace}");
- Console.WriteLine();
- Console.WriteLine("Presiona cualquier tecla para salir...");
- Console.ReadKey();
- }
- }
- }
-}
diff --git a/TestNPSH.cs b/TestNPSH.cs
deleted file mode 100644
index 6496b2f..0000000
--- a/TestNPSH.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-using System;
-using CtrEditor.HydraulicSimulator;
-
-namespace CtrEditor
-{
- public class TestNPSH
- {
- public static void Main(string[] args)
- {
- Console.WriteLine("Iniciando prueba de verificación NPSH...");
-
- try
- {
- // Crear una bomba con curva característica
- var pumpModel = new PumpHQ(
- h0: 50.0, // 50 metros de cabeza a caudal cero
- q0: 100.0, // 100 L/min caudal máximo teórico
- speed: 1750 // 1750 RPM nominal
- );
-
- // Configurar NPSH requerido de 3 metros (típico para bombas centrífugas)
- pumpModel.NPSHRequerido = 3.0;
-
- Console.WriteLine($"Bomba configurada:");
- Console.WriteLine($" H0: {pumpModel.H0} m");
- Console.WriteLine($" Q0: {pumpModel.Q0} L/min");
- Console.WriteLine($" NPSH Requerido: {pumpModel.NPSHRequerido} m");
-
- // CASO 1: Condición problemática del usuario
- // Tanque origen vacío (1.01 bar = presión atmosférica)
- // Tanque destino con 34 bar de presión
- Console.WriteLine("\n=== CASO 1: Condición problemática ===");
- double presionOrigen = 1.01; // bar
- double presionDestino = 34.0; // bar
- double caudal = 50.0; // L/min
-
- // Calcular NPSH disponible
- double npshDisponible = pumpModel.CalculateNPSHAvailable(presionOrigen);
- Console.WriteLine($"Presión origen: {presionOrigen} bar");
- Console.WriteLine($"Presión destino: {presionDestino} bar");
- Console.WriteLine($"NPSH Disponible: {npshDisponible:F2} m");
- Console.WriteLine($"NPSH Requerido: {pumpModel.NPSHRequerido} m");
-
- bool puedeOperar = pumpModel.CanOperateWithoutCavitation(presionOrigen);
- Console.WriteLine($"¿Puede operar sin cavitación?: {(puedeOperar ? "SÍ" : "NO")}");
-
- if (!puedeOperar)
- {
- double factorCavitacion = pumpModel.GetCavitationFactor(presionOrigen);
- Console.WriteLine($"Factor de cavitación: {factorCavitacion:F3}");
- Console.WriteLine("RESULTADO: La bomba NO debería operar en estas condiciones");
- }
-
- // CASO 2: Condición normal
- Console.WriteLine("\n=== CASO 2: Condición normal ===");
- presionOrigen = 2.5; // bar (presión adecuada)
- presionDestino = 5.0; // bar (presión razonable)
-
- npshDisponible = pumpModel.CalculateNPSHAvailable(presionOrigen);
- Console.WriteLine($"Presión origen: {presionOrigen} bar");
- Console.WriteLine($"Presión destino: {presionDestino} bar");
- Console.WriteLine($"NPSH Disponible: {npshDisponible:F2} m");
-
- puedeOperar = pumpModel.CanOperateWithoutCavitation(presionOrigen);
- Console.WriteLine($"¿Puede operar sin cavitación?: {(puedeOperar ? "SÍ" : "NO")}");
-
- if (puedeOperar)
- {
- // Calcular presión diferencial normal
- double deltaP = pumpModel.Dp(caudal);
- Console.WriteLine($"Presión diferencial a {caudal} L/min: {deltaP:F2} bar");
- Console.WriteLine("RESULTADO: La bomba puede operar normalmente");
- }
-
- Console.WriteLine("\n=== RESUMEN ===");
- Console.WriteLine("La implementación NPSH previene que la bomba opere");
- Console.WriteLine("cuando la presión de succión es insuficiente,");
- Console.WriteLine("solucionando el problema físicamente imposible");
- Console.WriteLine("reportado por el usuario.");
-
- }
- catch (Exception ex)
- {
- Console.WriteLine($"Error en la prueba: {ex.Message}");
- Console.WriteLine($"Stack trace: {ex.StackTrace}");
- }
-
- Console.WriteLine("\nPresione cualquier tecla para salir...");
- Console.ReadKey();
- }
- }
-}