Skip to content

Commit

Permalink
Fixing some issues in the raw tutorial and example.
Browse files Browse the repository at this point in the history
Adding the information related to the calculations topics.
  • Loading branch information
Jonathan Chico committed Nov 22, 2023
1 parent c46be8b commit 5dbe245
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 51 deletions.
29 changes: 29 additions & 0 deletions docs/source/topics/calculations/base.md
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
# `LammpsBaseCalculation`

The `LammpsBaseCalculation` performs a single stage LAMMPS calculation, the input is generated by a set of parameters passed as a dictionary. The inputs accepted are the following:

## Inputs:

- **structure**, (`StructureData`) - Structure used in the ``LAMMPS`` calculation.
- **potential**, (`LammpsPotentialData`) - Potential used in the ``LAMMPS`` calculation.
- **parameters**, (`Dict`) - Parameters that control the input script generated for the ``LAMMPS`` calculation.
- **settings**, (`Dict`), *optional* - Additional settings that control the ``LAMMPS`` calculation.
- **input_restartfile** (`SinglefileData`), *optional* - Input restartfile to continue from a previous ``LAMMPS`` calculation.
- **parent_folder**, (`RemoteData`), *optional* - An optional working directory of a previously completed calculation to restart from.
- **metadata.options.input_filename**, (`str`), *optional* - Name of the input file for the calculation. Defaults to `input.in`.
- **metadata.options.structure_filename**, (`str`), *optional* - Name of the file where the structure is stored. Defaults to `structure.dat`
- **metadata.options.output_filename**, (`str`). *optional* - Name of the main output file for LAMMPS. Defaults to `lammps.out`.
- **metadata.options.variables_filename**, (`str`), *optional* - Name of the file where the final values of the thermodynamic variables are stored. Defaults to `aiida_lammps.yaml`.
- **metadata.options.trajectory_filename**, (`str`), *optional* - Name of the file where the trajectories are stored. Defaults to `aiida_lammps.trajectory.dump`.
- **metadata.options.restart_filename**, (`str`), *optional* - Name of the restartfile to be written. Defaults to `lammps.restart`.
- **metadata.options.parser_name**, (`str`), *optional* - Name of the parser to be used for this calculation. Defaults to `lammps.base`.

## Outputs:

- **results**, (`Dict`) - The parsed data extracted from the lammps output file.
- **trajectories** (`LammpsTrajectory`) - The data extracted from the lammps trajectory file, includes the atomic trajectories and the site and time dependent calculation parameters.
- **time_dependent_computes**, (`ArrayData`) - The data with the time dependent computes parsed from the lammps.out.
- **restartfile**, (`SinglefileData`), *optional* - The restartfile of a ``LAMMPS`` calculation.
- **structure**, (`StructureData`), *optional* - The output structure of the calculation.
- **remote_folder**, (`RemoteData`) - Folder in the remote machine where the calculation was performed.
- **remote_stash**, (`RemoteStashData`), *optional* – Contents of the stash.source_list option are stored in this remote folder after job completion.
- **retrieved**, (`FolderData`) - Files that are retrieved by the daemon will be stored in this node. By default the stdout and stderr of the scheduler will be added, but one can add more by specifying them in `CalcInfo.retrieve_list`.
18 changes: 18 additions & 0 deletions docs/source/topics/calculations/raw.md
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
# `LammpsRawCalculation`

The `LammpsRawCalculation` performs a LAMMPS calculation from a given LAMMPS input script and a set of files.

## Inputs:

- **script**, (`SinglefileData`) - Complete input script to use. If specified, `structure`, `potential` and `parameters` are ignored.
- **files**, (Namespace of `SinglefileData`), *optional* - Optional files that should be written to the working directory. This is an
- **filenames**, (`Dict`), *optional* - Optional namespace to specify with which filenames the files of ``files`` input should be written.
- **metadata.options.input_filename**, (`str`), *optional* - Name of the input file for the calculation. Defaults to `input.in`.
- **metadata.options.output_filename**, (`str`). *optional* - Name of the main output file for LAMMPS. Defaults to `lammps.out`.
- **metadata.options.parser_name**, (`str`), *optional* - Name of the parser to be used for this calculation. Defaults to `lammps.raw`.

## Outputs:

