~madteam/mg5amcnlo/series2.0

« back to all changes in this revision

Viewing changes to tests/unit_tests/loop/test_loop_exporters.py

  • Committer: olivier Mattelaer
  • Date: 2015-03-05 00:14:16 UTC
  • mfrom: (258.1.9 2.3)
  • mto: (258.8.1 2.3)
  • mto: This revision was merged to the branch mainline in revision 259.
  • Revision ID: olivier.mattelaer@uclouvain.be-20150305001416-y9mzeykfzwnl9t0j
partial merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
    """Test class for the loop exporter modules. It uses hardcoded output 
73
73
    for the comparisons."""
74
74
 
 
75
    loop_exporters = {}
 
76
 
75
77
    # A helper function to add more easily IOTests for several exporters.
76
78
    def addIOTestsForProcess(self,testName,testFolder,particles_ids,exporters,orders,
77
79
                             files_to_check=IOTests.IOTest.all_files,
88
90
            fortran_model = self.fortran_models['fortran_model']
89
91
        
90
92
        needed = False
91
 
        if not isinstance(exporters,dict):
 
93
 
 
94
        if not isinstance(exporters,list):
92
95
            if self.need(testFolder,testName):
93
 
                needed = True
 
96
                needed = True    
94
97
        elif any(self.need('%s_%s'%(testFolder,exporter) ,testName) for \
95
 
                                                  exporter in exporters.keys()):
 
98
                                                         exporter in exporters):
96
99
            needed = True
 
100
            
97
101
        if not needed:
98
102
            return
99
103
        
107
111
                        'perturbation_couplings': perturbation_couplings,
108
112
                        'NLO_mode': NLO_mode})
109
113
        
110
 
        # Exporter directly given
111
 
        if not isinstance(exporters,dict):
 
114
        if isinstance(exporters, dict):
 
115
            # Several exporters given in a dictionary
 
116
            test_list = [('%s_%s'%(testFolder,exp),exp) for exp in exporters]            
 
117
        elif not isinstance(exporters,list) :
 
118
            # Exporter directly given
112
119
            test_list = [(testFolder,exporters)]
113
 
        # Several exporters given in a dictionary
114
120
        else:
115
 
            test_list = [('%s_%s'%(testFolder,exp),exporters[exp]) for exp in \
116
 
                                                               exporters.keys()]
117
 
               
 
121
            test_list = [('%s_%s'%(testFolder,exp),exp) for exp in exporters] 
 
122
 
118
123
        for (folderName, exporter) in test_list:
119
124
            if self.need(folderName,testName):
120
125
                self.addIOTest(folderName,testName, IOTests.IOTest(\
 
126
                  test_instance = self,
121
127
                  procdef=myproc,
122
128
                  exporter=exporter,
123
129
                  helasModel=fortran_model,
124
130
                  testedFiles=files_to_check,
125
131
                  outputPath=_proc_file_path))
 
132
    
 
133
    def get_exporter_withName(self, exporter_name):
 
134
        """ Returns on demand the exporter of given nickname """
 
135
 
 
136
 
 
137
        if exporter_name == 'default':
 
138
            self.loop_exporters[exporter_name] = loop_exporters.\
 
139
                              LoopProcessExporterFortranSA(
 
140
                              _mgme_file_path, _proc_file_path,
 
141
                              {'clean':False, 'complex_mass':False, 
 
142
                               'export_format':'madloop','mp':True,
 
143
                               'loop_dir':_loop_file_path,
 
144
                               'cuttools_dir':_cuttools_file_path,
 
145
                               'fortran_compiler':'gfortran',
 
146
                               'output_dependencies':'external',
 
147
                               'SubProc_prefix': 'P',
 
148
                               'compute_color_flows': False})
 
149
        elif exporter_name == 'optimized':
 
150
            self.loop_exporters[exporter_name] = loop_exporters.\
 
151
                              LoopProcessOptimizedExporterFortranSA(\
 
152
                              _mgme_file_path, _proc_file_path,
 
153
                              {'clean':False, 'complex_mass':False, 
 
154
                               'export_format':'madloop','mp':True,
 
155
                               'loop_dir':_loop_file_path,
 
156
                               'cuttools_dir':_cuttools_file_path,
 
157
                               'fortran_compiler':'gfortran',
 
158
                               'output_dependencies':'external',
 
159
                               'SubProc_prefix': 'P',
 
160
                               'compute_color_flows': False})
 
