-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
McCormackScheme/McCormackScheme/McCormackScheme/Program.cs
Lines 6 to 29 in cf6cf55
| Console.WriteLine("Welcome to the McCormack Scheme Console App"); | |
| Console.WriteLine("What is the bed slope?"); | |
| double bedSlope = Convert.ToDouble(Console.ReadLine()); | |
| Console.WriteLine("What is Manning's N?"); | |
| double n = Convert.ToDouble(Console.ReadLine()); | |
| Console.WriteLine("What is the initial velocity?"); | |
| double initialVelocity = Convert.ToDouble(Console.ReadLine()); | |
| Console.WriteLine("What is the channel bottom width?"); | |
| double bottomWidth = Convert.ToDouble(Console.ReadLine()); | |
| Console.WriteLine("What is the bank slope?"); | |
| double bankSlope = Convert.ToDouble(Console.ReadLine()); | |
| Console.WriteLine("What is the initial Depth?"); | |
| double initialDepth = Convert.ToDouble(Console.ReadLine()); | |
| Console.WriteLine("What is the gravitational constant?"); | |
| double g = Convert.ToDouble(Console.ReadLine()); | |
| Console.WriteLine("What is the time step?"); | |
| int timeStep = Convert.ToInt32(Console.ReadLine()); | |
| Console.WriteLine("What is the computational interval of distance?"); | |
| double distanceStep = Convert.ToDouble(Console.ReadLine()); | |
| Console.WriteLine("What is the simulation time period?"); | |
| double totalTime = Convert.ToDouble(Console.ReadLine()); | |
| Console.WriteLine("What is the length of the channel?"); | |
| double channelLength = Convert.ToDouble(Console.ReadLine()); |
Consider saving these inputs into separate objects. If I were to steal shamelessly from RAS's design, I'd say you have an initial conditions object, a computational settings object, and a geometry object.
You could then put these static methods into those objects as private functions, referencing properties instead of all parameter inputs, which might make your project a little cleaner. Could also keep them static. stylistic choice.
McCormackScheme/McCormackScheme/McCormackScheme/Calculate.cs
Lines 14 to 55 in cf6cf55
| public static double ManningsFrictionSlope(double depth, double bottomWidth, double bankSlopeHorizontalToOne, double velocity, double manningsN, double k) | |
| { | |
| double hydraulicRadius = TrapezoidalArea(depth, bottomWidth, bankSlopeHorizontalToOne) / TrapezoidalWettedPerimeter(bottomWidth, depth, bankSlopeHorizontalToOne); | |
| return (Math.Pow(velocity, 2) * Math.Pow(manningsN, 2)) / (Math.Pow(k, 2) * Math.Pow(hydraulicRadius, (4 / 3))); | |
| } | |
| public static double ManningsFrictionSlope(double velocity, double depth, double manningsN, double bankSlopeHorizontalToOne) | |
| { | |
| return (Math.Pow(velocity, 2) * Math.Pow(manningsN, 2)) / HydraulicRadius(depth, bankSlopeHorizontalToOne); | |
| } | |
| public static double HydraulicRadius(double depth, double bankSlopeHorizontalToOne) | |
| { | |
| return depth + bankSlopeHorizontalToOne * Math.Pow(depth, 2); | |
| } | |
| public static double TrapezoidalArea(double depthSolution, double bottomWidth, double bankSlopeHorizontalOnONe) | |
| { | |
| return depthSolution * bottomWidth + bankSlopeHorizontalOnONe * Math.Pow(depthSolution, 2); | |
| } | |
| public static double TrapezoidalWettedPerimeter(double bottomWidth, double depthSolution, double bankSlopeHorizontalOnONe) | |
| { | |
| double hypotenuse = Math.Pow(Math.Pow(depthSolution, 2) + Math.Pow(bankSlopeHorizontalOnONe * depthSolution, 2), 0.5); | |
| return bottomWidth + 2 * hypotenuse; | |
| } | |
| public static double TrapezoidalTopWidth(double depthSolution, double bottomWidth, double bankSlopeHorizontalOnONe) | |
| { | |
| return bottomWidth + 2 * bankSlopeHorizontalOnONe * depthSolution; | |
| } | |
| public static double VelocityFromDepthAndFlow(double normalDepth, double bottomWidth, double bankSlopeHorizontalToOne, double flowRate) | |
| { | |
| return flowRate / TrapezoidalArea(normalDepth, bottomWidth, bankSlopeHorizontalToOne); | |
| } | |
| public static double SpecificEnergy(double depth, double velocity, double gravity) | |
| { | |
| return depth + Math.Pow(velocity, 2) / gravity; | |
| } |
Metadata
Metadata
Assignees
Labels
No labels