Skip to content

Commit

Permalink
Deploying to gh-pages from @ d78a2ee 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
janash committed May 8, 2024
1 parent ce2dfb3 commit 9fcbddf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
17 changes: 14 additions & 3 deletions _sources/driver_tutorial.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,19 @@ When using MDI, we retrieve data from the engine by sending a command to the eng
The first command we use is the `mdi.MDI_Send_Command` function.
The argument to this function is the command to send and the engine we would like to send the command to.
When using `MDI_Send_Command`, we use `<` to tell the engine to send data to the driver, and `>` to tell the driver to send data to the engine.

For example, to get the number of atoms in the system, we first call `mdi.MDI_Send_Command("<NATOMS", lammps)` to tell LAMMPS to send the number of atoms.
Then, we call `mdi.MDI_Recv` to receive the data.

After we have sent the command to the engine, we have to retrieve the data.
This is done with the `mdi.MDI_Recv` function.
When using `mdi.MDI_Recv`, we have to tell MDI how many values we expect to get back and the data type for the value or values we expect to receive.
They syntax is

```python
mdi.MDI_Recv(EXPECTED_NUMBER_OF_VALUES, DATA_TYPE, ENGINE_COMMUNICATOR)
```

The expected data types are defined in the MDI library.
For example, `mdi.MDI_INT` is the data type for an integer, and `mdi.MDI_DOUBLE` is the data type for a double (decimal) value.

Add the following code to the `# Perform the simulation` section to get the number of atoms in the system:

