Beispiel #1
0
// TFSF boundaries
Field TFSF(Field EM, Loss lass, Loss1d lass1d, double Cour){

    int dx, dy;

    // TFSF boundary
    Bound first, last;
    first.x = 10; last.x = 390;
    first.y = 10; last.y = 190;

    // Update along right
    dx = last.x;
    for (int dy = first.y; dy <= last.y; dy++){
        EM.Hz(dx, dy) -= lass.HzE(dx, dy) * EM.Ey1d[dx];
    }

    // Updating Hz along left
    dx = first.x - 1;
    for (int dy = first.y; dy <= last.y; dy++){
        EM.Hz(dx, dy) += lass.HzE(dx, dy) * EM.Ey1d[dx + 1];
    }

    // Insert 1d grid stuff here. Update magnetic and electric field
    Hupdate1d(EM, lass1d, EM.t);
    Eupdate1d(EM, lass1d, EM.t);
    //EM.Ey1d[10] = ricker(EM.t,0, Cour);
    EM.Ey1d[10] = planewave(EM.t, 15, Cour, 30, 40);
    EM.t++;
    std::cout << EM.t << '\n';

    // Check mag instead of ricker.
    // Update along right edge!
    dx = last.x;
    for (int dy = first.y; dy <= last.y; dy++){
        EM.Ey(dx,dy) -= lass.EyH(dx, dy) * EM.Hz1d[dx];
    }

    // Updating along left edge
    dx = first.x;
    for (int dy = first.y; dy <= last.y; dy++){
        EM.Ey(dx,dy) += lass.EyH(dx, dy) * EM.Hz1d[dx-1];
    }

    // Updating along top
    dy = last.y;
    for (int dx = first.x; dx <= last.x; dx++){
        EM.Ex(dx,dy) += lass.ExH(dx, dy) * EM.Hz1d[dx];
    }

    // Update along bot
    dy = first.y;
    for (int dx = first.x; dx <= last.x; dx++){
        EM.Ex(dx,dy) -= lass.ExH(dx, dy) * EM.Hz1d[dx];
    }

    return EM;

}
Beispiel #2
0
Field Eupdate2d(Field EM, Loss lass, int t){
    // update electric field
    for (size_t dx = 0; dx < spacex - 1; dx++){
        for (size_t dy = 1; dy < spacey - 1; dy++){
           EM.Ex(dx,dy) = lass.ExE(dx,dy) * EM.Ex(dx,dy)
                       + lass.ExH(dx,dy) * (EM.Hz(dx, dy) - EM.Hz(dx, dy - 1));
        }
    }

    for (size_t dx = 1; dx < spacex - 1; dx++){
        for (size_t dy = 0; dy < spacey - 1; dy++){
           EM.Ey(dx,dy) = lass.EyE(dx,dy) * EM.Ey(dx,dy)
                       - lass.EyH(dx,dy) * (EM.Hz(dx, dy) - EM.Hz(dx - 1, dy));
        }
    }

    return EM;
}
Beispiel #3
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;
}