Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix quantity types #106

Merged
merged 21 commits into from
May 16, 2024
350 changes: 201 additions & 149 deletions atomisticparsers/amber/metainfo/amber.py

Large diffs are not rendered by default.

45 changes: 27 additions & 18 deletions atomisticparsers/asap/metainfo/asap.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import numpy as np # pylint: disable=unused-import
import typing # pylint: disable=unused-import
import numpy as np # pylint: disable=unused-import
import typing # pylint: disable=unused-import
from nomad.metainfo import ( # pylint: disable=unused-import
MSection, MCategory, Category, Package, Quantity, Section, SubSection, SectionProxy,
Reference
MSection,
MCategory,
Category,
Package,
Quantity,
Section,
SubSection,
SectionProxy,
Reference,
)
import simulationworkflowschema

Expand All @@ -29,38 +36,40 @@


class MolecularDynamics(simulationworkflowschema.MolecularDynamics):

m_def = Section(validate=False, extends_base_section=True)

x_asap_langevin_friction = Quantity(
type=np.dtype(np.float64),
type=np.float64,
shape=[],
description='''
description="""
Friction coeffient used in Langevin dynamics
''')
""",
)

x_asap_temperature = Quantity(
type=np.dtype(np.float64),
type=np.float64,
shape=[],
description='''
description="""
Temperature used in molecular-dynamics
''')
""",
)

x_asap_timestep = Quantity(
type=np.dtype(np.float64),
type=np.float64,
shape=[],
description='''
description="""
Timestep in molecular dynamics
''')
""",
)


class GeometryOptimization(simulationworkflowschema.GeometryOptimization):

m_def = Section(validate=False, extends_base_section=True)

x_asap_maxstep = Quantity(
type=np.dtype(np.float64),
type=np.float64,
shape=[],
description='''
description="""
Maxstep in Angstrom for geometry optimization
''')
""",
)
7 changes: 6 additions & 1 deletion atomisticparsers/asap/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,14 @@ def index():
for constraint in traj.constraints:
as_dict = constraint.todict()
indices = as_dict["kwargs"].get("a", as_dict["kwargs"].get("indices"))
indices = (
indices
if isinstance(indices, (np.ndarray, list))
else [int(indices)]
)
constraints.append(
dict(
atom_indices=np.asarray(indices),
atom_indices=[np.asarray(indices)],
kind=get_constraint_name(as_dict),
)
)
Expand Down
131 changes: 76 additions & 55 deletions atomisticparsers/bopfox/metainfo/bopfox.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import numpy as np # pylint: disable=unused-import
import numpy as np # pylint: disable=unused-import

from nomad.metainfo import ( # pylint: disable=unused-import
MSection, MCategory, Category, Package, Quantity, Section, SubSection, SectionProxy,
Reference, JSON
MSection,
MCategory,
Category,
Package,
Quantity,
Section,
SubSection,
SectionProxy,
Reference,
JSON,
)
import runschema.run # pylint: disable=unused-import
import runschema.calculation # pylint: disable=unused-import
Expand All @@ -32,173 +40,186 @@


class Method(runschema.calculation.Method):

m_def = Section(validate=False, extends_base_section=True)

x_bopfox_simulation_parameters = Quantity(
type=JSON,
shape=[],
description='''
''')
description="""
""",
)


class Energy(runschema.calculation.Energy):

m_def = Section(validate=False, extends_base_section=True)

x_bopfox_bond = SubSection(
sub_section=runschema.calculation.EnergyEntry.m_def,
description='''
description="""
Contains the value and information regarding the bond energy.
''')
""",
)

x_bopfox_prom = SubSection(
sub_section=runschema.calculation.EnergyEntry.m_def,
description='''
description="""
Contains the value and information regarding the promotion energy.
''')
""",
)

x_bopfox_rep1 = SubSection(
sub_section=runschema.calculation.EnergyEntry.m_def,
description='''
description="""
Contains the value and information regarding the first repulsion energy.
''')
""",
)

x_bopfox_rep2 = SubSection(
sub_section=runschema.calculation.EnergyEntry.m_def,
description='''
description="""
Contains the value and information regarding the second repulsion energy.
''')
""",
)

x_bopfox_rep3 = SubSection(
sub_section=runschema.calculation.EnergyEntry.m_def,
description='''
description="""
Contains the value and information regarding the third repulsion energy.
''')
""",
)


