Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ exclude: >

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-json
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.16.8
hooks:
- id: ruff
args: [--fix]
Expand Down
4 changes: 2 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def get_work_directory(config):
def pytest_report_header(config):
"""Add header information for pytest execution."""
return [
f'LAMMPS Executable: {shutil.which(config.getoption("lammps_exec") or "lammps")}',
f'LAMMPS Work Directory: {config.getoption("lammps_workdir") or "<TEMP>"}',
f"LAMMPS Executable: {shutil.which(config.getoption('lammps_exec') or 'lammps')}",
f"LAMMPS Work Directory: {config.getoption('lammps_workdir') or '<TEMP>'}",
]


Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,6 @@
with open("nitpick-exceptions") as handle:
nitpick_ignore = [
tuple(line.strip().split(None, 1))
for line in handle.readlines()
for line in handle
if line.strip() and not line.startswith("#")
]
18 changes: 9 additions & 9 deletions docs/source/getting_started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ from pathlib import Path

# Create the node with the computer
computer = Computer(
label='localhost',
hostname='localhost',
transport_type='core.local',
scheduler_type='core.direct',
workdir=Path('/home/my_username/aiida_workspace').resolve()
label="localhost",
hostname="localhost",
transport_type="core.local",
scheduler_type="core.direct",
workdir=Path("/home/my_username/aiida_workspace").resolve(),
)
# Store the node in the database
computer.store()
Expand Down Expand Up @@ -143,14 +143,14 @@ To define the [InstalledCode](https://aiida.readthedocs.io/projects/aiida-core/e
from aiida.orm import InstalledCode

# Load the computer resource where LAMMPS is installed
computer = load_computer('localhost')
computer = load_computer("localhost")

# Define the code node
code = InstalledCode(
label='lammps',
label="lammps",
computer=computer,
filepath_executable='/path/to/lammps/lmp',
default_calc_job_plugin='lammps.base'
filepath_executable="/path/to/lammps/lmp",
default_calc_job_plugin="lammps.base",
)

# Store the code node in the database
Expand Down
50 changes: 25 additions & 25 deletions docs/source/topics/data/parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,35 @@ The behavior of the {{ aiida_lammps }} calculation can be controlled by collecti

```python
parameters = {
'md': {
'velocity': [{'group': 'all', 'create': {'temp': 300}}],
'integration': {
'style': 'npt',
'constraints': {'iso': [0.0, 0.0, 1000.0], 'temp': [300, 300, 100]}
"md": {
"velocity": [{"group": "all", "create": {"temp": 300}}],
"integration": {
"style": "npt",
"constraints": {"iso": [0.0, 0.0, 1000.0], "temp": [300, 300, 100]},
},
'max_number_steps': 5000
"max_number_steps": 5000,
},
'dump': {'dump_rate': 1000},
'thermo': {
'printing_rate': 100,
'thermo_printing': {
'ke': True,
'pe': True,
'pxx': True,
'pyy': True,
'pzz': True,
'step': True,
'press': True
}
"dump": {"dump_rate": 1000},
"thermo": {
"printing_rate": 100,
"thermo_printing": {
"ke": True,
"pe": True,
"pxx": True,
"pyy": True,
"pzz": True,
"step": True,
"press": True,
},
},
'compute': {
'ke/atom': [{'type': [{'value': ' ', 'keyword': ' '}], 'group': 'all'}],
'pe/atom': [{'type': [{'value': ' ', 'keyword': ' '}], 'group': 'all'}],
'pressure': [{'type': ['thermo_temp'], 'group': 'all'}],
'stress/atom': [{'type': ['NULL'], 'group': 'all'}]
"compute": {
"ke/atom": [{"type": [{"value": " ", "keyword": " "}], "group": "all"}],
"pe/atom": [{"type": [{"value": " ", "keyword": " "}], "group": "all"}],
"pressure": [{"type": ["thermo_temp"], "group": "all"}],
"stress/atom": [{"type": ["NULL"], "group": "all"}],
},
'control': {'units': 'metal', 'timestep': 1e-05},
'structure': {'atom_style': 'atomic'}
"control": {"units": "metal", "timestep": 1e-05},
"structure": {"atom_style": "atomic"},
}
```

Expand Down
73 changes: 37 additions & 36 deletions docs/source/topics/data/potential.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,47 +18,49 @@ To demonstrate how this works one can [download](https://openkim.org/id/EAM_Dyna

```python
potential_parameters = {
'species': ['Fe'], # Which species can be treated by this potential (required)
'atom_style': 'atomic', # Which kind of atomic style is associated with this potential (required)
'pair_style': 'eam/fs', # LAMMPS pair style (required)
'units': 'metal', # Default units of this potential (required)
'extra_tags': {
'content_origin': 'NIST IPRP: https: // www.ctcms.nist.gov/potentials/Fe.html', # Where the file was original found
'content_other_locations': None, # If the file can be found somewhere else
'data_method': 'unknown', # How was the data generated
'description': """
"species": ["Fe"], # Which species can be treated by this potential (required)
"atom_style": "atomic", # Which kind of atomic style is associated with this potential (required)
"pair_style": "eam/fs", # LAMMPS pair style (required)
"units": "metal", # Default units of this potential (required)
"extra_tags": {
"content_origin": "NIST IPRP: https: // www.ctcms.nist.gov/potentials/Fe.html", # Where the file was original found
"content_other_locations": None, # If the file can be found somewhere else
"data_method": "unknown", # How was the data generated
"description": """
This Fe EAM potential parameter file is from the NIST repository, \"Fe_2.eam.fs\" as of the March 9, 2009 update.
It is similar to \"Fe_mm.eam.fs\" in the LAMMPS distribution dated 2007-06-11,
but gives different results for very small interatomic distances
(The LAMMPS potential is in fact the deprecated potential referred to in the March 9, 2009 update on the NIST repository).
The file header includes a note from the NIST contributor:
\"The potential was taken from v9_4_bcc (in C:\\SIMULATION.MD\\Fe\\Results\\ab_initio+Interstitials)\"
""", # Short description of the potential
'developer': ['Ronald E. Miller'], # Name of the developer that uploaded it to OpenKIM
'disclaimer': """
""", # Short description of the potential
"developer": [
"Ronald E. Miller"
], # Name of the developer that uploaded it to OpenKIM
"disclaimer": """
According to the developer Giovanni Bonny (as reported by the NIST IPRP),
this potential was not stiffened and cannot be used in its present form for collision cascades.
""", # Any known issues with the potential
'properties': None, # If any specific properties are associated to the potential
'publication_year': 2018, # Year of publication to OpenKIM
'source_citations': [{
'abstract': None,
'author':
'Mendelev, MI and Han, S and Srolovitz, DJ and Ackland, GJ and Sun, DY and Asta, M',
'doi': '10.1080/14786430310001613264',
'journal': '{Phil. Mag.}',
'number': '{35}',
'pages': '{3977-3994}',
'recordkey': 'MO_546673549085_000a',
'recordprimary': 'recordprimary',
'recordtype': 'article',
'title':
'{Development of new interatomic potentials appropriate for crystalline and liquid iron}',
'volume': '{83}',
'year': '{2003}'
}],
'title': 'EAM potential (LAMMPS cubic hermite tabulation) for Fe developed by Mendelev et al. (2003) v000' # Title of the potential
}
""", # Any known issues with the potential
"properties": None, # If any specific properties are associated to the potential
"publication_year": 2018, # Year of publication to OpenKIM
"source_citations": [
{
"abstract": None,
"author": "Mendelev, MI and Han, S and Srolovitz, DJ and Ackland, GJ and Sun, DY and Asta, M",
"doi": "10.1080/14786430310001613264",
"journal": "{Phil. Mag.}",
"number": "{35}",
"pages": "{3977-3994}",
"recordkey": "MO_546673549085_000a",
"recordprimary": "recordprimary",
"recordtype": "article",
"title": "{Development of new interatomic potentials appropriate for crystalline and liquid iron}",
"volume": "{83}",
"year": "{2003}",
}
],
"title": "EAM potential (LAMMPS cubic hermite tabulation) for Fe developed by Mendelev et al. (2003) v000", # Title of the potential
},
}
```
Certain tags are required, and must be provided to be able to upload the potential to the database. This is because they identify which {{ pair_style }} is associated with the potential, which atomic species can be treated with it, etc. The rest of the tags, in this example are filled so that they follow the [OpenKIM](https://openkim.org/doc/schema/kimspec/) standard as that is the place where the potential was obtained. If another database is used or if it is a homemade potential, these tags can be used to facilitate the querying of the potential.
Expand All @@ -68,10 +70,9 @@ Then the potential can be uploaded to the database
from aiida_lamps.data.potential import LammpsPotentialData

potential = LammpsPotentialData.get_or_create(
source='Fe_2.eam.fs', # Relative path to the potential file
**potential_parameters, # Parameters to tag the potential
source="Fe_2.eam.fs", # Relative path to the potential file
**potential_parameters, # Parameters to tag the potential
)

```

The {meth}`~aiida_lammps.data.potential.LammpsPotentialData.get_or_create` method is based on the one by [aiida-pseudo](https://github.com/aiidateam/aiida-pseudo/blob/master/aiida_pseudo/data/pseudo/pseudo.py), which will calculate the md5 sum of the file and check the database for another file with the same [md5 hash](https://en.wikipedia.org/wiki/MD5), if such entry is found, that potential is used instead. This avoids the unnecessary replication of potential data nodes whenever one tries to upload a previously uploaded potential.
Expand Down
112 changes: 57 additions & 55 deletions docs/source/tutorials/first_md.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Then, load the code that was setup in AiiDA for `lmp` and get an instance of the
```python
# Load the code configured for ``lmp``. Make sure to replace
# this string with the label used in the code setup.
code = load_code('lammps@localhost')
code = load_code("lammps@localhost")
builder = code.get_builder()
```

Expand All @@ -40,7 +40,8 @@ One can start by defining and assigning the structure to the builder:

```python
from ase.build import bulk
structure = StructureData(ase=bulk('Fe', 'bcc', 2.87, cubic=True))

structure = StructureData(ase=bulk("Fe", "bcc", 2.87, cubic=True))
builder.structure = structure
```

Expand All @@ -60,24 +61,28 @@ import requests
import io

# Download the potential from the repository and store it as a BytesIO object
_stream = io.BytesIO(requests.get('https://openkim.org/files/MO_546673549085_000/Fe_2.eam.fs', timeout=20).text.encode('utf-8'))
_stream = io.BytesIO(
requests.get(
"https://openkim.org/files/MO_546673549085_000/Fe_2.eam.fs", timeout=20
).text.encode("utf-8")
)

# Set the metadata for the potential
potential_parameters = {
'species': ['Fe'],
'atom_style': 'atomic',
'pair_style': 'eam/fs',
'units': 'metal',
'extra_tags': {
'title': 'EAM potential (LAMMPS cubic hermite tabulation) for Fe developed by Mendelev et al. (2003) v000',
'content_origin': 'NIST IPRP: https: // www.ctcms.nist.gov/potentials/Fe.html',
'developer': ['Ronald E. Miller'],
'publication_year': 2018,
}
"species": ["Fe"],
"atom_style": "atomic",
"pair_style": "eam/fs",
"units": "metal",
"extra_tags": {
"title": "EAM potential (LAMMPS cubic hermite tabulation) for Fe developed by Mendelev et al. (2003) v000",
"content_origin": "NIST IPRP: https: // www.ctcms.nist.gov/potentials/Fe.html",
"developer": ["Ronald E. Miller"],
"publication_year": 2018,
},
}

# Store the potential in an AiiDA node
potential = LammpsPotentialData.get_or_create(source=_stream,**potential_parameters)
potential = LammpsPotentialData.get_or_create(source=_stream, **potential_parameters)

builder.potential = potential
```
Expand All @@ -95,45 +100,42 @@ Then one needs to define the parameters which control how the input file for the
For a structural minimization the minimal set of parameters is the following:

```python

# Parameters to control the input file generation
parameters = Dict({
"control": {
"units": "metal",
"timestep": 1e-5
},
"compute":{
"pe/atom": [{"type": [{"keyword": " ", "value": " "}], "group": "all"}],
"ke/atom": [{"type": [{"keyword": " ", "value": " "}], "group": "all"}],
"stress/atom": [{"type": ["NULL"], "group": "all"}],
"pressure": [{"type": ["thermo_temp"], "group": "all"}],
},

"structure":{"atom_style": "atomic"},
"thermo":{
"printing_rate": 100,
"thermo_printing": {
"step": True,
"pe": True,
"ke": True,
"press": True,
"pxx": True,
"pyy": True,
"pzz": True,
}
},
"md":{
"integration": {
"style": "npt",
"constraints": {
"temp": [300, 300, 100],
"iso": [0.0, 0.0, 1000.0],
parameters = Dict(
{
"control": {"units": "metal", "timestep": 1e-5},
"compute": {
"pe/atom": [{"type": [{"keyword": " ", "value": " "}], "group": "all"}],
"ke/atom": [{"type": [{"keyword": " ", "value": " "}], "group": "all"}],
"stress/atom": [{"type": ["NULL"], "group": "all"}],
"pressure": [{"type": ["thermo_temp"], "group": "all"}],
},
"structure": {"atom_style": "atomic"},
"thermo": {
"printing_rate": 100,
"thermo_printing": {
"step": True,
"pe": True,
"ke": True,
"press": True,
"pxx": True,
"pyy": True,
"pzz": True,
},
},
"max_number_steps": 5000,
"velocity": [{"create": {"temp": 300}, "group": "all"}],
},
})
"md": {
"integration": {
"style": "npt",
"constraints": {
"temp": [300, 300, 100],
"iso": [0.0, 0.0, 1000.0],
},
},
"max_number_steps": 5000,
"velocity": [{"create": {"temp": 300}, "group": "all"}],
},
}
)
builder.parameters = parameters
```
The parameters have several sections which control different behavior of the calculation:
Expand All @@ -154,11 +156,11 @@ Lastly one needs to define the computational resources needed to perform the cal
# Run the calculation on 1 CPU and kill it if it runs longer than 1800 seconds.
# Set ``withmpi`` to ``False`` if ``pw.x`` was compiled without MPI support.
builder.metadata.options = {
'resources': {
'num_machines': 1,
"resources": {
"num_machines": 1,
},
'max_wallclock_seconds': 1800,
'withmpi': False,
"max_wallclock_seconds": 1800,
"withmpi": False,
}
```

Expand Down Expand Up @@ -213,5 +215,5 @@ The `time_dependent_computes` contains a series of numpy arrays each one represe
The complete output that was written by {{ LAMMPS }} to stdout, can be retrieved as follows:

```python
results['retrieved'].base.repository.get_object_content('aiida_lammps.out')
results["retrieved"].base.repository.get_object_content("aiida_lammps.out")
```
Loading
Loading