Skip to content

Commit

Permalink
small error fixes, mainly figures
Browse files Browse the repository at this point in the history
  • Loading branch information
schumannj committed Aug 6, 2024
1 parent b24d633 commit 1b7148e
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 76 deletions.
127 changes: 68 additions & 59 deletions src/nomad_catalysis/schema_packages/catalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,39 +1254,40 @@ 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()))

fig0 = go.Figure()
for i, c in enumerate(self.results[0].products):
fig0.add_trace(
go.Scatter(
x=x,
y=self.results[0].products[i].selectivity,
name=self.results[0].products[i].name,
if self.results[0].products[0].selectivity:
fig0 = go.Figure()
for i, c in enumerate(self.results[0].products):
fig0.add_trace(
go.Scatter(
x=x,
y=self.results[0].products[i].selectivity,
name=self.results[0].products[i].name,
)
)
fig0.update_layout(title_text='Selectivity', showlegend=True)
fig0.update_xaxes(title_text=x_text)
fig0.update_yaxes(title_text='Selectivity (%)')
self.figures.append(
PlotlyFigure(label='figure Selectivity', figure=fig0.to_plotly_json())
)
fig0.update_layout(title_text='Selectivity', showlegend=True)
fig0.update_xaxes(title_text='measurement points')
fig0.update_yaxes(title_text='Selectivity (%)')
self.figures.append(
PlotlyFigure(label='figure Selectivity', figure=fig0.to_plotly_json())
)

fig1 = go.Figure()
for i, c in enumerate(self.results[0].reactants_conversions):
fig1.add_trace(
go.Scatter(
x=x,
y=self.results[0].reactants_conversions[i].conversion,
name=self.results[0].reactants_conversions[i].name,
if self.results[0].reactants_conversions[0].conversion:
fig1 = go.Figure()
for i, c in enumerate(self.results[0].reactants_conversions):
fig1.add_trace(
go.Scatter(
x=x,
y=self.results[0].reactants_conversions[i].conversion,
name=self.results[0].reactants_conversions[i].name,
)
)
fig1.update_layout(title_text='Conversion', showlegend=True)
fig1.update_xaxes(title_text=x_text)
fig1.update_yaxes(title_text='Conversion (%)')
self.figures.append(
PlotlyFigure(label='figure Conversion', figure=fig1.to_plotly_json())
)
fig1.update_layout(title_text='Conversion', showlegend=True)
fig1.update_xaxes(title_text=x_text)
fig1.update_yaxes(title_text='Conversion (%)')
self.figures.append(
PlotlyFigure(label='figure Conversion', figure=fig1.to_plotly_json())
)

if self.results[0].rates is not None:
if self.results[0].rates:
fig = go.Figure()
for i, c in enumerate(self.results[0].rates):
fig.add_trace(
Expand All @@ -1302,28 +1303,30 @@ def plot_figures(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
self.figures.append(
PlotlyFigure(label='Rates', figure=fig.to_plotly_json())
)

for i, c in enumerate(self.results[0].reactants_conversions):
name = self.results[0].reactants_conversions[i].name
fig = go.Figure()
for j, p in enumerate(self.results[0].products):
fig.add_trace(
go.Scatter(
x=self.results[0].reactants_conversions[i].conversion,
y=self.results[0].products[j].selectivity,
name=self.results[0].products[j].name,
mode='markers',
if self.results[0].reactants_conversions[0].conversion and (
self.results[0].products[0].selectivity
):
for i, c in enumerate(self.results[0].reactants_conversions):
name = self.results[0].reactants_conversions[i].name
fig = go.Figure()
for j, p in enumerate(self.results[0].products):
fig.add_trace(
go.Scatter(
x=self.results[0].reactants_conversions[i].conversion,
y=self.results[0].products[j].selectivity,
name=self.results[0].products[j].name,
mode='markers',
)
)
fig.update_layout(title_text='S-X plot ' + str(i), showlegend=True)
fig.update_xaxes(title_text=name + ' Conversion (%)')
fig.update_yaxes(title_text='Selectivity (%)')
self.figures.append(
PlotlyFigure(
label='S-X plot ' + name + ' Conversion',
figure=fig.to_plotly_json(),
)
)
fig.update_layout(title_text='S-X plot ' + str(i), showlegend=True)
fig.update_xaxes(title_text=name + ' Conversion (%)')
fig.update_yaxes(title_text='Selectivity (%)')
self.figures.append(
PlotlyFigure(
label='S-X plot ' + name + ' Conversion',
figure=fig.to_plotly_json(),
)
)

def normalize_reaction_conditions(
self, archive: 'EntryArchive', logger: 'BoundLogger'
Expand All @@ -1336,15 +1339,16 @@ def normalize_reaction_conditions(
reagents.append(reagent)
self.reaction_conditions.reagents = reagents

if (
self.reaction_conditions.set_total_flow_rate is not None
and self.reactor_filling.catalyst_mass is not None
and self.reaction_conditions.weight_hourly_space_velocity is None
):
self.reaction_conditions.weight_hourly_space_velocity = (
self.reaction_conditions.set_total_flow_rate
/ self.reactor_filling.catalyst_mass
)
if self.reactor_filling is not None:
if (
self.reaction_conditions.set_total_flow_rate is not None
and self.reactor_filling.catalyst_mass is not None
and self.reaction_conditions.weight_hourly_space_velocity is None
):
self.reaction_conditions.weight_hourly_space_velocity = (
self.reaction_conditions.set_total_flow_rate
/ self.reactor_filling.catalyst_mass
)

def return_conversion_results(
self, archive: 'EntryArchive', logger: 'BoundLogger'
Expand Down Expand Up @@ -1377,14 +1381,19 @@ def return_conversion_results(
gas_concentration_out=i.gas_concentration_out,
)
conversions_results.append(react)
if i.gas_concentration_in != j.gas_concentration_in:
if (
np.allclose(
i.gas_concentration_in, j.gas_concentration_in
)
is False
):
logger.warn(f"""Gas concentration of '{i.name}' is not
the same in reaction_conditions and
results.reactants_conversions.""")
return conversions_results

def check_sample(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
if self.samples is not None and self.samples != []:
if self.samples:
if self.samples[0].lab_id is not None and self.samples[0].reference is None:
sample = CompositeSystemReference(
lab_id=self.samples[0].lab_id, name=self.samples[0].name
Expand Down
17 changes: 0 additions & 17 deletions tests/data/test.archive.yaml

This file was deleted.

0 comments on commit 1b7148e

Please sign in to comment.