changed REEPS name to LLEPE, modified opt_dict to deal with more general xml properties,

This commit is contained in:
titusquah
2020-07-14 09:03:00 -06:00
parent 97ca231afc
commit 0a9a7ffddc
10 changed files with 3755 additions and 0 deletions

0
tests/__init__.py Normal file
View File

59
tests/data_gen.py Normal file
View File

@@ -0,0 +1,59 @@
from llepe import LLEPE
import json
opt_dict = {'(HA)2(org)_h0': {'upper_element_name': 'species',
'upper_attrib_name': 'name',
'upper_attrib_value': 'Nd(H(A)2)3(org)',
'lower_element_name': 'h0',
'lower_attrib_name': None,
'lower_attrib_value': None,
'input_format': '{0}',
'input_value': -4.7e6}}
searcher_parameters = {'exp_data': 'Nd_exp_data.csv',
'phases_xml_filename':
'twophase.xml',
'opt_dict': opt_dict,
'phase_names': ['HCl_electrolyte',
'PC88A_liquid'],
'aq_solvent_name': 'H2O(L)',
'extractant_name': '(HA)2(org)',
'diluant_name': 'dodecane',
'complex_names':
['Nd(H(A)2)3(org)'],
'extracted_species_ion_names': ['Nd+++'],
'aq_solvent_rho': 1000.0,
'extractant_rho': 960.0,
'diluant_rho': 750.0,
'temp_xml_file_path': 'temp1.xml'}
searcher = LLEPE(**searcher_parameters)
searcher.update_xml(searcher_parameters['opt_dict'])
predicted_dict1 = searcher.get_predicted_dict()
def array_to_list_in_dict(dictionary):
new_dictionary = {}
for key, value in dictionary.items():
new_dictionary[key] = list(value)
return new_dictionary
predicted_dict1 = array_to_list_in_dict(predicted_dict1)
in_moles = searcher.get_in_moles().to_dict('list')
est_enthalpy, obj_value = searcher.fit()
searcher.update_xml(est_enthalpy)
predicted_dict2 = searcher.get_predicted_dict()
predicted_dict2 = array_to_list_in_dict(predicted_dict2)
r2 = searcher.r_squared()
validation_values = {'predicted_dict1': predicted_dict1,
'in_moles': in_moles,
'est_enthalpy': est_enthalpy,
'predicted_dict2': predicted_dict2,
'r2': r2}
with open("validation_values.txt", "w") as write_file:
json.dump(validation_values, write_file)
with open("validation_parameters.txt", 'w') as write_file:
json.dump(searcher_parameters, write_file)
print(r2)

View File

@@ -0,0 +1 @@
{"exp_data": "Nd_exp_data.csv", "phases_xml_filename": "twophase.xml", "opt_dict": {"(HA)2(org)_h0": {"upper_element_name": "species", "upper_attrib_name": "name", "upper_attrib_value": "Nd(H(A)2)3(org)", "lower_element_name": "h0", "lower_attrib_name": null, "lower_attrib_value": null, "input_format": "{0}", "input_value": -4700000.0}}, "phase_names": ["HCl_electrolyte", "PC88A_liquid"], "aq_solvent_name": "H2O(L)", "extractant_name": "(HA)2(org)", "diluant_name": "dodecane", "complex_names": ["Nd(H(A)2)3(org)"], "extracted_species_ion_names": ["Nd+++"], "aq_solvent_rho": 1000.0, "extractant_rho": 960.0, "diluant_rho": 750.0, "temp_xml_file_path": "C:/Users/tq220/AppData/Local/Temp/temp1.xml"}

View File

@@ -0,0 +1 @@
{"predicted_dict1": {"h_eq": [0.058364995714349444, 0.06391393155745115, 0.07444535507983865, 0.08262581542999746, 0.09476518930810575], "z_eq": [0.9516350042860701, 0.9460860684430508, 0.9355546449206639, 0.9273741845705067, 0.9152348106924012], "Nd_aq_eq": [0.03387952476202338, 0.08202671948101695, 0.12852391497355461, 0.17579539485683557, 0.27175642689746715], "Nd_org_eq": [0.01612166523797662, 0.017971310518983034, 0.021481785026445446, 0.02420860514316445, 0.02825506310253288], "Nd_d_eq": [0.4758527562360585, 0.21909093320673453, 0.16714231768356566, 0.13770898357650085, 0.1039720142964399]}, "in_moles": {"H2O(L)": [55.508435061791985, 55.508435061791985, 55.508435061791985, 55.508435061791985, 55.508435061791985], "H+": [0.01, 0.01, 0.01, 0.01, 0.01], "OH-": [0, 0, 0, 0, 0], "Cl-": [0.16000357, 0.30999409, 0.46001709999999996, 0.610012, 0.91003447], "Nd+++": [0.05000119, 0.09999803, 0.1500057, 0.200004, 0.30001149], "(HA)2(org)": [1.0, 1.0, 1.0, 1.0, 1.0], "dodecane": [2.997650493879708, 2.997650493879708, 2.997650493879708, 2.997650493879708, 2.997650493879708], "Nd(H(A)2)3(org)": [0.0, 0.0, 0.0, 0.0, 0.0]}, "est_enthalpy": {"(HA)2(org)_h0": {"upper_element_name": "species", "upper_attrib_name": "name", "upper_attrib_value": "Nd(H(A)2)3(org)", "lower_element_name": "h0", "lower_attrib_name": null, "lower_attrib_value": null, "input_format": "{0}", "input_value": -4704699.156668724}}, "predicted_dict2": {"h_eq": [0.08312070532256348, 0.09366629837883175, 0.10990341965038186, 0.12241262392184332, 0.14084968554653704], "z_eq": [0.9268792946777146, 0.9163337016214961, 0.900096580349945, 0.8875873760784844, 0.8691503144537928], "Nd_aq_eq": [0.025627621559238152, 0.07210926387383204, 0.11670456011664825, 0.1625331253594948, 0.25639492815126425], "Nd_org_eq": [0.02437356844076186, 0.027888766126168002, 0.033301139883351746, 0.03747087464050526, 0.04361656184873576], "Nd_d_eq": [0.9510663478630839, 0.38675704934340127, 0.2853456613012094, 0.23054300197345157, 0.1701147607062004]}, "r2": 0.9970803631106648}