|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: |
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<float.h>
#include<math.h>
#include<iomanip.h>
/*printcomplexnumber(double real,double imag)
{
if (real==0)
cout<<imag<<"i";
if (imag<0)
cout<<real<<imag<<"i";
if (imag > 0)
cout<<real<< "+"<<imag<<"i";
if (imag==0)
cout<<real;
return(real,imag); } */
int main()
{ double Ex[9][9][9][9],Ey[9][9][9][9],Ez[9][9][9][9];
double Hy[9][9][9][9],Hx[9][9][9][9],Hz[9][9][9][9];
int i,j,k,n,imax,jmax,kmax,nmax;
float A,ep[10][10][10],eo,muo;
float dt,c,w,t,lamda;
cout<<"enter the limits for space and time\n";
cin>>imax;
cin>>jmax;
cin>>kmax;
cin>>nmax;
/*to assign the dielectric constant*/
for(i=0;i<=imax;i++)
{for(j=0;j<=jmax;j++)
{for(k=0;k<=kmax;k++)
{if((i<=imax/2)&&(j<=jmax/2)&&(j<=jmax/2))
ep[i][j][k]=1;
else
ep[i][j][k]=12;
}/*kloop*/
}/*j loop*/
}/*i loop
/* to check the dielectric constant of space*/
cout<<"enter the value of x,y,z\n";
cin>>i;
cin>>j;
cin>>k;
cout<<"the dielectric constant at this point is ="<<ep[i][j][k]<<endl;
/*to clear the memor/
for(n=0;n<=nmax;n=n++)
{
for(i=0;i<=imax;i++)
{for(j=0;j<=jmax;j++)
{for(k=0;k<=kmax;k++)
{Ex[i][j][k][n]=0;
Ey[i][j][k][n]=0;
Ez[i][j][k][n]=0;
Hx[i][j][k][n]=0;
Hy[i][j][k][n]=0;
Hz[i][j][k][n]=0;
}/*k loop/
}/*j loop /
}/*i loop /
}/* t loop/
/* launching incident plane wave propagating in x dir*/
cout<<"\n enter the A and lamda(in micron)";
cin>>A;
cin>>lamda;
c=3e8;
w=(2*3.14*c)/lamda;
dt=1e-15;
cout<<"i j k n field value"<<endl;
for(n=1;n<=2;n++)
{for(i=0;i<=imax;i++)
{for(j=0;j<=jmax;j++)
{for(k=0;k<=kmax;k++)
{t=n*dt;
Ex[i][j][k][n]=A*sin(w*t);
Ey[i][j][k][n]=A*sin(w*t);
Ez[i][j][k][n]=A*sin(w*t);
Hx[i][j][k][n]=A*sin(w*t);
Hy[i][j][k][n]=A*sin(w*t);
Hz[i][j][k][n]=A*sin(w*t);
cout<<i<<"\t"<<j<<"\t"<<k<<"\t"<<n<<"\t"<<"Hz"<<"\t"<<Hz[i][j][k][n]<<endl;
cout<<i<<"\t"<<j<<"\t"<<k<<"\t"<<n<<"\t"<<"Hx"<<"\t"<<Hx[i][j][k][n]<<endl;
cout<<i<<"\t"<<j<<"\t"<<k<<"\t"<<n<<"\t"<<"Hy"<<"\t"<<Hy[i][j][k][n]<<endl;
cout<<i<<"\t"<<j<<"\t"<<k<<"\t"<<n<<"\t"<<"Ez"<<"\t"<<Ez[i][j][k][n]<<endl;
cout<<i<<"\t"<<j<<"\t"<<k<<"\t"<<n<<"\t"<<"Ey"<<"\t"<<Ey[i][j][k][n]<<endl;
cout<<i<<"\t"<<j<<"\t"<<k<<"\t"<<n<<"\t"<<"Ez"<<"\t"<<Ex[i][j][k][n]<<endl;
}/* k loop*/
}/* j loop*/
}/* i loop*/
}/*t loop*/
eo=8.85e-12;
muo=12.56e-7;
/*boundary condition*/
/*implememnting the FDTD ie.,leap frog method*/
for(n=2;n<=nmax-1;n++)
{for(i=2;i<=imax-2;i++)
{for(j=2;j<=jmax-2;j++)
{for(k=2;k<=kmax-2;k++)
{Hx[i][j][k][n+1]=Hx[i][j][k][n-1]+(1/muo)*(Ey[i][j][k+1][n]-Ey[i][j][k][n])-(1/muo)*(Ez[i][j+1][k][n]-Ez[i][j][k][n]);
Hy[i][j][k][n+1]=Hx[i][j][k][n-1]+(1/muo)*(Ez[i+1][j][k][n]-Ez[i][j][k][n])-(1/muo)*(Ex[i][j][k+1][n]-Ex[i][j][k][n]);
Hx[i][j][k][n+1]=Hx[i][j][k][n-1]+(1/muo)*(Ex[i][j+1][k][n]-Ex[i][j][k][n])-(1/muo)*(Ey[i+1][j][k][n]-Ey[i][j][k][n]);
Ex[i][j][k][n+1]=Ex[i][j][k][n-1]+(1/eo)*(Hz[i][j][k][n]-Hz[i][j-1][k][n])-(1/eo)*(Hy[i][j][k][n]-Hy[i][j][k-1][n]);
Ey[i][j][k][n+1]=Ex[i][j][k][n-1]+(1/eo)*(Hx[i][j][k][n]-Hx[i][j][k-1][n])-(1/eo)*(Hz[i][j][k][n]-Hz[i-1][j][k][n]);
Ez[i][j][k][n+1]=Ex[i][j][k][n-1]+(1/eo)*(Hy[i][j][k][n]-Hy[i-1][j][k][n])-(1/eo)*(Hx[i][j][k][n]-Hx[i][j-1][k][n]);
cout<<Ez[i][j][k][n+1]; }/* k loop*/
}/*j loop*/
} /*i loop*/
}/*t loop*/
return 0; }/*main end*/
|
Advertisement
| Hall of Fame |