161
        else:
 
162
            raise MadGraph5Error, 'Exporter with nickname '+\
 
163
                                          '%s not implemented'%exporter_name
 
164
        return self.loop_exporters[exporter_name]
126
165
 
127
166
    def load_IOTestsUnit(self):
128
167
        """load the models and exporters if necessary."""
138
177
                'fortran_model' : helas_call_writers.FortranUFOHelasCallWriter(\
139
178
                                                         self.models['loop_sm']) 
140
179
                                  }
141
 
            
142
 
            self.loop_exporters = {
143
 
                'default' : loop_exporters.LoopProcessExporterFortranSA(\
144
 
                                  _mgme_file_path, _proc_file_path,
145
 
                                  {'clean':False, 'complex_mass':False, 
146
 
                                   'export_format':'madloop','mp':True,
147
 
                                   'loop_dir':_loop_file_path,
148
 
                                   'cuttools_dir':_cuttools_file_path,
149
 
                                   'fortran_compiler':'gfortran',
150
 
                                   'output_dependencies':'external'}),
151
 
                'optimized' : loop_exporters.\
152
 
                                  LoopProcessOptimizedExporterFortranSA(\
153
 
                                  _mgme_file_path, _proc_file_path,
154
 
                                  {'clean':False, 'complex_mass':False, 
155
 
                                   'export_format':'madloop','mp':True,
156
 
                                   'loop_dir':_loop_file_path,
157
 
                                   'cuttools_dir':_cuttools_file_path,
158
 
                                   'fortran_compiler':'gfortran',
159
 
                                   'output_dependencies':'external'})
160
 
                                  }
161
 
            
 
180
 
162
181
            # g g > t t~
163
182
            self.addIOTestsForProcess( testName = 'gg_ttx',
164
183
                                       testFolder = 'short_ML_SMQCD',
165
184
                                       particles_ids = [21,21,6,-6],
166
 
                                       exporters = self.loop_exporters,
 
185
                                       exporters = ['default','optimized'],
167
186
                                       orders = {'QCD':2,'QED':0} )
168
187
 
169
188
            # d d > t t~ (only the proc files for this one)
170
189
            self.addIOTestsForProcess( testName = 'ddx_ttx',
171
190
                                       testFolder = 'short_ML_SMQCD',
172
191
                                       particles_ids = [1,-1,6,-6],
173
 
                                       exporters = self.loop_exporters,
 
192
                                       exporters = ['default','optimized'],
174
193
                                       orders = {'QCD':2,'QED':0},
175
194
                                       files_to_check=IOTests.IOTest.proc_files)
176
195
 
179
198
            self.addIOTestsForProcess( testName = 'gg_hh',
180
199
                                       testFolder = 'short_ML_SMQCD_LoopInduced',
181
200
                                       particles_ids = [21,21,25,25],
182
 
                                       exporters = self.loop_exporters['default'],
 
201
                                       exporters = 'default',
183
202
                                       orders = {'QCD': 2, 'QED': 2} )
184
203
 
185
204
    def testIO_ProcOutputIOTests(self, load_only=False):
214
233
                                   'loop_dir':_loop_file_path,
215
234
                                   'cuttools_dir':_cuttools_file_path,
216
235
                                   'fortran_compiler':'gfortran',
217
 
                                   'output_dependencies':'external'})
 
236
                                   'output_dependencies':'external',
 
237
                                   'SubProc_prefix': '',
 
238
                                   'compute_color_flows': False})
218
239
 
219
240
    @IOTests.createIOTest(groupName='LoopSquaredOrder_IOTest')
220
241
    def testIO_Loop_sqso_uux_ddx(self):
274
295
            # information in the Helas loop diagrams.
275
296
            matrix_element.compute_all_analytic_information(
276
297
                                      self.exporter.get_aloha_model(self.model))
277
 
            # and TIR specific entries
278
 
            self.exporter.set_TIR_replace_dict_entries()
279
298
            
280
299
            # Finally the entries specific to the optimized output
281
300
            self.exporter.set_optimized_output_specific_replace_dict_entries(\