Scripts and User Functions Center

Function for the design of an array of waveguides of N * N slots

The next function has the number of slots N.

It generates a slotted waveguide at the origin and along the X axis whose N slots placed on its meridian are alternately rotated 45 and 135 degrees. Each slot feeds through a transition to a top guide placed along the Y axis, the distance of the walls to the center of the nearest slot is lambda's guide / 4 and the distance between consecutive slots is lambda's guide / 2.

The upper guides have the same structure as the feeder guide but are formed by N slots which are positioned alternately with respect to the meridian of the guide, a distance SlotGap and without rotation.

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter; 
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;


    void waveguideFunction(int N) {

        // Parameters that can be modified
        double a = 2.12132;   // waveguide width
        double b = 1.016;     // waveguide heigth
        double f = 1.0E10;    // working frequency
        double c = 3.0E10;    // light speed(cm)

        // Mode converter parameters
        double lambda = c / f;
        double fc = c / (2 * a);    
        double lambdag = lambda / Math.sqrt(1 - Math.pow(fc / f, 2.0));
        double Length = (N - 1) * (lambdag / 2) + (6 * lambdag / 4);
        double L = lambdag / 2.0;

        double SlotLength = 0.81 * (lambda / 2);
        double SlotThin = 0.05 * lambda;
        double dStart = 3 * (lambdag / 4.0);   //distance from the end of the waveguide to the first slot center
        double SlotGap = 0.243953;

        double[] pos_ran = new double[N];
        double[] posy_ran = new double[N];
        double[] angulos = new double[N];
        double[] posx_waveguide = new double[N];
        double posy_waveguide = (Length / 2) - (a / 2) - (lambdag / 4);
        double indice = 0;

        String EOL = "\r\n";
        String separator = "\t";
        BufferedWriter bw = null;
        String cadena;
        double aux, aux1, aux2, aux3, aux4;
        try {
            bw = new BufferedWriter(new FileWriter("./mydatafiles/script_waveguide.nfs"));

            bw.write("#" + EOL);
            bw.write("#	 newFASANT script file" + EOL);
            bw.write("#" + EOL);

            //Feeding Waveguide
            
            
            aux= -(b/2)-0.05;
            bw.write("box -n BoxMain -p " + -Length / 2 + " " + -a / 2 + " " + aux + " " + Length + " " + a + " " + b + " " + EOL);
            bw.write("explode -s BoxMain " + EOL);
            
            //feeding port
            bw.write("delete -s BoxMain_5 " + EOL);
            bw.write("group -s BoxMain_1 BoxMain_2 BoxMain_3 BoxMain_4 BoxMain_6 -n " + "feeding_waveguide" + EOL);
            
            //Slots Position and Rotation Angle 
            pos_ran[0] = -(Length / 2) + dStart;
            angulos[0] = 45;       /////////Angulo rotacion ultimo
            for (int i = 1; i <= N - 1; i++) { 

                pos_ran[i] = pos_ran[i - 1] + L;

                if (i % 2 == 0) {
                    angulos[i] = 135;
                } else {
                    angulos[i] = 45;
                }
            }

            //Upper Slots Boxes    
            for (int j = 0; j <= N - 1; j++) {

                aux = pos_ran[j] - (SlotLength / 2);
                aux2=(b/2)-0.05;
                cadena = "box -n BoxSlot" + (j + 100000) + " -p " + aux + " " + -SlotThin / 2 + " " + aux2 + " " + SlotLength + " " + SlotThin + " " + 0 + " ";
                bw.write(cadena + EOL);
                
                if (j % 2 == 0) {
                    bw.write("rotate -s BoxSlot" + (j + 100000) + " -p " + pos_ran[j] + " " + 0 + " " + aux2 + " " + pos_ran[j] + " " + 0 + " " + (b / 2) + 1 + " " + 45 + " " + EOL);
                } else {
                    bw.write("rotate -s BoxSlot" + (j + 100000) + " -p " + pos_ran[j] + " " + 0 + " " + aux2 + " " + pos_ran[j] + " " + 0 + " " + (b / 2) + 1 + " " + 135 + " " + EOL);
                }

            }

            
		  //Boolean operation to create the slot
            bw.write("booleanOutside -s " + " -objectA feeding_waveguide " + " -objectB BoxSlot" + (100000) + " -n " + " feeding_waveguide_" + (0) + " " + EOL);

            for (int k = 1; k <= N - 1; k++) {

                bw.write("booleanOutside -s " + " -objectA feeding_waveguide_" + (k - 1) + " -objectB BoxSlot" + (k + 100000) + " -n " + " feeding_waveguide_" + (k) + " " + EOL);
            }

            
            
            //First Upper Waveguide
            
            //Positioning of the waveguide just above of the feeding waveguide
            bw.write("box -n BoxMain1 -p " + -(Length / 2) + " " + -(a / 2) + " " + +b / 2 + " " + Length + " " + a + " " + b + " " + EOL);
            bw.write("explode -s BoxMain1 " + EOL);

            //Erased of the waveguide´s rigth side to avoid overlapped objects
            bw.write("delete -s BoxMain1_2 " + EOL);
            bw.write("group -s BoxMain1_1 BoxMain1_3 BoxMain1_4 BoxMain1_5 BoxMain1_6 -n " + "waveguide_0" + EOL);

            //Upper Slots Position and distance to waveguide´s axis
            for (int i = 0; i <= N - 1; i++) { 

                posx_waveguide[i] = -(Length / 2) + (3 * lambdag / 4) + i * (lambdag / 2);

                if (i % 2 == 0) {
                    posy_ran[i] = SlotGap;
                } else {
                    posy_ran[i] = -SlotGap;
                }
            }

            //Feeding Slot
            aux = -(Length / 2) + (lambdag / 4) + (a / 2) - (SlotLength / 2);
            aux1 = -(Length / 2) + (lambdag / 4) + (a / 2); 
            bw.write("box -n BoxSlot" + (N + 200000) + " -p " + aux + " " + -(SlotThin / 2) + " " + b / 2 + " " + SlotLength + " " + SlotThin + " " + 0 + " " + EOL);
            bw.write("rotate -s BoxSlot" + (N + 200000) + " -p " + aux1 + " " + 0 + " " + b / 2 + " " + aux1 + " " + 0 + " " + (b / 2) + 1 + " " + 135 + " " + EOL);

            //Upper Slots Boxes
            for (int j = 0; j <= N - 1; j++) {

                aux = pos_ran[j] - (SlotLength / 2);
                cadena = "box -n BoxSlot" + (j + 200000) + " -p " + aux + " " + posy_ran[j] + " " + 3 * b / 2 + " " + SlotLength + " " + SlotThin + " " + 0 + " ";
                bw.write(cadena + EOL);

            }

            //Boolean operation to create the slot
            bw.write("booleanOutside -s " + " -objectA waveguide_0 " + " -objectB BoxSlot" + (200000) + " -n " + " sup_waveguide_" + (0) + " " + EOL);            
            for (int k = 1; k <= N; k++) {

                bw.write("booleanOutside -s " + " -objectA sup_waveguide_" + (k - 1) + " -objectB BoxSlot" + (k + 200000) + " -n " + " sup_waveguide_" + (k) + " " + EOL);
            }

            //90 degrees rotation of the waveguide and transferred it 0.05cm above of the first slot, erased of the old one.
            aux = -(Length / 2) - a;
            aux1 = -(Length / 2) + (3 * lambdag / 4) - (a / 2);
            aux2 = -(a / 2) - (lambdag / 4);
            bw.write("rotate -s sup_waveguide_" + (N) + " -p " + -Length / 2 + " " + -a / 2 + " " + b / 2 + " " + -Length / 2 + " " + -a / 2 + " " + (b / 2) + 1 + " " + 90 + " " + EOL);
            bw.write("copy -s sup_waveguide_" + (N) + " -n " + "supr_waveguide1" + " -p " + aux + " " + -a / 2 + " " + b / 2 + " " + aux1 + " " + aux2 + " " + (b / 2) + " " + EOL);
            bw.write("delete -s sup_waveguide_" + (N) + " " + EOL);

            //Pipe that connects both waveguides 
		  aux = -(Length / 2) + 3*(lambdag / 4) - (SlotLength / 2);
            aux1 = -(Length / 2) + (lambdag / 4) + (a / 2); 
            aux2= (b/2)-0.05;
            aux3= -(Length / 2) + 3*(lambdag / 4) + (SlotLength / 2);
            aux4=-(Length / 2) + 3*(lambdag / 4);
            bw.write("box -n BoxSlot" + (1 + 400000) + " -p " + aux + " " + -(SlotThin / 2) + " " + aux2 + " " + SlotLength + " " + 0 + " " + 0.05 + " " + EOL);
            bw.write("box -n BoxSlot" + (2 + 400000) + " -p " + aux + " " + -(SlotThin / 2) + " " + aux2 + " " + 0 + " " + SlotThin + " " + 0.05 + " " + EOL);
            bw.write("box -n BoxSlot" + (3 + 400000) + " -p " + aux3 + " " + -(SlotThin / 2) + " " + aux2 + " " + 0 + " " + SlotThin + " " + 0.05 + " " + EOL);
            bw.write("box -n BoxSlot" + (4 + 400000) + " -p " + aux + " " + (SlotThin / 2) + " " + aux2 + " " + SlotLength + " " + 0 + " " + 0.05 + " " + EOL);
            bw.write("group -s BoxSlot400001 BoxSlot400002 BoxSlot400003 BoxSlot400004 -n " + "canal1" + EOL);
            bw.write("rotate -s canal1 -p " + aux4 + " " + 0 + " " + aux2 + " " + aux4 + " " + 0 + " " + aux2 + 1 + " " + 45 + " " + EOL);
            bw.write("group -s canal1 supr_waveguide1_1 -n " + "supr_waveguide_1_1" + EOL);




            
            //Second Waveguide
            
            //Positioning of the waveguide just above of the feeding waveguide
            bw.write("box -n BoxMain2 -p " + -(Length / 2) + " " + -(a / 2) + " " + +b / 2 + " " + Length + " " + a + " " + b + " " + EOL);
            bw.write("explode -s BoxMain2 " + EOL);

            //Erased of the waveguide´s rigth side to avoid overlapped objects
            bw.write("delete -s BoxMain2_2 " + EOL);
            bw.write("group -s BoxMain2_1 BoxMain2_3 BoxMain2_4 BoxMain2_5 BoxMain2_6 -n " + "waveguide_1" + EOL);

		  //Feeding Slot Box
            aux = -(Length / 2) + (lambdag / 4) + (a / 2) - (SlotLength / 2);
            aux1 = -(Length / 2) + (lambdag / 4) + (a / 2); //cadena = "box -n BoxSlot" + (N + 200000) + " -p " + aux + " " + -(SlotThin / 2) + " " + b / 2 + " " + SlotLength + " " + SlotThin + " " + 0 + " ";
            bw.write("box -n BoxSlot" + (N + 300000) + " -p " + aux + " " + -(SlotThin / 2) + " " + b / 2 + " " + SlotLength + " " + SlotThin + " " + 0 + " " + EOL);
            bw.write("rotate -s BoxSlot" + (N + 300000) + " -p " + aux1 + " " + 0 + " " + b / 2 + " " + aux1 + " " + 0 + " " + (b / 2) + 1 + " " + 45 + " " + EOL);

            //Upper Slots Boxes
            for (int j = 0; j <= N - 1; j++) { 

                aux = pos_ran[j] - (SlotLength / 2);
                cadena = "box -n BoxSlot" + (j + 300000) + " -p " + aux + " " + posy_ran[j] + " " + 3 * b / 2 + " " + SlotLength + " " + SlotThin + " " + 0 + " ";
                bw.write(cadena + EOL);

            }

            ////Boolean operation to create the slot
            bw.write("booleanOutside -s " + " -objectA waveguide_1 " + " -objectB BoxSlot" + (300000) + " -n " + " sup2_waveguide_5" + (0) + " " + EOL);

            for (int k = 1; k <= N ; k++) {

                bw.write("booleanOutside -s " + " -objectA sup2_waveguide_5" + (k - 1) + " -objectB BoxSlot" + (k + 300000) + " -n " + " sup2_waveguide_5" + (k) + " " + EOL);
            }

            //90 degrees rotation of the waveguide and transferred it 0.05cm above of the second slot, erased of the old one.
            aux = -(Length / 2) - a;
            aux1 = -(Length / 2) + (3 * lambdag / 4) - (a / 2) + 1 * (lambdag / 2);
            aux2 = -(a / 2) - (lambdag / 4);
            bw.write("rotate -s sup2_waveguide_5" + (N) + " -p " + -Length / 2 + " " + -a / 2 + " " + b / 2 + " " + -Length / 2 + " " + -a / 2 + " " + (b / 2) + 1 + " " + 90 + " " + EOL);
            bw.write("copy -s sup2_waveguide_5" + (N) + " -n " + "supr_waveguide2" + " -p " + aux + " " + -a / 2 + " " + b / 2 + " " + aux1 + " " + aux2 + " " + (b / 2) + " " + EOL);
            bw.write("delete -s sup2_waveguide_5" + (N) + " " + EOL);

            //Pipe that connects both waveguides 
  		  aux = -(Length / 2) + 3*(lambdag / 4) + a - (SlotLength / 2);
            aux1 = -(Length / 2) + (lambdag / 4) + (a / 2); 
            aux2= (b/2)-0.05;
            aux3= -(Length / 2) + 3*(lambdag / 4) + a +(SlotLength / 2);
            aux4=-(Length / 2) + 3*(lambdag / 4) + a;
            bw.write("box -n BoxSlot" + (1 + 500000) + " -p " + aux + " " + -(SlotThin / 2) + " " + aux2 + " " + SlotLength + " " + 0 + " " + 0.05 + " " + EOL);
            bw.write("box -n BoxSlot" + (2 + 500000) + " -p " + aux + " " + -(SlotThin / 2) + " " + aux2 + " " + 0 + " " + SlotThin + " " + 0.05 + " " + EOL);
            bw.write("box -n BoxSlot" + (3 + 500000) + " -p " + aux3 + " " + -(SlotThin / 2) + " " + aux2 + " " + 0 + " " + SlotThin + " " + 0.05 + " " + EOL);
            bw.write("box -n BoxSlot" + (4 + 500000) + " -p " + aux + " " + (SlotThin / 2) + " " + aux2 + " " + SlotLength + " " + 0 + " " + 0.05 + " " + EOL);
            bw.write("group -s BoxSlot500001 BoxSlot500002 BoxSlot500003 BoxSlot500004 -n " + "canal2" + EOL);
            bw.write("rotate -s canal2 -p " + aux4 + " " + 0 + " " + aux2 + " " + aux4 + " " + 0 + " " + aux2 + 1 + " " + 135 + " " + EOL);
            bw.write("group -s canal2 supr_waveguide2_1 -n " + "supr_waveguide_2_1" + EOL);

            // resto de Guias

		  aux=-(Length / 2) + (3 * lambdag / 4) - (a / 2);
		  aux1=-(Length / 2) + (3 * lambdag / 4) - (a / 2) + 1 * (lambdag / 2);
		  
            aux3=-(a / 2) - (lambdag / 4);
		  for (int i = 2; i <= N - 1; i++) { 
		  aux2=-(Length / 2) + (3 * lambdag / 4) - (a / 2)+ i*(lambdag / 2);

            if (i % 2 == 0) {
                    bw.write("copy -s supr_waveguide_1_1" + " -n " + "supr_waveguide_1_"+ (i) + " -p " + aux + " " + aux3 + " " + b / 2 + " " + aux2 + " " + aux3 + " " + (b / 2) + " " + EOL);
                    
            }else {
                    bw.write("copy -s supr_waveguide_2_1" + " -n " + "supr_waveguide_2_" + (i) + " -p " + aux1 + " " + aux3 + " " + b / 2 + " " + aux2 + " " + aux3 + " " + (b / 2) + " " + EOL);
                }
            }


            //Addition of Lateral side to the last waveguide
         	  aux2=-(Length / 2) + (3 * lambdag / 4)-(a/2)+ N*(lambdag / 2);
         	  aux=(b/2)+b;
         	  aux1=-(a / 2) - (lambdag / 4) + Length;
		  bw.write("surfaceCornerPoints -n " + " pared -p "  + aux2 + " "+ aux3 + " "+ (b/2) + " "+ aux2 + " "+ aux3 + " "+ aux + " "+ aux2 + " "+ aux1 + " "+ aux + " "+ aux2  + " "+ aux1 + " "+ (b/2) + " " + EOL);
		  if (N % 2 == 0) {
       			bw.write("group -s pared supr_waveguide_2_" +(N-1) + "_1 -n waveguide1_8 " + "  " + EOL);
                    
            }else {
                    bw.write("group -s pared supr_waveguide_1_" +(N-1) + "_1 -n waveguide1_8 " + "  " + EOL);
                }

            

        } catch (Exception e) {
            System.err.println("Cannot write file " + EOL);
        } finally {
            try {
                bw.close();
            } catch (IOException ex) {
                Logger.getLogger(NewMain.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

    } 

Did you find this information useful?

We use cookies on this website to improve your navigation experience on this site. By using this site, you agree to our cookie policy.

I agree