~emmanuel-lambert/python-meep/intec

« back to all changes in this revision

Viewing changes to tests/convergence_cyl_waveguide.py

  • Committer: emmanuel.lambert at ugent
  • Date: 2009-11-23 10:23:17 UTC
  • Revision ID: emmanuel.lambert@intec.ugent.be-20091123102317-m00vrwyw0m6kpcmm
further merging with NS / replacing tests dir with default tests and creating new 'tests-intec' subdir

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    return 0
33
33
 
34
34
def test_convergence_without_averaging():
35
 
    use_averaging(False)
36
35
    w0 = 0.2858964  # exact to last digit 
37
36
 
38
37
    n = [0,0]
44
43
    for a in range(MINRES, MAXRES+RESSTEP, RESSTEP):
45
44
        vol = volcyl(1.0,0.0,a)
46
45
        s= structure(vol, EPS)
47
 
        f=fields_complex(s, 1)
 
46
        f=fields(s, 1)
48
47
        f.use_bloch(vec(0.1))
49
48
        f.set_boundary(High, R, Metallic)
50
49
        f.add_point_source(Hr, w0, 2.0, 0.0, 5.0, veccyl(0.2,0.0))
96
95
        a2_mean[i] /= n[i]
97
96
    for i in range(0,2):
98
97
        a2_meansqr[i] /= n[i]
99
 
 
100
 
 
101
 
    failOdd = False
102
 
    failEven = False
103
98
  
104
99
    if (find_exponent(a_mean[0], a_meansqr[0], a2_mean[0], a2_meansqr[0], "Even") != 1):
105
 
        master_printf("Failed even convergence test without averaging!\n")
106
 
        failEven = True
107
 
 
 
100
        abort("Failed even convergence test with no fancy averaging!\n")
108
101
    if (find_exponent(a_mean[1], a_meansqr[1], a2_mean[1], a2_meansqr[1], "Odd") != 1):
109
 
        master_printf("Failed odd convergence test without fancy averaging!\n")
110
 
        failOdd = True
111
 
 
112
 
    if failOdd or failEven:
113
 
       abort("failed convergence test\n")
114
 
 
115
 
    master_printf("Passed convergence test without averaging!\n")
 
102
        abort("Failed odd convergence test with no fancy averaging!\n")
 
103
 
 
104
    master_printf("Passed convergence test with no fancy averaging!\n")
116
105
 
117
106
 
118
107
def test_convergence_with_averaging():
119
 
    use_averaging(True)
120
108
    w0 = 0.2858964  #// exact to last digit 
121
109
    n = [0,0]
122
110
    a_mean = [0,0]
129
117
        s = structure(vol, EPS)
130
118
        s.set_epsilon(EPS)
131
119
 
132
 
        f=fields_complex(s, 1)
 
120
        f=fields(s, 1)
133
121
        f.use_bloch(vec(0.1))
134
122
        f.set_boundary(High, R, Metallic)
135
123
        f.add_point_source(Hr, w0, 2.0, 0.0, 5.0, veccyl(0.2,0.0))
188
176
 
189
177
 
190
178
master_printf("Testing convergence of a waveguide mode frequency...\n")
 
179
test_convergence_without_averaging()
191
180
test_convergence_with_averaging()
192
 
test_convergence_without_averaging()
193
181