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
26 changes: 26 additions & 0 deletions electronicparsers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,32 @@ def load(self):
},
)

rspt_parser_entry_point = EntryPoint(
name='parsers/rspt',
aliases=['parsers/rspt'],
description='NOMAD parser for RSPt.',
python_package='electronicparsers.rspt',
mainfile_contents_re=r'MPI RSPT',
mainfile_name_re=r'.*out_last',
parser_class_name='electronicparsers.rspt.RSPtParser',
code_name='RSPT',
code_homepage='https://www.uu.se/en/department/physics-and-astronomy/research/materials-theory/code-development',
code_category='Atomistic code',
metadata={
'codeCategory': 'Atomistic code',
'codeLabel': 'RSPT',
'codeLabelStyle': 'All in capitals',
'codeName': 'rspt',
'codeUrl': 'https://www.uu.se/en/department/physics-and-astronomy/research/materials-theory/code-development',
'parserDirName': 'dependencies/electronic/electronicparsers/rspt/',
'parserGitUrl': 'https://github.com/nomad-coe/electronic-parsers.git',
'parserSpecific': '',
'preamble': '',
'status': 'production',
'tableOfFiles': '',
},
)

siesta_parser_entry_point = EntryPoint(
name='parsers/siesta',
aliases=['parsers/siesta'],
Expand Down
10 changes: 10 additions & 0 deletions electronicparsers/rspt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
This is a very basic NOMAD parser for [RSPt](https://www.uu.se/en/department/physics-and-astronomy/research/materials-theory/code-development) with the following features:

- identifies RSPt calculation as a file ending with `out_last` and with the header `MPI RSPT`,
- reads the version number from the line `RSPt version number: <version>`
- reads the method (DFT or DMFT) from the line `Initialization of the <method> code`
- reads the temperature from the line `Readin: Setting the temperature to <temperature>` (needed for proper normalization of the DMFT method class)
- reads the structure information from a cif file found in the same directory as the `out_last` file



19 changes: 19 additions & 0 deletions electronicparsers/rspt/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD.
# See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from .parser import RSPtParser
31 changes: 31 additions & 0 deletions electronicparsers/rspt/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD.
# See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import sys
import json
import logging

from nomad.utils import configure_logging
from nomad.datamodel import EntryArchive
from electronicparsers.rspt import RSPtParser

if __name__ == '__main__':
configure_logging(console_log_level=logging.DEBUG)
archive = EntryArchive()
RSPtParser().parse(sys.argv[1], archive, logging)
json.dump(archive.m_to_dict(), sys.stdout, indent=2)
18 changes: 18 additions & 0 deletions electronicparsers/rspt/metainfo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD.
# See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
18 changes: 18 additions & 0 deletions electronicparsers/rspt/nomad_plugin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
code_category: Atomistic code
code_homepage: https://www.uu.se/en/department/physics-and-astronomy/research/materials-theory/code-development
code_name: RSPT
metadata:
codeCategory: Atomistic code
codeLabel: RSPT
codeLabelStyle: all in capitals
codeName: rspt
codeUrl: https://www.uu.se/en/department/physics-and-astronomy/research/materials-theory/code-development
parserDirName: dependencies/electronic/electronicparsers/rspt/
parserGitUrl: https://github.com/nomad-coe/electronic-parsers.git
preamble: ''
status: production
tableOfFiles: ''
name: parsers/rspt
parser_class_name: electronicparsers.rspt.parser.RSPtParser
python_package: electronicparsers.rspt
plugin_source_code_url: https://github.com/nomad-coe/electronic-parsers/tree/develop/electronicparsers/rspt
134 changes: 134 additions & 0 deletions electronicparsers/rspt/parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD.
# See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import re
import os
import numpy as np

from simulationparsers.utils import BasicParser
from nomad.units import ureg
from nomad.utils import get_logger
from nomad.parsing.file_parser import Quantity, TextParser, Parser
from runschema.system import System, Atoms
from runschema.calculation import Calculation
from runschema.method import (
Method,
DFT,
Electronic,
DMFT,
)
from ase.io import read as ase_read
from nomad.normalizing.common import nomad_atoms_from_ase_atoms


class MethodParser(TextParser):
def __init__(self):
self.method = None
super().__init__(None)

def init_quantities(self):
self._quantities = [
Quantity(
'method',
r'\s*Initialization of the (\w+) code\s*\n',
comment='#',
repeats=True,
),
Quantity(
'temperature',
r'\s*Readin: Setting the temperature to\s+([+-]?\d+\.\d+E[+-]?\d+)\s*\n',
comment='#',
repeats=False,
),
]


class RSPtParser(Parser):
def __init__(self, **kwargs) -> None:
self._method_parser = MethodParser()
super().__init__(**kwargs)

self._parser = BasicParser(
'RSPt',
program_version=r'RSPt version number:\s*rspt\.(\d+\.\d+)',
)

def parse(self, mainfile, archive, logger=None):
logger = logger if logger is not None else get_logger(__name__)
self._method_parser.logger = logger
self._method_parser.mainfile = mainfile
self.mainfile = mainfile
self._maindir = os.path.dirname(self.mainfile)
self._auxillary_files = os.listdir(self._maindir)

self._parser.parse(mainfile, archive, logger=None)

# PARSE METHOD
method = self._method_parser.get('method', '')
temperature = self._method_parser.get('temperature', None)
# TODO - check rspt units - inverse T has temp units?
temperature = temperature * ureg.kelvin if temperature else None
inverse_temperature = (
1.0 / (ureg.boltzmann_constant * temperature) if temperature else None
)
if all(m.upper() == 'DFT' for m in method):
archive.run[0].method.append(
Method(dft=DFT(), electronic=Electronic(method='DFT'))
)
elif all(m.upper() == 'DMFT' for m in method):
archive.run[0].method.append(
Method(dmft=DMFT(inverse_temperature=inverse_temperature))
)
else:
logger.warning(
'RSPtParser method not recognized, or multiple distinct methods found.'
)

# PARSE SYSTEM
cif_files = [f for f in self._auxillary_files if f.endswith('.cif')]
if cif_files:
if len(cif_files) > 1:
self.logger.warning(
'RSPtParser found multiple CIF files, using the first one found.'
)
ase_atoms = ase_read(f'{self._maindir}/{cif_files[0]}', format='cif')
nomad_atoms = nomad_atoms_from_ase_atoms(ase_atoms)
archive.run[0].system.append(
System(
atoms=Atoms(
atomic_numbers=nomad_atoms.atomic_numbers,
species=nomad_atoms.species,
labels=nomad_atoms.labels,
positions=nomad_atoms.positions,
lattice_vectors=nomad_atoms.lattice_vectors,
periodic=nomad_atoms.periodic,
),
)
)

# PARSE CALCULATION
sec_method = archive.run[0].method[0] if archive.run[0].method else None
sec_system = archive.run[0].system[0] if archive.run[0].system else None
archive.run[0].calculation.append(
Calculation(
system_ref=sec_system,
method_ref=sec_method,
temperature=temperature,
)
)
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ psi4parser = "electronicparsers:psi4_parser_entry_point"
qballparser = "electronicparsers:qball_parser_entry_point"
qboxparser = "electronicparsers:qbox_parser_entry_point"
quantumespressoparser = "electronicparsers:quantumespresso_parser_entry_point"
rspt = "electronicparsers:rspt_parser_entry_point"
siestaparser = "electronicparsers:siesta_parser_entry_point"
soliddmftparser = "electronicparsers:soliddmft_parser_entry_point"
tbstudioparser = "electronicparsers:tbstudio_parser_entry_point"
Expand Down
Loading