Exemplo n.º 1
0
def mdi_checks(mdi_engine, nengines):
    """
    Perform checks on the MDI driver we have accepted to make sure it fits this analysis.
    """
    # Confirm that this code is being used as a driver
    role = mdi_engine.MDI_Get_Role()
    if not role == mdi_engine.MDI_DRIVER:
        raise Exception("Must run driver_py.py as a DRIVER")

    # Connect to the engine
    engine_comm = []
    for iengine in range(nengines):
        comm = mdi.MDI_Accept_Communicator()
        engine_comm.append(comm)

    # Verify the engine names
    for iengine in range(nengines):
        comm = engine_comm[iengine]

        # Determine the name of the engine
        mdi_engine.MDI_Send_Command("<NAME", comm)
        name = mdi_engine.MDI_Recv(mdi.MDI_NAME_LENGTH, mdi.MDI_CHAR, comm)
        print(F"Engine name: {name}")

        if name != "NO_EWALD":
            raise Exception("Unrecognized engine name", name)

    return engine_comm
Exemplo n.º 2
0
def connect_to_engines(nengines):
    """
    Accept connection(s) from the MDI engine(s) and perform basic validation of the connection.

    Parameters
    ---------
    nengines : int
        The number of MDI engines to connect to.

    Returns
    -------
    engine_comm : list
        a list of MDI_Comm values
    """
    # Confirm that this code is being used as a driver
    role = mdi.MDI_Get_Role()
    if not role == mdi.MDI_DRIVER:
        raise Exception("Must run driver_py.py as a DRIVER")

    # Connect to the engine
    engine_comm = []
    for iengine in range(nengines):
        comm = mdi.MDI_Accept_Communicator()
        engine_comm.append(comm)

    # Verify the engine names
    for iengine in range(nengines):
        comm = engine_comm[iengine]

        # Determine the name of the engine
        mdi.MDI_Send_Command("<NAME", comm)
        name = mdi.MDI_Recv(mdi.MDI_NAME_LENGTH, mdi.MDI_CHAR, comm)
        print(f"Engine name: {name}")

        if name[:8] != "NO_EWALD":
            raise Exception("Unrecognized engine name", name)

    return engine_comm
Exemplo n.º 3
0
    total_steps = 8000  # Number of MD iterations. Note timestep = 2fs
    tau_gaussian = 400  # Frequency of addition of Gaussians
    upper_restraint = 14.0 * angstrom_to_atomic
    lower_restraint = 1.0 * angstrom_to_atomic
    upper_window = 8.0 * angstrom_to_atomic
    lower_window = 2.4 * angstrom_to_atomic
    k_restraint = 10 * kcalmol_per_angstrom_to_atomic
    verbose = False

    s_of_t = []  # value of collective variable at time t'

    # Creat a plot of the results
    my_plot = pl.AnimatedPlot(kcalmol_to_atomic, angstrom_to_atomic)

    # Connect to the engines
    comm = mdi.MDI_Accept_Communicator()

    # Perform the simulation
    mdi.MDI_Send_Command("<NAME", comm)
    name = mdi.MDI_Recv(mdi.MDI_NAME_LENGTH, mdi.MDI_CHAR, comm)
    print("ENGINE NAME: " + str(name))

    # Get the number of atoms
    mdi.MDI_Send_Command("<NATOMS", comm)
    natoms = mdi.MDI_Recv(1, mdi.MDI_INT, comm)

    # Get the number of masses
    mdi.MDI_Send_Command("<MASSES", comm)
    masses = mdi.MDI_Recv(natoms, mdi.MDI_DOUBLE, comm)

    # Initialize an MD simulation