Scripted PolygonsΒΆ

Learning targets

  • Use scripting to create complicated polygons
  • Transparent boundary conditions in 3D
  • Inhomogeneous exterior domain: waveguides and layered media

This example describes a computational domain with transparent boundary conditions at all sides. In this case, waveguides are included some of which touch the boundary of the computational domain, and which are modeled to extend also to the exterior domain. Further, a substrate is included which also extends to the exterior domain.

The following figure shows an image of parts of the geometry and mesh:

_images/ex3d_scripted_polygons_mesh1.png

The input file layout.jcm is shown below, it is created using the Matlab script run_geometry.m together with the template file layout.ring_resonator.jcmt, also shown below.

Input Files

  • layout.jcm [ASCII]

     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
    
    Layout3D {
      Name = "TutorialExample3D"
      UnitOfLength = 1e-06
      MeshOptions {
        MaximumSideLength = 4
        MinimumMeshAngle = 18
      }
      Extrusion {
        Objects {
          Polygon {
            Name = "ComputationalDomain"
            DomainId = 10
            Priority = -1
            Points = [-6.375 -7.625 ;7.175 -7.625 ;7.175 7.625 ;-6.375 7.625 ;]
            Boundary {
              Class = Transparent
            }
          }
          Polygon {
            Name = "Waveguide"
            DomainId = 20
            Priority = 1
            MeshOptions {
              MaximumSideLength = 0.45
            }
            Points = [5.550000 -7.625000 ;6.050000 -7.625000 ;6.050000 7.625000 ;5.550000 7.625000 ;]
          }
          Polygon {
            Name = "Ring"
            DomainId = 20
            Priority = 1
            MeshOptions {
              MaximumSideLength = 0.45
            }
            Points = [5.244714 1.485540 ;5.202486 1.954725 ;5.118372 2.418235 ;4.993047 2.872339 ;4.827521 3.313381 ;4.623127 3.737810 ;4.381510 4.142209 ;4.104615 4.523321 ;3.794673 4.878079 ;3.454178 5.203625 ;3.085873 5.497339 ;2.692721 5.756856 ;2.277890 5.980087 ;1.844718 6.165233 ;1.396693 6.310805 ;0.937424 6.415630 ;0.470606 6.478865 ;0.000000 6.500000 ;-0.470606 6.478865 ;-0.937424 6.415630 ;-1.396693 6.310805 ;-1.844718 6.165233 ;-2.277890 5.980087 ;-2.692721 5.756856 ;-3.085873 5.497339 ;-3.454178 5.203625 ;-3.794673 4.878079 ;-4.104615 4.523321 ;-4.381510 4.142209 ;-4.623127 3.737810 ;-4.827521 3.313381 ;-4.993047 2.872339 ;-5.118372 2.418235 ;-5.202486 1.954725 ;-5.244714 1.485540 ;-5.244714 -1.485540 ;-5.202486 -1.954725 ;-5.118372 -2.418235 ;-4.993047 -2.872339 ;-4.827521 -3.313381 ;-4.623127 -3.737810 ;-4.381510 -4.142209 ;-4.104615 -4.523321 ;-3.794673 -4.878079 ;-3.454178 -5.203625 ;-3.085873 -5.497339 ;-2.692721 -5.756856 ;-2.277890 -5.980087 ;-1.844718 -6.165233 ;-1.396693 -6.310805 ;-0.937424 -6.415630 ;-0.470606 -6.478865 ;-0.000000 -6.500000 ;0.470606 -6.478865 ;0.937424 -6.415630 ;1.396693 -6.310805 ;1.844718 -6.165233 ;2.277890 -5.980087 ;2.692721 -5.756856 ;3.085873 -5.497339 ;3.454178 -5.203625 ;3.794673 -4.878079 ;4.104615 -4.523321 ;4.381510 -4.142209 ;4.623127 -3.737810 ;4.827521 -3.313381 ;4.993047 -2.872339 ;5.118372 -2.418235 ;5.202486 -1.954725 ;5.244714 -1.485540 ;]
          }
          Polygon {
            Name = "Ring_Inner_Edge"
            DomainId = 10
            Priority = 2
            MeshOptions {
              MaximumSideLength = 4
            }
            Points = [4.745217 1.463108 ;4.707011 1.887608 ;4.630908 2.306974 ;4.517518 2.717831 ;4.367757 3.116869 ;4.182829 3.500876 ;3.964223 3.866761 ;3.713700 4.211577 ;3.433276 4.532548 ;3.125209 4.827089 ;2.791980 5.092831 ;2.436272 5.327632 ;2.060948 5.529602 ;1.669030 5.697116 ;1.263675 5.828824 ;0.848145 5.923666 ;0.425787 5.980878 ;0.000000 6.000000 ;-0.425787 5.980878 ;-0.848145 5.923666 ;-1.263675 5.828824 ;-1.669030 5.697116 ;-2.060948 5.529602 ;-2.436272 5.327632 ;-2.791980 5.092831 ;-3.125209 4.827089 ;-3.433276 4.532548 ;-3.713700 4.211577 ;-3.964223 3.866761 ;-4.182829 3.500876 ;-4.367757 3.116869 ;-4.517518 2.717831 ;-4.630908 2.306974 ;-4.707011 1.887608 ;-4.745217 1.463108 ;-4.745217 -1.463108 ;-4.707011 -1.887608 ;-4.630908 -2.306974 ;-4.517518 -2.717831 ;-4.367757 -3.116869 ;-4.182829 -3.500876 ;-3.964223 -3.866761 ;-3.713700 -4.211577 ;-3.433276 -4.532548 ;-3.125209 -4.827089 ;-2.791980 -5.092831 ;-2.436272 -5.327632 ;-2.060948 -5.529602 ;-1.669030 -5.697116 ;-1.263675 -5.828824 ;-0.848145 -5.923666 ;-0.425787 -5.980878 ;-0.000000 -6.000000 ;0.425787 -5.980878 ;0.848145 -5.923666 ;1.263675 -5.828824 ;1.669030 -5.697116 ;2.060948 -5.529602 ;2.436272 -5.327632 ;2.791980 -5.092831 ;3.125209 -4.827089 ;3.433276 -4.532548 ;3.713700 -4.211577 ;3.964223 -3.866761 ;4.182829 -3.500876 ;4.367757 -3.116869 ;4.517518 -2.717831 ;4.630908 -2.306974 ;4.707011 -1.887608 ;4.745217 -1.463108 ;]
          }
        }
        MultiLayer {
          LayerInterface {
            BoundaryClass = Transparent
          }
          Layer {
            Thickness = 0.225
            DomainIdMapping = [10 1, 20 1]
          }
          LayerInterface {
            GlobalZ = 0.0
          }
          Layer {
            Thickness = 0.25
            DomainIdMapping = [10 3, 20 2]
          }
          Layer {
            Thickness = 0.225
            DomainIdMapping = [10 3, 20 3]
          }
          LayerInterface {
            BoundaryClass = Transparent
          }
        }
      }
      
      
    
  • Matlab script run_geometry.m [ASCII]

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    % Interface for 3D ring resonator (stadium shape) geometry setup
    
    keys.uol = 1.0e-6; % Unit of Length (in m)
    
    % incoming waveguide
    keys.wg_width = 0.5; % waveguide width
    keys.wg_height = 0.25; % waveguide height 
    
    % resonator parameters
    keys.resonator_radius = 5.0; % ring resonator radius
    keys.resonator_wg_gap = 0.3; % gap between resonator and waveguide
    keys.resonator_coupling_length = 2.5;
    
    % meshing parameter
    keys.wg_segment_length = 0.45; % discretization segment length
    
    jcmwave_geo('.', keys, 'jcmt_pattern', 'ring_resonator', 'show', inf);
    
  • Layout template file layout.ring_resonator.jcmt [ASCII]

      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
    <?
    keys.slc1 = 4; % background
    keys.slc2 = keys.wg_segment_length; % waveguide
    keys.offset_xy = keys.wg_segment_length*2.5;
    keys.offset_z = keys.wg_segment_length/2;
    
    % coordinate positions from layout parameters
    x1 = - keys.resonator_radius - keys.wg_width/2 - keys.offset_xy;
    x2 = keys.resonator_radius + keys.wg_width/2 + keys.resonator_wg_gap;
    x3 = x2 + keys.wg_width;
    x4 = x3 + keys.offset_xy;
    
    y1 = -(keys.resonator_radius + keys.wg_width/2 + keys.offset_xy + keys.resonator_coupling_length/2);
    y2 = -y1;
    
    keys.points_cd = [x1 y1; x4 y1; x4 y2; x1 y2];
    keys.points_wg = [x2 y1; x3 y1; x3 y2; x2 y2];
    
    % define circles
    n = ceil(2*pi*keys.resonator_radius/keys.wg_segment_length);
    points_ring_outer = (keys.resonator_radius + keys.wg_width/2)*exp(1i*[0.5:n]*2*pi/n);
    points_ring_inner = (keys.resonator_radius - keys.wg_width/2)*exp(1i*[0.5:n]*2*pi/n);
    
    % insert linear segments to the circles (making them 
    points_ring_outer(1:end/2) = points_ring_outer(1:end/2) + keys.resonator_coupling_length*0.5i;
    points_ring_inner(1:end/2) = points_ring_inner(1:end/2) + keys.resonator_coupling_length*0.5i;
    points_ring_outer(end/2+1:end) = points_ring_outer(end/2+1:end) - keys.resonator_coupling_length*0.5i;
    points_ring_inner(end/2+1:end) = points_ring_inner(end/2+1:end) - keys.resonator_coupling_length*0.5i;
    
    keys.points_ring_outer = [real(points_ring_outer); imag(points_ring_outer)].';
    keys.points_ring_inner = [real(points_ring_inner); imag(points_ring_inner)].';
    
    ?>
    Layout3D {
      Name = "TutorialExample3D"
      UnitOfLength = %(uol)e
      MeshOptions { 
        MaximumSideLength = %(slc1)e
        MinimumMeshAngle = 18
      }
      BoundaryConditions {
        Boundary {
          Direction = All 
          Class = Transparent 
        }
      }
      Extrusion {
        Objects {
          Polygon { 
            Name = "ComputationalDomain" 
            DomainId = 10 
            Priority = -1 
            Points = %(points_cd)3f        
          }
          Polygon { 
            Name = "Waveguide" 
            DomainId = 20 
            Priority = 1
            MeshOptions {
              MaximumSideLength = %(slc2)e          
            }
            Points = %(points_wg)6f
          }
          Polygon { 
            Name = "Ring" 
            DomainId = 20 
            Priority = 1
            MeshOptions {
              MaximumSideLength = %(slc2)e          
            }
            Points = %(points_ring_outer)6f
          }
          Polygon { 
            Name = "Ring_Inner_Edge"
            DomainId = 10
            Priority = 2
            MeshOptions {
              MaximumSideLength = %(slc1)e          
            }
            Points = %(points_ring_inner)6f
          }
        }
        MultiLayer {
    
          Layer { 
            Thickness = %(offset_z)e
            DomainIdMapping = [10 1, 20 1]
          }
          LayerInterface {
            GlobalZ = 0.0
          }
          Layer { 
            Thickness = %(wg_height)e
            DomainIdMapping = [10 3, 20 2]
          }
          Layer { 
            Thickness = %(offset_z)e
            DomainIdMapping = [10 3, 20 3]
          }
        }
      }
    }