Skip to content

Commit

Permalink
add barin table data, graph saving/loading
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmcdermott committed Nov 16, 2021
1 parent 2bb1cbb commit 0c44c88
Show file tree
Hide file tree
Showing 16 changed files with 30,439 additions and 375 deletions.
21 changes: 19 additions & 2 deletions src/rxn_network/core/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def __init__(self, entries: List[Entry], enumerators, cost_function):
self.enumerators = enumerators
self.cost_function = cost_function
self._g = None
self.precursors = None
self.target = None
self._precursors = None
self._target = None

@abstractmethod
def build(self):
Expand All @@ -41,3 +41,20 @@ def set_precursors(self):
@abstractmethod
def set_target(self):
"""Set the phase used as a target in the network"""

@property
def precursors(self):
return self._precursors

@property
def target(self):
return self._target

@property
def graph(self):
""" Returns the network object in graph-tool"""
return self._g

@property
def chemsys(self):
return "-".join(sorted(self.entries.chemsys))
20 changes: 18 additions & 2 deletions src/rxn_network/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@

cwd = Path(__file__).parent.resolve()

G_COMPOUNDS = loadfn(cwd / "compounds.json")
PATH_TO_BARIN = cwd / "barin"
PATH_TO_NIST = cwd / "nist"

G_ELEMS = loadfn(cwd / "elements.json")
G_GASES = loadfn(cwd / "gases.json")


def load_experimental_data(fn):
"""
Load experimental data from a json file
"""
d = loadfn(fn)
return {comp: make_float_keys(data) for comp, data in d.items()}


def make_float_keys(d):
"""
Convert all keys in a dict to floats
"""
return {float(k): v for k, v in d.items()}
Loading

0 comments on commit 0c44c88

Please sign in to comment.