mirror of
https://github.com/ANL-CEEESA/LLEPE.git
synced 2025-12-06 09:58:52 -06:00
Added r-squared printout to parity plot. Fixed default optimizer to detect number of dimensions and update bounds to match.
This commit is contained in:
2
.idea/dictionaries/Titus.xml
generated
2
.idea/dictionaries/Titus.xml
generated
@@ -3,6 +3,7 @@
|
||||
<words>
|
||||
<w>coeffs</w>
|
||||
<w>conc</w>
|
||||
<w>csvs</w>
|
||||
<w>diluant</w>
|
||||
<w>disp</w>
|
||||
<w>dodecane</w>
|
||||
@@ -18,6 +19,7 @@
|
||||
<w>scipy</w>
|
||||
<w>slsqp</w>
|
||||
<w>thermo</w>
|
||||
<w>xmls</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
</component>
|
||||
89
.idea/workspace.xml
generated
89
.idea/workspace.xml
generated
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="f4439dc0-6756-4612-8f7d-596d8949f300" name="Default Changelist" comment="Modified reeps to grab charge from REE in xml file for initial chlorine moles calculation">
|
||||
<list default="true" id="f4439dc0-6756-4612-8f7d-596d8949f300" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/dictionaries/Titus.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dictionaries/Titus.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/data/xmls/twophase.xml" beforeDir="false" afterPath="$PROJECT_DIR$/data/xmls/twophase.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/docs/Examples/1_getting_started.ipynb" beforeDir="false" afterPath="$PROJECT_DIR$/docs/Examples/1_getting_started.ipynb" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/reeps.py" beforeDir="false" afterPath="$PROJECT_DIR$/reeps.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/tests/test_reeps.py" beforeDir="false" afterPath="$PROJECT_DIR$/tests/test_reeps.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -37,17 +37,20 @@
|
||||
<property name="run.code.analysis.last.selected.profile" value="aDefault" />
|
||||
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
|
||||
</component>
|
||||
<component name="RunManager" selected="Python.li_data_transformer">
|
||||
<configuration name="li_data_transformer" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<component name="RunManager" selected="Python.li_data_fit">
|
||||
<configuration name="formatting_methods" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<module name="parameter-estimation" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/../../anl_box/Box Sync/titus/one_rare_earth_fit" />
|
||||
<option name="IS_MODULE_SDK" value="false" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/../../anl_box/Box Sync/titus/one_rare_earth_fit/li_data_transformer.py" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/../../anl_box/Box Sync/titus/one_rare_earth_fit/formatting_methods.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="true" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
@@ -56,7 +59,7 @@
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="reeps" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<configuration name="gensurfdata" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<module name="parameter-estimation" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
@@ -64,11 +67,11 @@
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/../../anl_box/Box Sync/titus/onboarding/codes/multi/1_fit/01_Surface/2_linearfits" />
|
||||
<option name="IS_MODULE_SDK" value="false" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/reeps.py" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/../../anl_box/Box Sync/titus/onboarding/codes/multi/1_fit/01_Surface/2_linearfits/gensurfdata.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
@@ -77,21 +80,18 @@
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="test1" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<configuration name="li_data_fit" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<module name="parameter-estimation" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/tests" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/../../anl_box/Box Sync/titus/one_rare_earth_fit" />
|
||||
<option name="IS_MODULE_SDK" value="false" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/tests/test1.py" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/../../anl_box/Box Sync/titus/one_rare_earth_fit/li_data_fit.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="SHOW_COMMAND_LINE" value="true" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
@@ -102,6 +102,9 @@
|
||||
<module name="parameter-estimation" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/tests" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
@@ -132,11 +135,11 @@
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Python.li_data_transformer" />
|
||||
<item itemvalue="Python.li_data_transformer" />
|
||||
<item itemvalue="Python.test_reeps" />
|
||||
<item itemvalue="Python.reeps" />
|
||||
<item itemvalue="Python.test_reeps" />
|
||||
<item itemvalue="Python.li_data_fit" />
|
||||
<item itemvalue="Python.li_data_fit" />
|
||||
<item itemvalue="Python.formatting_methods" />
|
||||
<item itemvalue="Python.formatting_methods" />
|
||||
<item itemvalue="Python.li_data_fit" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
@@ -222,7 +225,14 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1591209082779</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="9" />
|
||||
<task id="LOCAL-00009" summary="Allow user to change optimizer and objective function. Also added r-squared evaluator. Changed temp file location to user temp folder. Added a prediction dictionary to access the values predicted by model.">
|
||||
<created>1591388459379</created>
|
||||
<option name="number" value="00009" />
|
||||
<option name="presentableId" value="LOCAL-00009" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1591388459379</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="10" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
@@ -242,7 +252,8 @@
|
||||
<MESSAGE value="started project" />
|
||||
<MESSAGE value="Completed one composition parameter estimation" />
|
||||
<MESSAGE value="Modified reeps to grab charge from REE in xml file for initial chlorine moles calculation" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Modified reeps to grab charge from REE in xml file for initial chlorine moles calculation" />
|
||||
<MESSAGE value="Allow user to change optimizer and objective function. Also added r-squared evaluator. Changed temp file location to user temp folder. Added a prediction dictionary to access the values predicted by model." />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Allow user to change optimizer and objective function. Also added r-squared evaluator. Changed temp file location to user temp folder. Added a prediction dictionary to access the values predicted by model." />
|
||||
</component>
|
||||
<component name="WindowStateProjectService">
|
||||
<state x="-1330" y="212" key="#Inspections" timestamp="1590787654691">
|
||||
@@ -261,10 +272,11 @@
|
||||
<screen x="-1920" y="2" width="1920" height="1040" />
|
||||
</state>
|
||||
<state x="-1213" y="379" key="ANALYSIS_DLG_com.intellij.analysis.BaseAnalysisAction$1/0.0.1536.824/-1920.2.1920.1040@-1920.2.1920.1040" timestamp="1590787657711" />
|
||||
<state x="-1364" y="117" key="CommitChangelistDialog2" timestamp="1591212137077">
|
||||
<screen x="-1920" y="2" width="1920" height="1040" />
|
||||
<state x="556" y="115" key="CommitChangelistDialog2" timestamp="1591388457261">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
<state x="-1364" y="117" key="CommitChangelistDialog2/0.0.1536.824/-1920.2.1920.1040@-1920.2.1920.1040" timestamp="1591212137077" />
|
||||
<state x="556" y="115" key="CommitChangelistDialog2/0.0.1920.1040@0.0.1920.1040" timestamp="1591388457261" />
|
||||
<state x="-1828" y="94" width="1736" height="856" key="DiffContextDialog" timestamp="1591048879404">
|
||||
<screen x="-1920" y="2" width="1920" height="1040" />
|
||||
</state>
|
||||
@@ -273,30 +285,30 @@
|
||||
<screen x="-1920" y="2" width="1920" height="1040" />
|
||||
</state>
|
||||
<state x="-1180" y="278" key="FileChooserDialogImpl/0.0.1536.824/-1920.2.1920.1040@-1920.2.1920.1040" timestamp="1590786964173" />
|
||||
<state width="949" height="281" key="GridCell.Tab.0.bottom" timestamp="1591385857254">
|
||||
<state width="1899" height="281" key="GridCell.Tab.0.bottom" timestamp="1591403861494">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
<state width="1899" height="281" key="GridCell.Tab.0.bottom/0.0.1536.824/-1920.2.1920.1040@-1920.2.1920.1040" timestamp="1591310049025" />
|
||||
<state width="1897" height="281" key="GridCell.Tab.0.bottom/0.0.1536.824/-1920.2.1920.1040@0.0.1536.824" timestamp="1590795386435" />
|
||||
<state width="949" height="281" key="GridCell.Tab.0.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1591385857254" />
|
||||
<state width="949" height="281" key="GridCell.Tab.0.center" timestamp="1591385857254">
|
||||
<state width="1899" height="281" key="GridCell.Tab.0.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1591403861494" />
|
||||
<state width="1899" height="281" key="GridCell.Tab.0.center" timestamp="1591403861493">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
<state width="1899" height="281" key="GridCell.Tab.0.center/0.0.1536.824/-1920.2.1920.1040@-1920.2.1920.1040" timestamp="1591310049023" />
|
||||
<state width="1897" height="281" key="GridCell.Tab.0.center/0.0.1536.824/-1920.2.1920.1040@0.0.1536.824" timestamp="1590795386434" />
|
||||
<state width="949" height="281" key="GridCell.Tab.0.center/0.0.1920.1040@0.0.1920.1040" timestamp="1591385857254" />
|
||||
<state width="949" height="281" key="GridCell.Tab.0.left" timestamp="1591385857253">
|
||||
<state width="1899" height="281" key="GridCell.Tab.0.center/0.0.1920.1040@0.0.1920.1040" timestamp="1591403861493" />
|
||||
<state width="1899" height="281" key="GridCell.Tab.0.left" timestamp="1591403861491">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
<state width="1899" height="281" key="GridCell.Tab.0.left/0.0.1536.824/-1920.2.1920.1040@-1920.2.1920.1040" timestamp="1591310049022" />
|
||||
<state width="1897" height="281" key="GridCell.Tab.0.left/0.0.1536.824/-1920.2.1920.1040@0.0.1536.824" timestamp="1590795386433" />
|
||||
<state width="949" height="281" key="GridCell.Tab.0.left/0.0.1920.1040@0.0.1920.1040" timestamp="1591385857253" />
|
||||
<state width="949" height="281" key="GridCell.Tab.0.right" timestamp="1591385857254">
|
||||
<state width="1899" height="281" key="GridCell.Tab.0.left/0.0.1920.1040@0.0.1920.1040" timestamp="1591403861491" />
|
||||
<state width="1899" height="281" key="GridCell.Tab.0.right" timestamp="1591403861493">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
<state width="1899" height="281" key="GridCell.Tab.0.right/0.0.1536.824/-1920.2.1920.1040@-1920.2.1920.1040" timestamp="1591310049024" />
|
||||
<state width="1897" height="281" key="GridCell.Tab.0.right/0.0.1536.824/-1920.2.1920.1040@0.0.1536.824" timestamp="1590795386434" />
|
||||
<state width="949" height="281" key="GridCell.Tab.0.right/0.0.1920.1040@0.0.1920.1040" timestamp="1591385857254" />
|
||||
<state width="1899" height="281" key="GridCell.Tab.0.right/0.0.1920.1040@0.0.1920.1040" timestamp="1591403861493" />
|
||||
<state x="-1460" y="164" key="SettingsEditor" timestamp="1590784300386">
|
||||
<screen x="-1920" y="2" width="1920" height="1040" />
|
||||
</state>
|
||||
@@ -305,12 +317,12 @@
|
||||
<screen x="-1920" y="2" width="1920" height="1040" />
|
||||
</state>
|
||||
<state x="-1368" y="256" key="Vcs.Push.Dialog.v2/0.0.1536.824/-1920.2.1920.1040@-1920.2.1920.1040" timestamp="1591047662716" />
|
||||
<state x="579" y="298" key="com.intellij.ide.util.TipDialog" timestamp="1591365504454">
|
||||
<state x="579" y="298" key="com.intellij.ide.util.TipDialog" timestamp="1591627942552">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
<state x="-1341" y="300" key="com.intellij.ide.util.TipDialog/0.0.1536.824/-1920.2.1920.1040@-1920.2.1920.1040" timestamp="1591192469960" />
|
||||
<state x="463" y="236" key="com.intellij.ide.util.TipDialog/0.0.1536.824/-1920.2.1920.1040@0.0.1536.824" timestamp="1590784072879" />
|
||||
<state x="579" y="298" key="com.intellij.ide.util.TipDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1591365504454" />
|
||||
<state x="579" y="298" key="com.intellij.ide.util.TipDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1591627942552" />
|
||||
<state x="769" y="438" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2" timestamp="1591037545358">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
@@ -319,10 +331,11 @@
|
||||
<screen x="-1920" y="2" width="1920" height="1040" />
|
||||
</state>
|
||||
<state x="-1219" y="166" key="refactoring.ChangeSignatureDialog/0.0.1536.824/-1920.2.1920.1040@-1920.2.1920.1040" timestamp="1591059193684" />
|
||||
<state x="-1297" y="227" width="672" height="678" key="search.everywhere.popup" timestamp="1591113024379">
|
||||
<screen x="-1920" y="2" width="1920" height="1040" />
|
||||
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup" timestamp="1591393246078">
|
||||
<screen x="0" y="0" width="1920" height="1040" />
|
||||
</state>
|
||||
<state x="-1297" y="227" width="672" height="678" key="search.everywhere.popup/0.0.1536.824/-1920.2.1920.1040@-1920.2.1920.1040" timestamp="1591113024379" />
|
||||
<state x="623" y="225" width="672" height="678" key="search.everywhere.popup/0.0.1920.1040@0.0.1920.1040" timestamp="1591393246078" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
|
||||
12
README.md
12
README.md
@@ -1,5 +1,5 @@
|
||||
# REEPS
|
||||
REEPS is a toolkit for estimating standard thermodynamic parameters for Gibbs minimization.
|
||||
REEPS (Rare Earth Element Parameter Searcher) is a toolkit for estimating standard thermodynamic parameters for Gibbs minimization.
|
||||
Extend a methodology for estimating standard thermodynamic parameters for Gibbs minimization in multiphase, multicomponent separations systems
|
||||
|
||||
|
||||
@@ -23,4 +23,12 @@ $ pip install -e.
|
||||
REEPS uses packages: cantera (https://cantera.org/), pandas, numpy, scipy, xml, seaborn, and matplotlib
|
||||
|
||||
## Usage
|
||||
Do random stuff and pray.
|
||||
Check out examples in docs/examples
|
||||
```python
|
||||
from reeps import REEPS
|
||||
searcher = REEPS(**REEPS_parameters_dictionary)
|
||||
optimized_parameter_dictionary = searcher.fit()
|
||||
searcher.update_xml(optimized_parameter_dictionary)
|
||||
searcher.parity_plot()
|
||||
print(seacher.r_squared())
|
||||
```
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<const_cp Tmax="300.0" Tmin="298.0">
|
||||
<t0 units="K">298.14999999999998</t0>
|
||||
|
||||
<h0 units="J/mol" updated="Updated at 14:15 6-5-2020">-4704703.645715787</h0>
|
||||
<h0 units="J/mol" updated="Updated at 14:33 6-5-2020">-4704699.156668724</h0>
|
||||
<s0 units="J/mol/K"> 1117.965 </s0>
|
||||
<cp0 units="J/mol/K">0.0</cp0>
|
||||
</const_cp>
|
||||
|
||||
File diff suppressed because one or more lines are too long
41
reeps.py
41
reeps.py
@@ -11,8 +11,9 @@ import shutil
|
||||
import copy
|
||||
from inspect import signature
|
||||
import os
|
||||
sns.set()
|
||||
|
||||
sns.set()
|
||||
sns.set(font_scale=1.6)
|
||||
|
||||
class REEPS:
|
||||
"""REEPS (Rare earth extraction parameter searcher)
|
||||
@@ -113,7 +114,7 @@ class REEPS:
|
||||
|
||||
@staticmethod
|
||||
def log_mean_squared_error(predicted_dict, meas_df):
|
||||
meas = meas_df['D(m)'].values
|
||||
meas = meas_df.values[:, 2]
|
||||
pred = predicted_dict['re_org'] / predicted_dict['re_aq']
|
||||
log_pred = np.log10(pred)
|
||||
log_meas = np.log10(meas)
|
||||
@@ -123,7 +124,7 @@ class REEPS:
|
||||
@staticmethod
|
||||
def slsqp_optimizer(objective, x_guess):
|
||||
optimizer_kwargs = {"method": 'SLSQP',
|
||||
"bounds": [(1e-1, 1e1) * len(x_guess)],
|
||||
"bounds": [(1e-1, 1e1)] * len(x_guess),
|
||||
"constraints": (),
|
||||
"options": {'disp': True, 'maxiter': 1000, 'ftol': 1e-6}}
|
||||
res = minimize(objective, x_guess, **optimizer_kwargs)
|
||||
@@ -400,7 +401,8 @@ class REEPS:
|
||||
for _ in opt_dict[species_name].keys():
|
||||
i += 1
|
||||
x = np.array(x)
|
||||
if i == len(x.shape):
|
||||
|
||||
if len(x.shape) == 1:
|
||||
xs = np.array([x])
|
||||
vectorized_x = False
|
||||
else:
|
||||
@@ -449,11 +451,9 @@ class REEPS:
|
||||
|
||||
optimizer = self._optimizer
|
||||
opt_dict = copy.deepcopy(self._opt_dict)
|
||||
# x_guess = []
|
||||
i = 0
|
||||
for species_name in opt_dict.keys():
|
||||
for _ in opt_dict[species_name].keys():
|
||||
# x_guess.append(opt_dict[species_name][thermo_prop])
|
||||
i += 1
|
||||
x_guess = np.ones(i)
|
||||
|
||||
@@ -504,7 +504,8 @@ class REEPS:
|
||||
self.set_phases(self._phases_xml_filename, self._phase_names)
|
||||
return None
|
||||
|
||||
def parity_plot(self, species='re_aq'):
|
||||
# noinspection PyUnusedLocal
|
||||
def parity_plot(self, species='re_aq', save_path=None, print_r_squared=False):
|
||||
"""Parity plot between measured and predicted rare earth composition"""
|
||||
phases_copy = self._phases.copy()
|
||||
mix = ct.Mixture(phases_copy)
|
||||
@@ -520,16 +521,32 @@ class REEPS:
|
||||
aq_ind, rare_earth_ion_name)]
|
||||
pred.append(re_aq)
|
||||
pred = np.array(pred)
|
||||
meas = exp_df['REeq(m)'].values
|
||||
meas = exp_df.values[:, 1]
|
||||
min_data = np.min([pred, meas])
|
||||
max_data = np.max([pred, meas])
|
||||
min_max_data = np.array([min_data, max_data])
|
||||
fig, ax = plt.subplots()
|
||||
sns.scatterplot(meas, pred, color="r",
|
||||
label="Rare earth equilibrium concentration (mol/L)")
|
||||
sns.lineplot(min_max_data, min_max_data, color="b", label="")
|
||||
re_element = ''
|
||||
n_plus = 0
|
||||
for char in self._rare_earth_ion_name:
|
||||
if char.isalpha():
|
||||
re_element = '{0}{1}'.format(re_element, char)
|
||||
else:
|
||||
n_plus += 1
|
||||
re_ion_name = '$%s^{%d+}$' % (re_element, n_plus)
|
||||
p1 = sns.scatterplot(meas, pred, color="r",
|
||||
label="{0} eq. conc. (mol/L)".format(re_ion_name),
|
||||
legend=False)
|
||||
p2 = sns.lineplot(min_max_data, min_max_data, color="b", label="")
|
||||
if print_r_squared:
|
||||
p1.text(min_max_data[0], min_max_data[1]*0.9, '$R^2$={0:.2f}'.format(self.r_squared()))
|
||||
plt.legend(loc='lower right')
|
||||
else:
|
||||
plt.legend()
|
||||
ax.set(xlabel='Measured', ylabel='Predicted')
|
||||
plt.show()
|
||||
if save_path is not None:
|
||||
plt.savefig(save_path, bbox_inches='tight')
|
||||
return None
|
||||
|
||||
def r_squared(self):
|
||||
@@ -548,7 +565,7 @@ class REEPS:
|
||||
aq_ind, rare_earth_ion_name)]
|
||||
pred.append(re_aq)
|
||||
predicted_y = np.array(pred)
|
||||
actual_y = exp_df['REeq(m)'].values
|
||||
actual_y = exp_df.values[:, 1]
|
||||
num = sum((actual_y - predicted_y) ** 2)
|
||||
den = sum((actual_y - np.mean(actual_y)) ** 2)
|
||||
r_2 = (1 - num / den)
|
||||
|
||||
Reference in New Issue
Block a user