Water Velocity Calculator
This calculator helps you determine the velocity of water flowing through a pipe or channel given its flow rate and cross-sectional area.
function calculateWaterVelocity() {
var flowRateInput = document.getElementById("flowRate");
var crossSectionalAreaInput = document.getElementById("crossSectionalArea");
var resultDiv = document.getElementById("result");
var flowRate = parseFloat(flowRateInput.value);
var crossSectionalArea = parseFloat(crossSectionalAreaInput.value);
if (isNaN(flowRate) || isNaN(crossSectionalArea)) {
resultDiv.innerHTML = "Please enter valid numbers for all fields.";
return;
}
if (crossSectionalArea <= 0) {
resultDiv.innerHTML = "Cross-sectional area must be greater than zero.";
return;
}
// Convert flow rate from L/s to m³/s (1 L = 0.001 m³)
var flowRateM3ps = flowRate * 0.001;
// Velocity (v) = Flow Rate (Q) / Area (A)
var velocity = flowRateM3ps / crossSectionalArea;
resultDiv.innerHTML = "The water velocity is:
" + velocity.toFixed(3) + " meters per second (m/s)";
}
.water-velocity-calculator {
font-family: sans-serif;
border: 1px solid #ccc;
padding: 20px;
border-radius: 8px;
max-width: 500px;
margin: 20px auto;
background-color: #f9f9f9;
}
.water-velocity-calculator h2 {
text-align: center;
color: #333;
margin-bottom: 15px;
}
.water-velocity-calculator p {
text-align: center;
color: #555;
font-size: 0.9em;
margin-bottom: 20px;
}
.calculator-inputs {
display: flex;
flex-direction: column;
gap: 15px;
}
.input-group {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 10px;
}
.input-group label {
flex: 0 0 150px;
text-align: right;
font-weight: bold;
color: #444;
}
.input-group input[type="number"] {
flex: 1;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
}
.input-group .unit {
font-size: 0.85em;
color: #777;
}
.water-velocity-calculator button {
padding: 10px 15px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1em;
transition: background-color 0.3s ease;
margin-top: 10px;
}
.water-velocity-calculator button:hover {
background-color: #45a049;
}
.calculator-result {
margin-top: 20px;
padding: 15px;
background-color: #eef;
border: 1px solid #dde;
border-radius: 4px;
text-align: center;
font-size: 1.1em;
color: #333;
}