Fortran Program For Secant Method Calculator

5/31/2018by

I am trying to write a program to solve for pipe diameter for a pump system I've designed. I've done this on paper and understand the mechanics of the equations. I would appreciate any guidance.

Newton Secant Method

Online calculator. The bisection method in mathematics is a root-finding method that repeatedly bisects an interval and then selects a subinterval in which a root. Fortran 90 and HPF Programs Related to. Here are corresponding to the Fortran 77 programs appeared in. With the secant method. Fortran Program For Secant Method Pdf. Fortran computer programs associated with our textbook. Secant Method Calculator. Sorry 2004 Download here. ROOTS OF A REAL FUNCTION IN FORTRAN 90 Choose a source program. Program to demonstrate Secant method Program to demonstrate the Aitken Steffenson iteration method.

EDIT: I have updated the code with some suggestions from users, still seeing quick divergence. The guesses in there are way too high. If I figure this out I will update it to working. It seems that the initial values for xold and xolder are too far from the solution. If we change them as xold = 3.0d-5 xolder = 9.0d-5 and changing the threshold for convergence more tightly as IF (ABS(fx(xnew,L,Q,hf,rho,mu,rough)). Thank you for taking the time out of your day to help me. I originally solved this problem in excel using solver and was given 0.799 inches, reasonable for the size of this system (according to my mentor).

As far as the solution goes, I've tried cleaning up the parenthesis and ended up getting the same answers. Units have also been checked multiple times, and I am certain that those are right. I rewrote the function using my empirical derivation which took all factors besides D out of the function and got the same thing.

Fortran Program For Secant Method Calculator

I didn't want to hard-wire the program and limit its usefulness. – Dec 14 '15 at 4:44 •. @Jake Hmm, I see.

And if you can calculate the answer by Excel, does it agree with the Fortran solution above (e.g. After some unit conversion etc)? At least, the secant code itself seems to be working correctly.

[Also, by 'pre-calculate the constant factors', I mean using some temporary variables to store constant factors as a whole, e.g. CoeffA = hf/(L* 4*Q/pi) to make it easy to see the structure of the expression (not hard-coding the literal numbers). This is also useful for the reader of this site, because it takes time to 'decode' the program. – Dec 14 '15 at 5:25 •. Yes on excel the answer is reported in feet, so the number is multiplied by 12 to get to inches which ends up being ~0.799.

I thought about doing coefficients but thought I couldn't because it would mess the function up but I am working on that now. I also realized I forgot a few terms from the colebrook equation which would explain a lot I am currently working with f=(1/SQRT(hf/((L/D)*(((4.0*Q)/(pi D 2))/2*g)))) & +2.0*log10((rough/(3.7*D))+ & ((2. Sonalksis Stereo Tools Free Download. 51/((rho*(4.0*Q/piD2)*D/mu) & SQRT(hf/((L/D)*(((4.0*Q)/(piD**2))/2*g))))))) But am going to simplify it. Thanks for your help – Dec 14 '15 at 5:30 •. You very clearly declare the function in the interface (and the implementation) as FUNCTION f(L,D,Q,hf,rho,mu,rough) IMPLICIT NONE INTEGER,PARAMETER::DP=selected_real_kind(15) REAL(DP), PARAMETER::pi=3.14159265, g=9.81 REAL(DP), INTENT(IN)::L,Q,rough,rho,mu,hf,D REAL(DP)::fx END FUNCTION So you need to pass 7 arguments to it. And none of them are optional. But when you call it, you call it as xnew=xold-fx(xold)*((xolder-xold)/(fx(xolder)-fx(xold)) supplying a single argument to it.

Comments are closed.