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

Add FEFF schema #41

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions aimmdb/adapters/feff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from tiled.adapters.dataframe import DataFrameAdapter


# dataframe adapter representing FEFF data
class FEFFAdapter(DataFrameAdapter):
specs = ["FEFF"]
63 changes: 63 additions & 0 deletions aimmdb/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,66 @@ class BatteryChargeMetadataInternal(pydantic.BaseModel):

class BatteryChargeMetadata(pydantic.BaseModel, extra=pydantic.Extra.allow):
charge: BatteryChargeMetadataInternal

class FEFFpotentials(pydantic.BaseModel, extra=pydantic.Extra.allow):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too fine-grained. We can simply remove it for now. All of this is going into input_script.

x: Optional[str]
ipot: int
Z: str
element: int
l_scmt: int
l_fms: int
#FEFFpotentials = (x, ipot, Z, element, l_scmt, l_fms)
#converted_potentials = str(FEFFpotentials)
#smiles = string

class FEFFcards(pydantic.BaseModel, extra=pydantic.Extra.allow):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as my previous comment:

This is too fine-grained. We can simply remove it for now. All of this is going into input_script.

atoms: float
control: int
exchange: float
title: Optional[str]
rpath: int
potentials: FEFFpotentials
xanes: float
edge: str
scf: float
fms: float
S02: float
corehole: str
#smiles = string

#class FEFFDataFrame(DataFrameStructure):
#file_input = "xmu.dat"
#omega: float
#e: float
#k: float
#mu: float
#mu0: float
#chi: float
#FEFFDataFrame_inputs = (omega, e, k, mu, mu0, chi)
#smiles = string

#need to write validation for the Dataframe

#class ExperimentalFEFFMetadata(pydantic.BaseModel, extra=pydantic.Extra.allow):
#FileType = "feff.out"; "feff.inp"
#measurement_type: MeasurementEnum = pydantic.Field("feff", const=True)
#title = measurement_type(pydantic.field("title"))
#absorbing_atom = measurement_type(pydantic.field("edge"))
#cards = measurement_type(FEFFcards)
#smiles = string

class FEFFInputMetadata(pydantic.BaseModel, extra=pydantic.Extra.allow):
element: XDIElement
measurement_type: MeasurementEnum = pydantic.Field("FEFF", const=True)
dataset: str
sample_id: str
input_script: str
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

input_script not input_scripts.


class FEFFOutputMetadata(pydantic.BaseModel, extra=pydantic.Extra.allow):
element: XDIElement
measurement_type: MeasurementEnum = pydantic.Field("FEFF", const=True)
dataset: str
sample_id: str
#change to output log
output_script: str
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to output_log 👍

Also, needs a new key: xmu.dat-comments, which is also str.


13 changes: 12 additions & 1 deletion aimmdb/validation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pydantic
from tiled.validation_registration import ValidationError

from .schemas import BatteryChargeMetadata, ExperimentalXASMetadata
from .schemas import BatteryChargeMetadata, ExperimentalXASMetadata, ExperimentalFEFFMetadata


def validate_xas_metadata(metadata, structure_family, structure, spec):
Expand Down Expand Up @@ -45,3 +45,14 @@ def validate_battery_charge_data(metadata, structure_family, structure, spec):
metadata = BatteryChargeMetadata.parse_obj(metadata)
except pydantic.ValidationError as e:
raise ValidationError(str(e))

def validate_feff(metadata, structure_family, structure, spec):
#validate_xas_metadata(metadata, structure_family, structure, spec)

columns = set(structure.macro.columns)

required_columns = {"omega", "e", "k", "mu", "mu0", "chi"}


if not required_columns.issubset(columns):
raise ValidationError(f"columns {columns} must contain {required_columns}")
Loading