Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, Could you please see the attached question? Given: January 6, 2017 Due: F

ID: 3818080 • Letter: H

Question

Hello,

Could you please see the attached question?

Given: January 6, 2017 Due: February 6, 2017 1: 4, 11, 13. A rectangular trough of infinite length and cross sectional dimensions of alpha = 1.0 cm, b = 2.0 cm, is shown in the figure. Three sides are grounded, and the top side is held at V_0 = 100 V. (a) Write a fortran or C + + program to solve Laplace's equation using the finite element method. Divide the region into 50 equally sized triangles. If it is useful to you, a fortran matrix inversion subroutine is attached. (b) Compare the finite element solution to the exact solution(found via separation of variables in rectangular co-ordinates)of V(x, y) = 4V_0/pi sigma^infinity_k = 0sin n pi x/a sin h n pi y/b/n sin h n pi a/b, n = 2k + 1

Explanation / Answer

(A)

//code

#include<iostream>
#include<cmath>
#include<fstream>
using namespace std;
int main()
{

   float V[20][20], V0[18][18], diff[18][18];
   int i, j;

   for (i=0;i<=19;i++)
   {
       for (j=0;j<=19;j++)
       {
           V[0][j] = 0.0;
       V[19][j] = 1.0;
       V[0] = (i)/19.0;
           V[19] = (i)/19.0;
       }
   }

   for (i=1; i<=18; i++)
   {
       for (j=1; j<=18; j++)
       {
           V[j]=1.0;
       }
   }

   float maxdiff, sum, diffsum;
   int count=0;
   for(i=1;i<=18;i++)
   {
       for(j=1; j<=18; j++)
       {
           diff[j]=1.0;
       }
   }

   maxdiff=0.0001;
   diffsum=1.0;
   while (diffsum >= maxdiff)
   {
       sum = 0.0;
       for (i=1; i<=18; i++)
       {
           for (j=1; j<=18; j++)
           {
               V0[j] = V[j];  
               V[j] = ((V[i+1][j] + V[i-1][j] + V[j+1] + V[j-1])/4.0);
           diff[j] = (V0[j] - V[j]);
sum = sum + diff[j];  
           }
       }
       diffsum=sum/(18 * 18);
       count++;
   }
   cout<< count;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote