Example #1
0
/* update electric field */
void updateE3(Grid *g) {
  int mm;

  for (mm = 1; mm < SizeX - 1; mm++)
    Ez(mm) = Ceze(mm) * Ez(mm) +      /*@ \label{update3B} @*/
             Cezh(mm) * (Hy(mm) - Hy(mm - 1));

  return;
}
Example #2
0
void gridInit3(Grid *g){
    double imp0 = 377.0;
    double imp0_inv = 1./377.0;
    int mm;
    
    SizeX   = 200;
    MaxTime = 400;
    Cdtds   = 1.0;
    
    ALLOC_1D(g->ez, (SizeX), double);
    ALLOC_1D(g->ceze, (SizeX), double);
    ALLOC_1D(g->cezh, (SizeX), double);
    
    ALLOC_1D(g->hy, (SizeX - 1), double);
    ALLOC_1D(g->chyh, (SizeX - 1), double);
    ALLOC_1D(g->chye, (SizeX - 1), double);
    
    #pragma omp parallel for
    /* set e field coeffs */
    for (mm = 0; mm < SizeX; mm++) {
        if (mm < 100) {
            Ceze(mm) = 1.0;
            Cezh(mm) = imp0;
        }else {
            Ceze(mm) = 1.0;
            Cezh(mm) = imp0 / EPSR ;
        }
    }

    #pragma omp parallel for    
    /*magnetic field coeffs */
    
    for (mm = 0; mm < (SizeX - 1); mm++) {
//        if (mm < LOSS_LAYER) {
            Chyh(mm) = 1.0;
            Chye(mm) = 1.0 / imp0;
//        }else {
//            Chyh(mm) = (1.0 - LOSS) / (1.0 + LOSS);
//            Chye(mm) = 1.0 * imp0_inv / (1.0 + LOSS);
//        }
    }
    
    return;
}
Example #3
0
void gridInit3(Grid *g) {
    double imp0 = 377.0;
    int mm;

    SizeX = 200;   // size of domain         /*@ \label{gridinit3C} @*/
    MaxTime = 450; // duration of simulation
    Cdtds = 1.0;   // Courant number         /*@ \label{gridinit3D} @*/

    ALLOC_1D(g->ez,   SizeX, double);  /*@ \label{gridinit3E} @*/
    ALLOC_1D(g->ceze, SizeX, double);
    ALLOC_1D(g->cezh, SizeX, double);
    ALLOC_1D(g->hy,   SizeX - 1, double);
    ALLOC_1D(g->chyh, SizeX - 1, double);
    ALLOC_1D(g->chye, SizeX - 1, double);  /*@ \label{gridinit3F} @*/

    /* set electric-field update coefficients */
    for (mm = 0; mm < SizeX; mm++)
        if (mm < 100) {
            Ceze(mm) = 1.0;
            Cezh(mm) = imp0;
        } else if (mm < LOSS_LAYER) {
            Ceze(mm) = 1.0;
            Cezh(mm) = imp0 / EPSR;
        } else {
            Ceze(mm) = (1.0 - LOSS) / (1.0 + LOSS);
            Cezh(mm) = imp0 / EPSR / (1.0 + LOSS);
        }

    /* set magnetic-field update coefficients */
    for (mm = 0; mm < SizeX - 1; mm++)
        if (mm < LOSS_LAYER) {
            Chyh(mm) = 1.0;
            Chye(mm) = 1.0 / imp0;
        } else {
            Chyh(mm) = (1.0 - LOSS) / (1.0 + LOSS);
            Chye(mm) = 1.0 / imp0 / (1.0 + LOSS);
        }

    return;
}
Example #4
0
void gridInit(Grid *g) {
  double imp0=377.0;
  int mm, nn, pp;

  // sphere parameters
  int m_c=17, n_c=17, p_c=17, isSpherePresent;
  double m2, n2, p2, r2, rad=8;

  Type    = threeDGrid;
  SizeX   = 35; // size of domain
  SizeY   = 35;
  SizeZ   = 35;
  MaxTime = 300; // duration of simulation
  Cdtds   = 1.0/sqrt(3.0); // Courant number

  printf("If the sphere present: (1=yes, 0=no) ");
  scanf(" %d",&isSpherePresent);

  /* memory allocation */
  ALLOC_3D(g->hx,  SizeX,  SizeY-1,SizeZ-1,double);
  ALLOC_3D(g->chxh,SizeX,  SizeY-1,SizeZ-1,double);
  ALLOC_3D(g->chxe,SizeX,  SizeY-1,SizeZ-1,double);
  ALLOC_3D(g->hy,  SizeX-1,SizeY,  SizeZ-1,double);
  ALLOC_3D(g->chyh,SizeX-1,SizeY,  SizeZ-1,double);
  ALLOC_3D(g->chye,SizeX-1,SizeY,  SizeZ-1,double);
  ALLOC_3D(g->hz,  SizeX-1,SizeY-1,SizeZ,  double);
  ALLOC_3D(g->chzh,SizeX-1,SizeY-1,SizeZ,  double);
  ALLOC_3D(g->chze,SizeX-1,SizeY-1,SizeZ,  double);

  ALLOC_3D(g->ex,  SizeX-1,SizeY,  SizeZ,  double);
  ALLOC_3D(g->cexe,SizeX-1,SizeY,  SizeZ,  double);
  ALLOC_3D(g->cexh,SizeX-1,SizeY,  SizeZ,  double);
  ALLOC_3D(g->ey,  SizeX,  SizeY-1,SizeZ,  double);
  ALLOC_3D(g->ceye,SizeX,  SizeY-1,SizeZ,  double);
  ALLOC_3D(g->ceyh,SizeX,  SizeY-1,SizeZ,  double);
  ALLOC_3D(g->ez,  SizeX,  SizeY,  SizeZ-1,double);
  ALLOC_3D(g->ceze,SizeX,  SizeY,  SizeZ-1,double);
  ALLOC_3D(g->cezh,SizeX,  SizeY,  SizeZ-1,double);
  
  /* set electric-field update coefficients */
  for (mm=0; mm<SizeX-1; mm++)
    for (nn=0; nn<SizeY; nn++) 
      for (pp=0; pp<SizeZ; pp++) {
	Cexe(mm,nn,pp) = 1.0;
	Cexh(mm,nn,pp) = Cdtds*imp0;
      }

  for (mm=0; mm<SizeX; mm++)
    for (nn=0; nn<SizeY-1; nn++) 
      for (pp=0; pp<SizeZ; pp++) {
	Ceye(mm,nn,pp) = 1.0;
	Ceyh(mm,nn,pp) = Cdtds*imp0;
      }

  for (mm=0; mm<SizeX; mm++)
    for (nn=0; nn<SizeY; nn++) 
      for (pp=0; pp<SizeZ-1; pp++) {
	Ceze(mm,nn,pp) = 1.0;
	Cezh(mm,nn,pp) = Cdtds*imp0;
      }

  // zero the nodes associated with the PEC sphere
  if (isSpherePresent) {
    r2 = rad*rad;
    for (mm=2; mm<SizeX-2; mm++) {
      m2 = (mm+0.5-m_c)*(mm+0.5-m_c);
      for (nn=2; nn<SizeY-2; nn++) {
	n2 = (nn+0.5-n_c)*(nn+0.5-n_c);
	for (pp=2; pp<SizeZ-2; pp++) {
	  p2 = (pp+0.5-p_c)*(pp+0.5-p_c);
	  // if center of a cube is within less than the radius to the
	  // center of the sphere, zero all the surrounding electric
	  // field nodes
	  if (m2+n2+p2 < r2) {
	    // zero surrounding Ex nodes
	    Cexe(mm,nn,  pp) = 0.0;
	    Cexe(mm,nn+1,pp) = 0.0;
	    Cexe(mm,nn,  pp+1) = 0.0;
	    Cexe(mm,nn+1,pp+1) = 0.0;
	    Cexh(mm,nn,  pp) = 0.0;
	    Cexh(mm,nn+1,pp) = 0.0;
	    Cexh(mm,nn,  pp+1) = 0.0;
	    Cexh(mm,nn+1,pp+1) = 0.0;
	    // zero surrounding Ey nodes
	    Ceye(mm,  nn,pp) = 0.0;
	    Ceye(mm+1,nn,pp) = 0.0;
	    Ceye(mm,  nn,pp+1) = 0.0;
	    Ceye(mm+1,nn,pp+1) = 0.0;
	    Ceyh(mm,  nn,pp) = 0.0;
	    Ceyh(mm+1,nn,pp) = 0.0;
	    Ceyh(mm,  nn,pp+1) = 0.0;
	    Ceyh(mm+1,nn,pp+1) = 0.0;
	    // zero surrounding Ez nodes
	    Ceze(mm,  nn,  pp) = 0.0;
	    Ceze(mm+1,nn,  pp) = 0.0;
	    Ceze(mm,  nn+1,pp) = 0.0;
	    Ceze(mm+1,nn+1,pp) = 0.0;
	    Cezh(mm,  nn,  pp) = 0.0;
	    Cezh(mm+1,nn,  pp) = 0.0;
	    Cezh(mm,  nn+1,pp) = 0.0;
	    Cezh(mm+1,nn+1,pp) = 0.0;
	  }
	}
      }
    }
  }


  /* set magnetic-field update coefficients */
  for (mm=0; mm<SizeX; mm++)
    for (nn=0; nn<SizeY-1; nn++) 
      for (pp=0; pp<SizeZ-1; pp++) {
	Chxh(mm,nn,pp) = 1.0;
	Chxe(mm,nn,pp) = Cdtds/imp0;
      }

  for (mm=0; mm<SizeX-1; mm++)
    for (nn=0; nn<SizeY; nn++) 
      for (pp=0; pp<SizeZ-1; pp++) {
	Chyh(mm,nn,pp) = 1.0;
	Chye(mm,nn,pp) = Cdtds/imp0;
      }

  for (mm=0; mm<SizeX-1; mm++)
    for (nn=0; nn<SizeY-1; nn++) 
      for (pp=0; pp<SizeZ; pp++) {
	Chzh(mm,nn,pp) = 1.0;
	Chze(mm,nn,pp) = Cdtds/imp0;
      }

  return;
}