diff --git a/gulpparser/main.py b/gulpparser/main.py index c5e178f52e2bb6d9dc64c8f6abefe8f8ec37e705..747bedfb3c383cb08c7f34fcec078ee37e48a0ce 100644 --- a/gulpparser/main.py +++ b/gulpparser/main.py @@ -108,11 +108,6 @@ def get_gulp_energy_sm(): subFlags=SM.SubFlags.Unordered, subMatchers=sms) -import nomad_meta_info -metaInfoPath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(nomad_meta_info.__file__)), "gulp.nomadmetainfo.json")) -metaInfoEnv, warnings = loadJsonFile(filePath = metaInfoPath, dependencyLoader = None, extraArgsHandling = InfoKindEl.ADD_EXTRA_ARGS, uri = None) -parser_info = {'name': 'gulp-parser', 'version': '1.0'} - #TODO #---- @@ -735,7 +730,7 @@ infoFileDescription = SM( get_optimise_sm(), # note British spelling get_md_sm(), SM(r'x^', - name='impossible') # 'Parse' the whole file + name='impossible') # 'Parse' the whole file ]) @@ -748,25 +743,14 @@ class GULPParser(): from unittest.mock import patch logging.info('GULP parser started') logging.getLogger('nomadcore').setLevel(logging.WARNING) - backend = self.backend_factory(metaInfoEnv) + backend = self.backend_factory("gulp.nomadmetainfo.json") with patch.object(sys, 'argv', ['<exe>', '--uri', 'nmd://uri', mainfile]): mainFunction( infoFileDescription, - metaInfoEnv, - parser_info, + None, + {'name': 'gulp-parser', 'version': '1.0'}, cachingLevelForMetaName={}, superContext=GulpContext(), superBackend=backend) return backend - -def main(**kwargs): - mainFunction(mainFileDescription=infoFileDescription, - metaInfoEnv=metaInfoEnv, - parserInfo=parser_info, - cachingLevelForMetaName={}, - superContext=context, - **kwargs) - -if __name__ == '__main__': - main() diff --git a/toDelete/parser/parser-gulp/generate_scala_testcode.py b/toDelete/parser/parser-gulp/generate_scala_testcode.py deleted file mode 100755 index 5acffbb6fc49c27adac45db6306642ce7d20b034..0000000000000000000000000000000000000000 --- a/toDelete/parser/parser-gulp/generate_scala_testcode.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python -# Copyright 2016-2018 Ask Hjorth Larsen, Fawzi Mohamed -# -# 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 __future__ import print_function -import os -from glob import glob - -scala_imports = """package eu.nomad_lab.parsers - -import eu.nomad_lab.{ parsers, DefaultPythonInterpreter } -import org.scalacheck.Properties -import org.specs2.mutable.Specification -import org.{ json4s => jn } - -""" - -test_template = """\ - "test %(name)s " >> { - "test with json-events" >> { - ParserRun.parse(GulpParser, "parsers/gulp/test/examples/outputs/%(name)s", "json-events") must_== ParseResult.ParseSuccess - } - "test with json" >> { - ParserRun.parse(GulpParser, "parsers/gulp/test/examples/outputs/%(name)s", "json") must_== ParseResult.ParseSuccess - } - }""" - -fd = open('out.scala', 'w') - -fd.write(scala_imports) - -print('object GulpParserSpec extends Specification {', file=fd) -print(' "GulpParserTest" >> {', file=fd) - -fnames = glob('test/outputs/example*.got') -fnames.sort() -for fname in fnames: - fname = os.path.basename(fname) - print(test_template % dict(name=fname), file=fd) - -print(' }', file=fd) -print('}', file=fd) diff --git a/toDelete/parser/parser-gulp/main.py b/toDelete/parser/parser-gulp/main.py deleted file mode 100644 index 7facfc8f2fa659f8919f820b1f99db8dc52b2feb..0000000000000000000000000000000000000000 --- a/toDelete/parser/parser-gulp/main.py +++ /dev/null @@ -1,752 +0,0 @@ -# Copyright 2016-2018 Ask Hjorth Larsen, Fawzi Mohamed -# -# 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. - -# -# Main author and maintainer: Ask Hjorth Larsen <asklarsen@gmail.com> - -from __future__ import print_function -import os -import sys -import setup_paths -import re - -import numpy as np -from ase import Atoms -from ase.spacegroup import crystal -#from ase.data import chemical_symbols - -from nomadcore.simple_parser import mainFunction, SimpleMatcher as SM -from nomadcore.local_meta_info import loadJsonFile, InfoKindEl -from nomadcore.unit_conversion.unit_conversion \ - import register_userdefined_quantity, convert_unit - -# relative import -from spacegroups import get_spacegroup_number -#from util import floating, integer - -# Generate list of all energy contributions: -# cat outputs/example*.got | grep "Components of energy" -A 20 | grep = |grep eV | cut -c 1-30 | sort|uniq|less -energy_contributions = """\ -Attachment energy -Attachment energy/unit -Bond-order potentials -Brenner potentials -Bulk energy -Dispersion (real+recip) -Electric_field*distance -Energy shift -Four-body potentials -Improper torsions -Interatomic potentials -Many-body potentials -Monopole - monopole (real) -Monopole - monopole (recip) -Monopole - monopole (total) -Neutralising energy - Non-primitive unit cell -Out of plane potentials - Primitive unit cell -ReaxFF force field -Region 1-2 interaction -Region 2-2 interaction -Self energy (EEM/QEq/SM) -SM Coulomb correction -Solvation energy -Three-body potentials -Total lattice energy""" - - -def get_gulp_energy_patterns(): - for name in energy_contributions.splitlines(): - name = name.strip() - basepattern = re.escape(name) - name = name.lower() - name = name.replace(' - ', '_') - name = name.replace(' (', '_') - name = name.replace(')', '') - name = name.replace('field*distance', 'field_times_distance') - name = re.sub(r'[-+/\s]', '_', name) - - metaname = 'x_gulp_energy_%s' % name - pattern = r'\s*%s\s*=\s*(?P<%s__eV>\S+)\s*eV' % (basepattern, - metaname) - yield name, metaname, pattern - -energy_term_template = """{ - "description": "GULP energy term for %(name)s", - "name": "%(metaname)s", - "superNames": [ "section_single_configuration_calculation" ], - "dtypeStr": "f", - "shape": [] - }, """ - -def generate_energy_json(): - for name, metaname, pattern in get_gulp_energy_patterns(): - print(energy_term_template % dict(name=name, - metaname=metaname), end='') -# generate_energy_json() # Print JSON for energy terms to stdout - -def get_gulp_energy_sm(): - sms = [] - for name, metaname, pattern in get_gulp_energy_patterns(): - #print(pattern) - sms.append(SM(pattern, name=name)) - - return SM(r'\s*Components of energy :', - name='gulp-energy', - subFlags=SM.SubFlags.Unordered, - subMatchers=sms) - -metaInfoPath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),"../../../../nomad-meta-info/meta_info/nomad_meta_info/gulp.nomadmetainfo.json")) -metaInfoEnv, warnings = loadJsonFile(filePath=metaInfoPath, - dependencyLoader=None, - extraArgsHandling=InfoKindEl.ADD_EXTRA_ARGS, - uri=None) - -parser_info = {'name': 'gulp-parser', 'version': '1.0'} - -#TODO -#---- - -#OK "program_name", -#OK "atom_labels", -#OK "atom_positions", -#OK "program_version", -#OK "energy_total", -#OK "simulation_cell", -#OK "configuration_periodic_dimensions" - -#OK 'section_system', -# 'section_method', -# 'section_frame_sequence', -# 'section_sampling_method', -#OK 'single_configuration_to_calculation_method_ref', -#OK 'single_configuration_calculation_to_system_ref', -# 'atom_forces_raw', -# 'frame_sequence_local_frames_ref', -# 'frame_sequence_to_sampling_ref', - -#DFT-only -# 'XC_functional_name', -# 'smearing_kind', -# 'smearing_width' -# 'eigenvalues_kpoints', -# 'eigenvalues_values', -# 'eigenvalues_occupation', -# 'band_k_points', -# 'band_energies', -# 'band_segm_start_end', -# 'band_segm_labels', -# 'dos_energies', -# 'dos_values', -# 'section_XC_functionals', -# 'program_basis_set_type', - -"""File structure. Example 4 - -Input for configuration = 1 - formula - irreducible atoms/shells - total atoms/shells - dimensionalitycat - symmetry - space group - cart lat vec - cell param - frac coord of asymm unit - constraints - -General input information - species, type, atomic number, mass, charge, ... (table) - general interatomic potentials (table) - -"Start of fitting :" - cycles... iterations - fit completed successfuly - final sum of squares - final values of parameters (table) - etc - general interatomic potentials (table) - total time to end of fitting - -output for configuration 1 - components of energy : - <components including total lattice energy> - -"Start of bulk optimization" - <iterations> - Optimization achieved - Final energy - Components of energies <numbers> - final asymmetric unit coords (table) - final cartecian lattice vectors (ang) (table) - final cell parameters and derivatives - -comparison of initial and final structures: ..... -time to end of optimisation -"job finished at ..." - -""" - - -class GulpContext(object): - def __init__(self): - self.data = {} - self.spacegroup = None - self.current_raw_cell = None - self.npbc = None - self.use_spacegroup = None - - self.section_refs = {} - - def startedParsing(self, fname, parser): - pass - - # Standard onOpen definitions from Siesta parser - def onOpen_section_sampling_method(self, backend, gindex, section): - self.section_refs['sampling_method'] = gindex - - def onOpen_section_frame_sequence(self, backend, gindex, section): - self.section_refs['frame_sequence'] = gindex - - def onOpen_section_method(self, backend, gindex, section): - self.section_refs['method'] = gindex - - def onOpen_section_system(self, backend, gindex, section): - self.section_refs['system'] = gindex - - def adhoc_whether_using_spacegroup(self, parser): - line = parser.fIn.readline() - - if 'Final coordinates of region' in line: - self.use_spacegroup = False - - def onClose_section_method(self, backend, gindex, section): - species = self.data['species'] - sym, types, charges = species.T - charges = convert_unit(charges.astype(float), 'e') - backend.addArrayValues('x_gulp_species_charge', charges) - - def onClose_section_system(self, backend, gindex, section): - data = self.data - - ctable = data.pop('gulp_coordinate_table', None) - if ctable is None: - return # This is probably an MD simulation or something. - # I am sure we will get to suffer because of this relatively arbitrary - # return, but what can you do - - symbols = ctable[:, 0] - gulp_labels = ctable[:, 1] - positions = ctable[:, 2:5].astype(float) - - chemical_symbols = [] - gulp_numeric_tags = [] - for sym in symbols: - m = re.match(r'([A-Z][a-z]?)(\d*)', sym) - chemical_symbols.append(m.group(1)) - gulp_numeric_tags.append(m.group(2)) - - # Construct a mapping which combines gulp numeric tags and core/shell - # etc. specification into a single numeric tag so ASE spacegroup - # module can distinguish the atoms when constructing the full system - types = {} - tags = [] - - ase_symbols = [] - for sym, label in zip(symbols, gulp_labels): - full_label = '%s_%s' % (sym, label) - tag = types.setdefault(full_label, len(types)) - tags.append(tag) - ase_symbols.append(re.match(r'[A-Z][a-z]?', sym).group()) - - # Really we want the opposite mapping - tag2type = dict((v, k) for k, v in types.items()) - - if self.npbc is None: - self.npbc = section['x_gulp_pbc'][0] - assert self.npbc in range(4) - - pbc = np.zeros(3, bool) - pbc[:self.npbc] = True - assert sum(pbc) == self.npbc - - # charge, occupancy? - - if self.spacegroup is None: - spacegroup = section['x_gulp_space_group'] - if spacegroup is not None: - spacegroup = spacegroup[0] - self.spacegroup = spacegroup - - self.current_raw_cell = data.pop('cell', self.current_raw_cell) - if self.npbc > 0: - assert self.current_raw_cell is not None - - if self.use_spacegroup is None: - self.use_spacegroup = (self.spacegroup is not None) - - if self.use_spacegroup: - # group may be none ---- no spacegroup - - cellparnames = ['a', 'b', 'c', 'alpha', 'beta', 'gamma'] - - #try:#if 'x_gulp_cell_a' in section: - val = [section['x_gulp_cell_%s' % name] for name in cellparnames] - if val[0] is None: - # if we have the prim cell and not the full cell, it's because they - # are identical (as far as I can tell). - val = [section['x_gulp_prim_cell_%s' % name] for name in cellparnames] - - cellpar = [] - for v in val: - assert len(v) == 1 - cellpar.append(v[0]) - assert len(cellpar) == 6 - - num = get_spacegroup_number(self.spacegroup) - - basis_atoms = Atoms(ase_symbols, tags=tags, - cell=np.eye(3), - scaled_positions=positions) - - unique_labels = set(gulp_labels) - thelabels = np.array(gulp_labels) - - constituents = [] - def build_atoms(label): - b = basis_atoms[thelabels == label] - atoms = crystal(b, - basis=b, - spacegroup=num, - cellpar=cellpar, - onduplicates='error') - constituents.append(atoms) - - # Avoid duplicates when constructing space group atoms *grumble* - # We want core and shell first - for sym in 'cs': - if sym in unique_labels: - unique_labels.remove(sym) - build_atoms(sym) - for sym in sorted(unique_labels): - build_atoms(sym) - - atoms = constituents[0] - for other in constituents[1:]: - atoms += other - else: - cell3d = np.identity(3) - if self.npbc > 0: - cell = self.current_raw_cell - assert cell.shape == (self.npbc, 3), cell.shape - cell3d[:self.npbc, :] = cell - - # use Atoms to get scaled positions/cell right: - atoms = Atoms([0] * len(positions), cell=cell3d, - scaled_positions=positions, pbc=pbc, - tags=tags) - - atom_labels = [tag2type[tag] for tag in atoms.get_tags()] - - backend.addArrayValues('atom_labels', np.asarray(atom_labels)) - backend.addArrayValues('configuration_periodic_dimensions', pbc) - backend.addValue('number_of_atoms', len(atom_labels)) - # The cell can be infinite in some directions. - # In that case the cell value will just be one (it has to have some value!!) - # but there will not be periodic boundary conditions in that direction. - # We will have to live with this except if simulation_cell permits something - # more general. - backend.addArrayValues('simulation_cell', - convert_unit(atoms.cell, 'angstrom')) - backend.addArrayValues('atom_positions', - convert_unit(atoms.positions, 'angstrom')) - - def onClose_section_single_configuration_calculation(self, backend, - gindex, section): - backend.addValue('single_configuration_to_calculation_method_ref', - self.section_refs['method']) - backend.addValue('single_configuration_calculation_to_system_ref', - self.section_refs['system']) - - # multi_sm is a copy from Siesta - def multi_sm(self, name, startpattern, linepattern, endmatcher=None, - conflict='fail', # 'fail', 'keep', 'overwrite' - *args, **kwargs): - - pat = re.compile(linepattern) # XXX how to get compiled pattern? - ngroups = pat.groups - - allgroups = [] - def addline(parser): - line = parser.fIn.readline() - match = pat.match(line) - assert match is not None - thislinegroups = match.groups() - assert len(thislinegroups) == ngroups - allgroups.append(thislinegroups) - - def savearray(parser): - arr = np.array(allgroups, dtype=object) - del allgroups[:] - if name in self.data: - if conflict == 'fail': - raise ValueError('grrr %s %s' % (name, self.data[name])) - elif conflict == 'keep': - return # Do not save array - elif conflict == 'overwrite': - pass - else: - raise ValueError('Unknown keyword %s' % conflict) - #if arr.size > 0: - if arr.size == 0: - arr.shape = (0, ngroups) - self.data[name] = arr - - if endmatcher is None: - endmatcher = r'.*' - - if hasattr(endmatcher, 'swapcase'): - endmatcher = SM(endmatcher, - endReStr='', - forwardMatch=True, - name='%s-end' % name, - adHoc=savearray) - - sm = SM(startpattern, - name=name, - subMatchers=[ - SM(linepattern, - name='%s-line' % name, - repeats=True, - forwardMatch=True, - required=True, - adHoc=addline), - endmatcher, - ], **kwargs) - return sm - - -context = GulpContext() - -def get_input_system_sm(): - m = SM(r'\*\s*Input for Configuration', - name='input-conf', - sections=['section_system'], - subMatchers=[ - SM(r'\s*Formula\s*=\s*(?P<x_gulp_formula>\S+)', - name='formula'), - SM(r'\s*Dimensionality\s*=\s*(?P<x_gulp_pbc>\d+)', - name='pbc'), - SM(r'\s*Symmetry\s*:', - name='symm-header', - subMatchers=[ - SM(r'\s*Space group \S+\s+:\s*(?P<x_gulp_space_group>.+?)\s*$', - name='spacegroup'), - SM(r'\s*Patterson group\s*:\s*(?P<x_gulp_patterson_group>.+?)\s*$', - name='patterson'), - ]), - SM(r'\s*([Cc]artesian lattice|Surface [Cc]artesian|Polymer [Cc]artesian) vectors? \(Angstroms\) :', - name='lattice-header', - subMatchers=[ - context.multi_sm('cell', - r'', - r'\s*(\S+)\s*(\S+)\s*(\S+)') - ]), - SM(r'\s*Primitive cell parameters\s*:\s*Full cell parameters\s*:', - name='cellpar1', - subMatchers=[ - SM(r'\s*a\s*=\s*\S+\s*alpha\s*=\s*\S+\s*a\s*=\s*(?P<x_gulp_cell_a>\S+)\s+alpha\s*=\s*(?P<x_gulp_cell_alpha>\S+)'), - SM(r'\s*b\s*=\s*\S+\s*beta\s*=\s*\S+\s*b =\s*(?P<x_gulp_cell_b>\S+)\s+beta\s*=\s*(?P<x_gulp_cell_beta>\S+)'), - SM(r'\s*c\s*=\s*\S+\s*gamma\s*=\s*\S+\s*c =\s*(?P<x_gulp_cell_c>\S+)\s+gamma\s*=\s*(?P<x_gulp_cell_gamma>\S+)'), - ]), - SM(r'\s*Cell parameters\s*\(Angstroms/Degrees\):', - name='cellpar2', - subMatchers=[ - SM(r'\s*a =\s*(?P<x_gulp_cell_a>\S+)\s*alpha\s*=\s*(?P<x_gulp_cell_alpha>\S+)'), - SM(r'\s*b =\s*(?P<x_gulp_cell_b>\S+)\s*beta\s*=\s*(?P<x_gulp_cell_beta>\S+)'), - SM(r'\s*c =\s*(?P<x_gulp_cell_c>\S+)\s*gamma\s*=\s*(?P<x_gulp_cell_gamma>\S+)'), - ]), - SM(r'\s*(Fractional|[Cc]artesian|Mixed fractional/[Cc]artesian) coordinates of (asymmetric unit|surface|polymer|cluster|)\s*:', - #r'\s*(Fractional coordinates of asymmetric unit' - #r'|Mixed fractional/Cartesian coordinates of (surface|polymer)' - #r'|Cartesian coordinates of cluster)\s*:', - subFlags=SM.SubFlags.Sequenced, - name='frac-coords', - subMatchers=[ - SM(r'--------+', name='bar'), - # We need to skip the 'Region 1' headers, so stop criterion is the empty line! - context.multi_sm('gulp_coordinate_table', - r'-----+', - #No. Atomic x y z Charge Occupancy - # Label (Frac) (Frac) (Frac) (e) (Frac) - # - # 1 La c 0.333333 0.666667 0.245000 * 9.00000 1.000000 - r'\s*\d+\s+(\S+)\s+(\S+)[\s\*]+(\S+)[\s\*]+(\S+)[\s\*]+(\S+)[\s\*]+(\S+)[\s\*]+(\S+)', - r'------------+') - ]), - #SM(r'General interatomic potentials', - #), - ]) - return m - - -def get_output_config_sm(): - m = SM(r'\*\s*Output for configuration', - name='output-conf', - endReStr='\s*Total lattice energy.*?kJ', - sections=['section_single_configuration_calculation'], - subMatchers=[ - get_gulp_energy_sm() - ]) - return m - -def get_optimise_sm(): - m = SM(r'\s*\*+\s*Optimisation achieved\s*\**', - #r'\s*Start of \S+ optimisation :', #r'\*\s*Output for configuration', - name='opt-start', - repeats=True, - sections=['section_system', - 'section_single_configuration_calculation'], - subMatchers=[ - get_gulp_energy_sm(), - #SM(r'\s*Components of energy :', - # name='e-components', - # subMatchers=[ - # get_gulp_energy_sm() - #SM(r'\s*Interatomic potentials\s*=\s*(?P<x_gulp_energy_interatomic_potentials__eV>\S+)\s*eV'), - #SM(r'\s*Monopole - monopole \(real\)\s*=\s*(?P<x_gulp_energy_monopole_monopole_real>\S+)\s*eV'), - #SM(r'\s*Monopole - monopole \(recip\)\s*=\s*(?P<x_gulp_energy_monopole_monopole_recip>\S+)\s*eV'), - #SM(r'\s*Monopole - monopole \(total\)\s*=\s*(?P<x_gulp_energy_monopole_monopole_total>\S+)\s*eV'), - #SM(r'\s*Electric_field\*distance\s*=\s*(?P<x_gulp_energy_electric_field>\S+)\s*eV'), - #SM(r'\s*Total lattice energy\s*=\s*(?P<energy_total__eV>\S+)\s*eV', - # name='etotal') - # ]), - SM(r'\s*Final (asymmetric unit|fractional|fractional/[Cc]artesian|[Cc]artesian)?\s*coordinates\s*(of atoms|of region \d+)?\s*:', - forwardMatch=True, - adHoc=context.adhoc_whether_using_spacegroup, - subMatchers=[ - context.multi_sm('gulp_coordinate_table', - r'-------------+', - # This table is slightly differently formatted than the one from the input - #-------------------------------------------------------------------------------- - # No. Atomic x y z Radius - # Label (Frac) (Frac) (Frac) (Angs) - #-------------------------------------------------------------------------------- - # 1 La c 0.333 0.666 0.248 0.000 - # 2 O c 0.000 0.000 0.000 0.000 - r'\s*\d+\s*(\S+)\s*(\S+)\s*(\S+)\s*(\S+)\s*(\S+)\s*(\S+)', - r'^$') - ]), - SM(r'\s*Final [Cc]artesian lattice vectors \(Angstroms\) :', - subMatchers=[ - context.multi_sm(r'cell', - r'', - r'\s*(\S+)\s*(\S+)\s*(\S+)') - ]), - SM(r'\s*Final cell parameters and derivatives :', - name='finalcell', - subMatchers=[ - SM(r'\s*a\s*(?P<x_gulp_prim_cell_a>\S+)\s+Angstrom', name='a'), - SM(r'\s*b\s*(?P<x_gulp_prim_cell_b>\S+)\s+Angstrom', name='b'), - SM(r'\s*c\s*(?P<x_gulp_prim_cell_c>\S+)\s+Angstrom', name='c'), - SM(r'\s*alpha\s*(?P<x_gulp_prim_cell_alpha>\S+)\s+Degrees', name='alpha'), - SM(r'\s*beta\s*(?P<x_gulp_prim_cell_beta>\S+)\s+Degrees', name='beta'), - SM(r'\s*gamma\s*(?P<x_gulp_prim_cell_gamma>\S+)\s+Degrees', name='gamma'), - ]), - SM(r'\s*Non-primitive lattice parameters :', - name='nonprim', - subMatchers=[ - SM(r'\s*a\s*=\s*(?P<x_gulp_cell_a>\S+)\s*b\s*=\s*(?P<x_gulp_cell_b>\S+)\s*c\s*=\s*(?P<x_gulp_cell_c>\S+)'), - SM(r'\s*alpha\s*=\s*(?P<x_gulp_cell_alpha>\S+)\s*beta\s*=\s*(?P<x_gulp_cell_beta>\S+)\s*gamma\s*=\s*(?P<x_gulp_cell_gamma>\S+)'), - ]), - ]) - return m - -def get_header_sm(): - m = SM(r'\*\s*GENERAL UTILITY LATTICE PROGRAM\s*\*', - name='header', - endReStr=r'\s*Job Started', - subMatchers=[ - SM(r'\*\s+.*?\s*\*$', - name='Julian and friends', - repeats=True), - SM(r'\*\*+'), - SM(r'\*\s*Version\s*=\s*(?P<program_version>\S+)', - name='version'), - SM(r'\*\*\*\*+', - endReStr=r'\*\*\*\*+', - name='bar', - subMatchers=[ - SM(r'\*\s*(?P<x_gulp_main_keyword>\S+)\s*-', - repeats=True, - sections=['x_gulp_section_main_keyword'], - name='mainkw') - ]), - SM(r'\*\s*(?P<x_gulp_title>.*?)\s*\*$', - name='title') - ]) - return m - -def get_gulp_potential_species_pattern(nspecies): - tokens = [] - for i in range(1, nspecies + 1): - tokens.append(r'(?P<x_gulp_forcefield_species_%d>\w+)\s*' % i) - tokens.append(r'(?P<x_gulp_forcefield_speciestype_%d>\S+)\s*' % i) - return ''.join(tokens) - - -def get_forcefield_table_sm(header, columnheaderpattern, tablepattern, name): - m = SM(header,#r'\s*(General interatomic|Intramolecular|Intermolecular) potentials :', - name=name, - subMatchers=[ - SM(columnheaderpattern,#r'\s*Atom\s*Types\s*Potential\s*A*\s*B\s*C\s*D', - #Atom Types Potential A B C D Cutoffs(Ang) - # 1 2 Min Max - # ------------------------------------------------------------------------------- - #O s La s Buckingham 0.570E+04 0.299 38.9 0.00 0.000 24.000 - subMatchers=[ - SM(r'----------+', name='potentials', - endReStr=r'----------+', - subMatchers=[ - SM(tablepattern,#''.join(tokens), - #get_gulp_potential_species_pattern(2) + - #r'(?P<x_gulp_forcefield_species_1>\w+)\s*' - #r'(?P<x_gulp_forcefield_speciestype_1>\S+)\s*' - #r'(?P<x_gulp_forcefield_species_2>\S+)\s*' - #r'(?P<x_gulp_forcefield_speciestype_2>\S+)\s*' - # The SRGlue potential is badly written in the table and unparseable. - # Probably a bug. So just ignore it. - #r'(SRGlue|(?P<x_gulp_forcefield_potential_name>\b.{1,14}?)\s*' - #r'(?P<x_gulp_forcefield_parameter_a>\S+)\s*' - #r'(?P<x_gulp_forcefield_parameter_b>\S+)\s*' - #r'(?P<x_gulp_forcefield_parameter_c>\S+)\s*' - # r'(?P<x_gulp_forcefield_parameter_d>\S+)\s*' - # r'(?P<x_gulp_forcefield_cutoff_min>\S+\s*)' - # r'(?P<x_gulp_forcefield_cutoff_max>\S+))$', - name='table', - sections=['x_gulp_section_forcefield'], - repeats=True - ), - ]), - ]), - ]) - return m - - -def get_general_input_sm(): - m = SM(r'\*\s*General input information', - name='general-input', - sections=['section_method'], - subMatchers=[ - SM(r'\s*Species output for all configurations :'), - SM(r'\s*Species\s*Type\s*Atomic', - subMatchers=[ - context.multi_sm('species', - r'-------+', - # species type charge - r'\s*(\S+)\s*(\S+)\s*\d+\s*\S+\s*(\S+)', - r'-------+') - ]), - get_forcefield_table_sm(r'\s*(General interatomic|Intramolecular) potentials :', - r'\s*Atom\s*Types\s*Potential\s*A*\s*B\s*C\s*D', - get_gulp_potential_species_pattern(2) + - r'(SRGlue|' - r'(?P<x_gulp_forcefield_potential_name>\b.{1,14}?)\s*' - r'(?P<x_gulp_forcefield_parameter_a>\S+)\s*' - r'(?P<x_gulp_forcefield_parameter_b>\S+)\s*' - r'(?P<x_gulp_forcefield_parameter_c>\S+)\s*' - r'(?P<x_gulp_forcefield_parameter_d>\S+)\s*' - r'(?P<x_gulp_forcefield_cutoff_min>\S+\s*)' - r'(?P<x_gulp_forcefield_cutoff_max>\S+)$)', - name='interatomic'), - get_forcefield_table_sm(r'\s*(Intermolecular) potentials :', # Basically a copy of the one just above - r'\s*Atom\s*Types\s*Potential\s*A*\s*B\s*C\s*D', - get_gulp_potential_species_pattern(2) + - r'(SRGlue|(?P<x_gulp_forcefield_potential_name>\b.{1,14}?)\s*' - r'(?P<x_gulp_forcefield_parameter_a>\S+)\s*' - r'(?P<x_gulp_forcefield_parameter_b>\S+)\s*' - r'(?P<x_gulp_forcefield_parameter_c>\S+)\s*' - r'(?P<x_gulp_forcefield_parameter_d>\S+)\s*' - r'(?P<x_gulp_forcefield_cutoff_min>\S+\s*)' - r'(?P<x_gulp_forcefield_cutoff_max>\S+))$', - name='intermolecular'), - get_forcefield_table_sm(r'\s*General Three-body potentials :', - r'\s*Atom\s*Atom\s*Atom\s*Force Constants\s*Theta', - get_gulp_potential_species_pattern(3) + - r'(?P<x_gulp_forcefield_threebody_1>\S+)\s*' - r'(?P<x_gulp_forcefield_threebody_2>\S+)\s*' - r'(?P<x_gulp_forcefield_threebody_3>\S+)\s*' - r'(?P<x_gulp_forcefield_threebody_theta>\S+)\s*', - name='3-body'), - get_forcefield_table_sm(r'\s*General Four-body potentials :', - r'\s*Atom Types\s*Force cst\s*Sign\s*Phase\s*Phi0', - get_gulp_potential_species_pattern(4) + - r'(?P<x_gulp_forcefield_fourbody_force_constant>\S+)\s*' - r'(?P<x_gulp_forcefield_fourbody_sign>\S+)\s*' - r'(?P<x_gulp_forcefield_fourbody_phase>\S+)\s*' - r'(?P<x_gulp_forcefield_fourbody_phi0>\S+)\s*', - name='3-body'), - ]) - return m - -def get_md_sm(): - m = SM(r'\*\s*Molecular Dynamics', - name='md', - subMatchers=[ - SM(r'\s*Molecular dynamics production :', - name='mdstep', - subMatchers=[ - SM(r'\s*\*\*\s*Time :\s*(?P<x_gulp_md_time__ps>\S+)\s*ps :', - sections=['section_system', 'section_single_configuration_calculation'], - repeats=True, - subMatchers=[ - SM(r'\s*Kinetic energy\s*\(eV\)\s*=\s*(?P<x_gulp_md_kinetic_energy__eV>\S+)'), - SM(r'\s*Potential energy\s*\(eV\)\s*=\s*(?P<x_gulp_md_potential_energy__eV>\S+)'), - SM(r'\s*Total energy\s*\(eV\)\s*=\s*(?P<x_gulp_md_total_energy__eV>\S+)'), - SM(r'\s*Temperature\s*\(K\)\s*=\s*(?P<x_gulp_md_temperature__K>\S+)'), - SM(r'\s*Pressure\s*\(GPa\)\s*=\s*(?P<x_gulp_md_pressure__GPa>\S+)'), - ]) - ]) - ]) - return m - -infoFileDescription = SM( - name='root', - weak=True, - startReStr='', - fixedStartValues={'program_name': 'gulp', - 'program_basis_set_type': 'unavailable'}, - sections=['section_run'], - subMatchers=[ - get_header_sm(), - get_input_system_sm(), - get_general_input_sm(), - get_output_config_sm(), - get_optimise_sm(), # note British spelling - get_md_sm(), - SM(r'x^', - name='impossible') # 'Parse' the whole file - ]) - -def main(**kwargs): - mainFunction(mainFileDescription=infoFileDescription, - metaInfoEnv=metaInfoEnv, - parserInfo=parser_info, - cachingLevelForMetaName={}, - superContext=context, - **kwargs) - -if __name__ == '__main__': - main() diff --git a/toDelete/parser/parser-gulp/nomad_meta_info b/toDelete/parser/parser-gulp/nomad_meta_info deleted file mode 120000 index 1b10d0640f73609a04c7e90a8923e8ca39e692dd..0000000000000000000000000000000000000000 --- a/toDelete/parser/parser-gulp/nomad_meta_info +++ /dev/null @@ -1 +0,0 @@ -../../../../nomad-meta-info/meta_info/nomad_meta_info \ No newline at end of file diff --git a/toDelete/parser/parser-gulp/outputs b/toDelete/parser/parser-gulp/outputs deleted file mode 120000 index 20e7a36aa4692f217ace22007f58becdc299fb51..0000000000000000000000000000000000000000 --- a/toDelete/parser/parser-gulp/outputs +++ /dev/null @@ -1 +0,0 @@ -../../test/examples/outputs/ \ No newline at end of file diff --git a/toDelete/parser/parser-gulp/runtests.py b/toDelete/parser/parser-gulp/runtests.py deleted file mode 100755 index a8122e203ded651004ea906849e6ee2f16eeed4e..0000000000000000000000000000000000000000 --- a/toDelete/parser/parser-gulp/runtests.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python -# Copyright 2016-2018 Ask Hjorth Larsen, Fawzi Mohamed -# -# 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 __future__ import print_function -from glob import glob -import re -from optparse import OptionParser -from subprocess import Popen, PIPE -import os -from ase.parallel import world -import platform - -p = OptionParser() -opts, args = p.parse_args() - -if len(args) == 0: - testfiles = glob('test/outputs/example*.got') - testfiles.sort() - - #tests = {} - - #testfiles.sort() - #print(testfiles) - - #pat = re.compile('test/outputs/example(\d+)[ab]?.got') - - #for fname in testfiles: - # print(fname, pat.match(fname)) - #testfiles.sort(key=lambda fname: - # int(pat.match(fname).group(1))) - #for f in testfiles: - # print(f) -else: - testfiles = argv - -for i, testfile in enumerate(testfiles): - if i % world.size != world.rank: - continue - dirname, basename = os.path.split(testfile) - print(basename) - py = 'python' - if platform.node() == 'labdev-nomad': - py = '/labEnv3/bin/python' - args = [py, 'main.py', '--annotate'] - args.append(testfile) - proc = Popen(args, stdout=PIPE) - txt = proc.stdout.read() - with open('%s.json' % testfile, 'w') as fd: - fd.write(txt.decode('ascii')) diff --git a/toDelete/parser/parser-gulp/setup_paths.py b/toDelete/parser/parser-gulp/setup_paths.py deleted file mode 100644 index d919821887f6961d953bf12534f5fa633208fe4f..0000000000000000000000000000000000000000 --- a/toDelete/parser/parser-gulp/setup_paths.py +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2016-2018 Ask Hjorth Larsen, Fawzi Mohamed -# -# 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, os, os.path -baseDir = os.path.dirname(os.path.abspath(__file__)) -commonDir = os.path.normpath(os.path.join(baseDir,"../../../../python-common/common/python")) - -if not commonDir in sys.path: - sys.path.insert(0, commonDir) diff --git a/toDelete/parser/parser-gulp/spacegroups.py b/toDelete/parser/parser-gulp/spacegroups.py deleted file mode 100644 index 3acba5b03fe2c96d3672df402072ae47edd2dc6e..0000000000000000000000000000000000000000 --- a/toDelete/parser/parser-gulp/spacegroups.py +++ /dev/null @@ -1,95 +0,0 @@ -# Copyright 2016-2018 Ask Hjorth Larsen, Fawzi Mohamed -# -# 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. - -# All the space groups that GULP will print -sg = ['P 1 ','P -1 ','P 2 ','P 21 ', - 'C 2 ','P M ','P C ','C M ','C C ', - 'P 2/M ','P 21/M ','C 2/M ','P 2/C ','P 21/C ', - 'C 2/C ','P 2 2 2 ','P 2 2 21 ','P 21 21 2 ','P 21 21 21 ', - 'C 2 2 21 ','C 2 2 2 ','F 2 2 2 ','I 2 2 2 ','I 21 21 21 ', - 'P M M 2 ','P M C 21 ','P C C 2 ','P M A 2 ','P C A 21 ', - 'P N C 2 ','P M N 21 ','P B A 2 ','P N A 21 ','P N N 2 ', - 'C M M 2 ','C M C 21 ','C C C 2 ','A M M 2 ','A B M 2 ', - 'A M A 2 ','A B A 2 ','F M M 2 ','F D D 2 ','I M M 2 ', - 'I B A 2 ','I M A 2 ','P M M M ','P N N N ','P C C M ', - 'P B A N ','P M M A ','P N N A ','P M N A ','P C C A ', - 'P B A M ','P C C N ','P B C M ','P N N M ','P M M N ', - 'P B C N ','P B C A ','P N M A ','C M C M ', - 'C M C A ','C M M M ','C C C M ','C M M A ','C C C A ', - 'F M M M ','F D D D ','I M M M ','I B A M ','I B C A ', - 'I M M A ','P 4 ','P 41 ','P 42 ','P 43 ', - 'I 4 ','I 41 ','P -4 ','I -4 ','P 4/M ', - 'P 42/M ','P 4/N ','P 42/N ','I 4/M ','I 41/A ', - 'P 4 2 2 ','P 4 21 2 ','P 41 2 2 ','P 41 21 2 ','P 42 2 2 ', - 'P 42 21 2 ','P 43 2 2 ','P 43 21 2 ','I 4 2 2 ','I 41 2 2 ', - 'P 4 M M ','P 4 B M ','P 42 C M ','P 42 N M ','P 4 C C ', - 'P 4 N C ','P 42 M C ','P 42 B C ','I 4 M M ','I 4 C M ', - 'I 41 M D ','I 41 C D ','P -4 2 M ','P -4 2 C ','P -4 21 M ', - 'P -4 21 C ','P -4 M 2 ','P -4 C 2 ','P -4 B 2 ','P -4 N 2 ', - 'I -4 M 2 ','I -4 C 2 ','I -4 2 M ','I -4 2 D ', - 'P 4/M M M ','P 4/M C C ','P 4/N B M ','P 4/N N C ','P 4/M B M ', - 'P 4/M N C ','P 4/N M M ','P 4/N C C ','P 42/M M C ','P 42/M C M ', - 'P 42/N B C ','P 42/N N M ','P 42/M B C ','P 42/M N M ','P 42/N M C ', - 'P 42/N C M ','I 4/M M M ','I 4/M C M ','I 41/A M D ','I 41/A C D ', - 'P 3 ','P 31 ','P 32 ','R 3 ','P -3 ', - 'R -3 ','P 3 1 2 ','P 3 2 1 ','P 31 1 2 ','P 31 2 1 ', - 'P 32 1 2 ','P 32 2 1 ','R 3 2 ','P 3 M 1 ','P 3 1 M ', - 'P 3 C 1 ','P 3 1 C ','R 3 M ','R 3 C ','P -3 1 M ', - 'P -3 1 C ','P -3 M 1 ','P -3 C 1 ','R -3 M ','R -3 C ', - 'P 6 ','P 61 ','P 65 ','P 62 ','P 64 ', - 'P 63 ','P -6 ','P 6/M ','P 63/M ','P 6 2 2 ', - 'P 61 2 2 ','P 65 2 2 ','P 62 2 2 ','P 64 2 2 ', - 'P 63 2 2 ','P 6 M M ','P 6 C C ','P 63 C M ','P 63 M C ', - 'P -6 M 2 ','P -6 C 2 ','P -6 2 M ','P -6 2 C ','P 6/M M M ', - 'P 6/M C C ','P 63/M C M ','P 63/M M C ','P 2 3 ','F 2 3 ', - 'I 2 3 ','P 21 3 ','I 21 3 ','P M 3 ','P N 3 ', - 'F M 3 ','F D 3 ','I M 3 ','P A 3 ','I A 3 ', - 'P 4 3 2 ','P 42 3 2 ','F 4 3 2 ','F 41 3 2 ','I 4 3 2 ', - 'P 43 3 2 ','P 41 3 2 ','I 41 3 2 ','P -4 3 M ','F -4 3 M ', - 'I -4 3 M ','P -4 3 N ','F -4 3 C ','I -4 3 D ','P M 3 M ', - 'P N 3 N ','P M 3 N ','P N 3 M ','F M 3 M ','F M 3 C ', - 'F D 3 M ','F D 3 C ','I M 3 M ','I A 3 D ','C 1 ', - 'C -1 '] -sg = [string.strip() for string in sg] - -# GULP contains at least some errors in the space groups. Thus we have to somehow hack things until they work. - -sgdict = {} - -missing_minus = set(range(200, 207)) -missing_minus.union(range(221,231)) - -for i, name in enumerate(sg): - num = i + 1 - assert name not in sgdict - sgdict[name] = num - if num in missing_minus: - correct_name = name.replace('3', '-3') - assert correct_name not in sgdict - sgdict[correct_name] = num - -def get_spacegroup_number(name): - return sgdict[name] - -#for i -#print(len(sg)) -#from ase.spacegroup import Spacegroup -#asesym = [] -#for i in range(1, 231): -# asesym.append(Spacegroup(i).symbol) - -#for i, (s1, s2) in enumerate(zip(asesym, sg)): -# is_ok = (s1.lower() == s2.lower()) -# print('%3d %10s %10s %10s' % (i + 1, s1, s2, is_ok)) - diff --git a/toDelete/parser/parser-gulp/test b/toDelete/parser/parser-gulp/test deleted file mode 120000 index b8a3c0dc4cd4c371566ac9f59260cfdf9956650f..0000000000000000000000000000000000000000 --- a/toDelete/parser/parser-gulp/test +++ /dev/null @@ -1 +0,0 @@ -../../test/examples/ \ No newline at end of file diff --git a/toDelete/pysrc b/toDelete/pysrc deleted file mode 120000 index cfcb973b85379c9a984566cd2e8973340a2a7e8e..0000000000000000000000000000000000000000 --- a/toDelete/pysrc +++ /dev/null @@ -1 +0,0 @@ -parser/parser-gulp \ No newline at end of file