UNPKG

@ppramanik62/lab-works

Version:

A comprehensive command-line toolkit for hydraulic turbine calculations, supporting Francis Turbine and Pelton Wheel computations with interactive mode and validation.

102 lines 4.2 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.runKaplan = void 0; /** * Kaplan Turbine Calculator - Main orchestrator */ const colors_1 = require("../../shared/colors"); const round_1 = require("../../shared/round"); const formulas_1 = require("./formulas"); const io_1 = require("./io"); /** * Print results in human-readable format */ const printResults = (results) => { const title = (0, colors_1.safeColorize)("📊 Kaplan Turbine Calculation Results", colors_1.theme.title); const separator = (0, colors_1.safeColorize)("═".repeat(50), colors_1.theme.accent); console.log(`\n${title}`); console.log(separator); const formatResult = (label, value, unit) => { const labelColored = (0, colors_1.safeColorize)(`${label}:`, colors_1.theme.info); const valueColored = (0, colors_1.safeColorize)((0, round_1.formatNumber)(value), colors_1.theme.success); const unitColored = (0, colors_1.safeColorize)(unit, colors_1.theme.subtle); return `${labelColored.padEnd(35)} ${valueColored} ${unitColored}`; }; console.log(formatResult("Available Head (Ha)", results.Ha, "m")); console.log(formatResult("Unit Speed (N1)", results.N1, "rpm")); console.log(formatResult("Unit Discharge (Q1)", results.Q1, "m³/s")); console.log(formatResult("Unit Torque (T1)", results.T1, "N⋅m")); console.log(formatResult("Unit Power (Pt1)", results.Pt1, "W")); console.log(formatResult("Available Power (Pa)", results.Pa, "W")); console.log(formatResult("Efficiency (η)", results.eta, "%")); console.log(separator); }; /** * Print results in JSON format */ const printResultsJson = (results) => { const roundedResults = { Ha: (0, round_1.threeDecimal)(results.Ha), N1: (0, round_1.threeDecimal)(results.N1), Q1: (0, round_1.threeDecimal)(results.Q1), T1: (0, round_1.threeDecimal)(results.T1), Pt1: (0, round_1.threeDecimal)(results.Pt1), Pa: (0, round_1.threeDecimal)(results.Pa), eta: (0, round_1.threeDecimal)(results.eta), }; console.log(JSON.stringify(roundedResults, null, 2)); }; /** * Run the Kaplan Turbine calculator */ const runKaplan = async (options = {}) => { try { const input = await (0, io_1.collectInput)(options); const results = (0, formulas_1.calculateKaplan)(input.pg, input.w1, input.w2, input.rpm, input.lhs_mercury, input.rhs_mercury); if (options.json) { printResultsJson(results); } else { printResults(results); } } catch (error) { const { handleError } = await Promise.resolve().then(() => __importStar(require("../../shared/error"))); handleError(error); } }; exports.runKaplan = runKaplan; //# sourceMappingURL=index.js.map