Exemplo n.º 1
0
 def test_lfu(self):
     sm_wc_dict = eos.get_sm_wcs(data_path)
     wc_dict = {
         'b->uenue::cSL': 0.2j,
         'b->umunumu::cSL': 0.1j,
     }
     wc = wcxf.WC('WET', 'EOS', 4.2, wcxf.WC.dict2values(wc_dict))
     with self.assertRaises(ValueError):
         eos.wcxf2eos(wc, sm_wc_dict)
Exemplo n.º 2
0
def eos():
    from wcxf.converters.eos import wcxf2eos, get_sm_wcs
    parser = argparse.ArgumentParser(
        description=
        """Command line script to convert a WCxf file to an EOS Wilson coefficient parameter file.""",
        formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument("FILE",
                        nargs='?',
                        help="Input file. If \"-\", read from standard input",
                        type=argparse.FileType('r'),
                        default=sys.stdin)
    parser.add_argument(
        "--eosprefix",
        help="Installation prefix for the EOS installation. Defaults to /usr",
        default='/usr')
    parser.add_argument(
        "--output",
        nargs='?',
        help="Output file. If absent, print to standard output",
        type=argparse.FileType('w'),
        default=sys.stdout)
    parser.add_argument(
        "--eoshome",
        help=
        "EOS home directory. If specified, values will be written to EOSHOME/parameters/wcxf.yaml. Cannot be used simultaneously with output",
        default=None)
    args = parser.parse_args()
    # check sanity of inputs
    if args.output != sys.stdout and args.eoshome is not None:
        logging.error(
            "Cannot use --output and --eoshome arguments simultaneously")
        return 1
    elif args.output == sys.stdout and args.eoshome is not None:
        output_dir = os.path.join(args.eoshome, 'parameters')
        if not os.path.isdir(output_dir):
            logging.error(
                "Output directory {} does not exist".format(output_dir))
            return 1
        f = open(os.path.join(output_dir, 'wcxf.yaml'), 'w')
    else:
        f = args.output
    # read in & validate WCxf file
    wc = wcxf.WC.load(args.FILE)
    wc.validate()
    # read EOS SM contributions
    sm_wc_dict = get_sm_wcs(
        os.path.join(args.eosprefix, 'share/eos', 'parameters'))
    # convert to EOS parameters
    eos_dict = wcxf2eos(wc, sm_wc_dict)
    yaml.dump(eos_dict, f, default_flow_style=False)
    f.close()
    return 0
Exemplo n.º 3
0
 def test_wcxf2eos(self):
     sm_wc_dict = eos.get_sm_wcs(data_path)
     wc_dict = {
         'b->s::c7': 0.1,
         'b->uenue::cSL': 0.2j,
         'b->umunumu::cSL': 0.2j,
         'b->uenue::cVL': 0.2,
         'b->umunumu::cVL': 0.2,
         'b->s::c5': -0.03
     }
     wc = wcxf.WC('WET', 'EOS', 4.2, wcxf.WC.dict2values(wc_dict))
     eos_dict = eos.wcxf2eos(wc, sm_wc_dict)
     self.assertEqual(eos_dict['b->s::Re{c7}']['central'],
                      -0.33726473 + 0.1)
     self.assertEqual(eos_dict['b->s::c5']['central'], 0.00042854 - 0.03)
     self.assertEqual(eos_dict['b->ulnu::Im{cSL}']['min'], 0.0 + 0.2)
     self.assertEqual(eos_dict['b->ulnu::Re{cVL}']['max'], 1.0 + 0.2)
Exemplo n.º 4
0
 def test_get_sm_wcs(self):
     eos_sm_dict = eos.get_sm_wcs(data_path)
     self.assertEqual(eos_sm_dict['b->s::Re{c7}']['central'], -0.33726473)
     self.assertEqual(eos_sm_dict['b->s::c5']['central'], 0.00042854)
     self.assertEqual(eos_sm_dict['b->ulnu::Im{cVL}']['min'], 0.0)