Beispiel #1
0
def ani_ase_calculator(ani_model):
    """
    Return a calculator from a model.
    choices are %s
    """ % " ".join(models.keys())

    return ANIENS(aniensloader(models[ani_model]))
Beispiel #2
0
def parse_args():
    """
    parse commandline arguments
    """

    parser = argparse.ArgumentParser(
        description="Run ani on a testset",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)

    parser.add_argument('datadir',
                        type=str,
                        help='directory holding json files to use as ref data')

    parser.add_argument('-network-type',
                        type=str,
                        choices=models.keys(),
                        required=True)

    parser.add_argument(
        '-implementation',
        type=str,
        choices=IMPLEMENTATIONS,
        default=TORCHANI,
    )

    parser.add_argument('-optimize',
                        action='store_true',
                        help='optimize molecule prior to computing energy')

    parser.add_argument('-numb-networks',
                        default=8,
                        type=int,
                        help='number of committee members to load')

    return parser.parse_args()
Beispiel #3
0
def khan_calculator(ani_model, khan_network, numb_networks):
    """
    Return a calculator from a roitberg model.
    choices are %s
    """ % " ".join(models.keys())

    if khan_network is None:
        print("setting up Roitberg network")
        model_file = models[ani_model]

        wkdir = model_file.rsplit('/', 1)[0] + '/'

        data = np.loadtxt(model_file, dtype=str)
        cnstfile = wkdir + data[0]  # AEV parameters
        saefile = wkdir + data[1]  # Atomic shifts
        nnfdir = wkdir + data[2]  # network prefix
        Nn = int(data[3])  # Number of networks in the ensemble

        assert numb_networks <= Nn

        network_dir = nnfdir[:-5]

    else:
        print("setting up khan network")
        saefile = os.path.join(os.environ["KHAN"], "data", "sae_linfit.dat"
                               #"sae_wb97x.dat"
                               )
        network_dir = None

    ani_lib = os.path.join(os.environ["KHAN"], "gpu_featurizer", "ani_cpu.so")
    initialize_module(ani_lib)

    cp = tf.ConfigProto(
        intra_op_parallelism_threads=1,
        inter_op_parallelism_threads=1,
    )
    tf_sess = tf.Session(config=cp)

    atomic_energies = read_sae_parameters(saefile)

    calculator = Calculator(tf_sess,
                            atomic_energies,
                            numb_networks,
                            khan_saved_network=khan_network,
                            roitberg_network=network_dir)

    return calculator
Beispiel #4
0
def parse_args():
    """
    parse commandline arguments
    """

    parser = argparse.ArgumentParser(
        description="optimize structures with ANI",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)

    parser.add_argument(
        'mae_file',
        type=str,
        help='name of mae file',
    )

    parser.add_argument(
        '-network-type',
        type=str,
        choices=models.keys(),
        default="ani-1x",
    )

    parser.add_argument(
        '-implementation',
        type=str,
        choices=IMPLEMENTATIONS,
        default=KHAN,
    )

    parser.add_argument('-khan-network',
                        type=str,
                        default=None,
                        help='khan trained network')

    parser.add_argument('-optimize', action='store_true', help='optimize')

    parser.add_argument('-numb-networks',
                        default=8,
                        type=int,
                        help='number of committee members to load')

    return parser.parse_args()
def parse_args():
    """
    parse commandline arguments
    """

    parser = argparse.ArgumentParser(
        description="optimize a crystal structure from a cif file with ANI",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)

    parser.add_argument('cif_file',
                        type=str,
                        help='name of cif file (must end in .cif)')

    parser.add_argument('-network-type',
                        type=str,
                        choices=models.keys(),
                        required=True)

    parser.add_argument(
        '-implementation',
        type=str,
        choices=IMPLEMENTATIONS,
        default=TORCHANI,
    )

    parser.add_argument('-khan-network',
                        type=str,
                        default=None,
                        help='khan trained network')

    parser.add_argument('-numb-networks',
                        default=8,
                        type=int,
                        help='number of committee members to load')

    parser.add_argument('-MC',
                        type=str,
                        required=False,
                        help='running Monte Carlo for n steps')

    return parser.parse_args()
Beispiel #6
0
def torchani_calculator(ani_model, numb_networks):
    """
    Return a calculator from a model.
    choices are %s
    """ % " ".join(models.keys())

    model_file = models[ani_model]

    wkdir = model_file.rsplit('/', 1)[0] + '/'

    data = np.loadtxt(model_file, dtype=str)
    cnstfile = wkdir + data[0]  # AEV parameters
    saefile = wkdir + data[1]  # Atomic shifts
    nnfdir = wkdir + data[2]  # network prefix
    Nn = int(data[3])  # Number of networks in the ensemble
    assert numb_networks <= Nn

    constants = torchani.neurochem.Constants(cnstfile)
    energy_shifter = torchani.neurochem.load_sae(saefile)
    aev_computer = torchani.AEVComputer(**constants)
    aev_computer.to(torch.double)
    nn_models = torchani.neurochem.load_model_ensemble(
        constants.species,
        nnfdir, 
        numb_networks)

    # go to double precision
    for model in nn_models:
        model.to(torch.double)

    calculator = torchani.ase.Calculator(
        constants.species,
        aev_computer,
        nn_models,
        energy_shifter)

    return calculator
