|
where is the algorithm question?
|
|
|
|
|
Didn't Math forum get consolidated to this room? This is not forum for Math question?
Tadeusz Westawic
An ounce of Clever is worth a pound of Experience.
|
|
|
|
|
This forum used to be called "Math and Algoritms" or something similar. But the math unfortunately had to go, so now it is about algorithms only. Advice on software selection is mostly handled in the Lounge now.
|
|
|
|
|
The Windows XP calculator allows this too.
|
|
|
|
|
The Windows Vista calculator has an option for hex calculations...choose the scientific option from the view menu.
|
|
|
|
|
Thanks All,
The salient feature I needed was mixing radices in same operation which the VISTA calculator allows.
Thanks once more.
Tadeusz Westawic
Caveat juris excretorium.
|
|
|
|
|
|
I'm looking for a solution to an equation that looks familiar, but I've forgotten too much in 30 years. I'm hoping one of our younger folks ( or mathematically skilled old farts ) can help.
Given the equation:
4R/D = Φ - sinΦ
what is the value of Φ given that D is constant, and R is known from other independent calculations? WolframAlpha came up with a nice graph, but I need an analytic solution that I can use to return a definite numeric answer to the calling program. Any solutions out there?
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
I don't think that has an analytical solution, but it's pretty easy to solve numerically by using one of various techniques to find the root of
Φ - sin(&Phi) - (4*R/D) = 0.
Since -1 <= sin(&Phi) <= 1, you should be able to find an excellent starting point for iterating.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
That wasn't the answer I was hoping for, but you may be right. This may come down to solving a problem in more than one variable, using linear programming techniques or some other optimization methodology. The problem set involves a flow of fluid through a pipe; I want to be able to vary the slope of the pipe, or change the amount of liquid dumped into it and predict what the depth of water will be under steady state conditions; transient analysis is completely beyond my pay grade.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
I agree with Walt, a few iterations of Newton-Raphson[^] should solve that numerically.
|
|
|
|
|
yup Newton Raphsom method would do it.
Also It would be helpful to find out what are the ranges of possible values of phi, say if phi belongs in -1 to 1 you can apply sine series formula to phi.
|
|
|
|
|
The equation is modeling a physical phenomenon (water streaming in a pipe), I don't know all the details, however I'm confident it will be well behaved, have a simple first guess (say 10 degrees), and converge easily.
|
|
|
|
|
What do the variables represent? Is there a way to determine reasonable variable limits? For example, if you know that Φ must be between +/- 2 Π that limits the solutions and table look up or a curve fit to the solution might be good enough. How much precision do you need?
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
I was thinking perhaps a cubic spline solution...
The variables are part of the equation for fluid flow in a pipe, and Φ represents the angle from horizontal a line drawn from the center of the pipe to the intersection of the line marking the top of the fluid within.
V = (1.485/n)* R2/3 * S1/2, ft/sec.
S is the slope of the pipe, and n is a very small number that varies with the smoothness of the pipe - a common value is .013. R is called the 'hydraulic radius' and is given by the ratio of the area of flow to the wetted perimeter in the pipe. Calculating that area value is what hurts my head.
It's fairly straightforward to calculate the flow, given everything else, but I'm trying to predict a level in the pipe from a given flow and slope. That's not what the equation is designed for, though there's no reason not to use it this way. If I can't find a reasonable way to do it, I may have to resort to Bernoulli's equation, with all those nasty energy calculations and differential equations. We hates those...
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Roger Wright wrote: I was thinking perhaps a cubic spline solution...
A cubic spline would be an approximation, i.e. a curve fitting a couple of points. Calculating it would be more complex than solving the equation itself, and the results would not be all that accurate.
|
|
|
|
|
Sure, Manning's equation. It's been awhile since I worked with single phase open channel flow. S should be the slope of the hydraulic head (potential gradient) if I recall. That's not the same as the pipe slope, unless the head loss is negligible or the pipe is full. If it's full, then Darcy-Weisbach is a better way to estimate and if you're in fully turbulent flow, the friction factors can be estimated quite easily, but it's still probably not an analytic solution.
I'm not sure I understand what Φ is in relation to the hydraulic gradient and/or pipe slope, though. Where does the Φ come in?
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
I doubt that Manning's is the right equation to use, but having searched out a number of public building codes I've found that all of them require sewer flows to be calculated using it. Even crazier, most of them specify that n = .013 be used, regardless of the pipe material. Darcy-Weisbach is probably better, but the only application I've found using it requires reading values from a nomograph - ridiculous! IIRC, I believe it requires knowledge of the viscosity and flow characteristics, as well, little of which is known at design time. I can estimate %solids from the measurements taken from the influent at the sewer processing plant, but even then I probably have areas with wildly different fluid properties.
The angle Φ is used to calculate the area of fluid in a pipe that isn't full. Picture a circle with a line drawn through it representing the fluid level. A line from the center of the circle to the point where the fluid level intersects the circle makes the angle Φ with the horizontal.
I've got some more figuring to do, I guess. Or perhaps I should just keep it simple.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
OK, I understand, Φ is based on Θ in this figure where they calculate hydraulic radius: http://www.ajdesigner.com/phphydraulicradius/hydraulic_radius_equation_pipe.php[^]. If I follow you, Φ = (Π - Θ)/2.
Since it's building codes that are specifying the method to use, then you have little choice but to do that, unless you have a licensed engineer come up with a good reason to do something better. Manning's equation with the empirical friction factor equivalent is probably conservative for the purpose, and that's OK.
I'd guess that the iterative solution is your best bet.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Walt Fair, Jr. wrote: I'd guess that the iterative solution is your best bet.
we are all converging now.
|
|
|
|
|
I made this, but it's not an analytical answer..
static double Solve(double y)
{
double x = y;
double error = double.MaxValue;
double prevError = double.PositiveInfinity;
while (error != 0 && Math.Abs(prevError) > Math.Abs(error))
{
x -= (x - Math.Sin(x) - y) / (1 - Math.Cos(x));
prevError = error;
error = y - (x - Math.Sin(x));
}
return x;
}
It doesn't work for zero, and gives infinity for y < 0.00000001054, but otherwise it seems alright.
The input is supposed to be your value for 4R/D and the output will approximate Φ.
I can't guarantee that it will always terminate, but it did for every value I tested (which included negative numbers, and insanely big numbers, and very small numbers)
|
|
|
|
|
do I detect a Newton-Raphson smell around here?
|
|
|
|
|
Probably, because that's what it is
|
|
|
|
|
Thanks! That should be a good start. I may have a shortcut to make it converge faster, though. I'll have to think about it.
The idea is to model (one situation) a sewer line that is existing, to which a new customer - a car wash, for instance - wants to connect. I'd like to then force a change in gpm inflow, then see what happens to everything else. Since the gpm is a function of the area and velocity of flow, that's one equation. Then the other can be used to provide a bound for the next guess at Φ until the two equations converge to a single value, +/- some tolerance value.
My head hurts; I think I'll bang out something easy - a database program to inventory the entire electrical system maybe - while I'm cogitating.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
That went right over my head..
Maybe I'll think about it some more but I have other things to do as well.
Good luck
|
|
|
|