- **results**, (`Dict`) - The parsed data extracted from the lammps output file.
- **remote_folder**, (`RemoteData`) - Folder in the remote machine where the calculation was performed.
- **remote_stash**, (`RemoteStashData`), *optional* – Contents of the stash.source_list option are stored in this remote folder after job completion.
- **retrieved**, (`FolderData`) - Files that are retrieved by the daemon will be stored in this node. By default the stdout and stderr of the scheduler will be added, but one can add more by specifying them in `CalcInfo.retrieve_list`.
4 changes: 4 additions & 0 deletions docs/source/topics/data/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ potential
trajectory
```

`aiida-lammps` has two specific data types, the [`LammpsPotentialData`](potential.md) handling the different types of interatomic potentials and the [`LammpsTrajectory`](trajectory.md) dealing with the atomic positions and the time dependent site dependent calculated properties of the system.

Another data set of interest, is the [parameters](parameters.md), this is a dictionary that contains the instructions on how to generate the LAMMPS input file. It abstracts, as much as possible, the generation of a single stage LAMMPS calculation input file into a python dictionary.
25 changes: 13 additions & 12 deletions docs/source/tutorials/first_md.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,25 +179,26 @@ The `outputs` is a dictionary containing the output nodes produced by the calcul
```python
print(outputs)
{
'results': <Dict: uuid: 1dfa9349-7397-48ab-8a02-df267e3504bb (pk: 77503)>,
'time_dependent_computes': <ArrayData: uuid: 6ec8947f-2a82-4c7a-898a-dd058d8e914e (pk: 77504)>,
'trajectories': <LammpsTrajectory: uuid: 8755ba9d-6145-43ea-88fe-3a53a753e5eb (pk: 77505)>,
'structure': <StructureData: uuid: 11cb6a62-01b6-464f-a737-9774f9baa9b7 (pk: 77506)>,
'remote_folder': <RemoteData: uuid: 00f6ed4d-c026-4f1e-8d82-032b6ec4603c (pk: 77501)>,
'retrieved': <FolderData: uuid: 7a5fea76-f007-4109-971d-082c8db38993 (pk: 77502)>
'remote_folder': <RemoteData: uuid: 4d5ffdc5-2935-478a-bbc3-2b5ac5bcd663 (pk: 77519)>,
'retrieved': <FolderData: uuid: e2dc6535-d954-470d-9ea9-c330b289f0d1 (pk: 77520)>,
'results': <Dict: uuid: ff724a1f-c24f-4dae-907f-7883a4770c69 (pk: 77521)>,
'time_dependent_computes': <ArrayData: uuid: d8150b46-8c2c-4a23-b039-7ef2a3e50554 (pk: 77522)>,
'trajectories': <LammpsTrajectory: uuid: f7af7031-6cd9-4adc-936e-27bdd358210e (pk: 77523)>,
'structure': <StructureData: uuid: 4bc51630-358d-4f1f-89ed-972bbd37d51e (pk: 77524)>,
}
```

The `results` node is a dictionary that will contain the final result of the calculated thermodynamic variables as well as general information about the calculation status

```python
print(results.get_dict())
print(outputs['results'].get_dict())
{
'final_ke': 0,
'final_pe': -8.2418066986197,
'final_pxx': -27037.610112703,
'final_pyy': -27037.610112703,
'final_pzz': -27037.610112703,
'final_ke': 0.024456795122703,
'final_pe': -8.2274854545799,
'final_pxx': -26539.404872624,
'final_pyy': -25646.583264533,
'final_pzz': -25646.563988137,
'final_step': 5000,
...
}
```
Expand Down
66 changes: 50 additions & 16 deletions docs/source/tutorials/first_raw.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ First import the required classes and functions:

```python
from aiida.plugins import CalculationFactory
from aiida.engine import run
from aiida import engine
from aiida.orm import SinglefileData, load_code
```

Expand Down Expand Up @@ -86,23 +86,17 @@ script = SinglefileData(
builder.script = script
```

