def test_properties_substance_from_reaction(self): reacLit2 = '''{ "TPMethods":[ { "dr_ryzhenko_coeffs":{ "values":[ 3.61, 1.563, -193.7 ] }, "method":{ "10":"solute_eos_ryzhenko_gems" } } ], "datasources":"Migdisov et al., 2016", "equation":"LaSO4+_mi = La+3 + SO4-2", "symbol":"LaSO4+_mi" }''' substLit2 = '''{ "symbol": "LaSO4+_mi", "formula": "LaSO4+", "reaction": "LaSO4+_mi" }''' db = thermofun.Database('pytests/mines16-sub-thermofun.json') db.addReaction(reacLit2) db.addSubstance(substLit2) engine3 = thermofun.ThermoEngine(db) assert engine3.thermoPropertiesSubstance(473.15, 0, "LaSO4+_mi").gibbs_energy.val == pytest.approx(-1426099.716850813, 1e-5, 1e-14) assert engine3.thermoPropertiesSubstance(473.15, 0, "LaSO4+_mi").volume.val == pytest.approx(-1.883700250726727, 1e-5, 1e-14) assert engine3.thermoPropertiesSubstance(473.15, 0, "LaSO4+_mi").entropy.val == pytest.approx(-168.47492835119232, 1e-5, 1e-14)
def on_dropdown_change(change): if change['name'] == 'value' and (change['new'] != change['old']): global db_file origin.disabled = True button.disabled = True db_file = change['new'] global database try: database = fun.Database(db_file) reaction_equations = [] for r in database.mapReactions().values(): reaction_equations.append(r.equation()) dfSelectReact[db_file] = multi_checkbox_widget( database.mapReactions(), [ "logKr", "reaction_gibbs_energy", "reaction_enthalpy", "reaction_entropy", "reaction_heat_capacity_cp", "reaction_volume" ], reaction_equations) dfSelectSubst[db_file] = multi_checkbox_widget( database.mapSubstances(), [ "gibbs_energy", "enthalpy", "entropy", "heat_capacity_cp", "volume" ]) dfInputReact[db_file] = input_reactions_widget( database.mapSubstances(), [ "logKr", "reaction_gibbs_energy", "reaction_enthalpy", "reaction_entropy", "reaction_heat_capacity_cp", "reaction_volume" ]) # select_subst_n = multi_checkbox_widget(database.mapSubstances()) # select_react_n = multi_checkbox_widget(database.mapReactions()) # select_subst.children = dfSelectSubst[db_file].children # select_react.children = dfSelectReact[db_file].children #ndx = copy.deepcopy(tabs.selected_index) tabs_new = make_tabs_3( dfSelectSubst[db_file], dfSelectReact[db_file], dfInputReact[db_file], ['Substances', 'Reactions', 'Write Reactions']) tabs.children = tabs_new.children #tabs.selected_index=ndx with plot_out: clear_output() with plot3d_out: clear_output() with table_out: clear_output() except Exception as e: with status_out: clear_output(wait=True) print(e) origin.disabled = False button.disabled = False
def on_button_clicked(b): for i, f in enumerate(files): progress.value = i+1 dfDatabase[f] = fun.Database(f) reaction_equations = [] for r in dfDatabase[f].mapReactions().values(): reaction_equations.append(r.equation()) dfSelectSubst[f] = multi_checkbox_widget(dfDatabase[f].mapSubstances(), ["gibbs_energy","enthalpy","entropy","heat_capacity_cp","volume"]) dfSelectReact[f] = multi_checkbox_widget(dfDatabase[f].mapReactions(), ["logKr", "reaction_gibbs_energy","reaction_enthalpy","reaction_entropy","reaction_heat_capacity_cp", "reaction_volume"], reaction_equations) progress.value = i+1 #time.sleep(0.1) with data_out: clear_output(wait=True) load_widgets(dfDatabase, dfSelectSubst, dfSelectReact)
def setUp(self): self.database = thermofun.Database( 'pytests/test-database-thermofun.json')
def initialize_widgets(): dfDatabase = {} dfSelectSubst = {} dfSelectReact = {} dfInputReact = {} # global progress # hbox=widgets.HBox(children=[progress]) # with progress_out: # #display(widgets.IntSlider()) # display(hbox) # display(progress_out) # def on_button_clicked(b): # for i, f in enumerate(files): # progress.value = i+1 # dfDatabase[f] = fun.Database(f) # reaction_equations = [] # for r in dfDatabase[f].mapReactions().values(): # reaction_equations.append(r.equation()) # dfSelectSubst[f] = multi_checkbox_widget(dfDatabase[f].mapSubstances(), ["gibbs_energy","enthalpy","entropy","heat_capacity_cp","volume"]) # dfSelectReact[f] = multi_checkbox_widget(dfDatabase[f].mapReactions(), ["logKr", "reaction_gibbs_energy","reaction_enthalpy","reaction_entropy","reaction_heat_capacity_cp", "reaction_volume"], # reaction_equations) # progress.value = i+1 # #time.sleep(0.1) # with data_out: # clear_output(wait=True) # load_widgets(dfDatabase, dfSelectSubst, dfSelectReact) # button.on_click(on_button_clicked) global db_file try: database = fun.Database(db_file) reaction_equations = [] for r in database.mapReactions().values(): reaction_equations.append(r.equation()) dfSelectReact[db_file] = multi_checkbox_widget( database.mapReactions(), [ "logKr", "reaction_gibbs_energy", "reaction_enthalpy", "reaction_entropy", "reaction_heat_capacity_cp", "reaction_volume" ], reaction_equations) dfSelectSubst[db_file] = multi_checkbox_widget( database.mapSubstances(), [ "gibbs_energy", "enthalpy", "entropy", "heat_capacity_cp", "volume" ]) dfInputReact[db_file] = input_reactions_widget( database.mapSubstances(), [ "logKr", "reaction_gibbs_energy", "reaction_enthalpy", "reaction_entropy", "reaction_heat_capacity_cp", "reaction_volume" ]) except Exception as e: with progress_out: clear_output(wait=True) print(e) load_widgets(dfDatabase, dfSelectSubst, dfSelectReact, dfInputReact)