CHARGES#

Exchange atomic charge information.

>CHARGES#

Send atomic charges.

Datatype: MDI_DOUBLE
Quantity: NATOMS
Units: elementary charge (\(e\))

Format: Sequentially ascending order of atomic index

The driver sends a set of atomic charges to the engine, which replaces its atomic charges with those sent by the driver.

Examples#

import mdi
import numpy as np

# connect to the engine
mdi_engine = mdi.MDI_Accept_Communicator()

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

# create a list of atomic charges using
# method appropriate for your use case.
charges = # some array of atomic charges

# send the atomic charges to the engine
mdi.MDI_Send_Command(">CHARGES", mdi_engine)
mdi.MDI_Send(charges, natoms, mdi.MDI_DOUBLE, mdi_engine)

import mdi
import numpy as np

# connect to the engine
mdi_engine = mdi.MDI_Accept_Communicator()

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

# create an array of atomic charges using
# method appropriate for your use case.
# Zeros shown here for example.
charges = np.zeros(natoms, dtype=float)

# send the atomic charges to the engine
mdi.MDI_Send_Command(">CHARGES", mdi_engine)
mdi.MDI_Send(charges, natoms, mdi.MDI_DOUBLE, mdi_engine)

#include "mdi.h"
#include <vector>

// connect to the engine
MDI_Comm mdi_engine = MDI_Accept_Communicator();

// retrieve the number of atoms
int natoms;
MDI_Send_Command("<NATOMS", mdi_engine);
MDI_Recv(&natoms, 1, MDI_INT, mdi_engine);

// create an vector of atomic charges
std::vector<double> charges(natoms);

// fill the array with charges.

// send the atomic charges to the engine
MDI_Send_Command(">CHARGES", mdi_engine);
MDI_Send(charges.data(), natoms, MDI_DOUBLE, mdi_engine);

<CHARGES#

Receive atomic charges.

Datatype: MDI_DOUBLE
Quantity: NATOMS
Units: elementary charge (\(e\))

Format: Sequentially ascending order of atomic index

The engine sends a set of atomic charges to the driver.

Examples#

import mdi
import numpy as np

# connect to the engine
mdi_engine = mdi.MDI_Accept_Communicator()

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

# receive the atomic charges from the engine
mdi.MDI_Send_Command("<CHARGES", mdi_engine)
charges = mdi.MDI_Recv(natoms, mdi.MDI_DOUBLE, mdi_engine) 

import mdi
import numpy as np

# connect to the engine
mdi_engine = mdi.MDI_Accept_Communicator()

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

# create a buffer to hold the atomic charges
charges = np.zeros(natoms, dtype=float)

# receive the atomic charges from the engine
mdi.MDI_Send_Command("<CHARGES", mdi_engine)
mdi.MDI_Recv(natoms, mdi.MDI_DOUBLE, mdi_engine, buf=charges) 

#include "mdi.h"
#include <vector>

// connect to the engine
MDI_Comm mdi_engine = MDI_Accept_Communicator();

// retrieve the number of atoms
int natoms;
MDI_Send_Command("<NATOMS", mdi_engine);
MDI_Recv(&natoms, 1, MDI_INT, mdi_engine);

// create a vector to hold the atomic charges
std::vector<double> charges(natoms);

// receive the atomic charges from the engine
MDI_Send_Command("<CHARGES", mdi_engine);
MDI_Recv(charges.data(), natoms, MDI_DOUBLE, mdi_engine);