class Forces(runschema.calculation.Forces):

m_def = Section(validate=False, extends_base_section=True)

x_bopfox_analytic = SubSection(
sub_section=runschema.calculation.ForcesEntry.m_def,
description='''
description="""
Contains the value and information regarding the analytic forces.
''')
""",
)

x_bopfox_rep1 = SubSection(
sub_section=runschema.calculation.ForcesEntry.m_def,
description='''
description="""
Contains the value and information regarding the first analytic forces.
''')
""",
)

x_bopfox_rep2 = SubSection(
sub_section=runschema.calculation.ForcesEntry.m_def,
description='''
description="""
Contains the value and information regarding the second analytic forces.
''')
""",
)

x_bopfox_rep3 = SubSection(
sub_section=runschema.calculation.ForcesEntry.m_def,
description='''
description="""
Contains the value and information regarding the third analytic forces.
''')
""",
)


class x_bopfox_onsite_levels_value(runschema.calculation.AtomicValues):

m_def = Section(validate=False)

value = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
description="""
Value of the onsite level projected on orbital and spin channel.
''')
""",
)


class x_bopfox_onsite_levels(runschema.calculation.Atomic):

m_def = Section(validate=False)

orbital_projected = SubSection(sub_section=x_bopfox_onsite_levels_value.m_def, repeats=True)
orbital_projected = SubSection(
sub_section=x_bopfox_onsite_levels_value.m_def, repeats=True
)


class Calculation(runschema.calculation.Calculation):

m_def = Section(validate=False, extends_base_section=True)

x_bopfox_onsite_levels = SubSection(sub_section=x_bopfox_onsite_levels.m_def, repeats=True)
x_bopfox_onsite_levels = SubSection(
sub_section=x_bopfox_onsite_levels.m_def, repeats=True
)


class Interaction(runschema.method.Interaction):

m_def = Section(validate=False, extends_base_section=True)

x_bopfox_valence = Quantity(
type=str,
shape=['n_atoms'],
description='''
shape=["n_atoms"],
description="""
Valence of the atoms described by the interaction.
''')
""",
)

x_bopfox_chargetransfer = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
shape=["*"],
description="""
Charge transfer parameters.
''')
""",
)

x_bopfox_cutoff = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
description="""
Cutoff distance for the interaction.
''')
""",
)

x_bopfox_dcutoff = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
description="""
Distance from cutoff where the cutoff function is applied.
''')
""",
)


class Model(runschema.method.Model):

m_def = Section(validate=False, extends_base_section=True)

x_bopfox_parameters = Quantity(
type=JSON,
shape=[],
description='''
''')
description="""
""",
)


class xTB(runschema.method.xTB):

m_def = Section(validate=False, extends_base_section=True)

x_bopfox_parameters = Quantity(
type=JSON,
shape=[],
description='''
''')
description="""
""",
)


class AtomParameters(runschema.method.AtomParameters):

m_def = Section(validate=False, extends_base_section=True)

x_bopfox_valenceorbitals = Quantity(
type=np.dtype(np.int32),
shape=[],
description='''
''')
description="""
""",
)

x_bopfox_stonerintegral = Quantity(
type=np.dtype(np.float64),
shape=[3],
description='''
''')
description="""
""",
)
6 changes: 3 additions & 3 deletions atomisticparsers/bopfox/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def write_to_archive(self) -> None:
name=key,
functional_form=val[0],
parameters=val[1:],
atom_labels=bond.get("bond"),
atom_labels=[bond.get("bond")],
x_bopfox_valence=bond.get("valence"),
x_bopfox_cutoff=bond.get("rcut"),
x_bopfox_dcutoff=bond.get("dcut"),
Expand All @@ -496,7 +496,7 @@ def write_to_archive(self) -> None:
name=key,
functional_form=val[0],
parameters=val[1:],
atom_labels=bond.get("bond"),
atom_labels=[bond.get("bond")],
x_bopfox_cutoff=bond.get("r2cut"),
x_bopfox_dcutoff=bond.get("d2cut"),
)
Expand All @@ -508,7 +508,7 @@ def write_to_archive(self) -> None:
name=key,
functional_form=val[0],
parameters=val[1:],
atom_labels=bond.get("bond"),
atom_labels=[bond.get("bond")],
x_bopfox_cutoff=bond.get("r2cut"),
x_bopfox_dcutoff=bond.get("d2cut"),
)
Expand Down
Loading
Loading