From 711f48e7c72ec2283c837539d0e34c89c90a0e8b Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Sat, 9 Nov 2024 13:43:49 -0500 Subject: [PATCH 1/3] changed input form --- htm_dashboard/new_property_form.py | 48 ++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/htm_dashboard/new_property_form.py b/htm_dashboard/new_property_form.py index b7a9cc1..5ca2778 100644 --- a/htm_dashboard/new_property_form.py +++ b/htm_dashboard/new_property_form.py @@ -9,11 +9,10 @@ def make_form(property_type: str): pre_exp_label = f"D_0 ({htm.Diffusivity().units:~P})" act_energy_label = "E_D (eV)" elif property_type == "solubility": - sample_prop = htm.Solubility(law="sievert") - pre_exp_label = f"S_0 ({sample_prop.units:~P})" + pre_exp_label = f"S_0 (Sievert: {htm.Solubility(law="sievert").units:~P}, Henry: {htm.Solubility(law='henry').units:~P})" act_energy_label = "E_S (eV)" elif property_type == "permeability": - pre_exp_label = f"P_0 ({htm.Permeability(law='sievert').units:~P})" + pre_exp_label = f"P_0 (Sievert: {htm.Permeability(law='sievert').units:~P}, Henry: {htm.Permeability(law='henry').units:~P})" act_energy_label = "E_P (eV)" elif property_type == "recombination_coeff": pre_exp_label = f"Kr_0 ({htm.RecombinationCoeff().units:~P})" @@ -21,9 +20,10 @@ def make_form(property_type: str): elif property_type == "dissociation_coeff": pre_exp_label = f"Kd_0 ({htm.DissociationCoeff().units:~P})" act_energy_label = "E_Kd (eV)" + preexponential_input = html.Div( [ - dbc.Label(pre_exp_label, width=2), + dbc.Label(pre_exp_label, width=10), dbc.Col( dbc.Input( type="number", @@ -139,15 +139,33 @@ def make_form(property_type: str): ), ], ) - form = dbc.Form( - [ - preexponential_input, - activation_energy_input, - author_input, - year_input, - isotope_input, - material_input, - temperature_input, - ] - ) + + inputs = [ + preexponential_input, + activation_energy_input, + author_input, + year_input, + isotope_input, + material_input, + temperature_input, + ] + if property_type in ["solubility", "permeability"]: + solubility_law_input = html.Div( + [ + dbc.Label("Law", width=2), + dbc.Col( + dbc.RadioItems( + id=f"new_{property_type}_law", + value="sievert", + options=[ + {"label": "Sievert", "value": "sievert"}, + {"label": "Henry", "value": "henry"}, + ], + ), + width=10, + ), + ], + ) + inputs.insert(0, solubility_law_input) + form = dbc.Form(inputs) return form From 75264f964330c4eca5e5b36b39ea0c19797c78f8 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Sat, 9 Nov 2024 13:54:43 -0500 Subject: [PATCH 2/3] add a property now exposes solubility law --- app.py | 54 +++++++++++++++++++++++++++----------- htm_dashboard/callbacks.py | 3 ++- 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/app.py b/app.py index 9267ff0..aaa6c1f 100644 --- a/app.py +++ b/app.py @@ -130,22 +130,44 @@ def toggle_modal(n1, is_open): prevent_initial_call=True, )(cb.make_toggle_modal_function(group)) - app.callback( - dash.Output(f"material_filter_{group}", "options"), - dash.Output(f"author_filter_{group}", "options"), - dash.Output(f"error_message_new_{group}", "children"), - dash.Input(f"submit_new_{group}", "n_clicks"), - dash.Input(f"material_filter_{group}", "value"), - dash.State(f"new_{group}_pre_exp", "value"), - dash.State(f"new_{group}_act_energy", "value"), - dash.State(f"new_{group}_author", "value"), - dash.State(f"new_{group}_year", "value"), - dash.State(f"new_{group}_isotope", "value"), - dash.State(f"new_{group}_material", "value"), - dash.State(f"new_{group}_range_low", "value"), - dash.State(f"new_{group}_range_high", "value"), - prevent_initial_call=True, - )(cb.make_add_property(group)) + # add property form + # since an additional parameter is needed for solubility and permeability + # we need to check the group + if group in ["solubility", "permeability"]: + app.callback( + dash.Output(f"material_filter_{group}", "options"), + dash.Output(f"author_filter_{group}", "options"), + dash.Output(f"error_message_new_{group}", "children"), + dash.Input(f"submit_new_{group}", "n_clicks"), + dash.Input(f"material_filter_{group}", "value"), + dash.State(f"new_{group}_pre_exp", "value"), + dash.State(f"new_{group}_act_energy", "value"), + dash.State(f"new_{group}_author", "value"), + dash.State(f"new_{group}_year", "value"), + dash.State(f"new_{group}_isotope", "value"), + dash.State(f"new_{group}_material", "value"), + dash.State(f"new_{group}_range_low", "value"), + dash.State(f"new_{group}_range_high", "value"), + dash.State(f"new_{group}_law", "value"), + prevent_initial_call=True, + )(cb.make_add_property(group)) + else: + app.callback( + dash.Output(f"material_filter_{group}", "options"), + dash.Output(f"author_filter_{group}", "options"), + dash.Output(f"error_message_new_{group}", "children"), + dash.Input(f"submit_new_{group}", "n_clicks"), + dash.Input(f"material_filter_{group}", "value"), + dash.State(f"new_{group}_pre_exp", "value"), + dash.State(f"new_{group}_act_energy", "value"), + dash.State(f"new_{group}_author", "value"), + dash.State(f"new_{group}_year", "value"), + dash.State(f"new_{group}_isotope", "value"), + dash.State(f"new_{group}_material", "value"), + dash.State(f"new_{group}_range_low", "value"), + dash.State(f"new_{group}_range_high", "value"), + prevent_initial_call=True, + )(cb.make_add_property(group)) app.callback( dash.Output(f"table_{group}", "data"), diff --git a/htm_dashboard/callbacks.py b/htm_dashboard/callbacks.py index 6119e5a..4e048da 100644 --- a/htm_dashboard/callbacks.py +++ b/htm_dashboard/callbacks.py @@ -220,6 +220,7 @@ def add_property( new_material, new_range_low, new_range_high, + new_sol_law=None, ): changed_id = [p["prop_id"] for p in dash.callback_context.triggered][0] if changed_id == f"submit_new_{group}.n_clicks": @@ -244,7 +245,7 @@ def add_property( new_property = htm.Solubility( S_0=new_pre_exp, E_S=new_act_energy, - law="sievert", # TODO expose this (see #68) + law=new_sol_law, ) elif group == "recombination_coeff": new_property = htm.RecombinationCoeff( From 954bc43d7713975281db73308e49e70a38535aa3 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Sat, 9 Nov 2024 14:51:29 -0500 Subject: [PATCH 3/3] fixed strings --- htm_dashboard/new_property_form.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htm_dashboard/new_property_form.py b/htm_dashboard/new_property_form.py index 5ca2778..7651609 100644 --- a/htm_dashboard/new_property_form.py +++ b/htm_dashboard/new_property_form.py @@ -9,7 +9,7 @@ def make_form(property_type: str): pre_exp_label = f"D_0 ({htm.Diffusivity().units:~P})" act_energy_label = "E_D (eV)" elif property_type == "solubility": - pre_exp_label = f"S_0 (Sievert: {htm.Solubility(law="sievert").units:~P}, Henry: {htm.Solubility(law='henry').units:~P})" + pre_exp_label = f"S_0 (Sievert: {htm.Solubility(law='sievert').units:~P}, Henry: {htm.Solubility(law='henry').units:~P})" act_energy_label = "E_S (eV)" elif property_type == "permeability": pre_exp_label = f"P_0 (Sievert: {htm.Permeability(law='sievert').units:~P}, Henry: {htm.Permeability(law='henry').units:~P})"