Expand All @@ -336,14 +345,16 @@ print(f"The number of atoms in the system is {natoms}.")
```
````

These set of commands first tells LAMMPS to send the number of atoms in the system (`mdi.MDI_Send_Command("<NATOMS", lammps)`). After that, we receive the number of atoms from LAMMPS. Using `mdi.MDI_Recv`, we tell lammps we are expecting `1` value for `natoms` and that its data type is an integer.
These set of commands first tells LAMMPS to send the number of atoms in the system (`mdi.MDI_Send_Command("<NATOMS", lammps)`).
After that, we receive the number of atoms from LAMMPS. Using `mdi.MDI_Recv`, we tell lammps we are expecting `1` value for `natoms` and that its data type is an integer.

````{admonition} Check Your Understanding
:class: exercise

Retrieve the box vectors from LAMMPS and print it to the screen.

The command to get the box vectors is `<CELL`. You expect this to contain 9 values (3 for each dimension).
The data type we expect is an mdi.MDI_DOUBLE.

```{admonition} Solution
:class: solution dropdown
Expand Down
21 changes: 15 additions & 6 deletions driver_tutorial.html
Original file line number Diff line number Diff line change
Expand Up @@ -721,10 +721,17 @@ <h2>Sending and Receiving Data<a class="headerlink" href="#sending-and-receiving
<p>When using MDI, we retrieve data from the engine by sending a command to the engine and then receiving the data.
The first command we use is the <code class="docutils literal notranslate"><span class="pre">mdi.MDI_Send_Command</span></code> function.
The argument to this function is the command to send and the engine we would like to send the command to.
When using <code class="docutils literal notranslate"><span class="pre">MDI_Send_Command</span></code>, we use <code class="docutils literal notranslate"><span class="pre">&lt;</span></code> to tell the engine to send data to the driver, and <code class="docutils literal notranslate"><span class="pre">&gt;</span></code> to tell the driver to send data to the engine.</p>
<p>For example, to get the number of atoms in the system, we first call <code class="docutils literal notranslate"><span class="pre">mdi.MDI_Send_Command(&quot;&lt;NATOMS&quot;,</span> <span class="pre">lammps)</span></code> to tell LAMMPS to send the number of atoms.
Then, we call <code class="docutils literal notranslate"><span class="pre">mdi.MDI_Recv</span></code> to receive the data.
When using <code class="docutils literal notranslate"><span class="pre">mdi.MDI_Recv</span></code>, we have to tell MDI how many values we expect to get back and the data type for the value or values we expect to receive.</p>
When using <code class="docutils literal notranslate"><span class="pre">MDI_Send_Command</span></code>, we use <code class="docutils literal notranslate"><span class="pre">&lt;</span></code> to tell the engine to send data to the driver, and <code class="docutils literal notranslate"><span class="pre">&gt;</span></code> to tell the driver to send data to the engine.
For example, to get the number of atoms in the system, we first call <code class="docutils literal notranslate"><span class="pre">mdi.MDI_Send_Command(&quot;&lt;NATOMS&quot;,</span> <span class="pre">lammps)</span></code> to tell LAMMPS to send the number of atoms.</p>
<p>After we have sent the command to the engine, we have to retrieve the data.
This is done with the <code class="docutils literal notranslate"><span class="pre">mdi.MDI_Recv</span></code> function.
When using <code class="docutils literal notranslate"><span class="pre">mdi.MDI_Recv</span></code>, we have to tell MDI how many values we expect to get back and the data type for the value or values we expect to receive.
They syntax is</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">mdi</span><span class="o">.</span><span class="n">MDI_Recv</span><span class="p">(</span><span class="n">EXPECTED_NUMBER_OF_VALUES</span><span class="p">,</span> <span class="n">DATA_TYPE</span><span class="p">,</span> <span class="n">ENGINE_COMMUNICATOR</span><span class="p">)</span>
</pre></div>
</div>
<p>The expected data types are defined in the MDI library.
For example, <code class="docutils literal notranslate"><span class="pre">mdi.MDI_INT</span></code> is the data type for an integer, and <code class="docutils literal notranslate"><span class="pre">mdi.MDI_DOUBLE</span></code> is the data type for a double (decimal) value.</p>
<p>Add the following code to the <code class="docutils literal notranslate"><span class="pre">#</span> <span class="pre">Perform</span> <span class="pre">the</span> <span class="pre">simulation</span></code> section to get the number of atoms in the system:</p>
<div class="sd-tab-set docutils">
<input checked="checked" id="sd-tab-item-6" name="sd-tab-set-6" type="radio">
Expand All @@ -739,11 +746,13 @@ <h2>Sending and Receiving Data<a class="headerlink" href="#sending-and-receiving
</div>
</div>
</div>
<p>These set of commands first tells LAMMPS to send the number of atoms in the system (<code class="docutils literal notranslate"><span class="pre">mdi.MDI_Send_Command(&quot;&lt;NATOMS&quot;,</span> <span class="pre">lammps)</span></code>). After that, we receive the number of atoms from LAMMPS. Using <code class="docutils literal notranslate"><span class="pre">mdi.MDI_Recv</span></code>, we tell lammps we are expecting <code class="docutils literal notranslate"><span class="pre">1</span></code> value for <code class="docutils literal notranslate"><span class="pre">natoms</span></code> and that its data type is an integer.</p>
<p>These set of commands first tells LAMMPS to send the number of atoms in the system (<code class="docutils literal notranslate"><span class="pre">mdi.MDI_Send_Command(&quot;&lt;NATOMS&quot;,</span> <span class="pre">lammps)</span></code>).
After that, we receive the number of atoms from LAMMPS. Using <code class="docutils literal notranslate"><span class="pre">mdi.MDI_Recv</span></code>, we tell lammps we are expecting <code class="docutils literal notranslate"><span class="pre">1</span></code> value for <code class="docutils literal notranslate"><span class="pre">natoms</span></code> and that its data type is an integer.</p>
<div class="exercise admonition">
<p class="admonition-title">Check Your Understanding</p>
<p>Retrieve the box vectors from LAMMPS and print it to the screen.</p>
<p>The command to get the box vectors is <code class="docutils literal notranslate"><span class="pre">&lt;CELL</span></code>. You expect this to contain 9 values (3 for each dimension).</p>
<p>The command to get the box vectors is <code class="docutils literal notranslate"><span class="pre">&lt;CELL</span></code>. You expect this to contain 9 values (3 for each dimension).
The data type we expect is an mdi.MDI_DOUBLE.</p>
<div class="solution dropdown admonition">
<p class="admonition-title">Solution</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># Get the box size from LAMMPS </span>
Expand Down
Loading

0 comments on commit 9fcbddf

Please sign in to comment.