Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Change B =1 to B = 0.5 in both B please Program implicit none integer*4 nn, ne, nen, nquad, i, j, k, n real*8 A,

image text in transcribed

Change B =1 to B = 0.5 in both B please

Program

implicit none integer*4 nn, ne, nen, nquad, i, j, k, n real*8 A, B, DX, FX, GKISA, FXKISA, JAC, INTEG real*8, allocatable :: G(:) real*8, allocatable :: F(:) real*8, allocatable :: X(:) integer*4, allocatable :: EN(:,:) real*8, allocatable :: GE(:) real*8, allocatable :: FE(:) real*8, allocatable :: XE(:) real*8, allocatable :: SH(:) real*8, allocatable :: SHX(:) real*8, allocatable :: KISA(:) real*8, allocatable :: W(:) real*8 tstart, tend WRITE(6,'(A)')'What is the starting point in x (A) ?' READ (5,*) a WRITE(6,'(A)')'What is the ending point in x (B) ?' READ (5,*) b WRITE(6,'(A)')'Number of nodes (odd number) ?' READ (5,*) nn IF(mod(nn-1,2).gt.0) then WRITE(6,'(A)')'Invalid number of nodes.' STOP ENDIF WRITE(6,'(A)')'Number of element nodes(nen) ?' READ (5,*) nen WRITE(6,'(A)')'Choose number of quadrature points' WRITE(6,'(A)')'----------------------------------' WRITE(6,'(A)')'1: One-Point Gaussian (Mid-Point)' WRITE(6,'(A)')'2: Two-Point Gaussian' WRITE(6,'(A)')'3: Three-Point Gaussian' READ (5,*) nquad CALL cpu_time(tstart) IF (nen.eq.2) then ne = nn -1 ELSE IF (nen.eq.3) then ne = (nn-1)/2 ELSE WRITE(6,'(A)')'Invalid number for nen.' STOP ENDIF DX = (B-A)/(nn-1) allocate (G(nn)) allocate (F(nn)) allocate (X(nn)) allocate (EN(nen,ne)) allocate ( GE(nen)) allocate ( FE(nen)) allocate ( XE(nen)) allocate ( SH(nen)) allocate (SHX(nen)) allocate (KISA(nquad)) allocate ( W(nquad)) DO i = 1,nn X(i) = A + (i-1)*dx CALL GF(G(i),F(i),X(i)) ENDDO DO i = 1,ne EN(1,i) = (nen-1)*(i-1) + 1 EN(2,i) = EN(1,i) + 1 IF (nen.eq.3) THEN EN(3,i) = EN(2,i) + 1 ENDIF ENDDO CALL INTRULE (KISA,W,nquad) INTEG = 0.0 DO i = 1, ne DO j = 1, nen XE(j) = X(EN(j,i)) GE(j) = G(EN(j,i)) FE(j) = F(EN(j,i)) ENDDO DO k = 1, nquad CALL SHAPEF (SH,SHX,XE,JAC,KISA(k),nen) GKISA = 0.0 FXKISA = 0.0 DO j=1,nen GKISA = GKISA + GE(j)* SH(j) FXKISA = FXKISA + FE(j)*SHX(j) ENDDO INTEG = INTEG+GKISA*GKISA*FXKISA*JAC*W(k) ENDDO !! end number of integration point loop ENDDO !! end number of element loop WRITE(6,'(A,e16.9)') 'Integration is = ', INTEG CALL cpu_time(tend) WRITE(6,'(A,e12.5)') 'Total CPU time = ',tend-tstart END SUBROUTINE GF(g,f,x) implicit none real*8 pi parameter (pi = 3.141592653589793) real*8 g, f, x g = 1.0-exp(-x) f = x**3.0 return end SUBROUTINE SHAPEF (SH,SHX,XE,JAC,kisa,nen) implicit none integer*4 nen real*8 SH(nen),SHX(nen), XE(nen), kisa, JAC IF (nen.eq.2) then SH (1) = +0.5*(1-kisa) SH (2) = +0.5*(1+kisa) SHX(1) = -0.5 SHX(2) = +0.5 JAC = XE(1)*SHX(1) + XE(2)*SHX(2) SHX(1) = SHX(1)/JAC !! derivative w.r.t x SHX(2) = SHX(2)/JAC !! derivative w.r.t x ELSE SH (1) = +0.5*kisa*(kisa-1.0) SH (2) = +1.0-kisa**2.0 SH (3) = +0.5*kisa*(kisa+1.0) SHX(1) = kisa - 0.5 SHX(2) = -2.0*kisa SHX(3) = kisa + 0.5 JAC = XE(1)*SHX(1) + XE(2)*SHX(2) + XE(3)*SHX(3) SHX(1) = SHX(1)/JAC !! derivative w.r.t x SHX(2) = SHX(2)/JAC !! derivative w.r.t x SHX(3) = SHX(3)/JAC !! derivative w.r.t x ENDIF RETURN END SUBROUTINE INTRULE (kisa,w,nquad) implicit none integer*4 nquad real*8 kisa(nquad), w(nquad) IF (nquad.EQ.1) THEN w(1) = 2.0 kisa(1) = 0.0 ELSE IF (nquad.EQ.2) THEN w(1) = 1.0 kisa(1) = -1.0/(3.0**0.5) w(2) = W(1) kisa(2) = -kisa(1) ELSE IF (nquad.EQ.3) THEN nquad = 3 w(1) = 5.0/9.0 kisa(1) = -(3.0/5.0)**0.5 w(2) = 8.0/9.0 kisa(2) = 0.0 w(3) = w(1) kisa(3) = -kisa(1) ELSE WRITE(6,'(A)')'Invalid number for nquad.' STOP ENDIF return end

(1.27) Problem 1.2. Modify the g and f functions in program "INTELEMENT.t" as following: g(x) = 0; f() = te" Compile the program and execute it with parameters below. A=0, B=1, nn=101, nen=2, nquad=1 Record your result. Execute the program one more time with following parameters. (1.28) A=0, B=1, nn = 100,001, nen =3, nquad=3 (1.29) Compare your results are write a paragraph explaining the results. Can you find out what the exact integral is? (1.27) Problem 1.2. Modify the g and f functions in program "INTELEMENT.t" as following: g(x) = 0; f() = te" Compile the program and execute it with parameters below. A=0, B=1, nn=101, nen=2, nquad=1 Record your result. Execute the program one more time with following parameters. (1.28) A=0, B=1, nn = 100,001, nen =3, nquad=3 (1.29) Compare your results are write a paragraph explaining the results. Can you find out what the exact integral is

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

why we face Listening Challenges?

Answered: 1 week ago

Question

what is Listening in Context?

Answered: 1 week ago