@@ -38,36 +38,36 @@ def experimental_series(taus, u_ref_left, u_ref_right, experiment):
38
38
"""
39
39
@type taus list
40
40
"""
41
- print "EXPERIMENTAL SERIES"
41
+ print ( "EXPERIMENTAL SERIES" )
42
42
43
43
errors_left = []
44
44
errors_right = []
45
45
experiment_counter = 1
46
46
n_experiments = taus .__len__ ()
47
47
48
48
for tau in taus :
49
- print "----"
50
- print "%i of %i" % (experiment_counter , n_experiments )
51
- print "tau = %f" % tau
49
+ print ( "----" )
50
+ print ( "%i of %i" % (experiment_counter , n_experiments ) )
51
+ print ( "tau = %f" % tau )
52
52
53
53
u_left , u_right = experiment (tau )
54
54
55
55
# compute error
56
56
e_tot_left = np .sum (np .abs (u_left - u_ref_left )) / u_left .shape [0 ]
57
57
e_tot_right = np .sum (np .abs (u_right - u_ref_right )) / (u_right .shape [0 ])
58
58
59
- print "Error total = %.2e | %.2e" % (e_tot_left , e_tot_right )
59
+ print ( "Error total = %.2e | %.2e" % (e_tot_left , e_tot_right ) )
60
60
61
61
experiment_counter += 1
62
62
errors_left += [e_tot_left ]
63
63
errors_right += [e_tot_right ]
64
64
65
- print "----"
65
+ print ( "----" )
66
66
np .set_printoptions (formatter = {'float' : lambda x : format (x , '6.3E' )}) # print in scientific notation
67
- print repr (np .array (errors_left ))
68
- print repr (np .array (errors_right ))
69
- print taus
70
- print
67
+ print ( repr (np .array (errors_left ) ))
68
+ print ( repr (np .array (errors_right ) ))
69
+ print ( taus )
70
+ print ()
71
71
72
72
return errors_left , errors_right
73
73
@@ -145,7 +145,7 @@ def solve_monolithic_problem(tau, time_stepping_scheme, domain):
145
145
def compute_reference_solution (domain , tau , time_integration_scheme = time_integration .ImplicitTrapezoidalRule ()):
146
146
# compute monolithic at constant spatial and very fine temporal resolution
147
147
148
- print "REFERENCE SOLUTION for grid " + str (domain .grid .x )
148
+ print ( "REFERENCE SOLUTION for grid " + str (domain .grid .x ) )
149
149
150
150
return solve_monolithic_problem (tau , time_integration_scheme , domain )
151
151
@@ -166,7 +166,7 @@ def coupling_experiment(coupling_scheme, time_stepping_schemes, left_domain, rig
166
166
"""
167
167
if type (time_stepping_schemes ) is list :
168
168
experiment_name = time_stepping_schemes [0 ].name + " - " + time_stepping_schemes [1 ].name + " - " + coupling_scheme .name
169
- print experiment_name
169
+ print ( experiment_name )
170
170
experiment_errors_left , experimental_errors_right = experimental_series (experiment_timesteps , u_ref_left , u_ref_right , lambda tau : solve_inhomogeneously_coupled_problem (
171
171
tau , time_stepping_schemes , coupling_scheme , [left_domain , right_domain ]))
172
172
else :
@@ -175,7 +175,7 @@ def coupling_experiment(coupling_scheme, time_stepping_schemes, left_domain, rig
175
175
experiment_name += " - " + coupling_scheme .name_suffix
176
176
except AttributeError :
177
177
pass
178
- print experiment_name
178
+ print ( experiment_name )
179
179
experiment_errors_left , experimental_errors_right = experimental_series (experiment_timesteps , u_ref_left , u_ref_right , lambda tau : solve_coupled_problem (tau , time_stepping_schemes , coupling_scheme , left_domain , right_domain ))
180
180
181
181
return Experiment (experiment_name , [left_domain .grid .h , right_domain .grid .h ], experiment_timesteps , experiment_errors_left , experimental_errors_right , additional_numerical_parameters = numeric_parameters .numeric_parameters_dict )
@@ -193,7 +193,7 @@ def monolithic_experiment(time_stepping_scheme, monolithic_domain, u_ref_left, u
193
193
:return:
194
194
"""
195
195
experiment_name = time_stepping_scheme .name + " - " + coupling_schemes .MonolithicScheme ().name
196
- print experiment_name
196
+ print ( experiment_name )
197
197
experiment_errors_left , experimental_errors_right = experimental_series (experiment_timesteps , u_ref_left , u_ref_right , lambda tau : solve_monolithic_problem (tau , time_stepping_scheme , monolithic_domain ))
198
198
199
199
if type (monolithic_domain .grid ) is IrregularGrid :
@@ -250,7 +250,7 @@ def save_experiments(experimental_series, prefix):
250
250
u_ref_left_regular , u_ref_right_regular = compute_reference_solution (monolithic_domain_regular , tau_ref , time_integration_scheme = time_integration .RungeKutta4 )
251
251
u_ref_left_nonregular , u_ref_right_nonregular = compute_reference_solution (monolithic_domain_nonregular , tau_ref , time_integration_scheme = time_integration .RungeKutta4 )
252
252
253
- print "### experimental series 1: order degradation with classical schemes on regular domain"
253
+ print ( "### experimental series 1: order degradation with classical schemes on regular domain" )
254
254
255
255
experiments = list ()
256
256
experiments .append (monolithic_experiment (time_integration .ExplicitHeun , monolithic_domain_regular , u_ref_left_regular , u_ref_right_regular , experiment_timesteps ))
@@ -261,7 +261,7 @@ def save_experiments(experimental_series, prefix):
261
261
experiments .append (coupling_experiment (coupling_schemes .FullyImplicitCoupling (), time_integration .RungeKutta4 , left_domain , right_domain_coarse , u_ref_left_regular , u_ref_right_regular , experiment_timesteps ))
262
262
save_experiments (experiments , 'series1_Order' )
263
263
264
- print "### experimental series 2: Customized schemes Semi Implicit-Explicit coupling and Predictor coupling on regular domain"
264
+ print ( "### experimental series 2: Customized schemes Semi Implicit-Explicit coupling and Predictor coupling on regular domain" )
265
265
266
266
experiments = list ()
267
267
experiments .append (monolithic_experiment (time_integration .ExplicitHeun , monolithic_domain_regular , u_ref_left_regular , u_ref_right_regular , experiment_timesteps ))
@@ -272,7 +272,7 @@ def save_experiments(experimental_series, prefix):
272
272
experiments .append (coupling_experiment (coupling_schemes .SemiImplicitExplicitCoupling (), time_integration .ImplicitTrapezoidalRule , left_domain , right_domain_coarse , u_ref_left_regular , u_ref_right_regular , experiment_timesteps ))
273
273
save_experiments (experiments , 'series2_Custom' )
274
274
275
- print "### experimental series 3: Strang splitting coupling on non-regular domain"
275
+ print ( "### experimental series 3: Strang splitting coupling on non-regular domain" )
276
276
277
277
experiments = list ()
278
278
experiments .append (monolithic_experiment (time_integration .ExplicitHeun , monolithic_domain_nonregular , u_ref_left_nonregular , u_ref_right_nonregular , experiment_timesteps ))
@@ -284,7 +284,7 @@ def save_experiments(experimental_series, prefix):
284
284
experiments .append (coupling_experiment (coupling_schemes .StrangSplittingCoupling (), [time_integration .RungeKutta4 , time_integration .ImplicitTrapezoidalRule ], left_domain , right_domain_fine , u_ref_left_nonregular , u_ref_right_nonregular , experiment_timesteps ))
285
285
save_experiments (experiments , 'series3_Strang' )
286
286
287
- print "### experimental series 4: Waveform relaxation coupling on non-regular domain"
287
+ print ( "### experimental series 4: Waveform relaxation coupling on non-regular domain" )
288
288
289
289
experiments = list ()
290
290
experiments .append (monolithic_experiment (time_integration .ImplicitTrapezoidalRule , monolithic_domain_nonregular , u_ref_left_nonregular , u_ref_right_nonregular , experiment_timesteps ))
0 commit comments