Welcome to AE Resources
ROOT FINDING DEMONSTRATION

ROOT FINDING DEMONSTRATION

		CASE (2)
		  WRITE(*,*) ’’
		  WRITE(*,*) ’Using the Newton-Raphson Method’
		  Ma = .9*M !Initial guess point
		  DO
			Cp_test = (2.0/(gamma*M**2)) *&
	                   (( (1. + ((gamma - 1.)/2.)*(M**2.)) / &
                            (1. + ((gamma - 1.)/2.)*(Ma**2.)) ) &
                             ** (gamma/(gamma - 1.)) - 1.) - Cp
			!Test tolerance
			tol = ABS(Cp_test)
			nmax = nmax + 1
			IF (tol <= .001) THEN !Within tolerance of .1%
			    EXIT
			ELSE IF (nmax >= 500) THEN !Stop inifinite loop
			   WRITE(*,*) ’Maximum counter limit reached (500).’
			   STOP
			ELSE
			   !Obtain local slope of line
			   Ma = Ma + .00001
			   Cp_test2 = (2.0/(gamma*M**2)) *&
                                (( (1. + ((gamma - 1.)/2.)*(M**2.)) / &
                                 (1. + ((gamma - 1.)/2.)*(Ma**2.)) ) &
                                  ** (gamma/(gamma - 1.)) - 1.) - Cp
			     slope = (Cp_test2 - Cp_test) / 0.00001
			     !Apply formula M(i+1) = M - f(M) / f’(M)
			      Ma = (Ma - 0.000001) - (Cp_test) / slope
			   END IF
			END DO
		
	END SELECT
	
	!Print out final value and info about calculations
	WRITE(*,*) ’Ma =’, Ma
	!WRITE(*,*) ’Iterations:’, nmax
	!WRITE(*,*) ’Percent error:’, (tol*100.), ’%’
	
END PROGRAM rootFinding
← Previous Page
← Previous Page