def parse_args():
    """
    parse commandline arguments
    """

    parser = argparse.ArgumentParser(
        description="optimize a crystal structure from a cif file with ANI",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)

    parser.add_argument('cif_file',
                        type=str,
                        help='name of cif file (must end in .cif)')

    parser.add_argument('-network-type',
                        type=str,
                        choices=models.keys(),
                        required=True)

    parser.add_argument(
        '-implementation',
        type=str,
        choices=IMPLEMENTATIONS,
        default=TORCHANI,
    )

    parser.add_argument('-khan-network',
                        type=str,
                        default=None,
                        help='khan trained network')

    parser.add_argument('-numb-networks',
                        default=8,
                        type=int,
                        help='number of committee members to load')

    parser.add_argument('-MC',
                        type=int,
                        required=False,
                        help='running Monte Carlo for n steps')

    parser.add_argument(
        '-space_group',
        default=1,
        type=int,
        help=
        'under which space group you would like to run, by default it is P1')

    parser.add_argument(
        '-step_size',
        dest='MC_f1_f2_f3_f4_f5_f6_f7_f8',
        metavar='<Xi>',
        default=(0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1),
        nargs=8,
        type=float,
        help=
        'MC step size for translate, rotatioin, cell length(a,b,c), and cell angle(alpha, beta, gamma), unit(A or degree)'
    )

    parser.add_argument(
        '-perturbation_type',
        choices=[
            'translation', 'rotation', 'cell_length_a', 'cell_length_b',
            'cell_length_c', 'cell_angle_alpha', 'cell_angle_beta',
            'cell_angle_gamma'
        ],
        type=str,
        default=[
            'translation', 'rotation', 'cell_length_a', 'cell_length_b',
            'cell_length_c', 'cell_angle_alpha', 'cell_angle_beta',
            'cell_angle_gamma'
        ],
        help=
        'choose one type of perturbation, by default run all types randomly')

    parser.add_argument(
        '-debug',
        default=False,
        dest='debug',
        action='store_true',
        help='debug option to print out all the accepted frames')

    return parser.parse_args()
Beispiel #8
0
def parse_args():
    """
    parse commandline arguments
    """

    parser = argparse.ArgumentParser(
        description="optimize a crystal structure from a cif file with ANI",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter
        )

    parser.add_argument(
        'cif_file',
         type=str,
         help='name of cif file (must end in .cif)'
    )

    parser.add_argument(
        '-network-type',
        type=str,
        choices=models.keys(),
        required=True
    )

    parser.add_argument(
        '-implementation',
        type=str,
        choices=IMPLEMENTATIONS,
        default=TORCHANI,
    )

    parser.add_argument(
       '-khan-network',
       type=str,
       default=None,
       help='khan trained network'
    )

    parser.add_argument(
        '-numb-networks',
        default=8,
        type=int,
        help='number of committee members to load'
    )

    parser.add_argument(
        '-MC',
        type=int,
        required=False,
        help='running Monte Carlo for n steps'
    )

    parser.add_argument(
        '-space_group',
        default=1,
        type=int,
        help='under which space group you would like to run, by default it is P1'
    )

    parser.add_argument(
        '-step_size',
        dest='MC_f1_f2_f3_f4',
        metavar='<Xi>',
        default=(0.1, 0.1, 0.1, 0.1),
        nargs=4,
        type=float,
        help='MC step size for translate, rotatioin, cell length, and cell angle, unit(A or degree)'
    )

    return parser.parse_args()
def parse_args():
    """
    parse commandline arguments
    """

    parser = argparse.ArgumentParser(
        description="optimize a crystal structure from a cif file with ANI",
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)

    parser.add_argument('cif_file',
                        type=str,
                        help='name of cif file (must end in .cif)')

    parser.add_argument('-network-type',
                        type=str,
                        choices=models.keys(),
                        required=True)

    parser.add_argument('-time-step',
                        default=0.1,
                        type=float,
                        help="time step in fs")

    parser.add_argument('-total-time',
                        default=10.0,
                        type=float,
                        help="total MD time in ps")

    parser.add_argument(
        '-implementation',
        type=str,
        choices=IMPLEMENTATIONS,
        default=TORCHANI,
    )

    parser.add_argument('-khan-network',
                        type=str,
                        default=None,
                        help='khan trained network')

    parser.add_argument('-optimize',
                        action='store_true',
                        help='optimize crystal prior to computing energy')

    parser.add_argument(
        '-relax-cell',
        action='store_true',
        help='allow cell shape to change when optimizing',
    )

    parser.add_argument('-dynamics',
                        action='store_true',
                        help='perform molecular dynamics')

    parser.add_argument('-numb-networks',
                        default=8,
                        type=int,
                        help='number of committee members to load')

    parser.add_argument('-truncate-box',
                        default=False,
                        action="store_true",
                        help='truncate a box at 12 angstrom')

    parser.add_argument(
        '-torsion',
        default=None,
        nargs=5,
        help=
        "list of one float and four integers defining a torsion to scan from a value of zero"
    )

    parser.add_argument(
        '-box-length',
        type=float,
        default=None,
        help='if system is not periodic, place it in a box of this length')

    parser.add_argument(
        '-supercell',
        type=int,
        default=None,
        help='make a supercell of this size from initial system')

    return parser.parse_args()