Exemple #1
0
 def setUp(self):
     lp.set_caching_enabled(False)
     if not self.is_setup:
         utils.setup_logging()
         # load equations
         self.dirpath = os.path.dirname(os.path.realpath(__file__))
         gasname = os.path.join(self.dirpath, 'test.cti')
         # first check test config
         gasname = get_mechanism_file()
         # load the gas
         gas = ct.Solution(gasname)
         # the mechanism
         elems, specs, reacs = read_mech_ct(gasname)
         # and finally check for a test platform
         platform = get_platform_file()
         try:
             if platform is None:
                 platform = ''
                 raise OSError
             platform = build_and_validate('test_platform_schema.yaml',
                                           platform)
         except (OSError, IOError):
             logger = logging.getLogger(__name__)
             logger.warn('Test platform file {} was not found, reverting '
                         'to default.'.format(platform))
             platform = None
         self.store = storage(platform, gas, specs, reacs)
         self.is_setup = True
Exemple #2
0
def main(args=None):
    lp.set_caching_enabled(False)
    utils.setup_logging()
    if args is None:
        # command line arguments
        parser = ArgumentParser(description='Tests pyJac versus an'
                                ' autodifferentiated jacobian\n')
        parser.add_argument('-w', '--working_directory',
                            type=str,
                            default='performance',
                            help='Directory storing the mechanisms / data.'
                            )
        parser.add_argument('-t', '--test_matrix',
                            type=str,
                            help='The platforms / tests to run, as well as '
                                 'possible memory limits. For an example see'
                                 'the pyjac/examples/test_matrix.yaml included with'
                                 'pyJac'
                            )
        parser.add_argument('-r', '--runtype',
                            choices=['jac', 'spec', 'both'],
                            default='both',
                            help='The type of validation test to run, Jacobian [jac]'
                                 ' or species rates [spec], or [both].')
        parser.add_argument('-p', '--prefix',
                            type=str,
                            default='',
                            help='A prefix to store the output of this test in'
                                 'for each mechanism in the working_directory.'
                                 'This can be a helpful tool on a cluster to '
                                 'run multiple tests at once on different platforms')
        args = parser.parse_args()
        methods = []
        if args.runtype == 'jac':
            methods = [jacobian_tester]
        elif args.runtype == 'spec':
            methods = [species_rate_tester]
        else:
            methods = [species_rate_tester, jacobian_tester]

        for m in methods:
            m(args.working_directory, args.test_matrix, args.prefix)
Exemple #3
0
    def setUp(self):
        lp.set_caching_enabled(False)
        if not self.is_setup:
            utils.setup_logging()
            # first check test config
            gasname = get_mechanism_file()
            # load the gas
            gas = ct.Solution(gasname)
            # the mechanism
            elems, specs, reacs = read_mech_ct(gasname)
            # get sort type
            sorting = get_rxn_sorting()
            if sorting != reaction_sorting.none:
                # get ordering
                ordering = sort_reactions(reacs, sorting, return_order=True)
                # and apply
                reacs = sort_reactions(reacs, sorting)
                ct_reacs = gas.reactions()
                # and apply to gas
                gas = ct.Solution(thermo='IdealGas',
                                  kinetics='GasKinetics',
                                  species=gas.species(),
                                  reactions=[ct_reacs[i] for i in ordering])

            # and reassign
            utils.reassign_species_lists(reacs, specs)
            # and finally check for a test platform
            platform = get_platform_file()
            try:
                if platform is None:
                    platform = ''
                    raise OSError
                platform = build_and_validate('test_platform_schema.yaml',
                                              platform)
            except (OSError, IOError):
                logger = logging.getLogger(__name__)
                logger.warn('Test platform file {} was not found, reverting '
                            'to default.'.format(platform))
                platform = None
            self.store = storage(platform, gas, specs, reacs)
            self.is_setup = True
Exemple #4
0
def main(args=None):
    if args is None:
        utils.setup_logging()
        utils.create()