As one can notice the script wants to read a file named `data.rhodo` via the [`read_data`](https://docs.lammps.org/read_data.html) command. One can pass any set of files that the script might need by first storing them as `SinglefileData` nodes and the passing them to the builder as follows:
As one can notice the script wants to read a file named `data.rhodo` via the [`read_data`](https://docs.lammps.org/read_data.html) command. One can pass any set of files that the script might need, in this case a file stored in the lammps repository that is downloaded using the [requests library](https://docs.python-requests.org/en/latest/index.html), by first storing them as `SinglefileData` nodes and the passing them to the builder as follows:

```python
data = orm.SinglefileData(
import requests
data = SinglefileData(
io.StringIO(
textwrap.dedent(
"""
LAMMPS data file from restart file: timestep = 5000, procs = 1
32000 atoms
27723 bonds
40467 angles
56829 dihedrals
1034 impropers
...
"""
)
textwrap.dedent(
requests.get(
"https://raw.githubusercontent.com/lammps/lammps/develop/bench/data.rhodo"
).text
)
)
)
builder.files = {"data": data}
Expand All @@ -129,7 +123,7 @@ builder.metadata.options = {
Now as all the needed parameters have been defined the calculation can bse launched using the process builder:

```python
outputs, node = run.get_node(builder)
outputs, node = engine.get_node(builder)
```

Once the calculation is finished `run.get_node` will return the outputs produced and the calculation node, `outputs` and `node` respectively.
Expand All @@ -142,3 +136,43 @@ node.exit_status
```

If the result is different from zero it means that a problem was encountered in the calculation. This might indicate that some output is not present, that the calculation failed due to a transitory issue, an input problem, etc.

The `outputs` is a dictionary containing the output nodes produced by the calculation:

```python
print(outputs)
{
'remote_folder': <RemoteData: uuid: 70b075de-1597-4997-a4c1-7a86af790dfb (pk: 77529)>,
'retrieved': <FolderData: uuid: 83b32034-7eef-4f0b-b567-f312a46cc2d3 (pk: 77530)>,
'results': <Dict: uuid: c0fc582e-16b3-464f-8627-3023baebc459 (pk: 77531)>
}
```

The `results` node is a dictionary that will contain some basic parsed information from the data written to the stdout


```python
print(outputs['results'].get_dict())
{
'compute_variables': {
'bin': 'standard',
'bins': [10, 13, 13],
'errors': [],
'binsize': 6,
'warnings': [],
'units_style': 'real',
'total_wall_time': '0:00:20',
'steps_per_second': 5.046,
'ghost_atom_cutoff': 12,
'max_neighbors_atom': 2000,
'total_wall_time_seconds': 20,
'master_list_distance_cutoff': 12
}
}
```

The complete output that was written by {{ LAMMPS }} to stdout, can be retrieved as follows:

```python
results['retrieved'].base.repository.get_object_content('lammps.out')
```
2 changes: 1 addition & 1 deletion docs/source/tutorials/first_relaxation.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ print(outputs)
The `results` node is a dictionary that will contain the final result of the calculated thermodynamic variables as well as general information about the calculation status

```python
print(results.get_dict())
print(outputs['results'].get_dict())
{
'final_ke': 0,
'final_pe': -8.2418066986197,
Expand Down
20 changes: 8 additions & 12 deletions docs/source/tutorials/include/scripts/run_raw_basic.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env runaiida
"""Run a LAMMPS calculation with additional input files
The example input script is taken from https://www.lammps.org/inputs/in.rhodo.txt and is an example benchmark script for
Expand All @@ -7,9 +8,10 @@
import io
import textwrap

from aiida.engine import run
from aiida import engine
from aiida.orm import SinglefileData, load_code
from aiida.plugins import CalculationFactory
import requests

script = SinglefileData(
io.StringIO(
Expand Down Expand Up @@ -49,16 +51,10 @@
data = SinglefileData(
io.StringIO(
textwrap.dedent(
"""
LAMMPS data file from restart file: timestep = 5000, procs = 1
32000 atoms
27723 bonds
40467 angles
56829 dihedrals
1034 impropers
...
"""
requests.get(
"https://raw.githubusercontent.com/lammps/lammps/develop/bench/data.rhodo",
timeout=20,
).text
)
)
)
Expand All @@ -69,7 +65,7 @@
builder.files = {"data": data}
builder.filenames = {"data": "data.rhodo"}
builder.metadata.options = {"resources": {"num_machines": 1}}
results, node = run.run_get_node(builder)
results, node = engine.run_get_node(builder)

print(
f"Calculation: {node.process_class}<{node.pk}> {node.process_state.value} [{node.exit_status}]"
Expand Down
15 changes: 5 additions & 10 deletions examples/launch_lammps_raw_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import textwrap

from aiida import engine, orm, plugins
import requests

script = orm.SinglefileData(
io.StringIO(
Expand Down Expand Up @@ -47,16 +48,10 @@
data = orm.SinglefileData(
io.StringIO(
textwrap.dedent(
"""
LAMMPS data file from restart file: timestep = 5000, procs = 1
32000 atoms
27723 bonds
40467 angles
56829 dihedrals
1034 impropers
...
"""
requests.get(
"https://raw.githubusercontent.com/lammps/lammps/develop/bench/data.rhodo",
timeout=20,
).text
)
)
)
Expand Down

0 comments on commit 5dbe245

Please sign in to comment.