Skip to content

Commit

Permalink
fix rates in results for haber data, specify h5 file, which can be pr…
Browse files Browse the repository at this point in the history
…ocessed
  • Loading branch information
schumannj committed Nov 7, 2024
1 parent 133d9bc commit c67a48b
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions src/nomad_catalysis/schema_packages/catalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ def read_haber_data(self, archive, logger): # noqa: PLR0912, PLR0915
This function reads the h5 data from the data file and assigns the data to the
corresponding attributes of the class.
"""
if self.data_file.endswith('.h5'):
if self.data_file.endswith('NH3_Decomposition.h5'):
with archive.m_context.raw_file(self.data_file, 'rb') as f:
import h5py

Expand Down Expand Up @@ -1723,7 +1723,11 @@ def check_and_read_data_file(self, archive, logger):
if self.data_file.endswith('.csv') or self.data_file.endswith('.xlsx'):
self.read_clean_data(archive, logger)
elif self.data_file.endswith('.h5'):
self.read_haber_data(archive, logger)
if self.data_file.endswith('NH3_Decomposition.h5'):
self.read_haber_data(archive, logger)
else:
logger.info("""This h5 file format currently not supported. Please
contact the plugin developers if you want to add support for this.""")
else:
logger.error(
"""Data file format not supported. Please provide a
Expand Down Expand Up @@ -1988,6 +1992,17 @@ def plot_figures(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
fig = self.single_plot(x, x_text, y.to(unit_dict[var]), y_text, title)
self.figures.append(PlotlyFigure(label=title, figure=fig.to_plotly_json()))

fig1 = self.conversion_plot(x, x_text, logger)
if fig1 is not None:
self.figures.append(
PlotlyFigure(label='Conversion', figure=fig1.to_plotly_json())
)

if self.results[0].rates:
self.make_rates_plot(x, x_text)

if not self.results[0].products:
return
if (
self.results[0].products is not None
and self.results[0].products != []
Expand All @@ -2008,14 +2023,6 @@ def plot_figures(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
self.figures.append(
PlotlyFigure(label='Selectivity', figure=fig0.to_plotly_json())
)
fig1 = self.conversion_plot(x, x_text, logger)
if fig1 is not None:
self.figures.append(
PlotlyFigure(label='Conversion', figure=fig1.to_plotly_json())
)

if self.results[0].rates:
self.make_rates_plot(x, x_text)

if not self.results[0].reactants_conversions:
return
Expand Down Expand Up @@ -2165,7 +2172,14 @@ def reduce_haber_data(self, archive: 'EntryArchive', logger: 'BoundLogger') -> N
name='molecular hydrogen',
reaction_rate=Rates * ureg.mmol / ureg.g / ureg.hour,
)
archive.results.properties.catalytic.reaction.rate = [h2_rate]
rates = []
rates.append(h2_rate)
set_nested_attr(
archive.results.properties.catalytic.reaction,
'rates',
rates,
)
# archive.results.properties.catalytic.reaction.rate = [h2_rate]

react = Reactant(
name='ammonia', conversion=Convs, gas_concentration_in=NH3concs
Expand Down

0 comments on commit c67a48b

Please sign in to comment.