Beispiel #1
0
// 2 dimensional functions for E / H movement
Field Hupdate2d(Field EM, Loss lass, int t){
    // update magnetic field, x direction
    for (size_t dx = 0; dx < spacex - 1; dx++){
        for (size_t dy = 0; dy < spacey - 1; dy++){
           EM.Hz(dx,dy) = lass.HzH(dx,dy) * EM.Hz(dx, dy)
                       + lass.HzE(dx,dy) * ((EM.Ex(dx, dy + 1)
                                         - EM.Ex(dx, dy))
                                         - (EM.Ey(dx + 1,dy)
                                         - EM.Ey(dx, dy)));
        }
    }

    return EM;

}
Beispiel #2
0
// Creating loss
Loss createloss2d(Loss lass, double eps, double Cour, double loss){

    double radius = 40;
    int sourcex = 200, sourcex2 = 100;
    int sourcey = 100, sourcey2 = 100;
    double dist, var, Q, epsp, mup, dist2;
    for (size_t dx = 0; dx < spacex; dx++){
        for (size_t dy = 0; dy < spacey; dy++){
             dist = sqrt((dx - sourcex)*(dx - sourcex)
                       + (dy - sourcey)*(dy - sourcey));
             dist2 = sqrt((dx - sourcex2)*(dx - sourcex2)
                        + (dy - sourcey2)*(dy - sourcey2));

            // if (dx > 100 && dx < 150 && dy > 75 && dy < 125){
            if (dist < radius){
                Q = cbrt(-(radius / dist) + sqrt((radius/dist)
                                               * (radius/dist) + (1.0/27.0)));
                var = (Q - (1.0 / (3.0 * Q))) * (Q - (1.0/ (3.0 * Q)));
                // var = 1.4;
                if (abs(var) > 1000){
                    var = 1000;
                }

                if (isnan(var)){
                    var = 1000;
                }

                epsp = eps / (var * var);
                mup = 1 / (var * var);

                lass.ExH(dx, dy) = Cour * epsp /(1.0 - loss);
                lass.ExE(dx, dy) = (1.0 - loss) / (1.0 + loss);
                lass.EyE(dx, dy) = (1.0 - loss) / (1.0 + loss);
                lass.EyH(dx, dy) = Cour * epsp / (1.0 + loss);
                lass.HzE(dx, dy) = Cour * (mup / eps) / (1.0 + loss);
                lass.HzH(dx, dy) = (1.0 - loss) / (1.0 + loss);

/*
                // PEC stuff -- not complete!
                lass.ExH(dx, dy) = 0;
                lass.ExE(dx, dy) = 0;
                lass.HzH(dx, dy) = 0;
                lass.HzE(dx, dy) = 0;
                lass.ExE(dx, dy) = 0;
                lass.ExH(dx, dy) = 0;
*/

            }
            else{

                lass.ExH(dx, dy) = Cour * eps;
                lass.ExE(dx, dy) = 1.0;
                lass.EyE(dx, dy) = 1.0;
                lass.EyH(dx, dy) = Cour * eps;
                lass.HzE(dx, dy) = Cour / eps;
                lass.HzH(dx, dy) = 1.0;

            }
        }
    }


    return lass;
}